diff --git a/dist/bundle.js b/dist/bundle.js index 79b0d49..bb06d73 100644 --- a/dist/bundle.js +++ b/dist/bundle.js @@ -1,4 +1,4 @@ -function e(e,t){return t.forEach(function(t){t&&"string"!=typeof t&&!Array.isArray(t)&&Object.keys(t).forEach(function(i){if("default"!==i&&!(i in e)){var r=Object.getOwnPropertyDescriptor(t,i);Object.defineProperty(e,i,r.get?r:{enumerable:!0,get:function(){return t[i]}})}})}),Object.freeze(e)}function t(){}function i(e,t){for(const i in t)e[i]=t[i];return e}function r(e){return e()}function n(){return Object.create(null)}function o(e){e.forEach(r)}function s(e){return"function"==typeof e}function a(e,t){return e!=e?t==t:e!==t||e&&"object"==typeof e||"function"==typeof e}function l(e,i,r){e.$$.on_destroy.push(function(e,...i){if(null==e)return t;const r=e.subscribe(...i);return r.unsubscribe?()=>r.unsubscribe():r}(i,r))}function c(e,t,i,r){if(e){const n=u(e,t,i,r);return e[0](n)}}function u(e,t,r,n){return e[1]&&n?i(r.ctx.slice(),e[1](n(t))):r.ctx}function h(e,t,i,r){if(e[2]&&r){const n=e[2](r(i));if(void 0===t.dirty)return n;if("object"==typeof n){const e=[],i=Math.max(t.dirty.length,n.length);for(let r=0;r32){const t=[],i=e.ctx.length/32;for(let e=0;ee.removeEventListener(t,i,r)}function S(e,t,i){null==i?e.removeAttribute(t):e.getAttribute(t)!==i&&e.setAttribute(t,i)}function I(e){return""===e?null:+e}function M(e,t){t=""+t,e.data!==t&&(e.data=t)}function P(e,t){e.value=null==t?"":t}function R(e,t,i,r){null==i?e.style.removeProperty(t):e.style.setProperty(t,i,r?"important":"")}function F(e,t,i){for(let i=0;i{const n=e.$$.callbacks[t];if(n){const o=function(e,t,{bubbles:i=!1,cancelable:r=!1}={}){const n=document.createEvent("CustomEvent");return n.initCustomEvent(e,i,r,t),n}(t,i,{cancelable:r});return n.slice().forEach(t=>{t.call(e,o)}),!o.defaultPrevented}return!0}}function Q(e,t){const i=e.$$.callbacks[t.type];i&&i.slice().forEach(e=>e.call(this,t))}const $=[],Z=[];let W=[];const q=[],K=Promise.resolve();let X=!1;function J(){X||(X=!0,K.then(ie))}function Y(e){W.push(e)}const ee=new Set;let te=0;function ie(){if(0!==te)return;const e=D;do{try{for(;te<$.length;){const e=$[te];te++,N(e),re(e.$$)}}catch(e){throw $.length=0,te=0,e}for(N(null),$.length=0,te=0;Z.length;)Z.pop()();for(let e=0;e{ne.delete(e),r&&(i&&e.d(1),r())}),e.o(t)}else r&&r()}function ue(e,t){const i={},r={},n={$$scope:1};let o=e.length;for(;o--;){const s=e[o],a=t[o];if(a){for(const e in s)e in a||(r[e]=1);for(const e in a)n[e]||(i[e]=a[e],n[e]=1);e[o]=a}else for(const e in s)n[e]=1}for(const e in r)e in i||(i[e]=void 0);return i}function he(e){return"object"==typeof e&&null!==e?e:{}}function de(e){e&&e.c()}function pe(e,t,i,n){const{fragment:a,after_update:l}=e.$$;a&&a.m(t,i),n||Y(()=>{const t=e.$$.on_mount.map(r).filter(s);e.$$.on_destroy?e.$$.on_destroy.push(...t):o(t),e.$$.on_mount=[]}),l.forEach(Y)}function fe(e,t){const i=e.$$;null!==i.fragment&&(!function(e){const t=[],i=[];W.forEach(r=>-1===e.indexOf(r)?t.push(r):i.push(r)),i.forEach(e=>e()),W=t}(i.after_update),o(i.on_destroy),i.fragment&&i.fragment.d(t),i.on_destroy=i.fragment=null,i.ctx=[])}function me(e,i,r,s,a,l,c,u=[-1]){const h=D;N(e);const d=e.$$={fragment:null,ctx:[],props:l,update:t,not_equal:a,bound:n(),on_mount:[],on_destroy:[],on_disconnect:[],before_update:[],after_update:[],context:new Map(i.context||(h?h.$$.context:[])),callbacks:n(),dirty:u,skip_bound:!1,root:i.target||h.$$.root};c&&c(d.root);let p=!1;if(d.ctx=r?r(e,i.props||{},(t,i,...r)=>{const n=r.length?r[0]:i;return d.ctx&&a(d.ctx[t],d.ctx[t]=n)&&(!d.skip_bound&&d.bound[t]&&d.bound[t](n),p&&function(e,t){-1===e.$$.dirty[0]&&($.push(e),J(),e.$$.dirty.fill(0)),e.$$.dirty[t/31|0]|=1<{const e=r.indexOf(i);-1!==e&&r.splice(e,1)}}$set(e){var t;this.$$set&&(t=e,0!==Object.keys(t).length)&&(this.$$.skip_bound=!0,this.$$set(e),this.$$.skip_bound=!1)}}const _e="[object RegExp]",Ae="[object String]",ye="[object Number]",ve="[object Boolean]",xe="[object Arguments]",be="[object Symbol]",we="[object Date]",Te="[object Map]",Ee="[object Set]",Ce="[object Array]",Be="[object ArrayBuffer]",Se="[object Object]",Ie="[object DataView]",Me="[object Uint8Array]",Pe="[object Uint8ClampedArray]",Re="[object Uint16Array]",Le="[object Uint32Array]",Fe="[object Int8Array]",ke="[object Int16Array]",De="[object Int32Array]",Oe="[object Float32Array]",ze="[object Float64Array]";function Ue(e,t,i,r=new Map,n=void 0){const o=n?.(e,t,i,r);if(void 0!==o)return o;if(null==(s=e)||"object"!=typeof s&&"function"!=typeof s)return e;var s;if(r.has(e))return r.get(e);if(Array.isArray(e)){const t=new Array(e.length);r.set(e,t);for(let o=0;oObject.prototype.propertyIsEnumerable.call(s,e)))];var s;for(let s=0;s{const s=t?.(i,r,n,o);if(void 0!==s)return s;if("object"==typeof e)switch(Object.prototype.toString.call(e)){case ye:case Ae:case ve:{const t=new e.constructor(e?.valueOf());return Ne(t,e),t}case xe:{const t={};return Ne(t,e),t.length=e.length,t[Symbol.iterator]=e[Symbol.iterator],t}default:return}})}function je(e){return Ve(e)}var Ge="undefined"!=typeof globalThis?globalThis:"undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:{};function He(e){return e&&e.__esModule&&Object.prototype.hasOwnProperty.call(e,"default")?e.default:e}function Qe(e){if(e.__esModule)return e;var t=Object.defineProperty({},"__esModule",{value:!0});return Object.keys(e).forEach(function(i){var r=Object.getOwnPropertyDescriptor(e,i);Object.defineProperty(t,i,r.get?r:{enumerable:!0,get:function(){return e[i]}})}),t}var $e={exports:{}};$e.exports=function(){var e,t,i;function r(r,n){if(e)if(t){var o="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 = {}; ("+e+")(sharedChunk); ("+t+")(sharedChunk); self.onerror = null;",s={};e(s),i=n(s),"undefined"!=typeof window&&window&&window.URL&&window.URL.createObjectURL&&(i.workerUrl=window.URL.createObjectURL(new Blob([o],{type:"text/javascript"})))}else t=n;else e=n}r(["exports"],function(e){var t=1e-6,i="undefined"!=typeof Float32Array?Float32Array:Array;function r(e,t){var i=t[0],r=t[1],n=t[2],o=t[3],s=i*o-n*r;return s?(e[0]=o*(s=1/s),e[1]=-r*s,e[2]=-n*s,e[3]=i*s,e):null}function n(){var e=new i(9);return i!=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 o(e,t){var i=t[0],r=t[1],n=t[2],o=t[3],s=t[4],a=t[5],l=t[6],c=t[7],u=t[8];return e[0]=s*u-a*c,e[1]=n*c-r*u,e[2]=r*a-n*s,e[3]=a*l-o*u,e[4]=i*u-n*l,e[5]=n*o-i*a,e[6]=o*c-s*l,e[7]=r*l-i*c,e[8]=i*s-r*o,e}function s(e,t,i){var r=t[0],n=t[1],o=t[2],s=t[3],a=t[4],l=t[5],c=t[6],u=t[7],h=t[8],d=i[0],p=i[1],f=i[2],m=i[3],g=i[4],_=i[5],A=i[6],y=i[7],v=i[8];return e[0]=d*r+p*s+f*c,e[1]=d*n+p*a+f*u,e[2]=d*o+p*l+f*h,e[3]=m*r+g*s+_*c,e[4]=m*n+g*a+_*u,e[5]=m*o+g*l+_*h,e[6]=A*r+y*s+v*c,e[7]=A*n+y*a+v*u,e[8]=A*o+y*l+v*h,e}function a(){var e=new i(16);return i!=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 l(e){var t=new i(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 c(e){return e[0]=1,e[1]=0,e[2]=0,e[3]=0,e[4]=0,e[5]=1,e[6]=0,e[7]=0,e[8]=0,e[9]=0,e[10]=1,e[11]=0,e[12]=0,e[13]=0,e[14]=0,e[15]=1,e}function u(e,t){var i=t[0],r=t[1],n=t[2],o=t[3],s=t[4],a=t[5],l=t[6],c=t[7],u=t[8],h=t[9],d=t[10],p=t[11],f=t[12],m=t[13],g=t[14],_=t[15],A=i*a-r*s,y=i*l-n*s,v=i*c-o*s,x=r*l-n*a,b=r*c-o*a,w=n*c-o*l,T=u*m-h*f,E=u*g-d*f,C=u*_-p*f,B=h*g-d*m,S=h*_-p*m,I=d*_-p*g,M=A*I-y*S+v*B+x*C-b*E+w*T;return M?(e[0]=(a*I-l*S+c*B)*(M=1/M),e[1]=(n*S-r*I-o*B)*M,e[2]=(m*w-g*b+_*x)*M,e[3]=(d*b-h*w-p*x)*M,e[4]=(l*C-s*I-c*E)*M,e[5]=(i*I-n*C+o*E)*M,e[6]=(g*v-f*w-_*y)*M,e[7]=(u*w-d*v+p*y)*M,e[8]=(s*S-a*C+c*T)*M,e[9]=(r*C-i*S-o*T)*M,e[10]=(f*b-m*v+_*A)*M,e[11]=(h*v-u*b-p*A)*M,e[12]=(a*E-s*B-l*T)*M,e[13]=(i*B-r*E+n*T)*M,e[14]=(m*y-f*x-g*A)*M,e[15]=(u*x-h*y+d*A)*M,e):null}function h(e,t,i){var r=t[0],n=t[1],o=t[2],s=t[3],a=t[4],l=t[5],c=t[6],u=t[7],h=t[8],d=t[9],p=t[10],f=t[11],m=t[12],g=t[13],_=t[14],A=t[15],y=i[0],v=i[1],x=i[2],b=i[3];return e[0]=y*r+v*a+x*h+b*m,e[1]=y*n+v*l+x*d+b*g,e[2]=y*o+v*c+x*p+b*_,e[3]=y*s+v*u+x*f+b*A,e[4]=(y=i[4])*r+(v=i[5])*a+(x=i[6])*h+(b=i[7])*m,e[5]=y*n+v*l+x*d+b*g,e[6]=y*o+v*c+x*p+b*_,e[7]=y*s+v*u+x*f+b*A,e[8]=(y=i[8])*r+(v=i[9])*a+(x=i[10])*h+(b=i[11])*m,e[9]=y*n+v*l+x*d+b*g,e[10]=y*o+v*c+x*p+b*_,e[11]=y*s+v*u+x*f+b*A,e[12]=(y=i[12])*r+(v=i[13])*a+(x=i[14])*h+(b=i[15])*m,e[13]=y*n+v*l+x*d+b*g,e[14]=y*o+v*c+x*p+b*_,e[15]=y*s+v*u+x*f+b*A,e}function d(e,t,i){var r,n,o,s,a,l,c,u,h,d,p,f,m=i[0],g=i[1],_=i[2];return t===e?(e[12]=t[0]*m+t[4]*g+t[8]*_+t[12],e[13]=t[1]*m+t[5]*g+t[9]*_+t[13],e[14]=t[2]*m+t[6]*g+t[10]*_+t[14],e[15]=t[3]*m+t[7]*g+t[11]*_+t[15]):(n=t[1],o=t[2],s=t[3],a=t[4],l=t[5],c=t[6],u=t[7],h=t[8],d=t[9],p=t[10],f=t[11],e[0]=r=t[0],e[1]=n,e[2]=o,e[3]=s,e[4]=a,e[5]=l,e[6]=c,e[7]=u,e[8]=h,e[9]=d,e[10]=p,e[11]=f,e[12]=r*m+a*g+h*_+t[12],e[13]=n*m+l*g+d*_+t[13],e[14]=o*m+c*g+p*_+t[14],e[15]=s*m+u*g+f*_+t[15]),e}function p(e,t,i){var r=i[0],n=i[1],o=i[2];return e[0]=t[0]*r,e[1]=t[1]*r,e[2]=t[2]*r,e[3]=t[3]*r,e[4]=t[4]*n,e[5]=t[5]*n,e[6]=t[6]*n,e[7]=t[7]*n,e[8]=t[8]*o,e[9]=t[9]*o,e[10]=t[10]*o,e[11]=t[11]*o,e[12]=t[12],e[13]=t[13],e[14]=t[14],e[15]=t[15],e}function f(e,t,i){var r=Math.sin(i),n=Math.cos(i),o=t[4],s=t[5],a=t[6],l=t[7],c=t[8],u=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*n+c*r,e[5]=s*n+u*r,e[6]=a*n+h*r,e[7]=l*n+d*r,e[8]=c*n-o*r,e[9]=u*n-s*r,e[10]=h*n-a*r,e[11]=d*n-l*r,e}function m(e,t,i){var r=Math.sin(i),n=Math.cos(i),o=t[0],s=t[1],a=t[2],l=t[3],c=t[8],u=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*n-c*r,e[1]=s*n-u*r,e[2]=a*n-h*r,e[3]=l*n-d*r,e[8]=o*r+c*n,e[9]=s*r+u*n,e[10]=a*r+h*n,e[11]=l*r+d*n,e}function g(e,t,i){var r=Math.sin(i),n=Math.cos(i),o=t[0],s=t[1],a=t[2],l=t[3],c=t[4],u=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*n+c*r,e[1]=s*n+u*r,e[2]=a*n+h*r,e[3]=l*n+d*r,e[4]=c*n-o*r,e[5]=u*n-s*r,e[6]=h*n-a*r,e[7]=d*n-l*r,e}function _(e,t){return e[0]=t[0],e[1]=0,e[2]=0,e[3]=0,e[4]=0,e[5]=t[1],e[6]=0,e[7]=0,e[8]=0,e[9]=0,e[10]=t[2],e[11]=0,e[12]=0,e[13]=0,e[14]=0,e[15]=1,e}function A(e,i,r){var n,o,s,a=r[0],l=r[1],c=r[2],u=Math.sqrt(a*a+l*l+c*c);return u0&&(o=1/Math.sqrt(o)),e[0]=t[0]*o,e[1]=t[1]*o,e[2]=t[2]*o,e}function U(e,t){return e[0]*t[0]+e[1]*t[1]+e[2]*t[2]}function N(e,t,i){var r=t[0],n=t[1],o=t[2],s=i[0],a=i[1],l=i[2];return e[0]=n*l-o*a,e[1]=o*s-r*l,e[2]=r*a-n*s,e}function V(e,t,i,r){var n=t[0],o=t[1],s=t[2];return e[0]=n+r*(i[0]-n),e[1]=o+r*(i[1]-o),e[2]=s+r*(i[2]-s),e}function j(e,t,i){var r=t[0],n=t[1],o=t[2],s=i[3]*r+i[7]*n+i[11]*o+i[15];return e[0]=(i[0]*r+i[4]*n+i[8]*o+i[12])/(s=s||1),e[1]=(i[1]*r+i[5]*n+i[9]*o+i[13])/s,e[2]=(i[2]*r+i[6]*n+i[10]*o+i[14])/s,e}function G(e,t,i){var r=t[0],n=t[1],o=t[2];return e[0]=r*i[0]+n*i[3]+o*i[6],e[1]=r*i[1]+n*i[4]+o*i[7],e[2]=r*i[2]+n*i[5]+o*i[8],e}function H(e,t,i){var r=i[0],n=i[1],o=i[2],s=i[3],a=t[0],l=t[1],c=t[2],u=n*c-o*l,h=o*a-r*c,d=r*l-n*a;return e[0]=a+s*(u+=u)+n*(d+=d)-o*(h+=h),e[1]=l+s*h+o*u-r*d,e[2]=c+s*d+r*h-n*u,e}function Q(e){return e[0]=0,e[1]=0,e[2]=0,e}function $(e,t){return e[0]===t[0]&&e[1]===t[1]&&e[2]===t[2]}var Z=S,W=I,q=T;function K(){var e=new i(4);return i!=Float32Array&&(e[0]=0,e[1]=0,e[2]=0,e[3]=0),e}function X(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 J(e,t){var i=t[0],r=t[1],n=t[2],o=t[3],s=i*i+r*r+n*n+o*o;return s>0&&(s=1/Math.sqrt(s)),e[0]=i*s,e[1]=r*s,e[2]=n*s,e[3]=o*s,e}function Y(e,t,i){var r=t[0],n=t[1],o=t[2],s=t[3];return e[0]=i[0]*r+i[4]*n+i[8]*o+i[12]*s,e[1]=i[1]*r+i[5]*n+i[9]*o+i[13]*s,e[2]=i[2]*r+i[6]*n+i[10]*o+i[14]*s,e[3]=i[3]*r+i[7]*n+i[11]*o+i[15]*s,e}function ee(){var e=new i(4);return i!=Float32Array&&(e[0]=0,e[1]=0,e[2]=0),e[3]=1,e}function te(e){return e[0]=0,e[1]=0,e[2]=0,e[3]=1,e}function ie(e,t,i){i*=.5;var r=t[0],n=t[1],o=t[2],s=t[3],a=Math.sin(i),l=Math.cos(i);return e[0]=r*l+s*a,e[1]=n*l+o*a,e[2]=o*l-n*a,e[3]=s*l-r*a,e}function re(e,t,i){i*=.5;var r=t[0],n=t[1],o=t[2],s=t[3],a=Math.sin(i),l=Math.cos(i);return e[0]=r*l-o*a,e[1]=n*l+s*a,e[2]=o*l+r*a,e[3]=s*l-n*a,e}b(),K();var ne,oe,se,ae=J,le=(ne=b(),oe=E(1,0,0),se=E(0,1,0),function(e,t,i){var r=U(t,i);return r<-.999999?(N(ne,oe,t),q(ne)<1e-6&&N(ne,se,t),z(ne,ne),function(e,t,i){i*=.5;var r=Math.sin(i);e[0]=r*t[0],e[1]=r*t[1],e[2]=r*t[2],e[3]=Math.cos(i)}(e,ne,Math.PI),e):r>.999999?(e[0]=0,e[1]=0,e[2]=0,e[3]=1,e):(N(ne,t,i),e[0]=ne[0],e[1]=ne[1],e[2]=ne[2],e[3]=1+r,ae(e,e))});function ce(){var e=new i(2);return i!=Float32Array&&(e[0]=0,e[1]=0),e}function ue(e,t){var r=new i(2);return r[0]=e,r[1]=t,r}function he(e,t,i){return e[0]=t,e[1]=i,e}function de(e,t,i){return e[0]=t[0]+i[0],e[1]=t[1]+i[1],e}function pe(e,t,i){return e[0]=t[0]-i[0],e[1]=t[1]-i[1],e}function fe(e,t,i){return e[0]=t[0]*i,e[1]=t[1]*i,e}function me(e){var t=e[0],i=e[1];return Math.sqrt(t*t+i*i)}function ge(e,t){var i=t[0],r=t[1],n=i*i+r*r;return n>0&&(n=1/Math.sqrt(n)),e[0]=t[0]*n,e[1]=t[1]*n,e}function _e(e,t){return e[0]*t[0]+e[1]*t[1]}ee(),ee(),n();var Ae,ye,ve=pe;function xe(e){return e&&e.__esModule&&Object.prototype.hasOwnProperty.call(e,"default")?e.default:e}ce();var be=function(){if(ye)return Ae;function e(e,t,i,r){this.cx=3*e,this.bx=3*(i-e)-this.cx,this.ax=1-this.cx-this.bx,this.cy=3*t,this.by=3*(r-t)-this.cy,this.ay=1-this.cy-this.by,this.p1x=e,this.p1y=t,this.p2x=i,this.p2y=r}return ye=1,Ae=e,e.prototype={sampleCurveX:function(e){return((this.ax*e+this.bx)*e+this.cx)*e},sampleCurveY:function(e){return((this.ay*e+this.by)*e+this.cy)*e},sampleCurveDerivativeX:function(e){return(3*this.ax*e+2*this.bx)*e+this.cx},solveCurveX:function(e,t){if(void 0===t&&(t=1e-6),e<0)return 0;if(e>1)return 1;for(var i=e,r=0;r<8;r++){var n=this.sampleCurveX(i)-e;if(Math.abs(n)n?s=i:a=i,i=.5*(a-s)+s;return i},solve:function(e,t){return this.sampleCurveY(this.solveCurveX(e,t))}},Ae}(),we=xe(be);function Te(e,t){this.x=e,this.y=t}function Ee(e,t){if(Array.isArray(e)){if(!Array.isArray(t)||e.length!==t.length)return!1;for(let i=0;i=1)return 1;const t=e*e,i=t*e;return 4*(e<.5?i:3*(e-t)+i-.75)}function Re(e,t,i,r){const n=new we(e,t,i,r);return function(e){return n.solve(e)}}const Le=Re(.25,.1,.25,1);function Fe(e,t,i){return Math.min(i,Math.max(t,e))}function ke(e,t,i){return(i=Fe((i-e)/(t-e),0,1))*i*(3-2*i)}function De(e,t,i){const r=i-t,n=((e-t)%r+r)%r+t;return n===t?i:n}function Oe(e,t,i){if(!e.length)return i(null,[]);let r=e.length;const n=new Array(e.length);let o=null;e.forEach((e,s)=>{t(e,(e,t)=>{e&&(o=e),n[s]=t,0==--r&&i(o,n)})})}let ze=1;function Ue(){return ze++}function Ne(e){return e<=1?1:Math.pow(2,Math.ceil(Math.log2(e)))}function Ve(e,t){e.forEach(e=>{t[e]&&(t[e]=t[e].bind(t))})}function je(e,t,i){const r={};for(const i in e)r[i]=t.call(this,e[i],i,e);return r}function Ge(e,t,i){const r={};for(const i in e)t.call(this,e[i],i,e)&&(r[i]=e[i]);return r}function He(e){return Array.isArray(e)?e.map(He):"object"==typeof e&&e?je(e,He):e}function Qe(e,t){for(let i=0;i=0)return!0;return!1}const $e={};function Ze(e){$e[e]||("undefined"!=typeof console&&console.warn(e),$e[e]=!0)}function We(e,t,i){return(i.y-e.y)*(t.x-e.x)>(t.y-e.y)*(i.x-e.x)}function qe(e){let t=0;for(let i,r,n=0,o=e.length,s=o-1;n@\,;\:\\"\/\[\]\?\=\{\}\x7F]+)(?:\=(?:([^\x00-\x20\(\)<>@\,;\:\\"\/\[\]\?\=\{\}\x7F]+)|(?:\"((?:[^"\\]|\\.)*)\")))?/g,(e,i,r,n)=>{const o=r||n;return t[i]=!o||o.toLowerCase(),""}),t["max-age"]){const e=parseInt(t["max-age"],10);isNaN(e)?delete t["max-age"]:t["max-age"]=e}return t}let Ye=null;function et(e,t){return[e[4*t],e[4*t+1],e[4*t+2],e[4*t+3]]}function tt(e,t,i,r){for(;t>1;e[n]>1;e[n]<=r?t=n+1:i=n}return t}function rt(e){return e>0?1/(1.001-e):1+e}function nt(e){return e>0?1-1/(1.001-e):-e}function ot(e,t,i){return(e-t.min)*(i.max-i.min)/(t.max-t.min)+i.min}const st={API_URL:"https://api.mapbox.com",get API_URL_REGEX(){return/^((https?:)?\/\/)?([^\/]+\.)?mapbox\.c(n|om)(\/|\?|$)/i},get API_TILEJSON_REGEX(){return/^((https?:)?\/\/)?([^\/]+\.)?mapbox\.c(n|om)(\/v[0-9]*\/.*\.json.*$)/i},get API_SPRITE_REGEX(){return/^((https?:)?\/\/)?([^\/]+\.)?mapbox\.c(n|om)(\/styles\/v[0-9]*\/)(.*\/sprite.*\..*$)/i},get API_FONTS_REGEX(){return/^((https?:)?\/\/)?([^\/]+\.)?mapbox\.c(n|om)(\/fonts\/v[0-9]*\/)(.*\.pbf.*$)/i},get API_STYLE_REGEX(){return/^((https?:)?\/\/)?([^\/]+\.)?mapbox\.c(n|om)(\/styles\/v[0-9]*\/)(.*$)/i},get API_CDN_URL_REGEX(){return/^((https?:)?\/\/)?api\.mapbox\.c(n|om)(\/mapbox-gl-js\/)(.*$)/i},get EVENTS_URL(){if(!st.API_URL)return null;try{const e=new URL(st.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:"https://api.mapbox.com/mapbox-gl-js/draco_decoder_gltf_v1.5.6.wasm",MESHOPT_URL:"https://api.mapbox.com/mapbox-gl-js/meshopt_base_v0.20.wasm",MESHOPT_SIMD_URL:"https://api.mapbox.com/mapbox-gl-js/meshopt_simd_v0.20.wasm",BUILDING_GEN_URL:"https://api.mapbox.com/mapbox-gl-js/building-gen/building_gen_v1.2.3.wasm",GLYPHS_URL:"mapbox://fonts/mapbox/{fontstack}/{range}.pbf",TILES3D_URL_PREFIX:"3dtiles/v1"};function at(e){return st.API_URL_REGEX.test(e)}function lt(e){return st.API_SPRITE_REGEX.test(e)}let ct,ut,ht,dt,pt,ft;function mt(){return null==ct&&(ct=self.OffscreenCanvas&&new OffscreenCanvas(1,1).getContext("2d")&&"function"==typeof self.createImageBitmap),ct}const gt={now:()=>void 0!==dt?dt:performance.now(),setNow(e){dt=e},restoreNow(){dt=void 0},frame(e){const t=requestAnimationFrame(e);return{cancel:()=>cancelAnimationFrame(t)}},getImageData(e,t=0){const{width:i,height:r}=e;pt||(pt=document.createElement("canvas"));const n=pt.getContext("2d",{willReadFrequently:!0});if(!n)throw new Error("failed to create canvas 2d context");return(i>pt.width||r>pt.height)&&(pt.width=i,pt.height=r),n.clearRect(-t,-t,i+2*t,r+2*t),n.drawImage(e,0,0,i,r),n.getImageData(-t,-t,i+2*t,r+2*t)},resolveURL:e=>(ut||(ut=document.createElement("a")),ut.href=e,ut.href),get devicePixelRatio(){return window.devicePixelRatio},get prefersReducedMotion(){return!!window.matchMedia&&(null==ht&&(ht=window.matchMedia("(prefers-reduced-motion: reduce)")),ht.matches)},hasCanvasFingerprintNoise(){if(void 0!==ft)return ft;if(!mt())return ft=!1,!1;const e=new OffscreenCanvas(85,1),t=e.getContext("2d",{willReadFrequently:!0});let i=0;for(let r=0;r0?`?${o}`:""}`}const yt="mapbox-tiles";let vt=500,xt=50;const bt=["language","worldview","jobid"];let wt,Tt;function Et(){try{return caches}catch(e){}}function Ct(){const e=Et();e&&null==wt&&(wt=e.open(yt))}let Bt=1/0;const St={supported:!1,testSupport:function(e){!Pt&&Mt&&(Rt?Ft(e):It=e)}};let It,Mt,Pt=!1,Rt=!1;const Lt="undefined"!=typeof self?self:{};function Ft(e){const t=e.createTexture();e.bindTexture(e.TEXTURE_2D,t);try{if(e.texImage2D(e.TEXTURE_2D,0,e.RGBA,e.RGBA,e.UNSIGNED_BYTE,Mt),e.isContextLost())return;St.supported=!0}catch(e){}e.deleteTexture(t),Pt=!0}Lt.document&&(Mt=Lt.document.createElement("img"),Mt.onload=function(){It&&Ft(It),It=null,Rt=!0},Mt.onerror=function(){Pt=!0,It=null},Mt.src="data:image/webp;base64,UklGRh4AAABXRUJQVlA4TBEAAAAvAQAAAAfQ//73v/+BiOh/AAA=");const kt={Unknown:"Unknown",Style:"Style",Source:"Source",Tile:"Tile",Glyphs:"Glyphs",SpriteImage:"SpriteImage",SpriteJSON:"SpriteJSON",Iconset:"Iconset",Image:"Image",Model:"Model"};"function"==typeof Object.freeze&&Object.freeze(kt);class Dt extends Error{constructor(e,t,i){401===t&&at(i)&&(e+=": you may have provided an invalid Mapbox access token. See https://docs.mapbox.com/api/overview/#access-tokens-and-token-scopes"),super(e),this.status=t,this.url=i}toString(){return`${this.name}: ${this.message} (${this.status}): ${this.url}`}}const Ot=Xe()?()=>self.worker.referrer:()=>("blob:"===location.protocol?parent:self).location.href,zt=function(e,t){if(!(/^file:/.test(i=e.url)||/^file:/.test(Ot())&&!/^\w+:/.test(i))){if(self.fetch&&self.Request&&self.AbortController&&Request.prototype.hasOwnProperty("signal"))return function(e,t){const i=new AbortController,r=new Request(e.url,{method:e.method||"GET",body:e.body,credentials:e.credentials,headers:e.headers,referrer:Ot(),referrerPolicy:e.referrerPolicy,signal:i.signal});let n=!1,o=!1;const s=(a=r.url).indexOf("sku=")>0&&at(a);var a;"json"===e.type&&r.headers.set("Accept","application/json");const l=(i,n,a)=>{if(o)return;if(i&&"SecurityError"!==i.message&&Ze(i.toString()),n&&a)return c(n);const l=Date.now();fetch(r).then(i=>{if(i.ok){const e=s?i.clone():null;return c(i,e,l)}return t(new Dt(i.statusText,i.status,e.url))}).catch(i=>{"AbortError"!==i.name&&t(new Error(`${i.message} ${e.url}`))})},c=(i,s,a)=>{("arrayBuffer"===e.type?i.arrayBuffer():"json"===e.type?i.json():i.text()).then(e=>{o||(s&&a&&function(e,t,i){if(Ct(),null==wt)return;const r=Je(t.headers.get("Cache-Control")||"");if(r["no-store"])return;const n={status:t.status,statusText:t.statusText,headers:new Headers};t.headers.forEach((e,t)=>n.headers.set(t,e)),r["max-age"]&&n.headers.set("Expires",new Date(i+1e3*r["max-age"]).toUTCString());const o=n.headers.get("Expires");if(!o)return;if(new Date(o).getTime()-i<42e4)return;let s=At(e.url,{persistentParams:bt});if(206===t.status){const t=e.headers.get("Range");if(!t)return;n.status=200,s=_t(s,{range:t})}!function(e,t){if(void 0===Tt)try{new Response(new ReadableStream),Tt=!0}catch(e){Tt=!1}Tt?t(e.body):e.blob().then(t).catch(e=>Ze(e.message))}(t,e=>{const i=new Response(200!==(r=t.status)&&404!==r&&[101,103,204,205,304].includes(r)?null:e,n);var r;Ct(),null!=wt&&wt.then(e=>e.put(s,i)).catch(e=>Ze(e.message))})}(r,s,a),n=!0,t(null,e,i.headers))}).catch(e=>{o||t(new Error(e.message))})};return s?function(e,t){if(Ct(),null==wt)return t(null);wt.then(i=>{let r=At(e.url,{persistentParams:bt});const n=e.headers.get("Range");n&&(r=_t(r,{range:n})),i.match(r).then(e=>{const n=function(e){if(!e)return!1;const t=new Date(e.headers.get("Expires")||0),i=Je(e.headers.get("Cache-Control")||"");return Number(t)>Date.now()&&!i["no-cache"]}(e);i.delete(r).catch(t),n&&i.put(r,e.clone()).catch(t),t(null,e,n)}).catch(t)}).catch(t)}(r,l):l(null,null),{cancel:()=>{o=!0,n||i.abort()}}}(e,t);if(Xe(self)&&self.worker.actor)return self.worker.actor.send("getResource",e,t,void 0,!0)}var i;return function(e,t){const i=new XMLHttpRequest;i.open(e.method||"GET",e.url,!0),"arrayBuffer"===e.type&&(i.responseType="arraybuffer");for(const t in e.headers)i.setRequestHeader(t,e.headers[t]);return"json"===e.type&&(i.responseType="text",i.setRequestHeader("Accept","application/json")),i.withCredentials="include"===e.credentials,i.onerror=()=>{t(new Error(i.statusText))},i.onload=()=>{if((i.status>=200&&i.status<300||0===i.status)&&null!==i.response){let r=i.response;if("json"===e.type)try{r=JSON.parse(i.response)}catch(e){return t(e)}const n=new Headers;i.getAllResponseHeaders().trim().split(/[\r\n]+/).forEach(e=>{const t=e.split(": "),i=t.shift(),r=t.join(": ");n.append(i,r)}),t(null,r,n)}else t(new Dt(i.statusText,i.status,e.url))},i.send(e.body),{cancel:()=>i.abort()}}(e,t)},Ut=function(e,t){return zt(Object.assign(e,{type:"arrayBuffer"}),t)};function Nt(e){const t=document.createElement("a");return t.href=e,t.protocol===location.protocol&&t.host===location.host}const Vt="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAYAAAAfFcSJAAAAC0lEQVQYV2NgAAIAAAUAAarVyFEAAAAASUVORK5CYII=";let jt,Gt;jt=[],Gt=0;const Ht=function(e,t){if(St.supported&&(e.headers||(e.headers={}),e.headers.accept="image/webp,*/*"),Gt>=st.MAX_PARALLEL_IMAGE_REQUESTS){const i={requestParameters:e,callback:t,cancelled:!1,cancel(){this.cancelled=!0}};return jt.push(i),i}Gt++;let i=!1;const r=()=>{if(!i)for(i=!0,Gt--;jt.length&&Gt{r(),e?t(e):i&&(self.createImageBitmap?function(e,t){const i=new Blob([new Uint8Array(e)],{type:"image/png"});createImageBitmap(i).then(e=>{t(null,e)}).catch(e=>{t(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.`))})}(i,(e,i)=>t(e,i,n)):function(e,t){const i=new Image;i.onload=()=>{t(null,i),URL.revokeObjectURL(i.src),i.onload=null,requestAnimationFrame(()=>{i.src=Vt})},i.onerror=()=>t(new Error("Could not load image. Please make sure to use a supported image type such as PNG or JPEG. Note that SVGs are not supported."));const r=new Blob([new Uint8Array(e)],{type:"image/png"});i.src=e.byteLength?URL.createObjectURL(r):Vt}(i,(e,i)=>t(e,i,n)))});return{cancel:()=>{n.cancel(),r()}}};var Qt,$t,Zt,Wt={exports:{}},qt={exports:{}},Kt={exports:{}},Xt=function(){if(Zt)return Wt.exports;Zt=1;var e=(Qt||(Qt=1,qt.exports=function(e,t){var i,r,n,o,s,a,l,c;for(r=e.length-(i=3&e.length),n=t,s=3432918353,a=461845907,c=0;c>>16)*s&65535)<<16)&4294967295)<<15|l>>>17))*a+(((l>>>16)*a&65535)<<16)&4294967295)<<13|n>>>19))+((5*(n>>>16)&65535)<<16)&4294967295))+((58964+(o>>>16)&65535)<<16);switch(l=0,i){case 3:l^=(255&e.charCodeAt(c+2))<<16;case 2:l^=(255&e.charCodeAt(c+1))<<8;case 1:n^=l=(65535&(l=(l=(65535&(l^=255&e.charCodeAt(c)))*s+(((l>>>16)*s&65535)<<16)&4294967295)<<15|l>>>17))*a+(((l>>>16)*a&65535)<<16)&4294967295}return n^=e.length,n=2246822507*(65535&(n^=n>>>16))+((2246822507*(n>>>16)&65535)<<16)&4294967295,n=3266489909*(65535&(n^=n>>>13))+((3266489909*(n>>>16)&65535)<<16)&4294967295,(n^=n>>>16)>>>0}),qt.exports),t=($t||($t=1,Kt.exports=function(e,t){for(var i,r=e.length,n=t^r,o=0;r>=4;)i=1540483477*(65535&(i=255&e.charCodeAt(o)|(255&e.charCodeAt(++o))<<8|(255&e.charCodeAt(++o))<<16|(255&e.charCodeAt(++o))<<24))+((1540483477*(i>>>16)&65535)<<16),n=1540483477*(65535&n)+((1540483477*(n>>>16)&65535)<<16)^(i=1540483477*(65535&(i^=i>>>24))+((1540483477*(i>>>16)&65535)<<16)),r-=4,++o;switch(r){case 3:n^=(255&e.charCodeAt(o+2))<<16;case 2:n^=(255&e.charCodeAt(o+1))<<8;case 1:n=1540483477*(65535&(n^=255&e.charCodeAt(o)))+((1540483477*(n>>>16)&65535)<<16)}return n=1540483477*(65535&(n^=n>>>13))+((1540483477*(n>>>16)&65535)<<16),(n^=n>>>15)>>>0}),Kt.exports);return Wt.exports=e,Wt.exports.murmur3=e,Wt.exports.murmur2=t,Wt.exports}(),Jt=xe(Xt);class Yt{constructor(e,...t){Object.assign(this,t[0]||{}),this.type=e}}class ei extends Yt{constructor(e,t={}){super("error",Object.assign({error:e},t))}}function ti(e,t,i){i[e]&&-1!==i[e].indexOf(t)||(i[e]=i[e]||[],i[e].push(t))}function ii(e,t,i){if(i&&i[e]){const r=i[e].indexOf(t);-1!==r&&i[e].splice(r,1)}}class ri{on(e,t){return this._listeners=this._listeners||{},ti(e,t,this._listeners),this}off(e,t){return ii(e,t,this._listeners),ii(e,t,this._oneTimeListeners),this}once(e,t){return t?(this._oneTimeListeners=this._oneTimeListeners||{},ti(e,t,this._oneTimeListeners),this):new Promise(t=>{this.once(e,t)})}fire(e,t){const i="string"==typeof e?new Yt(e,t):e,r=i.type;if(this.listens(r)){i.target=this;const e=this._listeners&&this._listeners[r]?this._listeners[r].slice():[];for(const t of e)t.call(this,i);const t=this._oneTimeListeners&&this._oneTimeListeners[r]?this._oneTimeListeners[r].slice():[];for(const e of t)ii(r,e,this._oneTimeListeners),e.call(this,i);const n=this._eventedParent;if(n){const e="function"==typeof this._eventedParentData?this._eventedParentData():this._eventedParentData;Object.assign(i,e),n.fire(i)}}else i instanceof ei&&console.error(i.error);return this}listens(e){return!!(this._listeners&&this._listeners[e]&&this._listeners[e].length>0||this._oneTimeListeners&&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 ni{constructor(e){"string"==typeof e?this.name=e:(this.name=e.name,this.iconsetId=e.iconsetId)}static from(e){return new ni(e)}static toString(e){return e.iconsetId?`${e.name}${e.iconsetId}`:e.name}static parse(e){const[t,i]=e.split("");return new ni({name:t,iconsetId:i})}static isEqual(e,t){return e.name===t.name&&e.iconsetId===t.iconsetId}toString(){return ni.toString(this)}serialize(){return{name:this.name,iconsetId:this.iconsetId}}}var oi,si={},ai=function(){if(oi)return si;oi=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 r(e){return(t="%"===e[e.length-1]?parseFloat(e)/100:parseFloat(e))<0?0:t>1?1:t;var t}function n(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{si.parseCSSColor=function(o){var s,a=o.replace(/ /g,"").toLowerCase();if(a in e)return e[a].slice();if("#"===a[0])return 4===a.length?(s=parseInt(a.substr(1),16))>=0&&s<=4095?[(3840&s)>>4|(3840&s)>>8,240&s|(240&s)>>4,15&s|(15&s)<<4,1]:null:7===a.length&&(s=parseInt(a.substr(1),16))>=0&&s<=16777215?[(16711680&s)>>16,(65280&s)>>8,255&s,1]:null;var l=a.indexOf("("),c=a.indexOf(")");if(-1!==l&&c+1===a.length){var u=a.substr(0,l),h=a.substr(l+1,c-(l+1)).split(","),d=1;switch(u){case"rgba":if(4!==h.length)return null;d=r(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=r(h.pop());case"hsl":if(3!==h.length)return null;var p=(parseFloat(h[0])%360+360)%360/360,f=r(h[1]),m=r(h[2]),g=m<=.5?m*(f+1):m+f-m*f,_=2*m-g;return[t(255*n(_,g,p+1/3)),t(255*n(_,g,p)),t(255*n(_,g,p-1/3)),d];default:return null}}return null}}catch(e){}return si}();class li{constructor(e,t,i,r=1){this.r=e,this.g=t,this.b=i,this.a=r}static parse(e){if(!e)return;if(e instanceof li)return e;if("string"!=typeof e)return;const t=ai.parseCSSColor(e);return t?new li(t[0]/255,t[1]/255,t[2]/255,t[3]):void 0}toString(){const[e,t,i,r]=[this.r,this.g,this.b,this.a];return`rgba(${Math.round(255*e)},${Math.round(255*t)},${Math.round(255*i)},${r})`}toNonPremultipliedRenderColor(e){const{r:t,g:i,b:r,a:n}=this;return new ui(e,t,i,r,n)}toPremultipliedRenderColor(e){const{r:t,g:i,b:r,a:n}=this;return new hi(e,t*n,i*n,r*n,n)}clone(){return new li(this.r,this.g,this.b,this.a)}}class ci{constructor(e,t,i,r,n,o=!1){if(this.premultiplied=!1,this.premultiplied=o,e){const o=e.image.height,s=o*o;this.premultiplied?(t=0===n?0:t/n*(o-1),i=0===n?0:i/n*(o-1),r=0===n?0:r/n*(o-1)):(t*=o-1,i*=o-1,r*=o-1);const a=Math.floor(t),l=Math.floor(i),c=Math.floor(r),u=Math.ceil(t),h=Math.ceil(i),d=Math.ceil(r),p=t-a,f=i-l,m=r-c,g=e.image.data,_=4*(a+l*s+c*o),A=4*(a+l*s+d*o),y=4*(a+h*s+c*o),v=4*(a+h*s+d*o),x=4*(u+l*s+c*o),b=4*(u+l*s+d*o),w=4*(u+h*s+c*o),T=4*(u+h*s+d*o);if(_<0||T>=g.length)throw new Error("out of range");this.r=di(di(di(g[_],g[A],m),di(g[y],g[v],m),f),di(di(g[x],g[b],m),di(g[w],g[T],m),f),p)/255*(this.premultiplied?n:1),this.g=di(di(di(g[_+1],g[A+1],m),di(g[y+1],g[v+1],m),f),di(di(g[x+1],g[b+1],m),di(g[w+1],g[T+1],m),f),p)/255*(this.premultiplied?n:1),this.b=di(di(di(g[_+2],g[A+2],m),di(g[y+2],g[v+2],m),f),di(di(g[x+2],g[b+2],m),di(g[w+2],g[T+2],m),f),p)/255*(this.premultiplied?n:1),this.a=n}else this.r=t,this.g=i,this.b=r,this.a=n}toArray(){const{r:e,g:t,b:i,a:r}=this;return[255*e,255*t,255*i,r]}toHslaArray(){let{r:e,g:t,b:i,a:r}=this;if(this.premultiplied){if(0===r)return[0,0,0,0];const n=1/r;e*=n,t*=n,i*=n}const n=Math.min(Math.max(e,0),1),o=Math.min(Math.max(t,0),1),s=Math.min(Math.max(i,0),1),a=Math.min(n,o,s),l=Math.max(n,o,s),c=l-a,u=.5*(a+l);if(0===c)return[0,0,100*u,r];const h=u>.5?c/(2-l-a):c/(l+a);let d;switch(l){case n:d=60*((o-s)/c+(odi(e,t[r],i))}li.black=new li(0,0,0,1),li.white=new li(1,1,1,1),li.transparent=new li(0,0,0,0),li.red=new li(1,0,0,1),li.blue=new li(0,0,1,1);var fi=Object.freeze({__proto__:null,array:pi,color:function(e,t,i){return new li(di(e.r,t.r,i),di(e.g,t.g,i),di(e.b,t.b,i),di(e.a,t.a,i))},number:di});class mi extends Error{constructor(e,t){super(t),this.message=t,this.key=e}}class gi{constructor(e,t=[]){this.parent=e,this.bindings={};for(const[e,i]of t)this.bindings[e]=i}concat(e){return new gi(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 _i={kind:"null"},Ai={kind:"number"},yi={kind:"string"},vi={kind:"boolean"},xi={kind:"color"},bi={kind:"object"},wi={kind:"value"},Ti={kind:"collator"},Ei={kind:"formatted"},Ci={kind:"resolvedImage"};function Bi(e,t){return{kind:"array",itemType:e,N:t}}function Si(e){if("array"===e.kind){const t=Si(e.itemType);return"number"==typeof e.N?`array<${t}, ${e.N}>`:"value"===e.itemType.kind?"array":`array<${t}>`}return e.kind}const Ii=[_i,Ai,yi,vi,xi,Ei,bi,Bi(wi),Ci];function Mi(e,t){if("error"===t.kind)return null;if("array"===e.kind){if("array"===t.kind&&(0===t.N&&"value"===t.itemType.kind||!Mi(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 Ii)if(!Mi(e,t))return null}return`Expected ${Si(e)} but found ${Si(t)} instead.`}function Pi(e,t){return t.some(t=>t.kind===e.kind)}function Ri(e,t){return t.some(t=>"null"===t?null===e:"array"===t?Array.isArray(e):"object"===t?e&&!Array.isArray(e)&&"object"==typeof e:t===typeof e)}function Li(e,t){return"array"===e.kind&&"array"===t.kind?e.N===t.N&&Li(e.itemType,t.itemType):e.kind===t.kind}class Fi{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 ki{constructor(e,t,i,r,n){this.text=e.normalize?e.normalize():e,this.image=t,this.scale=i,this.fontStack=r,this.textColor=n}}class Di{constructor(e){this.sections=e}static fromString(e){return new Di([new ki(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 Di?e:Di.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 Oi{constructor(e,t={}){if(this.id=ni.from(e),this.options=Object.assign({},t),t.transform){const{a:e,b:i,c:r,d:n,e:o,f:s}=t.transform;this.options.transform=new DOMMatrix([e,i,r,n,o,s])}else this.options.transform=new DOMMatrix([1,0,0,1,0,0])}toString(){const{a:e,b:t,c:i,d:r,e:n,f:o}=this.options.transform;return JSON.stringify({name:this.id.name,iconsetId:this.id.iconsetId,params:this.options.params,transform:{a:e,b:t,c:i,d:r,e:n,f:o}})}static parse(e){let t,i,r,n;try{({name:t,iconsetId:i,params:r,transform:n}=JSON.parse(e)||{})}catch(e){return null}if(!t)return null;const{a:o,b:s,c:a,d:l,e:c,f:u}=n||{};return new Oi({name:t,iconsetId:i},{params:r,transform:new DOMMatrix([o,s,a,l,c,u])})}scaleSelf(e,t){return this.options.transform.scaleSelf(e,t),this}}class zi{constructor(e,t,i,r,n=!1){this.primaryId=ni.from(e),this.primaryOptions=t,i&&(this.secondaryId=ni.from(i)),this.secondaryOptions=r,this.available=n}toString(){return this.primaryId&&this.secondaryId?`[${this.primaryId.name},${this.secondaryId.name}]`:this.primaryId.name}hasPrimary(){return!!this.primaryId}getPrimary(){return new Oi(this.primaryId,this.primaryOptions)}hasSecondary(){return!!this.secondaryId}getSecondary(){return this.secondaryId?new Oi(this.secondaryId,this.secondaryOptions):null}static from(e){return"string"==typeof e?zi.build({name:e}):e}static build(e,t,i,r){return!e||"object"==typeof e&&!("name"in e)?null:new zi(e,i,t,r)}}function Ui(e,t,i,r){return"number"==typeof e&&e>=0&&e<=255&&"number"==typeof t&&t>=0&&t<=255&&"number"==typeof i&&i>=0&&i<=255?void 0===r||"number"==typeof r&&r>=0&&r<=1?null:`Invalid rgba value [${[e,t,i,r].join(", ")}]: 'a' must be between 0 and 1.`:`Invalid rgba value [${("number"==typeof r?[e,t,i,r]:[e,t,i]).join(", ")}]: 'r', 'g', and 'b' must be between 0 and 255.`}function Ni(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 li)return!0;if(e instanceof Fi)return!0;if(e instanceof Di)return!0;if(e instanceof zi)return!0;if(Array.isArray(e)){for(const t of e)if(!Ni(t))return!1;return!0}if("object"==typeof e){for(const t in e)if(!Ni(e[t]))return!1;return!0}return!1}function Vi(e){if(null===e)return _i;if("string"==typeof e)return yi;if("boolean"==typeof e)return vi;if("number"==typeof e)return Ai;if(e instanceof li)return xi;if(e instanceof Fi)return Ti;if(e instanceof Di)return Ei;if(e instanceof zi)return Ci;if(Array.isArray(e)){const t=e.length;let i;for(const t of e){const e=Vi(t);if(i){if(i===e)continue;i=wi;break}i=e}return Bi(i||wi,t)}return bi}function ji(e){const t=typeof e;return null===e?"":"string"===t||"number"===t||"boolean"===t?String(e):e instanceof Di||e instanceof zi||e instanceof li?e.toString():JSON.stringify(e)}class Gi{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(!Ni(e[1]))return t.error("invalid value");const i=e[1];let r=Vi(i);const n=t.expectedType;return"array"!==r.kind||0!==r.N||!n||"array"!==n.kind||"number"==typeof n.N&&0!==n.N||(r=n),new Gi(r,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 li?["rgba"].concat(this.value.toNonPremultipliedRenderColor(null).toArray()):this.value instanceof Di?this.value.serialize():this.value}}class Hi{constructor(e){this.name="ExpressionEvaluationError",this.message=e}toJSON(){return this.message}}const Qi={string:yi,number:Ai,boolean:vi,object:bi};class $i{constructor(e,t){this.type=e,this.args=t}static parse(e,t){if(e.length<2)return t.error("Expected at least one argument.");let i,r=1;const n=e[0];if("array"===n){let n,o;if(e.length>2){const i=e[1];if("string"!=typeof i||!(i in Qi)||"object"===i)return t.error('The item type argument of "array" must be one of string, number, boolean',1);n=Qi[i],r++}else n=wi;if(e.length>3){if(null!==e[2]&&("number"!=typeof e[2]||e[2]<0||e[2]!==Math.floor(e[2])))return t.error('The length argument to "array" must be a positive integer literal',2);o=e[2],r++}i=Bi(n,o)}else i=Qi[n];const o=[];for(;re.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 r=e.N;("number"==typeof r||this.args.length>1)&&t.push(r)}}return t.concat(this.args.map(e=>e.serialize()))}}class Zi{constructor(e){this.type=Ei,this.sections=e}static parse(e,t){if(e.length<2)return t.error("Expected at least one argument.");const i=e[1];if(!Array.isArray(i)&&"object"==typeof i)return t.error("First argument must be an image or text section.");const r=[];let n=!1;for(let i=1;i<=e.length-1;++i){const o=e[i];if(n&&"object"==typeof o&&!Array.isArray(o)){n=!1;let e=null;if(o["font-scale"]&&(e=t.parseObjectValue(o["font-scale"],i,"font-scale",Ai),!e))return null;let s=null;if(o["text-font"]&&(s=t.parseObjectValue(o["text-font"],i,"text-font",Bi(yi)),!s))return null;let a=null;if(o["text-color"]&&(a=t.parseObjectValue(o["text-color"],i,"text-color",xi),!a))return null;const l=r[r.length-1];l.scale=e,l.font=s,l.textColor=a}else{const o=t.parse(e[i],i,wi);if(!o)return null;const s=o.type.kind;if("string"!==s&&"value"!==s&&"null"!==s&&"resolvedImage"!==s)return t.error("Formatted text type must be 'string', 'value', 'image' or 'null'.");n=!0,r.push({content:o,scale:null,font:null,textColor:null})}}return new Zi(r)}evaluate(e){return new Di(this.sections.map(t=>{const i=t.content.evaluate(e);return Li(Vi(i),Ci)?new ki("",i,null,null,null):new ki(ji(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 Wi{constructor(e,t,i,r){this._imageWarnHistory={},this.type=Ci,this.namePrimary=e,this.nameSecondary=t,i&&(this.paramsPrimary=i.params,this.iconsetIdPrimary=i.iconset?i.iconset.id:void 0),r&&(this.paramsSecondary=r.params,this.iconsetIdSecondary=r.iconset?r.iconset.id:void 0)}static parse(e,t){if(e.length<2)return t.error("Expected two or more arguments.");let i=1;const r=[];function n(){if(ini.isEqual(e,t)),r.available){const t=r.getSecondary()?r.getSecondary().id:null;t&&(r.available=e.availableImages.some(e=>ni.isEqual(e,t)))}}return r}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 qi(e){return Xi(e)?"string":Ji(e)?"number":Yi(e)?"boolean":Array.isArray(e)?"array":null===e?"null":Ki(e)?"object":typeof e}function Ki(e){return null!=e&&!Array.isArray(e)&&"function"!=typeof e&&!(e instanceof String||e instanceof Number||e instanceof Boolean)&&"object"==typeof e}function Xi(e){return"string"==typeof e||e instanceof String}function Ji(e){return"number"==typeof e||e instanceof Number}function Yi(e){return"boolean"==typeof e||e instanceof Boolean}const er={"to-boolean":vi,"to-color":xi,"to-number":Ai,"to-string":yi};class tr{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],r=[];let n=_i;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.`);n=Bi(t.expectedType.itemType,i)}else{if(!(i>0&&Ni(e[1][0])))return null;n=Bi(Vi(e[1][0]),i)}for(let o=0;o4?`Invalid rbga value ${JSON.stringify(t)}: expected an array containing either three or four numeric values.`:Ui(t[0],t[1],t[2],t[3]),!i))return new li(t[0]/255,t[1]/255,t[2]/255,t[3])}throw new Hi(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 r=Number(t);if(!isNaN(r))return r}throw new Hi(`Could not convert ${JSON.stringify(t)} to number.`)}return"formatted"===this.type.kind?Di.fromString(ji(this.args[0].evaluate(e))):"resolvedImage"===this.type.kind?zi.build(ji(this.args[0].evaluate(e))):"array"===this.type.kind?this.args.map(t=>t.evaluate(e)):ji(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 Zi([{content:this.args[0],scale:null,font:null,textColor:null}]).serialize();if("resolvedImage"===this.type.kind)return new Wi(this.args[0]).serialize();const e="array"===this.type.kind?[]:[`to-${this.type.kind}`];return this.eachChild(t=>{e.push(t.serialize())}),e}}const ir=["Unknown","Point","LineString","Polygon"];class rr{constructor(e,t,i){this.globals=null,this.feature=null,this.featureState=null,this.formattedSection=null,this._parseColorCache={},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?ir[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:r}=this.featureTileCoord;return this.featureDistanceData.bearing[0]*(i*t-e[0])+this.featureDistanceData.bearing[1]*(r*t-e[1])}return 0}parseColor(e){let t=this._parseColorCache[e];return t||(t=this._parseColorCache[e]=li.parse(e)),t}getConfig(e){return this.options?this.options.get(e):null}}class nr{constructor(e,t,i,r,n){this.name=e,this.type=t,this._evaluate=i,this.args=r,this._overloadIndex=n}evaluate(e){if(!this._evaluate){const e=nr.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],r=nr.definitions[i];if(!r)return t.error(`Unknown expression "${i}". If you wanted a literal array, use ["literal", [...]].`,0);const n=Array.isArray(r)?r[0]:r.type,o=Array.isArray(r)?[[r[1],r[2]]]:r.overloads,s=[];let a=null,l=-1;for(const[r,c]of o){if(Array.isArray(r)&&r.length!==e.length-1)continue;s.push(r),l++,a=new En(t.registry,t.path,null,t.scope,void 0,t._scope,t.options,t.iconImageUseTheme);const o=[];let u=!1;for(let t=1;te)).map(or).join(" | "),r=[];for(let i=1;ii;){if(r-i>600){const o=r-i+1,s=t-i+1,a=Math.log(o),l=.5*Math.exp(2*a/3),c=.5*Math.sqrt(a*l*(o-l)/o)*(s-o/2<0?-1:1);ar(e,t,Math.max(i,Math.floor(t-s*l/o+c)),Math.min(r,Math.floor(t+(o-s)*l/o+c)),n)}const o=e[t];let s=i,a=r;for(lr(e,i,t),n(e[r],o)>0&&lr(e,i,r);s0;)a--}0===n(e[i],o)?lr(e,i,a):(a++,lr(e,a,r)),a<=t&&(i=a+1),t<=a&&(r=a-1)}}function lr(e,t,i){const r=e[t];e[t]=e[i],e[i]=r}function cr(e,t){return et?1:0}function ur(e){let t=0;for(let i,r,n=0,o=e.length,s=o-1;n=t[2]||e[1]<=t[1]||e[3]>=t[3])}function pr(e,t,i){const r=e[0]-t[0],n=e[1]-t[1],o=e[0]-i[0],s=e[1]-i[1];return r*s-o*n==0&&r*o<=0&&n*s<=0}function fr(e,t,i=!1){let r=!1;for(let a=0,l=t.length;a(n=e)[1]!=(s=u)[1]>n[1]&&n[0]<(s[0]-o[0])*(n[1]-o[1])/(s[1]-o[1])+o[0]&&(r=!r)}}var n,o,s;return r}function mr(e,t,i,r){const n=r[0]-i[0],o=r[1]-i[1],s=(e[0]-i[0])*o-n*(e[1]-i[1]),a=(t[0]-i[0])*o-n*(t[1]-i[1]);return s>0&&a<0||s<0&&a>0}function gr(e,t,i,r){return 0!=(n=[r[0]-i[0],r[1]-i[1]])[0]*(o=[t[0]-e[0],t[1]-e[1]])[1]-n[1]*o[0]&&!(!mr(e,t,i,r)||!mr(i,r,e,t));var n,o}function _r(e){const t=new Te(Number.POSITIVE_INFINITY,Number.POSITIVE_INFINITY),i=new Te(Number.NEGATIVE_INFINITY,Number.NEGATIVE_INFINITY);for(const r of e[0])t.x>r.x&&(t.x=r.x),t.y>r.y&&(t.y=r.y),i.xi[2]){const t=.5*r;let n=e[0]-i[0]>t?-r:i[0]-e[0]>t?r:0;0===n&&(n=e[0]-i[2]>t?-r:i[2]-e[0]>t?r:0),e[0]+=n}hr(t,e)}function Br(e,t,i,r){const n=Math.pow(2,r.z)*Ar,o=[r.x*Ar,r.y*Ar],s=[];if(!e)return s;for(const r of e)for(const e of r){const r=[e.x+o[0],e.y+o[1]];Cr(r,t,i,n),s.push(r)}return s}function Sr(e,t,i,r){const n=Math.pow(2,r.z)*Ar,o=[r.x*Ar,r.y*Ar],s=[];if(!e)return s;for(const i of e){const e=[];for(const r of i){const i=[r.x+o[0],r.y+o[1]];hr(t,i),e.push(i)}s.push(e)}if(t[2]-t[0]<=n/2){(a=t)[0]=a[1]=1/0,a[2]=a[3]=-1/0;for(const e of s)for(const r of e)Cr(r,t,i,n)}var a;return s}class Ir{constructor(e,t){this.type=vi,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(Ni(e[1])){const t=e[1];if("FeatureCollection"===t.type)for(let e=0;et)return Dr(n,o,(t-(i-s))/s)}return e[e.length-1]}pointToSegmentDistance(e,t,i){let[r,n]=t,o=Or(i[0]-r)*this.kx,s=(i[1]-n)*this.ky;if(0!==o||0!==s){const t=(Or(e[0]-r)*this.kx*o+(e[1]-n)*this.ky*s)/(o*o+s*s);t>1?(r=i[0],n=i[1]):t>0&&(r+=o/this.kx*t,n+=s/this.ky*t)}return o=Or(e[0]-r)*this.kx,s=(e[1]-n)*this.ky,Math.sqrt(o*o+s*s)}pointOnLine(e,t){let i=1/0,r=e[0][0],n=e[0][1],o=0,s=0;for(let a=0;a1?(l=e[a+1][0],c=e[a+1][1]):d>0&&(l+=u/this.kx*d,c+=h/this.ky*d)),u=Or(t[0]-l)*this.kx,h=(t[1]-c)*this.ky;const p=u*u+h*h;pn.index||r.index===n.index&&r.t>n.t){const e=r;r=n,n=e}const o=[r.point],s=r.index+1,a=n.index;!kr(i[s],o[0])&&s<=a&&o.push(i[s]);for(let e=s+1;e<=a;e++)o.push(i[e]);return kr(i[a],n.point)||o.push(n.point),o}lineSliceAlong(e,t,i){let r=0;const n=[];for(let o=0;oe&&0===n.length&&n.push(Dr(s,a,(e-(r-l))/l)),r>=t)return n.push(Dr(s,a,(t-(r-l))/l)),n;r>e&&n.push(a)}return n}bufferPoint(e,t){const i=t/this.ky,r=t/this.kx;return[e[0]-r,e[1]-i,e[0]+r,e[1]+i]}bufferBBox(e,t){const i=t/this.ky,r=t/this.kx;return[e[0]-r,e[1]-i,e[2]+r,e[3]+i]}insideBBox(e,t){return Or(e[0]-t[0])>=0&&Or(e[0]-t[2])<=0&&e[1]>=t[1]&&e[1]<=t[3]}}function kr(e,t){return e[0]===t[0]&&e[1]===t[1]}function Dr(e,t,i){const r=Or(t[0]-e[0]);return[e[0]+r*i,e[1]+(t[1]-e[1])*i]}function Or(e){for(;e<-180;)e+=360;for(;e>180;)e-=360;return e}class zr{constructor(e=[],t=(e,t)=>et?1:0){if(this.data=e,this.length=this.data.length,this.compare=t,this.length>0)for(let e=(this.length>>1)-1;e>=0;e--)this._down(e)}push(e){this.data.push(e),this._up(this.length++)}pop(){if(0===this.length)return;const e=this.data[0],t=this.data.pop();return--this.length>0&&(this.data[0]=t,this._down(0)),e}peek(){return this.data[0]}_up(e){const{data:t,compare:i}=this,r=t[e];for(;e>0;){const n=e-1>>1,o=t[n];if(i(r,o)>=0)break;t[e]=o,e=n}t[e]=r}_down(e){const{data:t,compare:i}=this,r=this.length>>1,n=t[e];for(;e=0)break;t[e]=t[r],e=r}t[e]=n}}var Ur=8192;function Nr(e,t){return t.dist-e.dist}const Vr=100,jr=50;function Gr(e){const t=[1/0,1/0,-1/0,-1/0];if(t.length!==e.length)return!1;for(let i=0;i=e[0]&&e[1]e[1])return[null,null];const i=Hr(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 Zr(e,t){const i=[1/0,1/0,-1/0,-1/0];if(!Qr(t,e.length))return i;for(let r=t[0];r<=t[1];++r)hr(i,e[r]);return i}function Wr(e){const t=[1/0,1/0,-1/0,-1/0];for(let i=0;it[2]&&(r=e[0]-t[2]),e[1]>t[3]&&(n=e[1]-t[3]),e[3]=r)return r;if(dr(n,o)){if(ln(e,t))return 0}else if(ln(t,e))return 0;let s=r;for(const r of e)for(let e=0,n=r.length,o=n-1;e=o)continue;const c=n.range1;if(Hr(c)<=a){if(!Qr(c,e.length))return NaN;if(t){const t=an(e,c,i,r);if(0===(o=Math.min(o,t)))return o}else for(let t=c[0];t<=c[1];++t){const n=sn(e[t],i,r);if(0===(o=Math.min(o,n)))return o}}else{const i=$r(c,t);if(null!==i[0]){const t=qr(Zr(e,i[0]),l,r);t=s)continue;const u=o.range1,h=o.range2;if(Hr(u)<=l&&Hr(h)<=c){if(!Qr(u,e.length)||!Qr(h,i.length))return NaN;if(t&&r?s=Math.min(s,nn(e,u,i,h,n)):t||r?t&&!r?s=Math.min(s,tn(i,h,e,u,n)):!t&&r&&(s=Math.min(s,tn(e,u,i,h,n))):s=Math.min(s,on(e,u,i,h,n)),0===s)return s}else{const o=$r(u,t),l=$r(h,r);un(a,s,n,e,i,o[0],l[0]),un(a,s,n,e,i,o[0],l[1]),un(a,s,n,e,i,o[1],l[0]),un(a,s,n,e,i,o[1],l[1])}}return s}function pn(e,t,i,r,n=1/0){let o=n;const s=Zr(e,[0,e.length-1]);for(const n of i)if(!(o!==1/0&&qr(s,Zr(n,[0,n.length-1]),r)>=o)&&(o=Math.min(o,dn(e,t,n,!0,r,o)),0===o))return o;return o}function fn(e,t,i,r,n=1/0){let o=n;const s=Zr(e,[0,e.length-1]);for(const n of i){if(o!==1/0&&qr(s,Wr(n),r)>=o)continue;const i=hn(e,t,n,r,o);if(isNaN(i))return i;if(0===(o=Math.min(o,i)))return o}return o}function mn(e){return"Point"===e||"MultiPoint"===e||"LineString"===e||"MultiLineString"===e||"Polygon"===e||"MultiPolygon"===e}class gn{constructor(e,t){this.type=Ai,this.geojson=e,this.geometries=t}static parse(e,t){if(2!==e.length)return t.error(`'distance' expression requires either one argument, but found ' ${e.length-1} instead.`);if(Ni(e[1])){const t=e[1];if("FeatureCollection"===t.type){for(let e=0;e{t&&!_n(e)&&(t=!1)}),t}function An(e){if(e instanceof nr&&"feature-state"===e.name)return!1;let t=!0;return e.eachChild(e=>{t&&!An(e)&&(t=!1)}),t}function yn(e,t){if(e instanceof nr&&t.indexOf(e.name)>=0)return!1;let i=!0;return e.eachChild(e=>{i&&!yn(e,t)&&(i=!1)}),i}function vn(e,t,i){return[e,t,i].filter(Boolean).join("")}function xn(e,t){switch(e){case"string":return ji(t);case"number":return+t;case"boolean":return!!t;case"color":return li.parse(t);case"formatted":return Di.fromString(ji(t));case"resolvedImage":return zi.build(ji(t))}return t}function bn(e,t,i,r){return void 0!==r&&(e=r*Math.round(e/r)),void 0!==t&&ei&&(e=i),e}class wn{constructor(e,t,i,r=!1){this.type=e,this.key=t,this.scope=i,this.featureConstant=r}static parse(e,t){let i=t.expectedType;if(null==i&&(i=wi),e.length<2||e.length>3)return t.error("Invalid number of arguments for 'config' expression.");const r=t.parse(e[1],1);if(!(r instanceof Gi))return t.error("Key name of 'config' expression must be a string literal.");let n,o=!0;const s=ji(r.value);if(e.length>=3){const i=t.parse(e[2],2);if(!(i instanceof Gi))return t.error("Scope of 'config' expression must be a string literal.");n=ji(i.value)}if(t.options){const e=vn(s,n,t._scope),i=t.options.get(e);i&&(o=_n(i.value||i.default))}return new wn(i,s,n,o)}evaluate(e){const t=vn(this.key,this.scope,e.scope),i=e.getConfig(t);if(!i)return null;const{type:r,value:n,values:o,minValue:s,maxValue:a,stepValue:l}=i,c=i.default.evaluate(e);let u=c;if(n){const t=e.scope;e.scope=(t||"").split("").slice(1).join(""),u=n.evaluate(e),e.scope=t}return r&&(u=xn(r,u)),void 0===u||void 0===s&&void 0===a&&void 0===l||("number"==typeof u?u=bn(u,s,a,l):Array.isArray(u)&&(u=u.map(e=>"number"==typeof e?bn(e,s,a,l):e))),void 0!==n&&void 0!==u&&o&&!o.includes(u)&&(u=c,r&&(u=xn(r,u))),(r&&r!==this.type||void 0!==u&&!Li(Vi(u),this.type))&&(u=xn(this.type.kind,u)),u}eachChild(){}outputDefined(){return!1}serialize(){const e=["config",this.key];return this.scope&&e.concat(this.scope),e}}class Tn{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 Tn(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 En{constructor(e,t=[],i,r=new gi,n=[],o,s,a){this.registry=e,this.path=t,this.key=t.map(e=>"string"==typeof e?`['${e}']`:`[${e}]`).join(""),this.scope=r,this.errors=n,this.expectedType=i,this._scope=o,this.options=s,this.iconImageUseTheme=a}parse(e,t,i,r,n={}){return t||i?this.concat(t,null,i,r)._parse(e,n):this._parse(e,n)}parseObjectValue(e,t,i,r,n,o={}){return this.concat(t,i,r,n)._parse(e,o)}_parse(e,t){function i(e,t,i){return"assert"===i?new $i(t,[e]):"coerce"===i?new tr(t,[e]):e}if(null!==e&&"string"!=typeof e&&"boolean"!=typeof e&&"number"!=typeof e||(e=["literal",e]),Array.isArray(e)){if(0===e.length)return this.error('Expected an array with at least one element. If you wanted a literal array, use ["literal", []].');const r="string"==typeof e[0]?this.registry[e[0]]:void 0;if(r){let n=r.parse(e,this);if(!n)return null;if(this.expectedType){const e=this.expectedType,r=n.type;if("string"!==e.kind&&"number"!==e.kind&&"boolean"!==e.kind&&"object"!==e.kind&&"array"!==e.kind||"value"!==r.kind)if("color"!==e.kind&&"formatted"!==e.kind&&"resolvedImage"!==e.kind||"value"!==r.kind&&"string"!==r.kind){if(this.checkSubtype(e,r))return null}else n=i(n,e,t.typeAnnotation||"coerce");else n=i(n,e,t.typeAnnotation||"assert")}if(!(n instanceof Gi)&&"resolvedImage"!==n.type.kind&&Cn(n)){const t=new rr(this._scope,this.options,this.iconImageUseTheme);try{n=new Gi(n.type,n.evaluate(t))}catch(e){return this.error(e.message),null}}return n}return tr.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,r){let n="number"==typeof e?this.path.concat(e):this.path;n="string"==typeof t?n.concat(t):n;const o=r?this.scope.concat(r):this.scope;return new En(this.registry,n,i||null,o,this.errors,this._scope,this.options,this.iconImageUseTheme)}error(e,...t){const i=`${this.key}${t.map(e=>`[${e}]`).join("")}`;this.errors.push(new mi(i,e))}checkSubtype(e,t){const i=Mi(e,t);return i&&this.error(i),i}}function Cn(e){if(e instanceof Tn)return Cn(e.boundExpression);if(e instanceof nr&&"error"===e.name)return!1;if(e instanceof sr)return!1;if(e instanceof Ir)return!1;if(e instanceof gn)return!1;if(e instanceof wn)return!1;const t=e instanceof tr||e instanceof $i;let i=!0;return e.eachChild(e=>{i=t?i&&Cn(e):i&&e instanceof Gi}),!!i&&_n(e)&&yn(e,["zoom","heatmap-density","worldview","line-progress","raster-value","sky-radial-progress","accumulated","is-supported-script","pitch","distance-from-center","measure-light","raster-particle-speed"])}function Bn(e,t){const i=e.length-1;let r,n,o=0,s=i,a=0;for(;o<=s;)if(a=Math.floor((o+s)/2),r=e[a],n=e[a+1],r<=t){if(a===i||tt))throw new Hi("Input is not a number.");s=a-1}return 0}class Sn{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,Ai);if(!i)return null;const r=[];let n=null;t.expectedType&&"value"!==t.expectedType.kind&&(n=t.expectedType);for(let i=1;i=o)return t.error('Input/output pairs for "step" expressions must be arranged with input values in strictly ascending order.',a);const c=t.parse(s,l,n);if(!c)return null;n=n||c.type,r.push([o,c])}return new Sn(n,i,r)}evaluate(e){const t=this.labels,i=this.outputs;if(1===t.length)return i[0].evaluate(e);const r=this.input.evaluate(e);if(r<=t[0])return i[0].evaluate(e);const n=t.length;return r>=t[n-1]?i[n-1].evaluate(e):i[Bn(t,r)].evaluate(e)}eachChild(e){e(this.input);for(const t of this.outputs)e(t)}outputDefined(){return this.outputs.every(e=>e.outputDefined())}serialize(){const e=["step",this.input.serialize()];for(let t=0;t0&&e.push(this.labels[t]),e.push(this.outputs[t].serialize());return e}}const In=.95047,Mn=1.08883,Pn=4/29,Rn=6/29,Ln=3*Rn*Rn,Fn=Rn*Rn*Rn,kn=Math.PI/180,Dn=180/Math.PI;function On(e){return e>Fn?Math.pow(e,1/3):e/Ln+Pn}function zn(e){return e>Rn?e*e*e:Ln*(e-Pn)}function Un(e){return 255*(e<=.0031308?12.92*e:1.055*Math.pow(e,1/2.4)-.055)}function Nn(e){return(e/=255)<=.04045?e/12.92:Math.pow((e+.055)/1.055,2.4)}function Vn(e){const t=Nn(e.r),i=Nn(e.g),r=Nn(e.b),n=On((.4124564*t+.3575761*i+.1804375*r)/In),o=On((.2126729*t+.7151522*i+.072175*r)/1);return{l:116*o-16,a:500*(n-o),b:200*(o-On((.0193339*t+.119192*i+.9503041*r)/Mn)),alpha:e.a}}function jn(e){let t=(e.l+16)/116,i=isNaN(e.a)?t:t+e.a/500,r=isNaN(e.b)?t:t-e.b/200;return t=1*zn(t),i=In*zn(i),r=Mn*zn(r),new li(Un(3.2404542*i-1.5371385*t-.4985314*r),Un(-.969266*i+1.8760108*t+.041556*r),Un(.0556434*i-.2040259*t+1.0572252*r),e.alpha)}function Gn(e,t,i){const r=t-e;return e+i*(r>180||r<-180?r-360*Math.round(r/360):r)}const Hn={forward:Vn,reverse:jn,interpolate:function(e,t,i){return{l:di(e.l,t.l,i),a:di(e.a,t.a,i),b:di(e.b,t.b,i),alpha:di(e.alpha,t.alpha,i)}}},Qn={forward:function(e){const{l:t,a:i,b:r}=Vn(e),n=Math.atan2(r,i)*Dn;return{h:n<0?n+360:n,c:Math.sqrt(i*i+r*r),l:t,alpha:e.a}},reverse:function(e){const t=e.h*kn,i=e.c;return jn({l:e.l,a:Math.cos(t)*i,b:Math.sin(t)*i,alpha:e.alpha})},interpolate:function(e,t,i){return{h:Gn(e.h,t.h,i),c:di(e.c,t.c,i),l:di(e.l,t.l,i),alpha:di(e.alpha,t.alpha,i)}}};var $n=Object.freeze({__proto__:null,hcl:Qn,lab:Hn});class Zn{constructor(e,t,i,r,n){this.type=e,this.operator=t,this.interpolation=i,this.input=r,this.labels=[],this.outputs=[];for(const[e,t]of n)this.labels.push(e),this.outputs.push(t)}static interpolationFactor(e,t,i,r){let n=0;if("exponential"===e.name)n=Wn(t,e.base,i,r);else if("linear"===e.name)n=Wn(t,1,i,r);else if("cubic-bezier"===e.name){const o=e.controlPoints;n=new we(o[0],o[1],o[2],o[3]).solve(Wn(t,1,i,r))}return n}static parse(e,t){let[i,r,n,...o]=e;if(!Array.isArray(r)||0===r.length)return t.error("Expected an interpolation type expression.",1);if("linear"===r[0])r={name:"linear"};else if("exponential"===r[0]){const e=r[1];if("number"!=typeof e)return t.error("Exponential interpolation requires a numeric base.",1,1);r={name:"exponential",base:e}}else{if("cubic-bezier"!==r[0])return t.error(`Unknown interpolation type ${String(r[0])}`,1,0);{const e=r.slice(1);if(4!==e.length||e.some(e=>"number"!=typeof e||e<0||e>1))return t.error("Cubic bezier interpolation requires four numeric arguments with values between 0 and 1.",1);r={name:"cubic-bezier",controlPoints:e}}}if(e.length-1<4)return t.error(`Expected at least 4 arguments, but found only ${e.length-1}.`);if(e.length-1>3&&(e.length-1)%2!=0)return t.error("Expected an even number of arguments.");if(n=t.parse(n,2,Ai),!n)return null;const s=[];let a=null;"interpolate-hcl"===i||"interpolate-lab"===i?a=xi:t.expectedType&&"value"!==t.expectedType.kind&&(a=t.expectedType);for(let e=0;e=i)return t.error('Input/output pairs for "interpolate" expressions must be arranged with input values in strictly ascending order.',n);const c=t.parse(r,l,a);if(!c)return null;a=a||c.type,s.push([i,c])}return"number"===a.kind||"color"===a.kind||"array"===a.kind&&"number"===a.itemType.kind&&"number"==typeof a.N?new Zn(a,i,r,n,s):t.error(`Type ${Si(a)} is not interpolatable.`)}evaluate(e){const t=this.labels,i=this.outputs;if(1===t.length)return i[0].evaluate(e);const r=this.input.evaluate(e);if(r<=t[0])return i[0].evaluate(e);const n=t.length;if(r>=t[n-1])return i[n-1].evaluate(e);const o=Bn(t,r),s=Zn.interpolationFactor(this.interpolation,r,t[o],t[o+1]),a=i[o].evaluate(e),l=i[o+1].evaluate(e);return"interpolate"===this.operator?fi[this.type.kind.toLowerCase()](a,l,s):"interpolate-hcl"===this.operator?Qn.reverse(Qn.interpolate(Qn.forward(a),Qn.forward(l),s)):Hn.reverse(Hn.interpolate(Hn.forward(a),Hn.forward(l),s))}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;eMi(r,e.type));return new qn(o?wi:i,n)}evaluate(e){let t,i=null,r=0;for(const n of this.args){if(r++,i=n.evaluate(e),i&&i instanceof zi&&!i.available&&(t||(t=i),i=null,r===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}}class Kn{constructor(e,t){this.type=t.type,this.bindings=[].concat(e),this.result=t}evaluate(e){return this.result.evaluate(e)}eachChild(e){for(const t of this.bindings)e(t[1]);e(this.result)}static parse(e,t){if(e.length<4)return t.error(`Expected at least 3 arguments, but found ${e.length-1} instead.`);const i=[];for(let r=1;r=i.length)throw new Hi("Array index out of bounds: index exceeds array size");if(t!==Math.floor(t))throw new Hi("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 Jn{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,Ai),r=t.parse(e[2],2,Bi(t.expectedType||wi));return i&&r?new Jn(r.type.itemType,i,r):null}evaluate(e){const t=this.index.evaluate(e),i=this.input.evaluate(e);if(t<0)throw new Hi(`Array index out of bounds: ${t} < 0.`);if(t>i.length-1)throw new Hi(`Array index out of bounds: ${t} > ${i.length-1}.`);if(t===Math.floor(t))return i[t];const r=Math.floor(t),n=Math.ceil(t),o=i[r],s=i[n];if("number"!=typeof o||"number"!=typeof s)throw new Hi(`Cannot interpolate between non-number values at index ${t}.`);const a=t-r;return o*(1-a)+s*a}eachChild(e){e(this.index),e(this.input)}outputDefined(){return!1}serialize(){return["at-interpolated",this.index.serialize(),this.input.serialize()]}}class Yn{constructor(e,t){this.type=vi,this.needle=e,this.haystack=t}static parse(e,t){if(3!==e.length)return t.error(`Expected 2 arguments, but found ${e.length-1} instead.`);const i=t.parse(e[1],1,wi),r=t.parse(e[2],2,wi);return i&&r?Pi(i.type,[vi,yi,Ai,_i,wi])?new Yn(i,r):t.error(`Expected first argument to be of type boolean, string, number or null, but found ${Si(i.type)} instead`):null}evaluate(e){const t=this.needle.evaluate(e),i=this.haystack.evaluate(e);if(null==i)return!1;if(!Ri(t,["boolean","string","number","null"]))throw new Hi(`Expected first argument to be of type boolean, string, number or null, but found ${Si(Vi(t))} instead.`);if(!Ri(i,["string","array"]))throw new Hi(`Expected second argument to be of type array or string, but found ${Si(Vi(i))} instead.`);return i.indexOf(t)>=0}eachChild(e){e(this.needle),e(this.haystack)}outputDefined(){return!0}serialize(){return["in",this.needle.serialize(),this.haystack.serialize()]}}class eo{constructor(e,t,i){this.type=Ai,this.needle=e,this.haystack=t,this.fromIndex=i}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.`);const i=t.parse(e[1],1,wi),r=t.parse(e[2],2,wi);if(!i||!r)return null;if(!Pi(i.type,[vi,yi,Ai,_i,wi]))return t.error(`Expected first argument to be of type boolean, string, number or null, but found ${Si(i.type)} instead`);if(4===e.length){const n=t.parse(e[3],3,Ai);return n?new eo(i,r,n):null}return new eo(i,r)}evaluate(e){const t=this.needle.evaluate(e),i=this.haystack.evaluate(e);if(!Ri(t,["boolean","string","number","null"]))throw new Hi(`Expected first argument to be of type boolean, string, number or null, but found ${Si(Vi(t))} instead.`);if(!Ri(i,["string","array"]))throw new Hi(`Expected second argument to be of type array or string, but found ${Si(Vi(i))} instead.`);if(this.fromIndex){const r=this.fromIndex.evaluate(e);return i.indexOf(t,r)}return i.indexOf(t)}eachChild(e){e(this.needle),e(this.haystack),this.fromIndex&&e(this.fromIndex)}outputDefined(){return!1}serialize(){if(null!=this.fromIndex&&void 0!==this.fromIndex){const e=this.fromIndex.serialize();return["index-of",this.needle.serialize(),this.haystack.serialize(),e]}return["index-of",this.needle.serialize(),this.haystack.serialize()]}}class to{constructor(e,t,i,r,n,o){this.inputType=e,this.type=t,this.input=i,this.cases=r,this.outputs=n,this.otherwise=o}static parse(e,t){if(e.length<5)return t.error(`Expected at least 4 arguments, but found only ${e.length-1}.`);if(e.length%2!=1)return t.error("Expected an even number of arguments.");let i,r;t.expectedType&&"value"!==t.expectedType.kind&&(r=t.expectedType);const n={},o=[];for(let s=2;sNumber.MAX_SAFE_INTEGER)return c.error(`Branch labels must be integers no larger than ${Number.MAX_SAFE_INTEGER}.`);if("number"==typeof e&&Math.floor(e)!==e)return c.error("Numeric branch labels must be integer values.");if(i){if(c.checkSubtype(i,Vi(e)))return null}else i=Vi(e);if(void 0!==n[String(e)])return c.error("Branch labels must be unique.");n[String(e)]=o.length}const u=t.parse(l,s,r);if(!u)return null;r=r||u.type,o.push(u)}const s=t.parse(e[1],1,wi);if(!s)return null;const a=t.parse(e[e.length-1],e.length-1,r);return a?"value"!==s.type.kind&&t.concat(1).checkSubtype(i,s.type)?null:new to(i,r,s,n,o,a):null}evaluate(e){const t=this.input.evaluate(e);return(Li(Vi(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=[],r={};for(const e of t){const t=r[this.cases[e]];void 0===t?(r[this.cases[e]]=i.length,i.push([this.cases[e],[e]])):i[t][1].push(e)}const n=e=>"number"===this.inputType.kind?Number(e):e;for(const[t,r]of i)e.push(1===r.length?n(r[0]):r.map(n)),e.push(this.outputs[t].serialize());return e.push(this.otherwise.serialize()),e}}class io{constructor(e,t,i){this.type=e,this.branches=t,this.otherwise=i}static parse(e,t){if(e.length<4)return t.error(`Expected at least 3 arguments, but found only ${e.length-1}.`);if(e.length%2!=0)return t.error("Expected an odd number of arguments.");let i;t.expectedType&&"value"!==t.expectedType.kind&&(i=t.expectedType);const r=[];for(let n=1;nt.outputDefined())&&this.otherwise.outputDefined()}serialize(){const e=["case"];return this.eachChild(t=>{e.push(t.serialize())}),e}}class ro{constructor(e,t,i,r){this.type=e,this.input=t,this.beginIndex=i,this.endIndex=r}static parse(e,t){if(e.length<=2||e.length>=5)return t.error(`Expected 3 or 4 arguments, but found ${e.length-1} instead.`);const i=t.parse(e[1],1,wi),r=t.parse(e[2],2,Ai);if(!i||!r)return null;if(!Pi(i.type,[Bi(wi),yi,wi]))return t.error(`Expected first argument to be of type array or string, but found ${Si(i.type)} instead`);if(4===e.length){const n=t.parse(e[3],3,Ai);return n?new ro(i.type,i,r,n):null}return new ro(i.type,i,r)}evaluate(e){const t=this.input.evaluate(e),i=this.beginIndex.evaluate(e);if(!Ri(t,["string","array"]))throw new Hi(`Expected first argument to be of type array or string, but found ${Si(Vi(t))} instead.`);if(this.endIndex){const r=this.endIndex.evaluate(e);return t.slice(i,r)}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()]}}class no{constructor(e,t){this.type=Bi(yi),this.str=e,this.delimiter=t}static parse(e,t){if(3!==e.length)return t.error(`Expected 2 arguments, but found ${e.length-1} instead.`);const i=t.parse(e[1],1,yi),r=t.parse(e[2],2,yi);return i&&r?new no(i,r):void 0}evaluate(e){const t=this.str.evaluate(e),i=this.delimiter.evaluate(e);return t.split(i)}eachChild(e){e(this.str),e(this.delimiter)}outputDefined(){return!1}serialize(){return["split",this.str.serialize(),this.delimiter.serialize()]}}function oo(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 so(e,t,i,r){return 0===r.compare(t,i)}function ao(e,t,i){const r="=="!==e&&"!="!==e;return class n{constructor(e,t,i){this.type=vi,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,wi);if(!o)return null;if(!oo(i,o.type))return t.concat(1).error(`"${i}" comparisons are not supported for type '${Si(o.type)}'.`);let s=t.parse(e[2],2,wi);if(!s)return null;if(!oo(i,s.type))return t.concat(2).error(`"${i}" comparisons are not supported for type '${Si(s.type)}'.`);if(o.type.kind!==s.type.kind&&"value"!==o.type.kind&&"value"!==s.type.kind)return t.error(`Cannot compare types '${Si(o.type)}' and '${Si(s.type)}'.`);r&&("value"===o.type.kind&&"value"!==s.type.kind?o=new $i(s.type,[o]):"value"!==o.type.kind&&"value"===s.type.kind&&(s=new $i(o.type,[s])));let a=null;if(4===e.length){if("string"!==o.type.kind&&"string"!==s.type.kind&&"value"!==o.type.kind&&"value"!==s.type.kind)return t.error("Cannot use collator to compare non-string types.");if(a=t.parse(e[3],3,Ti),!a)return null}return new n(o,s,a)}evaluate(n){const o=this.lhs.evaluate(n),s=this.rhs.evaluate(n);if(r&&this.hasUntypedArgument){const t=Vi(o),i=Vi(s);if(t.kind!==i.kind||"string"!==t.kind&&"number"!==t.kind)throw new Hi(`Expected arguments for "${e}" to be (string, string) or (number, number), but found (${t.kind}, ${i.kind}) instead.`)}if(this.collator&&!r&&this.hasUntypedArgument){const e=Vi(o),i=Vi(s);if("string"!==e.kind||"string"!==i.kind)return t(n,o,s)}return this.collator?i(n,o,s,this.collator.evaluate(n)):t(n,o,s)}eachChild(e){e(this.lhs),e(this.rhs),this.collator&&e(this.collator)}outputDefined(){return!0}serialize(){const t=[e];return this.eachChild(e=>{t.push(e.serialize())}),t}}}const lo=ao("==",function(e,t,i){return t===i},so),co=ao("!=",function(e,t,i){return t!==i},function(e,t,i,r){return!so(0,t,i,r)}),uo=ao("<",function(e,t,i){return t",function(e,t,i){return t>i},function(e,t,i,r){return r.compare(t,i)>0}),po=ao("<=",function(e,t,i){return t<=i},function(e,t,i,r){return r.compare(t,i)<=0}),fo=ao(">=",function(e,t,i){return t>=i},function(e,t,i,r){return r.compare(t,i)>=0});class mo{constructor(e,t,i,r,n,o){this.type=yi,this.number=e,this.locale=t,this.currency=i,this.unit=r,this.minFractionDigits=n,this.maxFractionDigits=o}static parse(e,t){if(3!==e.length)return t.error("Expected two arguments.");const i=t.parse(e[1],1,Ai);if(!i)return null;const r=e[2];if("object"!=typeof r||Array.isArray(r))return t.error("NumberFormat options argument must be an object.");let n=null;if(r.locale&&(n=t.parseObjectValue(r.locale,2,"locale",yi),!n))return null;let o=null;if(r.currency&&(o=t.parseObjectValue(r.currency,2,"currency",yi),!o))return null;let s=null;if(r.unit&&(s=t.parseObjectValue(r.unit,2,"unit",yi),!s))return null;let a=null;if(r["min-fraction-digits"]&&(a=t.parseObjectValue(r["min-fraction-digits"],2,"min-fraction-digits",Ai),!a))return null;let l=null;return r["max-fraction-digits"]&&(l=t.parseObjectValue(r["max-fraction-digits"],2,"max-fraction-digits",Ai),!l)?null:new mo(i,n,o,s,a,l)}evaluate(e){return new Intl.NumberFormat(this.locale?this.locale.evaluate(e):[],{style:(this.currency?"currency":this.unit&&"unit")||"decimal",currency:this.currency?this.currency.evaluate(e):void 0,unit:this.unit?this.unit.evaluate(e):void 0,minimumFractionDigits:this.minFractionDigits?this.minFractionDigits.evaluate(e):void 0,maximumFractionDigits:this.maxFractionDigits?this.maxFractionDigits.evaluate(e):void 0}).format(this.number.evaluate(e))}eachChild(e){e(this.number),this.locale&&e(this.locale),this.currency&&e(this.currency),this.unit&&e(this.unit),this.minFractionDigits&&e(this.minFractionDigits),this.maxFractionDigits&&e(this.maxFractionDigits)}outputDefined(){return!1}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 go{constructor(e){this.type=Ai,this.input=e}static parse(e,t){if(2!==e.length)return t.error(`Expected 1 argument, but found ${e.length-1} instead.`);const i=t.parse(e[1],1);return i?"array"!==i.type.kind&&"string"!==i.type.kind&&"value"!==i.type.kind?t.error(`Expected argument of type string or array, but found ${Si(i.type)} instead.`):new go(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 Hi(`Expected value to be of type string or array, but found ${Si(Vi(t))} instead.`)}eachChild(e){e(this.input)}outputDefined(){return!1}serialize(){const e=["length"];return this.eachChild(t=>{e.push(t.serialize())}),e}}function _o(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 Ao={"==":lo,"!=":co,">":ho,"<":uo,">=":fo,"<=":po,array:$i,at:Xn,"at-interpolated":Jn,boolean:$i,case:io,coalesce:qn,collator:sr,format:Zi,image:Wi,in:Yn,"index-of":eo,interpolate:Zn,"interpolate-hcl":Zn,"interpolate-lab":Zn,length:go,let:Kn,literal:Gi,match:to,number:$i,"number-format":mo,object:$i,slice:ro,step:Sn,string:$i,"to-boolean":tr,"to-color":tr,"to-number":tr,"to-string":tr,var:Tn,within:Ir,distance:gn,config:wn,split:no};function yo(e,[t,i,r,n]){t=t.evaluate(e),i=i.evaluate(e),r=r.evaluate(e);const o=n?n.evaluate(e):1,s=Ui(t,i,r,o);if(s)throw new Hi(s);return new li(t/255,i/255,r/255,o)}function vo(e,[t,i,r,n]){t=t.evaluate(e),i=i.evaluate(e),r=r.evaluate(e);const o=n?n.evaluate(e):1,s=function(e,t,i,r){return"number"==typeof e&&e>=0&&e<=360?"number"==typeof t&&t>=0&&t<=100&&"number"==typeof i&&i>=0&&i<=100?void 0===r||"number"==typeof r&&r>=0&&r<=1?null:`Invalid hsla value [${[e,t,i,r].join(", ")}]: 'a' must be between 0 and 1.`:`Invalid hsla value [${("number"==typeof r?[e,t,i,r]:[e,t,i]).join(", ")}]: 's', and 'l' must be between 0 and 100.`:`Invalid hsla value [${("number"==typeof r?[e,t,i,r]:[e,t,i]).join(", ")}]: 'h' must be between 0 and 360.`}(t,i,r,o);if(s)throw new Hi(s);const a=`hsla(${t}, ${i}%, ${r}%, ${o})`,l=li.parse(a);if(!l)throw new Hi(`Failed to parse HSLA color: ${a}`);return l}function xo(e,t){return e in t}function bo(e,t){const i=t[e];return void 0===i?null:i}function wo(e){return{type:e}}function To(e){if(e instanceof wn)return new Set([e.key]);let t=new Set;return e.eachChild(e=>{t=new Set([...t,...To(e)])}),t}function Eo(e){if(e instanceof nr&&"is-active-floor"===e.name)return!0;let t=!1;return e.eachChild(e=>{!t&&Eo(e)&&(t=!0)}),t}function Co(e){return{result:"success",value:e}}function Bo(e){return{result:"error",value:e}}function So(e,t){return!!e&&!!e.parameters&&e.parameters.indexOf(t)>-1}function Io(e){return"data-driven"===e["property-type"]}function Mo(e){return So(e.expression,"measure-light")}function Po(e){return So(e.expression,"zoom")}function Ro(e){return!!e.expression&&e.expression.interpolated}function Lo(e){return"object"==typeof e&&null!==e&&!Array.isArray(e)}function Fo(e){return e}function ko(e,t){const i="color"===t.type,r=e.stops&&"object"==typeof e.stops[0][0],n=r||!(r||void 0!==e.property),o=e.type||(Ro(t)?"exponential":"interval");if(i&&((e=Object.assign({},e)).stops&&(e.stops=e.stops.map(e=>[e[0],li.parse(e[1])])),e.default=li.parse(e.default?e.default:t.default)),e.colorSpace&&"rgb"!==e.colorSpace&&!$n[e.colorSpace])throw new Error(`Unknown color space: ${e.colorSpace}`);let s,a,l;if("exponential"===o)s=Uo;else if("interval"===o)s=zo;else if("categorical"===o){s=Oo,a=Object.create(null);for(const t of e.stops)a[t[0]]=t[1];l=typeof e.stops[0][0]}else{if("identity"!==o)throw new Error(`Unknown function type "${o}"`);s=No}if(r){const i={},r=[];for(let t=0;te[0]),evaluate:({zoom:i},r)=>Uo({stops:n,base:e.base},t,i).evaluate(i,r)}}if(n){const i="exponential"===o?{name:"exponential",base:void 0!==e.base?e.base:1}:null;return{kind:"camera",interpolationType:i,interpolationFactor:Zn.interpolationFactor.bind(void 0,i),zoomStops:e.stops.map(e=>e[0]),evaluate:({zoom:i})=>s(e,t,i,a,l)}}return{kind:"source",evaluate(i,r){const n=r&&r.properties?r.properties[e.property]:void 0;return void 0===n?Do(e.default,t.default):s(e,t,n,a,l)}}}function Do(e,t,i){return void 0!==e?e:void 0!==t?t:void 0!==i?i:void 0}function Oo(e,t,i,r,n){return Do(typeof i===n?r[i]:void 0,e.default,t.default)}function zo(e,t,i){if(!Ji(i))return Do(e.default,t.default);const r=e.stops.length;if(1===r)return e.stops[0][1];if(i<=e.stops[0][0])return e.stops[0][1];if(i>=e.stops[r-1][0])return e.stops[r-1][1];const n=Bn(e.stops.map(e=>e[0]),i);return e.stops[n][1]}function Uo(e,t,i){const r=void 0!==e.base?e.base:1;if(!Ji(i))return Do(e.default,t.default);const n=e.stops.length;if(1===n)return e.stops[0][1];if(i<=e.stops[0][0])return e.stops[0][1];if(i>=e.stops[n-1][0])return e.stops[n-1][1];const o=Bn(e.stops.map(e=>e[0]),i),s=function(e,t,i,r){const n=r-i,o=e-i;return 0===n?0:1===t?o/n:(Math.pow(t,o)-1)/(Math.pow(t,n)-1)}(i,r,e.stops[o][0],e.stops[o+1][0]),a=e.stops[o][1],l=e.stops[o+1][1];let c=fi[t.type]||Fo;if(e.colorSpace&&"rgb"!==e.colorSpace){const t=$n[e.colorSpace];c=(e,i)=>t.reverse(t.interpolate(t.forward(e),t.forward(i),s))}return"function"==typeof a.evaluate?{evaluate(...e){const t=a.evaluate.apply(void 0,e),i=l.evaluate.apply(void 0,e);if(void 0!==t&&void 0!==i)return c(t,i,s)}}:c(a,l,s)}function No(e,t,i){return"color"===t.type?i=li.parse(i):"formatted"===t.type?i=Di.fromString(i.toString()):"resolvedImage"===t.type?i=zi.build(i.toString()):qi(i)===t.type||"enum"===t.type&&t.values[i]||(i=void 0),Do(i,e.default,t.default)}nr.register(Ao,{error:[{kind:"error"},[yi],(e,[t])=>{throw new Hi(t.evaluate(e))}],typeof:[yi,[wi],(e,[t])=>Si(Vi(t.evaluate(e)))],"to-rgba":[Bi(Ai,4),[xi],(e,[t])=>t.evaluate(e).toNonPremultipliedRenderColor(null).toArray()],"to-hsla":[Bi(Ai,4),[xi],(e,[t])=>t.evaluate(e).toNonPremultipliedRenderColor(null).toHslaArray()],rgb:[xi,[Ai,Ai,Ai],yo],rgba:[xi,[Ai,Ai,Ai,Ai],yo],hsl:[xi,[Ai,Ai,Ai],vo],hsla:[xi,[Ai,Ai,Ai,Ai],vo],has:{type:vi,overloads:[[[yi],(e,[t])=>xo(t.evaluate(e),e.properties())],[[yi,bi],(e,[t,i])=>xo(t.evaluate(e),i.evaluate(e))]]},get:{type:wi,overloads:[[[yi],(e,[t])=>bo(t.evaluate(e),e.properties())],[[yi,bi],(e,[t,i])=>bo(t.evaluate(e),i.evaluate(e))]]},"feature-state":[wi,[yi],(e,[t])=>bo(t.evaluate(e),e.featureState||{})],properties:[bi,[],e=>e.properties()],"geometry-type":[yi,[],e=>e.geometryType()],worldview:[yi,[],e=>e.globals.worldview||""],"is-active-floor":[vi,wo(yi),(e,t)=>{if(!(e.globals.activeFloors&&e.globals.activeFloors.size>0))return!1;const i=e.globals.activeFloors;return t.some(t=>{const r=t.evaluate(e);return i.has(r)})}],id:[wi,[],e=>e.id()],zoom:[Ai,[],e=>e.globals.zoom],pitch:[Ai,[],e=>e.globals.pitch||0],"distance-from-center":[Ai,[],e=>e.distanceFromCenter()],"measure-light":[Ai,[yi],(e,[t])=>e.measureLight(t.evaluate(e))],"heatmap-density":[Ai,[],e=>e.globals.heatmapDensity||0],"line-progress":[Ai,[],e=>e.globals.lineProgress||0],"raster-value":[Ai,[],e=>e.globals.rasterValue||0],"raster-particle-speed":[Ai,[],e=>e.globals.rasterParticleSpeed||0],"sky-radial-progress":[Ai,[],e=>e.globals.skyRadialProgress||0],accumulated:[wi,[],e=>void 0===e.globals.accumulated?null:e.globals.accumulated],"+":[Ai,wo(Ai),(e,t)=>{let i=0;for(const r of t)i+=r.evaluate(e);return i}],"*":[Ai,wo(Ai),(e,t)=>{let i=1;for(const r of t)i*=r.evaluate(e);return i}],"-":{type:Ai,overloads:[[[Ai,Ai],(e,[t,i])=>t.evaluate(e)-i.evaluate(e)],[[Ai],(e,[t])=>-t.evaluate(e)]]},"/":[Ai,[Ai,Ai],(e,[t,i])=>t.evaluate(e)/i.evaluate(e)],"%":[Ai,[Ai,Ai],(e,[t,i])=>t.evaluate(e)%i.evaluate(e)],ln2:[Ai,[],()=>Math.LN2],pi:[Ai,[],()=>Math.PI],e:[Ai,[],()=>Math.E],"^":[Ai,[Ai,Ai],(e,[t,i])=>Math.pow(t.evaluate(e),i.evaluate(e))],sqrt:[Ai,[Ai],(e,[t])=>Math.sqrt(t.evaluate(e))],log10:[Ai,[Ai],(e,[t])=>Math.log(t.evaluate(e))/Math.LN10],ln:[Ai,[Ai],(e,[t])=>Math.log(t.evaluate(e))],log2:[Ai,[Ai],(e,[t])=>Math.log2(t.evaluate(e))],sin:[Ai,[Ai],(e,[t])=>Math.sin(t.evaluate(e))],cos:[Ai,[Ai],(e,[t])=>Math.cos(t.evaluate(e))],tan:[Ai,[Ai],(e,[t])=>Math.tan(t.evaluate(e))],asin:[Ai,[Ai],(e,[t])=>Math.asin(t.evaluate(e))],acos:[Ai,[Ai],(e,[t])=>Math.acos(t.evaluate(e))],atan:[Ai,[Ai],(e,[t])=>Math.atan(t.evaluate(e))],min:[Ai,wo(Ai),(e,t)=>Math.min(...t.map(t=>t.evaluate(e)))],max:[Ai,wo(Ai),(e,t)=>Math.max(...t.map(t=>t.evaluate(e)))],abs:[Ai,[Ai],(e,[t])=>Math.abs(t.evaluate(e))],round:[Ai,[Ai],(e,[t])=>{const i=t.evaluate(e);return i<0?-Math.round(-i):Math.round(i)}],floor:[Ai,[Ai],(e,[t])=>Math.floor(t.evaluate(e))],ceil:[Ai,[Ai],(e,[t])=>Math.ceil(t.evaluate(e))],"filter-==":[vi,[yi,wi],(e,[t,i])=>e.properties()[t.value]===i.value],"filter-id-==":[vi,[wi],(e,[t])=>e.id()===t.value],"filter-type-==":[vi,[yi],(e,[t])=>e.geometryType()===t.value],"filter-<":[vi,[yi,wi],(e,[t,i])=>{const r=e.properties()[t.value],n=i.value;return typeof r==typeof n&&r{const i=e.id(),r=t.value;return typeof i==typeof r&&i":[vi,[yi,wi],(e,[t,i])=>{const r=e.properties()[t.value],n=i.value;return typeof r==typeof n&&r>n}],"filter-id->":[vi,[wi],(e,[t])=>{const i=e.id(),r=t.value;return typeof i==typeof r&&i>r}],"filter-<=":[vi,[yi,wi],(e,[t,i])=>{const r=e.properties()[t.value],n=i.value;return typeof r==typeof n&&r<=n}],"filter-id-<=":[vi,[wi],(e,[t])=>{const i=e.id(),r=t.value;return typeof i==typeof r&&i<=r}],"filter->=":[vi,[yi,wi],(e,[t,i])=>{const r=e.properties()[t.value],n=i.value;return typeof r==typeof n&&r>=n}],"filter-id->=":[vi,[wi],(e,[t])=>{const i=e.id(),r=t.value;return typeof i==typeof r&&i>=r}],"filter-has":[vi,[wi],(e,[t])=>t.value in e.properties()],"filter-has-id":[vi,[],e=>null!==e.id()&&void 0!==e.id()],"filter-type-in":[vi,[Bi(yi)],(e,[t])=>t.value.indexOf(e.geometryType())>=0],"filter-id-in":[vi,[Bi(wi)],(e,[t])=>t.value.indexOf(e.id())>=0],"filter-in-small":[vi,[yi,Bi(wi)],(e,[t,i])=>i.value.indexOf(e.properties()[t.value])>=0],"filter-in-large":[vi,[yi,Bi(wi)],(e,[t,i])=>function(e,t,i,r){for(;i<=r;){const n=i+r>>1;if(t[n]===e)return!0;t[n]>e?r=n-1:i=n+1}return!1}(e.properties()[t.value],i.value,0,i.value.length-1)],all:{type:vi,overloads:[[[vi,vi],(e,[t,i])=>t.evaluate(e)&&i.evaluate(e)],[wo(vi),(e,t)=>{for(const i of t)if(!i.evaluate(e))return!1;return!0}]]},any:{type:vi,overloads:[[[vi,vi],(e,[t,i])=>t.evaluate(e)||i.evaluate(e)],[wo(vi),(e,t)=>{for(const i of t)if(i.evaluate(e))return!0;return!1}]]},"!":[vi,[vi],(e,[t])=>!t.evaluate(e)],"is-supported-script":[vi,[yi],(e,[t])=>{const i=e.globals&&e.globals.isSupportedScript;return!i||i(t.evaluate(e))}],upcase:[yi,[yi],(e,[t])=>t.evaluate(e).toUpperCase()],downcase:[yi,[yi],(e,[t])=>t.evaluate(e).toLowerCase()],concat:[yi,wo(wi),(e,t)=>t.map(t=>ji(t.evaluate(e))).join("")],"resolved-locale":[yi,[Ti],(e,[t])=>t.evaluate(e).resolvedLocale()],random:[Ai,[Ai,Ai,wi],(e,t)=>{const[i,r,n]=t.map(t=>t.evaluate(e));if(i>r)return i;if(i===r)return i;let o;if("string"==typeof n)o=function(e){let t=0;if(0===e.length)return t;for(let i=0;iJSON.stringify(e)).join(", ")}, but found ${JSON.stringify(e)} instead.`);return e}catch(e){return this._warningHistory[e.message]||(this._warningHistory[e.message]=!0,"undefined"!=typeof console&&console.warn(`Failed to evaluate expression "${JSON.stringify(this.expression.serialize())}". ${e.message}`)),this._defaultValue}}}function jo(e){return Array.isArray(e)&&e.length>0&&"string"==typeof e[0]&&e[0]in Ao}function Go(e,t,i,r,n){const o=new En(Ao,[],t?function(e){const t={color:xi,string:yi,number:Ai,enum:yi,boolean:vi,formatted:Ei,resolvedImage:Ci};return"array"===e.type?Bi(t[e.value]||wi,e.length):t[e.type]}(t):void 0,void 0,void 0,i,r,n),s=o.parse(e,void 0,void 0,void 0,t&&"string"===t.type?{typeAnnotation:"coerce"}:void 0);return s?Co(new Vo(s,t,i,r,n)):Bo(o.errors)}class Ho{constructor(e,t,i,r){this.kind=e,this._styleExpression=t,this.isLightConstant=i,this.isLineProgressConstant=r,this.isStateDependent="constant"!==e&&!An(t.expression),this.configDependencies=To(t.expression),this.isIndoorDependent=Eo(t.expression)}evaluateWithoutErrorHandling(e,t,i,r,n,o){return this._styleExpression.evaluateWithoutErrorHandling(e,t,i,r,n,o)}evaluate(e,t,i,r,n,o,s){return this._styleExpression.evaluate(e,t,i,r,n,o,void 0,void 0,s)}}class Qo{constructor(e,t,i,r,n,o){this.kind=e,this.zoomStops=i,this._styleExpression=t,this.isStateDependent="camera"!==e&&!An(t.expression),this.isIndoorDependent=Eo(t.expression),this.isLightConstant=n,this.isLineProgressConstant=o,this.configDependencies=To(t.expression),this.interpolationType=r}evaluateWithoutErrorHandling(e,t,i,r,n,o){return this._styleExpression.evaluateWithoutErrorHandling(e,t,i,r,n,o)}evaluate(e,t,i,r,n,o){return this._styleExpression.evaluate(e,t,i,r,n,o)}interpolationFactor(e,t,i){return this.interpolationType?Zn.interpolationFactor(this.interpolationType,e,t,i):0}}function $o(e,t,i,r,n){if("error"===(e=Go(e,t,i,r,n)).result)return e;const o=e.value.expression,s=_n(o);if(!s&&!Io(t))return Bo([new mi("","data expressions not supported")]);const a=yn(o,["zoom","pitch","distance-from-center"]);if(!a&&!Po(t))return Bo([new mi("","zoom expressions not supported")]);const l=yn(o,["measure-light"]);if(!l&&!Mo(t))return Bo([new mi("","measure-light expression not supported")]);const c=yn(o,["line-progress"]);if(!c&&!function(e){return So(e.expression,"line-progress")}(t))return Bo([new mi("","line-progress expression not supported")]);const u=t.expression&&t.expression.relaxZoomRestriction,h=Wo(o);return h||a||u?h instanceof mi?Bo([h]):h instanceof Zn&&!Ro(t)?Bo([new mi("",'"interpolate" expressions cannot be used with this property')]):Co(h?new Qo(s&&c?"camera":"composite",e.value,h.labels,h instanceof Zn?h.interpolation:void 0,l,c):new Ho(s&&c?"constant":"source",e.value,l,c)):Bo([new mi("",'"zoom" expression may only be used as input to a top-level "step" or "interpolate" expression, or in the properties of atmosphere.')])}class Zo{constructor(e,t){this._parameters=e,this._specification=t,Object.assign(this,ko(this._parameters,this._specification))}static deserialize(e){return new Zo(e._parameters,e._specification)}static serialize(e){return{_parameters:e._parameters,_specification:e._specification}}}function Wo(e){let t=null;if(e instanceof Kn)t=Wo(e.result);else if(e instanceof qn){for(const i of e.args)if(t=Wo(i),t)break}else(e instanceof Sn||e instanceof Zn)&&e.input instanceof nr&&"zoom"===e.input.name&&(t=e);return t instanceof mi||e.eachChild(e=>{const i=Wo(e);i instanceof mi?t=i:t&&i&&t!==i&&(t=new mi("",'Only one zoom-based "step" or "interpolate" subexpression may be used in an expression.'))}),t}var qo,Ko,Xo=function(){if(Ko)return qo;Ko=1,qo=t;var e=3;function t(t,i,r){var n=this.cells=[];if(t instanceof ArrayBuffer){this.arrayBuffer=t;var o=new Int32Array(this.arrayBuffer);t=o[0],this.d=(i=o[1])+2*(r=o[2]);for(var s=0;s=u[p+0]&&r>=u[p+1])?(s[d]=!0,o.push(c[d])):s[d]=!1}}},t.prototype._forEachCell=function(e,t,i,r,n,o,s,a){for(var l=this._convertToCellCoord(e),c=this._convertToCellCoord(t),u=this._convertToCellCoord(i),h=this._convertToCellCoord(r),d=l;d<=u;d++)for(var p=c;p<=h;p++){var f=this.d*p+d;if((!a||a(this._convertFromCellCoord(d),this._convertFromCellCoord(p),this._convertFromCellCoord(d+1),this._convertFromCellCoord(p+1)))&&n.call(this,e,t,i,r,f,o,s,a))return}},t.prototype._convertFromCellCoord=function(e){return(e-this.padding)/this.scale},t.prototype._convertToCellCoord=function(e){return Math.max(0,Math.min(this.d-1,Math.floor(e*this.scale)+this.padding))},t.prototype.toArrayBuffer=function(){if(this.arrayBuffer)return this.arrayBuffer;for(var t=this.cells,i=e+this.cells.length+1+1,r=0,n=0;n=0||(n[i]=rs(e[i],t)));e instanceof Error&&(n.message=e.message)}if(n.$name)throw new Error("$name property is reserved for worker serialization logic.");return"Object"!==r&&(n.$name=r),n}throw new Error("can't serialize object of type "+typeof e)}function ns(e){if(null==e||"boolean"==typeof e||"number"==typeof e||"string"==typeof e||e instanceof Boolean||e instanceof Number||e instanceof String||e instanceof Date||e instanceof RegExp||ts(e)||is(e)||ArrayBuffer.isView(e)||e instanceof ImageData)return e;if(Array.isArray(e))return e.map(ns);if("object"==typeof e){const t=e.$name||"Object";if("Map"===t){const t=e.entries||[],i=new Map;for(let e=0;ee>=128&&e<=255,Arabic:e=>e>=1536&&e<=1791,"Arabic Supplement":e=>e>=1872&&e<=1919,"Arabic Extended-A":e=>e>=2208&&e<=2303,"Hangul Jamo":e=>e>=4352&&e<=4607,"Unified Canadian Aboriginal Syllabics":e=>e>=5120&&e<=5759,Khmer:e=>e>=6016&&e<=6143,"Unified Canadian Aboriginal Syllabics Extended":e=>e>=6320&&e<=6399,"General Punctuation":e=>e>=8192&&e<=8303,"Letterlike Symbols":e=>e>=8448&&e<=8527,"Number Forms":e=>e>=8528&&e<=8591,"Miscellaneous Technical":e=>e>=8960&&e<=9215,"Control Pictures":e=>e>=9216&&e<=9279,"Optical Character Recognition":e=>e>=9280&&e<=9311,"Enclosed Alphanumerics":e=>e>=9312&&e<=9471,"Geometric Shapes":e=>e>=9632&&e<=9727,"Miscellaneous Symbols":e=>e>=9728&&e<=9983,"Miscellaneous Symbols and Arrows":e=>e>=11008&&e<=11263,"CJK Radicals Supplement":e=>e>=11904&&e<=12031,"Kangxi Radicals":e=>e>=12032&&e<=12255,"Ideographic Description Characters":e=>e>=12272&&e<=12287,"CJK Symbols and Punctuation":e=>e>=12288&&e<=12351,Hiragana:e=>e>=12352&&e<=12447,Katakana:e=>e>=12448&&e<=12543,Bopomofo:e=>e>=12544&&e<=12591,"Hangul Compatibility Jamo":e=>e>=12592&&e<=12687,Kanbun:e=>e>=12688&&e<=12703,"Bopomofo Extended":e=>e>=12704&&e<=12735,"CJK Strokes":e=>e>=12736&&e<=12783,"Katakana Phonetic Extensions":e=>e>=12784&&e<=12799,"Enclosed CJK Letters and Months":e=>e>=12800&&e<=13055,"CJK Compatibility":e=>e>=13056&&e<=13311,"CJK Unified Ideographs Extension A":e=>e>=13312&&e<=19903,"Yijing Hexagram Symbols":e=>e>=19904&&e<=19967,"CJK Unified Ideographs":e=>e>=19968&&e<=40959,"Yi Syllables":e=>e>=40960&&e<=42127,"Yi Radicals":e=>e>=42128&&e<=42191,"Hangul Jamo Extended-A":e=>e>=43360&&e<=43391,"Hangul Syllables":e=>e>=44032&&e<=55215,"Hangul Jamo Extended-B":e=>e>=55216&&e<=55295,"Private Use Area":e=>e>=57344&&e<=63743,"CJK Compatibility Ideographs":e=>e>=63744&&e<=64255,"Arabic Presentation Forms-A":e=>e>=64336&&e<=65023,"Vertical Forms":e=>e>=65040&&e<=65055,"CJK Compatibility Forms":e=>e>=65072&&e<=65103,"Small Form Variants":e=>e>=65104&&e<=65135,"Arabic Presentation Forms-B":e=>e>=65136&&e<=65279,"Halfwidth and Fullwidth Forms":e=>e>=65280&&e<=65519,Osage:e=>e>=66736&&e<=66815,"CJK Unified Ideographs Extension B":e=>e>=131072&&e<=173791};function ss(e){for(const t of e)if(cs(t.charCodeAt(0)))return!0;return!1}function as(e){for(const t of e)if(!ls(t.charCodeAt(0)))return!1;return!0}function ls(e){return!(os.Arabic(e)||os["Arabic Supplement"](e)||os["Arabic Extended-A"](e)||os["Arabic Presentation Forms-A"](e)||os["Arabic Presentation Forms-B"](e))}function cs(e){return!(746!==e&&747!==e&&(e<4352||!(os["Bopomofo Extended"](e)||os.Bopomofo(e)||os["CJK Compatibility Forms"](e)&&!(e>=65097&&e<=65103)||os["CJK Compatibility Ideographs"](e)||os["CJK Compatibility"](e)||os["CJK Radicals Supplement"](e)||os["CJK Strokes"](e)||!(!os["CJK Symbols and Punctuation"](e)||e>=12296&&e<=12305||e>=12308&&e<=12319||12336===e)||os["CJK Unified Ideographs Extension A"](e)||os["CJK Unified Ideographs"](e)||os["Enclosed CJK Letters and Months"](e)||os["Hangul Compatibility Jamo"](e)||os["Hangul Jamo Extended-A"](e)||os["Hangul Jamo Extended-B"](e)||os["Hangul Jamo"](e)||os["Hangul Syllables"](e)||os.Hiragana(e)||os["Ideographic Description Characters"](e)||os.Kanbun(e)||os["Kangxi Radicals"](e)||os["Katakana Phonetic Extensions"](e)||os.Katakana(e)&&12540!==e||!(!os["Halfwidth and Fullwidth Forms"](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)||!(!os["Small Form Variants"](e)||e>=65112&&e<=65118||e>=65123&&e<=65126)||os["Unified Canadian Aboriginal Syllabics"](e)||os["Unified Canadian Aboriginal Syllabics Extended"](e)||os["Vertical Forms"](e)||os["Yijing Hexagram Symbols"](e)||os["Yi Syllables"](e)||os["Yi Radicals"](e))))}function us(e){return!(cs(e)||function(e){return!!(os["Latin-1 Supplement"](e)&&(167===e||169===e||174===e||177===e||188===e||189===e||190===e||215===e||247===e)||os["General Punctuation"](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)||os["Letterlike Symbols"](e)||os["Number Forms"](e)||os["Miscellaneous Technical"](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)||os["Control Pictures"](e)&&9251!==e||os["Optical Character Recognition"](e)||os["Enclosed Alphanumerics"](e)||os["Geometric Shapes"](e)||os["Miscellaneous Symbols"](e)&&!(e>=9754&&e<=9759)||os["Miscellaneous Symbols and Arrows"](e)&&(e>=11026&&e<=11055||e>=11088&&e<=11097||e>=11192&&e<=11243)||os["CJK Symbols and Punctuation"](e)||os.Katakana(e)||os["Private Use Area"](e)||os["CJK Compatibility Forms"](e)||os["Small Form Variants"](e)||os["Halfwidth and Fullwidth Forms"](e)||8734===e||8756===e||8757===e||e>=9984&&e<=10087||e>=10102&&e<=10131||65532===e||65533===e)}(e))}function hs(e){return os.Arabic(e)||os["Arabic Supplement"](e)||os["Arabic Extended-A"](e)||os["Arabic Presentation Forms-A"](e)||os["Arabic Presentation Forms-B"](e)}function ds(e){return e>=1424&&e<=2303||os["Arabic Presentation Forms-A"](e)||os["Arabic Presentation Forms-B"](e)}function ps(e,t){return!(!t&&ds(e)||e>=2304&&e<=3583||e>=3840&&e<=4255||os.Khmer(e))}function fs(e){for(const t of e)if(ds(t.charCodeAt(0)))return!0;return!1}const ms={unavailable:"unavailable",deferred:"deferred",loading:"loading",parsing:"parsing",parsed:"parsed",loaded:"loaded",error:"error"};let gs=null,_s=ms.unavailable,As=null;const ys=function(e){e&&"string"==typeof e&&e.indexOf("NetworkError")>-1&&(_s=ms.error),gs&&gs(e)};function vs(){xs.fire(new Yt("pluginStateChange",{pluginStatus:_s,pluginURL:As}))}const xs=new ri,bs=function(){return _s},ws=function(){if(_s!==ms.deferred||!As)throw new Error("rtl-text-plugin cannot be downloaded unless a pluginURL is specified");_s=ms.loading,vs(),As&&Ut({url:As},e=>{e?ys(e):(_s=ms.loaded,vs())})},Ts={applyArabicShaping:null,processBidirectionalText:null,processStyledBidirectionalText:null,isLoaded:()=>_s===ms.loaded||null!=Ts.applyArabicShaping,isLoading:()=>_s===ms.loading,setState(e){_s=e.pluginStatus,As=e.pluginURL},isParsing:()=>_s===ms.parsing,isParsed:()=>_s===ms.parsed,getPluginURL:()=>As};class Es{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(!ps(i.charCodeAt(0),t))return!1;return!0}(e,Ts.isLoaded())}}class Cs{constructor(e,t,i,r,n){this.property=e,this.value=t,this.expression=function(e,t,i,r,n){if(Lo(e))return new Zo(e,t);if(jo(e)||Array.isArray(e)&&e.length>0){const o=$o(e,t,i,r,n);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=li.parse(e)),{kind:"constant",configDependencies:new Set,isIndoorDependent:!1,evaluate:()=>i}}}(void 0===t?e.specification.default:t,e.specification,i,r,n)}isIndoorDependent(){return this.expression.isIndoorDependent}isDataDriven(){return"source"===this.expression.kind||"composite"===this.expression.kind}possiblyEvaluate(e,t,i,r){return this.property.possiblyEvaluate(this,e,t,i,r)}}class Bs{constructor(e,t,i,r){this.property=e,this.value=new Cs(e,void 0,t,i,r)}transitioned(e,t){return new Is(this.property,this.value,t,Object.assign({},e.transition,this.transition),e.now)}untransitioned(){return new Is(this.property,this.value,null,{},0)}}class Ss{constructor(e,t,i,r){this._properties=e,this._values=Object.create(e.defaultTransitionablePropertyValues),this._scope=t,this._options=i,this._iconImageUseTheme=r,this._isIndoorDependent=!1,this.configDependencies=new Set}getValue(e){return He(this._values[e].value.value)}setValue(e,t){this._values.hasOwnProperty(e)||(this._values[e]=new Bs(this._values[e].property,this._scope,this._options,this._iconImageUseTheme)),this._values[e].value=new Cs(this._values[e].property,null===t?void 0:He(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 r=e[t];if(t.endsWith("-transition")){const e=t.slice(0,-11);i[e]&&this.setTransition(e,r)}else i.hasOwnProperty(t)&&this.setValue(t,r)}}getTransition(e){return He(this._values[e].transition)}setTransition(e,t){this._values.hasOwnProperty(e)||(this._values[e]=new Bs(this._values[e].property)),this._values[e].transition=He(t)||void 0}serialize(){const e={};for(const t of Object.keys(this._values)){const i=this.getValue(t);void 0!==i&&(e[t]=i);const r=this.getTransition(t);void 0!==r&&(e[`${t}-transition`]=r)}return e}transitioned(e,t){const i=new Ms(this._properties);for(const r of Object.keys(this._values))i._values[r]=this._values[r].transitioned(e,t._values[r]);return i}untransitioned(){const e=new Ms(this._properties);for(const t of Object.keys(this._values))e._values[t]=this._values[t].untransitioned();return e}isIndoorDependent(){return this._isIndoorDependent}}class Is{constructor(e,t,i,r,n){const o=r.delay||0,s=r.duration||0;n=n||0,this.property=e,this.value=t,this.begin=n+o,this.end=this.begin+s,e.specification.transition&&(r.delay||r.duration)&&(this.prior=i)}possiblyEvaluate(e,t,i){const r=e.now||0,n=this.value.possiblyEvaluate(e,t,i),o=this.prior;if(o){if(r>this.end)return this.prior=null,n;if(this.value.isDataDriven())return this.prior=null,n;if(r":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":{"expression":{"type":"expression"},"stops":{"type":"array","value":"function_stop"},"base":{"type":"number","default":1,"minimum":0},"property":{"type":"string","default":"$zoom"},"type":{"type":"enum","values":{"identity":1,"exponential":1,"interval":1,"categorical":1},"default":"exponential"},"colorSpace":{"type":"enum","values":{"rgb":1,"lab":1,"hcl":1},"default":"rgb"},"default":{"type":"*"}},"function_stop":{"type":"array","minimum":0,"maximum":24,"value":["number","color"],"length":2},"expression":{"type":"array","value":"*","minimum":1},"fog":{"range":{"type":"array","default":[0.5,10],"minimum":-20,"maximum":20,"length":2,"value":"number","transition":true,"expression":{"interpolated":true,"parameters":["zoom","measure-light"],"relaxZoomRestriction":true}},"color":{"type":"color","default":"#ffffff","expression":{"interpolated":true,"parameters":["zoom","measure-light"],"relaxZoomRestriction":true},"use-theme":true,"transition":true},"high-color":{"type":"color","default":"#245cdf","expression":{"interpolated":true,"parameters":["zoom","measure-light"],"relaxZoomRestriction":true},"use-theme":true,"transition":true},"space-color":{"type":"color","default":["interpolate",["linear"],["zoom"],4,"#010b19",7,"#367ab9"],"expression":{"interpolated":true,"parameters":["zoom","measure-light"],"relaxZoomRestriction":true},"use-theme":true,"transition":true},"horizon-blend":{"type":"number","default":["interpolate",["linear"],["zoom"],4,0.2,7,0.1],"minimum":0,"maximum":1,"expression":{"interpolated":true,"parameters":["zoom","measure-light"],"relaxZoomRestriction":true},"transition":true},"star-intensity":{"type":"number","default":["interpolate",["linear"],["zoom"],5,0.35,6,0],"minimum":0,"maximum":1,"expression":{"interpolated":true,"parameters":["zoom","measure-light"],"relaxZoomRestriction":true},"transition":true},"vertical-range":{"type":"array","default":[0,0],"minimum":0,"length":2,"value":"number","transition":true,"expression":{"interpolated":true,"parameters":["zoom","measure-light"],"relaxZoomRestriction":true}}},"snow":{"density":{"type":"number","default":["interpolate",["linear"],["zoom"],11,0,13,0.85],"minimum":0,"maximum":1,"expression":{"interpolated":true,"parameters":["zoom","measure-light"],"relaxZoomRestriction":true},"transition":true},"intensity":{"type":"number","default":1,"minimum":0,"maximum":1,"expression":{"interpolated":true,"parameters":["zoom","measure-light"],"relaxZoomRestriction":true},"transition":true},"color":{"type":"color","default":"#ffffff","expression":{"interpolated":true,"parameters":["zoom","measure-light"],"relaxZoomRestriction":true},"use-theme":true,"transition":true},"opacity":{"type":"number","default":1,"minimum":0,"maximum":1,"expression":{"interpolated":true,"parameters":["zoom","measure-light"],"relaxZoomRestriction":true},"transition":true},"vignette":{"type":"number","default":["interpolate",["linear"],["zoom"],11,0,13,0.3],"minimum":0,"maximum":1,"expression":{"interpolated":true,"parameters":["zoom","measure-light"],"relaxZoomRestriction":true},"transition":true},"vignette-color":{"type":"color","default":"#ffffff","expression":{"interpolated":true,"parameters":["zoom","measure-light"],"relaxZoomRestriction":true},"use-theme":true,"transition":true},"center-thinning":{"type":"number","default":0.4,"minimum":0,"maximum":1,"expression":{"interpolated":true,"parameters":["zoom","measure-light"],"relaxZoomRestriction":true},"transition":true},"direction":{"type":"array","default":[0,50],"minimum":0,"maximum":360,"length":2,"value":"number","transition":true,"expression":{"interpolated":true,"parameters":["zoom","measure-light"],"relaxZoomRestriction":true}},"flake-size":{"type":"number","default":0.71,"minimum":0,"maximum":5,"expression":{"interpolated":true,"parameters":["zoom","measure-light"],"relaxZoomRestriction":true},"transition":true}},"rain":{"density":{"type":"number","default":["interpolate",["linear"],["zoom"],11,0,13,0.5],"minimum":0,"maximum":1,"expression":{"interpolated":true,"parameters":["zoom","measure-light"],"relaxZoomRestriction":true},"transition":true},"intensity":{"type":"number","default":1,"minimum":0,"maximum":1,"expression":{"interpolated":true,"parameters":["zoom","measure-light"],"relaxZoomRestriction":true},"transition":true},"color":{"type":"color","default":["interpolate",["linear"],["measure-light","brightness"],0,"#03113d",0.3,"#a8adbc"],"expression":{"interpolated":true,"parameters":["zoom","measure-light"],"relaxZoomRestriction":true},"use-theme":true,"transition":true},"opacity":{"type":"number","default":["interpolate",["linear"],["measure-light","brightness"],0,0.88,1,0.7],"minimum":0,"maximum":1,"expression":{"interpolated":true,"parameters":["zoom","measure-light"],"relaxZoomRestriction":true},"transition":true},"vignette":{"type":"number","default":["interpolate",["linear"],["zoom"],11,0,13,1],"minimum":0,"maximum":1,"expression":{"interpolated":true,"parameters":["zoom","measure-light"],"relaxZoomRestriction":true},"transition":true},"vignette-color":{"type":"color","default":["interpolate",["linear"],["measure-light","brightness"],0,"#001736",0.3,"#464646"],"expression":{"interpolated":true,"parameters":["zoom","measure-light"],"relaxZoomRestriction":true},"use-theme":true,"transition":true},"center-thinning":{"type":"number","default":0.57,"minimum":0,"maximum":1,"expression":{"interpolated":true,"parameters":["zoom","measure-light"],"relaxZoomRestriction":true},"transition":true},"direction":{"type":"array","default":[0,80],"minimum":0,"maximum":360,"length":2,"value":"number","transition":true,"expression":{"interpolated":true,"parameters":["zoom","measure-light"],"relaxZoomRestriction":true}},"droplet-size":{"type":"array","default":[2.6,18.2],"minimum":0,"maximum":50,"length":2,"value":"number","transition":true,"expression":{"interpolated":true,"parameters":["zoom","measure-light"],"relaxZoomRestriction":true}},"distortion-strength":{"type":"number","default":0.7,"minimum":0,"maximum":1,"expression":{"interpolated":true,"parameters":["zoom","measure-light"],"relaxZoomRestriction":true},"transition":true}},"camera":{"camera-projection":{"type":"enum","values":{"perspective":1,"orthographic":1},"transition":true,"expression":{"interpolated":true,"parameters":["zoom"]},"default":"perspective"}},"colorTheme":{"data":{"type":"string","expression":{}}},"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","transition":true,"expression":{"interpolated":true,"parameters":["zoom"]}},"color":{"type":"color","default":"#ffffff","expression":{"interpolated":true,"parameters":["zoom"]},"use-theme":true,"transition":true},"intensity":{"type":"number","default":0.5,"minimum":0,"maximum":1,"expression":{"interpolated":true,"parameters":["zoom"]},"transition":true}},"projection":{"name":{"type":"enum","values":{"albers":1,"equalEarth":1,"equirectangular":1,"lambertConformalConic":1,"mercator":1,"naturalEarth":1,"winkelTripel":1,"globe":1},"default":"mercator"},"center":{"type":"array","length":2,"value":"number","minimum":[-180,-90],"maximum":[180,90]},"parallels":{"type":"array","length":2,"value":"number","minimum":[-90,-90],"maximum":[90,90]}},"terrain":{"source":{"type":"string"},"exaggeration":{"type":"number","default":1,"minimum":0,"maximum":1000,"expression":{"interpolated":true,"parameters":["zoom"]},"transition":true}},"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,"transition":true,"expression":{"interpolated":true,"parameters":["zoom","feature","feature-state","measure-light"]},"property-type":"data-driven"},"fill-color":{"type":"color","default":"#000000","use-theme":true,"transition":true,"expression":{"interpolated":true,"parameters":["zoom","feature","feature-state","measure-light"]},"property-type":"data-driven"},"fill-outline-color":{"type":"color","use-theme":true,"transition":true,"expression":{"interpolated":true,"parameters":["zoom","feature","feature-state","measure-light"]},"property-type":"data-driven"},"fill-translate":{"type":"array","value":"number","length":2,"default":[0,0],"transition":true,"expression":{"interpolated":true,"parameters":["zoom"]}},"fill-translate-anchor":{"type":"enum","values":{"map":1,"viewport":1},"default":"map","expression":{"parameters":["zoom"]}},"fill-pattern":{"type":"resolvedImage","expression":{"parameters":["zoom","feature"]},"property-type":"data-driven"},"fill-pattern-cross-fade":{"type":"number","default":0,"minimum":0,"maximum":1,"expression":{"interpolated":true,"parameters":["zoom","measure-light"]}},"fill-emissive-strength":{"type":"number","default":0,"minimum":0,"transition":true,"expression":{"interpolated":true,"parameters":["zoom","measure-light"]}},"fill-z-offset":{"type":"number","default":0,"minimum":0,"transition":true,"expression":{"interpolated":true,"parameters":["zoom","feature"]},"property-type":"data-driven"},"fill-bridge-guard-rail-color":{"type":"color","default":"rgba(241, 236, 225, 255)","use-theme":true,"transition":true,"expression":{"interpolated":true,"parameters":["zoom","measure-light","feature"]},"property-type":"data-driven"},"fill-tunnel-structure-color":{"type":"color","default":"rgba(241, 236, 225, 255)","use-theme":true,"transition":true,"expression":{"interpolated":true,"parameters":["zoom","measure-light","feature"]},"property-type":"data-driven"}},"paint_fill-extrusion":{"fill-extrusion-opacity":{"type":"number","default":1,"minimum":0,"maximum":1,"transition":true,"expression":{"interpolated":true,"parameters":["zoom"]}},"fill-extrusion-color":{"type":"color","default":"#000000","use-theme":true,"transition":true,"expression":{"interpolated":true,"parameters":["zoom","feature","feature-state","measure-light"]},"property-type":"data-driven"},"fill-extrusion-translate":{"type":"array","value":"number","length":2,"default":[0,0],"transition":true,"expression":{"interpolated":true,"parameters":["zoom"]}},"fill-extrusion-translate-anchor":{"type":"enum","values":{"map":1,"viewport":1},"default":"map","expression":{"parameters":["zoom"]}},"fill-extrusion-pattern":{"type":"resolvedImage","expression":{"parameters":["zoom","feature"]},"property-type":"data-driven"},"fill-extrusion-pattern-cross-fade":{"type":"number","default":0,"minimum":0,"maximum":1,"expression":{"interpolated":true,"parameters":["zoom","measure-light"]}},"fill-extrusion-height":{"type":"number","default":0,"minimum":0,"transition":true,"expression":{"interpolated":true,"parameters":["zoom","feature","feature-state"]},"property-type":"data-driven"},"fill-extrusion-base":{"type":"number","default":0,"minimum":0,"transition":true,"expression":{"interpolated":true,"parameters":["zoom","feature","feature-state"]},"property-type":"data-driven"},"fill-extrusion-height-alignment":{"type":"enum","values":{"terrain":1,"flat":1},"default":"flat"},"fill-extrusion-base-alignment":{"type":"enum","values":{"terrain":1,"flat":1},"default":"terrain"},"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":true,"parameters":["zoom"]},"transition":true},"fill-extrusion-ambient-occlusion-radius":{"type":"number","default":3,"minimum":0,"expression":{"interpolated":true,"parameters":["zoom"]},"transition":true},"fill-extrusion-ambient-occlusion-wall-radius":{"type":"number","default":3,"minimum":0,"expression":{"interpolated":true,"parameters":["zoom"]},"transition":true},"fill-extrusion-ambient-occlusion-ground-radius":{"type":"number","default":3,"minimum":0,"expression":{"interpolated":true,"parameters":["zoom"]},"transition":true},"fill-extrusion-ambient-occlusion-ground-attenuation":{"type":"number","default":0.69,"minimum":0,"maximum":1,"transition":true,"expression":{"interpolated":true,"parameters":["zoom"]}},"fill-extrusion-flood-light-color":{"type":"color","default":"#ffffff","use-theme":true,"transition":true,"expression":{"interpolated":true,"parameters":["zoom","measure-light"]}},"fill-extrusion-flood-light-intensity":{"type":"number","default":0,"minimum":0,"maximum":1,"transition":true,"expression":{"interpolated":true,"parameters":["zoom","measure-light"]}},"fill-extrusion-flood-light-wall-radius":{"property-type":"data-driven","type":"number","default":0,"minimum":0,"transition":true,"expression":{"interpolated":true,"parameters":["feature","feature-state"]}},"fill-extrusion-flood-light-ground-radius":{"property-type":"data-driven","type":"number","default":0,"transition":true,"expression":{"interpolated":true,"parameters":["feature","feature-state"]}},"fill-extrusion-flood-light-ground-attenuation":{"type":"number","default":0.69,"minimum":0,"maximum":1,"transition":true,"expression":{"interpolated":true,"parameters":["zoom"]}},"fill-extrusion-vertical-scale":{"type":"number","default":1,"minimum":0,"transition":true,"expression":{"interpolated":true,"parameters":["zoom"]}},"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":{}},"fill-extrusion-emissive-strength":{"type":"number","default":0,"minimum":0,"transition":true,"expression":{"interpolated":true,"parameters":["zoom","measure-light","feature-state"]},"property-type":"data-driven"},"fill-extrusion-line-width":{"type":"number","default":0,"minimum":0,"transition":true,"expression":{"interpolated":true,"parameters":["zoom","feature","feature-state","measure-light"]},"property-type":"data-driven"},"fill-extrusion-cast-shadows":{"type":"boolean","default":true}},"paint_building":{"building-opacity":{"type":"number","default":1,"minimum":0,"maximum":1,"transition":true,"expression":{"interpolated":true,"parameters":["zoom"]}},"building-ambient-occlusion-intensity":{"type":"number","default":0,"minimum":0,"maximum":1,"expression":{"parameters":[]},"transition":true},"building-ambient-occlusion-ground-intensity":{"type":"number","default":0,"minimum":0,"maximum":1,"expression":{"interpolated":true,"parameters":["zoom"]},"transition":true},"building-ambient-occlusion-ground-radius":{"type":"number","default":3,"minimum":0,"expression":{"interpolated":true,"parameters":["zoom"]},"transition":true},"building-ambient-occlusion-ground-attenuation":{"type":"number","default":0.69,"minimum":0,"maximum":1,"transition":true,"expression":{"interpolated":true,"parameters":["zoom"]}},"building-vertical-scale":{"type":"number","default":1,"minimum":0,"transition":true,"expression":{"interpolated":true,"parameters":["zoom"]}},"building-cast-shadows":{"type":"boolean","default":true},"building-color":{"type":"color","default":"rgba(193, 154, 127, 1)","use-theme":true,"expression":{"interpolated":true,"parameters":["feature","feature-state","measure-light"]},"property-type":"data-driven"},"building-emissive-strength":{"type":"number","default":0,"minimum":0,"maximum":5,"expression":{"interpolated":true,"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":true,"parameters":["measure-light","zoom"]}},"building-cutoff-fade-range":{"type":"number","default":0,"minimum":0,"maximum":1,"expression":{}},"building-flood-light-color":{"type":"color","default":"#ffffff","use-theme":true,"transition":true,"expression":{"interpolated":true,"parameters":["zoom","measure-light"]}},"building-flood-light-intensity":{"type":"number","default":0,"minimum":0,"maximum":1,"transition":true,"expression":{"interpolated":true,"parameters":["zoom","measure-light"]}},"building-flood-light-ground-attenuation":{"type":"number","default":0.69,"minimum":0,"maximum":1,"transition":true,"expression":{"interpolated":true,"parameters":["zoom"]}}},"paint_line":{"line-opacity":{"type":"number","default":1,"minimum":0,"maximum":1,"transition":true,"expression":{"interpolated":true,"parameters":["zoom","feature","feature-state","measure-light"]},"property-type":"data-driven"},"line-color":{"type":"color","default":"#000000","use-theme":true,"transition":true,"expression":{"interpolated":true,"parameters":["zoom","feature","feature-state","measure-light"]},"property-type":"data-driven"},"line-translate":{"type":"array","value":"number","length":2,"default":[0,0],"transition":true,"expression":{"interpolated":true,"parameters":["zoom"]}},"line-translate-anchor":{"type":"enum","values":{"map":1,"viewport":1},"default":"map","expression":{"parameters":["zoom"]}},"line-width":{"type":"number","default":1,"minimum":0,"transition":true,"expression":{"interpolated":true,"parameters":["zoom","feature","feature-state","measure-light","line-progress"]},"property-type":"data-driven"},"line-gap-width":{"type":"number","default":0,"minimum":0,"transition":true,"expression":{"interpolated":true,"parameters":["zoom","feature","feature-state","measure-light"]},"property-type":"data-driven"},"line-offset":{"type":"number","default":0,"transition":true,"expression":{"interpolated":true,"parameters":["zoom","feature","feature-state","measure-light"]},"property-type":"data-driven"},"line-blur":{"type":"number","default":0,"minimum":0,"transition":true,"expression":{"interpolated":true,"parameters":["zoom","feature","feature-state","measure-light"]},"property-type":"data-driven"},"line-dasharray":{"type":"array","value":"number","minimum":0,"expression":{"parameters":["zoom","feature"]},"property-type":"data-driven"},"line-pattern":{"type":"resolvedImage","expression":{"parameters":["zoom","feature"]},"property-type":"data-driven"},"line-pattern-cross-fade":{"type":"number","default":0,"minimum":0,"maximum":1,"expression":{"interpolated":true,"parameters":["zoom","measure-light"]}},"line-gradient":{"type":"color","use-theme":true,"expression":{"interpolated":true,"parameters":["line-progress"]}},"line-trim-offset":{"type":"array","value":"number","length":2,"default":[0,0],"minimum":[0,0],"maximum":[1,1]},"line-trim-fade-range":{"type":"array","value":"number","length":2,"default":[0,0],"minimum":[0,0],"maximum":[1,1],"expression":{"interpolated":true,"parameters":["zoom","measure-light"]}},"line-trim-color":{"type":"color","default":"transparent","use-theme":true,"transition":true,"expression":{"interpolated":true,"parameters":["zoom","measure-light"]}},"line-emissive-strength":{"type":"number","default":0,"minimum":0,"transition":true,"expression":{"interpolated":true,"parameters":["zoom","measure-light"]}},"line-border-width":{"type":"number","default":0,"minimum":0,"transition":true,"expression":{"interpolated":true,"parameters":["zoom","feature","feature-state"]},"property-type":"data-driven"},"line-border-color":{"type":"color","default":"rgba(0, 0, 0, 0)","use-theme":true,"transition":true,"expression":{"interpolated":true,"parameters":["zoom","feature","feature-state"]},"property-type":"data-driven"},"line-occlusion-opacity":{"type":"number","default":0,"minimum":0,"maximum":1,"expression":{"interpolated":true,"parameters":["zoom"]},"transition":true}},"paint_circle":{"circle-radius":{"type":"number","default":5,"minimum":0,"transition":true,"expression":{"interpolated":true,"parameters":["zoom","feature","feature-state","measure-light"]},"property-type":"data-driven"},"circle-color":{"type":"color","default":"#000000","use-theme":true,"transition":true,"expression":{"interpolated":true,"parameters":["zoom","feature","feature-state","measure-light"]},"property-type":"data-driven"},"circle-blur":{"type":"number","default":0,"transition":true,"expression":{"interpolated":true,"parameters":["zoom","feature","feature-state","measure-light"]},"property-type":"data-driven"},"circle-opacity":{"type":"number","default":1,"minimum":0,"maximum":1,"transition":true,"expression":{"interpolated":true,"parameters":["zoom","feature","feature-state","measure-light"]},"property-type":"data-driven"},"circle-translate":{"type":"array","value":"number","length":2,"default":[0,0],"transition":true,"expression":{"interpolated":true,"parameters":["zoom"]}},"circle-translate-anchor":{"type":"enum","values":{"map":1,"viewport":1},"default":"map","expression":{"parameters":["zoom"]}},"circle-pitch-scale":{"type":"enum","values":{"map":1,"viewport":1},"default":"map","expression":{"parameters":["zoom"]}},"circle-pitch-alignment":{"type":"enum","values":{"map":1,"viewport":1},"default":"viewport","expression":{"parameters":["zoom"]}},"circle-stroke-width":{"type":"number","default":0,"minimum":0,"transition":true,"expression":{"interpolated":true,"parameters":["zoom","feature","feature-state","measure-light"]},"property-type":"data-driven"},"circle-stroke-color":{"type":"color","default":"#000000","use-theme":true,"transition":true,"expression":{"interpolated":true,"parameters":["zoom","feature","feature-state","measure-light"]},"property-type":"data-driven"},"circle-stroke-opacity":{"type":"number","default":1,"minimum":0,"maximum":1,"transition":true,"expression":{"interpolated":true,"parameters":["zoom","feature","feature-state","measure-light"]},"property-type":"data-driven"},"circle-emissive-strength":{"type":"number","default":0,"minimum":0,"transition":true,"expression":{"interpolated":true,"parameters":["zoom","measure-light"]}}},"paint_heatmap":{"heatmap-radius":{"type":"number","default":30,"minimum":1,"transition":true,"expression":{"interpolated":true,"parameters":["zoom","feature","feature-state","measure-light"]},"property-type":"data-driven"},"heatmap-weight":{"type":"number","default":1,"minimum":0,"expression":{"interpolated":true,"parameters":["zoom","feature","feature-state","measure-light"]},"property-type":"data-driven"},"heatmap-intensity":{"type":"number","default":1,"minimum":0,"transition":true,"expression":{"interpolated":true,"parameters":["zoom"]}},"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"],"use-theme":true,"expression":{"interpolated":true,"parameters":["heatmap-density"]}},"heatmap-opacity":{"type":"number","default":1,"minimum":0,"maximum":1,"transition":true,"expression":{"interpolated":true,"parameters":["zoom"]}}},"paint_symbol":{"icon-opacity":{"type":"number","default":1,"minimum":0,"maximum":1,"transition":true,"expression":{"interpolated":true,"parameters":["zoom","feature","feature-state","measure-light"]},"property-type":"data-driven"},"icon-occlusion-opacity":{"type":"number","minimum":0,"maximum":1,"default":0,"transition":true,"expression":{"interpolated":true,"parameters":["zoom","feature","feature-state","measure-light"]},"property-type":"data-driven"},"icon-emissive-strength":{"type":"number","default":1,"minimum":0,"transition":true,"expression":{"interpolated":true,"parameters":["zoom","measure-light","feature-state"]},"property-type":"data-driven"},"text-emissive-strength":{"type":"number","default":1,"minimum":0,"transition":true,"expression":{"interpolated":true,"parameters":["zoom","measure-light","feature-state"]},"property-type":"data-driven"},"icon-color":{"type":"color","default":"#000000","use-theme":true,"transition":true,"expression":{"interpolated":true,"parameters":["zoom","feature","feature-state","measure-light"]},"property-type":"data-driven"},"icon-halo-color":{"type":"color","default":"rgba(0, 0, 0, 0)","use-theme":true,"transition":true,"expression":{"interpolated":true,"parameters":["zoom","feature","feature-state","measure-light"]},"property-type":"data-driven"},"icon-halo-width":{"type":"number","default":0,"minimum":0,"transition":true,"expression":{"interpolated":true,"parameters":["zoom","feature","feature-state","measure-light"]},"property-type":"data-driven"},"icon-halo-blur":{"type":"number","default":0,"minimum":0,"transition":true,"expression":{"interpolated":true,"parameters":["zoom","feature","feature-state","measure-light"]},"property-type":"data-driven"},"icon-translate":{"type":"array","value":"number","length":2,"default":[0,0],"transition":true,"expression":{"interpolated":true,"parameters":["zoom"]}},"icon-translate-anchor":{"type":"enum","values":{"map":1,"viewport":1},"default":"map","expression":{"parameters":["zoom"]}},"icon-image-cross-fade":{"type":"number","default":0,"minimum":0,"maximum":1,"expression":{"interpolated":true,"parameters":["zoom","measure-light"]}},"text-opacity":{"type":"number","default":1,"minimum":0,"maximum":1,"transition":true,"expression":{"interpolated":true,"parameters":["zoom","feature","feature-state","measure-light"]},"property-type":"data-driven"},"text-occlusion-opacity":{"type":"number","minimum":0,"maximum":1,"default":0,"transition":true,"expression":{"interpolated":true,"parameters":["zoom","feature","feature-state","measure-light"]},"property-type":"data-driven"},"text-color":{"type":"color","default":"#000000","use-theme":true,"transition":true,"overridable":true,"expression":{"interpolated":true,"parameters":["zoom","feature","feature-state","measure-light"]},"property-type":"data-driven"},"text-halo-color":{"type":"color","default":"rgba(0, 0, 0, 0)","use-theme":true,"transition":true,"expression":{"interpolated":true,"parameters":["zoom","feature","feature-state","measure-light"]},"property-type":"data-driven"},"text-halo-width":{"type":"number","default":0,"minimum":0,"transition":true,"expression":{"interpolated":true,"parameters":["zoom","feature","feature-state","measure-light"]},"property-type":"data-driven"},"text-halo-blur":{"type":"number","default":0,"minimum":0,"transition":true,"expression":{"interpolated":true,"parameters":["zoom","feature","feature-state","measure-light"]},"property-type":"data-driven"},"text-translate":{"type":"array","value":"number","length":2,"default":[0,0],"transition":true,"expression":{"interpolated":true,"parameters":["zoom"]}},"text-translate-anchor":{"type":"enum","values":{"map":1,"viewport":1},"default":"map","expression":{"parameters":["zoom"]}},"icon-color-saturation":{"type":"number","default":0,"minimum":-1,"maximum":1,"expression":{}},"icon-color-contrast":{"type":"number","default":0,"minimum":-1,"maximum":1,"expression":{}},"icon-color-brightness-min":{"type":"number","default":0,"minimum":0,"maximum":1,"expression":{}},"icon-color-brightness-max":{"type":"number","default":1,"minimum":0,"maximum":1,"expression":{}},"symbol-z-offset":{"type":"number","default":0,"minimum":0,"transition":true,"expression":{"interpolated":true,"parameters":["zoom","feature"]},"property-type":"data-driven"}},"paint_raster":{"raster-opacity":{"type":"number","default":1,"minimum":0,"maximum":1,"transition":true,"expression":{"interpolated":true,"parameters":["zoom"]}},"raster-color":{"type":"color","use-theme":true,"expression":{"interpolated":true,"parameters":["raster-value"]}},"raster-color-mix":{"type":"array","default":[0.2126,0.7152,0.0722,0],"length":4,"value":"number","transition":true,"expression":{"interpolated":true,"parameters":["zoom"]}},"raster-color-range":{"type":"array","length":2,"value":"number","transition":true,"expression":{"interpolated":true,"parameters":["zoom"]}},"raster-hue-rotate":{"type":"number","default":0,"period":360,"transition":true,"expression":{"interpolated":true,"parameters":["zoom"]}},"raster-brightness-min":{"type":"number","default":0,"minimum":0,"maximum":1,"transition":true,"expression":{"interpolated":true,"parameters":["zoom"]}},"raster-brightness-max":{"type":"number","default":1,"minimum":0,"maximum":1,"transition":true,"expression":{"interpolated":true,"parameters":["zoom"]}},"raster-saturation":{"type":"number","default":0,"minimum":-1,"maximum":1,"transition":true,"expression":{"interpolated":true,"parameters":["zoom"]}},"raster-contrast":{"type":"number","default":0,"minimum":-1,"maximum":1,"transition":true,"expression":{"interpolated":true,"parameters":["zoom"]}},"raster-resampling":{"type":"enum","values":{"linear":1,"nearest":1},"default":"linear","expression":{"parameters":["zoom"]}},"raster-fade-duration":{"type":"number","default":300,"minimum":0,"expression":{"interpolated":true,"parameters":["zoom"]}},"raster-emissive-strength":{"type":"number","default":0,"minimum":0,"transition":true,"expression":{"interpolated":true,"parameters":["zoom","measure-light"]}},"raster-array-band":{"type":"string"},"raster-elevation":{"type":"number","default":0,"minimum":0,"transition":true,"expression":{"interpolated":true,"parameters":["zoom"]}}},"paint_raster-particle":{"raster-particle-array-band":{"type":"string"},"raster-particle-count":{"type":"number","default":512,"minimum":1},"raster-particle-color":{"type":"color","use-theme":true,"expression":{"interpolated":true,"parameters":["raster-particle-speed"]}},"raster-particle-max-speed":{"type":"number","default":1,"minimum":1},"raster-particle-speed-factor":{"type":"number","default":0.2,"minimum":0,"maximum":1,"transition":true,"expression":{"interpolated":true,"parameters":["zoom"]}},"raster-particle-fade-opacity-factor":{"type":"number","default":0.98,"minimum":0,"maximum":1,"transition":true,"expression":{"interpolated":true,"parameters":["zoom"]}},"raster-particle-reset-rate-factor":{"type":"number","default":0.8,"minimum":0,"maximum":1},"raster-particle-elevation":{"type":"number","default":0,"minimum":0,"transition":true,"expression":{"interpolated":true,"parameters":["zoom"]}}},"paint_hillshade":{"hillshade-illumination-direction":{"type":"number","default":335,"minimum":0,"maximum":359,"expression":{"interpolated":true,"parameters":["zoom"]}},"hillshade-illumination-anchor":{"type":"enum","values":{"map":1,"viewport":1},"default":"viewport","expression":{"parameters":["zoom"]}},"hillshade-exaggeration":{"type":"number","default":0.5,"minimum":0,"maximum":1,"transition":true,"expression":{"interpolated":true,"parameters":["zoom"]}},"hillshade-shadow-color":{"type":"color","default":"#000000","use-theme":true,"transition":true,"expression":{"interpolated":true,"parameters":["zoom","measure-light"]}},"hillshade-highlight-color":{"type":"color","default":"#FFFFFF","use-theme":true,"transition":true,"expression":{"interpolated":true,"parameters":["zoom","measure-light"]}},"hillshade-accent-color":{"type":"color","default":"#000000","use-theme":true,"transition":true,"expression":{"interpolated":true,"parameters":["zoom","measure-light"]}},"hillshade-emissive-strength":{"type":"number","default":0,"minimum":0,"transition":true,"expression":{"interpolated":true,"parameters":["zoom","measure-light"]}}},"paint_background":{"background-pitch-alignment":{"type":"enum","values":{"map":1,"viewport":1},"default":"map","expression":{"parameters":[]}},"background-color":{"type":"color","default":"#000000","use-theme":true,"transition":true,"expression":{"interpolated":true,"parameters":["zoom"]}},"background-pattern":{"type":"resolvedImage","expression":{"parameters":["zoom"]}},"background-opacity":{"type":"number","default":1,"minimum":0,"maximum":1,"transition":true,"expression":{"interpolated":true,"parameters":["zoom"]}},"background-emissive-strength":{"type":"number","default":0,"minimum":0,"transition":true,"expression":{"interpolated":true,"parameters":["zoom","measure-light"]}}},"paint_sky":{"sky-type":{"type":"enum","values":{"gradient":1,"atmosphere":1},"default":"atmosphere","expression":{"parameters":["zoom"]}},"sky-atmosphere-sun":{"type":"array","value":"number","length":2,"minimum":[0,0],"maximum":[360,180],"expression":{"parameters":["zoom"]}},"sky-atmosphere-sun-intensity":{"type":"number","default":10,"minimum":0,"maximum":100},"sky-gradient-center":{"type":"array","value":"number","default":[0,0],"length":2,"minimum":[0,0],"maximum":[360,180],"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"],"use-theme":true,"expression":{"interpolated":true,"parameters":["sky-radial-progress"]}},"sky-atmosphere-halo-color":{"type":"color","default":"white","use-theme":true},"sky-atmosphere-color":{"type":"color","default":"white","use-theme":true},"sky-opacity":{"type":"number","default":1,"minimum":0,"maximum":1,"transition":true,"expression":{"interpolated":true,"parameters":["zoom"]}}},"paint_model":{"model-opacity":{"type":"number","default":1,"minimum":0,"maximum":1,"transition":true,"expression":{"interpolated":true,"parameters":["feature","feature-state","zoom"]},"property-type":"data-driven"},"model-rotation":{"type":"array","value":"number","length":3,"default":[0,0,0],"period":360,"property-type":"data-driven","expression":{"interpolated":true,"parameters":["feature","feature-state","zoom"]},"transition":true},"model-scale":{"type":"array","value":"number","length":3,"default":[1,1,1],"property-type":"data-driven","expression":{"interpolated":true,"parameters":["feature","feature-state","zoom"]},"transition":true},"model-translation":{"type":"array","value":"number","length":3,"default":[0,0,0],"property-type":"data-driven","expression":{"interpolated":true,"parameters":["feature","feature-state","zoom"]},"transition":true},"model-color":{"type":"color","default":"#ffffff","property-type":"data-driven","expression":{"interpolated":true,"parameters":["feature","feature-state","measure-light","zoom"]},"use-theme":true,"transition":true},"model-color-mix-intensity":{"type":"number","property-type":"data-driven","default":0,"minimum":0,"maximum":1,"expression":{"interpolated":true,"parameters":["feature","feature-state","measure-light"]},"transition":true},"model-type":{"type":"enum","values":{"common-3d":1,"location-indicator":1},"default":"common-3d"},"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":true,"parameters":["zoom"]},"transition":true},"model-emissive-strength":{"type":"number","property-type":"data-driven","default":0,"minimum":0,"maximum":5,"expression":{"interpolated":true,"parameters":["feature","feature-state","measure-light"]},"transition":true},"model-roughness":{"type":"number","default":1,"minimum":0,"maximum":1,"property-type":"data-driven","expression":{"interpolated":true,"parameters":["feature","feature-state"]},"transition":true},"model-height-based-emissive-strength-multiplier":{"type":"array","default":[1,1,1,1,0],"length":5,"value":"number","property-type":"data-driven","expression":{"interpolated":true,"parameters":["feature","feature-state","measure-light"]},"transition":true},"model-cutoff-fade-range":{"type":"number","default":0,"minimum":0,"maximum":1,"expression":{}},"model-front-cutoff":{"type":"array","value":"number","expression":{"interpolated":true,"parameters":["zoom"]},"length":3,"default":[0,0,1],"minimum":[0,0,0],"maximum":[1,1,1]},"model-elevation-reference":{"type":"enum","values":{"sea":1,"ground":1,"hd-road-markup":1},"default":"ground","expression":{}}},"transition":{"duration":{"type":"number","default":300,"minimum":0},"delay":{"type":"number","default":0,"minimum":0}},"promoteId":{"*":{"type":"*"}}}');function Us(e){return e instanceof Number||e instanceof String||e instanceof Boolean?e.valueOf():e}function Ns(e){if(Array.isArray(e))return e.map(Ns);if(e instanceof Object&&!(e instanceof Number||e instanceof String||e instanceof Boolean)){const t={};for(const i in e)t[i]=Ns(e[i]);return t}return Us(e)}function Vs(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(!Vs(t)&&"boolean"!=typeof t)return!1;return!0;default:return!0}}function js(e,t="",i=null,r="fill"){if(null==e)return{filter:()=>!0,needGeometry:!1,needFeature:!1};Vs(e)||(e=qs(e));const n=e;let o=!0;try{o=function(e){if(!Qs(e))return e;let t=Ns(e);return Hs(t),t=Gs(t),t}(n)}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(n,null,2)}\n `)}let s=null,a=null;if("background"!==r&&"sky"!==r&&"slot"!==r){a=zs[`filter_${r}`];const e=Go(o,a,t,i);if("error"===e.result)throw new Error(e.value.map(e=>`${e.key}: ${e.message}`).join(", "));s=(t,i,r)=>e.value.evaluate(t,i,{},r)}let l=null,c=null;if(o!==n){const e=Go(n,a,t,i);if("error"===e.result)throw new Error(e.value.map(e=>`${e.key}: ${e.message}`).join(", "));l=(t,i,r,n,o)=>e.value.evaluate(t,i,{},r,void 0,void 0,n,o),c=!_n(e.value.expression)}return{filter:s,dynamicFilter:l||void 0,needGeometry:Ws(o),needFeature:!!c}}function Gs(e){if(!Array.isArray(e))return e;const t=function(e){if($s.has(e[0]))for(let t=1;tGs(e))}function Hs(e){let t=!1;const i=[];if("case"===e[0]){for(let r=1;r",">=","<","<=","to-boolean"]);function Zs(e,t){return et?1:0}function Ws(e){if(!Array.isArray(e))return!1;if("within"===e[0]||"distance"===e[0])return!0;for(let t=1;t"===t||"<="===t||">="===t?Ks(e[1],e[2],t):"any"===t?(i=e.slice(1),["any"].concat(i.map(qs))):"all"===t?["all"].concat(e.slice(1).map(qs)):"none"===t?["all"].concat(e.slice(1).map(qs).map(Ys)):"in"===t?Xs(e[1],e.slice(2)):"!in"===t?Ys(Xs(e[1],e.slice(2))):"has"===t?Js(e[1]):"!has"!==t||Ys(Js(e[1]));var i}function Ks(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 Xs(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(Zs)]]:["filter-in-small",e,["literal",t]]}}function Js(e){switch(e){case"$type":return!0;case"$id":return["filter-has-id"];default:return["filter-has",e]}}function Ys(e){return["!",e]}const ea="";function ta(e,t){return t?`${e}${ea}${t}`:e}let ia;const ra=()=>ia||(ia=new Os({"icon-size":new ks(zs.layout_symbol["icon-size"]),"icon-image":new ks(zs.layout_symbol["icon-image"]),"icon-rotate":new ks(zs.layout_symbol["icon-rotate"]),"icon-offset":new ks(zs.layout_symbol["icon-offset"])}));class na{constructor(e,t,i,r,n,o){this.cachedIconPrimary=null;const s=Go(e,zs.appearance.condition);if("success"===s.result&&(this.condition=s.value),this.name=t,i){this.properties=new Ls(ra()),this.unevaluatedLayout=new Ps(ra(),r,n,o);for(const e in i)this.unevaluatedLayout.setValue(e,i[e])}}hasCachedIconPrimary(){return null!==this.cachedIconPrimary}setCachedIconPrimary(e){this.cachedIconPrimary=e}getCachedIconPrimary(){return this.cachedIconPrimary}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}getProperty(e){return this.properties.get(e)}getUnevaluatedProperties(){return this.unevaluatedLayout}recalculate(e,t,i){this.unevaluatedLayout&&(this.properties=this.unevaluatedLayout.possiblyEvaluate(e,void 0,t,i))}serialize(){const e={};return e.condition=this.condition.expression.serialize(),this.name&&(e.name=this.name),this.unevaluatedLayout&&(e.properties=this.unevaluatedLayout.serialize()),e}}const oa="-transition",sa=new Set(["fill","line","background","hillshade","raster"]);class aa extends ri{constructor(e,t,i,r,n,o){if(super(),this.id=e.id,this.fqid=ta(this.id,i),this.type=e.type,this.scope=i,this.lut=r,this.options=n,this.iconImageUseTheme=o,this.appearances=new Array,this._featureFilter={filter:()=>!0,needGeometry:!1,needFeature:!1},this._filterCompiled=!1,this.expressionDependencies={isIndoorDependent:!1,configDependencies:new Set},"custom"!==e.type){if(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;const t=Go(this.filter,zs[`filter_${e.type}`]);"error"!==t.result&&(this.expressionDependencies.configDependencies=new Set([...this.expressionDependencies.configDependencies,...t.value.configDependencies]),this.expressionDependencies.isIndoorDependent=this.expressionDependencies.isIndoorDependent||t.value.isIndoorDependent)}if(e.slot&&(this.slot=e.slot),e.appearances&&this.setAppearances(e.appearances),t.layout&&(this._unevaluatedLayout=new Ps(t.layout,this.scope,n,this.iconImageUseTheme),this.expressionDependencies.configDependencies=new Set([...this.expressionDependencies.configDependencies,...this._unevaluatedLayout.configDependencies]),this.expressionDependencies.isIndoorDependent=this.expressionDependencies.isIndoorDependent||this._unevaluatedLayout.isIndoorDependent()),t.paint){this._transitionablePaint=new Ss(t.paint,this.scope,n);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.expressionDependencies.configDependencies=new Set([...this.expressionDependencies.configDependencies,...this._transitionablePaint.configDependencies]),this.expressionDependencies.isIndoorDependent=this.expressionDependencies.isIndoorDependent||this._transitionablePaint.isIndoorDependent(),this._transitioningPaint=this._transitionablePaint.untransitioned(),this.paint=new Ls(t.paint)}}}onAdd(e){}onRemove(e){}isDraped(e){return!this.is3D(!0)&&sa.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),this.expressionDependencies.configDependencies=new Set([...this.expressionDependencies.configDependencies,...i.configDependencies]),this.expressionDependencies.isIndoorDependent=this.expressionDependencies.isIndoorDependent||i.isIndoorDependent(),"visibility"===e&&this.possiblyEvaluateVisibility())}setAppearances(e){this.appearances=[],e.forEach(e=>{this.appearances.push(new na(e.condition,e.name,e.properties,this.scope,this.options,this.iconImageUseTheme))})}possiblyEvaluateVisibility(){this._unevaluatedLayout._values.visibility&&(this.visibility=this._unevaluatedLayout._values.visibility.possiblyEvaluate({zoom:0}))}getPaintProperty(e){return e.endsWith(oa)?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,r=i._properties.properties;if(e.endsWith(oa)){const n=e.slice(0,-11);return r[n]&&i.setTransition(n,t||void 0),!1}if(!r[e])return!1;const n=i._values[e],o=n.value.isDataDriven(),s=n.value;i.setValue(e,t),this.expressionDependencies.configDependencies=new Set([...this.expressionDependencies.configDependencies,...i.configDependencies]),this.expressionDependencies.isIndoorDependent=this.expressionDependencies.isIndoorDependent||i.isIndoorDependent(),this._handleSpecialPaintPropertyUpdate(e);const a=i._values[e].value,l=a.isDataDriven(),c=e.endsWith("pattern")||"line-dasharray"===e;return l||o||c||this._handleOverridablePaintPropertyUpdate(e,s,a)}_handleSpecialPaintPropertyUpdate(e){}getProgramIds(){return null}getDefaultProgramParams(e,t,i){return null}_handleOverridablePaintPropertyUpdate(e,t,i){return!1}isHidden(e){return!!(this.minzoom&&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())),Ge(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}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 Rs&&Io(t.property.specification)&&("source"===t.value.kind||"composite"===t.value.kind)&&t.value.isStateDependent)return!0}for(const e of this.appearances)if(!An(e.condition.expression))return!0;return!1}compileFilter(e){this._filterCompiled||(this._featureFilter=js(this.filter,this.scope,e),this._filterCompiled=!0)}invalidateCompiledFilter(){this._filterCompiled=!1}dynamicFilter(){return this._featureFilter.dynamicFilter}dynamicFilterNeedsFeature(){return this._featureFilter.needFeature}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,r,n,o,s,a,l){}}const la={Int8:Int8Array,Uint8:Uint8Array,Int16:Int16Array,Uint16:Uint16Array,Int32:Int32Array,Uint32:Uint32Array,Float32:Float32Array};class ca{constructor(e,t){this._structArray=e,this._pos1=t*this.size,this._pos2=this._pos1/2,this._pos4=this._pos1/4,this._pos8=this._pos1/8}}class ua{constructor(){this.capacity=-1,this.resize(0)}static serialize(e,t){return e._trim(),t&&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,t.capacity=e.arrayBuffer.byteLength/t.bytesPerElement,t._refreshViews(),t}_trim(){this.length!==this.capacity&&(this.capacity=this.length,this.arrayBuffer=this.arrayBuffer.slice(0,this.length*this.bytesPerElement),this._refreshViews())}clear(){this.length=0}resize(e){this.reserve(e),this.length=e}reserve(e){if(e>this.capacity){this.capacity=Math.max(e,Math.floor(5*this.capacity),128),this.arrayBuffer=new ArrayBuffer(this.capacity*this.bytesPerElement);const t=this.uint8;this._refreshViews(),t&&this.uint8.set(t)}}_refreshViews(){throw new Error("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 ha(e,t=1){let i=0,r=0;return{members:e.map(e=>{const n=la[e.type].BYTES_PER_ELEMENT,o=i=da(i,Math.max(t,n)),s=e.components||1;return r=Math.max(r,n),i+=n*s,{name:e.name,type:e.type,components:s,offset:o}}),size:da(i,Math.max(r,t)),alignment:t}}function da(e,t){return Math.ceil(e/t)*t}class pa extends ua{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer)}emplaceBack(e,t){const i=this.length;return this.resize(i+1),this.emplace(i,e,t)}emplace(e,t,i){const r=2*e;return this.int16[r+0]=t,this.int16[r+1]=i,e}}pa.prototype.bytesPerElement=4,es(pa,"StructArrayLayout2i4");class fa extends ua{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer)}emplaceBack(e,t,i){const r=this.length;return this.resize(r+1),this.emplace(r,e,t,i)}emplace(e,t,i,r){const n=3*e;return this.int16[n+0]=t,this.int16[n+1]=i,this.int16[n+2]=r,e}}fa.prototype.bytesPerElement=6,es(fa,"StructArrayLayout3i6");class ma extends ua{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer)}emplaceBack(e,t,i,r){const n=this.length;return this.resize(n+1),this.emplace(n,e,t,i,r)}emplace(e,t,i,r,n){const o=4*e;return this.int16[o+0]=t,this.int16[o+1]=i,this.int16[o+2]=r,this.int16[o+3]=n,e}}ma.prototype.bytesPerElement=8,es(ma,"StructArrayLayout4i8");class ga extends ua{_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}}ga.prototype.bytesPerElement=4,es(ga,"StructArrayLayout1f4");class _a extends ua{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer)}emplaceBack(e,t,i){const r=this.length;return this.resize(r+1),this.emplace(r,e,t,i)}emplace(e,t,i,r){const n=4*e,o=2*e;return this.int16[n+0]=t,this.int16[n+1]=i,this.float32[o+1]=r,e}}_a.prototype.bytesPerElement=8,es(_a,"StructArrayLayout2i1f8");class Aa extends ua{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer)}emplaceBack(e,t,i){const r=this.length;return this.resize(r+1),this.emplace(r,e,t,i)}emplace(e,t,i,r){const n=4*e;return this.int16[n+0]=t,this.int16[n+1]=i,this.int16[n+2]=r,e}}Aa.prototype.bytesPerElement=8,es(Aa,"StructArrayLayout3i8");class ya extends ua{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer)}emplaceBack(e,t,i,r,n){const o=this.length;return this.resize(o+1),this.emplace(o,e,t,i,r,n)}emplace(e,t,i,r,n,o){const s=5*e;return this.int16[s+0]=t,this.int16[s+1]=i,this.int16[s+2]=r,this.int16[s+3]=n,this.int16[s+4]=o,e}}ya.prototype.bytesPerElement=10,es(ya,"StructArrayLayout5i10");class va extends ua{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer)}emplaceBack(e,t,i,r,n,o,s){const a=this.length;return this.resize(a+1),this.emplace(a,e,t,i,r,n,o,s)}emplace(e,t,i,r,n,o,s,a){const l=6*e,c=12*e,u=3*e;return this.int16[l+0]=t,this.int16[l+1]=i,this.uint8[c+4]=r,this.uint8[c+5]=n,this.uint8[c+6]=o,this.uint8[c+7]=s,this.float32[u+2]=a,e}}va.prototype.bytesPerElement=12,es(va,"StructArrayLayout2i4ub1f12");class xa extends ua{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer)}emplaceBack(e,t,i){const r=this.length;return this.resize(r+1),this.emplace(r,e,t,i)}emplace(e,t,i,r){const n=3*e;return this.float32[n+0]=t,this.float32[n+1]=i,this.float32[n+2]=r,e}}xa.prototype.bytesPerElement=12,es(xa,"StructArrayLayout3f12");class ba extends ua{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.uint16=new Uint16Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer)}emplaceBack(e,t,i,r,n){const o=this.length;return this.resize(o+1),this.emplace(o,e,t,i,r,n)}emplace(e,t,i,r,n,o){const s=6*e,a=3*e;return this.uint16[s+0]=t,this.uint16[s+1]=i,this.uint16[s+2]=r,this.uint16[s+3]=n,this.float32[a+2]=o,e}}ba.prototype.bytesPerElement=12,es(ba,"StructArrayLayout4ui1f12");class wa extends ua{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.uint16=new Uint16Array(this.arrayBuffer)}emplaceBack(e,t,i,r){const n=this.length;return this.resize(n+1),this.emplace(n,e,t,i,r)}emplace(e,t,i,r,n){const o=4*e;return this.uint16[o+0]=t,this.uint16[o+1]=i,this.uint16[o+2]=r,this.uint16[o+3]=n,e}}wa.prototype.bytesPerElement=8,es(wa,"StructArrayLayout4ui8");class Ta extends ua{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer)}emplaceBack(e,t,i,r,n,o){const s=this.length;return this.resize(s+1),this.emplace(s,e,t,i,r,n,o)}emplace(e,t,i,r,n,o,s){const a=6*e;return this.int16[a+0]=t,this.int16[a+1]=i,this.int16[a+2]=r,this.int16[a+3]=n,this.int16[a+4]=o,this.int16[a+5]=s,e}}Ta.prototype.bytesPerElement=12,es(Ta,"StructArrayLayout6i12");class Ea extends ua{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer),this.uint16=new Uint16Array(this.arrayBuffer)}emplaceBack(e,t,i,r,n,o,s,a,l,c,u,h){const d=this.length;return this.resize(d+1),this.emplace(d,e,t,i,r,n,o,s,a,l,c,u,h)}emplace(e,t,i,r,n,o,s,a,l,c,u,h,d){const p=12*e;return this.int16[p+0]=t,this.int16[p+1]=i,this.int16[p+2]=r,this.int16[p+3]=n,this.uint16[p+4]=o,this.uint16[p+5]=s,this.uint16[p+6]=a,this.uint16[p+7]=l,this.int16[p+8]=c,this.int16[p+9]=u,this.int16[p+10]=h,this.int16[p+11]=d,e}}Ea.prototype.bytesPerElement=24,es(Ea,"StructArrayLayout4i4ui4i24");class Ca extends ua{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer)}emplaceBack(e,t,i,r,n,o){const s=this.length;return this.resize(s+1),this.emplace(s,e,t,i,r,n,o)}emplace(e,t,i,r,n,o,s){const a=10*e,l=5*e;return this.int16[a+0]=t,this.int16[a+1]=i,this.int16[a+2]=r,this.float32[l+2]=n,this.float32[l+3]=o,this.float32[l+4]=s,e}}Ca.prototype.bytesPerElement=20,es(Ca,"StructArrayLayout3i3f20");class Ba extends ua{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer)}emplaceBack(e,t,i,r){const n=this.length;return this.resize(n+1),this.emplace(n,e,t,i,r)}emplace(e,t,i,r,n){const o=4*e;return this.float32[o+0]=t,this.float32[o+1]=i,this.float32[o+2]=r,this.float32[o+3]=n,e}}Ba.prototype.bytesPerElement=16,es(Ba,"StructArrayLayout4f16");class Sa extends ua{_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}}Sa.prototype.bytesPerElement=4,es(Sa,"StructArrayLayout1ul4");class Ia extends ua{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.uint16=new Uint16Array(this.arrayBuffer)}emplaceBack(e,t){const i=this.length;return this.resize(i+1),this.emplace(i,e,t)}emplace(e,t,i){const r=2*e;return this.uint16[r+0]=t,this.uint16[r+1]=i,e}}Ia.prototype.bytesPerElement=4,es(Ia,"StructArrayLayout2ui4");class Ma extends ua{_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,r,n,o,s,a,l,c,u,h,d){const p=this.length;return this.resize(p+1),this.emplace(p,e,t,i,r,n,o,s,a,l,c,u,h,d)}emplace(e,t,i,r,n,o,s,a,l,c,u,h,d,p){const f=20*e,m=10*e;return this.int16[f+0]=t,this.int16[f+1]=i,this.int16[f+2]=r,this.int16[f+3]=n,this.int16[f+4]=o,this.float32[m+3]=s,this.float32[m+4]=a,this.float32[m+5]=l,this.float32[m+6]=c,this.int16[f+14]=u,this.uint32[m+8]=h,this.uint16[f+18]=d,this.uint16[f+19]=p,e}}Ma.prototype.bytesPerElement=40,es(Ma,"StructArrayLayout5i4f1i1ul2ui40");class Pa extends ua{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer)}emplaceBack(e,t,i,r,n,o,s){const a=this.length;return this.resize(a+1),this.emplace(a,e,t,i,r,n,o,s)}emplace(e,t,i,r,n,o,s,a){const l=8*e;return this.int16[l+0]=t,this.int16[l+1]=i,this.int16[l+2]=r,this.int16[l+4]=n,this.int16[l+5]=o,this.int16[l+6]=s,this.int16[l+7]=a,e}}Pa.prototype.bytesPerElement=16,es(Pa,"StructArrayLayout3i2i2i16");class Ra extends ua{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer)}emplaceBack(e,t,i,r,n){const o=this.length;return this.resize(o+1),this.emplace(o,e,t,i,r,n)}emplace(e,t,i,r,n,o){const s=4*e,a=8*e;return this.float32[s+0]=t,this.float32[s+1]=i,this.float32[s+2]=r,this.int16[a+6]=n,this.int16[a+7]=o,e}}Ra.prototype.bytesPerElement=16,es(Ra,"StructArrayLayout2f1f2i16");class La extends ua{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer)}emplaceBack(e,t,i,r,n,o){const s=this.length;return this.resize(s+1),this.emplace(s,e,t,i,r,n,o)}emplace(e,t,i,r,n,o,s){const a=20*e,l=5*e;return this.uint8[a+0]=t,this.uint8[a+1]=i,this.float32[l+1]=r,this.float32[l+2]=n,this.float32[l+3]=o,this.float32[l+4]=s,e}}La.prototype.bytesPerElement=20,es(La,"StructArrayLayout2ub4f20");class Fa extends ua{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.uint16=new Uint16Array(this.arrayBuffer)}emplaceBack(e,t,i){const r=this.length;return this.resize(r+1),this.emplace(r,e,t,i)}emplace(e,t,i,r){const n=3*e;return this.uint16[n+0]=t,this.uint16[n+1]=i,this.uint16[n+2]=r,e}}Fa.prototype.bytesPerElement=6,es(Fa,"StructArrayLayout3ui6");class ka extends ua{_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,r,n,o,s,a,l,c,u,h,d,p,f,m,g,_,A,y,v){const x=this.length;return this.resize(x+1),this.emplace(x,e,t,i,r,n,o,s,a,l,c,u,h,d,p,f,m,g,_,A,y,v)}emplace(e,t,i,r,n,o,s,a,l,c,u,h,d,p,f,m,g,_,A,y,v,x){const b=30*e,w=15*e,T=60*e;return this.int16[b+0]=t,this.int16[b+1]=i,this.int16[b+2]=r,this.float32[w+2]=n,this.float32[w+3]=o,this.uint16[b+8]=s,this.uint16[b+9]=a,this.uint32[w+5]=l,this.uint32[w+6]=c,this.uint32[w+7]=u,this.uint16[b+16]=h,this.uint16[b+17]=d,this.uint16[b+18]=p,this.float32[w+10]=f,this.float32[w+11]=m,this.uint8[T+48]=g,this.uint8[T+49]=_,this.uint8[T+50]=A,this.uint32[w+13]=y,this.int16[b+28]=v,this.uint8[T+58]=x,e}}ka.prototype.bytesPerElement=60,es(ka,"StructArrayLayout3i2f2ui3ul3ui2f3ub1ul1i1ub60");class Da extends ua{_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,r,n,o,s,a,l,c,u,h,d,p,f,m,g,_,A,y,v,x,b,w,T,E,C,B,S,I,M,P,R){const L=this.length;return this.resize(L+1),this.emplace(L,e,t,i,r,n,o,s,a,l,c,u,h,d,p,f,m,g,_,A,y,v,x,b,w,T,E,C,B,S,I,M,P,R)}emplace(e,t,i,r,n,o,s,a,l,c,u,h,d,p,f,m,g,_,A,y,v,x,b,w,T,E,C,B,S,I,M,P,R,L){const F=20*e,k=40*e,D=80*e;return this.float32[F+0]=t,this.float32[F+1]=i,this.int16[k+4]=r,this.int16[k+5]=n,this.int16[k+6]=o,this.int16[k+7]=s,this.int16[k+8]=a,this.int16[k+9]=l,this.int16[k+10]=c,this.int16[k+11]=u,this.int16[k+12]=h,this.uint16[k+13]=d,this.uint16[k+14]=p,this.uint16[k+15]=f,this.uint16[k+16]=m,this.uint16[k+17]=g,this.uint16[k+18]=_,this.uint16[k+19]=A,this.uint16[k+20]=y,this.uint16[k+21]=v,this.uint16[k+22]=x,this.uint16[k+23]=b,this.uint16[k+24]=w,this.uint16[k+25]=T,this.uint16[k+26]=E,this.uint16[k+27]=C,this.uint32[F+14]=B,this.float32[F+15]=S,this.float32[F+16]=I,this.float32[F+17]=M,this.float32[F+18]=P,this.uint8[D+76]=R,this.uint16[k+39]=L,e}}Da.prototype.bytesPerElement=80,es(Da,"StructArrayLayout2f9i15ui1ul4f1ub1ui80");class Oa extends ua{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer)}emplaceBack(e,t,i,r,n,o){const s=this.length;return this.resize(s+1),this.emplace(s,e,t,i,r,n,o)}emplace(e,t,i,r,n,o,s){const a=6*e;return this.float32[a+0]=t,this.float32[a+1]=i,this.float32[a+2]=r,this.float32[a+3]=n,this.float32[a+4]=o,this.float32[a+5]=s,e}}Oa.prototype.bytesPerElement=24,es(Oa,"StructArrayLayout6f24");class za extends ua{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer)}emplaceBack(e,t,i,r,n){const o=this.length;return this.resize(o+1),this.emplace(o,e,t,i,r,n)}emplace(e,t,i,r,n,o){const s=5*e;return this.float32[s+0]=t,this.float32[s+1]=i,this.float32[s+2]=r,this.float32[s+3]=n,this.float32[s+4]=o,e}}za.prototype.bytesPerElement=20,es(za,"StructArrayLayout5f20");class Ua extends ua{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer)}emplaceBack(e,t,i,r,n,o,s){const a=this.length;return this.resize(a+1),this.emplace(a,e,t,i,r,n,o,s)}emplace(e,t,i,r,n,o,s,a){const l=7*e;return this.float32[l+0]=t,this.float32[l+1]=i,this.float32[l+2]=r,this.float32[l+3]=n,this.float32[l+4]=o,this.float32[l+5]=s,this.float32[l+6]=a,e}}Ua.prototype.bytesPerElement=28,es(Ua,"StructArrayLayout7f28");class Na extends ua{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer)}emplaceBack(e,t,i,r,n,o,s,a,l,c,u){const h=this.length;return this.resize(h+1),this.emplace(h,e,t,i,r,n,o,s,a,l,c,u)}emplace(e,t,i,r,n,o,s,a,l,c,u,h){const d=11*e;return this.float32[d+0]=t,this.float32[d+1]=i,this.float32[d+2]=r,this.float32[d+3]=n,this.float32[d+4]=o,this.float32[d+5]=s,this.float32[d+6]=a,this.float32[d+7]=l,this.float32[d+8]=c,this.float32[d+9]=u,this.float32[d+10]=h,e}}Na.prototype.bytesPerElement=44,es(Na,"StructArrayLayout11f44");class Va extends ua{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer)}emplaceBack(e,t,i,r,n,o,s,a,l){const c=this.length;return this.resize(c+1),this.emplace(c,e,t,i,r,n,o,s,a,l)}emplace(e,t,i,r,n,o,s,a,l,c){const u=9*e;return this.float32[u+0]=t,this.float32[u+1]=i,this.float32[u+2]=r,this.float32[u+3]=n,this.float32[u+4]=o,this.float32[u+5]=s,this.float32[u+6]=a,this.float32[u+7]=l,this.float32[u+8]=c,e}}Va.prototype.bytesPerElement=36,es(Va,"StructArrayLayout9f36");class ja extends ua{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer)}emplaceBack(e,t){const i=this.length;return this.resize(i+1),this.emplace(i,e,t)}emplace(e,t,i){const r=2*e;return this.float32[r+0]=t,this.float32[r+1]=i,e}}ja.prototype.bytesPerElement=8,es(ja,"StructArrayLayout2f8");class Ga extends ua{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.uint32=new Uint32Array(this.arrayBuffer),this.uint16=new Uint16Array(this.arrayBuffer)}emplaceBack(e,t,i,r){const n=this.length;return this.resize(n+1),this.emplace(n,e,t,i,r)}emplace(e,t,i,r,n){const o=6*e;return this.uint32[3*e+0]=t,this.uint16[o+2]=i,this.uint16[o+3]=r,this.uint16[o+4]=n,e}}Ga.prototype.bytesPerElement=12,es(Ga,"StructArrayLayout1ul3ui12");class Ha extends ua{_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}}Ha.prototype.bytesPerElement=2,es(Ha,"StructArrayLayout1ui2");class Qa extends ua{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer)}emplaceBack(e,t,i,r,n,o,s,a,l,c,u,h,d,p,f,m){const g=this.length;return this.resize(g+1),this.emplace(g,e,t,i,r,n,o,s,a,l,c,u,h,d,p,f,m)}emplace(e,t,i,r,n,o,s,a,l,c,u,h,d,p,f,m,g){const _=16*e;return this.float32[_+0]=t,this.float32[_+1]=i,this.float32[_+2]=r,this.float32[_+3]=n,this.float32[_+4]=o,this.float32[_+5]=s,this.float32[_+6]=a,this.float32[_+7]=l,this.float32[_+8]=c,this.float32[_+9]=u,this.float32[_+10]=h,this.float32[_+11]=d,this.float32[_+12]=p,this.float32[_+13]=f,this.float32[_+14]=m,this.float32[_+15]=g,e}}Qa.prototype.bytesPerElement=64,es(Qa,"StructArrayLayout16f64");class $a extends ua{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.uint16=new Uint16Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer)}emplaceBack(e,t,i,r,n,o,s){const a=this.length;return this.resize(a+1),this.emplace(a,e,t,i,r,n,o,s)}emplace(e,t,i,r,n,o,s,a){const l=10*e,c=5*e;return this.uint16[l+0]=t,this.uint16[l+1]=i,this.uint16[l+2]=r,this.uint16[l+3]=n,this.float32[c+2]=o,this.float32[c+3]=s,this.float32[c+4]=a,e}}$a.prototype.bytesPerElement=20,es($a,"StructArrayLayout4ui3f20");class Za extends ua{_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}}Za.prototype.bytesPerElement=2,es(Za,"StructArrayLayout1i2");class Wa extends ua{_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}}Wa.prototype.bytesPerElement=1,es(Wa,"StructArrayLayout1ub1");class qa extends ca{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]}}qa.prototype.size=40;class Ka extends Ma{get(e){return new qa(this,e)}}es(Ka,"CollisionBoxArray");class Xa extends ca{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}}Xa.prototype.size=60;class Ja extends ka{get(e){return new Xa(this,e)}}es(Ja,"PlacedSymbolArray");class Ya extends ca{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]}}Ya.prototype.size=80;class el extends Da{get(e){return new Ya(this,e)}}es(el,"SymbolInstanceArray");class tl extends ga{getoffsetX(e){return this.float32[1*e+0]}}es(tl,"GlyphOffsetArray");class il extends pa{getx(e){return this.int16[2*e+0]}gety(e){return this.int16[2*e+1]}}es(il,"SymbolLineVertexArray");class rl extends ca{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]}}rl.prototype.size=12;class nl extends Ga{get(e){return new rl(this,e)}}es(nl,"FeatureIndexArray");class ol extends Ia{geta_centroid_pos0(e){return this.uint16[2*e+0]}geta_centroid_pos1(e){return this.uint16[2*e+1]}}es(ol,"FillExtrusionCentroidArray");class sl extends ca{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]}}sl.prototype.size=6;class al extends fa{get(e){return new sl(this,e)}}es(al,"FillExtrusionWallArray");const ll=ha([{name:"a_pos",components:2,type:"Int16"}],4),cl=ha([{name:"a_circle_z_offset",components:1,type:"Float32"}],4),ul=ha([{name:"a_pos_3",components:3,type:"Int16"},{name:"a_pos_normal_3",components:3,type:"Int16"}]);class hl{constructor(e=[]){this.segments=e}_prepareSegment(e,t,i,r){let n=this.segments[this.segments.length-1];return e>hl.MAX_VERTEX_ARRAY_LENGTH&&Ze(`Max vertices per segment is ${hl.MAX_VERTEX_ARRAY_LENGTH}: bucket requested ${e}`),(!n||n.vertexLength+e>hl.MAX_VERTEX_ARRAY_LENGTH||n.sortKey!==r)&&(n={vertexOffset:t,primitiveOffset:i,vertexLength:0,primitiveLength:0},void 0!==r&&(n.sortKey=r),this.segments.push(n)),n}prepareSegment(e,t,i,r){return this._prepareSegment(e,t.length,i.length,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,r){return new hl([{vertexOffset:e,primitiveOffset:t,vertexLength:i,primitiveLength:r,vaos:{},sortKey:0}])}}function dl(e,t){return 256*(e=Fe(Math.floor(e),0,255))+Fe(Math.floor(t),0,255)}hl.MAX_VERTEX_ARRAY_LENGTH=Math.pow(2,16)-1,es(hl,"SegmentVector");const pl=ha([{name:"a_pattern",components:4,type:"Uint16"},{name:"a_pixel_ratio",components:1,type:"Float32"}]),fl=ha([{name:"a_pattern_b",components:4,type:"Uint16"}]),ml=ha([{name:"a_dash",components:4,type:"Uint16"}]);class gl{constructor(){this.ids=[],this.uniqueIds=[],this.positions=[],this.indexed=!1}add(e,t,i,r){this.ids.push(_l(e)),this.positions.push(t,i,r)}eachPosition(e,t){const i=_l(e);let r=0,n=this.ids.length-1;for(;r>1;this.ids[e]>=i?n=e:r=e+1}for(;this.ids[r]===i;)t(this.positions[3*r],this.positions[3*r+1],this.positions[3*r+2]),r++}static serialize(e,t){const i=new Float64Array(e.ids),r=new Uint32Array(e.positions);return Al(i,r,0,i.length-1),t&&(t.add(i.buffer),t.add(r.buffer)),{ids:i,positions:r}}static deserialize(e){const t=new gl;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 _l(e){const t=+e;return Number.isSafeInteger(t)?t:Jt(String(e))}function Al(e,t,i,r){for(;i>1];let o=i-1,s=r+1;for(;;){do{o++}while(e[o]n);if(o>=s)break;yl(e,o,s),yl(t,3*o,3*s),yl(t,3*o+1,3*s+1),yl(t,3*o+2,3*s+2)}s-i`u_${e}`),this.type=i,this.context=r}setUniform(e,t,i,r,n){const o=r.constantOr(this.value);t.set(e,n,o instanceof li?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 Cl(e):new bl(e)}}class kl{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,r,n){let o=null;"u_pattern"!==n&&"u_dash"!==n||(o=this.pattern),"u_pattern_b"===n&&(o=this.patternTransition),"u_pixel_ratio"===n&&(o=this.pixelRatio),o&&t.set(e,n,o)}getBinding(e,t){return"u_pattern"===t||"u_pattern_b"===t||"u_dash"===t?new El(e):new bl(e)}}class Dl{constructor(e,t,i,r){this.expression=e,this.type=i,this.maxValue=0,this.paintVertexAttributes=t.map(e=>({name:`a_${e}`,type:"Float32",components:"color"===i?2:1,offset:0})),this.paintVertexArray=new r}populatePaintArray(e,t,i,r,n,o,s,a){const l=this.paintVertexArray.length,c="composite"===this.expression.kind||"source"===this.expression.kind?this.expression.evaluate(new Es(0,{brightness:o,worldview:a}),t,{},n,r,s):"constant"===this.expression.kind&&this.expression.value,u=Ll(this.lutExpression,t,{},r,n,o,s,a);this.paintVertexArray.resize(e),this._setPaintValue(l,e,c,u?null:this.context.lut)}updatePaintArray(e,t,i,r,n,o,s,a){const l="composite"===this.expression.kind||"source"===this.expression.kind?this.expression.evaluate({zoom:0,brightness:s,worldview:a},i,r,void 0,n):"constant"===this.expression.kind&&this.expression.value,c=Ll(this.lutExpression,i,r,n,void 0,s,void 0,a);this._setPaintValue(e,t,l,c?null:this.context.lut)}_setPaintValue(e,t,i,r){if("color"===this.type){const n=Rl(i.toPremultipliedRenderColor(r));for(let i=e;i`u_${e}_t`),this.type=i,this.useIntegerZoom=r,this.context=n,this.maxValue=0,this.paintVertexAttributes=t.map(e=>({name:`a_${e}`,type:"Float32",components:"color"===i?4:2,offset:0})),this.paintVertexArray=new o}populatePaintArray(e,t,i,r,n,o,s,a){const l=this.expression.evaluate(new Es(this.context.zoom,{brightness:o,worldview:a}),t,{},n,r,s),c=this.expression.evaluate(new Es(this.context.zoom+1,{brightness:o,worldview:a}),t,{},n,r,s),u=Ll(this.lutExpression,t,{},r,n,o,s,a),h=this.paintVertexArray.length;this.paintVertexArray.resize(e),this._setPaintValue(h,e,l,c,u?null:this.context.lut)}updatePaintArray(e,t,i,r,n,o,s,a){const l=this.expression.evaluate({zoom:this.context.zoom,brightness:s,worldview:a},i,r,void 0,n),c=this.expression.evaluate({zoom:this.context.zoom+1,brightness:s,worldview:a},i,r,void 0,n),u=Ll(this.lutExpression,i,r,n,void 0,s,void 0,a);this._setPaintValue(e,t,l,c,u?null:this.context.lut)}_setPaintValue(e,t,i,r,n){if("color"===this.type){const r=Rl(i.toPremultipliedRenderColor(n)),o=Rl(i.toPremultipliedRenderColor(n));for(let i=e;i!0){this.binders={},this._buffers=[],this.context=t;const r=[];for(const n in e.paint._values){const o=e.paint.get(n);if(n.endsWith("-use-theme"))continue;if(!i(n))continue;if(!(o instanceof Rs&&Io(o.property.specification)))continue;const s=jl(n,e.type),a=o.value,l=o.property.specification.type,c=!!o.property.useIntegerZoom,u="line-dasharray"===n||n.endsWith("pattern"),h=e.paint.get(`${n}-use-theme`),d="line-dasharray"===n&&"constant"!==e.layout.get("line-cap").value.kind||h&&"constant"!==h.value.kind;if("constant"!==a.kind||d)if("source"===a.kind||d||u){const t=Ql(n,l,"source");this.binders[n]=u?new zl(a,s,l,t,e.id):new Dl(a,s,l,t),r.push(`/a_${n}`)}else{const e=Ql(n,l,"composite");this.binders[n]=new Ol(a,s,l,c,t,e),r.push(`/z_${n}`)}else this.binders[n]=u?new kl(a.value,s):new Fl(a.value,s,l,t),r.push(`/u_${n}`);h&&(this.binders[n].lutExpression=h.value)}this.cacheKey=r.sort().join("")}getMaxValue(e){const t=this.binders[e];return t instanceof Dl||t instanceof Ol?t.maxValue:0}populatePaintArrays(e,t,i,r,n,o,s,a){for(const l in this.binders){const c=this.binders[l];c.context=this.context,(c instanceof Dl||c instanceof Ol||c instanceof zl)&&c.populatePaintArray(e,t,i,r,n,o,s,a)}}setConstantPatternPositions(e,t){for(const i in this.binders){const r=this.binders[i];r instanceof kl&&r.setConstantPatternPositions(e,t)}}getPatternTransitionVertexBuffer(e){const t=this.binders[e];return t instanceof zl?t.paintTransitionVertexBuffer:null}updatePaintArrays(e,t,i,r,n,o,s,a,l,c){let u=!1;const h=Object.keys(e),d=0!==h.length&&!a,p=d?h:t.uniqueIds;this.context.lut=n.lut;for(const a in this.binders){const h=this.binders[a];if(h.context=this.context,(h instanceof Dl||h instanceof Ol||h instanceof zl)&&h.expression&&h.expression.kind&&"constant"!==h.expression.kind&&(!0===h.expression.isStateDependent||!1===h.expression.isLightConstant)){const f=n.paint.get(a);h.expression=f.value;for(const i of p){const n=e[i.toString()];t.eachPosition(i,(e,t,i)=>{const a=r.feature(e);h.updatePaintArray(t,i,a,n,o,s,l,c)})}if(!d)for(const t of i.uniqueIds){const n=e[t.toString()];i.eachPosition(t,(e,t,i)=>{const a=r.feature(e);h.updatePaintArray(t,i,a,n,o,s,l,c)})}u=!0}}return u}defines(){const e=[];for(const t in this.binders){const i=this.binders[t];(i instanceof Fl||i instanceof kl)&&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 r=this.binders[i];if(r instanceof Fl||r instanceof kl||r instanceof Ol)for(const n of r.uniformNames)t.push({name:n,property:i,binding:r.getBinding(e,n)})}return t}setUniforms(e,t,i,r,n){for(const{name:t,property:o,binding:s}of i)this.binders[o].setUniform(e,s,n,r.get(o),t)}updatePaintBuffers(){this._buffers=[];for(const e in this.binders){const t=this.binders[e];(t instanceof Dl||t instanceof Ol||t instanceof zl)&&t.paintVertexBuffer&&this._buffers.push(t.paintVertexBuffer),t instanceof zl&&t.paintTransitionVertexBuffer&&this._buffers.push(t.paintTransitionVertexBuffer)}}upload(e){for(const t in this.binders){const i=this.binders[t];(i instanceof Dl||i instanceof Ol||i instanceof zl)&&i.upload(e)}this.updatePaintBuffers()}destroy(){for(const e in this.binders){const t=this.binders[e];(t instanceof Dl||t instanceof Ol||t instanceof zl)&&t.destroy()}}}class Nl{constructor(e,t,i=()=>!0){this.programConfigurations={};for(const r of e)this.programConfigurations[r.id]=new Ul(r,t,i);this.needsUpload=!1,this._featureMap=new gl,this._featureMapWithoutIds=new gl,this._bufferOffset=0,this._idlessCounter=0}populatePaintArrays(e,t,i,r,n,o,s,a,l){for(const i in this.programConfigurations)this.programConfigurations[i].populatePaintArrays(e,t,r,n,o,s,a,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,r,n,o,s,a){for(const l of i)this.needsUpload=this.programConfigurations[l.id].updatePaintArrays(e,this._featureMap,this._featureMapWithoutIds,t,l,r,n,o,s||0,a)||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()}}const Vl={"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 jl(e,t){return Vl[e]||[e.replace(`${t}-`,"").replace(/-/g,"_")]}const Gl={"line-pattern":{source:ba,composite:ba},"fill-pattern":{source:ba,composite:ba},"fill-extrusion-pattern":{source:ba,composite:ba},"line-dasharray":{source:wa,composite:wa}},Hl={color:{source:ja,composite:Ba},number:{source:ga,composite:ja}};function Ql(e,t,i){const r=Gl[e];return r&&r[i]||Hl[t][i]}es(Fl,"ConstantBinder"),es(kl,"PatternConstantBinder"),es(Dl,"SourceExpressionBinder"),es(zl,"PatternCompositeBinder"),es(Ol,"CompositeExpressionBinder"),es(Ul,"ProgramConfiguration",{omit:["_buffers"]}),es(Nl,"ProgramConfigurationSet");const $l=Ur/Math.PI/2,Zl=5,Wl=6,ql=16383,Kl=64,Xl=[Kl,32,16],Jl=-$l,Yl=$l;function ec(e,t,i,r=$l){return i=Se(i),[e*Math.sin(i)*r,-t*r,e*Math.cos(i)*r]}function tc(e,t,i){return ec(Math.cos(Se(e)),Math.sin(Se(e)),t,i)}const ic=6371008.8,rc=2*Math.PI*ic;class nc{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 nc(De(this.lng,-180,180),this.lat)}toArray(){return[this.lng,this.lat]}toString(){return`LngLat(${this.lng}, ${this.lat})`}distanceTo(e){const t=Math.PI/180,i=this.lat*t,r=e.lat*t,n=Math.sin(i)*Math.sin(r)+Math.cos(i)*Math.cos(r)*Math.cos((e.lng-this.lng)*t);return ic*Math.acos(Math.min(n,1))}toBounds(e=0){const t=360*e/40075017,i=t/Math.cos(Math.PI/180*this.lat);return new oc({lng:this.lng-i,lat:this.lat-t},{lng:this.lng+i,lat:this.lat+t})}toEcef(e){return tc(this.lat,this.lng,$l+e*$l/ic)}static convert(e){if(e instanceof nc)return e;if(Array.isArray(e)&&(2===e.length||3===e.length))return new nc(Number(e[0]),Number(e[1]));if(!Array.isArray(e)&&"object"==typeof e&&null!==e)return new nc(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: , lat: }, an object {lon: , lat: }, or an array of [, ]")}}class oc{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 nc?new nc(e.lng,e.lat):nc.convert(e),this}setSouthWest(e){return this._sw=e instanceof nc?new nc(e.lng,e.lat):nc.convert(e),this}extend(e){const t=this._sw,i=this._ne;let r,n;if(e instanceof nc)r=e,n=e;else{if(!(e instanceof oc))return Array.isArray(e)?4===e.length||e.every(Array.isArray)?this.extend(oc.convert(e)):this.extend(nc.convert(e)):"object"==typeof e&&null!==e&&e.hasOwnProperty("lat")&&(e.hasOwnProperty("lon")||e.hasOwnProperty("lng"))?this.extend(nc.convert(e)):this;if(r=e._sw,n=e._ne,!r||!n)return this}return t||i?(t.lng=Math.min(r.lng,t.lng),t.lat=Math.min(r.lat,t.lat),i.lng=Math.max(n.lng,i.lng),i.lat=Math.max(n.lat,i.lat)):(this._sw=new nc(r.lng,r.lat),this._ne=new nc(n.lng,n.lat)),this}getCenter(){return new nc((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 nc(this.getWest(),this.getNorth())}getSouthEast(){return new nc(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}=nc.convert(e);let r=this._sw.lng<=t&&t<=this._ne.lng;return this._sw.lng>this._ne.lng&&(r=this._sw.lng>=t&&t>=this._ne.lng),this._sw.lat<=i&&i<=this._ne.lat&&r}static convert(e){if(e)return e instanceof oc?e:new oc(e)}}const sc=0,ac=25.5;function lc(e){return rc*Math.cos(e*Math.PI/180)}function cc(e){return(180+e)/360}function uc(e){return(180-180/Math.PI*Math.log(Math.tan(Math.PI/4+e*Math.PI/360)))/360}function hc(e,t){return e/lc(t)}function dc(e){return 360*e-180}function pc(e){return 360/Math.PI*Math.atan(Math.exp((180-360*e)*Math.PI/180))-90}function fc(e,t){return e*lc(pc(t))}const mc=85.051129;function gc(e){return Math.cos(Se(Fe(e,-mc,mc)))}function _c(e,t){const i=Fe(t,sc,ac),r=Math.pow(2,i);return gc(e)*rc/(512*r)}function Ac(e){return 1/Math.cos(e*Math.PI/180)}function yc(e,t=0){const i=Math.exp(Math.PI*(1-(e.y+t/Ur)/(1<=l?(xc(e,t,i,c,u,o,h,a,l),xc(e,c,u,r,n,h,s,a,l)):e.push(s)}function bc(e,t,i){let r=e[0],n=r.x,o=r.y;t(r);const s=[r];for(let a=1;ae.x+1||re.y+1)&&Ze("Geometry exceeds allowed extent, reduce your vector tile buffer size"),e}function Sc(e,t,i){const r=e.loadGeometry(),n=e.extent,o=Ur/n;if(t&&i&&i.projection.isReprojectedInTileSpace){const o=1<{const i=dc((t.x+e.x/n)/o),r=pc((t.y+e.y/n)/o),u=c.project(i,r);e.x=(u.x*s-a)*n,e.y=(u.y*s-l)*n};for(let t=0;t=n||i.y<0||i.y>=n||(u(i),e.push(i));r[t]=e}}for(const e of r)for(const t of e)Bc(t,o);return r}function Ic(e,t){return{type:e.type,id:e.id,properties:e.properties,geometry:t?Sc(e):[]}}class Mc{constructor(e,t,i,r,n){this.properties={},this.extent=i,this.type=0,this.id=void 0,this._pbf=e,this._geometry=-1,this._keys=r,this._values=n,e.readFields(Pc,this,t)}loadGeometry(){const e=this._pbf;e.pos=this._geometry;const t=e.readVarint()+e.pos,i=[];let r,n=1,o=0,s=0,a=0;for(;e.pos>3}if(o--,1===n||2===n)s+=e.readSVarint(),a+=e.readSVarint(),1===n&&(r&&i.push(r),r=[]),r&&r.push(new Te(s,a));else{if(7!==n)throw new Error(`unknown command ${n}`);r&&r.push(r[0].clone())}}return r&&i.push(r),i}bbox(){const e=this._pbf;e.pos=this._geometry;const t=e.readVarint()+e.pos;let i=1,r=0,n=0,o=0,s=1/0,a=-1/0,l=1/0,c=-1/0;for(;e.pos>3}if(r--,1===i||2===i)n+=e.readSVarint(),o+=e.readSVarint(),na&&(a=n),oc&&(c=o);else if(7!==i)throw new Error(`unknown command ${i}`)}return[s,l,a,c]}toGeoJSON(e,t,i){const r=this.extent*Math.pow(2,i),n=this.extent*e,o=this.extent*t,s=this.loadGeometry();function a(e){return[360*(e.x+n)/r-180,360/Math.PI*Math.atan(Math.exp((1-2*(e.y+o)/r)*Math.PI))-90]}function l(e){return e.map(a)}let c;if(1===this.type){const e=[];for(const t of s)e.push(t[0]);const t=l(e);c=1===e.length?{type:"Point",coordinates:t[0]}:{type:"MultiPoint",coordinates:t}}else if(2===this.type){const e=s.map(l);c=1===e.length?{type:"LineString",coordinates:e[0]}:{type:"MultiLineString",coordinates:e}}else{if(3!==this.type)throw new Error("unknown feature type");{const e=function(e){const t=e.length;if(t<=1)return[e];const i=[];let r,n;for(let o=0;o=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 Mc(this._pbf,t,this.extent,this._keys,this._values)}}function Fc(e,t,i){15===e?t.version=i.readVarint():1===e?t.name=i.readString():5===e?t.extent=i.readVarint():2===e?t._features.push(i.pos):3===e?t._keys.push(i.readString()):4===e&&t._values.push(function(e){let t=null;const i=e.readVarint()+e.pos;for(;e.pos>3;t=1===i?e.readString():2===i?e.readFloat():3===i?e.readDouble():4===i?e.readVarint64():5===i?e.readVarint():6===i?e.readSVarint():7===i?e.readBoolean():null}if(null==t)throw new Error("unknown feature value");return t}(i))}class kc{constructor(e,t){this.layers=e.readFields(Dc,{},t)}}function Dc(e,t,i){if(3===e){const e=new Lc(i,i.readVarint()+i.pos);e.length&&(t[e.name]=e)}}const Oc="3d_elevation_id",zc="level";class Uc{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,r){const n=this.feature.properties.hasOwnProperty(e)?+this.feature.properties[e]:void 0;return this._valid&&void 0!==n&&!Number.isNaN(n)?i(r?r(n):n):t&&(this._valid=!1),this}}class Nc{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 Vc=new Nc((e,t,i)=>e.reset(t).require(Oc,e=>{i.id=e}).optional("fixed_height_relative",e=>{i.constantHeight=e},Gc.decodeRelativeHeight).geometry(e=>{i.bounds=e},_r).success(),(e,t,i)=>e.reset(t).require(Oc,e=>{i.id=e}).require("elevation_idx",e=>{i.idx=e}).require("extent",e=>{i.extent=e}).require("height_relative",e=>{i.height=e},Gc.decodeRelativeHeight).geometry(e=>{i.position=e},Gc.getPoint).success()),jc=new Nc((e,t,i)=>e.reset(t).require(Oc,e=>{i.id=e}).optional("fixed_height",e=>{i.constantHeight=e},Gc.decodeMetricHeight).geometry(e=>{i.bounds=e},_r).success(),(e,t,i)=>e.reset(t).require(Oc,e=>{i.id=e}).require("elevation_idx",e=>{i.idx=e}).require("extent",e=>{i.extent=e}).require("height",e=>{i.height=e},Gc.decodeMetricHeight).geometry(e=>{i.position=e},Gc.getPoint).success());class Gc{static getPoint(e){return ue(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?jc:void 0:Vc}static parse(e){const t=[],i=[],r=e.length,n=new Uc;for(let o=0;o=0);if(0===o)return 0;o!==t.length&&(i=!1)}return i?2:1}function qc(e,t){for(const i of e.projections){const r=Zc(t,e.points[0],i.axis);if(i.projection[1]r[1])return 0}return 1}function Kc(e,t){let i=0;const r=[0,0,0,0];for(let s=0;s=0&&i++;var n,o;return i}class Xc{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=Jc.fromPoints(this.points),this.projections=[],this.frustumEdges=[Z([],this.points[2],this.points[3]),Z([],this.points[0],this.points[3]),Z([],this.points[4],this.points[0]),Z([],this.points[5],this.points[1]),Z([],this.points[6],this.points[2]),Z([],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:Zc(this.points,this.points[0],t)}),this.projections.push({axis:i,projection:Zc(this.points,this.points[0],i)})}}static fromInvProjectionMatrix(e,t,i,r){const n=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=Y([],i,e),s=1/o[3]/t*n;return(a=o)[0]=(l=o)[0]*(c=[s,s,r?1/o[3]:s,s])[0],a[1]=l[1]*c[1],a[2]=l[2]*c[2],a[3]=l[3]*c[3],a;var a,l,c}),s=[[0,1,2],[6,5,4],[0,3,7],[2,1,5],[3,2,6],[0,4,5]].map(e=>{const t=z([],N([],Z([],o[e[0]],o[e[1]]),Z([],o[e[2]],o[e[1]]))),i=-U(t,o[e[1]]);return t.concat(i)}),a=[];for(let e=0;es[1]||s[0]>o[1])return 0}return 1}containsPoint(e){for(const t of this.planes){const i=t[3];if(U([t[0],t[1],t[2]],e)+i<0)return!1}return!0}}class Jc{static fromPoints(e){const t=[1/0,1/0,1/0],i=[-1/0,-1/0,-1/0];for(const r of e)M(t,t,r),P(i,i,r);return new Jc(t,i)}static fromTileIdAndHeight(e,t,i){const r=1<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])]}}es(Jc,"Aabb");class Yc{constructor(e,t){this.feature=e,this.metersToTile=t,this.index=0}get(){const e=this.feature.vertices[this.index],t=this.feature.vertexProps[this.index].dir,i=t[1],r=-t[0],n=(e.extent+1)*this.metersToTile;return[new Te(Math.trunc(e.position[0]+i*n),Math.trunc(e.position[1]+r*n)),new Te(Math.trunc(e.position[0]-i*n),Math.trunc(e.position[1]-r*n))]}next(){this.index++}valid(){return this.index{return e.a0?R(a,a,1/l):C(a,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,r=0;const[n,o,s,a,l,c,u]=this._tmpVec2;he(u,e.x,e.y);const h=new Hc(u,null);for(let e=0;e0?_e(a,s)/A:0,v=Fe(y,0,1),x=Math.abs((y-v)*this.edgeProps[e].len);pe(l,u,f),he(c,p[1],-p[0]);const b=x+Math.abs(_e(l,c));b=0;--o){const s=this.edges[o].a,a=this.edges[o].b,{position:l,height:c,extent:u}=this.vertices[s],{position:h,height:d,extent:p}=this.vertices[a],f=this.vertexProps[s].dir,m=this.vertexProps[a].dir;if(C(t,l[0]/e,l[1]/e,c),C(i,h[0]/e,h[1]/e,d),C(r,f[1],-f[0],0),R(r,r,u),C(n,m[1],-m[0],0),R(n,n,p),this.distSqLines(E(t[0]+.5*r[0],t[1]+.5*r[1],t[2]+.5*r[2]),E(i[0]-.5*n[0],i[1]-.5*n[1],i[2]-.5*n[2]),E(t[0]-.5*r[0],t[1]-.5*r[1],t[2]-.5*r[2]),E(i[0]+.5*n[0],i[1]+.5*n[1],i[2]+.5*n[2]))<=.0025000000000000005)continue;const g=this.vertices.length,_=de(ce(),l,h);this.vertices.push({position:fe(_,_,.5),height:.5*(c+d),extent:.5*(u+p)});const A=de(ce(),f,m);this.vertexProps.push({dir:ge(A,A)}),this.edges.splice(o,1),this.edgeProps.splice(o,1),this.edges.push({a:s,b:g}),this.edges.push({a:g,b:a});const y=pe(ce(),this.vertices[g].position,l),v=me(y),x={vec:y,dir:fe(ce(),y,1/v),len:v};this.edgeProps.push(x),this.edgeProps.push(x)}}distSqLines(e,t,i,r){const n=S(b(),t,e),o=S(b(),r,i),s=S(b(),e,i),a=U(n,n),l=U(n,o),c=U(n,s),u=U(o,o),h=U(o,s),d=a*u-l*l;if(0===d)return k(V(n,i,r,U(s,o)/U(o,o)),e);const p=(a*h-l*c)/d;return k(V(n,e,t,(l*h-c*u)/d),V(o,i,r,p))}}class tu{static parseFrom(e,t){const i=Gc.parse(e);if(!i)return[];let{vertices:r,features:n}=i;const o=1/yc(t);n.sort((e,t)=>e.id-t.id),r.sort((e,t)=>e.id-t.id||e.idx-t.idx),r=r.filter((e,t,i)=>t===i.findIndex(t=>t.id===e.id&&t.idx===e.idx));const s=new Array;let a=0;const l=r.length;for(const e of n){if(e.constantHeight){s.push(new eu(e.id,e.bounds,e.constantHeight));continue}for(;a!==l&&r[a].ide.id===i)}}class iu{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)*Ur,this.yOffset=(e.y*this.zScale-t.y)*Ur)}constantElevation(e,t){if(null!=e.constantHeight)return this.computeBiasedHeight(e.constantHeight,t)}pointElevation(e,t,i){const r=this.constantElevation(t,i);return null!=r?r:(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*ke(0,t,e>=0?e:Math.abs(.5*e))}}es(eu,"ElevationFeature");class ru{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 pa,this.indexArray=new Fa,this.segments=new hl,this.programConfigurations=new Nl(e.layers,{zoom:e.zoom,lut:e.lut}),this.stateDependentLayerIds=this.layers.filter(e=>e.isStateDependent()).map(e=>e.id),this.elevationMode=this.layers[0].layout.get("circle-elevation-reference"),this.hasElevation=!1,"none"!==this.elevationMode&&(this.elevatedLayoutVertexArray=new ga),this.worldview=e.worldview,this.hasAppearances=null}updateFootprints(e,t){}updateAppearances(e,t,i,r){}populate(e,t,i,r){const n=this.layers[0],o=[];let s=null;"circle"===n.type&&(s=n.layout.get("circle-sort-key"));for(const{feature:n,id:a,index:l,sourceLayerIndex:c}of e){const e=this.layers[0]._featureFilter.needGeometry,u=Ic(n,e);if(!this.layers[0]._featureFilter.filter(new Es(this.zoom,{worldview:this.worldview,activeFloors:t.activeFloors}),u,i))continue;const h=s?s.evaluate(u,{},i):void 0,d={id:a,properties:n.properties,type:n.type,sourceLayerIndex:c,index:l,geometry:e?u.geometry:Sc(n,i,r),patterns:{},sortKey:h};o.push(d)}s&&o.sort((e,t)=>e.sortKey-t.sortKey);let a=null;"globe"===r.projection.name&&(this.globeExtVertexArray=new Ta,a=r.projection);for(const r of o){const{geometry:n,index:o,sourceLayerIndex:s}=r,l=e[o].feature;this.addFeature(r,n,o,t.availableImages,i,a,t.brightness,t.elevationFeatures),t.featureIndex.insert(l,n,o,s,this.index)}this.hasElevation||(this.elevatedLayoutVertexArray=void 0)}update(e,t,i,r,n,o,s){this.programConfigurations.updatePaintArrays(e,t,n,i,r,o,s,this.worldview)}isEmpty(){return 0===this.layoutVertexArray.length}uploadPending(){return!this.uploaded||this.programConfigurations.needsUpload}upload(e){this.uploaded||(this.layoutVertexBuffer=e.createVertexBuffer(this.layoutVertexArray,ll.members),this.indexBuffer=e.createIndexBuffer(this.indexArray),this.globeExtVertexArray&&(this.globeExtVertexBuffer=e.createVertexBuffer(this.globeExtVertexArray,ul.members)),this.elevatedLayoutVertexArray&&(this.elevatedLayoutVertexBuffer=e.createVertexBuffer(this.elevatedLayoutVertexArray,cl.members))),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.elevatedLayoutVertexBuffer&&this.elevatedLayoutVertexBuffer.destroy())}addFeature(e,t,i,r,n,o,s,a){let l;"none"!==this.elevationMode&&(l=tu.getElevationFeature(e,a));for(const i of t)for(const t of i){const i=t.x,r=t.y;if(i<0||i>=Ur||r<0||r>=Ur)continue;if(o){const e=o.projectTilePoint(i,r,n),t=o.upVector(n,i,r);this.addGlobeExtVertex(e,t),this.addGlobeExtVertex(e,t),this.addGlobeExtVertex(e,t),this.addGlobeExtVertex(e,t)}const s=this.segments.prepareSegment(4,this.layoutVertexArray,this.indexArray,e.sortKey),a=s.vertexLength;if(this.addCircleVertex(i,r,-1,-1),this.addCircleVertex(i,r,1,-1),this.addCircleVertex(i,r,1,1),this.addCircleVertex(i,r,-1,1),"none"!==this.elevationMode){const e=l?l.pointElevation(new Te(i,r)):0;this.hasElevation=this.hasElevation||0!==e;for(let t=0;t<4;t++)this.elevatedLayoutVertexArray.emplaceBack(e)}this.indexArray.emplaceBack(a,a+1,a+2),this.indexArray.emplaceBack(a,a+2,a+3),s.vertexLength+=4,s.primitiveLength+=2}this.programConfigurations.populatePaintArrays(this.layoutVertexArray.length,e,i,{},r,n,s,void 0,this.worldview)}addCircleVertex(e,t,i,r){this.layoutVertexArray.emplaceBack(2*e+(i+1)/2,2*t+(r+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)}}function nu(e,t){for(let i=0;i1){if(lu(e,t))return!0;for(let r=0;r1?i:i.sub(t)._mult(n)._add(t))}function fu(e,t){let i,r,n,o=!1;for(let s=0;st.y!=n.y>t.y&&t.x<(n.x-r.x)*(t.y-r.y)/(n.y-r.y)+r.x&&(o=!o)}return o}function mu(e,t){let i=!1;for(let r=0,n=e.length-1;rt.y!=s.y>t.y&&t.x<(s.x-o.x)*(t.y-o.y)/(s.y-o.y)+o.x&&(i=!i)}return i}function gu(e,t,i,r,n){for(const o of e)if(t<=o.x&&i<=o.y&&r>=o.x&&n>=o.y)return!0;const o=[new Te(t,i),new Te(t,n),new Te(r,n),new Te(r,i)];if(e.length>2)for(const t of o)if(mu(e,t))return!0;for(let t=0;tn.x&&t.x>n.x||e.yn.y&&t.y>n.y)return!1;const o=We(e,t,i[0]);return o!==We(e,t,i[1])||o!==We(e,t,i[2])||o!==We(e,t,i[3])}function Au(e,t,i,r,n,o){let s=t.y-e.y,a=e.x-t.x;if(o=o||0){const e=s*s+a*a;if(0===e)return!0;const t=Math.sqrt(e);s/=t,a/=t}return!((i.x-e.x)*s+(i.y-e.y)*a-o<0||(r.x-e.x)*s+(r.y-e.y)*a-o<0||(n.x-e.x)*s+(n.y-e.y)*a-o<0)}function yu(e,t,i,r,n,o,s){return!(Au(e,t,r,n,o,s)||Au(t,i,r,n,o,s)||Au(i,e,r,n,o,s)||Au(r,n,e,t,i,s)||Au(n,o,e,t,i,s)||Au(o,r,e,t,i,s))}function vu(e,t,i){const r=t.paint.get(e).value;return"constant"===r.kind?r.value:i.programConfigurations.get(t.id).getMaxValue(e)}function xu(e){return Math.sqrt(e[0]*e[0]+e[1]*e[1])}function bu(e,t,i,r,n){if(!t[0]&&!t[1])return e;const o=Te.convert(t)._mult(n);"viewport"===i&&o._rotate(-r);const s=[];for(let t=0;t>t&&e.y===this.y>>t}url(e,t){const i=function(e,t,i){var r=Cu(256*e,256*(t=Math.pow(2,i)-t-1),i),n=Cu(256*(e+1),256*(t+1),i);return r[0]+","+r[1]+","+n[0]+","+n[1]}(this.x,this.y,this.z),r=function(e,t,i){let r,n="";for(let o=e;o>0;o--)r=1<this.canonical.z?new Iu(e,this.wrap,this.canonical.z,this.canonical.x,this.canonical.y):new Iu(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 Mu(this.wrap*+t,e,this.canonical.z,this.canonical.x,this.canonical.y);{const i=this.canonical.z-e;return Mu(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>t&&e.canonical.y===this.canonical.y>>t}children(e){if(this.overscaledZ>=e)return[new Iu(this.overscaledZ+1,this.wrap,this.canonical.z,this.canonical.x,this.canonical.y)];const t=this.canonical.z+1,i=2*this.canonical.x,r=2*this.canonical.y;return[new Iu(t,this.wrap,t,i,r),new Iu(t,this.wrap,t,i+1,r),new Iu(t,this.wrap,t,i,r+1),new Iu(t,this.wrap,t,i+1,r+1)]}isLessThan(e){return this.wrape.wrap)&&(this.overscaledZe.overscaledZ)&&(this.canonical.xe.canonical.x)&&this.canonical.y{let t=e.canonical.x-1,i=e.wrap;return t<0&&(t=(1<{let t=e.canonical.x+1,i=e.wrap;return t===1<new Iu(e.overscaledZ,e.wrap,e.canonical.z,e.canonical.x,(0===e.canonical.y?1<new Iu(e.overscaledZ,e.wrap,e.canonical.z,e.canonical.x,e.canonical.y===(1<1?null:function(e,t,i,r){const n=Math.sin(i);return e*(Math.sin((1-r)*i)/n)+t*(Math.sin(r*i)/n)}(e.a[t],e.b[t],e.angle,Fe(i,0,1))+e.center[t]}function Vu(e){if(e.z<=1)return Ou[e.z+2*e.y+e.x];const t=$u(Qu(e));return Jc.fromPoints(t)}function ju(e,t,i){return R(e,e,1-i),L(e,e,t,i)}function Gu(e,t,i){for(const r of e)j(r,r,t),R(r,r,i)}function Hu(e,t,i,r){const n=t/e.worldSize,o=e.globeMatrix;if(i.z<=1){const e=Vu(i).getCorners();return Gu(e,o,n),Jc.fromPoints(e)}const s=Qu(i,r),a=$u(s,$l+Du(e._tileCoverLift));Gu(a,o,n);const l=Number.MAX_VALUE,c=[-l,-l,-l],u=[l,l,l];if(s.contains(e.center)){for(const e of a)M(u,u,e),P(c,c,e);c[2]=0;const t=e.point,i=[t.x*n,t.y*n,0];return M(u,u,i),P(c,c,i),new Jc(u,c)}if(e._tileCoverLift>0){for(const e of a)M(u,u,e),P(c,c,e);return new Jc(u,c)}const h=[o[12]*n,o[13]*n,o[14]*n],d=s.getCenter(),p=Fe(e.center.lat,-mc,mc),f=Fe(d.lat,-mc,mc),m=cc(e.center.lng),g=uc(p);let _=m-cc(d.lng);const A=g-uc(f);_>.5?_-=1:_<-.5&&(_+=1);let y=0;Math.abs(_)>Math.abs(A)?y=_>=0?1:3:(y=A>=0?0:2,L(h,h,[o[4]*n,o[5]*n,o[6]*n],-Math.sin(Se(A>=0?s.getSouth():s.getNorth()))*$l));const v=a[y],x=a[(y+1)%4],b=new Uu(v,x,h),w=[Nu(b,0)||v[0],Nu(b,1)||v[1],Nu(b,2)||v[2]],T=th(e.zoom);if(T>0){const r=function({x:e,y:t,z:i},r,n,o,s){const a=1/(1<.5?d=-1:p<-.5&&(d=1),l=((l+d)*r-(o*=r))*n+o,c=((c+d)*r-o)*n+o,u=(u*r-(s*=r))*n+s,h=(h*r-s)*n+s,[[l,h,0],[c,h,0],[c,u,0],[l,u,0]]}(i,t,e._pixelsPerMercatorPixel,m,g);for(let e=0;eMath.PI/2*1.01}const nh=Se(85),oh=Math.cos(nh),sh=Math.sin(nh),ah=a(),lh=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 ch(e,t,i,r,n,o,s,a,l){if(o&&e.queryGeometry.isAboveHorizon)return!1;o&&(l*=e.pixelToTileUnitsFactor);const c=e.tileID.canonical,u=i.projection.upVectorScale(c,i.center.lat,i.worldSize).metersToTile;for(const h of t)for(const t of h){const h=t.add(a),d=n&&i.elevation?i.elevation.exaggeration()*n.getElevationAt(h.x,h.y,!0):0,p=i.projection.projectTilePoint(h.x,h.y,c);if(d>0){const e=i.projection.upVector(c,h.x,h.y);p.x+=e[0]*u*d,p.y+=e[1]*u*d,p.z+=e[2]*u*d}const f=o?h:uh(p.x,p.y,p.z,r),m=o?e.tilespaceRays.map(e=>ph(e,d)):e.queryGeometry.screenGeometry,g=Y([],[p.x,p.y,p.z,1],r);if(!s&&o?l*=g[3]/i.cameraToCenterDistance:s&&!o&&(l*=i.cameraToCenterDistance/g[3]),o){const e=pc((t.y/Ur+c.y)/(1<e.width||n.height>e.height||i.x>e.width-n.width||i.y>e.height-n.height)throw new RangeError("out of range source coordinates for image copy");if(n.width>t.width||n.height>t.height||r.x>t.width-n.width||r.y>t.height-n.height)throw new RangeError("out of range destination coordinates for image copy");const l=e.data,c=t.data,u=4===o&&a;for(let a=0;a{t[e.evaluationKey]=o;const s=e.expression.evaluate(t),a=s?s.toNonPremultipliedRenderColor(null):null;a&&(n.data[i+r+0]=Math.floor(255*a.r),n.data[i+r+1]=Math.floor(255*a.g),n.data[i+r+2]=Math.floor(255*a.b),n.data[i+r+3]=Math.floor(255*a.a))};if(e.clips)for(let t=0,n=0;t80*i){a=e[0],l=e[1];let t=a,r=l;for(let o=i;ot&&(t=i),n>r&&(r=n)}c=Math.max(t-a,r-l),c=0!==c?32767/c:0}return Lh(o,s,i,a,l,c,0),s}function Ph(e,t,i,r,n){let o;if(n===function(e,t,i,r){let n=0;for(let o=t,s=i-r;o0)for(let n=t;n=t;n-=r)o=Yh(n/r|0,e[n],e[n+1],o);return o&&Zh(o,o.next)&&(ed(o),o=o.next),o}function Rh(e,t){if(!e)return e;t||(t=e);let i,r=e;do{if(i=!1,r.steiner||!Zh(r,r.next)&&0!==$h(r.prev,r,r.next))r=r.next;else{if(ed(r),r=t=r.prev,r===r.next)break;i=!0}}while(i||r!==t);return t}function Lh(e,t,i,r,n,o,s){if(!e)return;!s&&o&&function(e,t,i,r){let n=e;do{0===n.z&&(n.z=Vh(n.x,n.y,t,i,r)),n.prevZ=n.prev,n.nextZ=n.next,n=n.next}while(n!==e);n.prevZ.nextZ=null,n.prevZ=null,function(e){let t,i=1;do{let r,n=e;e=null;let o=null;for(t=0;n;){t++;let s=n,a=0;for(let e=0;e0||l>0&&s;)0!==a&&(0===l||!s||n.z<=s.z)?(r=n,n=n.nextZ,a--):(r=s,s=s.nextZ,l--),o?o.nextZ=r:e=r,r.prevZ=o,o=r;n=s}o.nextZ=null,i*=2}while(t>1)}(n)}(e,r,n,o);let a=e;for(;e.prev!==e.next;){const l=e.prev,c=e.next;if(o?kh(e,r,n,o):Fh(e))t.push(l.i,e.i,c.i),ed(e),e=c.next,a=c.next;else if((e=c)===a){s?1===s?Lh(e=Dh(Rh(e),t),t,i,r,n,o,2):2===s&&Oh(e,t,i,r,n,o):Lh(Rh(e),t,i,r,n,o,1);break}}}function Fh(e){const t=e.prev,i=e,r=e.next;if($h(t,i,r)>=0)return!1;const n=t.x,o=i.x,s=r.x,a=t.y,l=i.y,c=r.y,u=Math.min(n,o,s),h=Math.min(a,l,c),d=Math.max(n,o,s),p=Math.max(a,l,c);let f=r.next;for(;f!==t;){if(f.x>=u&&f.x<=d&&f.y>=h&&f.y<=p&&Hh(n,a,o,l,s,c,f.x,f.y)&&$h(f.prev,f,f.next)>=0)return!1;f=f.next}return!0}function kh(e,t,i,r){const n=e.prev,o=e,s=e.next;if($h(n,o,s)>=0)return!1;const a=n.x,l=o.x,c=s.x,u=n.y,h=o.y,d=s.y,p=Math.min(a,l,c),f=Math.min(u,h,d),m=Math.max(a,l,c),g=Math.max(u,h,d),_=Vh(p,f,t,i,r),A=Vh(m,g,t,i,r);let y=e.prevZ,v=e.nextZ;for(;y&&y.z>=_&&v&&v.z<=A;){if(y.x>=p&&y.x<=m&&y.y>=f&&y.y<=g&&y!==n&&y!==s&&Hh(a,u,l,h,c,d,y.x,y.y)&&$h(y.prev,y,y.next)>=0)return!1;if(y=y.prevZ,v.x>=p&&v.x<=m&&v.y>=f&&v.y<=g&&v!==n&&v!==s&&Hh(a,u,l,h,c,d,v.x,v.y)&&$h(v.prev,v,v.next)>=0)return!1;v=v.nextZ}for(;y&&y.z>=_;){if(y.x>=p&&y.x<=m&&y.y>=f&&y.y<=g&&y!==n&&y!==s&&Hh(a,u,l,h,c,d,y.x,y.y)&&$h(y.prev,y,y.next)>=0)return!1;y=y.prevZ}for(;v&&v.z<=A;){if(v.x>=p&&v.x<=m&&v.y>=f&&v.y<=g&&v!==n&&v!==s&&Hh(a,u,l,h,c,d,v.x,v.y)&&$h(v.prev,v,v.next)>=0)return!1;v=v.nextZ}return!0}function Dh(e,t){let i=e;do{const r=i.prev,n=i.next.next;!Zh(r,n)&&Wh(r,i,i.next,n)&&Xh(r,n)&&Xh(n,r)&&(t.push(r.i,i.i,n.i),ed(i),ed(i.next),i=e=n),i=i.next}while(i!==e);return Rh(i)}function Oh(e,t,i,r,n,o){let s=e;do{let e=s.next.next;for(;e!==s.prev;){if(s.i!==e.i&&Qh(s,e)){let a=Jh(s,e);return s=Rh(s,s.next),a=Rh(a,a.next),Lh(s,t,i,r,n,o,0),void Lh(a,t,i,r,n,o,0)}e=e.next}s=s.next}while(s!==e)}function zh(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 Uh(e,t){const i=function(e,t){let i=t;const r=e.x,n=e.y;let o,s=-1/0;if(Zh(e,i))return i;do{if(Zh(e,i.next))return i.next;if(n<=i.y&&n>=i.next.y&&i.next.y!==i.y){const e=i.x+(n-i.y)*(i.next.x-i.x)/(i.next.y-i.y);if(e<=r&&e>s&&(s=e,o=i.x=i.x&&i.x>=l&&r!==i.x&&Gh(no.x||i.x===o.x&&Nh(o,i)))&&(o=i,u=t)}i=i.next}while(i!==a);return o}(e,t);if(!i)return t;const r=Jh(i,e);return Rh(r,r.next),Rh(i,i.next)}function Nh(e,t){return $h(e.prev,e,t.prev)<0&&$h(t.next,e,e.next)<0}function Vh(e,t,i,r,n){return(e=1431655765&((e=858993459&((e=252645135&((e=16711935&((e=(e-i)*n|0)|e<<8))|e<<4))|e<<2))|e<<1))|(t=1431655765&((t=858993459&((t=252645135&((t=16711935&((t=(t-r)*n|0)|t<<8))|t<<4))|t<<2))|t<<1))<<1}function jh(e){let t=e,i=e;do{(t.x=(e-s)*(o-a)&&(e-s)*(r-a)>=(i-s)*(t-a)&&(i-s)*(o-a)>=(n-s)*(r-a)}function Hh(e,t,i,r,n,o,s,a){return!(e===s&&t===a)&&Gh(e,t,i,r,n,o,s,a)}function Qh(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&&Wh(i,i.next,e,t))return!0;i=i.next}while(i!==e);return!1}(e,t)&&(Xh(e,t)&&Xh(t,e)&&function(e,t){let i=e,r=!1;const n=(e.x+t.x)/2,o=(e.y+t.y)/2;do{i.y>o!=i.next.y>o&&i.next.y!==i.y&&n<(i.next.x-i.x)*(o-i.y)/(i.next.y-i.y)+i.x&&(r=!r),i=i.next}while(i!==e);return r}(e,t)&&($h(e.prev,e,t.prev)||$h(e,t.prev,t))||Zh(e,t)&&$h(e.prev,e,e.next)>0&&$h(t.prev,t,t.next)>0)}function $h(e,t,i){return(t.y-e.y)*(i.x-t.x)-(t.x-e.x)*(i.y-t.y)}function Zh(e,t){return e.x===t.x&&e.y===t.y}function Wh(e,t,i,r){const n=Kh($h(e,t,i)),o=Kh($h(e,t,r)),s=Kh($h(i,r,e)),a=Kh($h(i,r,t));return n!==o&&s!==a||!(0!==n||!qh(e,i,t))||!(0!==o||!qh(e,r,t))||!(0!==s||!qh(i,e,r))||!(0!==a||!qh(i,t,r))}function qh(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 Kh(e){return e>0?1:e<0?-1:0}function Xh(e,t){return $h(e.prev,e,e.next)<0?$h(e,t,e.next)>=0&&$h(e,e.prev,t)>=0:$h(e,t,e.prev)<0||$h(e,e.next,t)<0}function Jh(e,t){const i=td(e.i,e.x,e.y),r=td(t.i,t.x,t.y),n=e.next,o=t.prev;return e.next=t,t.prev=e,i.next=n,n.prev=i,r.next=i,i.prev=r,o.next=r,r.prev=o,r}function Yh(e,t,i,r){const n=td(e,t,i);return r?(n.next=r.next,n.prev=r,r.next.prev=n,r.next=n):(n.prev=n,n.next=n),n}function ed(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 td(e,t,i){return{i:e,x:t,y:i,prev:null,next:null,z:0,prevZ:null,nextZ:null,steiner:!1}}function id(e,t){const i=e.length;if(i<=1)return[e];const r=[];let n,o;for(let t=0;t1)for(let e=0;e=Ur&&t>=Ur}static evaluate(e){if(0===e.length)return new ld;let t=[];for(const i of e)t.push(...i.portals);if(0===t.length)return new ld;for(const e of t){const t=e.va,i=e.vb;(ld.isOnBorder(t.x,i.x)||ld.isOnBorder(t.y,i.y))&&(e.type="border")}const i=t.filter(e=>"unevaluated"!==e.type),r=t.filter(e=>"unevaluated"===e.type);if(0===r.length)return new ld;r.sort((e,t)=>e.hash===t.hash?e.isTunnel===t.isTunnel?0:e.isTunnel?-1:1:e.hashe.hash"fill-tunnel-structure-color"!==e),this.tunnelProgramConfigurations=new Nl(t,{zoom:i,lut:r},e=>"fill-bridge-guard-rail-color"!==e)}addVertices(e,t){const i=this.unevalVertices.length;for(let i=0;i=n.min.x&&c.x<=n.max.x&&c.y>=n.min.y&&c.y<=n.max.y||u.x>=n.min.x&&u.x<=n.max.x&&u.y>=n.min.y&&u.y<=n.max.y||_u(c,u,s)))continue;if(this.isOnBorder(c.x,u.x)||this.isOnBorder(c.y,u.y))continue;const h=ud.computeEdgeHash(this.unevalVertices[i],this.unevalVertices[l]);let d,p=this.vertexHashLookup.get(ud.computePosHash(c));null!=p?d=p.next:(p=this.vertexHashLookup.get(ud.computePosHash(u)),d=null!=p?p.prev:h),this.unevalEdges.push({polygonIdx:e,a:i,b:l,hash:h,portalHash:d,isTunnel:r,type:"unevaluated",featureInfo:o})}}addPortalCandidates(e,t,i,r,n){if(0===t.length)return;this.portalPolygons.add(e,{geometry:t,zLevel:n});const o=t[0];this.vertexHashLookup.clear();let s=ud.computeEdgeHash(o[o.length-2],o[o.length-1]);for(let t=0;t({vertexOffset:0,primitiveOffset:this.indexArray.length}),i=e=>{e.primitiveLength=this.indexArray.length-e.primitiveOffset},r=new cd(this.vertexPositions,this.vertexNormals,this.indexArray);this.prepareEdges(e.portals,this.unevalEdges);const n=t(),o=t(),s=t(),a=(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=a(this.unevalEdges,"none"),this.constructBridgeStructures(r,this.unevalVertices,this.unevalHeights,this.unevalEdges,{min:0,max:l},this.tileToMeters)),i(s);const c=t(),u=t();if(this.unevalEdges.length>0){const e=this.unevalEdges.splice(l),t=a(e,"tunnel")+l;this.unevalEdges.push(...e),this.constructTunnelStructures(r,this.unevalVertices,this.unevalHeights,this.unevalEdges,{min:0,max:l},{min:l,max:t})}i(c),r.addTriangles(this.unevalTriangles,this.unevalVertices,this.unevalHeights),i(u),r.addTriangles(this.unevalTunnelTriangles,this.unevalVertices,this.unevalHeights),i(o),r.addTriangles(this.unevalTunnelTriangles,this.unevalVertices,[-.1]),i(n),this.maskSegments=hl.simpleSegment(0,u.primitiveOffset,0,u.primitiveLength),this.depthSegments=hl.simpleSegment(0,o.primitiveOffset,0,o.primitiveLength),this.renderableBridgeSegments=hl.simpleSegment(0,s.primitiveOffset,0,s.primitiveLength),this.renderableTunnelSegments=hl.simpleSegment(0,c.primitiveOffset,0,c.primitiveLength),this.shadowCasterSegments=hl.simpleSegment(0,n.primitiveOffset,0,n.primitiveLength)}update(e,t,i,r,n,o,s,a){this.bridgeProgramConfigurations.updatePaintArrays(e,t,n,i,r,o,s,a),this.tunnelProgramConfigurations.updatePaintArrays(e,t,n,i,r,o,s,a)}upload(e){this.vertexBuffer||0===this.vertexPositions.length||0===this.vertexNormals.length||0===this.indexArray.length||(this.vertexBuffer=e.createVertexBuffer(this.vertexPositions,Sh.members),this.vertexBufferNormal=e.createVertexBuffer(this.vertexNormals,Ih.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,r,n){const o=(o,s)=>{for(let a=0;aC(e,t[r].x,t[r].y,i[r]*a),u=b(),h=b(),d=b(),p=b(),f=b(),m=(e,i)=>{const r=s.get(ud.computePosHash(t[i])),n=r.from,o=r.to;if(!n||!o)return;c(u,n),c(h,i),c(d,o),Q(p),$(u,h)||(Z(f,h,u),z(p,f)),$(d,h)||(Z(f,d,h),B(p,p,z(f,f)));const a=q(p);return a>0?R(e,p,1/a):void 0};let g=Number.POSITIVE_INFINITY;this.sortSubarray(r,n.min,n.max,(e,t)=>e.featureInfo.featureIndex-t.featureInfo.featureIndex);const _=b(),A=b(),y=b(),v=b(),x=b(),w=b(),T=b(),E=b(),S=b(),I=[b(),b(),b(),b()],M=[b(),b(),b(),b()],P=[{coord:new Te(0,0),height:0},{coord:new Te(0,0),height:0}],L=(e,t)=>e>t;for(let c=n.min;ce.featureInfo.featureIndex-t.featureInfo.featureIndex;this.sortSubarray(r,n.min,n.max,a),this.sortSubarray(r,o.min,o.max,a);const l=e=>z(e,e),c=[{coord:new Te(0,0),height:0},{coord:new Te(0,0),height:0}],u=(e,t)=>ee.hash===t.hash?t.polygonIdx-e.polygonIdx:t.hash>e.hash?1:-1);let i=0,r=0,n=0,o=t[i].polygonIdx;do{r++,(r===t.length||t[i].hash!==t[r].hash)&&((1==r-i||t[r-1].polygonIdx!==o)&&(ne.portalHasho.hash?i++:o.hash>n.portalHash?r++:(n.type=o.type,i++)}}}isOnBorder(e,t){return e<=0&&t<=0||e>=Ur&&t>=Ur}addFeatureSection(e,t,i,r){return e!==t&&(t=e,i.push({featureIndex:e,vertexStart:r.getVertexCount()}),r.clearVertexLookup()),t}sortSubarray(e,t,i,r){const n=e.slice(t,i);n.sort(r),e.splice(t,n.length,...n)}static computeEdgeHash(e,t){return(e.y===t.y&&e.x>t.x||e.y>t.y)&&([e,t]=[t,e]),BigInt(ud.computePosHash(e))<<32n|BigInt(ud.computePosHash(t))}static computePosHash(e){return((65535&e.x)<<16|65535&e.y)>>>0}}var hd,dd={exports:{}},pd=(hd||(hd=1,function(e,t){!function(e){function t(e,t){return e>t?1:e0){var a=r+Math.floor(s/2),l={key:t[a],data:i[a],parent:e};return l.left=n(l,t,i,r,a),l.right=n(l,t,i,a+1,o),l}return null}function o(e,t,i,r,n){if(!(i>=r)){for(var s=e[i+r>>1],a=i-1,l=r+1;;){do{a++}while(n(e[a],s)<0);do{l--}while(n(e[l],s)>0);if(a>=l)break;var c=e[a];e[a]=e[l],e[l]=c,c=t[a],t[a]=t[l],t[l]=c}o(e,t,i,l,n),o(e,t,l+1,r,n)}}i.prototype.rotateLeft=function(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},i.prototype.rotateRight=function(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},i.prototype._splay=function(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)}},i.prototype.splay=function(e){for(var t,i,r,n,o;e.parent;)(i=(t=e.parent).parent)&&i.parent?((r=i.parent).left===i?r.left=e:r.right=e,e.parent=r):(e.parent=null,this._root=e),n=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):(n?(i.right=n,n.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)),n?(t.right=n,n.parent=t):t.right=null,e.left=t,t.parent=e)},i.prototype.replace=function(e,t){e.parent?e===e.parent.left?e.parent.left=t:e.parent.right=t:this._root=t,t&&(t.parent=e.parent)},i.prototype.minNode=function(e){if(void 0===e&&(e=this._root),e)for(;e.left;)e=e.left;return e},i.prototype.maxNode=function(e){if(void 0===e&&(e=this._root),e)for(;e.right;)e=e.right;return e},i.prototype.insert=function(e,t){var i=this._root,r=null,n=this._compare;if(this._noDuplicates)for(;i;){if(r=i,0===n(i.key,e))return;i=n(i.key,e)<0?i.right:i.left}else for(;i;)r=i,i=n(i.key,e)<0?i.right:i.left;return i={key:e,data:t,left:null,right:null,parent:r},r?n(r.key,i.key)<0?r.right=i:r.left=i:this._root=i,this.splay(i),this._size++,i},i.prototype.find=function(e){for(var t=this._root,i=this._compare;t;){var r=i(t.key,e);if(r<0)t=t.right;else{if(!(r>0))return t;t=t.left}}return null},i.prototype.contains=function(e){for(var t=this._root,i=this._compare;t;){var r=i(e,t.key);if(0===r)return!0;t=r<0?t.left:t.right}return!1},i.prototype.remove=function(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},i.prototype.removeNode=function(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},i.prototype.erase=function(e){var t=this.find(e);if(t){this.splay(t);var i=t.left,r=t.right,n=null;i&&(i.parent=null,n=this.maxNode(i),this.splay(n),this._root=n),r&&(i?n.right=r:this._root=r,r.parent=n),this._size--}},i.prototype.pop=function(){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},i.prototype.next=function(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},i.prototype.prev=function(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},i.prototype.forEach=function(e){for(var t=this._root,i=[],r=!1,n=0;!r;)t?(i.push(t),t=t.left):i.length>0?(e(t=i.pop(),n++),t=t.right):r=!0;return this},i.prototype.range=function(e,t,i,r){for(var n=[],o=this._compare,s=this._root;0!==n.length||s;)if(s)n.push(s),s=s.left;else{if(o((s=n.pop()).key,t)>0)break;if(o(s.key,e)>=0&&i.call(r,s))return this;s=s.right}return this},i.prototype.keys=function(){for(var e=this._root,t=[],i=[],r=!1;!r;)e?(t.push(e),e=e.left):t.length>0?(e=t.pop(),i.push(e.key),e=e.right):r=!0;return i},i.prototype.values=function(){for(var e=this._root,t=[],i=[],r=!1;!r;)e?(t.push(e),e=e.left):t.length>0?(e=t.pop(),i.push(e.data),e=e.right):r=!0;return i},i.prototype.at=function(e){for(var t=this._root,i=[],r=!1,n=0;!r;)if(t)i.push(t),t=t.left;else if(i.length>0){if(t=i.pop(),n===e)return t;n++,t=t.right}else r=!0;return null},i.prototype.load=function(e,t,i){if(void 0===e&&(e=[]),void 0===t&&(t=[]),void 0===i&&(i=!1),0!==this._size)throw new Error("bulk-load: tree is not empty");var r=e.length;return i&&o(e,t,0,r-1,this._compare),this._root=n(null,e,t,0,r),this._size=r,this},i.prototype.min=function(){var e=this.minNode(this._root);return e?e.key:null},i.prototype.max=function(){var e=this.maxNode(this._root);return e?e.key:null},i.prototype.isEmpty=function(){return null===this._root},r.size.get=function(){return this._size},i.createTree=function(e,t,r,n,o){return new i(r,o).load(e,t,n)},Object.defineProperties(i.prototype,r);var s=0,a=1,l=2,c=3,u=0,h=1,d=2,p=3;function f(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=!m(t,i)||t.isVertical()?t.prevInResult:t));var r=m(e,i);e.resultTransition=r?function(e,t){var i,r=!e.inOut,n=!e.otherInOut;switch(t){case u:i=r&&n;break;case h:i=r||n;break;case p:i=r^n;break;case d:i=e.isSubject?r&&!n:n&&!r}return i?1:-1}(e,i):0}function m(e,t){switch(e.type){case s:switch(t){case u:return!e.otherInOut;case h:return e.otherInOut;case d:return e.isSubject&&e.otherInOut||!e.isSubject&&!e.otherInOut;case p:return!0}break;case l:return t===u||t===h;case c:return t===d;case a:return!1}return!1}var g=function(e,t,i,r,n){this.left=t,this.point=e,this.otherEvent=i,this.isSubject=r,this.type=n||s,this.inOut=!1,this.otherInOut=!1,this.prevInResult=null,this.resultTransition=0,this.otherPos=-1,this.outputContourId=-1,this.isExteriorRing=!0},_={inResult:{configurable:!0}};function A(e,t){return e[0]===t[0]&&e[1]===t[1]}g.prototype.isBelow=function(e){var 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},g.prototype.isAbove=function(e){return!this.isBelow(e)},g.prototype.isVertical=function(){return this.point[0]===this.otherEvent.point[0]},_.inResult.get=function(){return 0!==this.resultTransition},g.prototype.clone=function(){var e=new g(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},Object.defineProperties(g.prototype,_);var y=11102230246251565e-32,v=134217729,x=(3+8*y)*y;function b(e,t,i,r,n){var o,s,a,l,c=t[0],u=r[0],h=0,d=0;u>c==u>-c?(o=c,c=t[++h]):(o=u,u=r[++d]);var p=0;if(hc==u>-c?(a=o-((s=c+o)-c),c=t[++h]):(a=o-((s=u+o)-u),u=r[++d]),o=s,0!==a&&(n[p++]=a);hc==u>-c?(a=o-((s=o+c)-(l=s-o))+(c-l),c=t[++h]):(a=o-((s=o+u)-(l=s-o))+(u-l),u=r[++d]),o=s,0!==a&&(n[p++]=a);for(;h0!=a>0)return l;var c=Math.abs(s+a);return Math.abs(l)>=T*c?l:-function(e,t,i,r,n,o,s){var a,l,c,u,h,d,p,f,m,g,_,A,y,w,T,R,L,F,k=e-n,D=i-n,O=t-o,z=r-o;B[0]=(T=(f=k-(p=(d=v*k)-(d-k)))*(g=z-(m=(d=v*z)-(d-z)))-((w=k*z)-p*m-f*m-p*g))-((_=T-(L=(f=O-(p=(d=v*O)-(d-O)))*(g=D-(m=(d=v*D)-(d-D)))-((R=O*D)-p*m-f*m-p*g)))+(h=T-_))+(h-L),B[1]=(y=w-((A=w+_)-(h=A-w))+(_-h))-((_=y-R)+(h=y-_))+(h-R),B[2]=A-((F=A+_)-(h=F-A))+(_-h),B[3]=F;var U=function(e,t){for(var i=t[0],r=1;r<4;r++)i+=t[r];return i}(0,B),N=E*s;if(U>=N||-U>=N)return U;if(a=e-(k+(h=e-k))+(h-n),c=i-(D+(h=i-D))+(h-n),l=t-(O+(h=t-O))+(h-o),u=r-(z+(h=r-z))+(h-o),0===a&&0===l&&0===c&&0===u)return U;if(N=C*s+x*Math.abs(U),(U+=k*u+z*a-(O*c+D*l))>=N||-U>=N)return U;P[0]=(T=(f=a-(p=(d=v*a)-(d-a)))*(g=z-(m=(d=v*z)-(d-z)))-((w=a*z)-p*m-f*m-p*g))-((_=T-(L=(f=l-(p=(d=v*l)-(d-l)))*(g=D-(m=(d=v*D)-(d-D)))-((R=l*D)-p*m-f*m-p*g)))+(h=T-_))+(h-L),P[1]=(y=w-((A=w+_)-(h=A-w))+(_-h))-((_=y-R)+(h=y-_))+(h-R),P[2]=A-((F=A+_)-(h=F-A))+(_-h),P[3]=F;var V=b(4,B,4,P,S);P[0]=(T=(f=k-(p=(d=v*k)-(d-k)))*(g=u-(m=(d=v*u)-(d-u)))-((w=k*u)-p*m-f*m-p*g))-((_=T-(L=(f=O-(p=(d=v*O)-(d-O)))*(g=c-(m=(d=v*c)-(d-c)))-((R=O*c)-p*m-f*m-p*g)))+(h=T-_))+(h-L),P[1]=(y=w-((A=w+_)-(h=A-w))+(_-h))-((_=y-R)+(h=y-_))+(h-R),P[2]=A-((F=A+_)-(h=F-A))+(_-h),P[3]=F;var j=b(V,S,4,P,I);P[0]=(T=(f=a-(p=(d=v*a)-(d-a)))*(g=u-(m=(d=v*u)-(d-u)))-((w=a*u)-p*m-f*m-p*g))-((_=T-(L=(f=l-(p=(d=v*l)-(d-l)))*(g=c-(m=(d=v*c)-(d-c)))-((R=l*c)-p*m-f*m-p*g)))+(h=T-_))+(h-L),P[1]=(y=w-((A=w+_)-(h=A-w))+(_-h))-((_=y-R)+(h=y-_))+(h-R),P[2]=A-((F=A+_)-(h=F-A))+(_-h),P[3]=F;var G=b(j,I,4,P,M);return M[G-1]}(e,t,i,r,n,o,c)}(e[0],e[1],t[0],t[1],i[0],i[1]);return r>0?-1:r<0?1:0}function L(e,t){var i=e.point,r=t.point;return i[0]>r[0]?1:i[0]r[1]?1:-1:function(e,t,i){return e.left!==t.left?e.left?1:-1:0!==R(i,e.otherEvent.point,t.otherEvent.point)?e.isBelow(t.otherEvent.point)?-1:1:!e.isSubject&&t.isSubject?1:-1}(e,t,i)}function F(e,t,i){var r=new g(t,!1,e,e.isSubject),n=new g(t,!0,e.otherEvent,e.isSubject);return A(e.point,e.otherEvent.point)&&console.warn("what is that, a collapsed segment?",e),r.contourId=n.contourId=e.contourId,L(n,e.otherEvent)>0&&(e.otherEvent.left=!0,n.left=!1),e.otherEvent.otherEvent=n,e.otherEvent=r,i.push(n),i.push(r),i}function k(e,t){return e[0]*t[1]-e[1]*t[0]}function D(e,t){return e[0]*t[0]+e[1]*t[1]}function O(e,t,i){var r=function(e,t,i,r){var n=[t[0]-e[0],t[1]-e[1]],o=[r[0]-i[0],r[1]-i[1]];function s(e,t,i){return[e[0]+t*i[0],e[1]+t*i[1]]}var a=[i[0]-e[0],i[1]-e[1]],l=k(n,o),c=l*l,u=D(n,n);if(c>0){var h=k(a,o)/l;if(h<0||h>1)return null;var d=k(a,n)/l;return d<0||d>1?null:0===h||1===h?[s(e,h,n)]:0===d||1===d?[s(i,d,o)]:[s(e,h,n)]}if((c=(l=k(a,n))*l)>0)return null;var p=D(n,a)/u,f=p+D(n,o)/u,m=Math.min(p,f),g=Math.max(p,f);return m<=1&&g>=0?1===m?[s(e,m>0?m:0,n)]:0===g?[s(e,g<1?g:1,n)]:[s(e,m>0?m:0,n),s(e,g<1?g:1,n)]:null}(e.point,e.otherEvent.point,t.point,t.otherEvent.point),n=r?r.length:0;if(0===n)return 0;if(1===n&&(A(e.point,t.point)||A(e.otherEvent.point,t.otherEvent.point)))return 0;if(2===n&&e.isSubject===t.isSubject)return 0;if(1===n)return A(e.point,r[0])||A(e.otherEvent.point,r[0])||F(e,r[0],i),A(t.point,r[0])||A(t.otherEvent.point,r[0])||F(t,r[0],i),1;var o=[],s=!1,u=!1;return A(e.point,t.point)?s=!0:1===L(e,t)?o.push(t,e):o.push(e,t),A(e.otherEvent.point,t.otherEvent.point)?u=!0:1===L(e.otherEvent,t.otherEvent)?o.push(t.otherEvent,e.otherEvent):o.push(e.otherEvent,t.otherEvent),s&&u||s?(t.type=a,e.type=t.inOut===e.inOut?l:c,s&&!u&&F(o[1].otherEvent,o[0].point,i),2):u?(F(o[0],o[1].point,i),3):o[0]!==o[3].otherEvent?(F(o[0],o[1].point,i),F(o[1],o[2].point,i),3):(F(o[0],o[1].point,i),F(o[3].otherEvent,o[2].point,i),3)}function z(e,t){if(e===t)return 0;if(0!==R(e.point,e.otherEvent.point,t.point)||0!==R(e.point,e.otherEvent.point,t.otherEvent.point))return A(e.point,t.point)?e.isBelow(t.otherEvent.point)?-1:1:e.point[0]===t.point[0]?e.point[1]t.contourId?1:-1:1===L(e,t)?1:-1}var U=function(){this.points=[],this.holeIds=[],this.holeOf=null,this.depth=null};function N(e,t,i,r){var n,o=e+1,s=t[e].point,a=t.length;for(or;)o--;return o}U.prototype.isExterior=function(){return null==this.holeOf};var V=G,j=G;function G(e,t){if(!(this instanceof G))return new G(e,t);if(this.data=e||[],this.length=this.data.length,this.compare=t||H,this.length>0)for(var i=(this.length>>1)-1;i>=0;i--)this._down(i)}function H(e,t){return et?1:0}G.prototype={push:function(e){this.data.push(e),this.length++,this._up(this.length-1)},pop:function(){if(0!==this.length){var e=this.data[0];return this.length--,this.length>0&&(this.data[0]=this.data[this.length],this._down(0)),this.data.pop(),e}},peek:function(){return this.data[0]},_up:function(e){for(var t=this.data,i=this.compare,r=t[e];e>0;){var n=e-1>>1,o=t[n];if(i(r,o)>=0)break;t[e]=o,e=n}t[e]=r},_down:function(e){for(var t=this.data,i=this.compare,r=this.length>>1,n=t[e];e=0)break;t[e]=a,e=o}t[e]=n}},V.default=j;var Q=Math.max,$=Math.min,Z=0;function W(e,t,i,r,n,o){var s,a,l,c,u,h;for(s=0,a=e.length-1;s0?h.left=!0:u.left=!0;var d=l[0],p=l[1];n[0]=$(n[0],d),n[1]=$(n[1],p),n[2]=Q(n[2],d),n[3]=Q(n[3],p),r.push(u),r.push(h)}}var q=[];function K(e,t,r){"number"==typeof e[0][0][0]&&(e=[e]),"number"==typeof t[0][0][0]&&(t=[t]);var n=function(e,t,i){var r=null;return e.length*t.length==0&&(i===u?r=q:i===d?r=e:i!==h&&i!==p||(r=0===e.length?t:e)),r}(e,t,r);if(n)return n===q?null:n;var o=[1/0,1/0,-1/0,-1/0],s=[1/0,1/0,-1/0,-1/0],a=function(e,t,i,r,n){var o,s,a,l,c,u,h=new V(null,L);for(a=0,l=e.length;ar[2]||r[0]>i[2]||i[1]>r[3]||r[1]>i[3])&&(n===u?o=q:n===d?o=e:n!==h&&n!==p||(o=e.concat(t))),o}(e,t,o,s,r))return n===q?null:n;for(var l=function(e){var t,i,r=function(e){var t,i,r,n,o=[];for(i=0,r=e.length;i0){var s=t[o];if(null!=s.holeOf){var a=s.holeOf;t[a].holeIds.push(i),r.holeOf=a,r.depth=t[o].depth}else t[o].holeIds.push(i),r.holeOf=o,r.depth=t[o].depth+1}else r.holeOf=null,r.depth=t[o].depth}else r.holeOf=null,r.depth=0;return r}(r[t],o,e),s=function(t){n[t]=!0,t=r.length)&&r[a];);o.push(i)}};for(t=0,i=r.length;tm||s===d&&g.point[0]>n[2])break;if(g.left){l=a=h.insert(g),a=a!==(c=h.minNode())?h.prev(a):null,l=h.next(l);var _=a?a.key:null;if(f(g,_,s),l&&2===O(g,l.key,e)&&(f(g,_,s),f(l.key,g,s)),a&&2===O(a.key,g,e)){var A=a;f(_,(A=A!==c?h.prev(A):null)?A.key:null,s),f(g,_,s)}}else l=a=h.find(g=g.otherEvent),a&&l&&(a=a!==c?h.prev(a):null,l=h.next(l),h.remove(g),l&&a&&O(a.key,l.key,e))}return p}(a,0,0,o,s,r)),c=[],m=0;mn.unsubscribe():n}(i,n))}function c(e,t,i,n){if(e){const r=u(e,t,i,n);return e[0](r)}}function u(e,t,n,r){return e[1]&&r?i(n.ctx.slice(),e[1](r(t))):n.ctx}function h(e,t,i,n){if(e[2]&&n){const r=e[2](n(i));if(void 0===t.dirty)return r;if("object"==typeof r){const e=[],i=Math.max(t.dirty.length,r.length);for(let n=0;n32){const t=[],i=e.ctx.length/32;for(let e=0;ee.removeEventListener(t,i,n)}function B(e,t,i){null==i?e.removeAttribute(t):e.getAttribute(t)!==i&&e.setAttribute(t,i)}function I(e){return""===e?null:+e}function M(e,t){t=""+t,e.data!==t&&(e.data=t)}function P(e,t){e.value=null==t?"":t}function R(e,t,i,n){null==i?e.style.removeProperty(t):e.style.setProperty(t,i,n?"important":"")}function F(e,t,i){for(let i=0;i{const r=e.$$.callbacks[t];if(r){const o=function(e,t,{bubbles:i=!1,cancelable:n=!1}={}){const r=document.createEvent("CustomEvent");return r.initCustomEvent(e,i,n,t),r}(t,i,{cancelable:n});return r.slice().forEach(t=>{t.call(e,o)}),!o.defaultPrevented}return!0}}function Q(e,t){const i=e.$$.callbacks[t.type];i&&i.slice().forEach(e=>e.call(this,t))}const $=[],Z=[];let W=[];const q=[],K=Promise.resolve();let X=!1;function J(){X||(X=!0,K.then(ie))}function Y(e){W.push(e)}const ee=new Set;let te=0;function ie(){if(0!==te)return;const e=D;do{try{for(;te<$.length;){const e=$[te];te++,N(e),ne(e.$$)}}catch(e){throw $.length=0,te=0,e}for(N(null),$.length=0,te=0;Z.length;)Z.pop()();for(let e=0;e{re.delete(e),n&&(i&&e.d(1),n())}),e.o(t)}else n&&n()}function ue(e,t){const i={},n={},r={$$scope:1};let o=e.length;for(;o--;){const s=e[o],a=t[o];if(a){for(const e in s)e in a||(n[e]=1);for(const e in a)r[e]||(i[e]=a[e],r[e]=1);e[o]=a}else for(const e in s)r[e]=1}for(const e in n)e in i||(i[e]=void 0);return i}function he(e){return"object"==typeof e&&null!==e?e:{}}function de(e){e&&e.c()}function pe(e,t,i,r){const{fragment:a,after_update:l}=e.$$;a&&a.m(t,i),r||Y(()=>{const t=e.$$.on_mount.map(n).filter(s);e.$$.on_destroy?e.$$.on_destroy.push(...t):o(t),e.$$.on_mount=[]}),l.forEach(Y)}function fe(e,t){const i=e.$$;null!==i.fragment&&(!function(e){const t=[],i=[];W.forEach(n=>-1===e.indexOf(n)?t.push(n):i.push(n)),i.forEach(e=>e()),W=t}(i.after_update),o(i.on_destroy),i.fragment&&i.fragment.d(t),i.on_destroy=i.fragment=null,i.ctx=[])}function me(e,i,n,s,a,l,c,u=[-1]){const h=D;N(e);const d=e.$$={fragment:null,ctx:[],props:l,update:t,not_equal:a,bound:r(),on_mount:[],on_destroy:[],on_disconnect:[],before_update:[],after_update:[],context:new Map(i.context||(h?h.$$.context:[])),callbacks:r(),dirty:u,skip_bound:!1,root:i.target||h.$$.root};c&&c(d.root);let p=!1;if(d.ctx=n?n(e,i.props||{},(t,i,...n)=>{const r=n.length?n[0]:i;return d.ctx&&a(d.ctx[t],d.ctx[t]=r)&&(!d.skip_bound&&d.bound[t]&&d.bound[t](r),p&&function(e,t){-1===e.$$.dirty[0]&&($.push(e),J(),e.$$.dirty.fill(0)),e.$$.dirty[t/31|0]|=1<{const e=n.indexOf(i);-1!==e&&n.splice(e,1)}}$set(e){var t;this.$$set&&(t=e,0!==Object.keys(t).length)&&(this.$$.skip_bound=!0,this.$$set(e),this.$$.skip_bound=!1)}}const _e="[object RegExp]",Ae="[object String]",ye="[object Number]",ve="[object Boolean]",xe="[object Arguments]",be="[object Symbol]",we="[object Date]",Te="[object Map]",Ee="[object Set]",Ce="[object Array]",Se="[object ArrayBuffer]",Be="[object Object]",Ie="[object DataView]",Me="[object Uint8Array]",Pe="[object Uint8ClampedArray]",Re="[object Uint16Array]",Le="[object Uint32Array]",Fe="[object Int8Array]",ke="[object Int16Array]",De="[object Int32Array]",Oe="[object Float32Array]",ze="[object Float64Array]";function Ue(e,t,i,n=new Map,r=void 0){const o=r?.(e,t,i,n);if(void 0!==o)return o;if(null==(s=e)||"object"!=typeof s&&"function"!=typeof s)return e;var s;if(n.has(e))return n.get(e);if(Array.isArray(e)){const t=new Array(e.length);n.set(e,t);for(let o=0;oObject.prototype.propertyIsEnumerable.call(s,e)))];var s;for(let s=0;s{const s=t?.(i,n,r,o);if(void 0!==s)return s;if("object"==typeof e)switch(Object.prototype.toString.call(e)){case ye:case Ae:case ve:{const t=new e.constructor(e?.valueOf());return Ne(t,e),t}case xe:{const t={};return Ne(t,e),t.length=e.length,t[Symbol.iterator]=e[Symbol.iterator],t}default:return}})}function je(e){return Ve(e)}var Ge="undefined"!=typeof globalThis?globalThis:"undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:{};function He(e){return e&&e.__esModule&&Object.prototype.hasOwnProperty.call(e,"default")?e.default:e}function Qe(e){if(e.__esModule)return e;var t=Object.defineProperty({},"__esModule",{value:!0});return Object.keys(e).forEach(function(i){var n=Object.getOwnPropertyDescriptor(e,i);Object.defineProperty(t,i,n.get?n:{enumerable:!0,get:function(){return e[i]}})}),t}var $e={exports:{}};$e.exports=function(){var e,t,i;function n(n,r){if(e)if(t){var o="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 = {}; ("+e+")(sharedChunk); ("+t+")(sharedChunk); self.onerror = null;",s={};e(s),i=r(s),"undefined"!=typeof window&&window&&window.URL&&window.URL.createObjectURL&&(i.workerUrl=window.URL.createObjectURL(new Blob([o],{type:"text/javascript"})))}else t=r;else e=r}n(["exports"],function(e){var t=1e-6,i="undefined"!=typeof Float32Array?Float32Array:Array;function n(e,t){var i=t[0],n=t[1],r=t[2],o=t[3],s=i*o-r*n;return s?(e[0]=o*(s=1/s),e[1]=-n*s,e[2]=-r*s,e[3]=i*s,e):null}function r(){var e=new i(9);return i!=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 o(e,t){var i=t[0],n=t[1],r=t[2],o=t[3],s=t[4],a=t[5],l=t[6],c=t[7],u=t[8];return e[0]=s*u-a*c,e[1]=r*c-n*u,e[2]=n*a-r*s,e[3]=a*l-o*u,e[4]=i*u-r*l,e[5]=r*o-i*a,e[6]=o*c-s*l,e[7]=n*l-i*c,e[8]=i*s-n*o,e}function s(e,t,i){var n=t[0],r=t[1],o=t[2],s=t[3],a=t[4],l=t[5],c=t[6],u=t[7],h=t[8],d=i[0],p=i[1],f=i[2],m=i[3],g=i[4],_=i[5],A=i[6],y=i[7],v=i[8];return e[0]=d*n+p*s+f*c,e[1]=d*r+p*a+f*u,e[2]=d*o+p*l+f*h,e[3]=m*n+g*s+_*c,e[4]=m*r+g*a+_*u,e[5]=m*o+g*l+_*h,e[6]=A*n+y*s+v*c,e[7]=A*r+y*a+v*u,e[8]=A*o+y*l+v*h,e}function a(){var e=new i(16);return i!=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 l(e){var t=new i(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 c(e){return e[0]=1,e[1]=0,e[2]=0,e[3]=0,e[4]=0,e[5]=1,e[6]=0,e[7]=0,e[8]=0,e[9]=0,e[10]=1,e[11]=0,e[12]=0,e[13]=0,e[14]=0,e[15]=1,e}function u(e,t){var i=t[0],n=t[1],r=t[2],o=t[3],s=t[4],a=t[5],l=t[6],c=t[7],u=t[8],h=t[9],d=t[10],p=t[11],f=t[12],m=t[13],g=t[14],_=t[15],A=i*a-n*s,y=i*l-r*s,v=i*c-o*s,x=n*l-r*a,b=n*c-o*a,w=r*c-o*l,T=u*m-h*f,E=u*g-d*f,C=u*_-p*f,S=h*g-d*m,B=h*_-p*m,I=d*_-p*g,M=A*I-y*B+v*S+x*C-b*E+w*T;return M?(e[0]=(a*I-l*B+c*S)*(M=1/M),e[1]=(r*B-n*I-o*S)*M,e[2]=(m*w-g*b+_*x)*M,e[3]=(d*b-h*w-p*x)*M,e[4]=(l*C-s*I-c*E)*M,e[5]=(i*I-r*C+o*E)*M,e[6]=(g*v-f*w-_*y)*M,e[7]=(u*w-d*v+p*y)*M,e[8]=(s*B-a*C+c*T)*M,e[9]=(n*C-i*B-o*T)*M,e[10]=(f*b-m*v+_*A)*M,e[11]=(h*v-u*b-p*A)*M,e[12]=(a*E-s*S-l*T)*M,e[13]=(i*S-n*E+r*T)*M,e[14]=(m*y-f*x-g*A)*M,e[15]=(u*x-h*y+d*A)*M,e):null}function h(e,t,i){var n=t[0],r=t[1],o=t[2],s=t[3],a=t[4],l=t[5],c=t[6],u=t[7],h=t[8],d=t[9],p=t[10],f=t[11],m=t[12],g=t[13],_=t[14],A=t[15],y=i[0],v=i[1],x=i[2],b=i[3];return e[0]=y*n+v*a+x*h+b*m,e[1]=y*r+v*l+x*d+b*g,e[2]=y*o+v*c+x*p+b*_,e[3]=y*s+v*u+x*f+b*A,e[4]=(y=i[4])*n+(v=i[5])*a+(x=i[6])*h+(b=i[7])*m,e[5]=y*r+v*l+x*d+b*g,e[6]=y*o+v*c+x*p+b*_,e[7]=y*s+v*u+x*f+b*A,e[8]=(y=i[8])*n+(v=i[9])*a+(x=i[10])*h+(b=i[11])*m,e[9]=y*r+v*l+x*d+b*g,e[10]=y*o+v*c+x*p+b*_,e[11]=y*s+v*u+x*f+b*A,e[12]=(y=i[12])*n+(v=i[13])*a+(x=i[14])*h+(b=i[15])*m,e[13]=y*r+v*l+x*d+b*g,e[14]=y*o+v*c+x*p+b*_,e[15]=y*s+v*u+x*f+b*A,e}function d(e,t,i){var n,r,o,s,a,l,c,u,h,d,p,f,m=i[0],g=i[1],_=i[2];return t===e?(e[12]=t[0]*m+t[4]*g+t[8]*_+t[12],e[13]=t[1]*m+t[5]*g+t[9]*_+t[13],e[14]=t[2]*m+t[6]*g+t[10]*_+t[14],e[15]=t[3]*m+t[7]*g+t[11]*_+t[15]):(r=t[1],o=t[2],s=t[3],a=t[4],l=t[5],c=t[6],u=t[7],h=t[8],d=t[9],p=t[10],f=t[11],e[0]=n=t[0],e[1]=r,e[2]=o,e[3]=s,e[4]=a,e[5]=l,e[6]=c,e[7]=u,e[8]=h,e[9]=d,e[10]=p,e[11]=f,e[12]=n*m+a*g+h*_+t[12],e[13]=r*m+l*g+d*_+t[13],e[14]=o*m+c*g+p*_+t[14],e[15]=s*m+u*g+f*_+t[15]),e}function p(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 f(e,t,i){var n=Math.sin(i),r=Math.cos(i),o=t[4],s=t[5],a=t[6],l=t[7],c=t[8],u=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+c*n,e[5]=s*r+u*n,e[6]=a*r+h*n,e[7]=l*r+d*n,e[8]=c*r-o*n,e[9]=u*r-s*n,e[10]=h*r-a*n,e[11]=d*r-l*n,e}function m(e,t,i){var n=Math.sin(i),r=Math.cos(i),o=t[0],s=t[1],a=t[2],l=t[3],c=t[8],u=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-c*n,e[1]=s*r-u*n,e[2]=a*r-h*n,e[3]=l*r-d*n,e[8]=o*n+c*r,e[9]=s*n+u*r,e[10]=a*n+h*r,e[11]=l*n+d*r,e}function g(e,t,i){var n=Math.sin(i),r=Math.cos(i),o=t[0],s=t[1],a=t[2],l=t[3],c=t[4],u=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+c*n,e[1]=s*r+u*n,e[2]=a*r+h*n,e[3]=l*r+d*n,e[4]=c*r-o*n,e[5]=u*r-s*n,e[6]=h*r-a*n,e[7]=d*r-l*n,e}function _(e,t){return e[0]=t[0],e[1]=0,e[2]=0,e[3]=0,e[4]=0,e[5]=t[1],e[6]=0,e[7]=0,e[8]=0,e[9]=0,e[10]=t[2],e[11]=0,e[12]=0,e[13]=0,e[14]=0,e[15]=1,e}function A(e,i,n){var r,o,s,a=n[0],l=n[1],c=n[2],u=Math.sqrt(a*a+l*l+c*c);return u0&&(o=1/Math.sqrt(o)),e[0]=t[0]*o,e[1]=t[1]*o,e[2]=t[2]*o,e}function U(e,t){return e[0]*t[0]+e[1]*t[1]+e[2]*t[2]}function N(e,t,i){var n=t[0],r=t[1],o=t[2],s=i[0],a=i[1],l=i[2];return e[0]=r*l-o*a,e[1]=o*s-n*l,e[2]=n*a-r*s,e}function V(e,t,i,n){var r=t[0],o=t[1],s=t[2];return e[0]=r+n*(i[0]-r),e[1]=o+n*(i[1]-o),e[2]=s+n*(i[2]-s),e}function j(e,t,i){var n=t[0],r=t[1],o=t[2],s=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])/(s=s||1),e[1]=(i[1]*n+i[5]*r+i[9]*o+i[13])/s,e[2]=(i[2]*n+i[6]*r+i[10]*o+i[14])/s,e}function G(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 H(e,t,i){var n=i[0],r=i[1],o=i[2],s=i[3],a=t[0],l=t[1],c=t[2],u=r*c-o*l,h=o*a-n*c,d=n*l-r*a;return e[0]=a+s*(u+=u)+r*(d+=d)-o*(h+=h),e[1]=l+s*h+o*u-n*d,e[2]=c+s*d+n*h-r*u,e}function Q(e){return e[0]=0,e[1]=0,e[2]=0,e}function $(e,t){return e[0]===t[0]&&e[1]===t[1]&&e[2]===t[2]}var Z=B,W=I,q=T;function K(){var e=new i(4);return i!=Float32Array&&(e[0]=0,e[1]=0,e[2]=0,e[3]=0),e}function X(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 J(e,t){var i=t[0],n=t[1],r=t[2],o=t[3],s=i*i+n*n+r*r+o*o;return s>0&&(s=1/Math.sqrt(s)),e[0]=i*s,e[1]=n*s,e[2]=r*s,e[3]=o*s,e}function Y(e,t,i){var n=t[0],r=t[1],o=t[2],s=t[3];return e[0]=i[0]*n+i[4]*r+i[8]*o+i[12]*s,e[1]=i[1]*n+i[5]*r+i[9]*o+i[13]*s,e[2]=i[2]*n+i[6]*r+i[10]*o+i[14]*s,e[3]=i[3]*n+i[7]*r+i[11]*o+i[15]*s,e}function ee(){var e=new i(4);return i!=Float32Array&&(e[0]=0,e[1]=0,e[2]=0),e[3]=1,e}function te(e){return e[0]=0,e[1]=0,e[2]=0,e[3]=1,e}function ie(e,t,i){i*=.5;var n=t[0],r=t[1],o=t[2],s=t[3],a=Math.sin(i),l=Math.cos(i);return e[0]=n*l+s*a,e[1]=r*l+o*a,e[2]=o*l-r*a,e[3]=s*l-n*a,e}function ne(e,t,i){i*=.5;var n=t[0],r=t[1],o=t[2],s=t[3],a=Math.sin(i),l=Math.cos(i);return e[0]=n*l-o*a,e[1]=r*l+s*a,e[2]=o*l+n*a,e[3]=s*l-r*a,e}b(),K();var re,oe,se,ae=J,le=(re=b(),oe=E(1,0,0),se=E(0,1,0),function(e,t,i){var n=U(t,i);return n<-.999999?(N(re,oe,t),q(re)<1e-6&&N(re,se,t),z(re,re),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,re,Math.PI),e):n>.999999?(e[0]=0,e[1]=0,e[2]=0,e[3]=1,e):(N(re,t,i),e[0]=re[0],e[1]=re[1],e[2]=re[2],e[3]=1+n,ae(e,e))});function ce(){var e=new i(2);return i!=Float32Array&&(e[0]=0,e[1]=0),e}function ue(e,t){var n=new i(2);return n[0]=e,n[1]=t,n}function he(e,t,i){return e[0]=t,e[1]=i,e}function de(e,t,i){return e[0]=t[0]+i[0],e[1]=t[1]+i[1],e}function pe(e,t,i){return e[0]=t[0]-i[0],e[1]=t[1]-i[1],e}function fe(e,t,i){return e[0]=t[0]*i,e[1]=t[1]*i,e}function me(e){var t=e[0],i=e[1];return Math.sqrt(t*t+i*i)}function ge(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 _e(e,t){return e[0]*t[0]+e[1]*t[1]}ee(),ee(),r();var Ae,ye,ve=pe;function xe(e){return e&&e.__esModule&&Object.prototype.hasOwnProperty.call(e,"default")?e.default:e}ce();var be=function(){if(ye)return Ae;function e(e,t,i,n){this.cx=3*e,this.bx=3*(i-e)-this.cx,this.ax=1-this.cx-this.bx,this.cy=3*t,this.by=3*(n-t)-this.cy,this.ay=1-this.cy-this.by,this.p1x=e,this.p1y=t,this.p2x=i,this.p2y=n}return ye=1,Ae=e,e.prototype={sampleCurveX:function(e){return((this.ax*e+this.bx)*e+this.cx)*e},sampleCurveY:function(e){return((this.ay*e+this.by)*e+this.cy)*e},sampleCurveDerivativeX:function(e){return(3*this.ax*e+2*this.bx)*e+this.cx},solveCurveX:function(e,t){if(void 0===t&&(t=1e-6),e<0)return 0;if(e>1)return 1;for(var i=e,n=0;n<8;n++){var r=this.sampleCurveX(i)-e;if(Math.abs(r)r?s=i:a=i,i=.5*(a-s)+s;return i},solve:function(e,t){return this.sampleCurveY(this.solveCurveX(e,t))}},Ae}(),we=xe(be);function Te(e,t){this.x=e,this.y=t}function Ee(e,t){if(Array.isArray(e)){if(!Array.isArray(t)||e.length!==t.length)return!1;for(let i=0;i=1)return 1;const t=e*e,i=t*e;return 4*(e<.5?i:3*(e-t)+i-.75)}function Re(e,t,i,n){const r=new we(e,t,i,n);return function(e){return r.solve(e)}}const Le=Re(.25,.1,.25,1);function Fe(e,t,i){return Math.min(i,Math.max(t,e))}function ke(e,t,i){return(i=Fe((i-e)/(t-e),0,1))*i*(3-2*i)}function De(e,t,i){const n=i-t,r=((e-t)%n+n)%n+t;return r===t?i:r}function Oe(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,s)=>{t(e,(e,t)=>{e&&(o=e),r[s]=t,0==--n&&i(o,r)})})}let ze=1;function Ue(){return ze++}function Ne(e){return e<=1?1:Math.pow(2,Math.ceil(Math.log2(e)))}function Ve(e,t){e.forEach(e=>{t[e]&&(t[e]=t[e].bind(t))})}function je(e,t,i){const n={};for(const i in e)n[i]=t.call(this,e[i],i,e);return n}function Ge(e,t,i){const n={};for(const i in e)t.call(this,e[i],i,e)&&(n[i]=e[i]);return n}function He(e){return Array.isArray(e)?e.map(He):"object"==typeof e&&e?je(e,He):e}function Qe(e,t){for(let i=0;i=0)return!0;return!1}const $e={};function Ze(e){$e[e]||("undefined"!=typeof console&&console.warn(e),$e[e]=!0)}function We(e,t,i){return(i.y-e.y)*(t.x-e.x)>(t.y-e.y)*(i.x-e.x)}function qe(e){let t=0;for(let i,n,r=0,o=e.length,s=o-1;r@\,;\:\\"\/\[\]\?\=\{\}\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}let Ye=null;function et(e,t){return[e[4*t],e[4*t+1],e[4*t+2],e[4*t+3]]}function tt(e,t,i,n){for(;t>1;e[r]>1;e[r]<=n?t=r+1:i=r}return t}function nt(e){return e>0?1/(1.001-e):1+e}function rt(e){return e>0?1-1/(1.001-e):-e}function ot(e,t,i){return(e-t.min)*(i.max-i.min)/(t.max-t.min)+i.min}const st={API_URL:"https://api.mapbox.com",get API_URL_REGEX(){return/^((https?:)?\/\/)?([^\/]+\.)?mapbox\.c(n|om)(\/|\?|$)/i},get API_TILEJSON_REGEX(){return/^((https?:)?\/\/)?([^\/]+\.)?mapbox\.c(n|om)(\/v[0-9]*\/.*\.json.*$)/i},get API_SPRITE_REGEX(){return/^((https?:)?\/\/)?([^\/]+\.)?mapbox\.c(n|om)(\/styles\/v[0-9]*\/)(.*\/sprite.*\..*$)/i},get API_FONTS_REGEX(){return/^((https?:)?\/\/)?([^\/]+\.)?mapbox\.c(n|om)(\/fonts\/v[0-9]*\/)(.*\.pbf.*$)/i},get API_STYLE_REGEX(){return/^((https?:)?\/\/)?([^\/]+\.)?mapbox\.c(n|om)(\/styles\/v[0-9]*\/)(.*$)/i},get API_CDN_URL_REGEX(){return/^((https?:)?\/\/)?api\.mapbox\.c(n|om)(\/mapbox-gl-js\/)(.*$)/i},get EVENTS_URL(){if(!st.API_URL)return null;try{const e=new URL(st.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:"https://api.mapbox.com/mapbox-gl-js/draco_decoder_gltf_v1.5.6.wasm",MESHOPT_URL:"https://api.mapbox.com/mapbox-gl-js/meshopt_base_v0.20.wasm",MESHOPT_SIMD_URL:"https://api.mapbox.com/mapbox-gl-js/meshopt_simd_v0.20.wasm",BUILDING_GEN_URL:"https://api.mapbox.com/mapbox-gl-js/building-gen/building_gen_v1.2.3.wasm",GLYPHS_URL:"mapbox://fonts/mapbox/{fontstack}/{range}.pbf",TILES3D_URL_PREFIX:"3dtiles/v1"};function at(e){return st.API_URL_REGEX.test(e)}function lt(e){return st.API_SPRITE_REGEX.test(e)}let ct,ut,ht,dt,pt,ft;function mt(){return null==ct&&(ct=self.OffscreenCanvas&&new OffscreenCanvas(1,1).getContext("2d")&&"function"==typeof self.createImageBitmap),ct}const gt={now:()=>void 0!==dt?dt:performance.now(),setNow(e){dt=e},restoreNow(){dt=void 0},frame(e){const t=requestAnimationFrame(e);return{cancel:()=>cancelAnimationFrame(t)}},getImageData(e,t=0){const{width:i,height:n}=e;pt||(pt=document.createElement("canvas"));const r=pt.getContext("2d",{willReadFrequently:!0});if(!r)throw new Error("failed to create canvas 2d context");return(i>pt.width||n>pt.height)&&(pt.width=i,pt.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=>(ut||(ut=document.createElement("a")),ut.href=e,ut.href),get devicePixelRatio(){return window.devicePixelRatio},get prefersReducedMotion(){return!!window.matchMedia&&(null==ht&&(ht=window.matchMedia("(prefers-reduced-motion: reduce)")),ht.matches)},hasCanvasFingerprintNoise(){if(void 0!==ft)return ft;if(!mt())return ft=!1,!1;const e=new OffscreenCanvas(85,1),t=e.getContext("2d",{willReadFrequently:!0});let i=0;for(let n=0;n0?`?${o}`:""}`}const yt="mapbox-tiles";let vt=500,xt=50;const bt=["language","worldview","jobid"];let wt,Tt;function Et(){try{return caches}catch(e){}}function Ct(){const e=Et();e&&null==wt&&(wt=e.open(yt))}let St=1/0;const Bt={supported:!1,testSupport:function(e){!Pt&&Mt&&(Rt?Ft(e):It=e)}};let It,Mt,Pt=!1,Rt=!1;const Lt="undefined"!=typeof self?self:{};function Ft(e){const t=e.createTexture();e.bindTexture(e.TEXTURE_2D,t);try{if(e.texImage2D(e.TEXTURE_2D,0,e.RGBA,e.RGBA,e.UNSIGNED_BYTE,Mt),e.isContextLost())return;Bt.supported=!0}catch(e){}e.deleteTexture(t),Pt=!0}Lt.document&&(Mt=Lt.document.createElement("img"),Mt.onload=function(){It&&Ft(It),It=null,Rt=!0},Mt.onerror=function(){Pt=!0,It=null},Mt.src="data:image/webp;base64,UklGRh4AAABXRUJQVlA4TBEAAAAvAQAAAAfQ//73v/+BiOh/AAA=");const kt={Unknown:"Unknown",Style:"Style",Source:"Source",Tile:"Tile",Glyphs:"Glyphs",SpriteImage:"SpriteImage",SpriteJSON:"SpriteJSON",Iconset:"Iconset",Image:"Image",Model:"Model"};"function"==typeof Object.freeze&&Object.freeze(kt);class Dt extends Error{constructor(e,t,i){401===t&&at(i)&&(e+=": you may have provided an invalid Mapbox access token. See https://docs.mapbox.com/api/overview/#access-tokens-and-token-scopes"),super(e),this.status=t,this.url=i}toString(){return`${this.name}: ${this.message} (${this.status}): ${this.url}`}}const Ot=Xe()?()=>self.worker.referrer:()=>("blob:"===location.protocol?parent:self).location.href,zt=function(e,t){if(!(/^file:/.test(i=e.url)||/^file:/.test(Ot())&&!/^\w+:/.test(i))){if(self.fetch&&self.Request&&self.AbortController&&Request.prototype.hasOwnProperty("signal"))return function(e,t){const i=new AbortController,n=new Request(e.url,{method:e.method||"GET",body:e.body,credentials:e.credentials,headers:e.headers,referrer:Ot(),referrerPolicy:e.referrerPolicy,signal:i.signal});let r=!1,o=!1;const s=(a=n.url).indexOf("sku=")>0&&at(a);var a;"json"===e.type&&n.headers.set("Accept","application/json");const l=(i,r,a)=>{if(o)return;if(i&&"SecurityError"!==i.message&&Ze(i.toString()),r&&a)return c(r);const l=Date.now();fetch(n).then(i=>{if(i.ok){const e=s?i.clone():null;return c(i,e,l)}return t(new Dt(i.statusText,i.status,e.url))}).catch(i=>{"AbortError"!==i.name&&t(new Error(`${i.message} ${e.url}`))})},c=(i,s,a)=>{("arrayBuffer"===e.type?i.arrayBuffer():"json"===e.type?i.json():i.text()).then(e=>{o||(s&&a&&function(e,t,i){if(Ct(),null==wt)return;const n=Je(t.headers.get("Cache-Control")||"");if(n["no-store"])return;const r={status:t.status,statusText:t.statusText,headers:new Headers};t.headers.forEach((e,t)=>r.headers.set(t,e)),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 s=At(e.url,{persistentParams:bt});if(206===t.status){const t=e.headers.get("Range");if(!t)return;r.status=200,s=_t(s,{range:t})}!function(e,t){if(void 0===Tt)try{new Response(new ReadableStream),Tt=!0}catch(e){Tt=!1}Tt?t(e.body):e.blob().then(t).catch(e=>Ze(e.message))}(t,e=>{const i=new Response(200!==(n=t.status)&&404!==n&&[101,103,204,205,304].includes(n)?null:e,r);var n;Ct(),null!=wt&&wt.then(e=>e.put(s,i)).catch(e=>Ze(e.message))})}(n,s,a),r=!0,t(null,e,i.headers))}).catch(e=>{o||t(new Error(e.message))})};return s?function(e,t){if(Ct(),null==wt)return t(null);wt.then(i=>{let n=At(e.url,{persistentParams:bt});const r=e.headers.get("Range");r&&(n=_t(n,{range:r})),i.match(n).then(e=>{const r=function(e){if(!e)return!1;const t=new Date(e.headers.get("Expires")||0),i=Je(e.headers.get("Cache-Control")||"");return Number(t)>Date.now()&&!i["no-cache"]}(e);i.delete(n).catch(t),r&&i.put(n,e.clone()).catch(t),t(null,e,r)}).catch(t)}).catch(t)}(n,l):l(null,null),{cancel:()=>{o=!0,r||i.abort()}}}(e,t);if(Xe(self)&&self.worker.actor)return self.worker.actor.send("getResource",e,t,void 0,!0)}var i;return function(e,t){const i=new XMLHttpRequest;i.open(e.method||"GET",e.url,!0),"arrayBuffer"===e.type&&(i.responseType="arraybuffer");for(const t in e.headers)i.setRequestHeader(t,e.headers[t]);return"json"===e.type&&(i.responseType="text",i.setRequestHeader("Accept","application/json")),i.withCredentials="include"===e.credentials,i.onerror=()=>{t(new Error(i.statusText))},i.onload=()=>{if((i.status>=200&&i.status<300||0===i.status)&&null!==i.response){let n=i.response;if("json"===e.type)try{n=JSON.parse(i.response)}catch(e){return t(e)}const r=new Headers;i.getAllResponseHeaders().trim().split(/[\r\n]+/).forEach(e=>{const t=e.split(": "),i=t.shift(),n=t.join(": ");r.append(i,n)}),t(null,n,r)}else t(new Dt(i.statusText,i.status,e.url))},i.send(e.body),{cancel:()=>i.abort()}}(e,t)},Ut=function(e,t){return zt(Object.assign(e,{type:"arrayBuffer"}),t)};function Nt(e){const t=document.createElement("a");return t.href=e,t.protocol===location.protocol&&t.host===location.host}const Vt="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAYAAAAfFcSJAAAAC0lEQVQYV2NgAAIAAAUAAarVyFEAAAAASUVORK5CYII=";let jt,Gt;jt=[],Gt=0;const Ht=function(e,t){if(Bt.supported&&(e.headers||(e.headers={}),e.headers.accept="image/webp,*/*"),Gt>=st.MAX_PARALLEL_IMAGE_REQUESTS){const i={requestParameters:e,callback:t,cancelled:!1,cancel(){this.cancelled=!0}};return jt.push(i),i}Gt++;let i=!1;const n=()=>{if(!i)for(i=!0,Gt--;jt.length&&Gt{n(),e?t(e):i&&(self.createImageBitmap?function(e,t){const i=new Blob([new Uint8Array(e)],{type:"image/png"});createImageBitmap(i).then(e=>{t(null,e)}).catch(e=>{t(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.`))})}(i,(e,i)=>t(e,i,r)):function(e,t){const i=new Image;i.onload=()=>{t(null,i),URL.revokeObjectURL(i.src),i.onload=null,requestAnimationFrame(()=>{i.src=Vt})},i.onerror=()=>t(new Error("Could not load image. Please make sure to use a supported image type such as PNG or JPEG. Note that SVGs are not supported."));const n=new Blob([new Uint8Array(e)],{type:"image/png"});i.src=e.byteLength?URL.createObjectURL(n):Vt}(i,(e,i)=>t(e,i,r)))});return{cancel:()=>{r.cancel(),n()}}};var Qt,$t,Zt,Wt={exports:{}},qt={exports:{}},Kt={exports:{}},Xt=function(){if(Zt)return Wt.exports;Zt=1;var e=(Qt||(Qt=1,qt.exports=function(e,t){var i,n,r,o,s,a,l,c;for(n=e.length-(i=3&e.length),r=t,s=3432918353,a=461845907,c=0;c>>16)*s&65535)<<16)&4294967295)<<15|l>>>17))*a+(((l>>>16)*a&65535)<<16)&4294967295)<<13|r>>>19))+((5*(r>>>16)&65535)<<16)&4294967295))+((58964+(o>>>16)&65535)<<16);switch(l=0,i){case 3:l^=(255&e.charCodeAt(c+2))<<16;case 2:l^=(255&e.charCodeAt(c+1))<<8;case 1:r^=l=(65535&(l=(l=(65535&(l^=255&e.charCodeAt(c)))*s+(((l>>>16)*s&65535)<<16)&4294967295)<<15|l>>>17))*a+(((l>>>16)*a&65535)<<16)&4294967295}return r^=e.length,r=2246822507*(65535&(r^=r>>>16))+((2246822507*(r>>>16)&65535)<<16)&4294967295,r=3266489909*(65535&(r^=r>>>13))+((3266489909*(r>>>16)&65535)<<16)&4294967295,(r^=r>>>16)>>>0}),qt.exports),t=($t||($t=1,Kt.exports=function(e,t){for(var i,n=e.length,r=t^n,o=0;n>=4;)i=1540483477*(65535&(i=255&e.charCodeAt(o)|(255&e.charCodeAt(++o))<<8|(255&e.charCodeAt(++o))<<16|(255&e.charCodeAt(++o))<<24))+((1540483477*(i>>>16)&65535)<<16),r=1540483477*(65535&r)+((1540483477*(r>>>16)&65535)<<16)^(i=1540483477*(65535&(i^=i>>>24))+((1540483477*(i>>>16)&65535)<<16)),n-=4,++o;switch(n){case 3:r^=(255&e.charCodeAt(o+2))<<16;case 2:r^=(255&e.charCodeAt(o+1))<<8;case 1:r=1540483477*(65535&(r^=255&e.charCodeAt(o)))+((1540483477*(r>>>16)&65535)<<16)}return r=1540483477*(65535&(r^=r>>>13))+((1540483477*(r>>>16)&65535)<<16),(r^=r>>>15)>>>0}),Kt.exports);return Wt.exports=e,Wt.exports.murmur3=e,Wt.exports.murmur2=t,Wt.exports}(),Jt=xe(Xt);class Yt{constructor(e,...t){Object.assign(this,t[0]||{}),this.type=e}}class ei extends Yt{constructor(e,t={}){super("error",Object.assign({error:e},t))}}function ti(e,t,i){i[e]&&-1!==i[e].indexOf(t)||(i[e]=i[e]||[],i[e].push(t))}function ii(e,t,i){if(i&&i[e]){const n=i[e].indexOf(t);-1!==n&&i[e].splice(n,1)}}class ni{on(e,t){return this._listeners=this._listeners||{},ti(e,t,this._listeners),this}off(e,t){return ii(e,t,this._listeners),ii(e,t,this._oneTimeListeners),this}once(e,t){return t?(this._oneTimeListeners=this._oneTimeListeners||{},ti(e,t,this._oneTimeListeners),this):new Promise(t=>{this.once(e,t)})}fire(e,t){const i="string"==typeof e?new Yt(e,t):e,n=i.type;if(this.listens(n)){i.target=this;const e=this._listeners&&this._listeners[n]?this._listeners[n].slice():[];for(const t of e)t.call(this,i);const t=this._oneTimeListeners&&this._oneTimeListeners[n]?this._oneTimeListeners[n].slice():[];for(const e of t)ii(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 ei&&console.error(i.error);return this}listens(e){return!!(this._listeners&&this._listeners[e]&&this._listeners[e].length>0||this._oneTimeListeners&&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 ri{constructor(e){"string"==typeof e?this.name=e:(this.name=e.name,this.iconsetId=e.iconsetId)}static from(e){return new ri(e)}static toString(e){return e.iconsetId?`${e.name}${e.iconsetId}`:e.name}static parse(e){const[t,i]=e.split("");return new ri({name:t,iconsetId:i})}static isEqual(e,t){return e.name===t.name&&e.iconsetId===t.iconsetId}toString(){return ri.toString(this)}serialize(){return{name:this.name,iconsetId:this.iconsetId}}}var oi,si={},ai=function(){if(oi)return si;oi=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{si.parseCSSColor=function(o){var s,a=o.replace(/ /g,"").toLowerCase();if(a in e)return e[a].slice();if("#"===a[0])return 4===a.length?(s=parseInt(a.substr(1),16))>=0&&s<=4095?[(3840&s)>>4|(3840&s)>>8,240&s|(240&s)>>4,15&s|(15&s)<<4,1]:null:7===a.length&&(s=parseInt(a.substr(1),16))>=0&&s<=16777215?[(16711680&s)>>16,(65280&s)>>8,255&s,1]:null;var l=a.indexOf("("),c=a.indexOf(")");if(-1!==l&&c+1===a.length){var u=a.substr(0,l),h=a.substr(l+1,c-(l+1)).split(","),d=1;switch(u){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 p=(parseFloat(h[0])%360+360)%360/360,f=n(h[1]),m=n(h[2]),g=m<=.5?m*(f+1):m+f-m*f,_=2*m-g;return[t(255*r(_,g,p+1/3)),t(255*r(_,g,p)),t(255*r(_,g,p-1/3)),d];default:return null}}return null}}catch(e){}return si}();class li{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 li)return e;if("string"!=typeof e)return;const t=ai.parseCSSColor(e);return t?new li(t[0]/255,t[1]/255,t[2]/255,t[3]):void 0}toString(){const[e,t,i,n]=[this.r,this.g,this.b,this.a];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 ui(e,t,i,n,r)}toPremultipliedRenderColor(e){const{r:t,g:i,b:n,a:r}=this;return new hi(e,t*r,i*r,n*r,r)}clone(){return new li(this.r,this.g,this.b,this.a)}}class ci{constructor(e,t,i,n,r,o=!1){if(this.premultiplied=!1,this.premultiplied=o,e){const o=e.image.height,s=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);const a=Math.floor(t),l=Math.floor(i),c=Math.floor(n),u=Math.ceil(t),h=Math.ceil(i),d=Math.ceil(n),p=t-a,f=i-l,m=n-c,g=e.image.data,_=4*(a+l*s+c*o),A=4*(a+l*s+d*o),y=4*(a+h*s+c*o),v=4*(a+h*s+d*o),x=4*(u+l*s+c*o),b=4*(u+l*s+d*o),w=4*(u+h*s+c*o),T=4*(u+h*s+d*o);if(_<0||T>=g.length)throw new Error("out of range");this.r=di(di(di(g[_],g[A],m),di(g[y],g[v],m),f),di(di(g[x],g[b],m),di(g[w],g[T],m),f),p)/255*(this.premultiplied?r:1),this.g=di(di(di(g[_+1],g[A+1],m),di(g[y+1],g[v+1],m),f),di(di(g[x+1],g[b+1],m),di(g[w+1],g[T+1],m),f),p)/255*(this.premultiplied?r:1),this.b=di(di(di(g[_+2],g[A+2],m),di(g[y+2],g[v+2],m),f),di(di(g[x+2],g[b+2],m),di(g[w+2],g[T+2],m),f),p)/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),s=Math.min(Math.max(i,0),1),a=Math.min(r,o,s),l=Math.max(r,o,s),c=l-a,u=.5*(a+l);if(0===c)return[0,0,100*u,n];const h=u>.5?c/(2-l-a):c/(l+a);let d;switch(l){case r:d=60*((o-s)/c+(odi(e,t[n],i))}li.black=new li(0,0,0,1),li.white=new li(1,1,1,1),li.transparent=new li(0,0,0,0),li.red=new li(1,0,0,1),li.blue=new li(0,0,1,1);var fi=Object.freeze({__proto__:null,array:pi,color:function(e,t,i){return new li(di(e.r,t.r,i),di(e.g,t.g,i),di(e.b,t.b,i),di(e.a,t.a,i))},number:di});class mi extends Error{constructor(e,t){super(t),this.message=t,this.key=e}}class gi{constructor(e,t=[]){this.parent=e,this.bindings={};for(const[e,i]of t)this.bindings[e]=i}concat(e){return new gi(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 _i={kind:"null"},Ai={kind:"number"},yi={kind:"string"},vi={kind:"boolean"},xi={kind:"color"},bi={kind:"object"},wi={kind:"value"},Ti={kind:"collator"},Ei={kind:"formatted"},Ci={kind:"resolvedImage"};function Si(e,t){return{kind:"array",itemType:e,N:t}}function Bi(e){if("array"===e.kind){const t=Bi(e.itemType);return"number"==typeof e.N?`array<${t}, ${e.N}>`:"value"===e.itemType.kind?"array":`array<${t}>`}return e.kind}const Ii=[_i,Ai,yi,vi,xi,Ei,bi,Si(wi),Ci];function Mi(e,t){if("error"===t.kind)return null;if("array"===e.kind){if("array"===t.kind&&(0===t.N&&"value"===t.itemType.kind||!Mi(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 Ii)if(!Mi(e,t))return null}return`Expected ${Bi(e)} but found ${Bi(t)} instead.`}function Pi(e,t){return t.some(t=>t.kind===e.kind)}function Ri(e,t){return t.some(t=>"null"===t?null===e:"array"===t?Array.isArray(e):"object"===t?e&&!Array.isArray(e)&&"object"==typeof e:t===typeof e)}function Li(e,t){return"array"===e.kind&&"array"===t.kind?e.N===t.N&&Li(e.itemType,t.itemType):e.kind===t.kind}class Fi{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 ki{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 Di{constructor(e){this.sections=e}static fromString(e){return new Di([new ki(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 Di?e:Di.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 Oi{constructor(e,t={}){if(this.id=ri.from(e),this.options=Object.assign({},t),t.transform){const{a:e,b:i,c:n,d:r,e:o,f:s}=t.transform;this.options.transform=new DOMMatrix([e,i,n,r,o,s])}else this.options.transform=new DOMMatrix([1,0,0,1,0,0])}toString(){const{a:e,b:t,c:i,d:n,e:r,f:o}=this.options.transform;return JSON.stringify({name:this.id.name,iconsetId:this.id.iconsetId,params:this.options.params,transform:{a:e,b:t,c:i,d:n,e:r,f:o}})}static parse(e){let t,i,n,r;try{({name:t,iconsetId:i,params:n,transform:r}=JSON.parse(e)||{})}catch(e){return null}if(!t)return null;const{a:o,b:s,c:a,d:l,e:c,f:u}=r||{};return new Oi({name:t,iconsetId:i},{params:n,transform:new DOMMatrix([o,s,a,l,c,u])})}scaleSelf(e,t){return this.options.transform.scaleSelf(e,t),this}}class zi{constructor(e,t,i,n,r=!1){this.primaryId=ri.from(e),this.primaryOptions=t,i&&(this.secondaryId=ri.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 Oi(this.primaryId,this.primaryOptions)}hasSecondary(){return!!this.secondaryId}getSecondary(){return this.secondaryId?new Oi(this.secondaryId,this.secondaryOptions):null}static from(e){return"string"==typeof e?zi.build({name:e}):e}static build(e,t,i,n){return!e||"object"==typeof e&&!("name"in e)?null:new zi(e,i,t,n)}}function Ui(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 Ni(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 li)return!0;if(e instanceof Fi)return!0;if(e instanceof Di)return!0;if(e instanceof zi)return!0;if(Array.isArray(e)){for(const t of e)if(!Ni(t))return!1;return!0}if("object"==typeof e){for(const t in e)if(!Ni(e[t]))return!1;return!0}return!1}function Vi(e){if(null===e)return _i;if("string"==typeof e)return yi;if("boolean"==typeof e)return vi;if("number"==typeof e)return Ai;if(e instanceof li)return xi;if(e instanceof Fi)return Ti;if(e instanceof Di)return Ei;if(e instanceof zi)return Ci;if(Array.isArray(e)){const t=e.length;let i;for(const t of e){const e=Vi(t);if(i){if(i===e)continue;i=wi;break}i=e}return Si(i||wi,t)}return bi}function ji(e){const t=typeof e;return null===e?"":"string"===t||"number"===t||"boolean"===t?String(e):e instanceof Di||e instanceof zi||e instanceof li?e.toString():JSON.stringify(e)}class Gi{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(!Ni(e[1]))return t.error("invalid value");const i=e[1];let n=Vi(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 Gi(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 li?["rgba"].concat(this.value.toNonPremultipliedRenderColor(null).toArray()):this.value instanceof Di?this.value.serialize():this.value}}class Hi{constructor(e){this.name="ExpressionEvaluationError",this.message=e}toJSON(){return this.message}}const Qi={string:yi,number:Ai,boolean:vi,object:bi};class $i{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 Qi)||"object"===i)return t.error('The item type argument of "array" must be one of string, number, boolean',1);r=Qi[i],n++}else r=wi;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=Si(r,o)}else i=Qi[r];const o=[];for(;ne.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 Zi{constructor(e){this.type=Ei,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",Ai),!e))return null;let s=null;if(o["text-font"]&&(s=t.parseObjectValue(o["text-font"],i,"text-font",Si(yi)),!s))return null;let a=null;if(o["text-color"]&&(a=t.parseObjectValue(o["text-color"],i,"text-color",xi),!a))return null;const l=n[n.length-1];l.scale=e,l.font=s,l.textColor=a}else{const o=t.parse(e[i],i,wi);if(!o)return null;const s=o.type.kind;if("string"!==s&&"value"!==s&&"null"!==s&&"resolvedImage"!==s)return t.error("Formatted text type must be 'string', 'value', 'image' or 'null'.");r=!0,n.push({content:o,scale:null,font:null,textColor:null})}}return new Zi(n)}evaluate(e){return new Di(this.sections.map(t=>{const i=t.content.evaluate(e);return Li(Vi(i),Ci)?new ki("",i,null,null,null):new ki(ji(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 Wi{constructor(e,t,i,n){this._imageWarnHistory={},this.type=Ci,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(iri.isEqual(e,t)),n.available){const t=n.getSecondary()?n.getSecondary().id:null;t&&(n.available=e.availableImages.some(e=>ri.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 qi(e){return Xi(e)?"string":Ji(e)?"number":Yi(e)?"boolean":Array.isArray(e)?"array":null===e?"null":Ki(e)?"object":typeof e}function Ki(e){return null!=e&&!Array.isArray(e)&&"function"!=typeof e&&!(e instanceof String||e instanceof Number||e instanceof Boolean)&&"object"==typeof e}function Xi(e){return"string"==typeof e||e instanceof String}function Ji(e){return"number"==typeof e||e instanceof Number}function Yi(e){return"boolean"==typeof e||e instanceof Boolean}const en={"to-boolean":vi,"to-color":xi,"to-number":Ai,"to-string":yi};class tn{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=_i;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=Si(t.expectedType.itemType,i)}else{if(!(i>0&&Ni(e[1][0])))return null;r=Si(Vi(e[1][0]),i)}for(let o=0;o4?`Invalid rbga value ${JSON.stringify(t)}: expected an array containing either three or four numeric values.`:Ui(t[0],t[1],t[2],t[3]),!i))return new li(t[0]/255,t[1]/255,t[2]/255,t[3])}throw new Hi(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 Hi(`Could not convert ${JSON.stringify(t)} to number.`)}return"formatted"===this.type.kind?Di.fromString(ji(this.args[0].evaluate(e))):"resolvedImage"===this.type.kind?zi.build(ji(this.args[0].evaluate(e))):"array"===this.type.kind?this.args.map(t=>t.evaluate(e)):ji(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 Zi([{content:this.args[0],scale:null,font:null,textColor:null}]).serialize();if("resolvedImage"===this.type.kind)return new Wi(this.args[0]).serialize();const e="array"===this.type.kind?[]:[`to-${this.type.kind}`];return this.eachChild(t=>{e.push(t.serialize())}),e}}const nn=["Unknown","Point","LineString","Polygon"];class rn{constructor(e,t,i){this.globals=null,this.feature=null,this.featureState=null,this.formattedSection=null,this._parseColorCache={},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?nn[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){let t=this._parseColorCache[e];return t||(t=this._parseColorCache[e]=li.parse(e)),t}getConfig(e){return this.options?this.options.get(e):null}}class on{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=on.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=on.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,s=[];let a=null,l=-1;for(const[n,c]of o){if(Array.isArray(n)&&n.length!==e.length-1)continue;s.push(n),l++,a=new Er(t.registry,t.path,null,t.scope,void 0,t._scope,t.options,t.iconImageUseTheme);const o=[];let u=!1;for(let t=1;te)).map(sn).join(" | "),n=[];for(let i=1;ii;){if(n-i>600){const o=n-i+1,s=t-i+1,a=Math.log(o),l=.5*Math.exp(2*a/3),c=.5*Math.sqrt(a*l*(o-l)/o)*(s-o/2<0?-1:1);ln(e,t,Math.max(i,Math.floor(t-s*l/o+c)),Math.min(n,Math.floor(t+(o-s)*l/o+c)),r)}const o=e[t];let s=i,a=n;for(cn(e,i,t),r(e[n],o)>0&&cn(e,i,n);s0;)a--}0===r(e[i],o)?cn(e,i,a):(a++,cn(e,a,n)),a<=t&&(i=a+1),t<=a&&(n=a-1)}}function cn(e,t,i){const n=e[t];e[t]=e[i],e[i]=n}function un(e,t){return et?1:0}function hn(e){let t=0;for(let i,n,r=0,o=e.length,s=o-1;r=t[2]||e[1]<=t[1]||e[3]>=t[3])}function fn(e,t,i){const n=e[0]-t[0],r=e[1]-t[1],o=e[0]-i[0],s=e[1]-i[1];return n*s-o*r==0&&n*o<=0&&r*s<=0}function mn(e,t,i=!1){let n=!1;for(let a=0,l=t.length;a(r=e)[1]!=(s=u)[1]>r[1]&&r[0]<(s[0]-o[0])*(r[1]-o[1])/(s[1]-o[1])+o[0]&&(n=!n)}}var r,o,s;return n}function gn(e,t,i,n){const r=n[0]-i[0],o=n[1]-i[1],s=(e[0]-i[0])*o-r*(e[1]-i[1]),a=(t[0]-i[0])*o-r*(t[1]-i[1]);return s>0&&a<0||s<0&&a>0}function _n(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]&&!(!gn(e,t,i,n)||!gn(i,n,e,t));var r,o}function An(e){const t=new Te(Number.POSITIVE_INFINITY,Number.POSITIVE_INFINITY),i=new Te(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.xi[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}dn(t,e)}function Bn(e,t,i,n){const r=Math.pow(2,n.z)*yn,o=[n.x*yn,n.y*yn],s=[];if(!e)return s;for(const n of e)for(const e of n){const n=[e.x+o[0],e.y+o[1]];Sn(n,t,i,r),s.push(n)}return s}function In(e,t,i,n){const r=Math.pow(2,n.z)*yn,o=[n.x*yn,n.y*yn],s=[];if(!e)return s;for(const i of e){const e=[];for(const n of i){const i=[n.x+o[0],n.y+o[1]];dn(t,i),e.push(i)}s.push(e)}if(t[2]-t[0]<=r/2){(a=t)[0]=a[1]=1/0,a[2]=a[3]=-1/0;for(const e of s)for(const n of e)Sn(n,t,i,r)}var a;return s}class Mn{constructor(e,t){this.type=vi,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(Ni(e[1])){const t=e[1];if("FeatureCollection"===t.type)for(let e=0;et)return On(r,o,(t-(i-s))/s)}return e[e.length-1]}pointToSegmentDistance(e,t,i){let[n,r]=t,o=zn(i[0]-n)*this.kx,s=(i[1]-r)*this.ky;if(0!==o||0!==s){const t=(zn(e[0]-n)*this.kx*o+(e[1]-r)*this.ky*s)/(o*o+s*s);t>1?(n=i[0],r=i[1]):t>0&&(n+=o/this.kx*t,r+=s/this.ky*t)}return o=zn(e[0]-n)*this.kx,s=(e[1]-r)*this.ky,Math.sqrt(o*o+s*s)}pointOnLine(e,t){let i=1/0,n=e[0][0],r=e[0][1],o=0,s=0;for(let a=0;a1?(l=e[a+1][0],c=e[a+1][1]):d>0&&(l+=u/this.kx*d,c+=h/this.ky*d)),u=zn(t[0]-l)*this.kx,h=(t[1]-c)*this.ky;const p=u*u+h*h;pr.index||n.index===r.index&&n.t>r.t){const e=n;n=r,r=e}const o=[n.point],s=n.index+1,a=r.index;!Dn(i[s],o[0])&&s<=a&&o.push(i[s]);for(let e=s+1;e<=a;e++)o.push(i[e]);return Dn(i[a],r.point)||o.push(r.point),o}lineSliceAlong(e,t,i){let n=0;const r=[];for(let o=0;oe&&0===r.length&&r.push(On(s,a,(e-(n-l))/l)),n>=t)return r.push(On(s,a,(t-(n-l))/l)),r;n>e&&r.push(a)}return r}bufferPoint(e,t){const i=t/this.ky,n=t/this.kx;return[e[0]-n,e[1]-i,e[0]+n,e[1]+i]}bufferBBox(e,t){const i=t/this.ky,n=t/this.kx;return[e[0]-n,e[1]-i,e[2]+n,e[3]+i]}insideBBox(e,t){return zn(e[0]-t[0])>=0&&zn(e[0]-t[2])<=0&&e[1]>=t[1]&&e[1]<=t[3]}}function Dn(e,t){return e[0]===t[0]&&e[1]===t[1]}function On(e,t,i){const n=zn(t[0]-e[0]);return[e[0]+n*i,e[1]+(t[1]-e[1])*i]}function zn(e){for(;e<-180;)e+=360;for(;e>180;)e-=360;return e}class Un{constructor(e=[],t=(e,t)=>et?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=0)break;t[e]=t[n],e=n}t[e]=r}}var Nn=8192;function Vn(e,t){return t.dist-e.dist}const jn=100,Gn=50;function Hn(e){const t=[1/0,1/0,-1/0,-1/0];if(t.length!==e.length)return!1;for(let i=0;i=e[0]&&e[1]e[1])return[null,null];const i=Qn(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 Wn(e,t){const i=[1/0,1/0,-1/0,-1/0];if(!$n(t,e.length))return i;for(let n=t[0];n<=t[1];++n)dn(i,e[n]);return i}function qn(e){const t=[1/0,1/0,-1/0,-1/0];for(let i=0;it[2]&&(n=e[0]-t[2]),e[1]>t[3]&&(r=e[1]-t[3]),e[3]=n)return n;if(pn(r,o)){if(lr(e,t))return 0}else if(lr(t,e))return 0;let s=n;for(const n of e)for(let e=0,r=n.length,o=r-1;e=o)continue;const c=r.range1;if(Qn(c)<=a){if(!$n(c,e.length))return NaN;if(t){const t=ar(e,c,i,n);if(0===(o=Math.min(o,t)))return o}else for(let t=c[0];t<=c[1];++t){const r=sr(e[t],i,n);if(0===(o=Math.min(o,r)))return o}}else{const i=Zn(c,t);if(null!==i[0]){const t=Kn(Wn(e,i[0]),l,n);t=s)continue;const u=o.range1,h=o.range2;if(Qn(u)<=l&&Qn(h)<=c){if(!$n(u,e.length)||!$n(h,i.length))return NaN;if(t&&n?s=Math.min(s,rr(e,u,i,h,r)):t||n?t&&!n?s=Math.min(s,ir(i,h,e,u,r)):!t&&n&&(s=Math.min(s,ir(e,u,i,h,r))):s=Math.min(s,or(e,u,i,h,r)),0===s)return s}else{const o=Zn(u,t),l=Zn(h,n);ur(a,s,r,e,i,o[0],l[0]),ur(a,s,r,e,i,o[0],l[1]),ur(a,s,r,e,i,o[1],l[0]),ur(a,s,r,e,i,o[1],l[1])}}return s}function pr(e,t,i,n,r=1/0){let o=r;const s=Wn(e,[0,e.length-1]);for(const r of i)if(!(o!==1/0&&Kn(s,Wn(r,[0,r.length-1]),n)>=o)&&(o=Math.min(o,dr(e,t,r,!0,n,o)),0===o))return o;return o}function fr(e,t,i,n,r=1/0){let o=r;const s=Wn(e,[0,e.length-1]);for(const r of i){if(o!==1/0&&Kn(s,qn(r),n)>=o)continue;const i=hr(e,t,r,n,o);if(isNaN(i))return i;if(0===(o=Math.min(o,i)))return o}return o}function mr(e){return"Point"===e||"MultiPoint"===e||"LineString"===e||"MultiLineString"===e||"Polygon"===e||"MultiPolygon"===e}class gr{constructor(e,t){this.type=Ai,this.geojson=e,this.geometries=t}static parse(e,t){if(2!==e.length)return t.error(`'distance' expression requires either one argument, but found ' ${e.length-1} instead.`);if(Ni(e[1])){const t=e[1];if("FeatureCollection"===t.type){for(let e=0;e{t&&!_r(e)&&(t=!1)}),t}function Ar(e){if(e instanceof on&&"feature-state"===e.name)return!1;let t=!0;return e.eachChild(e=>{t&&!Ar(e)&&(t=!1)}),t}function yr(e,t){if(e instanceof on&&t.indexOf(e.name)>=0)return!1;let i=!0;return e.eachChild(e=>{i&&!yr(e,t)&&(i=!1)}),i}function vr(e,t,i){return[e,t,i].filter(Boolean).join("")}function xr(e,t){switch(e){case"string":return ji(t);case"number":return+t;case"boolean":return!!t;case"color":return li.parse(t);case"formatted":return Di.fromString(ji(t));case"resolvedImage":return zi.build(ji(t))}return t}function br(e,t,i,n){return void 0!==n&&(e=n*Math.round(e/n)),void 0!==t&&ei&&(e=i),e}class wr{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(null==i&&(i=wi),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 Gi))return t.error("Key name of 'config' expression must be a string literal.");let r,o=!0;const s=ji(n.value);if(e.length>=3){const i=t.parse(e[2],2);if(!(i instanceof Gi))return t.error("Scope of 'config' expression must be a string literal.");r=ji(i.value)}if(t.options){const e=vr(s,r,t._scope),i=t.options.get(e);i&&(o=_r(i.value||i.default))}return new wr(i,s,r,o)}evaluate(e){const t=vr(this.key,this.scope,e.scope),i=e.getConfig(t);if(!i)return null;const{type:n,value:r,values:o,minValue:s,maxValue:a,stepValue:l}=i,c=i.default.evaluate(e);let u=c;if(r){const t=e.scope;e.scope=(t||"").split("").slice(1).join(""),u=r.evaluate(e),e.scope=t}return n&&(u=xr(n,u)),void 0===u||void 0===s&&void 0===a&&void 0===l||("number"==typeof u?u=br(u,s,a,l):Array.isArray(u)&&(u=u.map(e=>"number"==typeof e?br(e,s,a,l):e))),void 0!==r&&void 0!==u&&o&&!o.includes(u)&&(u=c,n&&(u=xr(n,u))),(n&&n!==this.type||void 0!==u&&!Li(Vi(u),this.type))&&(u=xr(this.type.kind,u)),u}eachChild(){}outputDefined(){return!1}serialize(){const e=["config",this.key];return this.scope&&e.concat(this.scope),e}}class Tr{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 Tr(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 Er{constructor(e,t=[],i,n=new gi,r=[],o,s,a){this.registry=e,this.path=t,this.key=t.map(e=>"string"==typeof e?`['${e}']`:`[${e}]`).join(""),this.scope=n,this.errors=r,this.expectedType=i,this._scope=o,this.options=s,this.iconImageUseTheme=a}parse(e,t,i,n,r={}){return t||i?this.concat(t,null,i,n)._parse(e,r):this._parse(e,r)}parseObjectValue(e,t,i,n,r,o={}){return this.concat(t,i,n,r)._parse(e,o)}_parse(e,t){function i(e,t,i){return"assert"===i?new $i(t,[e]):"coerce"===i?new tn(t,[e]):e}if(null!==e&&"string"!=typeof e&&"boolean"!=typeof e&&"number"!=typeof e||(e=["literal",e]),Array.isArray(e)){if(0===e.length)return this.error('Expected an array with at least one element. If you wanted a literal array, use ["literal", []].');const n="string"==typeof e[0]?this.registry[e[0]]:void 0;if(n){let r=n.parse(e,this);if(!r)return null;if(this.expectedType){const e=this.expectedType,n=r.type;if("string"!==e.kind&&"number"!==e.kind&&"boolean"!==e.kind&&"object"!==e.kind&&"array"!==e.kind||"value"!==n.kind)if("color"!==e.kind&&"formatted"!==e.kind&&"resolvedImage"!==e.kind||"value"!==n.kind&&"string"!==n.kind){if(this.checkSubtype(e,n))return null}else r=i(r,e,t.typeAnnotation||"coerce");else r=i(r,e,t.typeAnnotation||"assert")}if(!(r instanceof Gi)&&"resolvedImage"!==r.type.kind&&Cr(r)){const t=new rn(this._scope,this.options,this.iconImageUseTheme);try{r=new Gi(r.type,r.evaluate(t))}catch(e){return this.error(e.message),null}}return r}return tn.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){let r="number"==typeof e?this.path.concat(e):this.path;r="string"==typeof t?r.concat(t):r;const o=n?this.scope.concat(n):this.scope;return new Er(this.registry,r,i||null,o,this.errors,this._scope,this.options,this.iconImageUseTheme)}error(e,...t){const i=`${this.key}${t.map(e=>`[${e}]`).join("")}`;this.errors.push(new mi(i,e))}checkSubtype(e,t){const i=Mi(e,t);return i&&this.error(i),i}}function Cr(e){if(e instanceof Tr)return Cr(e.boundExpression);if(e instanceof on&&"error"===e.name)return!1;if(e instanceof an)return!1;if(e instanceof Mn)return!1;if(e instanceof gr)return!1;if(e instanceof wr)return!1;const t=e instanceof tn||e instanceof $i;let i=!0;return e.eachChild(e=>{i=t?i&&Cr(e):i&&e instanceof Gi}),!!i&&_r(e)&&yr(e,["zoom","heatmap-density","worldview","line-progress","raster-value","sky-radial-progress","accumulated","is-supported-script","pitch","distance-from-center","measure-light","raster-particle-speed"])}function Sr(e,t){const i=e.length-1;let n,r,o=0,s=i,a=0;for(;o<=s;)if(a=Math.floor((o+s)/2),n=e[a],r=e[a+1],n<=t){if(a===i||tt))throw new Hi("Input is not a number.");s=a-1}return 0}class Br{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,Ai);if(!i)return null;const n=[];let r=null;t.expectedType&&"value"!==t.expectedType.kind&&(r=t.expectedType);for(let i=1;i=o)return t.error('Input/output pairs for "step" expressions must be arranged with input values in strictly ascending order.',a);const c=t.parse(s,l,r);if(!c)return null;r=r||c.type,n.push([o,c])}return new Br(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[Sr(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;t0&&e.push(this.labels[t]),e.push(this.outputs[t].serialize());return e}}const Ir=.95047,Mr=1.08883,Pr=4/29,Rr=6/29,Lr=3*Rr*Rr,Fr=Rr*Rr*Rr,kr=Math.PI/180,Dr=180/Math.PI;function Or(e){return e>Fr?Math.pow(e,1/3):e/Lr+Pr}function zr(e){return e>Rr?e*e*e:Lr*(e-Pr)}function Ur(e){return 255*(e<=.0031308?12.92*e:1.055*Math.pow(e,1/2.4)-.055)}function Nr(e){return(e/=255)<=.04045?e/12.92:Math.pow((e+.055)/1.055,2.4)}function Vr(e){const t=Nr(e.r),i=Nr(e.g),n=Nr(e.b),r=Or((.4124564*t+.3575761*i+.1804375*n)/Ir),o=Or((.2126729*t+.7151522*i+.072175*n)/1);return{l:116*o-16,a:500*(r-o),b:200*(o-Or((.0193339*t+.119192*i+.9503041*n)/Mr)),alpha:e.a}}function jr(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*zr(t),i=Ir*zr(i),n=Mr*zr(n),new li(Ur(3.2404542*i-1.5371385*t-.4985314*n),Ur(-.969266*i+1.8760108*t+.041556*n),Ur(.0556434*i-.2040259*t+1.0572252*n),e.alpha)}function Gr(e,t,i){const n=t-e;return e+i*(n>180||n<-180?n-360*Math.round(n/360):n)}const Hr={forward:Vr,reverse:jr,interpolate:function(e,t,i){return{l:di(e.l,t.l,i),a:di(e.a,t.a,i),b:di(e.b,t.b,i),alpha:di(e.alpha,t.alpha,i)}}},Qr={forward:function(e){const{l:t,a:i,b:n}=Vr(e),r=Math.atan2(n,i)*Dr;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*kr,i=e.c;return jr({l:e.l,a:Math.cos(t)*i,b:Math.sin(t)*i,alpha:e.alpha})},interpolate:function(e,t,i){return{h:Gr(e.h,t.h,i),c:di(e.c,t.c,i),l:di(e.l,t.l,i),alpha:di(e.alpha,t.alpha,i)}}};var $r=Object.freeze({__proto__:null,hcl:Qr,lab:Hr});class Zr{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=Wr(t,e.base,i,n);else if("linear"===e.name)r=Wr(t,1,i,n);else if("cubic-bezier"===e.name){const o=e.controlPoints;r=new we(o[0],o[1],o[2],o[3]).solve(Wr(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,Ai),!r)return null;const s=[];let a=null;"interpolate-hcl"===i||"interpolate-lab"===i?a=xi:t.expectedType&&"value"!==t.expectedType.kind&&(a=t.expectedType);for(let e=0;e=i)return t.error('Input/output pairs for "interpolate" expressions must be arranged with input values in strictly ascending order.',r);const c=t.parse(n,l,a);if(!c)return null;a=a||c.type,s.push([i,c])}return"number"===a.kind||"color"===a.kind||"array"===a.kind&&"number"===a.itemType.kind&&"number"==typeof a.N?new Zr(a,i,n,r,s):t.error(`Type ${Bi(a)} 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=Sr(t,n),s=Zr.interpolationFactor(this.interpolation,n,t[o],t[o+1]),a=i[o].evaluate(e),l=i[o+1].evaluate(e);return"interpolate"===this.operator?fi[this.type.kind.toLowerCase()](a,l,s):"interpolate-hcl"===this.operator?Qr.reverse(Qr.interpolate(Qr.forward(a),Qr.forward(l),s)):Hr.reverse(Hr.interpolate(Hr.forward(a),Hr.forward(l),s))}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;eMi(n,e.type));return new qr(o?wi: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 zi&&!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}}class Kr{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=i.length)throw new Hi("Array index out of bounds: index exceeds array size");if(t!==Math.floor(t))throw new Hi("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 Jr{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,Ai),n=t.parse(e[2],2,Si(t.expectedType||wi));return i&&n?new Jr(n.type.itemType,i,n):null}evaluate(e){const t=this.index.evaluate(e),i=this.input.evaluate(e);if(t<0)throw new Hi(`Array index out of bounds: ${t} < 0.`);if(t>i.length-1)throw new Hi(`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],s=i[r];if("number"!=typeof o||"number"!=typeof s)throw new Hi(`Cannot interpolate between non-number values at index ${t}.`);const a=t-n;return o*(1-a)+s*a}eachChild(e){e(this.index),e(this.input)}outputDefined(){return!1}serialize(){return["at-interpolated",this.index.serialize(),this.input.serialize()]}}class Yr{constructor(e,t){this.type=vi,this.needle=e,this.haystack=t}static parse(e,t){if(3!==e.length)return t.error(`Expected 2 arguments, but found ${e.length-1} instead.`);const i=t.parse(e[1],1,wi),n=t.parse(e[2],2,wi);return i&&n?Pi(i.type,[vi,yi,Ai,_i,wi])?new Yr(i,n):t.error(`Expected first argument to be of type boolean, string, number or null, but found ${Bi(i.type)} instead`):null}evaluate(e){const t=this.needle.evaluate(e),i=this.haystack.evaluate(e);if(null==i)return!1;if(!Ri(t,["boolean","string","number","null"]))throw new Hi(`Expected first argument to be of type boolean, string, number or null, but found ${Bi(Vi(t))} instead.`);if(!Ri(i,["string","array"]))throw new Hi(`Expected second argument to be of type array or string, but found ${Bi(Vi(i))} instead.`);return i.indexOf(t)>=0}eachChild(e){e(this.needle),e(this.haystack)}outputDefined(){return!0}serialize(){return["in",this.needle.serialize(),this.haystack.serialize()]}}class eo{constructor(e,t,i){this.type=Ai,this.needle=e,this.haystack=t,this.fromIndex=i}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.`);const i=t.parse(e[1],1,wi),n=t.parse(e[2],2,wi);if(!i||!n)return null;if(!Pi(i.type,[vi,yi,Ai,_i,wi]))return t.error(`Expected first argument to be of type boolean, string, number or null, but found ${Bi(i.type)} instead`);if(4===e.length){const r=t.parse(e[3],3,Ai);return r?new eo(i,n,r):null}return new eo(i,n)}evaluate(e){const t=this.needle.evaluate(e),i=this.haystack.evaluate(e);if(!Ri(t,["boolean","string","number","null"]))throw new Hi(`Expected first argument to be of type boolean, string, number or null, but found ${Bi(Vi(t))} instead.`);if(!Ri(i,["string","array"]))throw new Hi(`Expected second argument to be of type array or string, but found ${Bi(Vi(i))} instead.`);if(this.fromIndex){const n=this.fromIndex.evaluate(e);return i.indexOf(t,n)}return i.indexOf(t)}eachChild(e){e(this.needle),e(this.haystack),this.fromIndex&&e(this.fromIndex)}outputDefined(){return!1}serialize(){if(null!=this.fromIndex&&void 0!==this.fromIndex){const e=this.fromIndex.serialize();return["index-of",this.needle.serialize(),this.haystack.serialize(),e]}return["index-of",this.needle.serialize(),this.haystack.serialize()]}}class to{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 s=2;sNumber.MAX_SAFE_INTEGER)return c.error(`Branch labels must be integers no larger than ${Number.MAX_SAFE_INTEGER}.`);if("number"==typeof e&&Math.floor(e)!==e)return c.error("Numeric branch labels must be integer values.");if(i){if(c.checkSubtype(i,Vi(e)))return null}else i=Vi(e);if(void 0!==r[String(e)])return c.error("Branch labels must be unique.");r[String(e)]=o.length}const u=t.parse(l,s,n);if(!u)return null;n=n||u.type,o.push(u)}const s=t.parse(e[1],1,wi);if(!s)return null;const a=t.parse(e[e.length-1],e.length-1,n);return a?"value"!==s.type.kind&&t.concat(1).checkSubtype(i,s.type)?null:new to(i,n,s,r,o,a):null}evaluate(e){const t=this.input.evaluate(e);return(Li(Vi(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 io{constructor(e,t,i){this.type=e,this.branches=t,this.otherwise=i}static parse(e,t){if(e.length<4)return t.error(`Expected at least 3 arguments, but found only ${e.length-1}.`);if(e.length%2!=0)return t.error("Expected an odd number of arguments.");let i;t.expectedType&&"value"!==t.expectedType.kind&&(i=t.expectedType);const n=[];for(let r=1;rt.outputDefined())&&this.otherwise.outputDefined()}serialize(){const e=["case"];return this.eachChild(t=>{e.push(t.serialize())}),e}}class no{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.`);const i=t.parse(e[1],1,wi),n=t.parse(e[2],2,Ai);if(!i||!n)return null;if(!Pi(i.type,[Si(wi),yi,wi]))return t.error(`Expected first argument to be of type array or string, but found ${Bi(i.type)} instead`);if(4===e.length){const r=t.parse(e[3],3,Ai);return r?new no(i.type,i,n,r):null}return new no(i.type,i,n)}evaluate(e){const t=this.input.evaluate(e),i=this.beginIndex.evaluate(e);if(!Ri(t,["string","array"]))throw new Hi(`Expected first argument to be of type array or string, but found ${Bi(Vi(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()]}}class ro{constructor(e,t){this.type=Si(yi),this.str=e,this.delimiter=t}static parse(e,t){if(3!==e.length)return t.error(`Expected 2 arguments, but found ${e.length-1} instead.`);const i=t.parse(e[1],1,yi),n=t.parse(e[2],2,yi);return i&&n?new ro(i,n):void 0}evaluate(e){const t=this.str.evaluate(e),i=this.delimiter.evaluate(e);return t.split(i)}eachChild(e){e(this.str),e(this.delimiter)}outputDefined(){return!1}serialize(){return["split",this.str.serialize(),this.delimiter.serialize()]}}function oo(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 so(e,t,i,n){return 0===n.compare(t,i)}function ao(e,t,i){const n="=="!==e&&"!="!==e;return class r{constructor(e,t,i){this.type=vi,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,wi);if(!o)return null;if(!oo(i,o.type))return t.concat(1).error(`"${i}" comparisons are not supported for type '${Bi(o.type)}'.`);let s=t.parse(e[2],2,wi);if(!s)return null;if(!oo(i,s.type))return t.concat(2).error(`"${i}" comparisons are not supported for type '${Bi(s.type)}'.`);if(o.type.kind!==s.type.kind&&"value"!==o.type.kind&&"value"!==s.type.kind)return t.error(`Cannot compare types '${Bi(o.type)}' and '${Bi(s.type)}'.`);n&&("value"===o.type.kind&&"value"!==s.type.kind?o=new $i(s.type,[o]):"value"!==o.type.kind&&"value"===s.type.kind&&(s=new $i(o.type,[s])));let a=null;if(4===e.length){if("string"!==o.type.kind&&"string"!==s.type.kind&&"value"!==o.type.kind&&"value"!==s.type.kind)return t.error("Cannot use collator to compare non-string types.");if(a=t.parse(e[3],3,Ti),!a)return null}return new r(o,s,a)}evaluate(r){const o=this.lhs.evaluate(r),s=this.rhs.evaluate(r);if(n&&this.hasUntypedArgument){const t=Vi(o),i=Vi(s);if(t.kind!==i.kind||"string"!==t.kind&&"number"!==t.kind)throw new Hi(`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=Vi(o),i=Vi(s);if("string"!==e.kind||"string"!==i.kind)return t(r,o,s)}return this.collator?i(r,o,s,this.collator.evaluate(r)):t(r,o,s)}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 lo=ao("==",function(e,t,i){return t===i},so),co=ao("!=",function(e,t,i){return t!==i},function(e,t,i,n){return!so(0,t,i,n)}),uo=ao("<",function(e,t,i){return t",function(e,t,i){return t>i},function(e,t,i,n){return n.compare(t,i)>0}),po=ao("<=",function(e,t,i){return t<=i},function(e,t,i,n){return n.compare(t,i)<=0}),fo=ao(">=",function(e,t,i){return t>=i},function(e,t,i,n){return n.compare(t,i)>=0});class mo{constructor(e,t,i,n,r,o){this.type=yi,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,Ai);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",yi),!r))return null;let o=null;if(n.currency&&(o=t.parseObjectValue(n.currency,2,"currency",yi),!o))return null;let s=null;if(n.unit&&(s=t.parseObjectValue(n.unit,2,"unit",yi),!s))return null;let a=null;if(n["min-fraction-digits"]&&(a=t.parseObjectValue(n["min-fraction-digits"],2,"min-fraction-digits",Ai),!a))return null;let l=null;return n["max-fraction-digits"]&&(l=t.parseObjectValue(n["max-fraction-digits"],2,"max-fraction-digits",Ai),!l)?null:new mo(i,r,o,s,a,l)}evaluate(e){return new Intl.NumberFormat(this.locale?this.locale.evaluate(e):[],{style:(this.currency?"currency":this.unit&&"unit")||"decimal",currency:this.currency?this.currency.evaluate(e):void 0,unit:this.unit?this.unit.evaluate(e):void 0,minimumFractionDigits:this.minFractionDigits?this.minFractionDigits.evaluate(e):void 0,maximumFractionDigits:this.maxFractionDigits?this.maxFractionDigits.evaluate(e):void 0}).format(this.number.evaluate(e))}eachChild(e){e(this.number),this.locale&&e(this.locale),this.currency&&e(this.currency),this.unit&&e(this.unit),this.minFractionDigits&&e(this.minFractionDigits),this.maxFractionDigits&&e(this.maxFractionDigits)}outputDefined(){return!1}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 go{constructor(e){this.type=Ai,this.input=e}static parse(e,t){if(2!==e.length)return t.error(`Expected 1 argument, but found ${e.length-1} instead.`);const i=t.parse(e[1],1);return i?"array"!==i.type.kind&&"string"!==i.type.kind&&"value"!==i.type.kind?t.error(`Expected argument of type string or array, but found ${Bi(i.type)} instead.`):new go(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 Hi(`Expected value to be of type string or array, but found ${Bi(Vi(t))} instead.`)}eachChild(e){e(this.input)}outputDefined(){return!1}serialize(){const e=["length"];return this.eachChild(t=>{e.push(t.serialize())}),e}}function _o(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 Ao={"==":lo,"!=":co,">":ho,"<":uo,">=":fo,"<=":po,array:$i,at:Xr,"at-interpolated":Jr,boolean:$i,case:io,coalesce:qr,collator:an,format:Zi,image:Wi,in:Yr,"index-of":eo,interpolate:Zr,"interpolate-hcl":Zr,"interpolate-lab":Zr,length:go,let:Kr,literal:Gi,match:to,number:$i,"number-format":mo,object:$i,slice:no,step:Br,string:$i,"to-boolean":tn,"to-color":tn,"to-number":tn,"to-string":tn,var:Tr,within:Mn,distance:gr,config:wr,split:ro};function yo(e,[t,i,n,r]){t=t.evaluate(e),i=i.evaluate(e),n=n.evaluate(e);const o=r?r.evaluate(e):1,s=Ui(t,i,n,o);if(s)throw new Hi(s);return new li(t/255,i/255,n/255,o)}function vo(e,[t,i,n,r]){t=t.evaluate(e),i=i.evaluate(e),n=n.evaluate(e);const o=r?r.evaluate(e):1,s=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(s)throw new Hi(s);const a=`hsla(${t}, ${i}%, ${n}%, ${o})`,l=li.parse(a);if(!l)throw new Hi(`Failed to parse HSLA color: ${a}`);return l}function xo(e,t){return e in t}function bo(e,t){const i=t[e];return void 0===i?null:i}function wo(e){return{type:e}}function To(e){if(e instanceof wr)return new Set([e.key]);let t=new Set;return e.eachChild(e=>{t=new Set([...t,...To(e)])}),t}function Eo(e){if(e instanceof on&&"is-active-floor"===e.name)return!0;let t=!1;return e.eachChild(e=>{!t&&Eo(e)&&(t=!0)}),t}function Co(e){return{result:"success",value:e}}function So(e){return{result:"error",value:e}}function Bo(e,t){return!!e&&!!e.parameters&&e.parameters.indexOf(t)>-1}function Io(e){return"data-driven"===e["property-type"]}function Mo(e){return Bo(e.expression,"measure-light")}function Po(e){return Bo(e.expression,"zoom")}function Ro(e){return!!e.expression&&e.expression.interpolated}function Lo(e){return"object"==typeof e&&null!==e&&!Array.isArray(e)}function Fo(e){return e}function ko(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||(Ro(t)?"exponential":"interval");if(i&&((e=Object.assign({},e)).stops&&(e.stops=e.stops.map(e=>[e[0],li.parse(e[1])])),e.default=li.parse(e.default?e.default:t.default)),e.colorSpace&&"rgb"!==e.colorSpace&&!$r[e.colorSpace])throw new Error(`Unknown color space: ${e.colorSpace}`);let s,a,l;if("exponential"===o)s=Uo;else if("interval"===o)s=zo;else if("categorical"===o){s=Oo,a=Object.create(null);for(const t of e.stops)a[t[0]]=t[1];l=typeof e.stops[0][0]}else{if("identity"!==o)throw new Error(`Unknown function type "${o}"`);s=No}if(n){const i={},n=[];for(let t=0;te[0]),evaluate:({zoom:i},n)=>Uo({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:Zr.interpolationFactor.bind(void 0,i),zoomStops:e.stops.map(e=>e[0]),evaluate:({zoom:i})=>s(e,t,i,a,l)}}return{kind:"source",evaluate(i,n){const r=n&&n.properties?n.properties[e.property]:void 0;return void 0===r?Do(e.default,t.default):s(e,t,r,a,l)}}}function Do(e,t,i){return void 0!==e?e:void 0!==t?t:void 0!==i?i:void 0}function Oo(e,t,i,n,r){return Do(typeof i===r?n[i]:void 0,e.default,t.default)}function zo(e,t,i){if(!Ji(i))return Do(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=Sr(e.stops.map(e=>e[0]),i);return e.stops[r][1]}function Uo(e,t,i){const n=void 0!==e.base?e.base:1;if(!Ji(i))return Do(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=Sr(e.stops.map(e=>e[0]),i),s=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]),a=e.stops[o][1],l=e.stops[o+1][1];let c=fi[t.type]||Fo;if(e.colorSpace&&"rgb"!==e.colorSpace){const t=$r[e.colorSpace];c=(e,i)=>t.reverse(t.interpolate(t.forward(e),t.forward(i),s))}return"function"==typeof a.evaluate?{evaluate(...e){const t=a.evaluate.apply(void 0,e),i=l.evaluate.apply(void 0,e);if(void 0!==t&&void 0!==i)return c(t,i,s)}}:c(a,l,s)}function No(e,t,i){return"color"===t.type?i=li.parse(i):"formatted"===t.type?i=Di.fromString(i.toString()):"resolvedImage"===t.type?i=zi.build(i.toString()):qi(i)===t.type||"enum"===t.type&&t.values[i]||(i=void 0),Do(i,e.default,t.default)}on.register(Ao,{error:[{kind:"error"},[yi],(e,[t])=>{throw new Hi(t.evaluate(e))}],typeof:[yi,[wi],(e,[t])=>Bi(Vi(t.evaluate(e)))],"to-rgba":[Si(Ai,4),[xi],(e,[t])=>t.evaluate(e).toNonPremultipliedRenderColor(null).toArray()],"to-hsla":[Si(Ai,4),[xi],(e,[t])=>t.evaluate(e).toNonPremultipliedRenderColor(null).toHslaArray()],rgb:[xi,[Ai,Ai,Ai],yo],rgba:[xi,[Ai,Ai,Ai,Ai],yo],hsl:[xi,[Ai,Ai,Ai],vo],hsla:[xi,[Ai,Ai,Ai,Ai],vo],has:{type:vi,overloads:[[[yi],(e,[t])=>xo(t.evaluate(e),e.properties())],[[yi,bi],(e,[t,i])=>xo(t.evaluate(e),i.evaluate(e))]]},get:{type:wi,overloads:[[[yi],(e,[t])=>bo(t.evaluate(e),e.properties())],[[yi,bi],(e,[t,i])=>bo(t.evaluate(e),i.evaluate(e))]]},"feature-state":[wi,[yi],(e,[t])=>bo(t.evaluate(e),e.featureState||{})],properties:[bi,[],e=>e.properties()],"geometry-type":[yi,[],e=>e.geometryType()],worldview:[yi,[],e=>e.globals.worldview||""],"is-active-floor":[vi,wo(yi),(e,t)=>{if(!(e.globals.activeFloors&&e.globals.activeFloors.size>0))return!1;const i=e.globals.activeFloors;return t.some(t=>{const n=t.evaluate(e);return i.has(n)})}],id:[wi,[],e=>e.id()],zoom:[Ai,[],e=>e.globals.zoom],pitch:[Ai,[],e=>e.globals.pitch||0],"distance-from-center":[Ai,[],e=>e.distanceFromCenter()],"measure-light":[Ai,[yi],(e,[t])=>e.measureLight(t.evaluate(e))],"heatmap-density":[Ai,[],e=>e.globals.heatmapDensity||0],"line-progress":[Ai,[],e=>e.globals.lineProgress||0],"raster-value":[Ai,[],e=>e.globals.rasterValue||0],"raster-particle-speed":[Ai,[],e=>e.globals.rasterParticleSpeed||0],"sky-radial-progress":[Ai,[],e=>e.globals.skyRadialProgress||0],accumulated:[wi,[],e=>void 0===e.globals.accumulated?null:e.globals.accumulated],"+":[Ai,wo(Ai),(e,t)=>{let i=0;for(const n of t)i+=n.evaluate(e);return i}],"*":[Ai,wo(Ai),(e,t)=>{let i=1;for(const n of t)i*=n.evaluate(e);return i}],"-":{type:Ai,overloads:[[[Ai,Ai],(e,[t,i])=>t.evaluate(e)-i.evaluate(e)],[[Ai],(e,[t])=>-t.evaluate(e)]]},"/":[Ai,[Ai,Ai],(e,[t,i])=>t.evaluate(e)/i.evaluate(e)],"%":[Ai,[Ai,Ai],(e,[t,i])=>t.evaluate(e)%i.evaluate(e)],ln2:[Ai,[],()=>Math.LN2],pi:[Ai,[],()=>Math.PI],e:[Ai,[],()=>Math.E],"^":[Ai,[Ai,Ai],(e,[t,i])=>Math.pow(t.evaluate(e),i.evaluate(e))],sqrt:[Ai,[Ai],(e,[t])=>Math.sqrt(t.evaluate(e))],log10:[Ai,[Ai],(e,[t])=>Math.log(t.evaluate(e))/Math.LN10],ln:[Ai,[Ai],(e,[t])=>Math.log(t.evaluate(e))],log2:[Ai,[Ai],(e,[t])=>Math.log2(t.evaluate(e))],sin:[Ai,[Ai],(e,[t])=>Math.sin(t.evaluate(e))],cos:[Ai,[Ai],(e,[t])=>Math.cos(t.evaluate(e))],tan:[Ai,[Ai],(e,[t])=>Math.tan(t.evaluate(e))],asin:[Ai,[Ai],(e,[t])=>Math.asin(t.evaluate(e))],acos:[Ai,[Ai],(e,[t])=>Math.acos(t.evaluate(e))],atan:[Ai,[Ai],(e,[t])=>Math.atan(t.evaluate(e))],min:[Ai,wo(Ai),(e,t)=>Math.min(...t.map(t=>t.evaluate(e)))],max:[Ai,wo(Ai),(e,t)=>Math.max(...t.map(t=>t.evaluate(e)))],abs:[Ai,[Ai],(e,[t])=>Math.abs(t.evaluate(e))],round:[Ai,[Ai],(e,[t])=>{const i=t.evaluate(e);return i<0?-Math.round(-i):Math.round(i)}],floor:[Ai,[Ai],(e,[t])=>Math.floor(t.evaluate(e))],ceil:[Ai,[Ai],(e,[t])=>Math.ceil(t.evaluate(e))],"filter-==":[vi,[yi,wi],(e,[t,i])=>e.properties()[t.value]===i.value],"filter-id-==":[vi,[wi],(e,[t])=>e.id()===t.value],"filter-type-==":[vi,[yi],(e,[t])=>e.geometryType()===t.value],"filter-<":[vi,[yi,wi],(e,[t,i])=>{const n=e.properties()[t.value],r=i.value;return typeof n==typeof r&&n{const i=e.id(),n=t.value;return typeof i==typeof n&&i":[vi,[yi,wi],(e,[t,i])=>{const n=e.properties()[t.value],r=i.value;return typeof n==typeof r&&n>r}],"filter-id->":[vi,[wi],(e,[t])=>{const i=e.id(),n=t.value;return typeof i==typeof n&&i>n}],"filter-<=":[vi,[yi,wi],(e,[t,i])=>{const n=e.properties()[t.value],r=i.value;return typeof n==typeof r&&n<=r}],"filter-id-<=":[vi,[wi],(e,[t])=>{const i=e.id(),n=t.value;return typeof i==typeof n&&i<=n}],"filter->=":[vi,[yi,wi],(e,[t,i])=>{const n=e.properties()[t.value],r=i.value;return typeof n==typeof r&&n>=r}],"filter-id->=":[vi,[wi],(e,[t])=>{const i=e.id(),n=t.value;return typeof i==typeof n&&i>=n}],"filter-has":[vi,[wi],(e,[t])=>t.value in e.properties()],"filter-has-id":[vi,[],e=>null!==e.id()&&void 0!==e.id()],"filter-type-in":[vi,[Si(yi)],(e,[t])=>t.value.indexOf(e.geometryType())>=0],"filter-id-in":[vi,[Si(wi)],(e,[t])=>t.value.indexOf(e.id())>=0],"filter-in-small":[vi,[yi,Si(wi)],(e,[t,i])=>i.value.indexOf(e.properties()[t.value])>=0],"filter-in-large":[vi,[yi,Si(wi)],(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:vi,overloads:[[[vi,vi],(e,[t,i])=>t.evaluate(e)&&i.evaluate(e)],[wo(vi),(e,t)=>{for(const i of t)if(!i.evaluate(e))return!1;return!0}]]},any:{type:vi,overloads:[[[vi,vi],(e,[t,i])=>t.evaluate(e)||i.evaluate(e)],[wo(vi),(e,t)=>{for(const i of t)if(i.evaluate(e))return!0;return!1}]]},"!":[vi,[vi],(e,[t])=>!t.evaluate(e)],"is-supported-script":[vi,[yi],(e,[t])=>{const i=e.globals&&e.globals.isSupportedScript;return!i||i(t.evaluate(e))}],upcase:[yi,[yi],(e,[t])=>t.evaluate(e).toUpperCase()],downcase:[yi,[yi],(e,[t])=>t.evaluate(e).toLowerCase()],concat:[yi,wo(wi),(e,t)=>t.map(t=>ji(t.evaluate(e))).join("")],"resolved-locale":[yi,[Ti],(e,[t])=>t.evaluate(e).resolvedLocale()],random:[Ai,[Ai,Ai,wi],(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;iJSON.stringify(e)).join(", ")}, but found ${JSON.stringify(e)} instead.`);return e}catch(e){return this._warningHistory[e.message]||(this._warningHistory[e.message]=!0,"undefined"!=typeof console&&console.warn(`Failed to evaluate expression "${JSON.stringify(this.expression.serialize())}". ${e.message}`)),this._defaultValue}}}function jo(e){return Array.isArray(e)&&e.length>0&&"string"==typeof e[0]&&e[0]in Ao}function Go(e,t,i,n,r){const o=new Er(Ao,[],t?function(e){const t={color:xi,string:yi,number:Ai,enum:yi,boolean:vi,formatted:Ei,resolvedImage:Ci};return"array"===e.type?Si(t[e.value]||wi,e.length):t[e.type]}(t):void 0,void 0,void 0,i,n,r),s=o.parse(e,void 0,void 0,void 0,t&&"string"===t.type?{typeAnnotation:"coerce"}:void 0);return s?Co(new Vo(s,t,i,n,r)):So(o.errors)}class Ho{constructor(e,t,i,n){this.kind=e,this._styleExpression=t,this.isLightConstant=i,this.isLineProgressConstant=n,this.isStateDependent="constant"!==e&&!Ar(t.expression),this.configDependencies=To(t.expression),this.isIndoorDependent=Eo(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,s){return this._styleExpression.evaluate(e,t,i,n,r,o,void 0,void 0,s)}}class Qo{constructor(e,t,i,n,r,o){this.kind=e,this.zoomStops=i,this._styleExpression=t,this.isStateDependent="camera"!==e&&!Ar(t.expression),this.isIndoorDependent=Eo(t.expression),this.isLightConstant=r,this.isLineProgressConstant=o,this.configDependencies=To(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?Zr.interpolationFactor(this.interpolationType,e,t,i):0}}function $o(e,t,i,n,r){if("error"===(e=Go(e,t,i,n,r)).result)return e;const o=e.value.expression,s=_r(o);if(!s&&!Io(t))return So([new mi("","data expressions not supported")]);const a=yr(o,["zoom","pitch","distance-from-center"]);if(!a&&!Po(t))return So([new mi("","zoom expressions not supported")]);const l=yr(o,["measure-light"]);if(!l&&!Mo(t))return So([new mi("","measure-light expression not supported")]);const c=yr(o,["line-progress"]);if(!c&&!function(e){return Bo(e.expression,"line-progress")}(t))return So([new mi("","line-progress expression not supported")]);const u=t.expression&&t.expression.relaxZoomRestriction,h=Wo(o);return h||a||u?h instanceof mi?So([h]):h instanceof Zr&&!Ro(t)?So([new mi("",'"interpolate" expressions cannot be used with this property')]):Co(h?new Qo(s&&c?"camera":"composite",e.value,h.labels,h instanceof Zr?h.interpolation:void 0,l,c):new Ho(s&&c?"constant":"source",e.value,l,c)):So([new mi("",'"zoom" expression may only be used as input to a top-level "step" or "interpolate" expression, or in the properties of atmosphere.')])}class Zo{constructor(e,t){this._parameters=e,this._specification=t,Object.assign(this,ko(this._parameters,this._specification))}static deserialize(e){return new Zo(e._parameters,e._specification)}static serialize(e){return{_parameters:e._parameters,_specification:e._specification}}}function Wo(e){let t=null;if(e instanceof Kr)t=Wo(e.result);else if(e instanceof qr){for(const i of e.args)if(t=Wo(i),t)break}else(e instanceof Br||e instanceof Zr)&&e.input instanceof on&&"zoom"===e.input.name&&(t=e);return t instanceof mi||e.eachChild(e=>{const i=Wo(e);i instanceof mi?t=i:t&&i&&t!==i&&(t=new mi("",'Only one zoom-based "step" or "interpolate" subexpression may be used in an expression.'))}),t}var qo,Ko,Xo=function(){if(Ko)return qo;Ko=1,qo=t;var e=3;function t(t,i,n){var r=this.cells=[];if(t instanceof ArrayBuffer){this.arrayBuffer=t;var o=new Int32Array(this.arrayBuffer);t=o[0],this.d=(i=o[1])+2*(n=o[2]);for(var s=0;s=u[p+0]&&n>=u[p+1])?(s[d]=!0,o.push(c[d])):s[d]=!1}}},t.prototype._forEachCell=function(e,t,i,n,r,o,s,a){for(var l=this._convertToCellCoord(e),c=this._convertToCellCoord(t),u=this._convertToCellCoord(i),h=this._convertToCellCoord(n),d=l;d<=u;d++)for(var p=c;p<=h;p++){var f=this.d*p+d;if((!a||a(this._convertFromCellCoord(d),this._convertFromCellCoord(p),this._convertFromCellCoord(d+1),this._convertFromCellCoord(p+1)))&&r.call(this,e,t,i,n,f,o,s,a))return}},t.prototype._convertFromCellCoord=function(e){return(e-this.padding)/this.scale},t.prototype._convertToCellCoord=function(e){return Math.max(0,Math.min(this.d-1,Math.floor(e*this.scale)+this.padding))},t.prototype.toArrayBuffer=function(){if(this.arrayBuffer)return this.arrayBuffer;for(var t=this.cells,i=e+this.cells.length+1+1,n=0,r=0;r=0||(r[i]=ns(e[i],t)));e instanceof Error&&(r.message=e.message)}if(r.$name)throw new Error("$name property is reserved for worker serialization logic.");return"Object"!==n&&(r.$name=n),r}throw new Error("can't serialize object of type "+typeof e)}function rs(e){if(null==e||"boolean"==typeof e||"number"==typeof e||"string"==typeof e||e instanceof Boolean||e instanceof Number||e instanceof String||e instanceof Date||e instanceof RegExp||ts(e)||is(e)||ArrayBuffer.isView(e)||e instanceof ImageData)return e;if(Array.isArray(e))return e.map(rs);if("object"==typeof e){const t=e.$name||"Object";if("Map"===t){const t=e.entries||[],i=new Map;for(let e=0;ee>=128&&e<=255,Arabic:e=>e>=1536&&e<=1791,"Arabic Supplement":e=>e>=1872&&e<=1919,"Arabic Extended-A":e=>e>=2208&&e<=2303,"Hangul Jamo":e=>e>=4352&&e<=4607,"Unified Canadian Aboriginal Syllabics":e=>e>=5120&&e<=5759,Khmer:e=>e>=6016&&e<=6143,"Unified Canadian Aboriginal Syllabics Extended":e=>e>=6320&&e<=6399,"General Punctuation":e=>e>=8192&&e<=8303,"Letterlike Symbols":e=>e>=8448&&e<=8527,"Number Forms":e=>e>=8528&&e<=8591,"Miscellaneous Technical":e=>e>=8960&&e<=9215,"Control Pictures":e=>e>=9216&&e<=9279,"Optical Character Recognition":e=>e>=9280&&e<=9311,"Enclosed Alphanumerics":e=>e>=9312&&e<=9471,"Geometric Shapes":e=>e>=9632&&e<=9727,"Miscellaneous Symbols":e=>e>=9728&&e<=9983,"Miscellaneous Symbols and Arrows":e=>e>=11008&&e<=11263,"CJK Radicals Supplement":e=>e>=11904&&e<=12031,"Kangxi Radicals":e=>e>=12032&&e<=12255,"Ideographic Description Characters":e=>e>=12272&&e<=12287,"CJK Symbols and Punctuation":e=>e>=12288&&e<=12351,Hiragana:e=>e>=12352&&e<=12447,Katakana:e=>e>=12448&&e<=12543,Bopomofo:e=>e>=12544&&e<=12591,"Hangul Compatibility Jamo":e=>e>=12592&&e<=12687,Kanbun:e=>e>=12688&&e<=12703,"Bopomofo Extended":e=>e>=12704&&e<=12735,"CJK Strokes":e=>e>=12736&&e<=12783,"Katakana Phonetic Extensions":e=>e>=12784&&e<=12799,"Enclosed CJK Letters and Months":e=>e>=12800&&e<=13055,"CJK Compatibility":e=>e>=13056&&e<=13311,"CJK Unified Ideographs Extension A":e=>e>=13312&&e<=19903,"Yijing Hexagram Symbols":e=>e>=19904&&e<=19967,"CJK Unified Ideographs":e=>e>=19968&&e<=40959,"Yi Syllables":e=>e>=40960&&e<=42127,"Yi Radicals":e=>e>=42128&&e<=42191,"Hangul Jamo Extended-A":e=>e>=43360&&e<=43391,"Hangul Syllables":e=>e>=44032&&e<=55215,"Hangul Jamo Extended-B":e=>e>=55216&&e<=55295,"Private Use Area":e=>e>=57344&&e<=63743,"CJK Compatibility Ideographs":e=>e>=63744&&e<=64255,"Arabic Presentation Forms-A":e=>e>=64336&&e<=65023,"Vertical Forms":e=>e>=65040&&e<=65055,"CJK Compatibility Forms":e=>e>=65072&&e<=65103,"Small Form Variants":e=>e>=65104&&e<=65135,"Arabic Presentation Forms-B":e=>e>=65136&&e<=65279,"Halfwidth and Fullwidth Forms":e=>e>=65280&&e<=65519,Osage:e=>e>=66736&&e<=66815,"CJK Unified Ideographs Extension B":e=>e>=131072&&e<=173791};function ss(e){for(const t of e)if(cs(t.charCodeAt(0)))return!0;return!1}function as(e){for(const t of e)if(!ls(t.charCodeAt(0)))return!1;return!0}function ls(e){return!(os.Arabic(e)||os["Arabic Supplement"](e)||os["Arabic Extended-A"](e)||os["Arabic Presentation Forms-A"](e)||os["Arabic Presentation Forms-B"](e))}function cs(e){return!(746!==e&&747!==e&&(e<4352||!(os["Bopomofo Extended"](e)||os.Bopomofo(e)||os["CJK Compatibility Forms"](e)&&!(e>=65097&&e<=65103)||os["CJK Compatibility Ideographs"](e)||os["CJK Compatibility"](e)||os["CJK Radicals Supplement"](e)||os["CJK Strokes"](e)||!(!os["CJK Symbols and Punctuation"](e)||e>=12296&&e<=12305||e>=12308&&e<=12319||12336===e)||os["CJK Unified Ideographs Extension A"](e)||os["CJK Unified Ideographs"](e)||os["Enclosed CJK Letters and Months"](e)||os["Hangul Compatibility Jamo"](e)||os["Hangul Jamo Extended-A"](e)||os["Hangul Jamo Extended-B"](e)||os["Hangul Jamo"](e)||os["Hangul Syllables"](e)||os.Hiragana(e)||os["Ideographic Description Characters"](e)||os.Kanbun(e)||os["Kangxi Radicals"](e)||os["Katakana Phonetic Extensions"](e)||os.Katakana(e)&&12540!==e||!(!os["Halfwidth and Fullwidth Forms"](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)||!(!os["Small Form Variants"](e)||e>=65112&&e<=65118||e>=65123&&e<=65126)||os["Unified Canadian Aboriginal Syllabics"](e)||os["Unified Canadian Aboriginal Syllabics Extended"](e)||os["Vertical Forms"](e)||os["Yijing Hexagram Symbols"](e)||os["Yi Syllables"](e)||os["Yi Radicals"](e))))}function us(e){return!(cs(e)||function(e){return!!(os["Latin-1 Supplement"](e)&&(167===e||169===e||174===e||177===e||188===e||189===e||190===e||215===e||247===e)||os["General Punctuation"](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)||os["Letterlike Symbols"](e)||os["Number Forms"](e)||os["Miscellaneous Technical"](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)||os["Control Pictures"](e)&&9251!==e||os["Optical Character Recognition"](e)||os["Enclosed Alphanumerics"](e)||os["Geometric Shapes"](e)||os["Miscellaneous Symbols"](e)&&!(e>=9754&&e<=9759)||os["Miscellaneous Symbols and Arrows"](e)&&(e>=11026&&e<=11055||e>=11088&&e<=11097||e>=11192&&e<=11243)||os["CJK Symbols and Punctuation"](e)||os.Katakana(e)||os["Private Use Area"](e)||os["CJK Compatibility Forms"](e)||os["Small Form Variants"](e)||os["Halfwidth and Fullwidth Forms"](e)||8734===e||8756===e||8757===e||e>=9984&&e<=10087||e>=10102&&e<=10131||65532===e||65533===e)}(e))}function hs(e){return os.Arabic(e)||os["Arabic Supplement"](e)||os["Arabic Extended-A"](e)||os["Arabic Presentation Forms-A"](e)||os["Arabic Presentation Forms-B"](e)}function ds(e){return e>=1424&&e<=2303||os["Arabic Presentation Forms-A"](e)||os["Arabic Presentation Forms-B"](e)}function ps(e,t){return!(!t&&ds(e)||e>=2304&&e<=3583||e>=3840&&e<=4255||os.Khmer(e))}function fs(e){for(const t of e)if(ds(t.charCodeAt(0)))return!0;return!1}const ms={unavailable:"unavailable",deferred:"deferred",loading:"loading",parsing:"parsing",parsed:"parsed",loaded:"loaded",error:"error"};let gs=null,_s=ms.unavailable,As=null;const ys=function(e){e&&"string"==typeof e&&e.indexOf("NetworkError")>-1&&(_s=ms.error),gs&&gs(e)};function vs(){xs.fire(new Yt("pluginStateChange",{pluginStatus:_s,pluginURL:As}))}const xs=new ni,bs=function(){return _s},ws=function(){if(_s!==ms.deferred||!As)throw new Error("rtl-text-plugin cannot be downloaded unless a pluginURL is specified");_s=ms.loading,vs(),As&&Ut({url:As},e=>{e?ys(e):(_s=ms.loaded,vs())})},Ts={applyArabicShaping:null,processBidirectionalText:null,processStyledBidirectionalText:null,isLoaded:()=>_s===ms.loaded||null!=Ts.applyArabicShaping,isLoading:()=>_s===ms.loading,setState(e){_s=e.pluginStatus,As=e.pluginURL},isParsing:()=>_s===ms.parsing,isParsed:()=>_s===ms.parsed,getPluginURL:()=>As};class Es{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(!ps(i.charCodeAt(0),t))return!1;return!0}(e,Ts.isLoaded())}}class Cs{constructor(e,t,i,n,r){this.property=e,this.value=t,this.expression=function(e,t,i,n,r){if(Lo(e))return new Zo(e,t);if(jo(e)||Array.isArray(e)&&e.length>0){const o=$o(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=li.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 Ss{constructor(e,t,i,n){this.property=e,this.value=new Cs(e,void 0,t,i,n)}transitioned(e,t){return new Is(this.property,this.value,t,Object.assign({},e.transition,this.transition),e.now)}untransitioned(){return new Is(this.property,this.value,null,{},0)}}class Bs{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 He(this._values[e].value.value)}setValue(e,t){this._values.hasOwnProperty(e)||(this._values[e]=new Ss(this._values[e].property,this._scope,this._options,this._iconImageUseTheme)),this._values[e].value=new Cs(this._values[e].property,null===t?void 0:He(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 i.hasOwnProperty(t)&&this.setValue(t,n)}}getTransition(e){return He(this._values[e].transition)}setTransition(e,t){this._values.hasOwnProperty(e)||(this._values[e]=new Ss(this._values[e].property)),this._values[e].transition=He(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 Ms(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 Ms(this._properties);for(const t of Object.keys(this._values))e._values[t]=this._values[t].untransitioned();return e}isIndoorDependent(){return this._isIndoorDependent}}class Is{constructor(e,t,i,n,r){const o=n.delay||0,s=n.duration||0;r=r||0,this.property=e,this.value=t,this.begin=r+o,this.end=this.begin+s,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":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":{"expression":{"type":"expression"},"stops":{"type":"array","value":"function_stop"},"base":{"type":"number","default":1,"minimum":0},"property":{"type":"string","default":"$zoom"},"type":{"type":"enum","values":{"identity":1,"exponential":1,"interval":1,"categorical":1},"default":"exponential"},"colorSpace":{"type":"enum","values":{"rgb":1,"lab":1,"hcl":1},"default":"rgb"},"default":{"type":"*"}},"function_stop":{"type":"array","minimum":0,"maximum":24,"value":["number","color"],"length":2},"expression":{"type":"array","value":"*","minimum":1},"fog":{"range":{"type":"array","default":[0.5,10],"minimum":-20,"maximum":20,"length":2,"value":"number","transition":true,"expression":{"interpolated":true,"parameters":["zoom","measure-light"],"relaxZoomRestriction":true}},"color":{"type":"color","default":"#ffffff","expression":{"interpolated":true,"parameters":["zoom","measure-light"],"relaxZoomRestriction":true},"use-theme":true,"transition":true},"high-color":{"type":"color","default":"#245cdf","expression":{"interpolated":true,"parameters":["zoom","measure-light"],"relaxZoomRestriction":true},"use-theme":true,"transition":true},"space-color":{"type":"color","default":["interpolate",["linear"],["zoom"],4,"#010b19",7,"#367ab9"],"expression":{"interpolated":true,"parameters":["zoom","measure-light"],"relaxZoomRestriction":true},"use-theme":true,"transition":true},"horizon-blend":{"type":"number","default":["interpolate",["linear"],["zoom"],4,0.2,7,0.1],"minimum":0,"maximum":1,"expression":{"interpolated":true,"parameters":["zoom","measure-light"],"relaxZoomRestriction":true},"transition":true},"star-intensity":{"type":"number","default":["interpolate",["linear"],["zoom"],5,0.35,6,0],"minimum":0,"maximum":1,"expression":{"interpolated":true,"parameters":["zoom","measure-light"],"relaxZoomRestriction":true},"transition":true},"vertical-range":{"type":"array","default":[0,0],"minimum":0,"length":2,"value":"number","transition":true,"expression":{"interpolated":true,"parameters":["zoom","measure-light"],"relaxZoomRestriction":true}}},"snow":{"density":{"type":"number","default":["interpolate",["linear"],["zoom"],11,0,13,0.85],"minimum":0,"maximum":1,"expression":{"interpolated":true,"parameters":["zoom","measure-light"],"relaxZoomRestriction":true},"transition":true},"intensity":{"type":"number","default":1,"minimum":0,"maximum":1,"expression":{"interpolated":true,"parameters":["zoom","measure-light"],"relaxZoomRestriction":true},"transition":true},"color":{"type":"color","default":"#ffffff","expression":{"interpolated":true,"parameters":["zoom","measure-light"],"relaxZoomRestriction":true},"use-theme":true,"transition":true},"opacity":{"type":"number","default":1,"minimum":0,"maximum":1,"expression":{"interpolated":true,"parameters":["zoom","measure-light"],"relaxZoomRestriction":true},"transition":true},"vignette":{"type":"number","default":["interpolate",["linear"],["zoom"],11,0,13,0.3],"minimum":0,"maximum":1,"expression":{"interpolated":true,"parameters":["zoom","measure-light"],"relaxZoomRestriction":true},"transition":true},"vignette-color":{"type":"color","default":"#ffffff","expression":{"interpolated":true,"parameters":["zoom","measure-light"],"relaxZoomRestriction":true},"use-theme":true,"transition":true},"center-thinning":{"type":"number","default":0.4,"minimum":0,"maximum":1,"expression":{"interpolated":true,"parameters":["zoom","measure-light"],"relaxZoomRestriction":true},"transition":true},"direction":{"type":"array","default":[0,50],"minimum":0,"maximum":360,"length":2,"value":"number","transition":true,"expression":{"interpolated":true,"parameters":["zoom","measure-light"],"relaxZoomRestriction":true}},"flake-size":{"type":"number","default":0.71,"minimum":0,"maximum":5,"expression":{"interpolated":true,"parameters":["zoom","measure-light"],"relaxZoomRestriction":true},"transition":true}},"rain":{"density":{"type":"number","default":["interpolate",["linear"],["zoom"],11,0,13,0.5],"minimum":0,"maximum":1,"expression":{"interpolated":true,"parameters":["zoom","measure-light"],"relaxZoomRestriction":true},"transition":true},"intensity":{"type":"number","default":1,"minimum":0,"maximum":1,"expression":{"interpolated":true,"parameters":["zoom","measure-light"],"relaxZoomRestriction":true},"transition":true},"color":{"type":"color","default":["interpolate",["linear"],["measure-light","brightness"],0,"#03113d",0.3,"#a8adbc"],"expression":{"interpolated":true,"parameters":["zoom","measure-light"],"relaxZoomRestriction":true},"use-theme":true,"transition":true},"opacity":{"type":"number","default":["interpolate",["linear"],["measure-light","brightness"],0,0.88,1,0.7],"minimum":0,"maximum":1,"expression":{"interpolated":true,"parameters":["zoom","measure-light"],"relaxZoomRestriction":true},"transition":true},"vignette":{"type":"number","default":["interpolate",["linear"],["zoom"],11,0,13,1],"minimum":0,"maximum":1,"expression":{"interpolated":true,"parameters":["zoom","measure-light"],"relaxZoomRestriction":true},"transition":true},"vignette-color":{"type":"color","default":["interpolate",["linear"],["measure-light","brightness"],0,"#001736",0.3,"#464646"],"expression":{"interpolated":true,"parameters":["zoom","measure-light"],"relaxZoomRestriction":true},"use-theme":true,"transition":true},"center-thinning":{"type":"number","default":0.57,"minimum":0,"maximum":1,"expression":{"interpolated":true,"parameters":["zoom","measure-light"],"relaxZoomRestriction":true},"transition":true},"direction":{"type":"array","default":[0,80],"minimum":0,"maximum":360,"length":2,"value":"number","transition":true,"expression":{"interpolated":true,"parameters":["zoom","measure-light"],"relaxZoomRestriction":true}},"droplet-size":{"type":"array","default":[2.6,18.2],"minimum":0,"maximum":50,"length":2,"value":"number","transition":true,"expression":{"interpolated":true,"parameters":["zoom","measure-light"],"relaxZoomRestriction":true}},"distortion-strength":{"type":"number","default":0.7,"minimum":0,"maximum":1,"expression":{"interpolated":true,"parameters":["zoom","measure-light"],"relaxZoomRestriction":true},"transition":true}},"camera":{"camera-projection":{"type":"enum","values":{"perspective":1,"orthographic":1},"transition":true,"expression":{"interpolated":true,"parameters":["zoom"]},"default":"perspective"}},"colorTheme":{"data":{"type":"string","expression":{}}},"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","transition":true,"expression":{"interpolated":true,"parameters":["zoom"]}},"color":{"type":"color","default":"#ffffff","expression":{"interpolated":true,"parameters":["zoom"]},"use-theme":true,"transition":true},"intensity":{"type":"number","default":0.5,"minimum":0,"maximum":1,"expression":{"interpolated":true,"parameters":["zoom"]},"transition":true}},"projection":{"name":{"type":"enum","values":{"albers":1,"equalEarth":1,"equirectangular":1,"lambertConformalConic":1,"mercator":1,"naturalEarth":1,"winkelTripel":1,"globe":1},"default":"mercator"},"center":{"type":"array","length":2,"value":"number","minimum":[-180,-90],"maximum":[180,90]},"parallels":{"type":"array","length":2,"value":"number","minimum":[-90,-90],"maximum":[90,90]}},"terrain":{"source":{"type":"string"},"exaggeration":{"type":"number","default":1,"minimum":0,"maximum":1000,"expression":{"interpolated":true,"parameters":["zoom"]},"transition":true}},"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,"transition":true,"expression":{"interpolated":true,"parameters":["zoom","feature","feature-state","measure-light"]},"property-type":"data-driven"},"fill-color":{"type":"color","default":"#000000","use-theme":true,"transition":true,"expression":{"interpolated":true,"parameters":["zoom","feature","feature-state","measure-light"]},"property-type":"data-driven"},"fill-outline-color":{"type":"color","use-theme":true,"transition":true,"expression":{"interpolated":true,"parameters":["zoom","feature","feature-state","measure-light"]},"property-type":"data-driven"},"fill-translate":{"type":"array","value":"number","length":2,"default":[0,0],"transition":true,"expression":{"interpolated":true,"parameters":["zoom"]}},"fill-translate-anchor":{"type":"enum","values":{"map":1,"viewport":1},"default":"map","expression":{"parameters":["zoom"]}},"fill-pattern":{"type":"resolvedImage","expression":{"parameters":["zoom","feature"]},"property-type":"data-driven"},"fill-pattern-cross-fade":{"type":"number","default":0,"minimum":0,"maximum":1,"expression":{"interpolated":true,"parameters":["zoom","measure-light"]}},"fill-emissive-strength":{"type":"number","default":0,"minimum":0,"transition":true,"expression":{"interpolated":true,"parameters":["zoom","measure-light"]}},"fill-z-offset":{"type":"number","default":0,"minimum":0,"transition":true,"expression":{"interpolated":true,"parameters":["zoom","feature"]},"property-type":"data-driven"},"fill-bridge-guard-rail-color":{"type":"color","default":"rgba(241, 236, 225, 255)","use-theme":true,"transition":true,"expression":{"interpolated":true,"parameters":["zoom","measure-light","feature"]},"property-type":"data-driven"},"fill-tunnel-structure-color":{"type":"color","default":"rgba(241, 236, 225, 255)","use-theme":true,"transition":true,"expression":{"interpolated":true,"parameters":["zoom","measure-light","feature"]},"property-type":"data-driven"}},"paint_fill-extrusion":{"fill-extrusion-opacity":{"type":"number","default":1,"minimum":0,"maximum":1,"transition":true,"expression":{"interpolated":true,"parameters":["zoom"]}},"fill-extrusion-color":{"type":"color","default":"#000000","use-theme":true,"transition":true,"expression":{"interpolated":true,"parameters":["zoom","feature","feature-state","measure-light"]},"property-type":"data-driven"},"fill-extrusion-translate":{"type":"array","value":"number","length":2,"default":[0,0],"transition":true,"expression":{"interpolated":true,"parameters":["zoom"]}},"fill-extrusion-translate-anchor":{"type":"enum","values":{"map":1,"viewport":1},"default":"map","expression":{"parameters":["zoom"]}},"fill-extrusion-pattern":{"type":"resolvedImage","expression":{"parameters":["zoom","feature"]},"property-type":"data-driven"},"fill-extrusion-pattern-cross-fade":{"type":"number","default":0,"minimum":0,"maximum":1,"expression":{"interpolated":true,"parameters":["zoom","measure-light"]}},"fill-extrusion-height":{"type":"number","default":0,"minimum":0,"transition":true,"expression":{"interpolated":true,"parameters":["zoom","feature","feature-state"]},"property-type":"data-driven"},"fill-extrusion-base":{"type":"number","default":0,"minimum":0,"transition":true,"expression":{"interpolated":true,"parameters":["zoom","feature","feature-state"]},"property-type":"data-driven"},"fill-extrusion-height-alignment":{"type":"enum","values":{"terrain":1,"flat":1},"default":"flat"},"fill-extrusion-base-alignment":{"type":"enum","values":{"terrain":1,"flat":1},"default":"terrain"},"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":true,"parameters":["zoom"]},"transition":true},"fill-extrusion-ambient-occlusion-radius":{"type":"number","default":3,"minimum":0,"expression":{"interpolated":true,"parameters":["zoom"]},"transition":true},"fill-extrusion-ambient-occlusion-wall-radius":{"type":"number","default":3,"minimum":0,"expression":{"interpolated":true,"parameters":["zoom"]},"transition":true},"fill-extrusion-ambient-occlusion-ground-radius":{"type":"number","default":3,"minimum":0,"expression":{"interpolated":true,"parameters":["zoom"]},"transition":true},"fill-extrusion-ambient-occlusion-ground-attenuation":{"type":"number","default":0.69,"minimum":0,"maximum":1,"transition":true,"expression":{"interpolated":true,"parameters":["zoom"]}},"fill-extrusion-flood-light-color":{"type":"color","default":"#ffffff","use-theme":true,"transition":true,"expression":{"interpolated":true,"parameters":["zoom","measure-light"]}},"fill-extrusion-flood-light-intensity":{"type":"number","default":0,"minimum":0,"maximum":1,"transition":true,"expression":{"interpolated":true,"parameters":["zoom","measure-light"]}},"fill-extrusion-flood-light-wall-radius":{"property-type":"data-driven","type":"number","default":0,"minimum":0,"transition":true,"expression":{"interpolated":true,"parameters":["feature","feature-state"]}},"fill-extrusion-flood-light-ground-radius":{"property-type":"data-driven","type":"number","default":0,"transition":true,"expression":{"interpolated":true,"parameters":["feature","feature-state"]}},"fill-extrusion-flood-light-ground-attenuation":{"type":"number","default":0.69,"minimum":0,"maximum":1,"transition":true,"expression":{"interpolated":true,"parameters":["zoom"]}},"fill-extrusion-vertical-scale":{"type":"number","default":1,"minimum":0,"transition":true,"expression":{"interpolated":true,"parameters":["zoom"]}},"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":{}},"fill-extrusion-emissive-strength":{"type":"number","default":0,"minimum":0,"transition":true,"expression":{"interpolated":true,"parameters":["zoom","measure-light","feature-state"]},"property-type":"data-driven"},"fill-extrusion-line-width":{"type":"number","default":0,"minimum":0,"transition":true,"expression":{"interpolated":true,"parameters":["zoom","feature","feature-state","measure-light"]},"property-type":"data-driven"},"fill-extrusion-cast-shadows":{"type":"boolean","default":true}},"paint_building":{"building-opacity":{"type":"number","default":1,"minimum":0,"maximum":1,"transition":true,"expression":{"interpolated":true,"parameters":["zoom"]}},"building-ambient-occlusion-intensity":{"type":"number","default":0,"minimum":0,"maximum":1,"expression":{"parameters":[]},"transition":true},"building-ambient-occlusion-ground-intensity":{"type":"number","default":0,"minimum":0,"maximum":1,"expression":{"interpolated":true,"parameters":["zoom"]},"transition":true},"building-ambient-occlusion-ground-radius":{"type":"number","default":3,"minimum":0,"expression":{"interpolated":true,"parameters":["zoom"]},"transition":true},"building-ambient-occlusion-ground-attenuation":{"type":"number","default":0.69,"minimum":0,"maximum":1,"transition":true,"expression":{"interpolated":true,"parameters":["zoom"]}},"building-vertical-scale":{"type":"number","default":1,"minimum":0,"transition":true,"expression":{"interpolated":true,"parameters":["zoom"]}},"building-cast-shadows":{"type":"boolean","default":true},"building-color":{"type":"color","default":"rgba(193, 154, 127, 1)","use-theme":true,"expression":{"interpolated":true,"parameters":["feature","feature-state","measure-light"]},"property-type":"data-driven"},"building-emissive-strength":{"type":"number","default":0,"minimum":0,"maximum":5,"expression":{"interpolated":true,"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":true,"parameters":["measure-light","zoom"]}},"building-cutoff-fade-range":{"type":"number","default":0,"minimum":0,"maximum":1,"expression":{}},"building-flood-light-color":{"type":"color","default":"#ffffff","use-theme":true,"transition":true,"expression":{"interpolated":true,"parameters":["zoom","measure-light"]}},"building-flood-light-intensity":{"type":"number","default":0,"minimum":0,"maximum":1,"transition":true,"expression":{"interpolated":true,"parameters":["zoom","measure-light"]}},"building-flood-light-ground-attenuation":{"type":"number","default":0.69,"minimum":0,"maximum":1,"transition":true,"expression":{"interpolated":true,"parameters":["zoom"]}}},"paint_line":{"line-opacity":{"type":"number","default":1,"minimum":0,"maximum":1,"transition":true,"expression":{"interpolated":true,"parameters":["zoom","feature","feature-state","measure-light"]},"property-type":"data-driven"},"line-color":{"type":"color","default":"#000000","use-theme":true,"transition":true,"expression":{"interpolated":true,"parameters":["zoom","feature","feature-state","measure-light"]},"property-type":"data-driven"},"line-translate":{"type":"array","value":"number","length":2,"default":[0,0],"transition":true,"expression":{"interpolated":true,"parameters":["zoom"]}},"line-translate-anchor":{"type":"enum","values":{"map":1,"viewport":1},"default":"map","expression":{"parameters":["zoom"]}},"line-width":{"type":"number","default":1,"minimum":0,"transition":true,"expression":{"interpolated":true,"parameters":["zoom","feature","feature-state","measure-light","line-progress"]},"property-type":"data-driven"},"line-gap-width":{"type":"number","default":0,"minimum":0,"transition":true,"expression":{"interpolated":true,"parameters":["zoom","feature","feature-state","measure-light"]},"property-type":"data-driven"},"line-offset":{"type":"number","default":0,"transition":true,"expression":{"interpolated":true,"parameters":["zoom","feature","feature-state","measure-light"]},"property-type":"data-driven"},"line-blur":{"type":"number","default":0,"minimum":0,"transition":true,"expression":{"interpolated":true,"parameters":["zoom","feature","feature-state","measure-light"]},"property-type":"data-driven"},"line-dasharray":{"type":"array","value":"number","minimum":0,"expression":{"parameters":["zoom","feature"]},"property-type":"data-driven"},"line-pattern":{"type":"resolvedImage","expression":{"parameters":["zoom","feature"]},"property-type":"data-driven"},"line-pattern-cross-fade":{"type":"number","default":0,"minimum":0,"maximum":1,"expression":{"interpolated":true,"parameters":["zoom","measure-light"]}},"line-gradient":{"type":"color","use-theme":true,"expression":{"interpolated":true,"parameters":["line-progress"]}},"line-trim-offset":{"type":"array","value":"number","length":2,"default":[0,0],"minimum":[0,0],"maximum":[1,1]},"line-trim-fade-range":{"type":"array","value":"number","length":2,"default":[0,0],"minimum":[0,0],"maximum":[1,1],"expression":{"interpolated":true,"parameters":["zoom","measure-light"]}},"line-trim-color":{"type":"color","default":"transparent","use-theme":true,"transition":true,"expression":{"interpolated":true,"parameters":["zoom","measure-light"]}},"line-emissive-strength":{"type":"number","default":0,"minimum":0,"transition":true,"expression":{"interpolated":true,"parameters":["zoom","measure-light"]}},"line-border-width":{"type":"number","default":0,"minimum":0,"transition":true,"expression":{"interpolated":true,"parameters":["zoom","feature","feature-state"]},"property-type":"data-driven"},"line-border-color":{"type":"color","default":"rgba(0, 0, 0, 0)","use-theme":true,"transition":true,"expression":{"interpolated":true,"parameters":["zoom","feature","feature-state"]},"property-type":"data-driven"},"line-occlusion-opacity":{"type":"number","default":0,"minimum":0,"maximum":1,"expression":{"interpolated":true,"parameters":["zoom"]},"transition":true}},"paint_circle":{"circle-radius":{"type":"number","default":5,"minimum":0,"transition":true,"expression":{"interpolated":true,"parameters":["zoom","feature","feature-state","measure-light"]},"property-type":"data-driven"},"circle-color":{"type":"color","default":"#000000","use-theme":true,"transition":true,"expression":{"interpolated":true,"parameters":["zoom","feature","feature-state","measure-light"]},"property-type":"data-driven"},"circle-blur":{"type":"number","default":0,"transition":true,"expression":{"interpolated":true,"parameters":["zoom","feature","feature-state","measure-light"]},"property-type":"data-driven"},"circle-opacity":{"type":"number","default":1,"minimum":0,"maximum":1,"transition":true,"expression":{"interpolated":true,"parameters":["zoom","feature","feature-state","measure-light"]},"property-type":"data-driven"},"circle-translate":{"type":"array","value":"number","length":2,"default":[0,0],"transition":true,"expression":{"interpolated":true,"parameters":["zoom"]}},"circle-translate-anchor":{"type":"enum","values":{"map":1,"viewport":1},"default":"map","expression":{"parameters":["zoom"]}},"circle-pitch-scale":{"type":"enum","values":{"map":1,"viewport":1},"default":"map","expression":{"parameters":["zoom"]}},"circle-pitch-alignment":{"type":"enum","values":{"map":1,"viewport":1},"default":"viewport","expression":{"parameters":["zoom"]}},"circle-stroke-width":{"type":"number","default":0,"minimum":0,"transition":true,"expression":{"interpolated":true,"parameters":["zoom","feature","feature-state","measure-light"]},"property-type":"data-driven"},"circle-stroke-color":{"type":"color","default":"#000000","use-theme":true,"transition":true,"expression":{"interpolated":true,"parameters":["zoom","feature","feature-state","measure-light"]},"property-type":"data-driven"},"circle-stroke-opacity":{"type":"number","default":1,"minimum":0,"maximum":1,"transition":true,"expression":{"interpolated":true,"parameters":["zoom","feature","feature-state","measure-light"]},"property-type":"data-driven"},"circle-emissive-strength":{"type":"number","default":0,"minimum":0,"transition":true,"expression":{"interpolated":true,"parameters":["zoom","measure-light"]}}},"paint_heatmap":{"heatmap-radius":{"type":"number","default":30,"minimum":1,"transition":true,"expression":{"interpolated":true,"parameters":["zoom","feature","feature-state","measure-light"]},"property-type":"data-driven"},"heatmap-weight":{"type":"number","default":1,"minimum":0,"expression":{"interpolated":true,"parameters":["zoom","feature","feature-state","measure-light"]},"property-type":"data-driven"},"heatmap-intensity":{"type":"number","default":1,"minimum":0,"transition":true,"expression":{"interpolated":true,"parameters":["zoom"]}},"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"],"use-theme":true,"expression":{"interpolated":true,"parameters":["heatmap-density"]}},"heatmap-opacity":{"type":"number","default":1,"minimum":0,"maximum":1,"transition":true,"expression":{"interpolated":true,"parameters":["zoom"]}}},"paint_symbol":{"icon-opacity":{"type":"number","default":1,"minimum":0,"maximum":1,"transition":true,"expression":{"interpolated":true,"parameters":["zoom","feature","feature-state","measure-light"]},"property-type":"data-driven"},"icon-occlusion-opacity":{"type":"number","minimum":0,"maximum":1,"default":0,"transition":true,"expression":{"interpolated":true,"parameters":["zoom","feature","feature-state","measure-light"]},"property-type":"data-driven"},"icon-emissive-strength":{"type":"number","default":1,"minimum":0,"transition":true,"expression":{"interpolated":true,"parameters":["zoom","measure-light","feature-state"]},"property-type":"data-driven"},"text-emissive-strength":{"type":"number","default":1,"minimum":0,"transition":true,"expression":{"interpolated":true,"parameters":["zoom","measure-light","feature-state"]},"property-type":"data-driven"},"icon-color":{"type":"color","default":"#000000","use-theme":true,"transition":true,"expression":{"interpolated":true,"parameters":["zoom","feature","feature-state","measure-light"]},"property-type":"data-driven"},"icon-halo-color":{"type":"color","default":"rgba(0, 0, 0, 0)","use-theme":true,"transition":true,"expression":{"interpolated":true,"parameters":["zoom","feature","feature-state","measure-light"]},"property-type":"data-driven"},"icon-halo-width":{"type":"number","default":0,"minimum":0,"transition":true,"expression":{"interpolated":true,"parameters":["zoom","feature","feature-state","measure-light"]},"property-type":"data-driven"},"icon-halo-blur":{"type":"number","default":0,"minimum":0,"transition":true,"expression":{"interpolated":true,"parameters":["zoom","feature","feature-state","measure-light"]},"property-type":"data-driven"},"icon-translate":{"type":"array","value":"number","length":2,"default":[0,0],"transition":true,"expression":{"interpolated":true,"parameters":["zoom"]}},"icon-translate-anchor":{"type":"enum","values":{"map":1,"viewport":1},"default":"map","expression":{"parameters":["zoom"]}},"icon-image-cross-fade":{"type":"number","default":0,"minimum":0,"maximum":1,"expression":{"interpolated":true,"parameters":["zoom","measure-light"]}},"text-opacity":{"type":"number","default":1,"minimum":0,"maximum":1,"transition":true,"expression":{"interpolated":true,"parameters":["zoom","feature","feature-state","measure-light"]},"property-type":"data-driven"},"text-occlusion-opacity":{"type":"number","minimum":0,"maximum":1,"default":0,"transition":true,"expression":{"interpolated":true,"parameters":["zoom","feature","feature-state","measure-light"]},"property-type":"data-driven"},"text-color":{"type":"color","default":"#000000","use-theme":true,"transition":true,"overridable":true,"expression":{"interpolated":true,"parameters":["zoom","feature","feature-state","measure-light"]},"property-type":"data-driven"},"text-halo-color":{"type":"color","default":"rgba(0, 0, 0, 0)","use-theme":true,"transition":true,"expression":{"interpolated":true,"parameters":["zoom","feature","feature-state","measure-light"]},"property-type":"data-driven"},"text-halo-width":{"type":"number","default":0,"minimum":0,"transition":true,"expression":{"interpolated":true,"parameters":["zoom","feature","feature-state","measure-light"]},"property-type":"data-driven"},"text-halo-blur":{"type":"number","default":0,"minimum":0,"transition":true,"expression":{"interpolated":true,"parameters":["zoom","feature","feature-state","measure-light"]},"property-type":"data-driven"},"text-translate":{"type":"array","value":"number","length":2,"default":[0,0],"transition":true,"expression":{"interpolated":true,"parameters":["zoom"]}},"text-translate-anchor":{"type":"enum","values":{"map":1,"viewport":1},"default":"map","expression":{"parameters":["zoom"]}},"icon-color-saturation":{"type":"number","default":0,"minimum":-1,"maximum":1,"expression":{}},"icon-color-contrast":{"type":"number","default":0,"minimum":-1,"maximum":1,"expression":{}},"icon-color-brightness-min":{"type":"number","default":0,"minimum":0,"maximum":1,"expression":{}},"icon-color-brightness-max":{"type":"number","default":1,"minimum":0,"maximum":1,"expression":{}},"symbol-z-offset":{"type":"number","default":0,"minimum":0,"transition":true,"expression":{"interpolated":true,"parameters":["zoom","feature"]},"property-type":"data-driven"}},"paint_raster":{"raster-opacity":{"type":"number","default":1,"minimum":0,"maximum":1,"transition":true,"expression":{"interpolated":true,"parameters":["zoom"]}},"raster-color":{"type":"color","use-theme":true,"expression":{"interpolated":true,"parameters":["raster-value"]}},"raster-color-mix":{"type":"array","default":[0.2126,0.7152,0.0722,0],"length":4,"value":"number","transition":true,"expression":{"interpolated":true,"parameters":["zoom"]}},"raster-color-range":{"type":"array","length":2,"value":"number","transition":true,"expression":{"interpolated":true,"parameters":["zoom"]}},"raster-hue-rotate":{"type":"number","default":0,"period":360,"transition":true,"expression":{"interpolated":true,"parameters":["zoom"]}},"raster-brightness-min":{"type":"number","default":0,"minimum":0,"maximum":1,"transition":true,"expression":{"interpolated":true,"parameters":["zoom"]}},"raster-brightness-max":{"type":"number","default":1,"minimum":0,"maximum":1,"transition":true,"expression":{"interpolated":true,"parameters":["zoom"]}},"raster-saturation":{"type":"number","default":0,"minimum":-1,"maximum":1,"transition":true,"expression":{"interpolated":true,"parameters":["zoom"]}},"raster-contrast":{"type":"number","default":0,"minimum":-1,"maximum":1,"transition":true,"expression":{"interpolated":true,"parameters":["zoom"]}},"raster-resampling":{"type":"enum","values":{"linear":1,"nearest":1},"default":"linear","expression":{"parameters":["zoom"]}},"raster-fade-duration":{"type":"number","default":300,"minimum":0,"expression":{"interpolated":true,"parameters":["zoom"]}},"raster-emissive-strength":{"type":"number","default":0,"minimum":0,"transition":true,"expression":{"interpolated":true,"parameters":["zoom","measure-light"]}},"raster-array-band":{"type":"string"},"raster-elevation":{"type":"number","default":0,"minimum":0,"transition":true,"expression":{"interpolated":true,"parameters":["zoom"]}}},"paint_raster-particle":{"raster-particle-array-band":{"type":"string"},"raster-particle-count":{"type":"number","default":512,"minimum":1},"raster-particle-color":{"type":"color","use-theme":true,"expression":{"interpolated":true,"parameters":["raster-particle-speed"]}},"raster-particle-max-speed":{"type":"number","default":1,"minimum":1},"raster-particle-speed-factor":{"type":"number","default":0.2,"minimum":0,"maximum":1,"transition":true,"expression":{"interpolated":true,"parameters":["zoom"]}},"raster-particle-fade-opacity-factor":{"type":"number","default":0.98,"minimum":0,"maximum":1,"transition":true,"expression":{"interpolated":true,"parameters":["zoom"]}},"raster-particle-reset-rate-factor":{"type":"number","default":0.8,"minimum":0,"maximum":1},"raster-particle-elevation":{"type":"number","default":0,"minimum":0,"transition":true,"expression":{"interpolated":true,"parameters":["zoom"]}}},"paint_hillshade":{"hillshade-illumination-direction":{"type":"number","default":335,"minimum":0,"maximum":359,"expression":{"interpolated":true,"parameters":["zoom"]}},"hillshade-illumination-anchor":{"type":"enum","values":{"map":1,"viewport":1},"default":"viewport","expression":{"parameters":["zoom"]}},"hillshade-exaggeration":{"type":"number","default":0.5,"minimum":0,"maximum":1,"transition":true,"expression":{"interpolated":true,"parameters":["zoom"]}},"hillshade-shadow-color":{"type":"color","default":"#000000","use-theme":true,"transition":true,"expression":{"interpolated":true,"parameters":["zoom","measure-light"]}},"hillshade-highlight-color":{"type":"color","default":"#FFFFFF","use-theme":true,"transition":true,"expression":{"interpolated":true,"parameters":["zoom","measure-light"]}},"hillshade-accent-color":{"type":"color","default":"#000000","use-theme":true,"transition":true,"expression":{"interpolated":true,"parameters":["zoom","measure-light"]}},"hillshade-emissive-strength":{"type":"number","default":0,"minimum":0,"transition":true,"expression":{"interpolated":true,"parameters":["zoom","measure-light"]}}},"paint_background":{"background-pitch-alignment":{"type":"enum","values":{"map":1,"viewport":1},"default":"map","expression":{"parameters":[]}},"background-color":{"type":"color","default":"#000000","use-theme":true,"transition":true,"expression":{"interpolated":true,"parameters":["zoom"]}},"background-pattern":{"type":"resolvedImage","expression":{"parameters":["zoom"]}},"background-opacity":{"type":"number","default":1,"minimum":0,"maximum":1,"transition":true,"expression":{"interpolated":true,"parameters":["zoom"]}},"background-emissive-strength":{"type":"number","default":0,"minimum":0,"transition":true,"expression":{"interpolated":true,"parameters":["zoom","measure-light"]}}},"paint_sky":{"sky-type":{"type":"enum","values":{"gradient":1,"atmosphere":1},"default":"atmosphere","expression":{"parameters":["zoom"]}},"sky-atmosphere-sun":{"type":"array","value":"number","length":2,"minimum":[0,0],"maximum":[360,180],"expression":{"parameters":["zoom"]}},"sky-atmosphere-sun-intensity":{"type":"number","default":10,"minimum":0,"maximum":100},"sky-gradient-center":{"type":"array","value":"number","default":[0,0],"length":2,"minimum":[0,0],"maximum":[360,180],"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"],"use-theme":true,"expression":{"interpolated":true,"parameters":["sky-radial-progress"]}},"sky-atmosphere-halo-color":{"type":"color","default":"white","use-theme":true},"sky-atmosphere-color":{"type":"color","default":"white","use-theme":true},"sky-opacity":{"type":"number","default":1,"minimum":0,"maximum":1,"transition":true,"expression":{"interpolated":true,"parameters":["zoom"]}}},"paint_model":{"model-opacity":{"type":"number","default":1,"minimum":0,"maximum":1,"transition":true,"expression":{"interpolated":true,"parameters":["feature","feature-state","zoom"]},"property-type":"data-driven"},"model-rotation":{"type":"array","value":"number","length":3,"default":[0,0,0],"period":360,"property-type":"data-driven","expression":{"interpolated":true,"parameters":["feature","feature-state","zoom"]},"transition":true},"model-scale":{"type":"array","value":"number","length":3,"default":[1,1,1],"property-type":"data-driven","expression":{"interpolated":true,"parameters":["feature","feature-state","zoom"]},"transition":true},"model-translation":{"type":"array","value":"number","length":3,"default":[0,0,0],"property-type":"data-driven","expression":{"interpolated":true,"parameters":["feature","feature-state","zoom"]},"transition":true},"model-color":{"type":"color","default":"#ffffff","property-type":"data-driven","expression":{"interpolated":true,"parameters":["feature","feature-state","measure-light","zoom"]},"use-theme":true,"transition":true},"model-color-mix-intensity":{"type":"number","property-type":"data-driven","default":0,"minimum":0,"maximum":1,"expression":{"interpolated":true,"parameters":["feature","feature-state","measure-light"]},"transition":true},"model-type":{"type":"enum","values":{"common-3d":1,"location-indicator":1},"default":"common-3d"},"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":true,"parameters":["zoom"]},"transition":true},"model-emissive-strength":{"type":"number","property-type":"data-driven","default":0,"minimum":0,"maximum":5,"expression":{"interpolated":true,"parameters":["feature","feature-state","measure-light"]},"transition":true},"model-roughness":{"type":"number","default":1,"minimum":0,"maximum":1,"property-type":"data-driven","expression":{"interpolated":true,"parameters":["feature","feature-state"]},"transition":true},"model-height-based-emissive-strength-multiplier":{"type":"array","default":[1,1,1,1,0],"length":5,"value":"number","property-type":"data-driven","expression":{"interpolated":true,"parameters":["feature","feature-state","measure-light"]},"transition":true},"model-cutoff-fade-range":{"type":"number","default":0,"minimum":0,"maximum":1,"expression":{}},"model-front-cutoff":{"type":"array","value":"number","expression":{"interpolated":true,"parameters":["zoom"]},"length":3,"default":[0,0,1],"minimum":[0,0,0],"maximum":[1,1,1]},"model-elevation-reference":{"type":"enum","values":{"sea":1,"ground":1,"hd-road-markup":1},"default":"ground","expression":{}}},"transition":{"duration":{"type":"number","default":300,"minimum":0},"delay":{"type":"number","default":0,"minimum":0}},"promoteId":{"*":{"type":"*"}}}');function Us(e){return e instanceof Number||e instanceof String||e instanceof Boolean?e.valueOf():e}function Ns(e){if(Array.isArray(e))return e.map(Ns);if(e instanceof Object&&!(e instanceof Number||e instanceof String||e instanceof Boolean)){const t={};for(const i in e)t[i]=Ns(e[i]);return t}return Us(e)}function Vs(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(!Vs(t)&&"boolean"!=typeof t)return!1;return!0;default:return!0}}function js(e,t="",i=null,n="fill"){if(null==e)return{filter:()=>!0,needGeometry:!1,needFeature:!1};Vs(e)||(e=qs(e));const r=e;let o=!0;try{o=function(e){if(!Qs(e))return e;let t=Ns(e);return Hs(t),t=Gs(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 s=null,a=null;if("background"!==n&&"sky"!==n&&"slot"!==n){a=zs[`filter_${n}`];const e=Go(o,a,t,i);if("error"===e.result)throw new Error(e.value.map(e=>`${e.key}: ${e.message}`).join(", "));s=(t,i,n)=>e.value.evaluate(t,i,{},n)}let l=null,c=null;if(o!==r){const e=Go(r,a,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),c=!_r(e.value.expression)}return{filter:s,dynamicFilter:l||void 0,needGeometry:Ws(o),needFeature:!!c}}function Gs(e){if(!Array.isArray(e))return e;const t=function(e){if($s.has(e[0]))for(let t=1;tGs(e))}function Hs(e){let t=!1;const i=[];if("case"===e[0]){for(let n=1;n",">=","<","<=","to-boolean"]);function Zs(e,t){return et?1:0}function Ws(e){if(!Array.isArray(e))return!1;if("within"===e[0]||"distance"===e[0])return!0;for(let t=1;t"===t||"<="===t||">="===t?Ks(e[1],e[2],t):"any"===t?(i=e.slice(1),["any"].concat(i.map(qs))):"all"===t?["all"].concat(e.slice(1).map(qs)):"none"===t?["all"].concat(e.slice(1).map(qs).map(Ys)):"in"===t?Xs(e[1],e.slice(2)):"!in"===t?Ys(Xs(e[1],e.slice(2))):"has"===t?Js(e[1]):"!has"!==t||Ys(Js(e[1]));var i}function Ks(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 Xs(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(Zs)]]:["filter-in-small",e,["literal",t]]}}function Js(e){switch(e){case"$type":return!0;case"$id":return["filter-has-id"];default:return["filter-has",e]}}function Ys(e){return["!",e]}const ea="";function ta(e,t){return t?`${e}${ea}${t}`:e}let ia;const na=()=>ia||(ia=new Os({"icon-size":new ks(zs.layout_symbol["icon-size"]),"icon-image":new ks(zs.layout_symbol["icon-image"]),"icon-rotate":new ks(zs.layout_symbol["icon-rotate"]),"icon-offset":new ks(zs.layout_symbol["icon-offset"])}));class ra{constructor(e,t,i,n,r,o){this.cachedIconPrimary=null;const s=Go(e,zs.appearance.condition);if("success"===s.result&&(this.condition=s.value),this.name=t,i){this.properties=new Ls(na()),this.unevaluatedLayout=new Ps(na(),n,r,o);for(const e in i)this.unevaluatedLayout.setValue(e,i[e])}}hasCachedIconPrimary(){return null!==this.cachedIconPrimary}setCachedIconPrimary(e){this.cachedIconPrimary=e}getCachedIconPrimary(){return this.cachedIconPrimary}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}getProperty(e){return this.properties.get(e)}getUnevaluatedProperties(){return this.unevaluatedLayout}recalculate(e,t,i){this.unevaluatedLayout&&(this.properties=this.unevaluatedLayout.possiblyEvaluate(e,void 0,t,i))}serialize(){const e={};return e.condition=this.condition.expression.serialize(),this.name&&(e.name=this.name),this.unevaluatedLayout&&(e.properties=this.unevaluatedLayout.serialize()),e}}const oa="-transition",sa=new Set(["fill","line","background","hillshade","raster"]);class aa extends ni{constructor(e,t,i,n,r,o){if(super(),this.id=e.id,this.fqid=ta(this.id,i),this.type=e.type,this.scope=i,this.lut=n,this.options=r,this.iconImageUseTheme=o,this.appearances=new Array,this._featureFilter={filter:()=>!0,needGeometry:!1,needFeature:!1},this._filterCompiled=!1,this.expressionDependencies={isIndoorDependent:!1,configDependencies:new Set},"custom"!==e.type){if(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;const t=Go(this.filter,zs[`filter_${e.type}`]);"error"!==t.result&&(this.expressionDependencies.configDependencies=new Set([...this.expressionDependencies.configDependencies,...t.value.configDependencies]),this.expressionDependencies.isIndoorDependent=this.expressionDependencies.isIndoorDependent||t.value.isIndoorDependent)}if(e.slot&&(this.slot=e.slot),e.appearances&&this.setAppearances(e.appearances),t.layout&&(this._unevaluatedLayout=new Ps(t.layout,this.scope,r,this.iconImageUseTheme),this.expressionDependencies.configDependencies=new Set([...this.expressionDependencies.configDependencies,...this._unevaluatedLayout.configDependencies]),this.expressionDependencies.isIndoorDependent=this.expressionDependencies.isIndoorDependent||this._unevaluatedLayout.isIndoorDependent()),t.paint){this._transitionablePaint=new Bs(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.expressionDependencies.configDependencies=new Set([...this.expressionDependencies.configDependencies,...this._transitionablePaint.configDependencies]),this.expressionDependencies.isIndoorDependent=this.expressionDependencies.isIndoorDependent||this._transitionablePaint.isIndoorDependent(),this._transitioningPaint=this._transitionablePaint.untransitioned(),this.paint=new Ls(t.paint)}}}onAdd(e){}onRemove(e){}isDraped(e){return!this.is3D(!0)&&sa.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),this.expressionDependencies.configDependencies=new Set([...this.expressionDependencies.configDependencies,...i.configDependencies]),this.expressionDependencies.isIndoorDependent=this.expressionDependencies.isIndoorDependent||i.isIndoorDependent(),"visibility"===e&&this.possiblyEvaluateVisibility())}setAppearances(e){this.appearances=[],e.forEach(e=>{this.appearances.push(new ra(e.condition,e.name,e.properties,this.scope,this.options,this.iconImageUseTheme))})}possiblyEvaluateVisibility(){this._unevaluatedLayout._values.visibility&&(this.visibility=this._unevaluatedLayout._values.visibility.possiblyEvaluate({zoom:0}))}getPaintProperty(e){return e.endsWith(oa)?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(oa)){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(),s=r.value;i.setValue(e,t),this.expressionDependencies.configDependencies=new Set([...this.expressionDependencies.configDependencies,...i.configDependencies]),this.expressionDependencies.isIndoorDependent=this.expressionDependencies.isIndoorDependent||i.isIndoorDependent(),this._handleSpecialPaintPropertyUpdate(e);const a=i._values[e].value,l=a.isDataDriven(),c=e.endsWith("pattern")||"line-dasharray"===e;return l||o||c||this._handleOverridablePaintPropertyUpdate(e,s,a)}_handleSpecialPaintPropertyUpdate(e){}getProgramIds(){return null}getDefaultProgramParams(e,t,i){return null}_handleOverridablePaintPropertyUpdate(e,t,i){return!1}isHidden(e){return!!(this.minzoom&&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())),Ge(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}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 Rs&&Io(t.property.specification)&&("source"===t.value.kind||"composite"===t.value.kind)&&t.value.isStateDependent)return!0}for(const e of this.appearances)if(!Ar(e.condition.expression))return!0;return!1}compileFilter(e){this._filterCompiled||(this._featureFilter=js(this.filter,this.scope,e),this._filterCompiled=!0)}invalidateCompiledFilter(){this._filterCompiled=!1}dynamicFilter(){return this._featureFilter.dynamicFilter}dynamicFilterNeedsFeature(){return this._featureFilter.needFeature}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,s,a,l){}}const la={Int8:Int8Array,Uint8:Uint8Array,Int16:Int16Array,Uint16:Uint16Array,Int32:Int32Array,Uint32:Uint32Array,Float32:Float32Array};class ca{constructor(e,t){this._structArray=e,this._pos1=t*this.size,this._pos2=this._pos1/2,this._pos4=this._pos1/4,this._pos8=this._pos1/8}}class ua{constructor(){this.capacity=-1,this.resize(0)}static serialize(e,t){return e._trim(),t&&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,t.capacity=e.arrayBuffer.byteLength/t.bytesPerElement,t._refreshViews(),t}_trim(){this.length!==this.capacity&&(this.capacity=this.length,this.arrayBuffer=this.arrayBuffer.slice(0,this.length*this.bytesPerElement),this._refreshViews())}clear(){this.length=0}resize(e){this.reserve(e),this.length=e}reserve(e){if(e>this.capacity){this.capacity=Math.max(e,Math.floor(5*this.capacity),128),this.arrayBuffer=new ArrayBuffer(this.capacity*this.bytesPerElement);const t=this.uint8;this._refreshViews(),t&&this.uint8.set(t)}}_refreshViews(){throw new Error("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 ha(e,t=1){let i=0,n=0;return{members:e.map(e=>{const r=la[e.type].BYTES_PER_ELEMENT,o=i=da(i,Math.max(t,r)),s=e.components||1;return n=Math.max(n,r),i+=r*s,{name:e.name,type:e.type,components:s,offset:o}}),size:da(i,Math.max(n,t)),alignment:t}}function da(e,t){return Math.ceil(e/t)*t}class pa extends ua{_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}}pa.prototype.bytesPerElement=4,es(pa,"StructArrayLayout2i4");class fa extends ua{_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}}fa.prototype.bytesPerElement=6,es(fa,"StructArrayLayout3i6");class ma extends ua{_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}}ma.prototype.bytesPerElement=8,es(ma,"StructArrayLayout4i8");class ga extends ua{_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}}ga.prototype.bytesPerElement=4,es(ga,"StructArrayLayout1f4");class _a extends ua{_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}}_a.prototype.bytesPerElement=8,es(_a,"StructArrayLayout2i1f8");class Aa extends ua{_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}}Aa.prototype.bytesPerElement=8,es(Aa,"StructArrayLayout3i8");class ya extends ua{_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 s=5*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,e}}ya.prototype.bytesPerElement=10,es(ya,"StructArrayLayout5i10");class va extends ua{_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,s){const a=this.length;return this.resize(a+1),this.emplace(a,e,t,i,n,r,o,s)}emplace(e,t,i,n,r,o,s,a){const l=6*e,c=12*e,u=3*e;return this.int16[l+0]=t,this.int16[l+1]=i,this.uint8[c+4]=n,this.uint8[c+5]=r,this.uint8[c+6]=o,this.uint8[c+7]=s,this.float32[u+2]=a,e}}va.prototype.bytesPerElement=12,es(va,"StructArrayLayout2i4ub1f12");class xa extends ua{_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}}xa.prototype.bytesPerElement=12,es(xa,"StructArrayLayout3f12");class ba extends ua{_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 s=6*e,a=3*e;return this.uint16[s+0]=t,this.uint16[s+1]=i,this.uint16[s+2]=n,this.uint16[s+3]=r,this.float32[a+2]=o,e}}ba.prototype.bytesPerElement=12,es(ba,"StructArrayLayout4ui1f12");class wa extends ua{_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}}wa.prototype.bytesPerElement=8,es(wa,"StructArrayLayout4ui8");class Ta extends ua{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer)}emplaceBack(e,t,i,n,r,o){const s=this.length;return this.resize(s+1),this.emplace(s,e,t,i,n,r,o)}emplace(e,t,i,n,r,o,s){const a=6*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,this.int16[a+5]=s,e}}Ta.prototype.bytesPerElement=12,es(Ta,"StructArrayLayout6i12");class Ea extends ua{_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,s,a,l,c,u,h){const d=this.length;return this.resize(d+1),this.emplace(d,e,t,i,n,r,o,s,a,l,c,u,h)}emplace(e,t,i,n,r,o,s,a,l,c,u,h,d){const p=12*e;return this.int16[p+0]=t,this.int16[p+1]=i,this.int16[p+2]=n,this.int16[p+3]=r,this.uint16[p+4]=o,this.uint16[p+5]=s,this.uint16[p+6]=a,this.uint16[p+7]=l,this.int16[p+8]=c,this.int16[p+9]=u,this.int16[p+10]=h,this.int16[p+11]=d,e}}Ea.prototype.bytesPerElement=24,es(Ea,"StructArrayLayout4i4ui4i24");class Ca extends ua{_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 s=this.length;return this.resize(s+1),this.emplace(s,e,t,i,n,r,o)}emplace(e,t,i,n,r,o,s){const a=10*e,l=5*e;return this.int16[a+0]=t,this.int16[a+1]=i,this.int16[a+2]=n,this.float32[l+2]=r,this.float32[l+3]=o,this.float32[l+4]=s,e}}Ca.prototype.bytesPerElement=20,es(Ca,"StructArrayLayout3i3f20");class Sa extends ua{_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}}Sa.prototype.bytesPerElement=16,es(Sa,"StructArrayLayout4f16");class Ba extends ua{_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}}Ba.prototype.bytesPerElement=4,es(Ba,"StructArrayLayout1ul4");class Ia extends ua{_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}}Ia.prototype.bytesPerElement=4,es(Ia,"StructArrayLayout2ui4");class Ma extends ua{_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,s,a,l,c,u,h,d){const p=this.length;return this.resize(p+1),this.emplace(p,e,t,i,n,r,o,s,a,l,c,u,h,d)}emplace(e,t,i,n,r,o,s,a,l,c,u,h,d,p){const f=20*e,m=10*e;return this.int16[f+0]=t,this.int16[f+1]=i,this.int16[f+2]=n,this.int16[f+3]=r,this.int16[f+4]=o,this.float32[m+3]=s,this.float32[m+4]=a,this.float32[m+5]=l,this.float32[m+6]=c,this.int16[f+14]=u,this.uint32[m+8]=h,this.uint16[f+18]=d,this.uint16[f+19]=p,e}}Ma.prototype.bytesPerElement=40,es(Ma,"StructArrayLayout5i4f1i1ul2ui40");class Pa extends ua{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer)}emplaceBack(e,t,i,n,r,o,s){const a=this.length;return this.resize(a+1),this.emplace(a,e,t,i,n,r,o,s)}emplace(e,t,i,n,r,o,s,a){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]=s,this.int16[l+7]=a,e}}Pa.prototype.bytesPerElement=16,es(Pa,"StructArrayLayout3i2i2i16");class Ra extends ua{_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 s=4*e,a=8*e;return this.float32[s+0]=t,this.float32[s+1]=i,this.float32[s+2]=n,this.int16[a+6]=r,this.int16[a+7]=o,e}}Ra.prototype.bytesPerElement=16,es(Ra,"StructArrayLayout2f1f2i16");class La extends ua{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer)}emplaceBack(e,t,i,n,r,o){const s=this.length;return this.resize(s+1),this.emplace(s,e,t,i,n,r,o)}emplace(e,t,i,n,r,o,s){const a=20*e,l=5*e;return this.uint8[a+0]=t,this.uint8[a+1]=i,this.float32[l+1]=n,this.float32[l+2]=r,this.float32[l+3]=o,this.float32[l+4]=s,e}}La.prototype.bytesPerElement=20,es(La,"StructArrayLayout2ub4f20");class Fa extends ua{_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}}Fa.prototype.bytesPerElement=6,es(Fa,"StructArrayLayout3ui6");class ka extends ua{_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,s,a,l,c,u,h,d,p,f,m,g,_,A,y,v){const x=this.length;return this.resize(x+1),this.emplace(x,e,t,i,n,r,o,s,a,l,c,u,h,d,p,f,m,g,_,A,y,v)}emplace(e,t,i,n,r,o,s,a,l,c,u,h,d,p,f,m,g,_,A,y,v,x){const b=30*e,w=15*e,T=60*e;return this.int16[b+0]=t,this.int16[b+1]=i,this.int16[b+2]=n,this.float32[w+2]=r,this.float32[w+3]=o,this.uint16[b+8]=s,this.uint16[b+9]=a,this.uint32[w+5]=l,this.uint32[w+6]=c,this.uint32[w+7]=u,this.uint16[b+16]=h,this.uint16[b+17]=d,this.uint16[b+18]=p,this.float32[w+10]=f,this.float32[w+11]=m,this.uint8[T+48]=g,this.uint8[T+49]=_,this.uint8[T+50]=A,this.uint32[w+13]=y,this.int16[b+28]=v,this.uint8[T+58]=x,e}}ka.prototype.bytesPerElement=60,es(ka,"StructArrayLayout3i2f2ui3ul3ui2f3ub1ul1i1ub60");class Da extends ua{_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,s,a,l,c,u,h,d,p,f,m,g,_,A,y,v,x,b,w,T,E,C,S,B,I,M,P,R){const L=this.length;return this.resize(L+1),this.emplace(L,e,t,i,n,r,o,s,a,l,c,u,h,d,p,f,m,g,_,A,y,v,x,b,w,T,E,C,S,B,I,M,P,R)}emplace(e,t,i,n,r,o,s,a,l,c,u,h,d,p,f,m,g,_,A,y,v,x,b,w,T,E,C,S,B,I,M,P,R,L){const F=20*e,k=40*e,D=80*e;return this.float32[F+0]=t,this.float32[F+1]=i,this.int16[k+4]=n,this.int16[k+5]=r,this.int16[k+6]=o,this.int16[k+7]=s,this.int16[k+8]=a,this.int16[k+9]=l,this.int16[k+10]=c,this.int16[k+11]=u,this.int16[k+12]=h,this.uint16[k+13]=d,this.uint16[k+14]=p,this.uint16[k+15]=f,this.uint16[k+16]=m,this.uint16[k+17]=g,this.uint16[k+18]=_,this.uint16[k+19]=A,this.uint16[k+20]=y,this.uint16[k+21]=v,this.uint16[k+22]=x,this.uint16[k+23]=b,this.uint16[k+24]=w,this.uint16[k+25]=T,this.uint16[k+26]=E,this.uint16[k+27]=C,this.uint32[F+14]=S,this.float32[F+15]=B,this.float32[F+16]=I,this.float32[F+17]=M,this.float32[F+18]=P,this.uint8[D+76]=R,this.uint16[k+39]=L,e}}Da.prototype.bytesPerElement=80,es(Da,"StructArrayLayout2f9i15ui1ul4f1ub1ui80");class Oa extends ua{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer)}emplaceBack(e,t,i,n,r,o){const s=this.length;return this.resize(s+1),this.emplace(s,e,t,i,n,r,o)}emplace(e,t,i,n,r,o,s){const a=6*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,this.float32[a+5]=s,e}}Oa.prototype.bytesPerElement=24,es(Oa,"StructArrayLayout6f24");class za extends ua{_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 s=5*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,e}}za.prototype.bytesPerElement=20,es(za,"StructArrayLayout5f20");class Ua extends ua{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer)}emplaceBack(e,t,i,n,r,o,s){const a=this.length;return this.resize(a+1),this.emplace(a,e,t,i,n,r,o,s)}emplace(e,t,i,n,r,o,s,a){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]=s,this.float32[l+6]=a,e}}Ua.prototype.bytesPerElement=28,es(Ua,"StructArrayLayout7f28");class Na extends ua{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer)}emplaceBack(e,t,i,n,r,o,s,a,l,c,u){const h=this.length;return this.resize(h+1),this.emplace(h,e,t,i,n,r,o,s,a,l,c,u)}emplace(e,t,i,n,r,o,s,a,l,c,u,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]=s,this.float32[d+6]=a,this.float32[d+7]=l,this.float32[d+8]=c,this.float32[d+9]=u,this.float32[d+10]=h,e}}Na.prototype.bytesPerElement=44,es(Na,"StructArrayLayout11f44");class Va extends ua{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer)}emplaceBack(e,t,i,n,r,o,s,a,l){const c=this.length;return this.resize(c+1),this.emplace(c,e,t,i,n,r,o,s,a,l)}emplace(e,t,i,n,r,o,s,a,l,c){const u=9*e;return this.float32[u+0]=t,this.float32[u+1]=i,this.float32[u+2]=n,this.float32[u+3]=r,this.float32[u+4]=o,this.float32[u+5]=s,this.float32[u+6]=a,this.float32[u+7]=l,this.float32[u+8]=c,e}}Va.prototype.bytesPerElement=36,es(Va,"StructArrayLayout9f36");class ja extends ua{_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}}ja.prototype.bytesPerElement=8,es(ja,"StructArrayLayout2f8");class Ga extends ua{_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}}Ga.prototype.bytesPerElement=12,es(Ga,"StructArrayLayout1ul3ui12");class Ha extends ua{_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}}Ha.prototype.bytesPerElement=2,es(Ha,"StructArrayLayout1ui2");class Qa extends ua{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer)}emplaceBack(e,t,i,n,r,o,s,a,l,c,u,h,d,p,f,m){const g=this.length;return this.resize(g+1),this.emplace(g,e,t,i,n,r,o,s,a,l,c,u,h,d,p,f,m)}emplace(e,t,i,n,r,o,s,a,l,c,u,h,d,p,f,m,g){const _=16*e;return this.float32[_+0]=t,this.float32[_+1]=i,this.float32[_+2]=n,this.float32[_+3]=r,this.float32[_+4]=o,this.float32[_+5]=s,this.float32[_+6]=a,this.float32[_+7]=l,this.float32[_+8]=c,this.float32[_+9]=u,this.float32[_+10]=h,this.float32[_+11]=d,this.float32[_+12]=p,this.float32[_+13]=f,this.float32[_+14]=m,this.float32[_+15]=g,e}}Qa.prototype.bytesPerElement=64,es(Qa,"StructArrayLayout16f64");class $a extends ua{_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,s){const a=this.length;return this.resize(a+1),this.emplace(a,e,t,i,n,r,o,s)}emplace(e,t,i,n,r,o,s,a){const l=10*e,c=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[c+2]=o,this.float32[c+3]=s,this.float32[c+4]=a,e}}$a.prototype.bytesPerElement=20,es($a,"StructArrayLayout4ui3f20");class Za extends ua{_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}}Za.prototype.bytesPerElement=2,es(Za,"StructArrayLayout1i2");class Wa extends ua{_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}}Wa.prototype.bytesPerElement=1,es(Wa,"StructArrayLayout1ub1");class qa extends ca{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]}}qa.prototype.size=40;class Ka extends Ma{get(e){return new qa(this,e)}}es(Ka,"CollisionBoxArray");class Xa extends ca{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}}Xa.prototype.size=60;class Ja extends ka{get(e){return new Xa(this,e)}}es(Ja,"PlacedSymbolArray");class Ya extends ca{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]}}Ya.prototype.size=80;class el extends Da{get(e){return new Ya(this,e)}}es(el,"SymbolInstanceArray");class tl extends ga{getoffsetX(e){return this.float32[1*e+0]}}es(tl,"GlyphOffsetArray");class il extends pa{getx(e){return this.int16[2*e+0]}gety(e){return this.int16[2*e+1]}}es(il,"SymbolLineVertexArray");class nl extends ca{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]}}nl.prototype.size=12;class rl extends Ga{get(e){return new nl(this,e)}}es(rl,"FeatureIndexArray");class ol extends Ia{geta_centroid_pos0(e){return this.uint16[2*e+0]}geta_centroid_pos1(e){return this.uint16[2*e+1]}}es(ol,"FillExtrusionCentroidArray");class sl extends ca{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]}}sl.prototype.size=6;class al extends fa{get(e){return new sl(this,e)}}es(al,"FillExtrusionWallArray");const ll=ha([{name:"a_pos",components:2,type:"Int16"}],4),cl=ha([{name:"a_circle_z_offset",components:1,type:"Float32"}],4),ul=ha([{name:"a_pos_3",components:3,type:"Int16"},{name:"a_pos_normal_3",components:3,type:"Int16"}]);class hl{constructor(e=[]){this.segments=e}_prepareSegment(e,t,i,n){let r=this.segments[this.segments.length-1];return e>hl.MAX_VERTEX_ARRAY_LENGTH&&Ze(`Max vertices per segment is ${hl.MAX_VERTEX_ARRAY_LENGTH}: bucket requested ${e}`),(!r||r.vertexLength+e>hl.MAX_VERTEX_ARRAY_LENGTH||r.sortKey!==n)&&(r={vertexOffset:t,primitiveOffset:i,vertexLength:0,primitiveLength:0},void 0!==n&&(r.sortKey=n),this.segments.push(r)),r}prepareSegment(e,t,i,n){return this._prepareSegment(e,t.length,i.length,n)}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 hl([{vertexOffset:e,primitiveOffset:t,vertexLength:i,primitiveLength:n,vaos:{},sortKey:0}])}}function dl(e,t){return 256*(e=Fe(Math.floor(e),0,255))+Fe(Math.floor(t),0,255)}hl.MAX_VERTEX_ARRAY_LENGTH=Math.pow(2,16)-1,es(hl,"SegmentVector");const pl=ha([{name:"a_pattern",components:4,type:"Uint16"},{name:"a_pixel_ratio",components:1,type:"Float32"}]),fl=ha([{name:"a_pattern_b",components:4,type:"Uint16"}]),ml=ha([{name:"a_dash",components:4,type:"Uint16"}]);class gl{constructor(){this.ids=[],this.uniqueIds=[],this.positions=[],this.indexed=!1}add(e,t,i,n){this.ids.push(_l(e)),this.positions.push(t,i,n)}eachPosition(e,t){const i=_l(e);let n=0,r=this.ids.length-1;for(;n>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 Al(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 gl;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 _l(e){const t=+e;return Number.isSafeInteger(t)?t:Jt(String(e))}function Al(e,t,i,n){for(;i>1];let o=i-1,s=n+1;for(;;){do{o++}while(e[o]r);if(o>=s)break;yl(e,o,s),yl(t,3*o,3*s),yl(t,3*o+1,3*s+1),yl(t,3*o+2,3*s+2)}s-i`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 li?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 Cl(e):new bl(e)}}class kl{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 El(e):new bl(e)}}class Dl{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,s,a){const l=this.paintVertexArray.length,c="composite"===this.expression.kind||"source"===this.expression.kind?this.expression.evaluate(new Es(0,{brightness:o,worldview:a}),t,{},r,n,s):"constant"===this.expression.kind&&this.expression.value,u=Ll(this.lutExpression,t,{},n,r,o,s,a);this.paintVertexArray.resize(e),this._setPaintValue(l,e,c,u?null:this.context.lut)}updatePaintArray(e,t,i,n,r,o,s,a){const l="composite"===this.expression.kind||"source"===this.expression.kind?this.expression.evaluate({zoom:0,brightness:s,worldview:a},i,n,void 0,r):"constant"===this.expression.kind&&this.expression.value,c=Ll(this.lutExpression,i,n,r,void 0,s,void 0,a);this._setPaintValue(e,t,l,c?null:this.context.lut)}_setPaintValue(e,t,i,n){if("color"===this.type){const r=Rl(i.toPremultipliedRenderColor(n));for(let i=e;i`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,s,a){const l=this.expression.evaluate(new Es(this.context.zoom,{brightness:o,worldview:a}),t,{},r,n,s),c=this.expression.evaluate(new Es(this.context.zoom+1,{brightness:o,worldview:a}),t,{},r,n,s),u=Ll(this.lutExpression,t,{},n,r,o,s,a),h=this.paintVertexArray.length;this.paintVertexArray.resize(e),this._setPaintValue(h,e,l,c,u?null:this.context.lut)}updatePaintArray(e,t,i,n,r,o,s,a){const l=this.expression.evaluate({zoom:this.context.zoom,brightness:s,worldview:a},i,n,void 0,r),c=this.expression.evaluate({zoom:this.context.zoom+1,brightness:s,worldview:a},i,n,void 0,r),u=Ll(this.lutExpression,i,n,r,void 0,s,void 0,a);this._setPaintValue(e,t,l,c,u?null:this.context.lut)}_setPaintValue(e,t,i,n,r){if("color"===this.type){const n=Rl(i.toPremultipliedRenderColor(r)),o=Rl(i.toPremultipliedRenderColor(r));for(let i=e;i!0){this.binders={},this._buffers=[],this.context=t;const n=[];for(const r in e.paint._values){const o=e.paint.get(r);if(r.endsWith("-use-theme"))continue;if(!i(r))continue;if(!(o instanceof Rs&&Io(o.property.specification)))continue;const s=jl(r,e.type),a=o.value,l=o.property.specification.type,c=!!o.property.useIntegerZoom,u="line-dasharray"===r||r.endsWith("pattern"),h=e.paint.get(`${r}-use-theme`),d="line-dasharray"===r&&"constant"!==e.layout.get("line-cap").value.kind||h&&"constant"!==h.value.kind;if("constant"!==a.kind||d)if("source"===a.kind||d||u){const t=Ql(r,l,"source");this.binders[r]=u?new zl(a,s,l,t,e.id):new Dl(a,s,l,t),n.push(`/a_${r}`)}else{const e=Ql(r,l,"composite");this.binders[r]=new Ol(a,s,l,c,t,e),n.push(`/z_${r}`)}else this.binders[r]=u?new kl(a.value,s):new Fl(a.value,s,l,t),n.push(`/u_${r}`);h&&(this.binders[r].lutExpression=h.value)}this.cacheKey=n.sort().join("")}getMaxValue(e){const t=this.binders[e];return t instanceof Dl||t instanceof Ol?t.maxValue:0}populatePaintArrays(e,t,i,n,r,o,s,a){for(const l in this.binders){const c=this.binders[l];c.context=this.context,(c instanceof Dl||c instanceof Ol||c instanceof zl)&&c.populatePaintArray(e,t,i,n,r,o,s,a)}}setConstantPatternPositions(e,t){for(const i in this.binders){const n=this.binders[i];n instanceof kl&&n.setConstantPatternPositions(e,t)}}getPatternTransitionVertexBuffer(e){const t=this.binders[e];return t instanceof zl?t.paintTransitionVertexBuffer:null}updatePaintArrays(e,t,i,n,r,o,s,a,l,c){let u=!1;const h=Object.keys(e),d=0!==h.length&&!a,p=d?h:t.uniqueIds;this.context.lut=r.lut;for(const a in this.binders){const h=this.binders[a];if(h.context=this.context,(h instanceof Dl||h instanceof Ol||h instanceof zl)&&h.expression&&h.expression.kind&&"constant"!==h.expression.kind&&(!0===h.expression.isStateDependent||!1===h.expression.isLightConstant)){const f=r.paint.get(a);h.expression=f.value;for(const i of p){const r=e[i.toString()];t.eachPosition(i,(e,t,i)=>{const a=n.feature(e);h.updatePaintArray(t,i,a,r,o,s,l,c)})}if(!d)for(const t of i.uniqueIds){const r=e[t.toString()];i.eachPosition(t,(e,t,i)=>{const a=n.feature(e);h.updatePaintArray(t,i,a,r,o,s,l,c)})}u=!0}}return u}defines(){const e=[];for(const t in this.binders){const i=this.binders[t];(i instanceof Fl||i instanceof kl)&&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 Fl||n instanceof kl||n instanceof Ol)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:s}of i)this.binders[o].setUniform(e,s,r,n.get(o),t)}updatePaintBuffers(){this._buffers=[];for(const e in this.binders){const t=this.binders[e];(t instanceof Dl||t instanceof Ol||t instanceof zl)&&t.paintVertexBuffer&&this._buffers.push(t.paintVertexBuffer),t instanceof zl&&t.paintTransitionVertexBuffer&&this._buffers.push(t.paintTransitionVertexBuffer)}}upload(e){for(const t in this.binders){const i=this.binders[t];(i instanceof Dl||i instanceof Ol||i instanceof zl)&&i.upload(e)}this.updatePaintBuffers()}destroy(){for(const e in this.binders){const t=this.binders[e];(t instanceof Dl||t instanceof Ol||t instanceof zl)&&t.destroy()}}}class Nl{constructor(e,t,i=()=>!0){this.programConfigurations={};for(const n of e)this.programConfigurations[n.id]=new Ul(n,t,i);this.needsUpload=!1,this._featureMap=new gl,this._featureMapWithoutIds=new gl,this._bufferOffset=0,this._idlessCounter=0}populatePaintArrays(e,t,i,n,r,o,s,a,l){for(const i in this.programConfigurations)this.programConfigurations[i].populatePaintArrays(e,t,n,r,o,s,a,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,s,a){for(const l of i)this.needsUpload=this.programConfigurations[l.id].updatePaintArrays(e,this._featureMap,this._featureMapWithoutIds,t,l,n,r,o,s||0,a)||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()}}const Vl={"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 jl(e,t){return Vl[e]||[e.replace(`${t}-`,"").replace(/-/g,"_")]}const Gl={"line-pattern":{source:ba,composite:ba},"fill-pattern":{source:ba,composite:ba},"fill-extrusion-pattern":{source:ba,composite:ba},"line-dasharray":{source:wa,composite:wa}},Hl={color:{source:ja,composite:Sa},number:{source:ga,composite:ja}};function Ql(e,t,i){const n=Gl[e];return n&&n[i]||Hl[t][i]}es(Fl,"ConstantBinder"),es(kl,"PatternConstantBinder"),es(Dl,"SourceExpressionBinder"),es(zl,"PatternCompositeBinder"),es(Ol,"CompositeExpressionBinder"),es(Ul,"ProgramConfiguration",{omit:["_buffers"]}),es(Nl,"ProgramConfigurationSet");const $l=Nn/Math.PI/2,Zl=5,Wl=6,ql=16383,Kl=64,Xl=[Kl,32,16],Jl=-$l,Yl=$l;function ec(e,t,i,n=$l){return i=Be(i),[e*Math.sin(i)*n,-t*n,e*Math.cos(i)*n]}function tc(e,t,i){return ec(Math.cos(Be(e)),Math.sin(Be(e)),t,i)}const ic=6371008.8,nc=2*Math.PI*ic;class rc{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 rc(De(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 ic*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 oc({lng:this.lng-i,lat:this.lat-t},{lng:this.lng+i,lat:this.lat+t})}toEcef(e){return tc(this.lat,this.lng,$l+e*$l/ic)}static convert(e){if(e instanceof rc)return e;if(Array.isArray(e)&&(2===e.length||3===e.length))return new rc(Number(e[0]),Number(e[1]));if(!Array.isArray(e)&&"object"==typeof e&&null!==e)return new rc(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: , lat: }, an object {lon: , lat: }, or an array of [, ]")}}class oc{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 rc?new rc(e.lng,e.lat):rc.convert(e),this}setSouthWest(e){return this._sw=e instanceof rc?new rc(e.lng,e.lat):rc.convert(e),this}extend(e){const t=this._sw,i=this._ne;let n,r;if(e instanceof rc)n=e,r=e;else{if(!(e instanceof oc))return Array.isArray(e)?4===e.length||e.every(Array.isArray)?this.extend(oc.convert(e)):this.extend(rc.convert(e)):"object"==typeof e&&null!==e&&e.hasOwnProperty("lat")&&(e.hasOwnProperty("lon")||e.hasOwnProperty("lng"))?this.extend(rc.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 rc(n.lng,n.lat),this._ne=new rc(r.lng,r.lat)),this}getCenter(){return new rc((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 rc(this.getWest(),this.getNorth())}getSouthEast(){return new rc(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}=rc.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 oc?e:new oc(e)}}const sc=0,ac=25.5;function lc(e){return nc*Math.cos(e*Math.PI/180)}function cc(e){return(180+e)/360}function uc(e){return(180-180/Math.PI*Math.log(Math.tan(Math.PI/4+e*Math.PI/360)))/360}function hc(e,t){return e/lc(t)}function dc(e){return 360*e-180}function pc(e){return 360/Math.PI*Math.atan(Math.exp((180-360*e)*Math.PI/180))-90}function fc(e,t){return e*lc(pc(t))}const mc=85.051129;function gc(e){return Math.cos(Be(Fe(e,-mc,mc)))}function _c(e,t){const i=Fe(t,sc,ac),n=Math.pow(2,i);return gc(e)*nc/(512*n)}function Ac(e){return 1/Math.cos(e*Math.PI/180)}function yc(e,t=0){const i=Math.exp(Math.PI*(1-(e.y+t/Nn)/(1<=l?(xc(e,t,i,c,u,o,h,a,l),xc(e,c,u,n,r,h,s,a,l)):e.push(s)}function bc(e,t,i){let n=e[0],r=n.x,o=n.y;t(n);const s=[n];for(let a=1;ae.x+1||ne.y+1)&&Ze("Geometry exceeds allowed extent, reduce your vector tile buffer size"),e}function Bc(e,t,i){const n=e.loadGeometry(),r=e.extent,o=Nn/r;if(t&&i&&i.projection.isReprojectedInTileSpace){const o=1<{const i=dc((t.x+e.x/r)/o),n=pc((t.y+e.y/r)/o),u=c.project(i,n);e.x=(u.x*s-a)*r,e.y=(u.y*s-l)*r};for(let t=0;t=r||i.y<0||i.y>=r||(u(i),e.push(i));n[t]=e}}for(const e of n)for(const t of e)Sc(t,o);return n}function Ic(e,t){return{type:e.type,id:e.id,properties:e.properties,geometry:t?Bc(e):[]}}class Mc{constructor(e,t,i,n,r){this.properties={},this.extent=i,this.type=0,this.id=void 0,this._pbf=e,this._geometry=-1,this._keys=n,this._values=r,e.readFields(Pc,this,t)}loadGeometry(){const e=this._pbf;e.pos=this._geometry;const t=e.readVarint()+e.pos,i=[];let n,r=1,o=0,s=0,a=0;for(;e.pos>3}if(o--,1===r||2===r)s+=e.readSVarint(),a+=e.readSVarint(),1===r&&(n&&i.push(n),n=[]),n&&n.push(new Te(s,a));else{if(7!==r)throw new Error(`unknown command ${r}`);n&&n.push(n[0].clone())}}return n&&i.push(n),i}bbox(){const e=this._pbf;e.pos=this._geometry;const t=e.readVarint()+e.pos;let i=1,n=0,r=0,o=0,s=1/0,a=-1/0,l=1/0,c=-1/0;for(;e.pos>3}if(n--,1===i||2===i)r+=e.readSVarint(),o+=e.readSVarint(),ra&&(a=r),oc&&(c=o);else if(7!==i)throw new Error(`unknown command ${i}`)}return[s,l,a,c]}toGeoJSON(e,t,i){const n=this.extent*Math.pow(2,i),r=this.extent*e,o=this.extent*t,s=this.loadGeometry();function a(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(a)}let c;if(1===this.type){const e=[];for(const t of s)e.push(t[0]);const t=l(e);c=1===e.length?{type:"Point",coordinates:t[0]}:{type:"MultiPoint",coordinates:t}}else if(2===this.type){const e=s.map(l);c=1===e.length?{type:"LineString",coordinates:e[0]}:{type:"MultiLineString",coordinates:e}}else{if(3!==this.type)throw new Error("unknown feature type");{const e=function(e){const t=e.length;if(t<=1)return[e];const i=[];let n,r;for(let o=0;o=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 Mc(this._pbf,t,this.extent,this._keys,this._values)}}function Fc(e,t,i){15===e?t.version=i.readVarint():1===e?t.name=i.readString():5===e?t.extent=i.readVarint():2===e?t._features.push(i.pos):3===e?t._keys.push(i.readString()):4===e&&t._values.push(function(e){let t=null;const i=e.readVarint()+e.pos;for(;e.pos>3;t=1===i?e.readString():2===i?e.readFloat():3===i?e.readDouble():4===i?e.readVarint64():5===i?e.readVarint():6===i?e.readSVarint():7===i?e.readBoolean():null}if(null==t)throw new Error("unknown feature value");return t}(i))}class kc{constructor(e,t){this.layers=e.readFields(Dc,{},t)}}function Dc(e,t,i){if(3===e){const e=new Lc(i,i.readVarint()+i.pos);e.length&&(t[e.name]=e)}}const Oc="3d_elevation_id",zc="level";class Uc{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=this.feature.properties.hasOwnProperty(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 Nc{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 Vc=new Nc((e,t,i)=>e.reset(t).require(Oc,e=>{i.id=e}).optional("fixed_height_relative",e=>{i.constantHeight=e},Gc.decodeRelativeHeight).geometry(e=>{i.bounds=e},An).success(),(e,t,i)=>e.reset(t).require(Oc,e=>{i.id=e}).require("elevation_idx",e=>{i.idx=e}).require("extent",e=>{i.extent=e}).require("height_relative",e=>{i.height=e},Gc.decodeRelativeHeight).geometry(e=>{i.position=e},Gc.getPoint).success()),jc=new Nc((e,t,i)=>e.reset(t).require(Oc,e=>{i.id=e}).optional("fixed_height",e=>{i.constantHeight=e},Gc.decodeMetricHeight).geometry(e=>{i.bounds=e},An).success(),(e,t,i)=>e.reset(t).require(Oc,e=>{i.id=e}).require("elevation_idx",e=>{i.idx=e}).require("extent",e=>{i.extent=e}).require("height",e=>{i.height=e},Gc.decodeMetricHeight).geometry(e=>{i.position=e},Gc.getPoint).success());class Gc{static getPoint(e){return ue(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?jc:void 0:Vc}static parse(e){const t=[],i=[],n=e.length,r=new Uc;for(let o=0;o=0);if(0===o)return 0;o!==t.length&&(i=!1)}return i?2:1}function qc(e,t){for(const i of e.projections){const n=Zc(t,e.points[0],i.axis);if(i.projection[1]n[1])return 0}return 1}function Kc(e,t){let i=0;const n=[0,0,0,0];for(let s=0;s=0&&i++;var r,o;return i}class Xc{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=Jc.fromPoints(this.points),this.projections=[],this.frustumEdges=[Z([],this.points[2],this.points[3]),Z([],this.points[0],this.points[3]),Z([],this.points[4],this.points[0]),Z([],this.points[5],this.points[1]),Z([],this.points[6],this.points[2]),Z([],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:Zc(this.points,this.points[0],t)}),this.projections.push({axis:i,projection:Zc(this.points,this.points[0],i)})}}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=Y([],i,e),s=1/o[3]/t*r;return(a=o)[0]=(l=o)[0]*(c=[s,s,n?1/o[3]:s,s])[0],a[1]=l[1]*c[1],a[2]=l[2]*c[2],a[3]=l[3]*c[3],a;var a,l,c}),s=[[0,1,2],[6,5,4],[0,3,7],[2,1,5],[3,2,6],[0,4,5]].map(e=>{const t=z([],N([],Z([],o[e[0]],o[e[1]]),Z([],o[e[2]],o[e[1]]))),i=-U(t,o[e[1]]);return t.concat(i)}),a=[];for(let e=0;es[1]||s[0]>o[1])return 0}return 1}containsPoint(e){for(const t of this.planes){const i=t[3];if(U([t[0],t[1],t[2]],e)+i<0)return!1}return!0}}class Jc{static fromPoints(e){const t=[1/0,1/0,1/0],i=[-1/0,-1/0,-1/0];for(const n of e)M(t,t,n),P(i,i,n);return new Jc(t,i)}static fromTileIdAndHeight(e,t,i){const n=1<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])]}}es(Jc,"Aabb");class Yc{constructor(e,t){this.feature=e,this.metersToTile=t,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;return[new Te(Math.trunc(e.position[0]+i*r),Math.trunc(e.position[1]+n*r)),new Te(Math.trunc(e.position[0]-i*r),Math.trunc(e.position[1]-n*r))]}next(){this.index++}valid(){return this.index{return e.a0?R(a,a,1/l):C(a,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,s,a,l,c,u]=this._tmpVec2;he(u,e.x,e.y);const h=new Hc(u,null);for(let e=0;e0?_e(a,s)/A:0,v=Fe(y,0,1),x=Math.abs((y-v)*this.edgeProps[e].len);pe(l,u,f),he(c,p[1],-p[0]);const b=x+Math.abs(_e(l,c));b=0;--o){const s=this.edges[o].a,a=this.edges[o].b,{position:l,height:c,extent:u}=this.vertices[s],{position:h,height:d,extent:p}=this.vertices[a],f=this.vertexProps[s].dir,m=this.vertexProps[a].dir;if(C(t,l[0]/e,l[1]/e,c),C(i,h[0]/e,h[1]/e,d),C(n,f[1],-f[0],0),R(n,n,u),C(r,m[1],-m[0],0),R(r,r,p),this.distSqLines(E(t[0]+.5*n[0],t[1]+.5*n[1],t[2]+.5*n[2]),E(i[0]-.5*r[0],i[1]-.5*r[1],i[2]-.5*r[2]),E(t[0]-.5*n[0],t[1]-.5*n[1],t[2]-.5*n[2]),E(i[0]+.5*r[0],i[1]+.5*r[1],i[2]+.5*r[2]))<=.0025000000000000005)continue;const g=this.vertices.length,_=de(ce(),l,h);this.vertices.push({position:fe(_,_,.5),height:.5*(c+d),extent:.5*(u+p)});const A=de(ce(),f,m);this.vertexProps.push({dir:ge(A,A)}),this.edges.splice(o,1),this.edgeProps.splice(o,1),this.edges.push({a:s,b:g}),this.edges.push({a:g,b:a});const y=pe(ce(),this.vertices[g].position,l),v=me(y),x={vec:y,dir:fe(ce(),y,1/v),len:v};this.edgeProps.push(x),this.edgeProps.push(x)}}distSqLines(e,t,i,n){const r=B(b(),t,e),o=B(b(),n,i),s=B(b(),e,i),a=U(r,r),l=U(r,o),c=U(r,s),u=U(o,o),h=U(o,s),d=a*u-l*l;if(0===d)return k(V(r,i,n,U(s,o)/U(o,o)),e);const p=(a*h-l*c)/d;return k(V(r,e,t,(l*h-c*u)/d),V(o,i,n,p))}}class tu{static parseFrom(e,t){const i=Gc.parse(e);if(!i)return[];let{vertices:n,features:r}=i;const o=1/yc(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 s=new Array;let a=0;const l=n.length;for(const e of r){if(e.constantHeight){s.push(new eu(e.id,e.bounds,e.constantHeight));continue}for(;a!==l&&n[a].ide.id===i)}}class iu{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)*Nn,this.yOffset=(e.y*this.zScale-t.y)*Nn)}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*ke(0,t,e>=0?e:Math.abs(.5*e))}}es(eu,"ElevationFeature");class nu{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 pa,this.indexArray=new Fa,this.segments=new hl,this.programConfigurations=new Nl(e.layers,{zoom:e.zoom,lut:e.lut}),this.stateDependentLayerIds=this.layers.filter(e=>e.isStateDependent()).map(e=>e.id),this.elevationMode=this.layers[0].layout.get("circle-elevation-reference"),this.hasElevation=!1,"none"!==this.elevationMode&&(this.elevatedLayoutVertexArray=new ga),this.worldview=e.worldview,this.hasAppearances=null}updateFootprints(e,t){}updateAppearances(e,t,i,n){}populate(e,t,i,n){const r=this.layers[0],o=[];let s=null;"circle"===r.type&&(s=r.layout.get("circle-sort-key"));for(const{feature:r,id:a,index:l,sourceLayerIndex:c}of e){const e=this.layers[0]._featureFilter.needGeometry,u=Ic(r,e);if(!this.layers[0]._featureFilter.filter(new Es(this.zoom,{worldview:this.worldview,activeFloors:t.activeFloors}),u,i))continue;const h=s?s.evaluate(u,{},i):void 0,d={id:a,properties:r.properties,type:r.type,sourceLayerIndex:c,index:l,geometry:e?u.geometry:Bc(r,i,n),patterns:{},sortKey:h};o.push(d)}s&&o.sort((e,t)=>e.sortKey-t.sortKey);let a=null;"globe"===n.projection.name&&(this.globeExtVertexArray=new Ta,a=n.projection);for(const n of o){const{geometry:r,index:o,sourceLayerIndex:s}=n,l=e[o].feature;this.addFeature(n,r,o,t.availableImages,i,a,t.brightness,t.elevationFeatures),t.featureIndex.insert(l,r,o,s,this.index)}this.hasElevation||(this.elevatedLayoutVertexArray=void 0)}update(e,t,i,n,r,o,s){this.programConfigurations.updatePaintArrays(e,t,r,i,n,o,s,this.worldview)}isEmpty(){return 0===this.layoutVertexArray.length}uploadPending(){return!this.uploaded||this.programConfigurations.needsUpload}upload(e){this.uploaded||(this.layoutVertexBuffer=e.createVertexBuffer(this.layoutVertexArray,ll.members),this.indexBuffer=e.createIndexBuffer(this.indexArray),this.globeExtVertexArray&&(this.globeExtVertexBuffer=e.createVertexBuffer(this.globeExtVertexArray,ul.members)),this.elevatedLayoutVertexArray&&(this.elevatedLayoutVertexBuffer=e.createVertexBuffer(this.elevatedLayoutVertexArray,cl.members))),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.elevatedLayoutVertexBuffer&&this.elevatedLayoutVertexBuffer.destroy())}addFeature(e,t,i,n,r,o,s,a){let l;"none"!==this.elevationMode&&(l=tu.getElevationFeature(e,a));for(const i of t)for(const t of i){const i=t.x,n=t.y;if(i<0||i>=Nn||n<0||n>=Nn)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 s=this.segments.prepareSegment(4,this.layoutVertexArray,this.indexArray,e.sortKey),a=s.vertexLength;if(this.addCircleVertex(i,n,-1,-1),this.addCircleVertex(i,n,1,-1),this.addCircleVertex(i,n,1,1),this.addCircleVertex(i,n,-1,1),"none"!==this.elevationMode){const e=l?l.pointElevation(new Te(i,n)):0;this.hasElevation=this.hasElevation||0!==e;for(let t=0;t<4;t++)this.elevatedLayoutVertexArray.emplaceBack(e)}this.indexArray.emplaceBack(a,a+1,a+2),this.indexArray.emplaceBack(a,a+2,a+3),s.vertexLength+=4,s.primitiveLength+=2}this.programConfigurations.populatePaintArrays(this.layoutVertexArray.length,e,i,{},n,r,s,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)}}function ru(e,t){for(let i=0;i1){if(lu(e,t))return!0;for(let n=0;n1?i:i.sub(t)._mult(r)._add(t))}function fu(e,t){let i,n,r,o=!1;for(let s=0;st.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 mu(e,t){let i=!1;for(let n=0,r=e.length-1;nt.y!=s.y>t.y&&t.x<(s.x-o.x)*(t.y-o.y)/(s.y-o.y)+o.x&&(i=!i)}return i}function gu(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 Te(t,i),new Te(t,r),new Te(n,r),new Te(n,i)];if(e.length>2)for(const t of o)if(mu(e,t))return!0;for(let t=0;tr.x&&t.x>r.x||e.yr.y&&t.y>r.y)return!1;const o=We(e,t,i[0]);return o!==We(e,t,i[1])||o!==We(e,t,i[2])||o!==We(e,t,i[3])}function Au(e,t,i,n,r,o){let s=t.y-e.y,a=e.x-t.x;if(o=o||0){const e=s*s+a*a;if(0===e)return!0;const t=Math.sqrt(e);s/=t,a/=t}return!((i.x-e.x)*s+(i.y-e.y)*a-o<0||(n.x-e.x)*s+(n.y-e.y)*a-o<0||(r.x-e.x)*s+(r.y-e.y)*a-o<0)}function yu(e,t,i,n,r,o,s){return!(Au(e,t,n,r,o,s)||Au(t,i,n,r,o,s)||Au(i,e,n,r,o,s)||Au(n,r,e,t,i,s)||Au(r,o,e,t,i,s)||Au(o,n,e,t,i,s))}function vu(e,t,i){const n=t.paint.get(e).value;return"constant"===n.kind?n.value:i.programConfigurations.get(t.id).getMaxValue(e)}function xu(e){return Math.sqrt(e[0]*e[0]+e[1]*e[1])}function bu(e,t,i,n,r){if(!t[0]&&!t[1])return e;const o=Te.convert(t)._mult(r);"viewport"===i&&o._rotate(-n);const s=[];for(let t=0;t>t&&e.y===this.y>>t}url(e,t){const i=function(e,t,i){var n=Cu(256*e,256*(t=Math.pow(2,i)-t-1),i),r=Cu(256*(e+1),256*(t+1),i);return n[0]+","+n[1]+","+r[0]+","+r[1]}(this.x,this.y,this.z),n=function(e,t,i){let n,r="";for(let o=e;o>0;o--)n=1<this.canonical.z?new Iu(e,this.wrap,this.canonical.z,this.canonical.x,this.canonical.y):new Iu(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 Mu(this.wrap*+t,e,this.canonical.z,this.canonical.x,this.canonical.y);{const i=this.canonical.z-e;return Mu(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>t&&e.canonical.y===this.canonical.y>>t}children(e){if(this.overscaledZ>=e)return[new Iu(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 Iu(t,this.wrap,t,i,n),new Iu(t,this.wrap,t,i+1,n),new Iu(t,this.wrap,t,i,n+1),new Iu(t,this.wrap,t,i+1,n+1)]}isLessThan(e){return this.wrape.wrap)&&(this.overscaledZe.overscaledZ)&&(this.canonical.xe.canonical.x)&&this.canonical.y{let t=e.canonical.x-1,i=e.wrap;return t<0&&(t=(1<{let t=e.canonical.x+1,i=e.wrap;return t===1<new Iu(e.overscaledZ,e.wrap,e.canonical.z,e.canonical.x,(0===e.canonical.y?1<new Iu(e.overscaledZ,e.wrap,e.canonical.z,e.canonical.x,e.canonical.y===(1<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,Fe(i,0,1))+e.center[t]}function Vu(e){if(e.z<=1)return Ou[e.z+2*e.y+e.x];const t=$u(Qu(e));return Jc.fromPoints(t)}function ju(e,t,i){return R(e,e,1-i),L(e,e,t,i)}function Gu(e,t,i){for(const n of e)j(n,n,t),R(n,n,i)}function Hu(e,t,i,n){const r=t/e.worldSize,o=e.globeMatrix;if(i.z<=1){const e=Vu(i).getCorners();return Gu(e,o,r),Jc.fromPoints(e)}const s=Qu(i,n),a=$u(s,$l+Du(e._tileCoverLift));Gu(a,o,r);const l=Number.MAX_VALUE,c=[-l,-l,-l],u=[l,l,l];if(s.contains(e.center)){for(const e of a)M(u,u,e),P(c,c,e);c[2]=0;const t=e.point,i=[t.x*r,t.y*r,0];return M(u,u,i),P(c,c,i),new Jc(u,c)}if(e._tileCoverLift>0){for(const e of a)M(u,u,e),P(c,c,e);return new Jc(u,c)}const h=[o[12]*r,o[13]*r,o[14]*r],d=s.getCenter(),p=Fe(e.center.lat,-mc,mc),f=Fe(d.lat,-mc,mc),m=cc(e.center.lng),g=uc(p);let _=m-cc(d.lng);const A=g-uc(f);_>.5?_-=1:_<-.5&&(_+=1);let y=0;Math.abs(_)>Math.abs(A)?y=_>=0?1:3:(y=A>=0?0:2,L(h,h,[o[4]*r,o[5]*r,o[6]*r],-Math.sin(Be(A>=0?s.getSouth():s.getNorth()))*$l));const v=a[y],x=a[(y+1)%4],b=new Uu(v,x,h),w=[Nu(b,0)||v[0],Nu(b,1)||v[1],Nu(b,2)||v[2]],T=th(e.zoom);if(T>0){const n=function({x:e,y:t,z:i},n,r,o,s){const a=1/(1<.5?d=-1:p<-.5&&(d=1),l=((l+d)*n-(o*=n))*r+o,c=((c+d)*n-o)*r+o,u=(u*n-(s*=n))*r+s,h=(h*n-s)*r+s,[[l,h,0],[c,h,0],[c,u,0],[l,u,0]]}(i,t,e._pixelsPerMercatorPixel,m,g);for(let e=0;eMath.PI/2*1.01}const rh=Be(85),oh=Math.cos(rh),sh=Math.sin(rh),ah=a(),lh=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 ch(e,t,i,n,r,o,s,a,l){if(o&&e.queryGeometry.isAboveHorizon)return!1;o&&(l*=e.pixelToTileUnitsFactor);const c=e.tileID.canonical,u=i.projection.upVectorScale(c,i.center.lat,i.worldSize).metersToTile;for(const h of t)for(const t of h){const h=t.add(a),d=r&&i.elevation?i.elevation.exaggeration()*r.getElevationAt(h.x,h.y,!0):0,p=i.projection.projectTilePoint(h.x,h.y,c);if(d>0){const e=i.projection.upVector(c,h.x,h.y);p.x+=e[0]*u*d,p.y+=e[1]*u*d,p.z+=e[2]*u*d}const f=o?h:uh(p.x,p.y,p.z,n),m=o?e.tilespaceRays.map(e=>ph(e,d)):e.queryGeometry.screenGeometry,g=Y([],[p.x,p.y,p.z,1],n);if(!s&&o?l*=g[3]/i.cameraToCenterDistance:s&&!o&&(l*=i.cameraToCenterDistance/g[3]),o){const e=pc((t.y/Nn+c.y)/(1<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,c=t.data,u=4===o&&a;for(let a=0;a{t[e.evaluationKey]=o;const s=e.expression.evaluate(t),a=s?s.toNonPremultipliedRenderColor(null):null;a&&(r.data[i+n+0]=Math.floor(255*a.r),r.data[i+n+1]=Math.floor(255*a.g),r.data[i+n+2]=Math.floor(255*a.b),r.data[i+n+3]=Math.floor(255*a.a))};if(e.clips)for(let t=0,r=0;t80*i){a=e[0],l=e[1];let t=a,n=l;for(let o=i;ot&&(t=i),r>n&&(n=r)}c=Math.max(t-a,n-l),c=0!==c?32767/c:0}return Lh(o,s,i,a,l,c,0),s}function Ph(e,t,i,n,r){let o;if(r===function(e,t,i,n){let r=0;for(let o=t,s=i-n;o0)for(let r=t;r=t;r-=n)o=Yh(r/n|0,e[r],e[r+1],o);return o&&Zh(o,o.next)&&(ed(o),o=o.next),o}function Rh(e,t){if(!e)return e;t||(t=e);let i,n=e;do{if(i=!1,n.steiner||!Zh(n,n.next)&&0!==$h(n.prev,n,n.next))n=n.next;else{if(ed(n),n=t=n.prev,n===n.next)break;i=!0}}while(i||n!==t);return t}function Lh(e,t,i,n,r,o,s){if(!e)return;!s&&o&&function(e,t,i,n){let r=e;do{0===r.z&&(r.z=Vh(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 s=r,a=0;for(let e=0;e0||l>0&&s;)0!==a&&(0===l||!s||r.z<=s.z)?(n=r,r=r.nextZ,a--):(n=s,s=s.nextZ,l--),o?o.nextZ=n:e=n,n.prevZ=o,o=n;r=s}o.nextZ=null,i*=2}while(t>1)}(r)}(e,n,r,o);let a=e;for(;e.prev!==e.next;){const l=e.prev,c=e.next;if(o?kh(e,n,r,o):Fh(e))t.push(l.i,e.i,c.i),ed(e),e=c.next,a=c.next;else if((e=c)===a){s?1===s?Lh(e=Dh(Rh(e),t),t,i,n,r,o,2):2===s&&Oh(e,t,i,n,r,o):Lh(Rh(e),t,i,n,r,o,1);break}}}function Fh(e){const t=e.prev,i=e,n=e.next;if($h(t,i,n)>=0)return!1;const r=t.x,o=i.x,s=n.x,a=t.y,l=i.y,c=n.y,u=Math.min(r,o,s),h=Math.min(a,l,c),d=Math.max(r,o,s),p=Math.max(a,l,c);let f=n.next;for(;f!==t;){if(f.x>=u&&f.x<=d&&f.y>=h&&f.y<=p&&Hh(r,a,o,l,s,c,f.x,f.y)&&$h(f.prev,f,f.next)>=0)return!1;f=f.next}return!0}function kh(e,t,i,n){const r=e.prev,o=e,s=e.next;if($h(r,o,s)>=0)return!1;const a=r.x,l=o.x,c=s.x,u=r.y,h=o.y,d=s.y,p=Math.min(a,l,c),f=Math.min(u,h,d),m=Math.max(a,l,c),g=Math.max(u,h,d),_=Vh(p,f,t,i,n),A=Vh(m,g,t,i,n);let y=e.prevZ,v=e.nextZ;for(;y&&y.z>=_&&v&&v.z<=A;){if(y.x>=p&&y.x<=m&&y.y>=f&&y.y<=g&&y!==r&&y!==s&&Hh(a,u,l,h,c,d,y.x,y.y)&&$h(y.prev,y,y.next)>=0)return!1;if(y=y.prevZ,v.x>=p&&v.x<=m&&v.y>=f&&v.y<=g&&v!==r&&v!==s&&Hh(a,u,l,h,c,d,v.x,v.y)&&$h(v.prev,v,v.next)>=0)return!1;v=v.nextZ}for(;y&&y.z>=_;){if(y.x>=p&&y.x<=m&&y.y>=f&&y.y<=g&&y!==r&&y!==s&&Hh(a,u,l,h,c,d,y.x,y.y)&&$h(y.prev,y,y.next)>=0)return!1;y=y.prevZ}for(;v&&v.z<=A;){if(v.x>=p&&v.x<=m&&v.y>=f&&v.y<=g&&v!==r&&v!==s&&Hh(a,u,l,h,c,d,v.x,v.y)&&$h(v.prev,v,v.next)>=0)return!1;v=v.nextZ}return!0}function Dh(e,t){let i=e;do{const n=i.prev,r=i.next.next;!Zh(n,r)&&Wh(n,i,i.next,r)&&Xh(n,r)&&Xh(r,n)&&(t.push(n.i,i.i,r.i),ed(i),ed(i.next),i=e=r),i=i.next}while(i!==e);return Rh(i)}function Oh(e,t,i,n,r,o){let s=e;do{let e=s.next.next;for(;e!==s.prev;){if(s.i!==e.i&&Qh(s,e)){let a=Jh(s,e);return s=Rh(s,s.next),a=Rh(a,a.next),Lh(s,t,i,n,r,o,0),void Lh(a,t,i,n,r,o,0)}e=e.next}s=s.next}while(s!==e)}function zh(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 Uh(e,t){const i=function(e,t){let i=t;const n=e.x,r=e.y;let o,s=-1/0;if(Zh(e,i))return i;do{if(Zh(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>s&&(s=e,o=i.x=i.x&&i.x>=l&&n!==i.x&&Gh(ro.x||i.x===o.x&&Nh(o,i)))&&(o=i,u=t)}i=i.next}while(i!==a);return o}(e,t);if(!i)return t;const n=Jh(i,e);return Rh(n,n.next),Rh(i,i.next)}function Nh(e,t){return $h(e.prev,e,t.prev)<0&&$h(t.next,e,e.next)<0}function Vh(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 jh(e){let t=e,i=e;do{(t.x=(e-s)*(o-a)&&(e-s)*(n-a)>=(i-s)*(t-a)&&(i-s)*(o-a)>=(r-s)*(n-a)}function Hh(e,t,i,n,r,o,s,a){return!(e===s&&t===a)&&Gh(e,t,i,n,r,o,s,a)}function Qh(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&&Wh(i,i.next,e,t))return!0;i=i.next}while(i!==e);return!1}(e,t)&&(Xh(e,t)&&Xh(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)&&($h(e.prev,e,t.prev)||$h(e,t.prev,t))||Zh(e,t)&&$h(e.prev,e,e.next)>0&&$h(t.prev,t,t.next)>0)}function $h(e,t,i){return(t.y-e.y)*(i.x-t.x)-(t.x-e.x)*(i.y-t.y)}function Zh(e,t){return e.x===t.x&&e.y===t.y}function Wh(e,t,i,n){const r=Kh($h(e,t,i)),o=Kh($h(e,t,n)),s=Kh($h(i,n,e)),a=Kh($h(i,n,t));return r!==o&&s!==a||!(0!==r||!qh(e,i,t))||!(0!==o||!qh(e,n,t))||!(0!==s||!qh(i,e,n))||!(0!==a||!qh(i,t,n))}function qh(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 Kh(e){return e>0?1:e<0?-1:0}function Xh(e,t){return $h(e.prev,e,e.next)<0?$h(e,t,e.next)>=0&&$h(e,e.prev,t)>=0:$h(e,t,e.prev)<0||$h(e,e.next,t)<0}function Jh(e,t){const i=td(e.i,e.x,e.y),n=td(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 Yh(e,t,i,n){const r=td(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 ed(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 td(e,t,i){return{i:e,x:t,y:i,prev:null,next:null,z:0,prevZ:null,nextZ:null,steiner:!1}}function id(e,t){const i=e.length;if(i<=1)return[e];const n=[];let r,o;for(let t=0;t1)for(let e=0;e=Nn&&t>=Nn}static evaluate(e){if(0===e.length)return new ld;let t=[];for(const i of e)t.push(...i.portals);if(0===t.length)return new ld;for(const e of t){const t=e.va,i=e.vb;(ld.isOnBorder(t.x,i.x)||ld.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 ld;n.sort((e,t)=>e.hash===t.hash?e.isTunnel===t.isTunnel?0:e.isTunnel?-1:1:e.hashe.hash"fill-tunnel-structure-color"!==e),this.tunnelProgramConfigurations=new Nl(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=r.min.x&&c.x<=r.max.x&&c.y>=r.min.y&&c.y<=r.max.y||u.x>=r.min.x&&u.x<=r.max.x&&u.y>=r.min.y&&u.y<=r.max.y||_u(c,u,s)))continue;if(this.isOnBorder(c.x,u.x)||this.isOnBorder(c.y,u.y))continue;const h=ud.computeEdgeHash(this.unevalVertices[i],this.unevalVertices[l]);let d,p=this.vertexHashLookup.get(ud.computePosHash(c));null!=p?d=p.next:(p=this.vertexHashLookup.get(ud.computePosHash(u)),d=null!=p?p.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)return;this.portalPolygons.add(e,{geometry:t,zLevel:r});const o=t[0];this.vertexHashLookup.clear();let s=ud.computeEdgeHash(o[o.length-2],o[o.length-1]);for(let t=0;t({vertexOffset:0,primitiveOffset:this.indexArray.length}),i=e=>{e.primitiveLength=this.indexArray.length-e.primitiveOffset},n=new cd(this.vertexPositions,this.vertexNormals,this.indexArray);this.prepareEdges(e.portals,this.unevalEdges);const r=t(),o=t(),s=t(),a=(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=a(this.unevalEdges,"none"),this.constructBridgeStructures(n,this.unevalVertices,this.unevalHeights,this.unevalEdges,{min:0,max:l},this.tileToMeters)),i(s);const c=t(),u=t();if(this.unevalEdges.length>0){const e=this.unevalEdges.splice(l),t=a(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(c),n.addTriangles(this.unevalTriangles,this.unevalVertices,this.unevalHeights),i(u),n.addTriangles(this.unevalTunnelTriangles,this.unevalVertices,this.unevalHeights),i(o),n.addTriangles(this.unevalTunnelTriangles,this.unevalVertices,[-.1]),i(r),this.maskSegments=hl.simpleSegment(0,u.primitiveOffset,0,u.primitiveLength),this.depthSegments=hl.simpleSegment(0,o.primitiveOffset,0,o.primitiveLength),this.renderableBridgeSegments=hl.simpleSegment(0,s.primitiveOffset,0,s.primitiveLength),this.renderableTunnelSegments=hl.simpleSegment(0,c.primitiveOffset,0,c.primitiveLength),this.shadowCasterSegments=hl.simpleSegment(0,r.primitiveOffset,0,r.primitiveLength)}update(e,t,i,n,r,o,s,a){this.bridgeProgramConfigurations.updatePaintArrays(e,t,r,i,n,o,s,a),this.tunnelProgramConfigurations.updatePaintArrays(e,t,r,i,n,o,s,a)}upload(e){this.vertexBuffer||0===this.vertexPositions.length||0===this.vertexNormals.length||0===this.indexArray.length||(this.vertexBuffer=e.createVertexBuffer(this.vertexPositions,Bh.members),this.vertexBufferNormal=e.createVertexBuffer(this.vertexNormals,Ih.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,s)=>{for(let a=0;aC(e,t[n].x,t[n].y,i[n]*a),u=b(),h=b(),d=b(),p=b(),f=b(),m=(e,i)=>{const n=s.get(ud.computePosHash(t[i])),r=n.from,o=n.to;if(!r||!o)return;c(u,r),c(h,i),c(d,o),Q(p),$(u,h)||(Z(f,h,u),z(p,f)),$(d,h)||(Z(f,d,h),S(p,p,z(f,f)));const a=q(p);return a>0?R(e,p,1/a):void 0};let g=Number.POSITIVE_INFINITY;this.sortSubarray(n,r.min,r.max,(e,t)=>e.featureInfo.featureIndex-t.featureInfo.featureIndex);const _=b(),A=b(),y=b(),v=b(),x=b(),w=b(),T=b(),E=b(),B=b(),I=[b(),b(),b(),b()],M=[b(),b(),b(),b()],P=[{coord:new Te(0,0),height:0},{coord:new Te(0,0),height:0}],L=(e,t)=>e>t;for(let c=r.min;ce.featureInfo.featureIndex-t.featureInfo.featureIndex;this.sortSubarray(n,r.min,r.max,a),this.sortSubarray(n,o.min,o.max,a);const l=e=>z(e,e),c=[{coord:new Te(0,0),height:0},{coord:new Te(0,0),height:0}],u=(e,t)=>ee.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)&&(re.portalHasho.hash?i++:o.hash>r.portalHash?n++:(r.type=o.type,i++)}}}isOnBorder(e,t){return e<=0&&t<=0||e>=Nn&&t>=Nn}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(ud.computePosHash(e))<<32n|BigInt(ud.computePosHash(t))}static computePosHash(e){return((65535&e.x)<<16|65535&e.y)>>>0}}var hd,dd={exports:{}},pd=(hd||(hd=1,function(e,t){!function(e){function t(e,t){return e>t?1:e0){var a=n+Math.floor(s/2),l={key:t[a],data:i[a],parent:e};return l.left=r(l,t,i,n,a),l.right=r(l,t,i,a+1,o),l}return null}function o(e,t,i,n,r){if(!(i>=n)){for(var s=e[i+n>>1],a=i-1,l=n+1;;){do{a++}while(r(e[a],s)<0);do{l--}while(r(e[l],s)>0);if(a>=l)break;var c=e[a];e[a]=e[l],e[l]=c,c=t[a],t[a]=t[l],t[l]=c}o(e,t,i,l,r),o(e,t,l+1,n,r)}}i.prototype.rotateLeft=function(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},i.prototype.rotateRight=function(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},i.prototype._splay=function(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)}},i.prototype.splay=function(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)},i.prototype.replace=function(e,t){e.parent?e===e.parent.left?e.parent.left=t:e.parent.right=t:this._root=t,t&&(t.parent=e.parent)},i.prototype.minNode=function(e){if(void 0===e&&(e=this._root),e)for(;e.left;)e=e.left;return e},i.prototype.maxNode=function(e){if(void 0===e&&(e=this._root),e)for(;e.right;)e=e.right;return e},i.prototype.insert=function(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},i.prototype.find=function(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},i.prototype.contains=function(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},i.prototype.remove=function(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},i.prototype.removeNode=function(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},i.prototype.erase=function(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--}},i.prototype.pop=function(){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},i.prototype.next=function(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},i.prototype.prev=function(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},i.prototype.forEach=function(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},i.prototype.range=function(e,t,i,n){for(var r=[],o=this._compare,s=this._root;0!==r.length||s;)if(s)r.push(s),s=s.left;else{if(o((s=r.pop()).key,t)>0)break;if(o(s.key,e)>=0&&i.call(n,s))return this;s=s.right}return this},i.prototype.keys=function(){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},i.prototype.values=function(){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},i.prototype.at=function(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},i.prototype.load=function(e,t,i){if(void 0===e&&(e=[]),void 0===t&&(t=[]),void 0===i&&(i=!1),0!==this._size)throw new Error("bulk-load: tree is not empty");var n=e.length;return i&&o(e,t,0,n-1,this._compare),this._root=r(null,e,t,0,n),this._size=n,this},i.prototype.min=function(){var e=this.minNode(this._root);return e?e.key:null},i.prototype.max=function(){var e=this.maxNode(this._root);return e?e.key:null},i.prototype.isEmpty=function(){return null===this._root},n.size.get=function(){return this._size},i.createTree=function(e,t,n,r,o){return new i(n,o).load(e,t,r)},Object.defineProperties(i.prototype,n);var s=0,a=1,l=2,c=3,u=0,h=1,d=2,p=3;function f(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=!m(t,i)||t.isVertical()?t.prevInResult:t));var n=m(e,i);e.resultTransition=n?function(e,t){var i,n=!e.inOut,r=!e.otherInOut;switch(t){case u:i=n&&r;break;case h:i=n||r;break;case p:i=n^r;break;case d:i=e.isSubject?n&&!r:r&&!n}return i?1:-1}(e,i):0}function m(e,t){switch(e.type){case s:switch(t){case u:return!e.otherInOut;case h:return e.otherInOut;case d:return e.isSubject&&e.otherInOut||!e.isSubject&&!e.otherInOut;case p:return!0}break;case l:return t===u||t===h;case c:return t===d;case a:return!1}return!1}var g=function(e,t,i,n,r){this.left=t,this.point=e,this.otherEvent=i,this.isSubject=n,this.type=r||s,this.inOut=!1,this.otherInOut=!1,this.prevInResult=null,this.resultTransition=0,this.otherPos=-1,this.outputContourId=-1,this.isExteriorRing=!0},_={inResult:{configurable:!0}};function A(e,t){return e[0]===t[0]&&e[1]===t[1]}g.prototype.isBelow=function(e){var 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},g.prototype.isAbove=function(e){return!this.isBelow(e)},g.prototype.isVertical=function(){return this.point[0]===this.otherEvent.point[0]},_.inResult.get=function(){return 0!==this.resultTransition},g.prototype.clone=function(){var e=new g(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},Object.defineProperties(g.prototype,_);var y=11102230246251565e-32,v=134217729,x=(3+8*y)*y;function b(e,t,i,n,r){var o,s,a,l,c=t[0],u=n[0],h=0,d=0;u>c==u>-c?(o=c,c=t[++h]):(o=u,u=n[++d]);var p=0;if(hc==u>-c?(a=o-((s=c+o)-c),c=t[++h]):(a=o-((s=u+o)-u),u=n[++d]),o=s,0!==a&&(r[p++]=a);hc==u>-c?(a=o-((s=o+c)-(l=s-o))+(c-l),c=t[++h]):(a=o-((s=o+u)-(l=s-o))+(u-l),u=n[++d]),o=s,0!==a&&(r[p++]=a);for(;h0!=a>0)return l;var c=Math.abs(s+a);return Math.abs(l)>=T*c?l:-function(e,t,i,n,r,o,s){var a,l,c,u,h,d,p,f,m,g,_,A,y,w,T,R,L,F,k=e-r,D=i-r,O=t-o,z=n-o;S[0]=(T=(f=k-(p=(d=v*k)-(d-k)))*(g=z-(m=(d=v*z)-(d-z)))-((w=k*z)-p*m-f*m-p*g))-((_=T-(L=(f=O-(p=(d=v*O)-(d-O)))*(g=D-(m=(d=v*D)-(d-D)))-((R=O*D)-p*m-f*m-p*g)))+(h=T-_))+(h-L),S[1]=(y=w-((A=w+_)-(h=A-w))+(_-h))-((_=y-R)+(h=y-_))+(h-R),S[2]=A-((F=A+_)-(h=F-A))+(_-h),S[3]=F;var U=function(e,t){for(var i=t[0],n=1;n<4;n++)i+=t[n];return i}(0,S),N=E*s;if(U>=N||-U>=N)return U;if(a=e-(k+(h=e-k))+(h-r),c=i-(D+(h=i-D))+(h-r),l=t-(O+(h=t-O))+(h-o),u=n-(z+(h=n-z))+(h-o),0===a&&0===l&&0===c&&0===u)return U;if(N=C*s+x*Math.abs(U),(U+=k*u+z*a-(O*c+D*l))>=N||-U>=N)return U;P[0]=(T=(f=a-(p=(d=v*a)-(d-a)))*(g=z-(m=(d=v*z)-(d-z)))-((w=a*z)-p*m-f*m-p*g))-((_=T-(L=(f=l-(p=(d=v*l)-(d-l)))*(g=D-(m=(d=v*D)-(d-D)))-((R=l*D)-p*m-f*m-p*g)))+(h=T-_))+(h-L),P[1]=(y=w-((A=w+_)-(h=A-w))+(_-h))-((_=y-R)+(h=y-_))+(h-R),P[2]=A-((F=A+_)-(h=F-A))+(_-h),P[3]=F;var V=b(4,S,4,P,B);P[0]=(T=(f=k-(p=(d=v*k)-(d-k)))*(g=u-(m=(d=v*u)-(d-u)))-((w=k*u)-p*m-f*m-p*g))-((_=T-(L=(f=O-(p=(d=v*O)-(d-O)))*(g=c-(m=(d=v*c)-(d-c)))-((R=O*c)-p*m-f*m-p*g)))+(h=T-_))+(h-L),P[1]=(y=w-((A=w+_)-(h=A-w))+(_-h))-((_=y-R)+(h=y-_))+(h-R),P[2]=A-((F=A+_)-(h=F-A))+(_-h),P[3]=F;var j=b(V,B,4,P,I);P[0]=(T=(f=a-(p=(d=v*a)-(d-a)))*(g=u-(m=(d=v*u)-(d-u)))-((w=a*u)-p*m-f*m-p*g))-((_=T-(L=(f=l-(p=(d=v*l)-(d-l)))*(g=c-(m=(d=v*c)-(d-c)))-((R=l*c)-p*m-f*m-p*g)))+(h=T-_))+(h-L),P[1]=(y=w-((A=w+_)-(h=A-w))+(_-h))-((_=y-R)+(h=y-_))+(h-R),P[2]=A-((F=A+_)-(h=F-A))+(_-h),P[3]=F;var G=b(j,I,4,P,M);return M[G-1]}(e,t,i,n,r,o,c)}(e[0],e[1],t[0],t[1],i[0],i[1]);return n>0?-1:n<0?1:0}function L(e,t){var i=e.point,n=t.point;return i[0]>n[0]?1:i[0]n[1]?1:-1:function(e,t,i){return e.left!==t.left?e.left?1:-1:0!==R(i,e.otherEvent.point,t.otherEvent.point)?e.isBelow(t.otherEvent.point)?-1:1:!e.isSubject&&t.isSubject?1:-1}(e,t,i)}function F(e,t,i){var n=new g(t,!1,e,e.isSubject),r=new g(t,!0,e.otherEvent,e.isSubject);return A(e.point,e.otherEvent.point)&&console.warn("what is that, a collapsed segment?",e),n.contourId=r.contourId=e.contourId,L(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 k(e,t){return e[0]*t[1]-e[1]*t[0]}function D(e,t){return e[0]*t[0]+e[1]*t[1]}function O(e,t,i){var n=function(e,t,i,n){var r=[t[0]-e[0],t[1]-e[1]],o=[n[0]-i[0],n[1]-i[1]];function s(e,t,i){return[e[0]+t*i[0],e[1]+t*i[1]]}var a=[i[0]-e[0],i[1]-e[1]],l=k(r,o),c=l*l,u=D(r,r);if(c>0){var h=k(a,o)/l;if(h<0||h>1)return null;var d=k(a,r)/l;return d<0||d>1?null:0===h||1===h?[s(e,h,r)]:0===d||1===d?[s(i,d,o)]:[s(e,h,r)]}if((c=(l=k(a,r))*l)>0)return null;var p=D(r,a)/u,f=p+D(r,o)/u,m=Math.min(p,f),g=Math.max(p,f);return m<=1&&g>=0?1===m?[s(e,m>0?m:0,r)]:0===g?[s(e,g<1?g:1,r)]:[s(e,m>0?m:0,r),s(e,g<1?g:1,r)]:null}(e.point,e.otherEvent.point,t.point,t.otherEvent.point),r=n?n.length:0;if(0===r)return 0;if(1===r&&(A(e.point,t.point)||A(e.otherEvent.point,t.otherEvent.point)))return 0;if(2===r&&e.isSubject===t.isSubject)return 0;if(1===r)return A(e.point,n[0])||A(e.otherEvent.point,n[0])||F(e,n[0],i),A(t.point,n[0])||A(t.otherEvent.point,n[0])||F(t,n[0],i),1;var o=[],s=!1,u=!1;return A(e.point,t.point)?s=!0:1===L(e,t)?o.push(t,e):o.push(e,t),A(e.otherEvent.point,t.otherEvent.point)?u=!0:1===L(e.otherEvent,t.otherEvent)?o.push(t.otherEvent,e.otherEvent):o.push(e.otherEvent,t.otherEvent),s&&u||s?(t.type=a,e.type=t.inOut===e.inOut?l:c,s&&!u&&F(o[1].otherEvent,o[0].point,i),2):u?(F(o[0],o[1].point,i),3):o[0]!==o[3].otherEvent?(F(o[0],o[1].point,i),F(o[1],o[2].point,i),3):(F(o[0],o[1].point,i),F(o[3].otherEvent,o[2].point,i),3)}function z(e,t){if(e===t)return 0;if(0!==R(e.point,e.otherEvent.point,t.point)||0!==R(e.point,e.otherEvent.point,t.otherEvent.point))return A(e.point,t.point)?e.isBelow(t.otherEvent.point)?-1:1:e.point[0]===t.point[0]?e.point[1]t.contourId?1:-1:1===L(e,t)?1:-1}var U=function(){this.points=[],this.holeIds=[],this.holeOf=null,this.depth=null};function N(e,t,i,n){var r,o=e+1,s=t[e].point,a=t.length;for(on;)o--;return o}U.prototype.isExterior=function(){return null==this.holeOf};var V=G,j=G;function G(e,t){if(!(this instanceof G))return new G(e,t);if(this.data=e||[],this.length=this.data.length,this.compare=t||H,this.length>0)for(var i=(this.length>>1)-1;i>=0;i--)this._down(i)}function H(e,t){return et?1:0}G.prototype={push:function(e){this.data.push(e),this.length++,this._up(this.length-1)},pop:function(){if(0!==this.length){var e=this.data[0];return this.length--,this.length>0&&(this.data[0]=this.data[this.length],this._down(0)),this.data.pop(),e}},peek:function(){return this.data[0]},_up:function(e){for(var t=this.data,i=this.compare,n=t[e];e>0;){var r=e-1>>1,o=t[r];if(i(n,o)>=0)break;t[e]=o,e=r}t[e]=n},_down:function(e){for(var t=this.data,i=this.compare,n=this.length>>1,r=t[e];e=0)break;t[e]=a,e=o}t[e]=r}},V.default=j;var Q=Math.max,$=Math.min,Z=0;function W(e,t,i,n,r,o){var s,a,l,c,u,h;for(s=0,a=e.length-1;s0?h.left=!0:u.left=!0;var d=l[0],p=l[1];r[0]=$(r[0],d),r[1]=$(r[1],p),r[2]=Q(r[2],d),r[3]=Q(r[3],p),n.push(u),n.push(h)}}var q=[];function K(e,t,n){"number"==typeof e[0][0][0]&&(e=[e]),"number"==typeof t[0][0][0]&&(t=[t]);var r=function(e,t,i){var n=null;return e.length*t.length==0&&(i===u?n=q:i===d?n=e:i!==h&&i!==p||(n=0===e.length?t:e)),n}(e,t,n);if(r)return r===q?null:r;var o=[1/0,1/0,-1/0,-1/0],s=[1/0,1/0,-1/0,-1/0],a=function(e,t,i,n,r){var o,s,a,l,c,u,h=new V(null,L);for(a=0,l=e.length;an[2]||n[0]>i[2]||i[1]>n[3]||n[1]>i[3])&&(r===u?o=q:r===d?o=e:r!==h&&r!==p||(o=e.concat(t))),o}(e,t,o,s,n))return r===q?null:r;for(var l=function(e){var t,i,n=function(e){var t,i,n,r,o=[];for(i=0,n=e.length;i0){var s=t[o];if(null!=s.holeOf){var a=s.holeOf;t[a].holeIds.push(i),n.holeOf=a,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}(n[t],o,e),s=function(t){r[t]=!0,t=n.length)&&n[a];);o.push(i)}};for(t=0,i=n.length;tm||s===d&&g.point[0]>r[2])break;if(g.left){l=a=h.insert(g),a=a!==(c=h.minNode())?h.prev(a):null,l=h.next(l);var _=a?a.key:null;if(f(g,_,s),l&&2===O(g,l.key,e)&&(f(g,_,s),f(l.key,g,s)),a&&2===O(a.key,g,e)){var A=a;f(_,(A=A!==c?h.prev(A):null)?A.key:null,s),f(g,_,s)}}else l=a=h.find(g=g.otherEvent),a&&l&&(a=a!==c?h.prev(a):null,l=h.next(l),h.remove(g),l&&a&&O(a.key,l.key,e))}return p}(a,0,0,o,s,n)),c=[],m=0;m * @license MIT * @preserve - */function fd(e,t,i,r){const n=[],o=0===r?(e,t,i,r,n,o)=>{e.push(new Te(o,i+(o-t)/(r-t)*(n-i)))}:(e,t,i,r,n,o)=>{e.push(new Te(t+(o-i)/(n-i)*(r-t),o))};for(const s of e){const e=[];for(const n of s){if(n.length<=2)continue;const s=[];for(let e=0;et&&o(s,a,l,c,u,t):h>i?d=t&&o(s,a,l,c,u,t),d>i&&h<=i&&o(s,a,l,c,u,i)}let a=n[n.length-1];const l=0===r?a.x:a.y;l>=t&&l<=i&&s.push(a),s.length&&(a=s[s.length-1],s[0].x===a.x&&s[0].y===a.y||s.push(s[0]),e.push(s))}e.length&&n.push(e)}return n}function md(e,t){const i=_d(e),r=_d([t]),n=pd.intersection(i,r);return null==n?[]:Ad(n)}function gd(e,t){const i=65536;let r=_d(e,i);const n=[];for(;t.valid();t.next()){const[e,r]=t.get(),o=e.x*i,s=e.y*i,a=r.x*i,l=r.y*i,c=a-o,u=l-s,h=Math.hypot(c,u);if(0===h)continue;const d=Math.trunc(u/h*3),p=-Math.trunc(c/h*3);n.push([[[o,s],[a,l],[a+d,l+p],[o+d,s+p],[o,s]]])}return n.length>0&&(r=pd.diff(r,n)),Ad(r,1/i)}function _d(e,t=1){return[e.map(e=>e.map(e=>[e.x*t,e.y*t]))]}function Ad(e,t=1){return e.map(e=>e.map((e,i)=>{const r=e.map(e=>new Te(e[0]*t,e[1]*t).round());return i>0&&r.reverse(),r}))}class yd{constructor(e,t){this.layoutVertexArray=new pa,this.indexArray=new Fa,this.lineIndexArray=new Ia,this.triangleSegments=new hl,this.lineSegments=new hl,this.programConfigurations=new Nl(e.layers,{zoom:e.zoom,lut:e.lut}),this.uploaded=!1,t&&(this.elevatedLayoutVertexArray=new ga)}update(e,t,i,r,n,o,s,a){this.programConfigurations.updatePaintArrays(e,t,n,i,r,o,s,a)}isEmpty(){return 0===this.layoutVertexArray.length}needsUpload(){return this.programConfigurations.needsUpload}upload(e){this.uploaded||(this.layoutVertexBuffer=e.createVertexBuffer(this.layoutVertexArray,Ch.members),this.indexBuffer=e.createIndexBuffer(this.indexArray),this.lineIndexBuffer=e.createIndexBuffer(this.lineIndexArray),this.elevatedLayoutVertexArray&&this.elevatedLayoutVertexArray.length>0&&(this.elevatedLayoutVertexBuffer=e.createVertexBuffer(this.elevatedLayoutVertexArray,Bh.members))),this.programConfigurations.upload(e),this.uploaded=!0}destroy(){this.layoutVertexBuffer&&(this.elevatedLayoutVertexBuffer&&this.elevatedLayoutVertexBuffer.destroy(),this.layoutVertexBuffer.destroy(),this.indexBuffer.destroy(),this.lineIndexBuffer.destroy(),this.programConfigurations.destroy(),this.triangleSegments.destroy(),this.lineSegments.destroy())}populatePaintArrays(e,t,i,r,n,o,s){this.programConfigurations.populatePaintArrays(this.layoutVertexArray.length,e,t,i,r,n,o,void 0,s)}}class vd{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 yd(e,!1),this.elevationBufferData=new yd(e,!0),this.stateDependentLayerIds=this.layers.filter(e=>e.isStateDependent()).map(e=>e.id),this.projection=e.projection,this.elevationMode=this.layers[0].layout.get("fill-elevation-reference"),this.sourceLayerIndex=e.sourceLayerIndex,this.worldview=e.worldview,this.hasAppearances=null}updateFootprints(e,t){}updateAppearances(e,t,i,r){}populate(e,t,i,r){this.hasPattern=od("fill",this.layers,this.pixelRatio,t);const n=this.layers[0].layout.get("fill-sort-key"),o=[];for(const{feature:s,id:a,index:l,sourceLayerIndex:c}of e){const e=this.layers[0]._featureFilter.needGeometry,u=Ic(s,e);if(!this.layers[0]._featureFilter.filter(new Es(this.zoom,{worldview:this.worldview,activeFloors:t.activeFloors}),u,i))continue;const h=n?n.evaluate(u,{},i,t.availableImages):void 0,d={id:a,properties:s.properties,type:s.type,sourceLayerIndex:c,index:l,geometry:e?u.geometry:Sc(s,i,r),patterns:{},sortKey:h};o.push(d)}n&&o.sort((e,t)=>e.sortKey-t.sortKey);for(const r of o){const{geometry:n,index:o,sourceLayerIndex:s}=r;if(this.hasPattern){const e=sd("fill",this.layers,r,this.zoom,this.pixelRatio,t);this.patternFeatures.push(e)}else this.addFeature(r,n,o,i,{},t.availableImages,t.brightness,t.elevationFeatures);t.featureIndex.insert(e[o].feature,n,o,s,this.index)}}update(e,t,i,r,n,o,s){this.bufferData.update(e,t,i,r,n,o,s,this.worldview),this.elevationBufferData.update(e,t,i,r,n,o,s,this.worldview),this.elevatedStructures&&this.elevatedStructures.update(e,t,i,r,n,o,s,this.worldview)}addFeatures(e,t,i,r,n,o){for(const n of this.patternFeatures)this.addFeature(n,n.geometry,n.index,t,i,r,o,e.elevationFeatures)}isEmpty(){return this.bufferData.isEmpty()&&this.elevationBufferData.isEmpty()}uploadPending(){return!this.uploaded||this.bufferData.needsUpload()||this.elevationBufferData.needsUpload()}upload(e){this.bufferData.upload(e),this.elevationBufferData.upload(e),this.elevatedStructures&&this.elevatedStructures.upload(e)}destroy(){this.bufferData.destroy(),this.elevationBufferData.destroy(),this.elevatedStructures&&this.elevatedStructures.destroy()}addFeature(e,t,i,r,n,o=[],s,a){const l=id(t,500);"none"!==this.elevationMode?this.addElevatedRoadFeature(e,l,r,i,a):this.addGeometry(l,this.bufferData),this.bufferData.populatePaintArrays(e,i,n,o,r,s,this.worldview),this.elevationBufferData.populatePaintArrays(e,i,n,o,r,s,this.worldview)}getUnevaluatedPortalGraph(){return this.elevatedStructures?this.elevatedStructures.unevaluatedPortals:void 0}getElevationPolygons(){return this.elevatedStructures?this.elevatedStructures.portalPolygons:void 0}setEvaluatedPortalGraph(e,t,i,r,n){this.elevatedStructures&&(this.elevatedStructures.construct(e),this.elevatedStructures.populatePaintArrays(t,i,r,n,this.worldview))}addElevatedRoadFeature(e,t,i,r,n){const o=new Array,s=tu.getElevationFeature(e,n);if(!s)return void this.addGeometry(t,this.bufferData);{const e=this.clipPolygonsToTile(t,1);e.length>0&&o.push({polygons:e,elevationFeature:s,elevationTileID:i})}const a={guardRailEnabled:this.layers[0].layout.get("fill-construct-bridge-guard-rail").evaluate(e,{},i),featureIndex:r};for(const t of o)if(t.elevationFeature){if("hd-road-base"===this.elevationMode){this.elevatedStructures||(this.elevatedStructures=new ud(t.elevationTileID,this.layers,this.zoom,this.lut));const i=t.elevationFeature.isTunnel();let r=0;e.properties.hasOwnProperty(zc)&&(r=+e.properties[zc]);for(const e of t.polygons)this.elevatedStructures.addPortalCandidates(t.elevationFeature.id,e,i,t.elevationFeature,r)}null==t.elevationFeature.constantHeight&&(t.polygons=this.prepareElevatedPolygons(t.polygons,t.elevationFeature,t.elevationTileID));const n=new iu(i,t.elevationTileID);this.addElevatedGeometry(t.polygons,n,t.elevationFeature,"hd-road-base"===this.elevationMode?0:.05,r,a)}}addElevatedGeometry(e,t,i,r,n,o){const s={elevation:i,elevationSampler:t,bias:r,index:n,featureInfo:o},[a,l]=this.addGeometry(e,this.elevationBufferData,s);null==this.elevationBufferData.heightRange?this.elevationBufferData.heightRange={min:a,max:l}:(this.elevationBufferData.heightRange.min=Math.min(this.elevationBufferData.heightRange.min,a),this.elevationBufferData.heightRange.max=Math.max(this.elevationBufferData.heightRange.max,l))}addGeometry(e,t,i){let r=Number.POSITIVE_INFINITY,n=Number.NEGATIVE_INFINITY,o=null;i&&(o=i.elevationSampler.constantElevation(i.elevation,i.bias),null!=o&&(r=o,n=o));const s=(e,s,a)=>{if(null!=i)if(s.push(e),null!=o)t.elevatedLayoutVertexArray.emplaceBack(o),a.push(o);else{const o=i.elevationSampler.pointElevation(e,i.elevation,i.bias);t.elevatedLayoutVertexArray.emplaceBack(o),a.push(o),r=Math.min(r,o),n=Math.max(n,o)}};for(const r of e){let e=0;for(const t of r)e+=t.length;const n=t.triangleSegments.prepareSegment(e,t.layoutVertexArray,t.indexArray),o=n.vertexLength,a=[],l=[],c=[],u=[],h=[],d=t.layoutVertexArray.length;for(const e of r){if(0===e.length)continue;e!==r[0]&&l.push(a.length/2);const n=t.lineSegments.prepareSegment(e.length,t.layoutVertexArray,t.lineIndexArray),o=n.vertexLength;i&&h.push(t.layoutVertexArray.length-d),s(e[0],c,u),t.layoutVertexArray.emplaceBack(e[0].x,e[0].y),t.lineIndexArray.emplaceBack(o+e.length-1,o),a.push(e[0].x),a.push(e[0].y);for(let i=1;i0&&i&&"hd-road-base"===this.elevationMode){const e=i.elevation.isTunnel(),t=i.elevation.safeArea,r=this.elevatedStructures.addVertices(c,u);this.elevatedStructures.addTriangles(p,r,e);const n=h.length;if(n>0){for(let o=0;o=i&&c.max.x<=n&&c.min.y>=r&&c.max.y<=o?a:l).push(t)}if(a.length===e.length)return e;const c=[new Te(i,r),new Te(n,r),new Te(n,o),new Te(i,o),new Te(i,r)],u=a;for(const e of l)u.push(...md(e,c));return u}}let xd,bd,wd,Td;es(vd,"FillBucket",{omit:["layers","patternFeatures"]}),es(yd,"FillBufferData"),es(ud,"ElevatedStructures");class Ed{constructor(e,t,i,r){if(this.triangleCount=t.length/3,this.min=new Te(0,0),this.max=new Te(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[n,o]=[e[0].clone(),e[0].clone()];for(let t=1;te.cellIdx-t.cellIdx||e.triIdx-t.triIdx);let c=0;for(;cthis.max.x||this.min.x>e.x||e.y>this.max.y||this.min.y>e.y)return;const i=Cd(e.x-this.min.x,this.xScale,this.cellsX),r=Cd(e.y-this.min.y,this.yScale,this.cellsY),n=this.cells[r*this.cellsX+i];if(n){this._lazyInitLookup();for(let e=0;ethis.max.x||this.min.x>t.x)return;if(e.y>this.max.y||this.min.y>t.y)return;this._lazyInitLookup();const r=Cd(e.x-this.min.x,this.xScale,this.cellsX),n=Cd(t.x-this.min.x,this.xScale,this.cellsX),o=Cd(e.y-this.min.y,this.yScale,this.cellsY),s=Cd(t.y-this.min.y,this.yScale,this.cellsY);for(let e=o;e<=s;e++)for(let t=r;t<=n;t++){const r=this.cells[e*this.cellsX+t];if(r)for(let e=0;ee.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,r){}populate(e,t,i,r){const n=[];for(const{feature:o,id:s,index:a,sourceLayerIndex:l}of e){const e=this.layers[0]._featureFilter.needGeometry,c=Ic(o,e);if(!this.layers[0]._featureFilter.filter(new Es(this.zoom,{worldview:this.worldview,activeFloors:t.activeFloors}),c,i))continue;const u={id:s,properties:o.properties,type:o.type,sourceLayerIndex:l,index:a,geometry:e?c.geometry:Sc(o,i,r),patterns:{}};n.push(u)}for(const r of n){const{geometry:n,index:o,sourceLayerIndex:s}=r;this.addFeature(r,n,o,i,{},t.availableImages,t.brightness),t.featureIndex.insert(e[o].feature,n,o,s,this.index)}}isEmpty(){return 0===this.footprints.length}uploadPending(){return!1}upload(e){}update(e,t,i,r,n,o,s){}destroy(){}addFeature(e,t,i,r,n,o=[],s){for(const e of id(t,2)){const t=[],i=[],r=[],n=new Te(1/0,1/0),o=new Te(-1/0,-1/0);for(const s of e)if(0!==s.length){s!==e[0]&&r.push(i.length/2);for(let e=0;et===e)}(r,e.clipScope)}function Ud(e,t){return e.x-t.x||e.y-t.y}function Nd(e,t){return 0===Ud(e.min,t.min)&&0===Ud(e.max,t.max)}function Vd(e,t){return!(e.min.x>t.max.x||e.max.xt.max.y||e.max.ynew Te((e.x+o.x*Ur)*a-s.x*Ur,(e.y+o.y*Ur)*a-s.y*Ur))}return Qd(i,n,e.indices,0,e.indices.length,0,0)}function Zd(e,t,i,r){const n=Math.pow(2,r.z-i.z);return new Te((e+i.x*Ur)*n-r.x*Ur,(t+i.y*Ur)*n-r.y*Ur)}function Wd(e,t){const i=[];t.grid.queryPoint(e,i);const r=t.indices,n=t.vertices;for(let t=0;t0&&(r.length>1&&i.push(r),r=[])}return r.length>1&&i.push(r),i}const Xd=Mc.types,Jd=["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"],Yd=["fill-extrusion-flood-light-ground-radius"],ep=Math.pow(2,13),tp=Math.pow(2,15)-1,ip=new Te(0,1),rp=2147483648,np=7,op=450;function sp(e,t,i,r,n,o,s,a){e.emplaceBack((t<<1)+s,(i<<1)+o,(Math.floor(r*ep)<<1)+n,Math.round(a))}function ap(e,t,i){e.emplaceBack(t.x*Ur,t.y*Ur,i?1:0)}function lp(e,t,i,r,n,o){e.emplaceBack(t.x,t.y,(i.x<<1)+r,(i.y<<1)+n,o)}function cp(e,t,i){const r=16384;e.emplaceBack(t.x,t.y,t.z,i[0]*r,i[1]*r,i[2]*r)}class up{constructor(){this.vertexOffset=0,this.vertexCount=0,this.indexOffset=0,this.indexCount=0}}class hp{constructor(){this.centroidXY=new Te(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 Te(Number.MAX_VALUE,Number.MAX_VALUE),this.max=new Te(-Number.MAX_VALUE,-Number.MAX_VALUE),this.height=0,this.buildingId=0}span(){return new Te(this.max.x-this.min.x,this.max.y-this.min.y)}}class dp{constructor(){this.acc=new Te(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 r=!!this.borders;t.xe.max.x&&(e.max.x=t.x,r=!0),t.ye.max.y&&(e.max.y=t.y,r=!0),((0===t.x||t.x===Ur)&&t.x===i.x)!=((0===t.y||t.y===Ur)&&t.y===i.y)&&this.processBorderOverlap(t,i),r&&this.checkBorderIntersection(t,i)}checkBorderIntersection(e,t){t.x<0!=e.x<0&&this.addBorderIntersection(0,di(t.y,e.y,(0-t.x)/(e.x-t.x))),t.x>Ur!=e.x>Ur&&this.addBorderIntersection(1,di(t.y,e.y,(Ur-t.x)/(e.x-t.x))),t.y<0!=e.y<0&&this.addBorderIntersection(2,di(t.x,e.x,(0-t.y)/(e.y-t.y))),t.y>Ur!=e.y>Ur&&this.addBorderIntersection(3,di(t.x,e.x,(Ur-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];ti[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 Te(0,0):new Te(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 pp(e,t){const i=e.add(t)._unit(),r=Fe(e.x*i.x+e.y*i.y,-1,1);var n,o,s;return n=Math.acos(r),Math.min(4,Math.max(-4,Math.tan(n)))/4*tp*((o=e).x*(s=t).y-o.y*s.x<0?-1:1)}const fp=[e=>e.x<0,e=>e.x>Ur,e=>e.y<0,e=>e.y>Ur];function mp(e,t,i,r){const n=[4];if(0===r)return n;i._mult(r);const o=e.sub(i),s=t.sub(i),a=[e,t,o,s];for(let e=0;e<4;e++)for(const t of a)if(fp[e](t)){n.push(e);break}return n}class gp{constructor(e){this.groundRadiusArray=null,this.groundRadiusBuffer=null,this.vertexArray=new ya,this.indexArray=new Fa,this.programConfigurations=new Nl(e.layers,{zoom:e.zoom,lut:e.lut},e=>Yd.includes(e)),this._segments=new hl,this.hiddenByLandmarkVertexArray=new Wa,this._segmentToGroundQuads={},this._segmentToGroundQuads[0]=[],this._segmentToRegionTriCounts={},this._segmentToRegionTriCounts[0]=[0,0,0,0,0],this.regionSegments={},this.regionSegments[4]=new hl}getDefaultSegment(){return this.regionSegments[4]}hasData(){return 0!==this.vertexArray.length}addData(e,t,i,r=!1){const n=e.length;if(n>2){let o=Math.max(0,this._segments.get().length-1);const s=this._segments._prepareSegment(4*n,this.vertexArray.length,2*this._segmentToGroundQuads[o].length);let a;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];a=pp(t.sub(e[n-1])._perp()._unit(),i.sub(t)._perp()._unit())}for(let l=0;le.region-t.region);for(let i=0;ie+t,0);let o=0;for(let e=0;e<=4;e++){const t=n[e];if(0!==t){let i=this.regionSegments[e];i||(i=this.regionSegments[e]=new hl);const n={vertexOffset:r.vertexOffset,primitiveOffset:r.primitiveOffset+o,vertexLength:r.vertexLength,primitiveLength:t};i.get().push(n)}o+=t}for(let e=0;e0?this.hiddenByLandmarkVertexBuffer=e.createVertexBuffer(this.hiddenByLandmarkVertexArray,Ld.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 _p{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=[],this.footprintIndices=new Fa,this.footprintVertices=new pa,this.footprintSegments=[],this.layoutVertexArray=new ma,this.centroidVertexArray=new ol,this.wallVertexArray=new al,this.indexArray=new Fa,this.programConfigurations=new Nl(e.layers,{zoom:e.zoom,lut:e.lut},e=>Jd.includes(e)),this.segments=new hl,this.stateDependentLayerIds=this.layers.filter(e=>e.isStateDependent()).map(e=>e.id),this.groundEffect=new gp(e),this.maxHeight=0,this.partLookup={},this.triangleSubSegments=[],this.polygonSegments=[],this.worldview=e.worldview,this.hasAppearances=null}updateFootprints(e,t){}updateAppearances(e,t,i,r){}populate(e,t,i,r){this.features=[],this.hasPattern=od("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=yc(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:n,id:o,index:s,sourceLayerIndex:a}of e){const e=this.layers[0]._featureFilter.needGeometry,l=Ic(n,e);if(!this.layers[0]._featureFilter.filter(new Es(this.zoom,{worldview:this.worldview,activeFloors:t.activeFloors}),l,i))continue;const c={id:o,sourceLayerIndex:a,index:s,geometry:e?l.geometry:Sc(n,i,r),properties:n.properties,type:n.type,patterns:{}},u=this.layoutVertexArray.length,h="Polygon"===Xd[c.type];if(this.hasPattern)this.features.push({featureId:n.id,feature:sd("fill-extrusion",this.layers,c,this.zoom,this.pixelRatio,t)});else if(this.wallMode)for(const e of c.geometry)for(const o of Kd(e,h))this.addFeature(n.id,c,[o],s,i,{},t.availableImages,r,t.brightness);else this.addFeature(n.id,c,c.geometry,s,i,{},t.availableImages,r,t.brightness);t.featureIndex.insert(n,c.geometry,s,a,this.index,u)}this.sortBorders(),"mercator"===this.projection.name&&this.splitToSubtiles(),this.groundEffect.prepareBorderSegments(),this.polygonSegments.length=0}addFeatures(e,t,i,r,n,o){for(const{featureId:e,feature:s}of this.features){const a="Polygon"===Xd[s.type],{geometry:l}=s;if(this.wallMode)for(const c of l)for(const l of Kd(c,a))this.addFeature(e,s,[l],s.index,t,i,r,n,o);else this.addFeature(e,s,l,s.index,t,i,r,n,o)}this.sortBorders(),"mercator"===this.projection.name&&this.splitToSubtiles()}update(e,t,i,r,n,o,s){this.programConfigurations.updatePaintArrays(e,t,n,i,r,o,s,this.worldview),this.groundEffect.update(e,t,n,i,r,o,s,this.worldview)}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,kd),this.indexBuffer=e.createIndexBuffer(this.indexArray),this.wallVertexBuffer=e.createVertexBuffer(this.wallVertexArray,Rd.members),this.layoutVertexExtArray&&(this.layoutVertexExtBuffer=e.createVertexBuffer(this.layoutVertexExtArray,Fd.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,Pd.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,r,n,o,s,a,l){const c=this.layers[0].paint.get("fill-extrusion-flood-light-ground-radius").evaluate(t,{})/this.tileToMeter,u=[new Te(0,0),new Te(Ur,Ur)],h=a.projection,d="globe"===h.name,p=this.wallMode||"Polygon"===Xd[t.type],f=new dp;f.centroidDataIndex=this.centroidData.length;const m=new hp;m.buildingId=e,t.properties&&t.properties.hasOwnProperty("building_id")&&(m.buildingId=t.properties.building_id);const g=this.layers[0].paint.get("fill-extrusion-base").evaluate(t,{},n)<=0,_=this.layers[0].paint.get("fill-extrusion-height").evaluate(t,{},n);let A;if(m.height=_,m.vertexArrayOffset=this.layoutVertexArray.length,m.groundVertexArrayOffset=this.groundEffect.vertexArray.length,d&&!this.layoutVertexExtArray&&(this.layoutVertexExtArray=new Ta),this.wallMode){if(d)return void Ze("Non zero fill-extrusion-line-width is not yet supported on globe.");if(1!==i.length)return;A=function(e){const t=e[0].x===e[e.length-1].x&&e[0].y===e[e.length-1].y,i=function(e){let t=0;const i=e.length;for(let r=0;r=0}(e);i||(e=e.reverse());const r={geometry:[],joinNormals:[],indices:[]},n=[],o=[],s=[];let a=e.length;for(;a>=2&&e[a-1].equals(e[a-2]);)a--;if(a<(t?3:2))return r;let l,c,u,h,d,p=0;for(;p0;let _="miter";const A=2;"miter"===_&&m>A&&(_="bevel"),"bevel"===_&&(m>100&&(_="flipbevel"),m{const a=new Te(e.x,e.y),l=new Te(e.x,e.y);a.x+=t.x*r,a.y+=t.y*r,l.x-=t.x*Math.max(i,1),l.y-=t.y*Math.max(i,1),s.push(t),n.push(a),o.push(l)};if("miter"===_)r._mult(m),y(l,r,0,0);else if("flipbevel"===_)r=d.mult(-1),y(l,r,0,0),y(l,r.mult(-1),0,0);else{const e=-Math.sqrt(m*m-1),t=g?e:0,i=g?0:e;c&&y(l,h,t,i),u&&y(l,d,t,i)}}r.geometry=[...n,...o.reverse(),n[0]],r.joinNormals=[...s,...s.reverse(),s[s.length-1]];const f=r.geometry.length-1;for(let e=0;ee<(t.length-1)/2||e===t.length-1,v=this.wallMode?[i]:id(i,500);for(let e=v.length-1;e>=0;e--){const t=v[e];(0===t.length||(x=t[0]).every(e=>e.x<=0)||x.every(e=>e.x>=Ur)||x.every(e=>e.y<=0)||x.every(e=>e.y>=Ur))&&v.splice(e,1)}var x;let b;if(d)b=Cp(v,u,n);else{b=[];for(const e of v)b.push({polygon:e,bounds:u})}const w=p?this.edgeRadius:0,T=w>0&&this.zoom<17,E=(e,t)=>{if(0===e.length)return!1;const i=e[e.length-1];return t.x===i.x&&t.y===i.y};for(const{polygon:e,bounds:t}of b){let i=0,r=0;for(const t of e)p&&!t[0].equals(t[t.length-1])&&t.push(t[0]),r+=p?t.length-1:t.length;const o=this.segments.prepareSegment((p?5:4)*r,this.layoutVertexArray,this.indexArray);m.footprintSegIdx<0&&(m.footprintSegIdx=this.footprintSegments.length),m.polygonSegIdx<0&&(m.polygonSegIdx=this.polygonSegments.length);const s={triangleArrayOffset:this.indexArray.length,triangleCount:0,triangleSegIdx:this.segments.segments.length-1},a=new up;if(a.vertexOffset=this.footprintVertices.length,a.indexOffset=3*this.footprintIndices.length,a.ringIndices=[],p){const r=[],s=[];i=o.vertexLength;for(let i=0;i4&&wp(s[s.length-2],s[0],s[1]),l=w?yp(s[s.length-2],s[0],s[1],w):0;const u=[];let _,v,x;v=s[1].sub(s[0])._perp()._unit();let b=!0;for(let e=1,r=0;e0?1:0,I=c.dist(p);if(r+I>32768&&(r=0),w){x=T.sub(p)._perp()._unit();let e=vp(c,p,T,Ap(v,x),w);isNaN(e)&&(e=0);const t=p.sub(c)._unit();c=c.add(t.mult(l))._round(),p=p.add(t.mult(-e))._round(),l=e,v=x,g&&this.zoom>=17&&(E(u,c)||u.push(c),E(u,p)||u.push(p))}const M=o.vertexLength,P=s.length>4&&wp(c,p,T);let R=Tp(r,a,b);if(sp(this.layoutVertexArray,c.x,c.y,B,S,0,0,R),sp(this.layoutVertexArray,c.x,c.y,B,S,0,1,R),this.wallMode){const t=y(e-1,s),i=A.joinNormals[e-1];ap(this.wallVertexArray,i,t),ap(this.wallVertexArray,i,t)}if(r+=I,R=Tp(r,P,!b),a=P,sp(this.layoutVertexArray,p.x,p.y,B,S,0,0,R),sp(this.layoutVertexArray,p.x,p.y,B,S,0,1,R),this.wallMode){const t=y(e,s),i=A.joinNormals[e];ap(this.wallVertexArray,i,t),ap(this.wallVertexArray,i,t)}if(o.vertexLength+=4,this.indexArray.emplaceBack(M+0,M+1,M+2),this.indexArray.emplaceBack(M+1,M+3,M+2),o.primitiveLength+=2,w){const r=i+(1===e?s.length-2:e-2),n=1===e?i:r+1;if(this.indexArray.emplaceBack(M+1,r,M+3),this.indexArray.emplaceBack(r,n,M+3),o.primitiveLength+=2,void 0===_&&(_=M),!xp(T,s[e],t)){const t=e===s.length-1?_:o.vertexLength;this.indexArray.emplaceBack(M+2,M+3,t),this.indexArray.emplaceBack(M+3,t+1,t),this.indexArray.emplaceBack(M+3,n,t+1),o.primitiveLength+=3}b=!b}if(d){const e=this.layoutVertexExtArray,t=h.projectTilePoint(c.x,c.y,n),i=h.projectTilePoint(p.x,p.y,n),r=h.upVector(n,c.x,c.y),o=h.upVector(n,p.x,p.y);cp(e,t,r),cp(e,t,r),cp(e,i,o),cp(e,i,o)}}p&&(i+=s.length-1),g&&w&&this.zoom>=17&&(0!==u.length&&E(u,u[0])&&u.pop(),this.groundEffect.addData(u,t,c,w>0))}this.footprintSegments.push(a),s.triangleCount=this.indexArray.length-s.triangleArrayOffset,this.polygonSegments.push(s),++m.footprintSegLen,++m.polygonSegLen}if(m.vertexCount=this.layoutVertexArray.length-m.vertexArrayOffset,m.groundVertexCount=this.groundEffect.vertexArray.length-m.groundVertexArrayOffset,0!==m.vertexCount){if(m.centroidXY=f.borders?ip:this.encodeCentroid(f,m),this.centroidData.push(m),f.borders){this.featuresOnBorder.push(f);const e=this.featuresOnBorder.length-1;for(let t=0;tthis.featuresOnBorder[t].borders[e][0]-this.featuresOnBorder[i].borders[e][0])}splitToSubtiles(){const e=[];for(let t=0;tUr),n=2*r+(+(i.min.x+i.max.x>Ur)^r);for(let r=0;re.triangleSegmentIdx===t.triangleSegmentIdx?e.subtile-t.subtile:e.triangleSegmentIdx-t.triangleSegmentIdx);let i=0,r=0,n=0;for(const t of e){if(t.triangleSegmentIdx!==i)break;n++}const o=e.length;for(;r!==e.length;){i=e[r].triangleSegmentIdx;let s=0,a=r,l=r;for(let t=a;t0&&this.triangleSubSegments.push({segment:u,min:o,max:c}),a=l;for(let t=a;t[e[0]*(1-i[0])+t[0]*i[0],e[1]*(1-i[1])+t[1]*i[1]],d=[],p=[];for(const e of this.triangleSubSegments){d[0]=e.min.x/Ur,d[1]=e.min.y/Ur,p[0]=e.max.x/Ur,p[1]=e.max.y/Ur;const t=h(c,u,d),s=h(c,u,p);if(0===new Jc([t[0],t[1],n],[s[0],s[1],o]).intersectsPrecise(i)){l&&(r.segments.push(l),l=void 0);continue}const a=e.segment;l&&l.vertexOffset!==a.vertexOffset&&(r.segments.push(l),l=void 0),l?(l.vertexLength+=a.vertexLength,l.primitiveLength+=a.primitiveLength):l={vertexOffset:a.vertexOffset,primitiveLength:a.primitiveLength,vertexLength:a.vertexLength,primitiveOffset:a.primitiveOffset,sortKey:void 0,vaos:{}}}return l&&r.segments.push(l),r}encodeCentroid(e,t){const i=e.centroid(),r=t.span(),n=Math.min(7,Math.round(r.x*this.tileToMeter/10)),o=Math.min(7,Math.round(r.y*this.tileToMeter/10));return new Te(Fe(i.x,1,Ur-1)<<3|n,Fe(i.y,1,Ur-1)<<3|o)}encodeBorderCentroid(e){if(!e.borders)return new Te(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 Te(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 Te((t[e][0]+t[e][1])/2<<3|6,6|(t[2][0]!==i?0:65528))}}showCentroid(e){const t=this.centroidData[e.centroidDataIndex];t.flags&=2147483647,t.centroidXY.x=0,t.centroidXY.y=0,this.writeCentroidToBuffer(t)}writeCentroidToBuffer(e){this.groundEffect.updateHiddenByLandmark(e);const t=e.vertexArrayOffset,i=e.vertexCount+e.vertexArrayOffset,r=e.flags&rp?ip:e.centroidXY,n=this.centroidVertexArray.geta_centroid_pos0(t);if(this.centroidVertexArray.geta_centroid_pos1(t)!==r.y||n!==r.x){for(let e=t;ei.max.x||i.min.x>t.max.x||t.min.y>i.max.y||i.min.y>t.max.y))for(let o=0;ot!=l>t&&e<(this.footprintVertices.int16[2*(a+o.vertexOffset)+0]-i)*(t-s)/(l-s)+i&&(r=!r)}s=i}}return r}getHeightAtTileCoord(e,t){let i=Number.NEGATIVE_INFINITY,r=!0;const n=4*(e+Ur)*Ur+(t+Ur);if(this.partLookup.hasOwnProperty(n)){const e=this.partLookup[n];return e?{height:e.height,hidden:!!(e.flags&rp)}:void 0}for(const o of this.centroidData)e>o.max.x||o.min.x>e||t>o.max.y||o.min.y>t||o.height<=i||this.footprintContainsPoint(e,t,o)&&(i=o.height,this.partLookup[n]=o,r=!!(o.flags&rp));if(i!==Number.NEGATIVE_INFINITY)return{height:i,hidden:r};this.partLookup[n]=void 0}}function Ap(e,t){const i=e.add(t)._unit();return e.x*i.x+e.y*i.y}function yp(e,t,i,r){const n=t.sub(e)._perp()._unit(),o=i.sub(t)._perp()._unit();return vp(e,t,i,Ap(n,o),r)}function vp(e,t,i,r,n){const o=Math.sqrt(1-r*r);return Math.min(e.dist(t)/3,t.dist(i)/3,n*o/r)}function xp(e,t,i){return e.xi[1].x&&t.x>i[1].x||e.yi[1].y&&t.y>i[1].y}function bp(e,t){return e.xt[1].x||e.yt[1].y}function wp(e,t,i){if(e.x<0||e.x>=Ur||t.x<0||t.x>=Ur||i.x<0||i.x>=Ur)return!1;const r=i.sub(t),n=r.perp(),o=e.sub(t);return(r.x*o.x+r.y*o.y)/Math.sqrt((r.x*r.x+r.y*r.y)*(o.x*o.x+o.y*o.y))>-.866&&n.x*o.x+n.y*o.y<0}function Tp(e,t,i){const r=t?2|e:-3&e;return i?1|r:-2&r}function Ep(){const e=Math.PI/32,t=Math.tan(e),i=ic;return i*Math.sqrt(1+2*t*t)-i}function Cp(e,t,i){const r=1<{for(const i of e)s.push({polygon:i,bounds:t})},l=Math.ceil(Math.log2(i)),c=Math.ceil(Math.log2(r)),u=l-c,h=[];for(let e=0;e0?0:1);for(let e=0;et+1?p.push({polygons:d,bounds:e,depth:t+1}):a(d,e)}if(f.length){const e=[new Te(0===i?u:r.x,1===i?u:r.y),s];h.length>t+1?p.push({polygons:f,bounds:e,depth:t+1}):a(f,e)}}return s}(e,t,Math.ceil((o-n)/11.25),Math.ceil((s-a)/11.25),1,(e,t,n)=>{if(0===e)return.5*(t+n);{const e=pc((i.y+t/Ur)/r);return(uc(.5*(pc((i.y+n/Ur)/r)+e))*r-i.y)*Ur}})}function Bp(e,t,i,r,n,o){const s=Math.pow(2,r.z-n.z);for(let a=0;a=s[i]&&(r=t,s=e),r[i]n&&Rp(r,s,i,n),r[i]o&&Rp(s,r,i,o)}}function Fp(e,t,i,r,n,o){const s=[];for(let a=0;a=r&&d.x>=r||(u.x>=r?u=new Te(r,u.y+(r-u.x)/(d.x-u.x)*(d.y-u.y))._round():d.x>=r&&(d=new Te(r,u.y+(r-u.x)/(d.x-u.x)*(d.y-u.y))._round()),u.y>=n&&d.y>=n||(u.y>=n?u=new Te(u.x+(n-u.y)/(d.y-u.y)*(d.x-u.x),n)._round():d.y>=n&&(d=new Te(u.x+(n-u.y)/(d.y-u.y)*(d.x-u.x),n)._round()),c&&u.equals(c[c.length-1])||(c=[u],s.push(c),o&&o.push({progress:{min:f+Dp(m,g,u)*p,max:1},parentIndex:a,prevPoint:m,nextPoint:g})),c.push(d),o&&(o[o.length-1].progress.max=f+Dp(m,g,d)*p,o[o.length-1].nextPoint=g)))))}if(o&&h>0)for(let e=u;ee.t-t.t);let s=0,a=0,l=[];for(r.push(l);s!==e.length;){if(a===o.length){for(;s!==e.length;)0!==l.length&&l[l.length-1].equals(e[s])||l.push(e[s]),s++;break}o[a].t<=s?(0!==l.length&&l[l.length-1].equals(o[a].point)||l.push(o[a].point),Math.trunc(o[a].t),a++):(0!==l.length&&l[l.length-1].equals(e[s])||l.push(e[s]),s++)}}function Dp(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 Op(e,t){return e.x*t.x+e.y*t.y}function zp(e,t){if(1===e.length){let i=0;const r=t[i++];let n;for(;!n||r.equals(n);)if(n=t[i++],!n)return 1/0;for(;i{e[0]=t,e[1]=i,e[2]=r,e[3]=1},_=Ep();i>0&&(i+=_),r+=_;for(const _ of t){const t=[],A=[];for(const h of _){const d=h.x+n.x,_=h.y+n.y,y=e.projection.projectTilePoint(d,_,u),v=e.projection.upVector(u,h.x,h.y);let x=i,b=r;if(s){const e=Vp(d,_,i,r,s,a,l,c);x+=e.base,b+=e.top}0!==i?g(f,y.x+v[0]*p*x,y.y+v[1]*p*x,y.z+v[2]*p*x):g(f,y.x,y.y,y.z),g(m,y.x+v[0]*p*b,y.y+v[1]*p*b,y.z+v[2]*p*b),j(f,f,o),j(m,m,o),t.push(new Mp(f[0],f[1],f[2])),A.push(new Mp(m[0],m[1],m[2]))}h.push(t),d.push(A)}return[h,d]}(e,t,i,r,n,o,s,a,l,c,u):s?function(e,t,i,r,n,o,s,a,l){const c=[],u=[],h=[0,0,0,1];for(const d of e){const e=[],p=[];for(const c of d){const u=c.x+r.x,d=c.y+r.y,f=Vp(u,d,t,i,o,s,a,l);h[0]=u,h[1]=d,h[2]=f.base,h[3]=1,Y(h,h,n),h[3]=Math.max(h[3],1e-5);const m=new Mp(h[0]/h[3],h[1]/h[3],h[2]/h[3]);h[0]=u,h[1]=d,h[2]=f.top,h[3]=1,Y(h,h,n),h[3]=Math.max(h[3],1e-5);const g=new Mp(h[0]/h[3],h[1]/h[3],h[2]/h[3]);e.push(m),p.push(g)}c.push(e),u.push(p)}return[c,u]}(t,i,r,n,o,s,a,l,c):function(e,t,i,r,n){const o=[],s=[],a=n[8]*t,l=n[9]*t,c=n[10]*t,u=n[11]*t,h=n[8]*i,d=n[9]*i,p=n[10]*i,f=n[11]*i;for(const t of e){const e=[],i=[];for(const o of t){const t=o.x+r.x,s=o.y+r.y,m=n[0]*t+n[4]*s+n[12],g=n[1]*t+n[5]*s+n[13],_=n[2]*t+n[6]*s+n[14],A=n[3]*t+n[7]*s+n[15],y=m+a,v=g+l,x=_+c,b=Math.max(A+u,1e-5),w=m+h,T=g+d,E=_+p,C=Math.max(A+f,1e-5);e.push(new Mp(y/b,v/b,x/b)),i.push(new Mp(w/C,T/C,E/C))}o.push(e),s.push(i)}return[o,s]}(t,i,r,n,o)}function Vp(e,t,i,r,n,o,s,a){const l=s*n.getElevationAt(e,t,!0,!0),c=0!==o[0],u=c?0===o[1]?s*(o[0]/np-op):s*function(e,t,i){const r=Math.floor(t[0]/8),n=Math.floor(t[1]/8),o=10*(t[0]-8*r),s=10*(t[1]-8*n),a=e.getElevationAt(r,n,!0,!0),l=e.getMeterToDEM(i),c=Math.floor(.5*(o*l-1)),u=Math.floor(.5*(s*l-1)),h=e.tileCoordToPixel(r,n),d=2*c+1,p=2*u+1,f=function(e,t,i,r,n){return[e.getElevationAtPixel(t,i,!0),e.getElevationAtPixel(t+n,i,!0),e.getElevationAtPixel(t,i+n,!0),e.getElevationAtPixel(t+r,i+n,!0)]}(e,h.x-c,h.y-u,d,p),m=Math.abs(f[0]-f[1]),g=Math.abs(f[2]-f[3]),_=Math.abs(f[0]-f[2])+Math.abs(f[1]-f[3]),A=Math.min(.25,.5*l*(m+g)/d),y=Math.min(.25,.5*l*_/p);return a+Math.max(A*o,y*s)}(n,o,a):l;return{base:l+(0===i?-1:i),top:c?Math.max(u+r,l+i+2):l+r}}class jp{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=void 0,this._callback=()=>{}}}class Gp{constructor(){this.tasks={},this.taskQueue=[],Ve(["process"],this),this.invoker=new jp(this.process),this.nextId=0}add(e,t){const i=this.nextId++,r=function({type:e,isSymbolTile:t,zoom:i}){return i=i||0,"message"===e?0:"maybePrepare"!==e||t?"parseTile"!==e||t?"parseTile"===e&&t?300-i:"maybePrepare"===e&&t?400-i:500:200-i:100-i}(t);if(0===r){try{e()}finally{}return null}return this.tasks[i]={fn:e,metadata:t,priority:r,id:i},this.taskQueue.push(i),this.invoker.trigger(),{cancel:()=>{delete this.tasks[i]}}}process(){try{if(this.taskQueue=this.taskQueue.filter(e=>!!this.tasks[e]),!this.taskQueue.length)return;const e=this.pick();if(null===e)return;const t=this.tasks[e];if(delete this.tasks[e],this.taskQueue.length&&this.invoker.trigger(),!t)return;t.fn()}finally{}}pick(){let e=null,t=1/0;for(let i=0;i{i&&delete this.callbacks[s],this.target.postMessage({id:s,type:"",targetMapId:r,sourceMapId:this.mapId})}}}receive(e){const t=e.data;if(!t)return;const i=t.id;if(i&&(!t.targetMapId||this.mapId===t.targetMapId))if(""===t.type){const e=this.cancelCallbacks[i];delete this.cancelCallbacks[i],e&&e.cancel()}else if(t.mustQueue||Xe(self)){const e=this.callbacks[i],r=this.scheduler.add(()=>this.processTask(i,t),e&&e.metadata||{type:"message"});r&&(this.cancelCallbacks[i]=r)}else this.processTask(i,t)}processTask(e,t){if(delete this.cancelCallbacks[e],""===t.type){const i=this.callbacks[e];delete this.callbacks[e],i&&(t.error?i(ns(t.error)):i(null,ns(t.data)))}else{const i=new Set,r=t.hasCallback?(t,r)=>{this.target.postMessage({id:e,type:"",sourceMapId:this.mapId,error:t?rs(t):null,data:rs(r,i)},i)}:()=>{},n=ns(t.data);if(this.parent[t.type])this.parent[t.type](t.sourceMapId,n,r);else if(this.parent.getWorkerSource){const e=t.type.split("."),{source:i,scope:o}=n;this.parent.getWorkerSource(t.sourceMapId,e[0],i,o)[e[1]](n,r)}else r(new Error(`Could not find function ${t.type}`))}}remove(){this.scheduler.remove(),this.target.removeEventListener("message",this.receive,!1)}}var Qp={workerUrl:"",workerClass:null,workerParams:void 0};const $p="mapboxgl_preloaded_worker_pool";class Zp{constructor(){this.active={}}acquire(e,t=Zp.workerCount){if(!this.workers)for(this.workers=[];this.workers.length{e.terminate()}),this.workers=null)}isPreloaded(){return!!this.active[$p]}numActive(){return Object.keys(this.active).length}}Zp.workerCount=2;class Wp{constructor(e,t,i="Worker",r=Zp.workerCount){this.workerPool=e,this.actors=[],this.currentActor=0,this.id=Ue();const n=this.workerPool.acquire(this.id,r);for(let e=0;e{this.ready=!0})}broadcast(e,t,i){Oe(this.actors,(i,r)=>{i.send(e,t,r)},i=i||function(){})}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)}}let qp,Kp;function Xp(){return qp||(qp=new Zp),qp}Wp.Actor=Hp;class Jp{constructor(e){this.module=e}createIntArray(e){const t=new Int32Array(e),i=this.module.malloc(t.length*t.BYTES_PER_ELEMENT);return this.module.heap32.set(t,i/t.BYTES_PER_ELEMENT),i}createFloatArray(e){const t=new Float32Array(e),i=this.module.malloc(t.length*t.BYTES_PER_ELEMENT);return this.module.heapF32.set(t,i/t.BYTES_PER_ELEMENT),i}createStringBuffer(e){const t=this.module.malloc(e.length+1);for(let i=0;ie.arrayBuffer()).then(e=>{t.buffers[i]=e})}function Tf(e,t){const i=e.json.bufferViews[t];return new Uint8Array(e.buffers[i.buffer],i.byteOffset||0,i.byteLength)}function Ef(e,t,i,r){if(e.uri){const n=bf(e.uri,r);return fetch(n).then(e=>e.blob()).then(e=>createImageBitmap(e)).then(e=>{t.images[i]=e})}if(void 0!==e.bufferView){const r=Tf(t,e.bufferView),n=new Blob([r],{type:e.mimeType});return createImageBitmap(n).then(e=>{t.images[i]=e})}}function Cf(e,t=0,i){const r={json:null,images:[],buffers:[]};if(new Uint32Array(e,t,1)[0]===vf){const i=new Uint32Array(e,t);let n=2;const o=(i[n++]>>2)-3,s=i[n++]>>2;if(n++,r.json=JSON.parse(xf.decode(i.subarray(n,n+s))),n+=s,n{const e=[],t=a&&a.includes(gf),n=a&&a.includes(Af);if(t&&e.push(function(){if(!tf)return null!=Yp?Yp:(Yp=function(e){let t,i=null;function r(){t=new Uint8Array(i.buffer)}function n(){throw new Error("Unexpected Draco error.")}const o={a:{a:n,d:function(e,i,r){return t.copyWithin(e,i,i+r)},c:function(e){const n=t.length,o=Math.max(e>>>0,Math.ceil(1.2*n)),s=Math.ceil((o-n)/65536);try{return i.grow(s),r(),!0}catch(e){return!1}},b:n}};return(WebAssembly.instantiateStreaming?WebAssembly.instantiateStreaming(e,o):e.then(e=>e.arrayBuffer()).then(e=>WebAssembly.instantiate(e,o))).then(e=>{const{Rb:n,Qb:o,P:s,T:a,X:l,Ja:c,La:u,Qa:h,Va:d,Wa:p,eb:f,jb:m,f:g,e:_,yb:A,zb:y,Ab:v,Bb:x,Db:b,Gb:w}=e.instance.exports;i=_;const T=(()=>{let e=0,i=0,r=0,s=0;return a=>{r&&(n(s),n(e),i+=r,r=e=0),e||(i+=128,e=o(i));const l=a.length+7&-8;let c=e;l>=i&&(r=l,c=s=o(l));for(let e=0;e{tf=e,Yp=void 0}))}()),n&&e.push(function(){if(nf)return;const e=function(e){let t;const i=WebAssembly.instantiateStreaming(e,{}).then(e=>{t=e.instance,t.exports.__wasm_call_ctors()}),r={NONE:"",OCTAHEDRAL:"meshopt_decodeFilterOct",QUATERNION:"meshopt_decodeFilterQuat",EXPONENTIAL:"meshopt_decodeFilterExp"},n={ATTRIBUTES:"meshopt_decodeVertexBuffer",TRIANGLES:"meshopt_decodeIndexBuffer",INDICES:"meshopt_decodeIndexSequence"};return{ready:i,supported:!0,decodeGltfBuffer(e,i,o,s,a,l){!function(e,t,i,r,n,o,s){const a=e.exports.sbrk,l=r+3&-4,c=a(l*n),u=a(o.length),h=new Uint8Array(e.exports.memory.buffer);h.set(o,u);const d=t(c,r,n,u,o.length);if(0===d&&s&&s(c,l,n),i.set(h.subarray(c,c+r*n)),a(c-a(0)),0!==d)throw new Error(`Malformed buffer data: ${d}`)}(t,t.exports[n[a]],e,i,o,s,t.exports[r[l]])}}}(fetch(uf()));return e.ready.then(()=>{nf=e})}()),o)for(let t=0;t{if(t&&s)for(const{primitives:e}of s)for(const t of e)_f(t,r);if(n&&s&&l)for(const e of l)yf(e,r);return r})})}function Bf(e){return fetch(e).then(e=>e.arrayBuffer()).then(t=>Cf(t,0,e))}function Sf(e){switch(e){case WebGL2RenderingContext.RGBA8: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 If(e){switch(e){case WebGL2RenderingContext.RGBA8:return WebGL2RenderingContext.UNSIGNED_BYTE;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}}class Mf{constructor(e,t,i,r){this.context=e,this.format=i,this.useMipmap=r&&r.useMipmap,this.texture=e.gl.createTexture(),this.update(t,{premultiply:r&&r.premultiply})}update(e,t){const i=e&&e instanceof HTMLVideoElement&&0===e.width?e.videoWidth:e.width,r=e&&e instanceof HTMLVideoElement&&0===e.height?e.videoHeight:e.height,{context:n}=this,{gl:o}=n,{x:s,y:a}=t&&t.position?t.position:{x:0,y:0},l=s+i,c=a+r;!this.size||this.size[0]===l&&this.size[1]===c||(o.bindTexture(o.TEXTURE_2D,null),o.deleteTexture(this.texture),this.texture=o.createTexture(),this.size=null),o.bindTexture(o.TEXTURE_2D,this.texture),n.pixelStoreUnpackFlipY.set(!1),n.pixelStoreUnpack.set(1),n.pixelStoreUnpackPremultiplyAlpha.set(this.format===o.RGBA8&&(!t||!1!==t.premultiply));const u=e instanceof HTMLImageElement||e instanceof HTMLCanvasElement||e instanceof HTMLVideoElement||e instanceof ImageData||ImageBitmap&&e instanceof ImageBitmap;if(!this.size&&l>0&&c>0){const e=this.useMipmap?Math.floor(Math.log2(Math.max(l,c)))+1:1;o.texStorage2D(o.TEXTURE_2D,e,this.format,l,c),this.size=[l,c]}this.size&&(u?o.texSubImage2D(o.TEXTURE_2D,0,s,a,Sf(this.format),If(this.format),e):"data"in e&&e.data&&o.texSubImage2D(o.TEXTURE_2D,0,s,a,i,r,Sf(this.format),If(this.format),e.data)),this.useMipmap&&o.generateMipmap(o.TEXTURE_2D)}bind(e,t,i=!1){const{context:r}=this,{gl:n}=r;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,this.useMipmap&&!i?e===n.NEAREST?n.NEAREST_MIPMAP_NEAREST:n.LINEAR_MIPMAP_LINEAR: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)}bindExtraParam(e,t,i,r,n){const{context:o}=this,{gl:s}=o;s.bindTexture(s.TEXTURE_2D,this.texture),t!==this.magFilter&&(s.texParameteri(s.TEXTURE_2D,s.TEXTURE_MAG_FILTER,t),this.magFilter=t),e!==this.minFilter&&(s.texParameteri(s.TEXTURE_2D,s.TEXTURE_MIN_FILTER,this.useMipmap?e===s.NEAREST?s.NEAREST_MIPMAP_NEAREST:s.LINEAR_MIPMAP_LINEAR:e),this.minFilter=e),i!==this.wrapS&&(s.texParameteri(s.TEXTURE_2D,s.TEXTURE_WRAP_S,i),this.wrapS=i),r!==this.wrapT&&(s.texParameteri(s.TEXTURE_2D,s.TEXTURE_WRAP_T,r),this.wrapT=r),n!==this.compareMode&&(n?(s.texParameteri(s.TEXTURE_2D,s.TEXTURE_COMPARE_MODE,s.COMPARE_REF_TO_TEXTURE),s.texParameteri(s.TEXTURE_2D,s.TEXTURE_COMPARE_FUNC,n)):s.texParameteri(s.TEXTURE_2D,s.TEXTURE_COMPARE_MODE,s.NONE),this.compareMode=n)}destroy(){const{gl:e}=this.context;e.deleteTexture(this.texture),this.texture=null}}class Pf{constructor(e,t){this.context=e,this.texture=t}bind(e,t){const{context:i}=this,{gl:r}=i;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,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)}}const Rf=ha([{name:"a_pos_3f",components:3,type:"Float32"}]),Lf=ha([{name:"a_color_3f",components:3,type:"Float32"}]),Ff=ha([{name:"a_color_4f",components:4,type:"Float32"}]),kf=ha([{name:"a_uv_2f",components:2,type:"Float32"}]),Df=ha([{name:"a_normal_3f",components:3,type:"Float32"}]),Of=ha([{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"}]),zf=ha([{name:"a_pbr",components:4,type:"Uint16"},{name:"a_heightBasedEmissiveStrength",components:3,type:"Float32"}]);function Uf(e,t){const i=Vf(e.projection,e.zoom,e.width,e.height),r=function(e,t,i,r,n){const o=new nc(i.lng-180*jf,i.lat),s=new nc(i.lng+180*jf,i.lat),a=e.project(o.lng,o.lat),l=e.project(s.lng,s.lat),u=-Math.atan2(l.y-a.y,l.x-a.x),d=vc.fromLngLat(i);d.y=Fe(d.y,-1+jf,1-jf);const f=d.toLngLat(),m=e.project(f.lng,f.lat),_=vc.fromLngLat(f);_.x+=jf;const A=_.toLngLat(),y=e.project(A.lng,A.lat),v=Hf(y.x-m.x,y.y-m.y,u),x=vc.fromLngLat(f);x.y+=jf;const b=x.toLngLat(),w=e.project(b.lng,b.lat),T=Hf(w.x-m.x,w.y-m.y,u),E=Math.abs(v.x)/Math.abs(T.y),C=c([]);g(C,C,-u*(1-(n?0:r)));const B=c([]);return p(B,B,[1,1-(1-E)*r,1]),B[4]=-T.x/T.y*r,g(B,B,u),h(B,C,B),B}(e.projection,0,e.center,i,t),n=Nf(e);return p(r,r,[n,n,1]),r}function Nf(e){const t=e.projection,i=Vf(e.projection,e.zoom,e.width,e.height),r=Gf(t,e.center),n=Gf(t,nc.convert(t.center));return Math.pow(2,r*i+(1-i)*n)}function Vf(e,t,i,r,n=1/0){const o=e.range;if(!o)return 0;const s=Math.min(n,Math.max(i,r)),a=Math.log2(s/1024);return ke(o[0]+a,o[1]+a,t)}const jf=1/4e4;function Gf(e,t){const i=Fe(t.lat,-mc,mc),r=new nc(t.lng-180*jf,i),n=new nc(t.lng+180*jf,i),o=e.project(r.lng,i),s=e.project(n.lng,i),a=vc.fromLngLat(r),l=vc.fromLngLat(n),c=s.x-o.x,u=s.y-o.y,h=l.x-a.x,d=l.y-a.y,p=Math.sqrt((h*h+d*d)/(c*c+u*u));return Math.log2(p)}function Hf(e,t,i){const r=Math.cos(i),n=Math.sin(i);return{x:e*r-t*n,y:e*n+t*r}}function Qf(e,t,i){c(e),g(e,e,Se(t[2])),f(e,e,Se(t[0])),m(e,e,Se(t[1])),p(e,e,i),h(e,e,[1,0,0,0,0,0,1,0,0,1,0,0,0,0,0,1])}function $f(e,t,i,r,n,o,s,a){const l=[i[0]-t[0],i[1]-t[1],0],c=[r[0]-t[0],r[1]-t[1],0];if(T(l)<1e-12||T(c)<1e-12)return te(e);const u=N([],l,c);z(u,u),S(c,r,t),l[2]=(o-n)*a,c[2]=(s-n)*a;const h=l;return N(h,l,c),z(h,h),le(e,u,h)}function Zf(e,t,i=!1){const r=th(t.zoom),n=function(e,t,i){const r=t.worldSize,n=[e[12],e[13],e[14]],o=pc(n[1]/r),s=dc(n[0]/r),a=c([]),l=hc(1,o)*r,u=hc(1,0)*r*_c(o,t.zoom),f=1/Ju(r);let m=u*f;if(i){const e=Vf(t.projection,t.zoom,t.width,t.height,1024);m=f*t.projection.pixelSpaceConversion(t.center.lat,r,e)}const g=tc(o,s);B(g,g,R([],z([],g),l*m*n[2]));const _=function(e){const t=[e[0],e[1],e[2]];let i=[0,1,0];const r=N([],i,t);return N(i,t,r),0===D(i)&&(i=[0,1,0],N(r,t,i)),z(r,r),z(i,i),z(t,t),[r[0],r[1],r[2],0,i[0],i[1],i[2],0,t[0],t[1],t[2],0,e[0],e[1],e[2],1]}(g);p(a,a,[m,m,m*l]),d(a,a,[-n[0],-n[1],-n[2]]);const A=h([],t.globeMatrix,_);return h(A,A,a),h(A,A,e),A}(e,t,i);if(r>0){const i=function(e,t){const i=t.worldSize,r=hc(1,0)*i*_c(t.center.lat,t.zoom)/Ju(i),n=hc(1,t.center.lat)*i,o=c([]);m(o,o,Se(t.center.lng)),f(o,o,Se(t.center.lat)),d(o,o,[0,0,$l]),p(o,o,[r,r,r*n]);const s=t.point;return d(o,o,[-s.x,-s.y,0]),h(o,o,e),h(o,t.globeMatrix,o)}(e,t);return function(e,t,i){const r=(e,t,i)=>{const r=T(e),n=T(t),o=ju(e,t,i);return R(o,o,1/T(o)*di(r,n,i))},n=r([e[0],e[1],e[2]],[t[0],t[1],t[2]],i),o=r([e[4],e[5],e[6]],[t[4],t[5],t[6]],i),s=r([e[8],e[9],e[10]],[t[8],t[9],t[10]],i),a=ju([e[12],e[13],e[14]],[t[12],t[13],t[14]],i);return[n[0],n[1],n[2],0,o[0],o[1],o[2],0,s[0],s[1],s[2],0,a[0],a[1],a[2],1]}(n,i,r)}return n}function Wf(e,t,i,r){const n=Jc.projectAabbCorners(r,i);let o=Number.MAX_VALUE;for(let e=0;e0||0===s&&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])&&(r=t)}n=r}while(n!==i);return t.length>0&&t.push(t[0]),t}(n);if(nu(e,s))return o}const qf=64,Kf={CoordinateSpaceTile:1,HasMapboxMeshFeatures:4,HasMeshoptCompression:8};function Xf(e,t,i,r,n,o,s,a,l,u=!1){const f=i.zoom,m=i.project(r),g=_c(r.lat,f),_=1/g;c(e),d(e,e,[m.x+s[0]*_,m.y+s[1]*_,s[2]]);let A=1,y=1;const x=i.worldSize;if(u){if("mercator"===i.projection.name){let e=0;i.elevation&&(e=i.elevation.getAtPointOrZero(new vc(m.x/x,m.y/x),0));const t=Y([],[m.x,m.y,e,1],i.projMatrix)[3]/i.cameraToCenterDistance;A=t,y=t*_c(i.center.lat,f)}else if("globe"===i.projection.name){const t=Zf(e,i),n=[0,0,0,1];Y(n,n,h([],i.projMatrix,t));const o=n[3]/i.cameraToCenterDistance,s=th(f),a=i.projection.pixelsPerMeter(r.lat,x)*_c(r.lat,f),l=i.projection.pixelsPerMeter(i.center.lat,x)*_c(i.center.lat,f);A=o/di(a,gc(i.center.lat),s),y=o*g/a,A*=l,y*=l}}else A=_;p(e,e,[A,A,y]);const b=[...e],w=t.orientation,T=[];if(Qf(T,[w[0]+(n?n[0]:0),w[1]+(n?n[1]:0),w[2]+(n?n[2]:0)],o),h(e,b,T),a&&i.elevation){let n=0;const o=[];if(l&&i.elevation){n=function(e,t,i,r,n){const o=t.elevation;if(!o)return 0;const s=Jc.projectAabbCorners(i,r),a=hc(1,n.lat)*t.worldSize,l=function(e,t){const i=[0,0,1],r=[{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 n of r){const r=e[n.corners[0]],o=e[n.corners[1]],s=e[n.corners[2]],a=[o[0]-r[0],o[1]-r[1],t*(o[2]-r[2])],l=N(a,a,[s[0]-r[0],s[1]-r[1],t*(s[2]-r[2])]);z(l,l),n.dotProductWithUp=U(l,i)}return r.sort((e,t)=>e.dotProductWithUp-t.dotProductWithUp),r[0].corners}(s,a),c=s[l[0]],u=s[l[1]],h=s[l[2]],d=s[l[3]],p=o.getAtPointOrZero(new vc(c[0]/t.worldSize,c[1]/t.worldSize),0),f=o.getAtPointOrZero(new vc(u[0]/t.worldSize,u[1]/t.worldSize),0),m=o.getAtPointOrZero(new vc(h[0]/t.worldSize,h[1]/t.worldSize),0),g=o.getAtPointOrZero(new vc(d[0]/t.worldSize,d[1]/t.worldSize),0),_=(p+g)/2,A=(f+m)/2;return _>A?f=t.gl.NEAREST_MIPMAP_NEAREST}),e.uploaded=!0,e.image=null)}function em(e,t,i){e.indexBuffer=t.createIndexBuffer(e.indexArray,!1,!0),e.vertexBuffer=t.createVertexBuffer(e.vertexArray,Rf.members,!1,!0),e.normalArray&&(e.normalBuffer=t.createVertexBuffer(e.normalArray,Df.members,!1,!0)),e.texcoordArray&&(e.texcoordBuffer=t.createVertexBuffer(e.texcoordArray,kf.members,!1,!0)),e.colorArray&&(e.colorBuffer=t.createVertexBuffer(e.colorArray,(12===e.colorArray.bytesPerElement?Lf:Ff).members,!1,!0)),e.featureArray&&(e.pbrBuffer=t.createVertexBuffer(e.featureArray,zf.members,!0)),e.segments=hl.simpleSegment(0,0,e.vertexArray.length,e.indexArray.length);const r=e.material;r.pbrMetallicRoughness.baseColorTexture&&Yf(r.pbrMetallicRoughness.baseColorTexture,t),r.pbrMetallicRoughness.metallicRoughnessTexture&&Yf(r.pbrMetallicRoughness.metallicRoughnessTexture,t),r.normalTexture&&Yf(r.normalTexture,t),r.occlusionTexture&&Yf(r.occlusionTexture,t,i),r.emissionTexture&&Yf(r.emissionTexture,t)}function tm(e,t,i){if(e.meshes)for(const r of e.meshes)em(r,t,i);if(e.children)for(const r of e.children)tm(r,t,i)}function im(e){if(e.meshes)for(const t of e.meshes)t.indexArray.destroy(),t.vertexArray.destroy(),t.colorArray&&t.colorArray.destroy(),t.normalArray&&t.normalArray.destroy(),t.texcoordArray&&t.texcoordArray.destroy(),t.featureArray&&t.featureArray.destroy();if(e.children)for(const t of e.children)im(t)}function rm(e){if(e.meshes)for(const i of e.meshes)i.vertexBuffer&&(i.vertexBuffer.destroy(),i.indexBuffer.destroy(),i.normalBuffer&&i.normalBuffer.destroy(),i.texcoordBuffer&&i.texcoordBuffer.destroy(),i.colorBuffer&&i.colorBuffer.destroy(),i.pbrBuffer&&i.pbrBuffer.destroy(),i.segments.destroy(),i.material&&((t=i.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()));var t;if(e.children)for(const t of e.children)rm(t)}function nm(e,t){const i=e.json.bufferViews[t.bufferView],r=df[t.componentType];return new r(e.buffers[i.buffer],(t.byteOffset||0)+(i.byteOffset||0),t.count*(i.byteStride&&i.byteStride!==ff[t.type]*r.BYTES_PER_ELEMENT?i.byteStride/r.BYTES_PER_ELEMENT:ff[t.type]))}function om(e,t,i,r){const n=df[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}}(n),s=e.json.bufferViews[t.bufferView],a=s.byteStride?s.byteStride/n.BYTES_PER_ELEMENT:ff[t.type],l=i.float32,c=l.length/i.capacity;for(let e=0,i=0;e0){for(let n=0;n0){o.texcoordArray=new ja;const e=t.json.accessors[n.TEXCOORD_0];o.texcoordArray.resize(e.count);const i=nm(t,e);om(t,e,o.texcoordArray,i)}if(void 0!==n._FEATURE_ID_RGBA4444){const e=t.json.accessors[n._FEATURE_ID_RGBA4444];t.json.extensionsUsed&&t.json.extensionsUsed.includes("EXT_meshopt_compression")&&(o.featureData=nm(t,e))}void 0!==n._FEATURE_RGBA4444&&(o.featureData=new Uint32Array(nm(t,t.json.accessors[n._FEATURE_RGBA4444]).buffer));const h=e.material;return o.material=function(e,t){const{emissiveFactor:i=[0,0,0],alphaMode:r="OPAQUE",alphaCutoff:n=.5,normalTexture:o,occlusionTexture:s,emissiveTexture:a,doubleSided:l,name:c}=e,{baseColorFactor:u=[1,1,1,1],metallicFactor:h=1,roughnessFactor:d=1,baseColorTexture:p,metallicRoughnessTexture:f}=e.pbrMetallicRoughness||{},m=s?t[s.index]:void 0;if(s&&s.extensions&&s.extensions.KHR_texture_transform&&m){const e=s.extensions.KHR_texture_transform;m.offsetScale=[e.offset[0],e.offset[1],e.scale[0],e.scale[1]]}return{name:c,pbrMetallicRoughness:{baseColorFactor:new li(...u),metallicFactor:h,roughnessFactor:d,baseColorTexture:p?t[p.index]:void 0,metallicRoughnessTexture:f?t[f.index]:void 0},doubleSided:l,emissiveFactor:new li(...i),alphaMode:r,alphaCutoff:n,normalTexture:o?t[o.index]:void 0,occlusionTexture:m,emissionTexture:a?t[a.index]:void 0,defined:void 0===e.defined}}(void 0!==h?t.json.materials[h]:{defined:!1},i),o}function am(e,t,i){const{matrix:r,rotation:n,translation:o,scale:s,mesh:a,extras:c,children:u,name:h}=e,d={};if(d.name=h,d.localMatrix=r||function(e,t,i,r){var n=t[0],o=t[1],s=t[2],a=t[3],l=n+n,c=o+o,u=s+s,h=n*l,d=n*c,p=n*u,f=o*c,m=o*u,g=s*u,_=a*l,A=a*c,y=a*u,v=r[0],x=r[1],b=r[2];return e[0]=(1-(f+g))*v,e[1]=(d+y)*v,e[2]=(p-A)*v,e[3]=0,e[4]=(d-y)*x,e[5]=(1-(h+g))*x,e[6]=(m+_)*x,e[7]=0,e[8]=(p+A)*b,e[9]=(m-_)*b,e[10]=(1-(h+f))*b,e[11]=0,e[12]=i[0],e[13]=i[1],e[14]=i[2],e[15]=1,e}([],n||[0,0,0,1],o||[0,0,0],s||[1,1,1]),d.globalMatrix=l(d.localMatrix),void 0!==a){d.meshes=i[a];const e=d.anchor=[0,0];for(const t of d.meshes){const{min:i,max:r}=t.aabb;e[0]+=i[0]+r[0],e[1]+=i[1]+r[1]}e[0]=Math.floor(e[0]/d.meshes.length/2),e[1]=Math.floor(e[1]/d.meshes.length/2)}if(c&&(c.id&&(d.id=c.id),c.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;e1&&r[r.length-1].equals(r[0])&&r.pop();let n=0;for(let e=0;e0&&r.reverse();const o=Mh(r.flatMap(e=>[e.x,e.y]),[]);return 0===o.length?null:{vertices:r,indices:o}}function um(e,t){const i=[],r=[];let n=0;const o=[];for(const s of e){n=i.length;const e=s.vertexArray.float32,a=s.indexArray.uint16;for(let r=0;r0&&([r[e+1],r[e+2]]=[r[e+2],r[e+1]])}return{vertices:i,indices:r}}function hm(e){const t=function(e,t){const i=[],r=WebGL2RenderingContext;if(e.json.textures)for(const n of e.json.textures){const o={magFilter:r.LINEAR,minFilter:r.NEAREST,wrapS:r.REPEAT,wrapT:r.REPEAT};void 0!==n.sampler&&Object.assign(o,e.json.samplers[n.sampler]),i.push({image:t[n.source],sampler:o,uploaded:!1})}return i}(e,e.images),i=function(e,t){const i=[];for(const r of e.json.meshes){const n=[];for(const i of r.primitives)n.push(sm(i,e,t));i.push(n)}return i}(e,t),{scenes:r,scene:n,nodes:o}=e.json,s=r?r[n||0].nodes:[...o.keys()],a=[];for(const t of s)a.push(am(o[t],e,i));return function(e,t,i){const r={},n=new Set;for(let o=0;o0){const t=Array.from(n.values()).sort((e,t)=>e-t);for(let i=t.length-1;i>=0;i--)e.splice(t[i],1)}}(a,s,e.json.nodes),a}function dm(e){e.heightmap=new Float32Array(4096),e.heightmap.fill(-1);const t=e.vertexArray.float32,i=e.aabb.min[0]-1,r=e.aabb.min[1]-1,n=qf/(e.aabb.max[0]-i+2),o=qf/(e.aabb.max[1]-r+2);for(let s=0;se.heightmap[c*qf+l]&&(e.heightmap[c*qf+l]=a)}}function pm(e,t,i,r,n){i.reserve(i.length+4*e.length),r.reserve(r.length+10*e.length),n.reserve(n.length+10*e.length);let o=r.length;for(const s of e){const e=Math.min(10,Math.max(4,1.3*s.height))*t,a=[-s.normal[1],s.normal[0],0],l=Math.min(.29,.1*s.width/s.depth),c=s.width-2*s.depth*t*(l+.01),u=L([],s.pos,a,c/2),h=L([],s.pos,a,-c/2),d=[u[0],u[1],u[2]+s.height],p=[h[0],h[1],h[2]+s.height],f=L([],s.normal,a,l);R(f,f,e);const m=L([],s.normal,a,-l);R(m,m,e),B(f,u,f),B(m,h,m),u[2]+=.1,h[2]+=.1,r.emplaceBack(f[0],f[1],f[2]),r.emplaceBack(m[0],m[1],m[2]),r.emplaceBack(u[0],u[1],u[2]),r.emplaceBack(h[0],h[1],h[2]),r.emplaceBack(d[0],d[1],d[2]),r.emplaceBack(p[0],p[1],p[2]),r.emplaceBack(u[0],u[1],u[2]),r.emplaceBack(h[0],h[1],h[2]),r.emplaceBack(f[0],f[1],f[2]),r.emplaceBack(m[0],m[1],m[2]);const g=c/e/2;n.emplaceBack(-g-l,-1,g,.8),n.emplaceBack(g+l,-1,g,.8),n.emplaceBack(-g,0,g,1.3),n.emplaceBack(g,0,g,1.3),n.emplaceBack(g+l,-.8,g,.7),n.emplaceBack(g+l,-.8,g,.7),n.emplaceBack(0,0,g,1.3),n.emplaceBack(0,0,g,1.3),n.emplaceBack(g+l,-1.2,g,.8),n.emplaceBack(g+l,-1.2,g,.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 fm(e,t){const i={};i.indexArray=new Fa,i.vertexArray=new xa,i.colorArray=new Ba,pm(e,t,i.indexArray,i.vertexArray,i.colorArray);const r={defined:!0};r.emissiveFactor=li.black;const n={};return n.baseColorFactor=li.white,r.pbrMetallicRoughness=n,i.material=r,i.aabb=new Jc([1/0,1/0,1/0],[-1/0,-1/0,-1/0]),i}const mm=ha([{name:"a_pos_3f",components:3,type:"Float32"}]),gm=ha([{name:"a_normal_3",components:3,type:"Int16"}]),_m=ha([{name:"a_centroid_3",components:3,type:"Int16"}]),Am=ha([{name:"a_part_color_emissive",components:2,type:"Uint16"}]),ym=ha([{name:"a_faux_facade_color_emissive",components:2,type:"Uint16"}]),vm=ha([{name:"a_faux_facade_data",components:4,type:"Uint16"}]),xm=ha([{name:"a_faux_facade_vertical_range",components:2,type:"Uint16"}]),bm=ha([{name:"a_bloom_attenuation",components:4,type:"Float32"}]),wm=ha([{name:"a_flood_light_wall_radius_1i16",components:1,type:"Uint16"}]),Tm=Mc.types,Em=32767;function Cm(e,t){const i=Ur+t;for(const r of e)for(const e of r)if(e.x<-t||e.x>i||e.y<-t||e.y>i)return!1;return!0}class Bm{constructor(){this.layoutVertexArray=new xa,this.layoutAttenuationArray=new Ba,this.layoutColorArray=new Ia,this.indexArray=new Fa,this.indexArrayForConflation=new Fa,this.segmentsBucket=new hl}}class Sm{constructor(){this.layoutVertexArray=new xa,this.layoutNormalArray=new fa,this.layoutCentroidArray=new fa,this.layoutColorArray=new Ia,this.layoutFacadePaintArray=null,this.layoutFacadeDataArray=null,this.layoutFacadeVerticalRangeArray=null,this.layoutFloodLightDataArray=new Ha,this.layoutAOArray=new ga,this.indexArray=new Fa,this.indexArrayForConflation=new Fa,this.segmentsBucket=new hl,this.entranceBloom=new Bm}}class Im{constructor(e){this.colorBufferUploaded=!1,this.maxHeight=0,this.replacementUpdateTime=0,this.activeReplacements=[],this.footprints=[],this.featuresOnBorder=[],this.buildingFeatures=[],this.buildingWithoutFacade=new Sm,this.buildingWithFacade=new Sm,this.indexArrayForConflationUploaded=!1,this.featureFootprintLookup=new Map,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.buildingWithFacade.layoutFacadePaintArray=new Ia,this.buildingWithFacade.layoutFacadeDataArray=new wa,this.buildingWithFacade.layoutFacadeVerticalRangeArray=new Ia,this.programConfigurations=new Nl(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 gp(e),this.groundEffect.groundRadiusArray=new ga,this.hasAppearances=null}updateFootprints(e,t){for(const i of this.footprints)t.push({footprint:i,id:e})}updateAppearances(e,t,i,r){}prepare(){return function(){if(null!=lf||null!=af)return null;if(null!=sf)return sf;const e=fetch(st.BUILDING_GEN_URL);return sf=function(e){let t,i,r,n;function o(){t=new Uint8Array(n.buffer),i=new Int32Array(n.buffer),r=new Float32Array(n.buffer)}function s(){throw new Error("Unexpected BuildingGen error.")}const a=()=>{},l={a:{a:s,f:function(e){const i=t.length,r=Math.max(e>>>0,Math.ceil(1.2*i)),s=Math.ceil((r-i)/65536);try{return n.grow(s),o(),!0}catch(e){return!1}},g:s,b:a,c:a,d:a,e:a}};return(WebAssembly.instantiateStreaming?WebAssembly.instantiateStreaming(e,l):e.then(e=>e.arrayBuffer()).then(e=>WebAssembly.instantiate(e,l))).then(e=>{const s=e.instance.exports;return(0,s.g)(),n=s.f,o(),new Jp({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,getColorsPtr:s.y,getColorsLength:s.z,getAOPtr:s.A,getAOLength:s.B,getUVPtr:s.C,getUVLength:s.D,getFauxFacadePtr:s.E,getFauxFacadeLength:s.F,getIndicesPtr:s.G,getIndicesLength:s.H,getBuildingPart:s.I,getRingCount:s.J,getRingPtr:s.K,getRingLength:s.L,free:s.M,malloc:s.N,heapU8:t,heap32:i,heapF32:r})})}(e).then(e=>(sf=null,lf=e,lf)).catch(e=>{Ze("Could not load building-gen"),sf=null,af=e}),sf}()}populate(e,t,i,r){const n=hf();if(!n)return;const o=yc(i);this.tileToMeter=o,this.brightness=t.brightness,n.setStyle({convertToMeters:!1,entranceColorRgb:[1,1,1],facadeGlazingColorRgb:[.5607843137254902,.6745098039215687,.7215686274509804],normalScale:[1,-1,o],ridgeHeight:3,roofColorRgb:[.886274516,.784313738,.713725507],tileToMeters:o,tileZoom:16,wallColorRgb:[.988235294,.933333337,.811764717]}),n.setAOOptions(!1,.3),n.setMetricOptions(!1,16),n.setStructuralOptions(!0),n.setFacadeClassifierOptions(3);const s=new Map,a=new Map;for(const{feature:t}of e){if("LineString"!==Tm[t.type]){s.set(t.id,t.properties.source_id);continue}const e=this.layers[0]._featureFilter.needGeometry,n=Ic(t,e);if(!this.layers[0]._featureFilter.filter(new Es(this.zoom),n,i))continue;const o=e?n.geometry:Sc(t,i,r),l=[];for(const e of o)for(const t of e)l.push({x:t.x,y:t.y});const c={coordinates:l,crossPerc:t.properties.cross_perc,distanceToRoad:t.properties.distance_to_road,entrances:t.properties.entrances,sourceId:0},u=t.properties.source_id;let h=a.get(u);h||(h=[],a.set(u,h)),h.push(c)}this.maxHeight=0;for(const{feature:l,id:c,index:u,sourceLayerIndex:h}of e){if("LineString"===Tm[l.type])continue;const e=this.layers[0]._featureFilter.needGeometry,d=Ic(l,e);if(!this.layers[0]._featureFilter.filter(new Es(this.zoom),d,i))continue;const p=e?d.geometry:Sc(l,i,r),f=id(p,500);if(!Cm(p,163))continue;const m=this.layers[0],g=m.layout.get("building-roof-shape").evaluate(l,{},i);if("flat"===g)continue;const _=m.layout.get("building-base").evaluate(l,{},i),A=m.layout.get("building-height").evaluate(l,{},i),y=m.layout.get("building-flood-light-ground-radius").evaluate(l,{},i),v=m.paint.get("building-ambient-occlusion-intensity"),x=y/this.tileToMeter;let b=m.layout.get("building-flood-light-wall-radius").evaluate(l,{},i);b=Fe(b,0,2048);const w=b/2048*Em,T=s.get(c);let E;E=a.has(T)?a.get(T):[];const C=0!==E.length&&m.layout.get("building-facade").evaluate(l,{},i);n.setFacadeOptions(4,!0),n.setFauxFacadeOptions(C,!1,1);let B=0,S=0,I=0,M=0,P=0,R=0;if(C){let e=Math.round(m.layout.get("building-facade-floors").evaluate(l,{},i));if(0===_){e=Math.max(1,e-(E.length>0?1:0));let t=4;if(A>100){const e=[10,13,15];t=e[l.id?l.id%e.length:0],n.setFacadeOptions(t,!0)}P=1.6803*t/o}else P=_/o;R=A/o,P=Math.min(P,R),I=m.layout.get("building-facade-unit-width").evaluate(l,{},i)/o,M=(R-P)/e,n.setFauxFacadeOptions(!0,!0,I);const t=m.layout.get("building-facade-window").evaluate(l,{},i);B=t[0],S=t[1]}const L=[],F=new Te(1/0,1/0),k=new Te(-1/0,-1/0),D=new Te(0,0);let O=0;for(const e of f)if(e.length>0){const t=[];for(const i of e){const e=[];for(let t=i.length-1;t>=0;t--){const r=i[t];e.push({x:r.x,y:r.y}),F.x=Math.min(F.x,r.x),F.y=Math.min(F.y,r.y),k.x=Math.max(k.x,r.x),k.y=Math.max(k.y,r.y),D.x+=r.x,D.y+=r.y,O++}t.push(e)}L.push({id:l.id?l.id:0,height:A,minHeight:_,sourceId:0,roofType:g,coordinates:t})}D.x/=O||1,D.y/=O||1;const z=n.generateMesh(L,E);if("string"==typeof z){Ze(`Unable to generate building ${l.id}: ${z}`);continue}if(0===z.meshes.length||0===z.modifiedPolygonRings.length)continue;let U=0;for(const e of z.meshes)U+=e.positions.length/3;const N=C?this.buildingWithFacade:this.buildingWithoutFacade,V=N.segmentsBucket.prepareSegment(U,N.layoutVertexArray,N.indexArray),j=[];let G=null,H=0,Q=-1;const $=N.layoutVertexArray.length,Z=N.indexArray.length;let W=0;for(const e of z.meshes){const t=N.layoutVertexArray.length;if("entrance"===e.buildingPart){const t=new Array;for(let i=0;iUr||F.y<0||k.y>Ur)&&this.featuresOnBorder.push({featureId:l.id,footprintIndex:this.footprints.length});{const e=Mh(K,null,2),t=new Ed(X,e,8,256);let i=l.id;l.properties&&l.properties.hasOwnProperty("building_id")&&(i=l.properties.building_id);const r={vertices:X,indices:e,grid:t,min:J,max:Y,buildingId:i,hiddenFlags:0,indicesOffset:Z,indicesLength:q,bloomIndicesOffset:H,bloomIndicesLength:Q,groundEffectVertexOffset:ee,groundEffectVertexLength:te,hasFauxFacade:C,segment:V,height:W};void 0!==l.id&&this.featureFootprintLookup.set(l.id,this.footprints.length),this.footprints.push(r)}this.programConfigurations.populatePaintArrays(N.layoutVertexArray.length,l,u,{},t.availableImages,i,t.brightness),this.groundEffect.addPaintPropertiesData(l,u,{},t.availableImages,i,t.brightness),t.featureIndex.insert(l,p,u,h,this.index,$)}this.groundEffect.prepareBorderSegments(),this.evaluate(this.layers[0],{})}update(e,t,i,r,n,o,s){this.programConfigurations.updatePaintArrays(e,t,n,i,r,o,s),this.groundEffect.update(e,t,n,i,r,o,s),this.evaluate(this.layers[0],e),this.colorBufferUploaded=!1}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,mm.members),t.layoutNormalBuffer=e.createVertexBuffer(t.layoutNormalArray,gm.members),t.layoutCentroidBuffer=e.createVertexBuffer(t.layoutCentroidArray,_m.members),t.layoutFloodLightDataBuffer=e.createVertexBuffer(t.layoutFloodLightDataArray,wm.members),t.layoutFacadeDataArray&&t.layoutFacadeDataArray.length&&(t.layoutFacadeDataBuffer=e.createVertexBuffer(t.layoutFacadeDataArray,vm.members)),t.layoutFacadeVerticalRangeArray&&t.layoutFacadeVerticalRangeArray.length&&(t.layoutFacadeVerticalRangeBuffer=e.createVertexBuffer(t.layoutFacadeVerticalRangeArray,xm.members)),t.entranceBloom.layoutVertexArray.length&&(t.entranceBloom.layoutVertexBuffer=e.createVertexBuffer(t.entranceBloom.layoutVertexArray,mm.members),t.entranceBloom.layoutAttenuationBuffer=e.createVertexBuffer(t.entranceBloom.layoutAttenuationArray,bm.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 r=!1;const n=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|n;e.hiddenFlags!==i&&(e.hiddenFlags=i,r=!0,this.groundEffect.updateHiddenByLandmarkRange(e.groundEffectVertexOffset,e.groundEffectVertexLength,0!==e.hiddenFlags))}return r&&(this.indexArrayForConflationUploaded=!1),r}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 r=e.indicesOffset;r{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,Am.members,!0),t.layoutFacadePaintArray&&(t.layoutFacadePaintBuffer?t.layoutFacadePaintBuffer.updateData(t.layoutFacadePaintArray):t.layoutFacadePaintBuffer=e.createVertexBuffer(t.layoutFacadePaintArray,ym.members,!0)),t.entranceBloom.layoutColorBuffer?t.entranceBloom.layoutColorBuffer.updateData(t.entranceBloom.layoutColorArray):t.entranceBloom.layoutColorBuffer=e.createVertexBuffer(t.entranceBloom.layoutColorArray,Am.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 r of this.buildingFeatures){const n=t[r.promoteId],o=r.feature;o.properties["building-part"]="roof";const s=e.paint.get("building-color").evaluate(o,n,this.canonical).toPremultipliedRenderColor(this.lut),a=e.paint.get("building-emissive-strength").evaluate(o,n,this.canonical);o.properties["building-part"]="wall";const l=e.paint.get("building-color").evaluate(o,n,this.canonical).toPremultipliedRenderColor(this.lut),c=e.paint.get("building-emissive-strength").evaluate(o,n,this.canonical);o.properties["building-part"]="window";const u=e.paint.get("building-color").evaluate(o,n,this.canonical).toPremultipliedRenderColor(this.lut),h=e.paint.get("building-emissive-strength").evaluate(o,n,this.canonical);o.properties["building-part"]="door";const d=e.paint.get("building-color").evaluate(o,n,this.canonical).toPremultipliedRenderColor(this.lut),p=e.paint.get("building-emissive-strength").evaluate(o,n,this.canonical),f=r.hasFauxFacade?this.buildingWithFacade:this.buildingWithoutFacade;for(const e of r.parts){let t,n=s;"roof"===e.part?(n=s,t=a):"wall"===e.part?(n=l,t=c):"facade_glazing"===e.part?(n=u,t=h):"entrance"===e.part&&(n=d,t=p),t=Fe(t,0,1);for(let o=0;ot.max.x||r.max.xt.max.y||r.max.ys.max.x||s.min.x>e||t>s.max.y||s.min.y>t||s.height<=i||Wd(o,s)&&(i=s.height,this.footprintLookup[n]=s,r=0!==s.hiddenFlags);if(i!==Number.NEGATIVE_INFINITY)return{height:i,hidden:r};this.footprintLookup[n]=void 0}}function Mm(e,t,i,r,n,o){const s=Math.pow(2,r.z-n.z);for(let a=0;a1&&(s=e[++o]);const l=Math.abs(a-s.left),c=Math.abs(a-s.right),u=Math.min(l,c);let h;const d=t/i*(r+1);if(s.isDash){const e=r-Math.abs(d);h=Math.sqrt(u*u+e*e)}else h=r-Math.sqrt(u*u+d*d);this.image.data[n+a]=Math.max(0,Math.min(255,h+128))}}}addRegularDash(e,t){for(let t=e.length-1;t>=0;--t){const i=e[t],r=e[t+1];i.zeroLength?e.splice(t,1):r&&r.isDash===i.isDash&&(r.left=i.left,e.splice(t,1))}const i=e[0],r=e[e.length-1];i.isDash===r.isDash&&(i.left=r.left-this.width,r.right=i.right+this.width);const n=this.width*this.nextRow;let o=0,s=e[o];for(let i=0;i1&&(s=e[++o]);const r=Math.abs(i-s.left),a=Math.abs(i-s.right),l=Math.min(r,a);this.image.data[n+i]=Math.max(0,Math.min(255,(s.isDash?l:-l)+t+128))}}addDash(e,t){const i=this.getKey(e,t);if(this.positions[i])return this.positions[i];const r="round"===t,n=r?7:0,o=2*n+1;if(this.nextRow+o>this.height)return Ze("LineAtlas out of space"),null;0===e.length&&e.push(1);let s=0;for(let t=0;te.fqid),this.index=e.index,this.projection=e.projection,this.hasPattern=!1,this.hasCrossSlope=!1,this.patternFeatures=[],this.lineClipsArray=[],this.gradients={},this.layers.forEach(e=>{this.gradients[e.id]={}}),this.layoutVertexArray=new va,this.layoutVertexArray2=new xa,this.patternVertexArray=new xa,this.indexArray=new Fa,this.programConfigurations=new Nl(e.layers,{zoom:e.zoom,lut:e.lut}),this.segments=new hl,this.maxLineLength=0,this.zOffsetVertexArray=new xa,this.stateDependentLayerIds=this.layers.filter(e=>e.isStateDependent()).map(e=>e.id),this.tessellationStep=e.tessellationStep?e.tessellationStep:Ur/64,this.worldview=e.worldview,this.hasAppearances=null}updateFootprints(e,t){}updateAppearances(e,t,i,r){}populate(e,t,i,r){this.hasPattern=od("line",this.layers,this.pixelRatio,t);const n=this.layers[0].layout.get("line-sort-key");this.tileToMeter=yc(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&&Ze(`line-elevation-reference: ground is used for the layer ${this.layerIds[0]} because non-zero line-z-offset value was found.`)}const s=this.layers[0].layout.get("line-cross-slope");this.hasCrossSlope="offset"===this.elevationType&&void 0!==s;const a=[];for(const{feature:o,id:s,index:l,sourceLayerIndex:c}of e){const e=this.layers[0]._featureFilter.needGeometry,u=Ic(o,e);if(!this.layers[0]._featureFilter.filter(new Es(this.zoom,{worldview:this.worldview,activeFloors:t.activeFloors}),u,i))continue;const h=n?n.evaluate(u,{},i):void 0,d={id:s,properties:o.properties,type:o.type,sourceLayerIndex:c,index:l,geometry:e?u.geometry:Sc(o,i,r),patterns:{},sortKey:h};a.push(d)}n&&a.sort((e,t)=>e.sortKey-t.sortKey);const{lineAtlas:l,featureIndex:c}=t,u=this.addConstantDashes(l);for(const r of a){const{geometry:n,index:o,sourceLayerIndex:s}=r;if(u&&this.addFeatureDashes(r,l),this.hasPattern){const e=sd("line",this.layers,r,this.zoom,this.pixelRatio,t);this.patternFeatures.push(e)}else this.addFeature(r,n,o,i,l.positions,t.availableImages,t.brightness,t.elevationFeatures);c.insert(e[o].feature,n,o,s,this.index)}}addConstantDashes(e){let t=!1;for(const i of this.layers){const r=i.paint.get("line-dasharray").value,n=i.layout.get("line-cap").value;if("constant"!==r.kind||"constant"!==n.kind)t=!0;else{const t=n.value,i=r.value;if(!i)continue;e.addDash(i,t)}}return t}addFeatureDashes(e,t){const i=this.zoom;for(const r of this.layers){const n=r.paint.get("line-dasharray").value,o=r.layout.get("line-cap").value;if("constant"===n.kind&&"constant"===o.kind)continue;let s,a;if("constant"===n.kind){if(s=n.value,!s)continue}else s=n.evaluate({zoom:i},e);a="constant"===o.kind?o.value:o.evaluate({zoom:i},e),t.addDash(s,a),e.patterns[r.id]=[t.getKey(s,a)]}}update(e,t,i,r,n,o,s,a){this.programConfigurations.updatePaintArrays(e,t,n,i,r,o,s,a)}addFeatures(e,t,i,r,n,o){for(const e of this.patternFeatures)this.addFeature(e,e.geometry,e.index,t,i,r,o)}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,Om)),0!==this.patternVertexArray.length&&(this.patternVertexBuffer=e.createVertexBuffer(this.patternVertexArray,Um)),!this.zOffsetVertexBuffer&&this.zOffsetVertexArray.length>0&&(this.zOffsetVertexBuffer=e.createVertexBuffer(this.zOffsetVertexArray,Fm.members,!0)),this.layoutVertexBuffer=e.createVertexBuffer(this.layoutVertexArray,km),this.indexBuffer=e.createIndexBuffer(this.indexArray)),this.programConfigurations.upload(e),this.uploaded=!0}destroy(){this.layoutVertexBuffer&&(this.zOffsetVertexBuffer&&this.zOffsetVertexBuffer.destroy(),this.layoutVertexBuffer.destroy(),this.indexBuffer.destroy(),this.programConfigurations.destroy(),this.segments.destroy())}lineFeatureClips(e,t){let i,r;if(t&&t>0?(i=`mapbox_clip_start_${t}`,r=`mapbox_clip_end_${t}`):(i="mapbox_clip_start",r="mapbox_clip_end"),e.properties&&e.properties.hasOwnProperty(i)&&e.properties.hasOwnProperty(r))return{start:+e.properties[i],end:+e.properties[r]}}addFeature(e,t,i,r,n,o,s,a){const l=this.layers[0].layout,c=l.get("line-join").evaluate(e,{}),u=l.get("line-cap").evaluate(e,{}),h=l.get("line-miter-limit"),d=l.get("line-round-limit");this.lineClips=this.lineFeatureClips(e),this.lineFeature=e;const p=!(!e.properties||!e.properties.hasOwnProperty("mapbox_line_metrics"))&&e.properties.mapbox_line_metrics;this.zOffsetValue=l.get("line-z-offset").value;const f=this.layers[0].paint.get("line-width").value;if("constant"!==f.kind&&!1===f.isLineProgressConstant&&(this.variableWidthValue=f),"road"===this.elevationType){const i=this.layoutVertexArray.length;if(!this.addElevatedRoadFeature(e,t,r,a,c,u,h,d)){const[n,o]=this.clipRuntimeLinesToTile(t,1);for(let t=0;t0?s.parentIndex:null)}this.fillNonElevatedRoadSegment(i)}}else for(let i=0;i0?i:null);this.programConfigurations.populatePaintArrays(this.layoutVertexArray.length,e,i,n,o,r,s,void 0,this.worldview)}computeSegNextDir(e,t){return e.nextPoint.sub(t.at(-2)).unit()}computeSegPrevDir(e,t){return t[1].sub(e.prevPoint).unit()}clipLinesToTile(e,t){return Fp(e,-t,-t,Ur+t,Ur+t)}clipRuntimeLinesToTile(e,t){const i=[];return[Fp(e,-t,-t,Ur+t,Ur+t,i),i]}addElevatedRoadFeature(e,t,i,r,n,o,s,a){const l=[],c=tu.getElevationFeature(e,r);if(c){const e=this.clipLinesToTile(t,1),r=this.prepareElevatedLines(e,c,i);for(const e of r)l.push({geometry:e,elevation:c,elevationTileID:i,segment:{progress:{min:0,max:1},nextDir:void 0,prevDir:void 0}})}if(0===l.length)return!1;for(const t of l){const r=this.layoutVertexArray.length;this.addLine(t.geometry,e,i,n,o,s,a);const l=new iu(i,t.elevationTileID);if(t.elevation)for(let e=r;e>1,this.layoutVertexArray.int16[6*e+1]>>1),r=l.pointElevation(i,t.elevation,.05);this.updateHeightRange(r),this.zOffsetVertexArray.emplaceBack(r,0,0)}else this.fillNonElevatedRoadSegment(r)}return!0}prepareElevatedLines(e,t,i){if(null!=t.constantHeight)return e;const r=[],n=1/yc(i);for(const i of e)kp(i,new Yc(t,n),0,r);return r}fillNonElevatedRoadSegment(e){for(let t=e;t0,h=a&&a.progress.max<1;if(this.lineClips){let i={min:this.lineClips.start,max:this.lineClips.end},r=1;if(a){const e=this.lineClips.end-this.lineClips.start;i=function(e,t,i){return{min:ot(e.min,t,i),max:ot(e.max,t,i)}}(a.progress,{min:0,max:1},i),e>0&&(r=(i.max-i.min)/e)}const n=+t.properties.mapbox_clip_feature_len,o=+t.properties.mapbox_clip_seg_len;if(Number.isNaN(n)||Number.isNaN(o)){for(let t=0;t=2&&e[p-1].equals(e[p-2]);)p--;let f=0;for(;f0,M=this.overscaling<=16?15*Ur/(512*this.overscaling):0;if(i&&"round"===a)if(Co&&(a="bevel"),"bevel"===a&&(C>2&&(a="flipbevel"),C2*M){const t=g.sub(g.sub(_)._mult(M/e)._round());this.updateDistance(_,t),this.addCurrentVertex(t,y,0,0,m,w),_=t}this.updateDistance(_,g),T._mult(C),this.addCurrentVertex(g,T,0,0,m,w);const t=g.dist(A);if(t>2*M){const e=g.add(A.sub(g)._mult(M/t)._round());this.updateDistance(g,e),this.addCurrentVertex(e,v,0,0,m,w),g=e}}else T._mult(C),this.addCurrentVertex(g,T,0,0,m,w);else if("flipbevel"===a){if(C>100)T=v.mult(-1);else{const e=C*y.add(v).mag()/y.sub(v).mag();T._perp()._mult(e*(I?-1:1))}this.addCurrentVertex(g,T,0,0,m,w),this.addCurrentVertex(g,T.mult(-1),0,0,m,w)}else if("bevel"===a||"fakeround"===a){null!=w&&_&&this.addCurrentVertex(g,b||y,-1,-1,m,w);const e=g.dist(_)<=2*M&&"bevel"!==a,t=T.mult(I?1:-1);t._mult(C);const i=v.mult(I?-1:1),r=y.mult(I?-1:1),n=this.evaluateLineProgressFeatures(this.distance);if(null==w&&(this.addHalfVertex(g,t.x,t.y,!1,!I,0,m,n),e||this.addHalfVertex(g,t.x+2*r.x,t.y+2*r.y,!1,I,0,m,n)),"fakeround"===a){const e=Math.round(180*B/Math.PI/20);this.addHalfVertex(g,r.x,r.y,!1,I,0,m,n);for(let t=0;t1){this.lineSoFar=e.w;const d=(t.x-e.x)/u,p=(t.y-e.y)/u,f=(t.z-e.z)/u,m=(t.w-e.w)/u;for(let t=1;t=0&&this.e2>=0&&(this.indexArray.emplaceBack(this.e1,this.e2,c),a.primitiveLength++),o?this.e2=c:this.e1=c,null!=l&&this.zOffsetVertexArray.emplaceBack(l.zOffset,l.variableWidth,l.variableWidth)}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 Qm(e,t,i){return e.xi||e.yi}let $m,Zm;function Wm(e,t,i){return t*(Ur/(e.tileSize*Math.pow(2,i-e.tileID.overscaledZ)))}es(Hm,"LineBucket",{omit:["layers","patternFeatures","currentVertex","currentVertexIsOutside"]});const qm=(e,t,i)=>(1-i)*e+i*t;function Km(e,t){return 1/Wm(e,1,t.tileZoom)}function Xm(e,t,i,r){return e.translatePosMatrix(r||t.tileID.projMatrix,t,i.paint.get("line-translate"),i.paint.get("line-translate-anchor"))}const Jm=e=>{const t=[];Ym(e)&&t.push("RENDER_LINE_DASH"),e.paint.get("line-gradient")&&t.push("RENDER_LINE_GRADIENT");const i=e.paint.get("line-trim-offset");0===i[0]&&0===i[1]||t.push("RENDER_LINE_TRIM_OFFSET"),0!==e.paint.get("line-border-width").constantOr(1)&&t.push("RENDER_LINE_BORDER");const r="none"===e.layout.get("line-join").constantOr("miter"),n=!!e.paint.get("line-pattern").constantOr(1);return r&&n&&t.push("LINE_JOIN_NONE"),t};function Ym(e){const t=e.paint.get("line-dasharray").value;return"constant"!==t.kind||t.value}let eg;const tg=()=>eg||(eg={layout:$m||($m=new Os({"line-cap":new ks(zs.layout_line["line-cap"]),"line-join":new ks(zs.layout_line["line-join"]),"line-miter-limit":new Fs(zs.layout_line["line-miter-limit"]),"line-round-limit":new Fs(zs.layout_line["line-round-limit"]),"line-sort-key":new ks(zs.layout_line["line-sort-key"]),"line-z-offset":new ks(zs.layout_line["line-z-offset"]),"line-elevation-reference":new Fs(zs.layout_line["line-elevation-reference"]),"line-cross-slope":new Fs(zs.layout_line["line-cross-slope"]),visibility:new Fs(zs.layout_line.visibility),"line-width-unit":new Fs(zs.layout_line["line-width-unit"])})),paint:Zm||(Zm=new Os({"line-opacity":new ks(zs.paint_line["line-opacity"]),"line-color":new ks(zs.paint_line["line-color"]),"line-translate":new Fs(zs.paint_line["line-translate"]),"line-translate-anchor":new Fs(zs.paint_line["line-translate-anchor"]),"line-width":new ks(zs.paint_line["line-width"]),"line-gap-width":new ks(zs.paint_line["line-gap-width"]),"line-offset":new ks(zs.paint_line["line-offset"]),"line-blur":new ks(zs.paint_line["line-blur"]),"line-dasharray":new ks(zs.paint_line["line-dasharray"]),"line-pattern":new ks(zs.paint_line["line-pattern"]),"line-pattern-cross-fade":new Fs(zs.paint_line["line-pattern-cross-fade"]),"line-gradient":new Ds(zs.paint_line["line-gradient"]),"line-trim-offset":new Fs(zs.paint_line["line-trim-offset"]),"line-trim-fade-range":new Fs(zs.paint_line["line-trim-fade-range"]),"line-trim-color":new Fs(zs.paint_line["line-trim-color"]),"line-emissive-strength":new Fs(zs.paint_line["line-emissive-strength"]),"line-border-width":new ks(zs.paint_line["line-border-width"]),"line-border-color":new ks(zs.paint_line["line-border-color"]),"line-occlusion-opacity":new Fs(zs.paint_line["line-occlusion-opacity"]),"line-color-use-theme":new ks({type:"string",default:"default","property-type":"data-driven"}),"line-gradient-use-theme":new ks({type:"string",default:"default","property-type":"data-driven"}),"line-trim-color-use-theme":new ks({type:"string",default:"default","property-type":"data-driven"}),"line-border-color-use-theme":new ks({type:"string",default:"default","property-type":"data-driven"})}))},eg);class ig extends ks{possiblyEvaluate(e,t){return t=new Es(Math.floor(t.zoom),{now:t.now,fadeDuration:t.fadeDuration,transition:t.transition,worldview:t.worldview}),super.possiblyEvaluate(e,t)}evaluate(e,t,i,r){return t=Object.assign({},t,{zoom:Math.floor(t.zoom)}),super.evaluate(e,t,i,r)}}let rg;function ng(e,t){return t>0?t+2*e:e}const og=ha([{name:"a_pos_offset",components:4,type:"Int16"},{name:"a_tex_size",components:4,type:"Uint16"},{name:"a_pixeloffset",components:4,type:"Int16"}],4),sg=ha([{name:"a_globe_anchor",components:3,type:"Int16"},{name:"a_globe_normal",components:3,type:"Float32"}],4),ag=ha([{name:"a_projected_pos",components:4,type:"Float32"}],4);ha([{name:"a_fade_opacity",components:1,type:"Uint32"}],4);const lg=ha([{name:"a_auto_z_offset",components:1,type:"Float32"}],4),cg=ha([{name:"a_x_axis",components:3,type:"Float32"},{name:"a_y_axis",components:3,type:"Float32"}]),ug=ha([{name:"a_texb",components:2,type:"Uint16"}]),hg=ha([{name:"a_placed",components:2,type:"Uint8"},{name:"a_shift",components:2,type:"Float32"},{name:"a_elevation_from_sea",components:2,type:"Float32"}]),dg=ha([{name:"a_size_scale",components:1,type:"Float32"},{name:"a_padding",components:2,type:"Float32"},{name:"a_auto_z_offset",components:1,type:"Float32"}]);ha([{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 pg=ha([{name:"a_pos",components:3,type:"Int16"},{name:"a_anchor_pos",components:2,type:"Int16"},{name:"a_extrude",components:2,type:"Int16"}],4),fg=ha([{name:"a_pos_2f",components:2,type:"Float32"},{name:"a_radius",components:1,type:"Float32"},{name:"a_flags",components:2,type:"Int16"}],4);ha([{name:"triangle",components:3,type:"Uint16"}]),ha([{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"}]),ha([{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"}]),ha([{type:"Float32",name:"offsetX"}]),ha([{type:"Int16",name:"x"},{type:"Int16",name:"y"}]);var mg=24;function gg(e,t,i){return e.sections.forEach(e=>{e.text=function(e,t,i){const r=t.layout.get("text-transform").evaluate(i,{});return"uppercase"===r?e=e.toLocaleUpperCase():"lowercase"===r&&(e=e.toLocaleLowerCase()),Ts.applyArabicShaping&&(e=Ts.applyArabicShaping(e)),e}(e.text,t,i)}),e}const _g={"!":"︕","#":"#",$:"$","%":"%","&":"&","(":"︵",")":"︶","*":"*","+":"+",",":"︐","-":"︲",".":"・","/":"/",":":"︓",";":"︔","<":"︿","=":"=",">":"﹀","?":"︖","@":"@","[":"﹇","\\":"\","]":"﹈","^":"^",_:"︳","`":"`","{":"︷","|":"―","}":"︸","~":"~","¢":"¢","£":"£","¥":"¥","¦":"¦","¬":"¬","¯":" ̄","–":"︲","—":"︱","‘":"﹃","’":"﹄","“":"﹁","”":"﹂","…":"︙","‧":"・","₩":"₩","、":"︑","。":"︒","〈":"︿","〉":"﹀","《":"︽","》":"︾","「":"﹁","」":"﹂","『":"﹃","』":"﹄","【":"︻","】":"︼","〔":"︹","〕":"︺","〖":"︗","〗":"︘","!":"︕","(":"︵",")":"︶",",":"︐","-":"︲",".":"・",":":"︓",";":"︔","<":"︿",">":"﹀","?":"︖","[":"﹇","]":"﹈","_":"︳","{":"︷","|":"―","}":"︸","⦅":"︵","⦆":"︶","。":"︒","「":"﹁","」":"﹂","←":"↑","→":"↓"};function Ag(e){return"︶"===e||"﹈"===e||"︸"===e||"﹄"===e||"﹂"===e||"︾"===e||"︼"===e||"︺"===e||"︘"===e||"﹀"===e||"︐"===e||"︓"===e||"︔"===e||"`"===e||" ̄"===e||"︑"===e||"︒"===e}function yg(e){return"︵"===e||"﹇"===e||"︷"===e||"﹃"===e||"﹁"===e||"︽"===e||"︻"===e||"︹"===e||"︗"===e||"︿"===e}const vg=4294967296,xg=1/vg,bg="undefined"==typeof TextDecoder?null:new TextDecoder("utf-8");let wg=class{constructor(e=new Uint8Array(16)){this.buf=ArrayBuffer.isView(e)?e:new Uint8Array(e),this.dataView=new DataView(this.buf.buffer),this.pos=0,this.type=0,this.length=this.buf.length}readFields(e,t,i=this.length){for(;this.pos>3,n=this.pos;this.type=7&i,e(r,t,this),this.pos===n&&this.skip(i)}return t}readMessage(e,t){return this.readFields(e,t,this.readVarint()+this.pos)}readFixed32(){const e=this.dataView.getUint32(this.pos,!0);return this.pos+=4,e}readSFixed32(){const e=this.dataView.getInt32(this.pos,!0);return this.pos+=4,e}readFixed64(){const e=this.dataView.getUint32(this.pos,!0)+this.dataView.getUint32(this.pos+4,!0)*vg;return this.pos+=8,e}readSFixed64(){const e=this.dataView.getUint32(this.pos,!0)+this.dataView.getInt32(this.pos+4,!0)*vg;return this.pos+=8,e}readFloat(){const e=this.dataView.getFloat32(this.pos,!0);return this.pos+=4,e}readDouble(){const e=this.dataView.getFloat64(this.pos,!0);return this.pos+=8,e}readVarint(e){const t=this.buf;let i,r;return r=t[this.pos++],i=127&r,r<128?i:(r=t[this.pos++],i|=(127&r)<<7,r<128?i:(r=t[this.pos++],i|=(127&r)<<14,r<128?i:(r=t[this.pos++],i|=(127&r)<<21,r<128?i:(r=t[this.pos],i|=(15&r)<<28,function(e,t,i){const r=i.buf;let n,o;if(o=r[i.pos++],n=(112&o)>>4,o<128)return Tg(e,n,t);if(o=r[i.pos++],n|=(127&o)<<3,o<128)return Tg(e,n,t);if(o=r[i.pos++],n|=(127&o)<<10,o<128)return Tg(e,n,t);if(o=r[i.pos++],n|=(127&o)<<17,o<128)return Tg(e,n,t);if(o=r[i.pos++],n|=(127&o)<<24,o<128)return Tg(e,n,t);if(o=r[i.pos++],n|=(1&o)<<31,o<128)return Tg(e,n,t);throw new Error("Expected varint not more than 10 bytes")}(i,e,this)))))}readVarint64(){return this.readVarint(!0)}readSVarint(){const e=this.readVarint();return e%2==1?(e+1)/-2:e/2}readBoolean(){return Boolean(this.readVarint())}readString(){const e=this.readVarint()+this.pos,t=this.pos;return this.pos=e,e-t>=12&&bg?bg.decode(this.buf.subarray(t,e)):function(e,t,i){let r="",n=t;for(;n239?4:t>223?3:t>191?2:1;if(n+c>i)break;1===c?t<128&&(l=t):2===c?(o=e[n+1],128==(192&o)&&(l=(31&t)<<6|63&o,l<=127&&(l=null))):3===c?(o=e[n+1],s=e[n+2],128==(192&o)&&128==(192&s)&&(l=(15&t)<<12|(63&o)<<6|63&s,(l<=2047||l>=55296&&l<=57343)&&(l=null))):4===c&&(o=e[n+1],s=e[n+2],a=e[n+3],128==(192&o)&&128==(192&s)&&128==(192&a)&&(l=(15&t)<<18|(63&o)<<12|(63&s)<<6|63&a,(l<=65535||l>=1114112)&&(l=null))),null===l?(l=65533,c=1):l>65535&&(l-=65536,r+=String.fromCharCode(l>>>10&1023|55296),l=56320|1023&l),r+=String.fromCharCode(l),n+=c}return r}(this.buf,t,e)}readBytes(){const e=this.readVarint()+this.pos,t=this.buf.subarray(this.pos,e);return this.pos=e,t}readPackedVarint(e=[],t){const i=this.readPackedEnd();for(;this.pos127;);else if(2===t)this.pos=this.readVarint()+this.pos;else if(5===t)this.pos+=4;else{if(1!==t)throw new Error(`Unimplemented type: ${t}`);this.pos+=8}}writeTag(e,t){this.writeVarint(e<<3|t)}realloc(e){let t=this.length||16;for(;t268435455||e<0?function(e,t){let i,r;if(e>=0?(i=e%4294967296|0,r=e/4294967296|0):(i=~(-e%4294967296),r=~(-e/4294967296),4294967295^i?i=i+1|0:(i=0,r=r+1|0)),e>=0x10000000000000000||e<-0x10000000000000000)throw new Error("Given varint doesn't fit into 10 bytes");t.realloc(10),function(e,t,i){i.buf[i.pos++]=127&e|128,e>>>=7,i.buf[i.pos++]=127&e|128,e>>>=7,i.buf[i.pos++]=127&e|128,e>>>=7,i.buf[i.pos++]=127&e|128,i.buf[i.pos]=127&(e>>>=7)}(i,0,t),function(e,t){const i=(7&e)<<4;t.buf[t.pos++]|=i|((e>>>=3)?128:0),e&&(t.buf[t.pos++]=127&e|((e>>>=7)?128:0),e&&(t.buf[t.pos++]=127&e|((e>>>=7)?128:0),e&&(t.buf[t.pos++]=127&e|((e>>>=7)?128:0),e&&(t.buf[t.pos++]=127&e|((e>>>=7)?128:0),e&&(t.buf[t.pos++]=127&e)))))}(r,t)}(e,this):(this.realloc(4),this.buf[this.pos++]=127&e|(e>127?128:0),e<=127||(this.buf[this.pos++]=127&(e>>>=7)|(e>127?128:0),e<=127||(this.buf[this.pos++]=127&(e>>>=7)|(e>127?128:0),e<=127||(this.buf[this.pos++]=e>>>7&127))))}writeSVarint(e){this.writeVarint(e<0?2*-e-1:2*e)}writeBoolean(e){this.writeVarint(+e)}writeString(e){e=String(e),this.realloc(4*e.length),this.pos++;const t=this.pos;this.pos=function(e,t,i){for(let r,n,o=0;o55295&&r<57344){if(!n){r>56319||o+1===t.length?(e[i++]=239,e[i++]=191,e[i++]=189):n=r;continue}if(r<56320){e[i++]=239,e[i++]=191,e[i++]=189,n=r;continue}r=n-55296<<10|r-56320|65536,n=null}else n&&(e[i++]=239,e[i++]=191,e[i++]=189,n=null);r<128?e[i++]=r:(r<2048?e[i++]=r>>6|192:(r<65536?e[i++]=r>>12|224:(e[i++]=r>>18|240,e[i++]=r>>12&63|128),e[i++]=r>>6&63|128),e[i++]=63&r|128)}return i}(this.buf,e,this.pos);const i=this.pos-t;i>=128&&Eg(t,i,this),this.pos=t-1,this.writeVarint(i),this.pos+=i}writeFloat(e){this.realloc(4),this.dataView.setFloat32(this.pos,e,!0),this.pos+=4}writeDouble(e){this.realloc(8),this.dataView.setFloat64(this.pos,e,!0),this.pos+=8}writeBytes(e){const t=e.length;this.writeVarint(t),this.realloc(t);for(let i=0;i=128&&Eg(i,r,this),this.pos=i-1,this.writeVarint(r),this.pos+=r}writeMessage(e,t,i){this.writeTag(e,2),this.writeRawMessage(t,i)}writePackedVarint(e,t){t.length&&this.writeMessage(e,Cg,t)}writePackedSVarint(e,t){t.length&&this.writeMessage(e,Bg,t)}writePackedBoolean(e,t){t.length&&this.writeMessage(e,Mg,t)}writePackedFloat(e,t){t.length&&this.writeMessage(e,Sg,t)}writePackedDouble(e,t){t.length&&this.writeMessage(e,Ig,t)}writePackedFixed32(e,t){t.length&&this.writeMessage(e,Pg,t)}writePackedSFixed32(e,t){t.length&&this.writeMessage(e,Rg,t)}writePackedFixed64(e,t){t.length&&this.writeMessage(e,Lg,t)}writePackedSFixed64(e,t){t.length&&this.writeMessage(e,Fg,t)}writeBytesField(e,t){this.writeTag(e,2),this.writeBytes(t)}writeFixed32Field(e,t){this.writeTag(e,5),this.writeFixed32(t)}writeSFixed32Field(e,t){this.writeTag(e,5),this.writeSFixed32(t)}writeFixed64Field(e,t){this.writeTag(e,1),this.writeFixed64(t)}writeSFixed64Field(e,t){this.writeTag(e,1),this.writeSFixed64(t)}writeVarintField(e,t){this.writeTag(e,0),this.writeVarint(t)}writeSVarintField(e,t){this.writeTag(e,0),this.writeSVarint(t)}writeStringField(e,t){this.writeTag(e,2),this.writeString(t)}writeFloatField(e,t){this.writeTag(e,5),this.writeFloat(t)}writeDoubleField(e,t){this.writeTag(e,1),this.writeDouble(t)}writeBooleanField(e,t){this.writeVarintField(e,+t)}};function Tg(e,t,i){return i?4294967296*t+(e>>>0):4294967296*(t>>>0)+(e>>>0)}function Eg(e,t,i){const r=t<=16383?1:t<=2097151?2:t<=268435455?3:Math.floor(Math.log(t)/(7*Math.LN2));i.realloc(r);for(let t=i.pos-1;t>=e;t--)i.buf[t+r]=i.buf[t]}function Cg(e,t){for(let i=0;i=0&&i>=e&&Hg[this.text.charCodeAt(i)];i--)t--;this.text=this.text.substring(e,t),this.sectionIndex=this.sectionIndex.slice(e,t)}substring(e,t){const i=new jg;return i.text=this.text.substring(e,t),i.sectionIndex=this.sectionIndex.slice(e,t),i.sections=this.sections,i}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(Vg.forText(e.scale,e.fontStack||t));const i=this.sections.length-1;for(let t=0;t=63743?null:++this.imageSectionID:(this.imageSectionID=57344,this.imageSectionID)}}function Gg(e,t,i,r,n,o,s,a,l,c,u,h,d,p,f,m=1){const g=jg.fromFeature(e,n,m);h===Ng.vertical&&g.verticalizePunctuation(d);let _=[];const A=function(e,t,i,r,n,o){if(!e)return[];const s=[],a=function(e,t,i,r,n,o){let s=0;for(let i=0;i=0;let c=0;for(let i=0;i0&&o>x&&(x=o)}else{const e=i[a.fontStack];if(!e)continue;e[m]&&(T=e[m]);const r=t[a.fontStack];if(!r)continue;const o=r.glyphs[m];if(!o)continue;if(y=o.metrics,C=8203!==m?mg:0,g){const e=void 0!==r.ascender?Math.abs(r.ascender):0,t=void 0!==r.descender?Math.abs(r.descender):0,i=(e+t)*_;b-i/2;){if(s--,s<0)return!1;a-=e[s].dist(o),o=e[s]}a+=e[s].dist(e[s+1]),s++;const l=[];let c=0;for(;ar;)c-=l.shift().angleDelta;if(c>n)return!1;s++,a+=t.dist(i)}return!0}function h_(e){let t=0;for(let i=0;ic){const u=(c-l)/o,h=di(r.x,n.x,u),d=di(r.y,n.y,u),p=new c_(h,d,0,n.angleTo(r),i);return!s||u_(e,p,a,s,t)?p:void 0}l+=o}}function m_(e,t,i,r,n,o,s,a,l){const c=d_(r,o,s),u=p_(r,n),h=u*s,d=0===e[0].x||e[0].x===l||0===e[0].y||e[0].y===l;return t-h=0&&_=0&&A=0&&d+c<=u){const i=new c_(_,A,0,m,t);r&&!u_(e,i,o,r,n)||p.push(i)}}h+=f}return a||p.length||s||(p=g_(e,h/2,i,r,n,o,s,!0,l)),p}function __(e){let t=0,i=0;for(const r of e)t+=r.w*r.h,i=Math.max(i,r.w);e.sort((e,t)=>t.h-e.h);const r=[{x:0,y:0,w:Math.max(Math.ceil(Math.sqrt(t/.95)),i),h:1/0}];let n=0,o=0;for(const t of e)for(let e=r.length-1;e>=0;e--){const i=r[e];if(!(t.w>i.w||t.h>i.h)){if(t.x=i.x,t.y=i.y,o=Math.max(o,t.y+t.h),n=Math.max(n,t.x+t.w),t.w===i.w&&t.h===i.h){const t=r.pop();t&&e1?s-1:s,wh.copy(r.data,l,{x:0,y:0},{x:a,y:c},r.data,i),wh.copy(r.data,l,{x:0,y:h-s},{x:a,y:c-s},{width:u,height:s},i),wh.copy(r.data,l,{x:0,y:0},{x:a,y:c+h},{width:u,height:s},i),wh.copy(r.data,l,{x:u-s,y:0},{x:a-s,y:c},{width:s,height:h},i),wh.copy(r.data,l,{x:0,y:0},{x:a+u,y:c},{width:s,height:h},i),wh.copy(r.data,l,{x:u-s,y:h-s},{x:a-s,y:c-s},{width:s,height:s},i),wh.copy(r.data,l,{x:0,y:h-s},{x:a+u,y:c-s},{width:s,height:s},i),wh.copy(r.data,l,{x:0,y:0},{x:a+u,y:c+h},{width:s,height:s},i),wh.copy(r.data,l,{x:u-s,y:0},{x:a-s,y:c+h},{width:s,height:s},i)}this.lut=i,this.image=l,this.iconPositions=r,this.patternPositions=n}addImages(e,t,i,r){for(const[n,o]of e.entries()){const{bin:e,imagePosition:s,imageVariant:a}=v_(n,o,i);t.set(n,s),r.push(e),o.hasRenderCallback&&this.haveRenderCallbacks.push(a.id)}}patchUpdatedImages(e,t,i){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=Oi.parse(n);if(ni.isEqual(o.id,r)){const o=e.getImage(r,i);this.patchUpdatedImage(this.iconPositions.get(n),o,t,null)}}for(const n of this.patternPositions.keys()){const o=Oi.parse(n);if(ni.isEqual(o.id,r)){const o=e.getImage(r,i);this.patchUpdatedImage(this.patternPositions.get(n),o,t,this.lut)}}}}patchUpdatedImage(e,t,i,r=null){if(!e||!t)return;if(e.version===t.version)return;e.version=t.version;const[n,o]=e.tl,s=e.sdf;if(this.lut||s){const e={width:t.data.width,height:t.data.height},a=new wh(e);wh.copy(t.data,a,{x:0,y:0},{x:0,y:0},e,r,s),i.update(a,{position:{x:n,y:o}})}else i.update(t.data,{position:{x:n,y:o}})}}es(y_,"ImagePosition"),es(x_,"ImageAtlas");const b_=1e20;function w_(e,t,i,r,n,o,s,a,l){for(let c=t;c-1);l++,o[l]=a,s[l]=c,s[l+1]=b_}for(let a=0,l=0;a{let n=this.entries[e];n||(n=this.entries[e]={glyphs:{},requests:{},ranges:{},ascender:void 0,descender:void 0});let o=n.glyphs[t];if(void 0!==o)return void i(null,{stack:e,id:t,glyph:o});if(o=this._tinySDF(n,e,t),o)return n.glyphs[t]=o,void i(null,{stack:e,id:t,glyph:o});const s=Math.floor(t/256);if(256*s>65535)return Ze("glyphs > 65535 not supported"),void i(null,{stack:e,id:t,glyph:o});if(n.ranges[s])return void i(null,{stack:e,id:t,glyph:o});let a=n.requests[s];a||(a=n.requests[s]=[],B_.loadGlyphRange(e,s,r,this.requestManager,(e,t)=>{if(t){n.ascender=t.ascender,n.descender=t.descender;for(const e in t.glyphs)this._doesCharSupportLocalGlyph(+e)||(n.glyphs[+e]=t.glyphs[+e]);n.ranges[s]=!0}for(const i of a)i(e,t);delete n.requests[s]})),a.push((r,n)=>{r?i(r):n&&i(null,{stack:e,id:t,glyph:n.glyphs[t]||null})})},(e,i)=>{if(e)t(e);else if(i){const e={};for(const{stack:t,id:r,glyph:n}of i)void 0===e[t]&&(e[t]={}),void 0===e[t].glyphs&&(e[t].glyphs={}),e[t].glyphs[r]=n&&{id:n.id,bitmap:n.bitmap.clone(),metrics:n.metrics},e[t].ascender=this.entries[t].ascender,e[t].descender=this.entries[t].descender;t(null,e)}})}_doesCharSupportLocalGlyph(e){return this.localGlyphMode!==C_.none&&(this.localGlyphMode===C_.all?!!this.localFontFamily:!!this.localFontFamily&&(os["CJK Unified Ideographs"](e)||os["Hangul Syllables"](e)||os.Hiragana(e)||os.Katakana(e)||os["CJK Symbols and Punctuation"](e)||os["CJK Unified Ideographs Extension A"](e)||os["CJK Unified Ideographs Extension B"](e)||os.Osage(e)))}_tinySDF(e,t,i){const r=this.localFontFamily;if(!r||!this._doesCharSupportLocalGlyph(i))return;let n=e.tinySDF;if(!n){let i="400";/bold/i.test(t)?i="900":/medium/i.test(t)?i="500":/light/i.test(t)&&(i="200"),n=e.tinySDF=new B_.TinySDF({fontFamily:r,fontWeight:i,fontSize:24*E_,buffer:3*E_,radius:8*E_}),n.fontWeight=i}if(this.localGlyphs[n.fontWeight][i])return this.localGlyphs[n.fontWeight][i];const o=String.fromCodePoint(i),{data:s,width:a,height:l,glyphWidth:c,glyphHeight:u,glyphLeft:h,glyphTop:d,glyphAdvance:p}=n.draw(o);return this.localGlyphs[n.fontWeight][i]={id:i,bitmap:new bh({width:a,height:l},s),metrics:{width:c/E_,height:u/E_,left:h/E_,top:d/E_-27,advance:p/E_,localGlyph:!0}}}}B_.loadGlyphRange=function(e,t,i,r,n){const o=256*t,s=o+255,a=r.transformRequest(r.normalizeGlyphsURL(i).replace("{fontstack}",e).replace("{range}",`${o}-${s}`),kt.Glyphs);Ut(a,(e,t)=>{if(e)n(e);else if(t){const e={},i=function(e){return new wg(e).readFields(Dg,{})}(t);for(const t of i.glyphs)e[t.id]=t;n(null,{glyphs:e,ascender:i.ascender,descender:i.descender})}})},B_.TinySDF=class{constructor({fontSize:e=24,buffer:t=3,radius:i=8,cutoff:r=.25,fontFamily:n="sans-serif",fontWeight:o="normal",fontStyle:s="normal",lang:a=null}={}){this.buffer=t,this.cutoff=r,this.radius=i,this.lang=a;const l=this.size=e+4*t,c=this._createCanvas(l),u=this.ctx=c.getContext("2d",{willReadFrequently:!0});u.font=`${s} ${o} ${e}px ${n}`,u.textBaseline="alphabetic",u.textAlign="left",u.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){const t=document.createElement("canvas");return t.width=t.height=e,t}draw(e){const{width:t,actualBoundingBoxAscent:i,actualBoundingBoxDescent:r,actualBoundingBoxLeft:n,actualBoundingBoxRight:o}=this.ctx.measureText(e),s=Math.ceil(i),a=Math.max(0,Math.min(this.size-this.buffer,Math.ceil(o-n))),l=Math.min(this.size-this.buffer,s+Math.ceil(r)),c=a+2*this.buffer,u=l+2*this.buffer,h=Math.max(c*u,0),d=new Uint8ClampedArray(h),p={data:d,width:c,height:u,glyphWidth:a,glyphHeight:l,glyphTop:s,glyphLeft:0,glyphAdvance:t};if(0===a||0===l)return p;const{ctx:f,buffer:m,gridInner:g,gridOuter:_}=this;this.lang&&(f.lang=this.lang),f.clearRect(m,m,a,l),f.fillText(e,m,m+s);const A=f.getImageData(m,m,a,l);_.fill(b_,0,h),g.fill(0,0,h);for(let e=0;e0?e*e:0,g[r]=e<0?e*e:0}}w_(_,0,0,c,u,c,this.f,this.v,this.z),w_(g,m,m,a,l,c,this.f,this.v,this.z);for(let e=0;e{const d=k_(r.stretch-A,y,u,e.left*n),p=D_(r.fixed-b,w,r.stretch,f),g=k_(o.stretch-v,x,h,e.top*n),_=D_(o.fixed-T,E,o.stretch,m),C=k_(l.stretch-A,y,u,e.left*n),B=D_(l.fixed-b,w,l.stretch,f),S=k_(c.stretch-v,x,h,e.top*n),I=D_(c.fixed-T,E,c.stretch,m),M=new Te(d,g),P=new Te(C,g),R=new Te(C,S),L=new Te(d,S),F=new Te(p/a,_/a),k=new Te(B/a,I/a),D=t*Math.PI/180;if(D){const e=Math.sin(D),t=Math.cos(D),i=[t,-e,e,t];M._matMult(i),P._matMult(i),L._matMult(i),R._matMult(i)}const O=r.stretch+r.fixed,z=l.stretch+l.fixed,U=o.stretch+o.fixed,N=c.stretch+c.fixed,V=e.imageSecondary;return{tl:M,tr:P,bl:L,br:R,texPrimary:{x:s.paddedRect.x+S_+O,y:s.paddedRect.y+S_+U,w:z-O,h:N-U},texSecondary:V?{x:V.paddedRect.x+S_+O,y:V.paddedRect.y+S_+U,w:z-O,h:N-U}:void 0,writingMode:void 0,glyphOffset:[0,0],sectionIndex:0,pixelOffsetTL:F,pixelOffsetBR:k,minFontScaleX:w/a/u,minFontScaleY:E/a/h,isSDF:i}};if(r&&(s.stretchX||s.stretchY)){const e=L_(d,g,f),t=L_(p,_,m);for(let i=0;io)&&(o=t.x),(!e||t.y>s)&&(s=t.y)}const l=Math.min(o-r,s-n);let c=l/2;const u=new zr([],U_);if(0===l)return new Te(r,n);for(let t=r;th.d||!h.d)&&(h=r,i&&console.log("found best %d after %d probes",Math.round(1e4*r.d)/1e4,d)),r.max-h.d<=t||(c=r.h/2,u.push(new N_(r.p.x-c,r.p.y-c,c,e)),u.push(new N_(r.p.x+c,r.p.y-c,c,e)),u.push(new N_(r.p.x-c,r.p.y+c,c,e)),u.push(new N_(r.p.x+c,r.p.y+c,c,e)),d+=4)}return i&&(console.log(`num probes: ${d}`),console.log(`best distance: ${h.d}`)),h.p}function U_(e,t){return t.max-e.max}class N_{constructor(e,t,i,r){this.p=new Te(e,t),this.h=i,this.d=function(e,t){let i=!1,r=1/0;for(let n=0;ne.y!=a.y>e.y&&e.x<(a.x-n.x)*(e.y-n.y)/(a.y-n.y)+n.x&&(i=!i),r=Math.min(r,pu(e,n,a))}}return(i?1:-1)*Math.sqrt(r)}(this.p,r),this.max=this.d+this.h*Math.SQRT2}}const V_=Object.keys,j_=Number.POSITIVE_INFINITY,G_=Math.sqrt(2);function H_(e,t,i,r){const n=e.collisionPadding||[0,0,0,0],o={top:e.top-n[1],bottom:e.bottom+n[3],left:e.left-n[0],right:e.right+n[2],scaled:!1};return void 0!==r&&function(e,t){e.top*=t,e.bottom*=t,e.left*=t,e.right*=t,e.scaled=!0}(o,r),i&&function(e,t){if(!t)return;const i=Se(t),r=new Te(e.left,e.top),n=new Te(e.right,e.top),o=new Te(e.left,e.bottom),s=new Te(e.right,e.bottom);r._rotateAround(i,new Te(0,0)),n._rotateAround(i,new Te(0,0)),o._rotateAround(i,new Te(0,0)),s._rotateAround(i,new Te(0,0)),e.left=Math.min(r.x,n.x,o.x,s.x),e.right=Math.max(r.x,n.x,o.x,s.x),e.top=Math.min(r.y,n.y,o.y,s.y),e.bottom=Math.max(r.y,n.y,o.y,s.y)}(o,i),t?{top:Math.min(t.top,o.top),bottom:Math.max(t.bottom,o.bottom),left:Math.min(t.left,o.left),right:Math.max(t.right,o.right),scaled:t.scaled||o.scaled}:o}function Q_(e,[t,i]){let r=0,n=0;if(i===j_){t<0&&(t=0);const i=t/G_;switch(e){case"top-right":case"top-left":n=i-7;break;case"bottom-right":case"bottom-left":n=7-i;break;case"bottom":n=7-t;break;case"top":n=t-7}switch(e){case"top-right":case"bottom-right":r=-i;break;case"top-left":case"bottom-left":r=i;break;case"left":r=t;break;case"right":r=-t}}else{switch(t=Math.abs(t),i=Math.abs(i),e){case"top-right":case"top-left":case"top":n=i-7;break;case"bottom-right":case"bottom-left":case"bottom":n=7-i}switch(e){case"top-right":case"bottom-right":case"right":r=-t;break;case"top-left":case"bottom-left":case"left":r=t}}return[r,n]}function $_(e,t,i,r,n,o,s,a,l,c,u){const h=e.layers[0],d=h.appearances;if(0===d.length)return{iconBBox:null,iconVerticalBBox:null};let p=null,f=null;const m=r.get("icon-rotate").evaluate(n,{},o);t&&(p=H_(t,p,m,s),i)&&(f=H_(i,f,m+90,s));const[g,_]=r.get("icon-size-scale-range"),A=Fe(1,g,_);for(const i of d){const r=i.getUnevaluatedProperties(),d=void 0!==r._values["icon-image"].value,g=void 0!==r._values["icon-size"].value,_=void 0!==r._values["icon-offset"].value,y=void 0!==r._values["icon-rotate"].value;if(d||g||_||y){const v=_?h.getAppearanceValueAndResolveTokens(i,"icon-offset",n,o,[]):null,x=v&&Array.isArray(v)?v:a,b=y?h.getAppearanceValueAndResolveTokens(i,"icon-rotate",n,o,[]):null,w="number"==typeof b?b:m,T=g?h.getAppearanceValueAndResolveTokens(i,"icon-size",n,o,[]):null,E="number"==typeof T?T*l.iconScaleFactor:s;let C=null,B=null,S=null;if(d){const t=h.getAppearanceValueAndResolveTokens(i,"icon-image",n,o,[]);if(t){const i=e.getResolvedImageFromTokens(t),s=r._values["icon-size"],a=q_(i,s_(e.zoom,s,e.worldview),s,o,e.zoom,n,e.pixelRatio,A,e.worldview);S=c.get(a.iconPrimary.toString())}}else t&&(S=t.imagePrimary);S&&(C=e_(S,null,x,u),e.allowVerticalPlacement&&(B=e_(S,null,x,u))),C&&(p=H_(C,p,w,E)),B&&(f=H_(B,f,w+90,E))}}return{iconBBox:p,iconVerticalBBox:f}}function Z_(e,t,i,r,n,o,s,a,l){if(!t||!t.usvg)return;const c=n_(r),u=n_(n),h="both"!==o&&"width"!==o||!i_(r)?1:u.width/c.width,d="both"!==o&&"height"!==o||!r_(r)?1:u.height/c.height;i.scaleSelf(h,d);const p=i.toString();s.set(p,i),a.set(p,t);const{imagePosition:f}=v_(p,t,A_);l.set(p,f)}function W_(e,t,i,r,n,o,s,a,l){if(!e)return;const c=function(e,t,i,r,n,o){if("camera"===e.kind)return e.maxSize;if("composite"===e.kind){const r=t.possiblyEvaluate(new Es(e.maxZoom,{worldview:o}),i).evaluate(n,{},i),s=t.possiblyEvaluate(new Es(e.minZoom,{worldview:o}),i).evaluate(n,{},i);return Math.max(r,s)}return t.possiblyEvaluate(new Es(r,{worldview:o})).evaluate(n,{},i)}(t,i,r,n,o,l);return e.scaleSelf(c*a*s)}function q_(e,t,i,r,n,o,s,a,l){return{iconPrimary:W_(e.getPrimary(),t,i,r,n,o,s,a,l),iconSecondary:W_(e.getSecondary(),t,i,r,n,o,s,a,l)}}function K_(e,t,i){if(!t)return;const r=i.get(e.toString()),n=i.get(t.toString());r&&n&&(r.paddedRect.w===n.paddedRect.w&&r.paddedRect.h===n.paddedRect.h||Ze(`Mismatch in icon variant sizes: ${e.toString()} and ${t.toString()}`),r.usvg!==n.usvg&&Ze(`Mismatch in icon variant image types: ${e.id} and ${t.id}`))}function X_(e,t,i,r){if(!e)return;const n=t.get(i.toString());if(e.imagePrimary=n,r){const i=t.get(r.toString());e.imageSecondary=i}}function J_(e,t){for(const i in e.horizontal)Y_(e.horizontal[i],t);Y_(e.vertical,t)}function Y_(e,t){if(e)for(const i of e.positionedLines)for(const e of i.positionedGlyphs)if(null!==e.image){const i=e.image.toString();e.rect=t.get(i).paddedRect}}function eA(e){switch(e){case"right":case"top-right":case"bottom-right":return"right";case"left":case"top-left":case"bottom-left":return"left"}return"center"}function tA(e,t,i,r,n,o,s,a,l){const c=sA(o.horizontal)||o.vertical,u=i.get("icon-text-fit-padding").evaluate(r,{},n);let h,d=t;return t&&"none"!==l&&(e.allowVerticalPlacement&&o.vertical&&(h=t_(t,o.vertical,l,u,a,s)),c&&(d=t_(t,c,l,u,a,s))),{defaultShapedIcon:d,verticallyShapedIcon:h}}function iA(e,t,i,r,n,o,s,a,l,c,u,h,d,p,f,m,g,_,A,y,v,x){let b=s.textMaxSize.evaluate(t,{},d);void 0===b?b=a*s.textScaleFactor:b*=s.textScaleFactor;const w=e.layers[0].layout,T=mg,E=a*s.textScaleFactor/T,C=sA(i.horizontal)||i.vertical;if("none"!==g&&e.appearanceFeatureData&&t.index18&&k>2&&(k>>=1),Math.max(Ur/(512*k),1)*w.get("symbol-spacing")),M=w.get("text-padding")*e.tilePixelRatio,P=w.get("icon-padding")*e.tilePixelRatio,R=Se(w.get("text-max-angle")),L="map"===w.get("icon-rotation-alignment")&&"point"!==y,F=I/2;var k;!1===e.hasAnyIconTextFit&&"none"!==g&&(e.hasAnyIconTextFit=!0);const D=t.properties?+t.properties[Oc]:null,O=D&&e.elevationFeatureIdToIndex?e.elevationFeatureIdToIndex.get(D):65535,z=(a,l,y)=>{if(l.x<0||l.x>=Ur||l.y<0||l.y>=Ur)return;let b=null;if(B){const{x:e,y:t,z:i}=p.projectTilePoint(l.x,l.y,y);b={anchor:new c_(e,t,i,0,void 0),up:p.upVector(y,l.x,l.y)}}!function(e,t,i,r,n,o,s,a,l,c,u,h,d,p,f,m,g,_,A,y,v,x,b,w,T,E,C,B,S,I,M){const P=e.addToLineVertexArray(t,r);let R,L,F,k,D,O,z,U=0,N=0,V=0,j=0,G=-1,H=-1;const Q={};let $=Jt("");const Z=i?i.anchor:t,W="none"!==B;let q=0,K=0;if(void 0===l._unevaluatedLayout.getValue("text-radial-offset")){const e=l.layout.get("text-offset").evaluate(v,{},T);q=e[0]*mg,K=e[1]*mg}else q=l.layout.get("text-radial-offset").evaluate(v,{},T)*mg,K=j_;if(e.allowVerticalPlacement&&n.vertical){const e=n.vertical;if(f)O=lA(e),a&&(z=lA(a));else{const i=l.layout.get("text-rotate").evaluate(v,{},T)+90;F=aA(c,Z,t,u,h,d,e,p,i,m),a&&(k=aA(c,Z,t,u,h,d,a,_,i,null,M))}}if(o){const r=e.iconSizeData,n=l.layout.get("icon-rotate").evaluate(v,{},T),s=M_(o,n,b,W,x.iconScaleFactor),p=a?M_(a,n,b,W,x.iconScaleFactor):void 0;L=aA(c,Z,t,u,h,d,o,_,n,null,I);const f=function(e,t,i,r,n,o,s,a){const l=e.layers[0],c=l.appearances;let u=t.length;if(i&&(u=Math.max(u,i.length)),0===c.length)return u;const[h,d]=r.get("icon-size-scale-range"),p=Fe(1,h,d);for(const t of c){const i=t.getUnevaluatedProperties();if(void 0!==i._values["icon-image"].value){const r=l.getAppearanceValueAndResolveTokens(t,"icon-image",n,o,[]);if(r){const t=e.getResolvedImageFromTokens(r);if(t){const r=i._values["icon-size"],l=q_(t,s_(e.zoom,r,e.worldview),r,o,e.zoom,n,e.pixelRatio,p,e.worldview),c=s.get(l.iconPrimary.toString());u=Math.max(u,P_(c,a))}}}}return u}(e,s,p,l.layout,v,T,e.iconAtlasPositions,W);U=4*f;let m=null;"source"===r.kind?(m=[o_*l.layout.get("icon-size").evaluate(v,{},T)*x.iconScaleFactor],m[0]>nA&&Ze(`${e.layerIds[0]}: Value for "icon-size" is >= ${rA}. Reduce your "icon-size".`)):"composite"===r.kind&&(m=[o_*x.compositeIconSizes[0].evaluate(v,{},T)*x.iconScaleFactor,o_*x.compositeIconSizes[1].evaluate(v,{},T)*x.iconScaleFactor],(m[0]>nA||m[1]>nA)&&Ze(`${e.layerIds[0]}: Value for "icon-size" is >= ${rA}. Reduce your "icon-size".`)),e.addSymbols(e.icon,s,m,y,A,v,void 0,i,t,P.lineStartIndex,P.lineLength,-1,w,T,E,C,e.symbolInstances.length,f),G=e.icon.placedSymbolArray.length-1,p&&(N=4*f,e.addSymbols(e.icon,p,m,y,A,v,Ng.vertical,i,t,P.lineStartIndex,P.lineLength,-1,w,T,E,C,e.symbolInstances.length,f),H=e.icon.placedSymbolArray.length-1)}for(const r in n.horizontal){const o=r,a=n.horizontal[o];R||($=Jt(a.text),f?D=lA(a):R=aA(c,Z,t,u,h,d,a,p,l.layout.get("text-rotate").evaluate(v,{},T),m));const g=1===a.positionedLines.length;if(V+=oA(e,i,t,a,s,l,f,v,m,P,n.vertical?Ng.horizontal:Ng.horizontalOnly,g?V_(n.horizontal):[o],Q,G,x,w,T,e.symbolInstances.length,E),g)break}n.vertical&&(j+=oA(e,i,t,n.vertical,s,l,f,v,m,P,Ng.vertical,["vertical"],Q,H,x,w,T,e.symbolInstances.length,E));let X=-1;const J=(e,t)=>e?Math.max(e,t):t;X=J(D,X),X=J(O,X),X=J(z,X);const Y=X>-1?1:0;e.glyphOffsetArray.length>=65535&&Ze("Too many glyphs being rendered in a tile. See https://github.com/mapbox/mapbox-gl-js/issues/2907"),void 0!==v.sortKey&&e.addToSortKeyRanges(e.symbolInstances.length,v.sortKey),e.symbolInstances.emplaceBack(t.x,t.y,Z.x,Z.y,Z.z,Q.right>=0?Q.right:-1,Q.center>=0?Q.center:-1,Q.left>=0?Q.left:-1,Q.vertical>=0?Q.vertical:-1,G,H,$,void 0!==R?R:e.collisionBoxArray.length,void 0!==R?R+1:e.collisionBoxArray.length,void 0!==F?F:e.collisionBoxArray.length,void 0!==F?F+1:e.collisionBoxArray.length,void 0!==L?L:e.collisionBoxArray.length,void 0!==L?L+1:e.collisionBoxArray.length,k||e.collisionBoxArray.length,k?k+1:e.collisionBoxArray.length,u,V,j,U,N,Y,0,q,K,X,0,W?1:0,S)}(e,l,b,a,i,r,o,n,e.layers[0],e.collisionBoxArray,t.index,t.sourceLayerIndex,e.index,M,A,c,0,P,L,_,t,s,u,h,d,f,m,g,O,v,x)};if("line"===y)for(const n of Fp(t.geometry,0,0,Ur,Ur)){const t=m_(n,I,R,i.vertical||C,r,T,S,e.overscaling,Ur);for(const i of t)C&&cA(e,C.text,F,i)||z(n,i,d)}else if("line-center"===y){for(const e of t.geometry)if(e.length>1){const t=f_(e,R,i.vertical||C,r,T,S);t&&z(e,t,d)}}else if("Polygon"===t.type)for(const e of id(t.geometry,0)){const t=z_(e,16);z(e[0],new c_(t.x,t.y,0,0,void 0),d)}else if("LineString"===t.type)for(const e of t.geometry)z(e,new c_(e[0].x,e[0].y,0,0,void 0),d);else if("Point"===t.type)for(const e of t.geometry)for(const t of e)z([t],new c_(t.x,t.y,0,0,void 0),d)}const rA=255,nA=rA*o_;function oA(e,t,i,r,n,o,s,a,l,c,u,h,d,p,f,m,g,_,A){const y=function(e,t,i,r,n,o,s,a){const l=[];if(0===t.positionedLines.length)return l;const c=r.layout.get("text-rotate").evaluate(o,{})*Math.PI/180,u=function(e){const t=e[0],i=e[1],r=t*i;return r>0?[t,-i]:r<0?[-t,i]:0===t?[i,t]:[i,-t]}(i);let h=Math.abs(t.top-t.bottom);for(const e of t.positionedLines)h-=e.lineOffset;const d=t.positionedLines.length,p=h/d;let f=t.top-i[1];for(let e=0;enA&&Ze(`${e.layerIds[0]}: Value for "text-size" is >= ${rA}. Reduce your "text-size".`)):"composite"===v.kind&&(x=[o_*f.compositeTextSizes[0].evaluate(a,{},g)*f.textScaleFactor,o_*f.compositeTextSizes[1].evaluate(a,{},g)*f.textScaleFactor],(x[0]>nA||x[1]>nA)&&Ze(`${e.layerIds[0]}: Value for "text-size" is >= ${rA}. Reduce your "text-size".`)),e.addSymbols(e.text,y,x,l,s,a,u,t,i,c.lineStartIndex,c.lineLength,p,m,g,A,!1,_,y.length);for(const t of h)d[t]=e.text.placedSymbolArray.length-1;return 4*y.length}function sA(e){for(const t in e)return e[t];return null}function aA(e,t,i,r,n,o,s,a,l,c,u){let h,d,p,f;if(h=u?u.top:s.top,d=u?u.bottom:s.bottom,p=u?u.left:s.left,f=u?u.right:s.right,Yg(s)&&s.collisionPadding){const e=s.collisionPadding;p-=e[0],h-=e[1],f+=e[2],d+=e[3]}if(l){const e=new Te(p,h),t=new Te(f,h),i=new Te(p,d),r=new Te(f,d),n=Se(l);let o=new Te(0,0);c&&(o=new Te(c[0],c[1])),e._rotateAround(n,o),t._rotateAround(n,o),i._rotateAround(n,o),r._rotateAround(n,o),p=Math.min(e.x,t.x,i.x,r.x),f=Math.max(e.x,t.x,i.x,r.x),h=Math.min(e.y,t.y,i.y,r.y),d=Math.max(e.y,t.y,i.y,r.y)}return e.emplaceBack(t.x,t.y,t.z,i.x,i.y,p,h,f,d,a,r,n,o),e.length-1}function lA(e){Yg(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 cA(e,t,i,r){const n=e.compareText;if(t in n){const e=n[t];for(let t=e.length-1;t>=0;t--)if(r.dist(e[t])y&&(v(e,c,r,n,a,l),v(c,i,a,l,o,s))}v(h,d,r,o,n,o),v(d,p,n,o,n,s),v(p,f,n,s,r,s),v(f,h,r,s,r,o),m-=y,g-=y,_+=y,A+=y;const x=1/Math.max(_-m,A-g);return{scale:x,x:m*x,y:g*x,x2:_*x,y2:A*x,projection:t}}function dA(e,{x:t,y:i},r=0){return new Te(((t-r)*e.scale-e.x)*Ur,(i*e.scale-e.y)*Ur)}const pA=c(new Float32Array(16));class fA{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 nc(0,0)}projectTilePoint(e,t,i){return{x:e,y:t,z:0}}locationPoint(e,t,i,r=!0){return e._coordinatePoint(e.locationCoordinate(t,i),r)}pixelsPerMeter(e,t){return hc(1,e)*t}pixelSpaceConversion(e,t,i){return 1}farthestPixelDistance(e){return uA(e,e.pixelsPerMeter)}pointCoordinate(e,t,i,r){const n=e.horizonLineFromTop(!1),o=new Te(t,Math.max(n,i));return e.rayIntersectionCoordinate(e.pointRayIntersection(o,r))}pointCoordinate3D(e,t,i){const r=new Te(t,i);if(e.elevation)return e.elevation.pointCoordinate(r);{const t=this.pointCoordinate(e,r.x,r.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.y0?t<-wA+i&&(t=-wA+i):t>wA-i&&(t=wA-i);const o=n/Math.pow(TA(t),r);let s=o*Math.sin(r*e),a=n-o*Math.cos(r*e);return s=.5*(s/Math.PI+.5),a=.5*(a/Math.PI+.5),{x:s,y:this.southernCenter?a:1-a,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:r}=this,n=r-t,o=Math.sign(n),s=Math.sign(i)*Math.sqrt(e*e+n*n);let a=Math.atan2(e,Math.abs(n))*o;n*i<0&&(a-=Math.PI*Math.sign(e)*o);const l=Fe(Ie(a/i)+this.center[0],-180,180),c=Fe(Ie(2*Math.atan(Math.pow(r/s,1/i))-wA),-mc,mc);return new nc(l,this.southernCenter?-c:c)}}class CA extends fA{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:cc(e),y:uc(t),z:0}}unproject(e,t){const i=dc(e),r=pc(t);return new nc(i,r)}}const BA=Se(mc);class SA extends fA{project(e,t){const i=(t=Se(t))*t,r=i*i;return{x:.5*((e=Se(e))*(.8707-.131979*i+r*(r*(.003971*i-.001529*r)-.013791))/Math.PI+.5),y:1-.5*(t*(1.007226+i*(.015085+r*(.028874*i-.044475-.005916*r)))/Math.PI+1),z:0}}unproject(e,t){e=(2*e-.5)*Math.PI;let i=t=(2*(1-t)-1)*Math.PI,r=25,n=0,o=i*i;do{o=i*i;const e=o*o;n=(i*(1.007226+o*(.015085+e*(.028874*o-.044475-.005916*e)))-t)/(1.007226+o*(.045255+e*(.259866*o-.311325-.005916*11*e))),i=Fe(i-n,-BA,BA)}while(Math.abs(n)>1e-6&&--r>0);o=i*i;const s=Fe(Ie(e/(.8707+o*(o*(o*o*o*(.003971-.001529*o)-.013791)-.131979))),-180,180),a=Ie(i);return new nc(s,a)}}const IA=Se(mc);class MA extends fA{project(e,t){t=Se(t),e=Se(e);const i=Math.cos(t),r=2/Math.PI,n=Math.acos(i*Math.cos(e/2)),o=Math.sin(n)/n,s=.5*(e*r+2*i*Math.sin(e/2)/o)||0,a=.5*(t+Math.sin(t)/o)||0;return{x:.5*(s/Math.PI+.5),y:1-.5*(a/Math.PI+1),z:0}}unproject(e,t){let i=e=(2*e-.5)*Math.PI,r=t=(2*(1-t)-1)*Math.PI,n=25;const o=1e-6;let s=0,a=0;do{const n=Math.cos(r),o=Math.sin(r),l=2*o*n,c=o*o,u=n*n,h=Math.cos(i/2),d=Math.sin(i/2),p=2*h*d,f=d*d,m=1-u*h*h,g=m?1/m:0,_=m?Math.acos(n*h)*Math.sqrt(1/m):0,A=.5*(2*_*n*d+2*i/Math.PI)-e,y=.5*(_*o+r)-t,v=.5*g*(u*f+_*n*h*c)+1/Math.PI,x=g*(p*l/4-_*o*d),b=.125*g*(l*d-_*o*u*p),w=.5*g*(c*h+_*f*n)+.5,T=x*b-w*v;s=(y*x-A*w)/T,a=(A*b-y*v)/T,i=Fe(i-s,-Math.PI,Math.PI),r=Fe(r-a,-IA,IA)}while((Math.abs(s)>o||Math.abs(a)>o)&&--n>0);return new nc(Ie(i),Ie(r))}}class PA extends fA{constructor(e){super(e),this.center=e.center||[0,0],this.parallels=e.parallels||[0,0],this.cosPhi=Math.max(.01,Math.cos(Se(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:r}=this;return{x:Se(e)*r*i+.5,y:-Math.sin(Se(t))/r*i+.5,z:0}}unproject(e,t){const{scale:i,cosPhi:r}=this,n=-(t-.5)/i,o=Fe(Ie((e-.5)/i)/r,-180,180),s=Math.asin(Fe(n*r,-1,1)),a=Fe(Ie(s),-mc,mc);return new nc(o,a)}}class RA extends CA{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 r=Zu(e,t,i);return j(r,r,Ku(Vu(i))),{x:r[0],y:r[1],z:r[2]}}locationPoint(e,t,i){const r=tc(t.lat,t.lng),n=z([],r),o=i?e._centerAltitude+i:e.elevation?e.elevation.getAtPointOrZero(e.locationCoordinate(t),e._centerAltitude):e._centerAltitude;L(r,r,n,hc(1,0)*Ur*o);const s=c(new Float64Array(16));return h(s,e.pixelMatrix,e.globeMatrix),j(r,r,s),new Te(r[0],r[1])}pixelsPerMeter(e,t){return hc(1,0)*t}pixelSpaceConversion(e,t,i){const r=hc(1,e)*t,n=di(hc(1,45)*t,r,i);return this.pixelsPerMeter(e,t)/n}createTileMatrix(e,t,i){const r=Xu(Vu(i.canonical));return h(new Float64Array(16),e.globeMatrix,r)}createInversionMatrix(e,t){const{center:i}=e,r=Ku(Vu(t));return m(r,r,Se(i.lng)),f(r,r,Se(i.lat)),p(r,r,[e._pixelsPerMercatorPixel,e._pixelsPerMercatorPixel,1]),Float32Array.from(r)}pointCoordinate(e,t,i,r){return zu(e,t,i,!0)||new vc(0,0)}pointCoordinate3D(e,t,i){const r=this.pointCoordinate(e,t,i,0);return[r.x,r.y,r.z]}isPointAboveHorizon(e,t){return!zu(e,t.x,t.y,!1)}farthestPixelDistance(e){const t=function(e,t){const i=e.cameraToCenterDistance,r=e._centerAltitude*t,n=e._camera,o=e._camera.forward(),s=B([],R([],o,-i),[0,0,r]),a=e.worldSize/(2*Math.PI),l=[0,0,-a],c=e.width/e.height,u=Math.tan(e.fovAboveCenter),h=R([],n.up(),u),d=R([],n.right(),u*c),p=z([],B([],B([],o,h),d)),f=[];let m;if(new Qc(s,p).closestPointOnSphere(l,a,f)){const t=B([],f,l),i=Z([],t,s);m=Math.cos(e.fovAboveCenter)*T(i)}else{const e=Z([],s,l),t=Z([],l,s);z(t,t);const i=T(e)-a;m=Math.sqrt(i*(i+2*a));const r=Math.acos(m/(a+i))-Math.acos(U(o,t));m*=Math.cos(r)}return 1.01*m}(e,this.pixelsPerMeter(e.center.lat,e.worldSize)),i=th(e.zoom);if(i>0){const r=uA(e,hc(1,e.center.lat)*e.worldSize),n=e.worldSize/(2*Math.PI),o=Math.max(e.width,e.height)/e.worldSize*Math.PI;return di(t,r+n*(1-Math.cos(o)),Math.pow(i,10))}return t}upVector(e,t,i){return Zu(t,i,e,1)}upVectorScale(e){return{metersToTile:Du(Wu(Vu(e)))}}}function LA(e){const t=e.parallels,i=!!t&&Math.abs(t[0]+t[1])<.01;switch(e.name){case"mercator":return new CA(e);case"equirectangular":return new bA(e);case"naturalEarth":return new SA(e);case"equalEarth":return new xA(e);case"winkelTripel":return new MA(e);case"albers":return i?new PA(e):new mA(e);case"lambertConformalConic":return i?new PA(e):new EA(e);case"globe":return new RA(e)}throw new Error(`Invalid projection name: ${e.name}`)}const FA=Mc.types,kA=[{name:"a_fade_opacity",components:1,type:"Uint8",offset:0}];function DA(e,t,i,r,n,o,s,a,l,c,u,h,d){const p=a?Math.min(nA,Math.round(a[0])):0,f=a?Math.min(nA,Math.round(a[1])):0;e.emplaceBack(t,i,Math.round(32*r),Math.round(32*n),o,s,(p<<1)+(l?1:0),0+(f<<1),16*c,16*u,256*h,256*d)}function OA(e,t,i){e.emplaceBack(t,i)}function zA(e,t,i,r,n,o,s){e.emplaceBack(t,i,r,n,o,s)}const UA=(e,t,i,r)=>{for(let n=0;n0&&(this.iconTransitioningVertexBuffer=e.createVertexBuffer(this.iconTransitioningVertexArray,ug.members,!0)),this.globeExtVertexArray.length>0&&(this.globeExtVertexBuffer=e.createVertexBuffer(this.globeExtVertexArray,sg.members,!0)),!this.zOffsetVertexBuffer&&(this.zOffsetVertexArray.length>0||n)&&(this.zOffsetVertexBuffer=e.createVertexBuffer(this.zOffsetVertexArray,lg.members,!0)),!this.orientationVertexBuffer&&this.orientationVertexArray&&this.orientationVertexArray.length>0&&(this.orientationVertexBuffer=e.createVertexBuffer(this.orientationVertexArray,cg.members,!0)),this.opacityVertexBuffer.itemSize=1),(i||r)&&this.programConfigurations.upload(e))}destroy(){this.layoutVertexBuffer&&(this.layoutVertexBuffer.destroy(),this.indexBuffer.destroy(),this.programConfigurations.destroy(),this.segments.destroy(),this.dynamicLayoutVertexBuffer.destroy(),this.opacityVertexBuffer.destroy(),this.iconTransitioningVertexBuffer&&this.iconTransitioningVertexBuffer.destroy(),this.globeExtVertexBuffer&&this.globeExtVertexBuffer.destroy(),this.zOffsetVertexBuffer&&this.zOffsetVertexBuffer.destroy(),this.orientationVertexBuffer&&this.orientationVertexBuffer.destroy())}}es(jA,"SymbolBuffers");class GA{constructor(e,t,i){this.layoutVertexArray=new e,this.layoutAttributes=t,this.indexArray=new i,this.segments=new hl,this.collisionVertexArray=new La,this.collisionVertexArrayExt=new Ba}upload(e){this.layoutVertexBuffer=e.createVertexBuffer(this.layoutVertexArray,this.layoutAttributes),this.indexBuffer=e.createIndexBuffer(this.indexArray),this.collisionVertexBuffer=e.createVertexBuffer(this.collisionVertexArray,hg.members,!0),this.collisionVertexBufferExt=e.createVertexBuffer(this.collisionVertexArrayExt,dg.members,!0)}destroy(){this.layoutVertexBuffer&&(this.layoutVertexBuffer.destroy(),this.indexBuffer.destroy(),this.segments.destroy(),this.collisionVertexBuffer.destroy(),this.collisionVertexBufferExt.destroy())}}es(GA,"CollisionBuffers");class HA{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=c([]),this.placementViewportMatrix=c([]);const t=this.layers[0]._unevaluatedLayout._values;this.worldview=e.worldview,this.textSizeData=s_(this.zoom,t["text-size"],this.worldview),this.iconSizeData=s_(this.zoom,t["icon-size"],this.worldview);const i=this.layers[0].layout,r=i.get("symbol-sort-key"),n=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"!==n&&void 0!==r.constantOr(1),this.sortFeaturesByY=("viewport-y"===n||"auto"===n&&!this.sortFeaturesByKey)&&this.canOverlap,this.writingModes=i.get("text-writing-mode").map(e=>Ng[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.elevationStateComplete=!1,this.activeReplacements=[],this.replacementUpdateTime=0,this.hasAnySecondaryIcon=!1,this.hasAppearances=null,this.lastActiveApperance=null}hasAnyAppearanceProperty(e){const t=this.layers[0].getAppearances();return!(!t||0===t.length)&&t.some(t=>null!=t.getProperty(e))}createArrays(){this.text=new jA(new Nl(this.layers,{zoom:this.zoom,lut:this.lut},e=>e.startsWith("text")||e.startsWith("symbol"))),this.icon=new jA(new Nl(this.layers,{zoom:this.zoom,lut:this.lut},e=>e.startsWith("icon")||e.startsWith("symbol"))),this.glyphOffsetArray=new tl,this.lineVertexArray=new il,this.symbolInstances=new el}calculateGlyphDependencies(e,t,i,r,n){for(const i of e){const e=i.codePointAt(0);if(void 0===e)break;if(t[e]=!0,r&&n&&e<=65535){const e=_g[i];e&&(t[e.charCodeAt(0)]=!0)}}}calculateEffectiveAppearanceIconSize(e,t,i,r,n,o){let s=1;const a=e.getUnevaluatedProperties()._values["icon-size"],l=s_(this.zoom,a,this.worldview),c=l_(l,t);if("constant"!==l.kind&&"camera"!==l.kind||(s=c.uSize),"composite"===l.kind){const{minZoom:e,maxZoom:t}=l,o=a.possiblyEvaluate(new Es(e,{worldview:this.worldview}),r),u=a.possiblyEvaluate(new Es(t,{worldview:this.worldview}),r),h=o.evaluate(i,{},r,n);s=h+(u.evaluate(i,{},r,n)-h)*c.uSizeT}return"source"===l.kind&&(s=a.possiblyEvaluate(new Es(this.zoom,{worldview:this.worldview}),r).evaluate(i,{},r,n)),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!jd(this.activeReplacements,i)&&(this.activeReplacements=i,!0)}getResolvedImageFromTokens(e){return"string"==typeof e?zi.build(e):e}populate(e,t,i,r){const n=this.layers[0],o=n.layout,s="globe"===this.projection.name,a=o.get("text-font"),l=o.get("text-field"),c=o.get("icon-image"),[u,h]=o.get("icon-size-scale-range"),d=Fe(t.scaleFactor||1,u,h),p=("constant"!==l.value.kind||l.value.value instanceof Di&&!l.value.value.isEmpty()||l.value.value.toString().length>0)&&("constant"!==a.value.kind||a.value.value.length>0),f="constant"!==c.value.kind||!!c.value.value||Object.keys(c.parameters).length>0,m=this.hasAnyAppearanceProperty("icon-image"),g=o.get("symbol-sort-key");if(this.features=[],this.appearanceFeatureData=[],!p&&!f&&!m)return;const _=t.iconDependencies,A=t.glyphDependencies,y=t.availableImages,v=new Es(this.zoom,{worldview:this.worldview,activeFloors:t.activeFloors}),x=e=>{const t=e.id.toString();_.has(t)?_.get(t).push(e):_.set(t,[e])};for(const t of e){const{feature:e,id:l,index:c,sourceLayerIndex:u}=t,h=n._featureFilter.needGeometry,b=Ic(e,h);if(!n._featureFilter.filter(v,b,i))continue;if(h||(b.geometry=Sc(e,i,r)),s&&1!==e.type&&i.z<=5){const e=b.geometry,t=.98078528056,r=(e,r)=>U(Zu(e.x,e.y,i,1),Zu(r.x,r.y,i,1)){if(!e.getProperty("icon-image"))return;const t=this.getCombinedIconPrimary(e,E,b,i,y,S,d);t&&x(t)}),w){const e=a.evaluate(b,{},i).join(","),t="map"===o.get("text-rotation-alignment")&&"point"!==o.get("symbol-placement");this.allowVerticalPlacement=this.writingModes&&this.writingModes.indexOf(Ng.vertical)>=0;for(const i of w.sections)if(i.image){const e=i.image.getPrimary().scaleSelf(this.pixelRatio),t=e.id.toString(),r=_.get(t)||[];r.push(e),_.set(t,r)}else{const r=ss(w.toString()),n=i.fontStack||e,o=A[n]=A[n]||{};this.calculateGlyphDependencies(i.text,o,t,this.allowVerticalPlacement,r)}}}if("line"===o.get("symbol-placement")&&(this.features=function(e){const t={},i={},r=[];let n=0;function o(t){r.push(e[t]),n++}function s(e,t,n){const o=i[e];return delete i[e],i[t]=o,r[o].geometry[0].pop(),r[o].geometry[0]=r[o].geometry[0].concat(n[0]),o}function a(e,i,n){const o=t[i];return delete t[i],t[e]=o,r[o].geometry[0].shift(),r[o].geometry[0]=n[0].concat(r[o].geometry[0]),o}function l(e,t,i){const r=i?t[0][t[0].length-1]:t[0][0];return`${e}:${r.x}:${r.y}`}for(let c=0;ce.geometry)}(this.features)),"hd-road-markup"===o.get("symbol-elevation-reference")){if(this.elevationType="road",t.elevationFeatures){!this.elevationFeatures&&t.elevationFeatures.length>0&&(this.elevationFeatures=[],this.elevationFeatureIdToIndex=new Map);for(const e of t.elevationFeatures)this.elevationFeatureIdToIndex.set(e.id,this.elevationFeatures.length),this.elevationFeatures.push(e)}}else 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)}getCombinedIconPrimary(e,t,i,r,n,o,s){let a,l;const c=e.getUnevaluatedProperties();if(void 0!==c._values["icon-image"].value){const o=t.getAppearanceValueAndResolveTokens(e,"icon-image",i,r,n);a=this.getResolvedImageFromTokens(o)}else{const e=t.getValueAndResolveTokens("icon-image",i,r,n);a=this.getResolvedImageFromTokens(e)}if(a){const e=c._values["icon-size"]||t._unevaluatedLayout._values["icon-size"];l=q_(a,s_(this.zoom,e,this.worldview),e,r,this.zoom,o,this.pixelRatio,s,this.worldview).iconPrimary}return l}updateAppearanceBasedIconTextures(e,t,i,r){if(!this.appearanceFeatureData)return!1;if(!this.icon.layoutVertexArray||0===this.icon.layoutVertexArray.length)return!1;const n=this.layers[0];let o=!1,s=0;const a=n.layout,[l,c]=a.get("icon-size-scale-range"),u=Fe(1,l,c);for(let a=0;a=0){const a=c.id,h=t&&void 0!==a?t[String(a)]:void 0,d={type:"Point",id:c.id,properties:c.properties,geometry:[]},p=this.layers[0].appearances&&this.layers[0].appearances.find(t=>t.isActive({globals:r,feature:d,canonical:e,featureState:h}));if(c.activeAppearance===p)continue;if(p){c.activeAppearance=p;const t={sortKey:void 0,text:void 0,icon:null,index:l.featureIndex,sourceLayerIndex:l.featureIndex,geometry:[],properties:c.properties,type:"Point",id:c.id};if(!p.hasCachedIconPrimary()){const r=this.getCombinedIconPrimary(p,n,d,e,i,t,u);p.setCachedIconPrimary(r)}const a=p.getCachedIconPrimary();if(!a)continue;const h=a.toString(),f=this.iconAtlasPositions&&this.iconAtlasPositions.get(h);if(f){const t=n.getAppearanceValueAndResolveTokens(p,"icon-offset",d,e,i),a=t&&Array.isArray(t)?t:[0,0];let h=e_(f,void 0,a,n.layout.get("icon-anchor").evaluate(d,{},e));const m=n.getAppearanceValueAndResolveTokens(p,"icon-rotate",d,e,i),g="number"==typeof m?m:0,_=f.sdf,A=n.layout.get("icon-text-fit").constantOr("none");"none"!==A&&c.textShaping&&c.iconTextFitPadding&&c.fontScale&&(h=t_(h,c.textShaping,A,c.iconTextFitPadding,a,c.fontScale));const y=this.calculateEffectiveAppearanceIconSize(p,r.zoom,d,e,i,u),v=0,x=1+(Math.min(nA,Math.round(y*o_))<<1),b=M_(h,g,_,"none"!==A,u);c.isUsingAppearanceVertexData||(c.isUsingAppearanceVertexData=!0,c.layoutBasedVertexData=this.icon.getIconVertexData(s,l.numIconVertices));for(let e=0;e0&&(this.icon.updateIconVertexData(s,0,0,0,0,0,0,0,0,0,0,0,0),this.icon.updateIconVertexData(s+1,0,0,0,0,0,0,0,0,0,0,0,0),this.icon.updateIconVertexData(s+2,0,0,0,0,0,0,0,0,0,0,0,0),this.icon.updateIconVertexData(s+3,0,0,0,0,0,0,0,0,0,0,0,0),o=!0),s+=l.numIconVertices,c.activeAppearance=null;else if(c.isUsingAppearanceVertexData){const e=12,t=c.layoutBasedVertexData.length/e;for(let i=0;i0||u>0,f=h>0,m=this.elevationFeatures[s.elevationFeatureIndex];if(m){const e=new Te(s.tileAnchorX,s.tileAnchorY),c=.075+m.pointElevation(e);s.zOffset!==c&&(t=!0,s.zOffset=c),0!==c&&(this.hasAnyZOffset=!0);const u=m.computeSlopeNormal(e,r),h=le(ee(),E(0,0,1),u);H(a,a,h),H(l,l,h),a[2]*=i,l[2]*=i,1===a[0]&&0===a[1]&&0===a[2]&&0===l[0]&&1===l[1]&&0===l[2]||(n=n||p,o=o||f)}if(p&&(UA(this.text.orientationVertexArray,c,a,l),UA(this.text.orientationVertexArray,u,a,l)),f){const{placedIconSymbolIndex:e,verticalPlacedIconSymbolIndex:t}=s;e>=0&&UA(this.icon.orientationVertexArray,h,a,l),t>=0&&UA(this.icon.orientationVertexArray,d,a,l)}}n||(this.text.orientationVertexArray=void 0),o||(this.icon.orientationVertexArray=void 0),t&&(this.zOffsetBuffersNeedUpload=!0,this.zOffsetSortDirty=!0)}updateZOffset(){const e=(e,t,r)=>{i+=t,i>e.length&&e.resize(i);for(let n=-t;n<0;n++)e.emplace(n+i,r)},t=(e,t,i)=>{r+=t,r>e.length&&e.resize(r);for(let n=-t;n<0;n++)e.emplace(n+r,i)};if(!this.zOffsetBuffersNeedUpload)return;this.zOffsetBuffersNeedUpload=!1;let i=0,r=0;for(let i=0;i0;if((n>0||o>0)&&(e(this.text.zOffsetVertexArray,n,a),e(this.text.zOffsetVertexArray,o,a)),l){const{placedIconSymbolIndex:e,verticalPlacedIconSymbolIndex:i}=r;e>=0&&t(this.icon.zOffsetVertexArray,s,a),i>=0&&t(this.icon.zOffsetVertexArray,r.numVerticalIconVertices,a)}}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,r,n){!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,!1),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,r){return!!(e&&t&&i)&&!(!this.icon.layoutVertexArray||0===this.icon.layoutVertexArray.length)&&!!this.icon.layoutVertexArray.arrayBuffer&&void(this.updateAppearanceBasedIconTextures(e,t,i,r)&&this.icon.layoutVertexBuffer&&null!==this.icon.layoutVertexArray.arrayBuffer&&this.icon.layoutVertexArray.length===this.icon.layoutVertexBuffer.length&&this.icon.layoutVertexBuffer.updateData(this.icon.layoutVertexArray))}destroyDebugData(){this.textCollisionBox.destroy(),this.iconCollisionBox.destroy()}getProjection(){return this.projectionInstance||(this.projectionInstance=LA(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,r,n,o,s,a,l,c,u,h,d,p,f,m,g,_){const A=e.indexArray,y=e.layoutVertexArray,v=e.globeExtVertexArray,x=e.segments.prepareSegment(4*_,y,A,this.canOverlap?o.sortKey:void 0),b=this.glyphOffsetArray.length,w=x.vertexLength,T=this.allowVerticalPlacement&&s===Ng.vertical?Math.PI/2:0,E=o.text&&o.text.sections;for(let r=0;r=0?t.rightJustifiedTextSymbolIndex:t.centerJustifiedTextSymbolIndex>=0?t.centerJustifiedTextSymbolIndex:t.leftJustifiedTextSymbolIndex>=0?t.leftJustifiedTextSymbolIndex:t.verticalPlacedTextSymbolIndex>=0?t.verticalPlacedTextSymbolIndex:r),o=a_(this.textSizeData,e,n)/mg;return this.tilePixelRatio*o}getSymbolInstanceIconSize(e,t,i){const r=this.icon.placedSymbolArray.get(i),n=a_(this.iconSizeData,e,r);return this.tilePixelRatio*n}_commitDebugCollisionVertexUpdate(e,t,i,r){e.emplaceBack(t,-i,-i,r),e.emplaceBack(t,i,-i,r),e.emplaceBack(t,i,i,r),e.emplaceBack(t,-i,i,r)}_updateTextDebugCollisionBoxes(e,t,i,r,n,o,s){for(let s=r;s0}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),r=i.vertexStartIndex+4*i.numGlyphs;for(let t=i.vertexStartIndex;tr[e]-r[t]||n[t]-n[e]),o}getSortedIndexesByZOffset(){if(!this.zOffsetSortDirty)return this.symbolInstanceIndexesSortedZOffset;if(!this.symbolInstanceIndexesSortedZOffset){this.symbolInstanceIndexesSortedZOffset=[];for(let e=0;ethis.symbolInstances.get(t).zOffset-this.symbolInstances.get(e).zOffset)}addToSortKeyRanges(e,t){const i=this.sortKeyRanges[this.sortKeyRanges.length-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&&!(this.text.segments.get().length>1||this.icon.segments.get().length>1)){this.symbolInstanceIndexes=this.getSortedSymbolIndexes(e),this.sortedAngle=e,this.text.indexArray.clear(),this.icon.indexArray.clear(),this.featureSortOrder=[];for(const e of this.symbolInstanceIndexes){const t=this.symbolInstances.get(e);this.featureSortOrder.push(t.featureIndex);const{rightJustifiedTextSymbolIndex:i,centerJustifiedTextSymbolIndex:r,leftJustifiedTextSymbolIndex:n,verticalPlacedTextSymbolIndex:o,placedIconSymbolIndex:s,verticalPlacedIconSymbolIndex:a}=t;i>=0&&this.addIndicesForPlacedSymbol(this.text,i),r>=0&&r!==i&&this.addIndicesForPlacedSymbol(this.text,r),n>=0&&n!==r&&n!==i&&this.addIndicesForPlacedSymbol(this.text,n),o>=0&&this.addIndicesForPlacedSymbol(this.text,o),s>=0&&this.addIndicesForPlacedSymbol(this.icon,s),a>=0&&this.addIndicesForPlacedSymbol(this.icon,a)}this.text.indexBuffer&&this.text.indexBuffer.updateData(this.text.indexArray),this.icon.indexBuffer&&this.icon.indexBuffer.updateData(this.icon.indexArray)}}getElevationFeatureForText(e){const t=this.symbolInstances.get(this.text.symbolInstanceIndices[e]).elevationFeatureIndex;let i;return this.elevationFeatures&&ti in e?String(e[i]):"")}let $A,ZA,WA;es(HA,"SymbolBucket",{omit:["layers","collisionBoxArray","compareText","features"]}),HA.addDynamicAttributes=NA;class qA{constructor(e){this.type=e.property.overrides?e.property.overrides.runtimeType:_i,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}}es(qA,"FormatSectionOverride",{omit:["defaultValue"]});const KA=()=>WA||(WA={layout:$A||($A=new Os({"symbol-placement":new Fs(zs.layout_symbol["symbol-placement"]),"symbol-spacing":new Fs(zs.layout_symbol["symbol-spacing"]),"symbol-avoid-edges":new Fs(zs.layout_symbol["symbol-avoid-edges"]),"symbol-sort-key":new ks(zs.layout_symbol["symbol-sort-key"]),"symbol-z-order":new Fs(zs.layout_symbol["symbol-z-order"]),"symbol-z-elevate":new Fs(zs.layout_symbol["symbol-z-elevate"]),"symbol-elevation-reference":new Fs(zs.layout_symbol["symbol-elevation-reference"]),"icon-allow-overlap":new Fs(zs.layout_symbol["icon-allow-overlap"]),"icon-ignore-placement":new Fs(zs.layout_symbol["icon-ignore-placement"]),"icon-optional":new Fs(zs.layout_symbol["icon-optional"]),"icon-rotation-alignment":new Fs(zs.layout_symbol["icon-rotation-alignment"]),"icon-size":new ks(zs.layout_symbol["icon-size"]),"icon-size-scale-range":new Fs(zs.layout_symbol["icon-size-scale-range"]),"icon-text-fit":new ks(zs.layout_symbol["icon-text-fit"]),"icon-text-fit-padding":new ks(zs.layout_symbol["icon-text-fit-padding"]),"icon-image":new ks(zs.layout_symbol["icon-image"]),"icon-image-use-theme":new Fs({type:"string",default:"default","property-type":"data-constant"}),"icon-rotate":new ks(zs.layout_symbol["icon-rotate"]),"icon-padding":new Fs(zs.layout_symbol["icon-padding"]),"icon-keep-upright":new Fs(zs.layout_symbol["icon-keep-upright"]),"icon-offset":new ks(zs.layout_symbol["icon-offset"]),"icon-anchor":new ks(zs.layout_symbol["icon-anchor"]),"icon-pitch-alignment":new Fs(zs.layout_symbol["icon-pitch-alignment"]),"text-pitch-alignment":new Fs(zs.layout_symbol["text-pitch-alignment"]),"text-rotation-alignment":new Fs(zs.layout_symbol["text-rotation-alignment"]),"text-field":new ks(zs.layout_symbol["text-field"]),"text-font":new ks(zs.layout_symbol["text-font"]),"text-size":new ks(zs.layout_symbol["text-size"]),"text-size-scale-range":new Fs(zs.layout_symbol["text-size-scale-range"]),"text-max-width":new ks(zs.layout_symbol["text-max-width"]),"text-line-height":new ks(zs.layout_symbol["text-line-height"]),"text-letter-spacing":new ks(zs.layout_symbol["text-letter-spacing"]),"text-justify":new ks(zs.layout_symbol["text-justify"]),"text-radial-offset":new ks(zs.layout_symbol["text-radial-offset"]),"text-variable-anchor":new Fs(zs.layout_symbol["text-variable-anchor"]),"text-anchor":new ks(zs.layout_symbol["text-anchor"]),"text-max-angle":new Fs(zs.layout_symbol["text-max-angle"]),"text-writing-mode":new Fs(zs.layout_symbol["text-writing-mode"]),"text-rotate":new ks(zs.layout_symbol["text-rotate"]),"text-padding":new Fs(zs.layout_symbol["text-padding"]),"text-keep-upright":new Fs(zs.layout_symbol["text-keep-upright"]),"text-transform":new ks(zs.layout_symbol["text-transform"]),"text-offset":new ks(zs.layout_symbol["text-offset"]),"text-allow-overlap":new Fs(zs.layout_symbol["text-allow-overlap"]),"text-ignore-placement":new Fs(zs.layout_symbol["text-ignore-placement"]),"text-optional":new Fs(zs.layout_symbol["text-optional"]),visibility:new Fs(zs.layout_symbol.visibility)})),paint:ZA||(ZA=new Os({"icon-opacity":new ks(zs.paint_symbol["icon-opacity"]),"icon-occlusion-opacity":new ks(zs.paint_symbol["icon-occlusion-opacity"]),"icon-emissive-strength":new ks(zs.paint_symbol["icon-emissive-strength"]),"text-emissive-strength":new ks(zs.paint_symbol["text-emissive-strength"]),"icon-color":new ks(zs.paint_symbol["icon-color"]),"icon-halo-color":new ks(zs.paint_symbol["icon-halo-color"]),"icon-halo-width":new ks(zs.paint_symbol["icon-halo-width"]),"icon-halo-blur":new ks(zs.paint_symbol["icon-halo-blur"]),"icon-translate":new Fs(zs.paint_symbol["icon-translate"]),"icon-translate-anchor":new Fs(zs.paint_symbol["icon-translate-anchor"]),"icon-image-cross-fade":new Fs(zs.paint_symbol["icon-image-cross-fade"]),"text-opacity":new ks(zs.paint_symbol["text-opacity"]),"text-occlusion-opacity":new ks(zs.paint_symbol["text-occlusion-opacity"]),"text-color":new ks(zs.paint_symbol["text-color"],{runtimeType:xi,getOverride:e=>e.textColor,hasOverride:e=>!!e.textColor}),"text-halo-color":new ks(zs.paint_symbol["text-halo-color"]),"text-halo-width":new ks(zs.paint_symbol["text-halo-width"]),"text-halo-blur":new ks(zs.paint_symbol["text-halo-blur"]),"text-translate":new Fs(zs.paint_symbol["text-translate"]),"text-translate-anchor":new Fs(zs.paint_symbol["text-translate-anchor"]),"icon-color-saturation":new Fs(zs.paint_symbol["icon-color-saturation"]),"icon-color-contrast":new Fs(zs.paint_symbol["icon-color-contrast"]),"icon-color-brightness-min":new Fs(zs.paint_symbol["icon-color-brightness-min"]),"icon-color-brightness-max":new Fs(zs.paint_symbol["icon-color-brightness-max"]),"symbol-z-offset":new ks(zs.paint_symbol["symbol-z-offset"]),"icon-color-use-theme":new ks({type:"string",default:"default","property-type":"data-driven"}),"icon-halo-color-use-theme":new ks({type:"string",default:"default","property-type":"data-driven"}),"text-color-use-theme":new ks({type:"string",default:"default","property-type":"data-driven"}),"text-halo-color-use-theme":new ks({type:"string",default:"default","property-type":"data-driven"})}))},WA);class XA extends aa{constructor(e,t,i,r){super(e,KA(),t,i,r,e.layout?e.layout["icon-image-use-theme"]:null),this._colorAdjustmentMatrix=c([]),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)}),"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.indexOf(t)<0&&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,r){return this._saturation===e&&this._contrast===t&&this._brightnessMin===i&&this._brightnessMax===r||(this._colorAdjustmentMatrix=function(e,t,i,r){e=nt(e),t=rt(t);const n=a(),o=e/3,s=1-2*o,l=[s,o,o,0,o,s,o,0,o,o,s,0,0,0,0,1],c=.5-.5*t,u=r-i;return h(n,[u,0,0,0,0,u,0,0,0,0,u,0,i,i,i,1],[t,0,0,0,0,t,0,0,0,0,t,0,c,c,c,1]),h(n,n,l),n}(e,t,i,r),this._saturation=e,this._contrast=t,this._brightnessMin=i,this._brightnessMax=r),this._colorAdjustmentMatrix}getValueAndResolveTokens(e,t,i,r){const n=this.layout.get(e).evaluate(t,{},i,r),o=this._unevaluatedLayout._values[e];return o.isDataDriven()||jo(o.value)||!n?n:QA(t.properties,n)}getAppearanceValueAndResolveTokens(e,t,i,r,n){const o=e.getProperty(t);if(!o)return;const s=o.evaluate(i,{},r,n),a=e.getUnevaluatedProperties()._values[t];return a.isDataDriven()||jo(a.value)||!s||"string"!=typeof s?s:QA(i.properties,s)}createBucket(e){return new HA(e)}queryRadius(){return 0}queryIntersectsFeature(){return!1}_setPaintOverrides(){for(const e of KA().paint.overridableProperties){if(!XA.hasPaintOverride(this.layout,e))continue;const t=this.paint.get(e),i=new qA(t),r=new Vo(i,t.property.specification,this.scope,this.options,this.layout.get("icon-image-use-theme"));let n=null;n="constant"===t.value.kind||"source"===t.value.kind?new Ho("source",r):new Qo("composite",r,t.value.zoomStops,t.value.interpolationType),this.paint._values[e]=new Rs(t.property,n,t.parameters)}}_handleOverridablePaintPropertyUpdate(e,t,i){return!(!this.layout||t.isDataDriven()||i.isDataDriven())&&XA.hasPaintOverride(this.layout,e)}static hasPaintOverride(e,t){const i=e.get("text-field"),r=KA().paint.properties[t];let n=!1;const o=e=>{for(const t of e)if(r.overrides&&r.overrides.hasOverride(t))return void(n=!0)};if("constant"===i.value.kind&&i.value.value instanceof Di)o(i.value.value.sections);else if("source"===i.value.kind){const e=t=>{n||(t instanceof Gi&&Vi(t.value)===Ei?o(t.value.sections):t instanceof Zi?o(t.sections):t.eachChild(e))},t=i.value;t._styleExpression&&e(t._styleExpression.expression)}return n}getProgramIds(){return["symbol"]}getDefaultProgramParams(e,t,i){return{config:new Ul(this,{zoom:t,lut:i}),overrideFog:!1}}hasElevation(){return this.layout&&"hd-road-markup"===this.layout.get("symbol-elevation-reference")}}let JA,YA,ey,ty;var iy=ha([{name:"a_pos",type:"Int16",components:2},{name:"a_texture_pos",type:"Int16",components:2}]);function ry(e,t,i,r,n,a,l,c){const u=[e,t,1,i,r,1,n,a,1],h=[l,c,1],d=o([],u),[p,f,m]=G(h,h,d);return s(u,u,[p,0,0,0,f,0,0,0,m])}function ny(e,t,i,r,n,a,l,c){const u=function(e,t,i,r,n,a,l,c){const u=ry(0,0,1,0,1,1,0,1),h=ry(e,t,i,r,n,a,l,c);return s(h,h,o([],u))}(e,t,i,r,n,a,l,c);return[u[2]/u[8]/Ur,u[5]/u[8]/Ur]}function oy(e){return[e[0],Math.min(Math.max(e[1],-mc),mc)]}class sy extends ri{constructor(e,t,i,r){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(r),this.options=t,this._dirty=!1}load(e,t){if(this._loaded=t||!1,this.fire(new Yt("dataloading",{dataType:"source"})),this.url=this.options.url,!this.url)return e&&(this.coordinates=e),this._loaded=!0,void this._finishLoading();this._imageRequest=Ht(this.map._requestManager.transformRequest(this.url,kt.Image),(t,i)=>{this._imageRequest=null,this._loaded=!0,t?this.fire(new ei(t)):i&&(this.image=i instanceof HTMLImageElement?gt.getImageData(i):i,this._dirty=!0,this.width=this.image.width,this.height=this.image.height,e&&(this.coordinates=e),this._finishLoading())})}loaded(){return this._loaded}updateImage(e){return e.url?(this._imageRequest&&e.url!==this.options.url&&(this._imageRequest.cancel(),this._imageRequest=null),this.options.url=e.url,this.load(e.coordinates,this._loaded),this):this}setTexture(e){if(!(e.handle instanceof WebGLTexture))throw new Error("The provided handle is not a WebGLTexture instance");return this.texture=new Pf(this.map.painter.context,e.handle),this.width=e.dimensions[0],this.height=e.dimensions[1],this._dirty=!1,this._loaded=!0,this._finishLoading(),this}_finishLoading(){this.map&&(this.setCoordinates(this.coordinates),this.fire(new Yt("data",{dataType:"source",sourceDataType:"metadata"})))}onAdd(e){this.map=e,this.load()}onRemove(e){this._imageRequest&&(this._imageRequest.cancel(),this._imageRequest=null),!this.texture||this.texture instanceof Pf||this.texture.destroy(),this.boundsBuffer&&(this.boundsBuffer.destroy(),this.elevatedGlobeVertexBuffer&&this.elevatedGlobeVertexBuffer.destroy(),this.elevatedGlobeIndexBuffer&&this.elevatedGlobeIndexBuffer.destroy())}setCoordinates(e){if(this.coordinates=e,this._boundsArray=void 0,this._unsupportedCoords=!1,!e.length)return this;this.onNorthPole=!1,this.onSouthPole=!1;let t=e[0][1],i=e[0][1];for(const r of e)r[1]>i&&(i=r[1]),r[1]mc?this.onNorthPole=!0:r<-mc&&(this.onSouthPole=!0),!this.onNorthPole&&!this.onSouthPole){const t=e.map(vc.fromLngLat);this.tileID=function(e){let t=1/0,i=1/0,r=-1/0,n=-1/0;for(const o of e)t=Math.min(t,o.x),i=Math.min(i,o.y),r=Math.max(r,o.x),n=Math.max(n,o.y);const o=Math.max(r-t,n-i),s=Math.max(0,Math.floor(-Math.log2(o))),a=Math.pow(2,s);let l=Math.floor((t+r)/2*a);return l>1&&(l-=1),new Bu(s,l,Math.floor((i+n)/2*a))}(t),this.minzoom=this.maxzoom=this.tileID.z}return this.fire(new Yt("data",{dataType:"source",sourceDataType:"content"})),this}_clear(){!this.texture||this.texture instanceof Pf||(this.texture.destroy(),this._dirty=!0),this.texture=null,this._boundsArray=void 0,this._unsupportedCoords=!1}_prepareData(e){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 t=hA(new Bu(0,0,0),this.map.transform.projection),i=[t.projection.project(this.coordinates[0][0],this.coordinates[0][1]),t.projection.project(this.coordinates[1][0],this.coordinates[1][1]),t.projection.project(this.coordinates[2][0],this.coordinates[2][1]),t.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,r=e[2].x-e[1].x,n=e[2].y-e[1].y,o=e[3].x-e[2].x,s=e[3].y-e[2].y,a=e[0].x-e[3].x,l=e[0].y-e[3].y,c=t*n-r*i,u=r*s-o*n,h=o*l-a*s,d=a*i-t*l;return c>0&&u>0&&h>0&&d>0||c<0&&u<0&&h<0&&d<0}(i))return console.warn("Image source coordinates are defining non-convex area in the Mercator projection"),void(this._unsupportedCoords=!0);const r=hA(this.tileID,this.map.transform.projection),[n,a,l,c]=this.coordinates.map(e=>{const t=r.projection.project(e[0],e[1]);return dA(r,t)._round()});this.perspectiveTransform=ny(n.x,n.y,a.x,a.y,l.x,l.y,c.x,c.y);const u=this._boundsArray=new ma;u.emplaceBack(n.x,n.y,0,0),u.emplaceBack(a.x,a.y,Ur,0),u.emplaceBack(c.x,c.y,0,Ur),u.emplaceBack(l.x,l.y,Ur,Ur),this.boundsBuffer&&(this.boundsBuffer.destroy(),this.elevatedGlobeVertexBuffer&&this.elevatedGlobeVertexBuffer.destroy(),this.elevatedGlobeIndexBuffer&&this.elevatedGlobeIndexBuffer.destroy()),this.boundsBuffer=e.createVertexBuffer(u,iy.members),this.boundsSegments=hl.simpleSegment(0,0,4,2);const h=[],d=[oy((p=this.coordinates)[0]),oy(p[1]),oy(p[2]),oy(p[3])];var p;const[f,m,g,_]=function(e){let t=e[0][0],i=t,r=e[0][1],n=r;for(let o=1;oi&&(i=e[o][0]),e[o][1]n&&(n=e[o][1]);return[t,r,i-t,n-r]}(d);{const r=new ma,[n,a,l,c]=function(e){let t=e[0].x,i=t,r=e[0].y,n=r;for(let o=1;oi&&(i=e[o].x),e[o].yn&&(n=e[o].y);return[t,r,i-t,n-r]}(i),u=e=>[(e.x-n)/l,(e.y-a)/c],[d,p,A,y]=i.map(u),v=function(e,t,i,r,n,a,l,c){const u=ry(0,0,1,0,1,1,0,1);return s(u,u,o([],ry(e,t,i,r,n,a,l,c)))}(d[0],d[1],p[0],p[1],A[0],A[1],y[0],y[1]);this.elevatedGlobePerspectiveTransform=ny(d[0],d[1],p[0],p[1],A[0],A[1],y[0],y[1]);const x=(e,t)=>{h.push(e.lng);const i=Math.round((e.lng-f)/g*Ur),n=Math.round((e.lat-m)/_*Ur),o=u(t),s=G([],[o[0],o[1],1],v),a=Math.round(s[0]/s[2]*Ur),l=Math.round(s[1]/s[2]*Ur);r.emplaceBack(i,n,a,l)},b=i[3].x-i[0].x,w=i[3].y-i[0].y,T=i[2].x-i[1].x,E=i[2].y-i[1].y;for(let e=0;e<65;e++){const r=e/64,n=[i[0].x+r*b,i[0].y+r*w],o=[i[1].x+r*T,i[1].y+r*E],s=o[0]-n[0],a=o[1]-n[1];for(let e=0;e<65;e++){const i=e/64,r={x:n[0]+s*i,y:n[1]+a*i};x(t.projection.unproject(r.x,r.y),r)}}this.elevatedGlobeVertexBuffer=e.createVertexBuffer(r,iy.members)}{this.maxLongitudeTriangleSize=0;let t=[],i=new Fa;const r=(e,r,n)=>{i.emplaceBack(e,r,n);const o=h[e],s=h[r],a=h[n],l=Math.min(Math.min(o,s),a),c=Math.max(Math.max(o,s),a)-l;c>this.maxLongitudeTriangleSize&&(this.maxLongitudeTriangleSize=c),t.push(l+c/2)};for(let e=0;e<64;e++)for(let t=0;t<64;t++){const i=65*e+t,n=i+1,o=i+65,s=o+1;r(i,o,n),r(n,o,s)}[t,i]=function(e,t){const i=Array.from({length:e.length},(e,t)=>t);i.sort((t,i)=>e[t]-e[i]);const r=[],n=new Fa;for(let o=0;o{o.segments.push({vertexOffset:0,primitiveOffset:e,vertexLength:t.segments[0].vertexLength,primitiveLength:i,sortKey:void 0,vaos:{}})},a=.51*this.maxLongitudeTriangleSize;if(Math.abs(i[0]-r)<=a){const e=it(i,0,i.length,r+a);return e===i.length||s(e,tt(i,e+1,i.length,r+360-a)-e),o}rUr?r-Ur:r,new Te(Math.trunc(r),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 by{constructor(e){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,r){}populate(e,t,i,r){this.tileToMeter=yc(i);const n=this.layers[0]._featureFilter.needGeometry;this.lookup=new Uint8Array(this.lookupDim*this.lookupDim);for(const{feature:o,id:s,index:a,sourceLayerIndex:l}of e){const e=null!=s?s:o.properties&&o.properties.hasOwnProperty("id")?o.properties.id:void 0,c=Ic(o,n);if(!this.layers[0]._featureFilter.filter(new Es(this.zoom,{worldview:this.worldview,activeFloors:t.activeFloors}),c,i))continue;const u={id:e,sourceLayerIndex:l,index:a,geometry:n?c.geometry:Sc(o,i,r),properties:o.properties,type:o.type,patterns:{}},h=this.addFeature(u,u.geometry,c);h&&t.featureIndex.insert(o,u.geometry,a,l,this.index,this.instancesPerModel[h].instancedDataArray.length,Ur/32)}this.lookup=null}evaluateQueryRenderedFeaturePadding(){const e=this.layers[0].modelManager,t=this.layers[0].scope;let i=0;for(const r of this.modelUris){const n=e.getModel(r,t);if(!n)continue;const o=this.instancesPerModel[r];if(o){const e=.5*F(n.aabb.max,n.aabb.min)*o.maxScale+o.maxXYTranslationDistance,t=Math.min(Ur,Math.max(e/this.tileToMeter,Ur/32));i=Math.max(t,i)}}return i}update(e,t,i,r){for(const t in this.instancesPerModel){const i=this.instancesPerModel[t];for(const t in e)i.idToFeaturesIndex.hasOwnProperty(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 r=this.layers[0],n=t.feature,o=this.canonical,s=r.paint.get("model-rotation").evaluate(n,{},o),a=r.paint.get("model-scale").evaluate(n,{},o),l=r.paint.get("model-translation").evaluate(n,{},o);$(t.rotation,s)&&$(t.scale,a)&&$(t.translation,l)||(this.evaluate(t,t.featureStates,i,!0),e=!0)}}return e}updateReplacement(e,t,i,r){if(t.updateTime===this.replacementUpdateTime)return!1;this.replacementUpdateTime=t.updateTime;const n=t.getReplacementRegionsForTile(e.toUnwrapped(),!0);if(jd(this.activeReplacements,n))return!1;this.activeReplacements=n;let o=!1;for(const t in this.instancesPerModel){const n=this.instancesPerModel[t],s=n.instancedDataArray;for(const t of n.features){const n=t.instancedDataOffset,a=t.instancedDataCount;for(let t=0;tUr;l=c?l-Ur:l;const u=Math.floor(l),h=Math.floor(s.float32[a+1]);let d=!1;for(const t of this.activeReplacements)if(!zd(t,i,_y.Model,r)&&!(t.min.x>u||u>t.max.x||t.min.y>h||h>t.max.y)&&(d=Wd(Zd(u,h,e.canonical,t.footprintTileId.canonical),t.footprint),d))break;s.float32[a]=d?l+Ur:l,o=o||d!==c}}}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,Of.members,!0,void 0,this.instanceCount))}this.uploaded=!0}destroy(){for(const e in this.instancesPerModel){const t=this.instancesPerModel[e];0!==t.instancedDataArray.length&&t.instancedDataBuffer&&t.instancedDataBuffer.destroy()}const e=this.layers[0].modelManager;if(e&&this.modelUris&&this.modelsRequested)for(const t of this.modelUris)e.removeModel(t,"",!0)}addFeature(e,t,i){const r=this.layers[0],n=r.layout.get("model-id").evaluate(i,{},this.canonical);if(!n)return Ze(`modelId is not evaluated for layer ${r.id} and it is not going to get rendered.`),n;(yy(n,!1)||void 0!==this.styleDefinedModelURLs[n])&&(this.modelUris.includes(n)||this.modelUris.push(n)),this.instancesPerModel[n]||(this.instancesPerModel[n]=new xy);const o=this.instancesPerModel[n],s=o.instancedDataArray,a=new vy(i,s.length);for(const e of t)for(const t of e){if(t.x<0||t.x>=Ur||t.y<0||t.y>=Ur)continue;if(0!==this.lookupDim){const e=(this.lookupDim-1)/Ur,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=s.length;s.resize(e+1),o.instancesEvaluatedElevation.push(0),s.float32[16*e]=t.x,s.float32[16*e+1]=t.y}return a.instancedDataCount=o.instancedDataArray.length-a.instancedDataOffset,a.instancedDataCount>0&&(e.id&&(o.idToFeaturesIndex[e.id]=o.features.length),o.features.push(a),this.evaluate(a,{},o,!1)),n}getModelUris(){return this.modelUris}evaluate(e,t,i,r){const n=this.layers[0],o=e.feature,s=this.canonical,a=e.rotation=n.paint.get("model-rotation").evaluate(o,t,s),l=e.scale=n.paint.get("model-scale").evaluate(o,t,s),c=e.translation=n.paint.get("model-translation").evaluate(o,t,s),u=Object.assign({},n.paint.get("model-color").evaluate(o,t,s));u.a=n.paint.get("model-color-mix-intensity").evaluate(o,t,s);const h=[];this.maxVerticalOffset0?Math.sqrt(d):0;i.maxScale=Math.max(Math.max(i.maxScale,l[0]),Math.max(l[1],l[2])),i.maxXYTranslationDistance=Math.max(i.maxXYTranslationDistance,p),this.maxScale=Math.max(Math.max(this.maxScale,l[0]),Math.max(l[1],l[2])),Qf(h,a,l);const f=Math.round(100*u.a)+u.b/1.05;for(let t=0;t10?this.tileToMeter:yc(s,d)),a[o+4]=c[0],a[o+5]=c[1],a[o+6]=c[2]+l,a[o+7]=h[0],a[o+8]=h[1],a[o+9]=h[2],a[o+10]=h[4],a[o+11]=h[5],a[o+12]=h[6],a[o+13]=h[8],a[o+14]=h[9],a[o+15]=h[10],i.instancesEvaluatedElevation[n]=c[2]}}}let wy,Ty;es(by,"ModelBucket",{omit:["layers"]}),es(xy,"PerModelAttributes"),es(vy,"ModelFeature");class Ey{constructor(e,t,i){this._demTile=e,this._dem=this._demTile.dem,this._scale=t,this._offset=i}static create(e,t,i){const r=i||e.findDEMTileFor(t);if(!r||!r.dem)return;const n=r.dem,o=r.tileID,s=1<e.fqid),this.stateDependentLayerIds=this.layers.filter(e=>e.isStateDependent()).map(e=>e.id),this.modelTraits|=Kf.CoordinateSpaceTile,this.uploaded=!1,this.hasPattern=!1,r&&(this.modelTraits|=Kf.HasMapboxMeshFeatures),n&&(this.modelTraits|=Kf.HasMeshoptCompression),this.zoom=-1,this.terrainExaggeration=1,this.projection={name:"mercator"},this.replacementUpdateTime=0,this.elevationReadFromZ=255,this.brightness=o,this.worldview=a,this.dirty=!0,this.needsUpload=!1,this.filter=null,this.nodesInfo=[];for(const e of t)this.nodesInfo.push(new Py(e)),Iy(e,s.featureIndexArray.length,s.grid),s.featureIndexArray.emplaceBack(this.nodesInfo.length-1,0,s.bucketLayerIDs.length-1,0);this.states={},this.hasAppearances=null}updateFootprints(e,t){for(const i of this.getNodesInfo()){const r=i.node;r.footprint&&t.push({footprint:r.footprint,id:e})}}updateAppearances(e,t,i,r){}update(e){const t=0!==Object.keys(e).length;if(t&&!this.stateDependentLayers.length)return;const i=t?this.stateDependentLayers:this.layers;if(!Ee(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):tm(t,e,!0)}for(const e of t)im(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);return t}needsReEvaluation(e,t,i){const r=e.transform.projectionOptions,n=e.style.getBrightness(),o=this.brightness!==n;if(!this.uploaded||this.dirty||r.name!==this.projection.name||Ly(i.paint.get("model-color").value,o)||Ly(i.paint.get("model-color-mix-intensity").value,o)||Ly(i.paint.get("model-roughness").value,o)||Ly(i.paint.get("model-emissive-strength").value,o)||Ly(i.paint.get("model-height-based-emissive-strength-multiplier").value,o)){this.projection=r,this.brightness=n;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(),r=this.id.canonical;for(const e of i){const i=e.feature;e.evaluatedTranslation=t.paint.get("model-translation").evaluate(i,{},r),e.evaluatedScale=t.paint.get("model-scale").evaluate(i,{},r)}}evaluate(e,t){const i=this.getNodesInfo();for(const r of i){if(!r.node.meshes)continue;const i=r.feature,n=t&&t[i.id];if(Ee(n,r.state))continue;r.state=structuredClone(n);const o=r.node.meshes&&r.node.meshes[0].featureData,s=r.evaluatedColor[2],a=r.evaluatedRMEA[2],l=this.id.canonical;if(r.hasTranslucentParts=!1,o){for(let t=0;t=e)continue;const h=Cy[c],d=Math.abs(h);d>a&&(s=h,a=d,l=n,u=t)}if(a>.1){const o=1-(e+.5*Math.abs(l*u))/c;let a=t._dem.get(r,i)+s*o;const h=t._dem.get(r+l,i+u),d=t._dem.get(r-l,i-u,!0);(a-h)*(a-d)>0&&(a=(h+d)/2),Cy[n]=t._dem.set(r,i,a),By[n]=e}}}}}s&&(t._demTile.needsDEMTextureUpload=!0,t._dem._timestamp=gt.now())}setFilter(e){this.filter=e?js(e):null}getNodesInfo(){return this.filter?this.nodesInfo.filter(e=>this.filter.filter(new Es(this.id.overscaledZ,{worldview:this.worldview}),e.feature,this.id.canonical)):this.nodesInfo}destroy(){const e=this.getNodesInfo();for(const t of e)im(t.node),rm(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.find(e=>e.footprint===t)}}getHeightAtTileCoord(e,t){const i=[],r=[0,0,0],n=c([]);for(const o of this.getNodesInfo()){const s=o.node.meshes[0],a=s.transformedAabb;if(ea.max[0]||t>a.max[1])continue;if(!0===o.node.hidden)return{height:1/0,maxHeight:o.feature.properties.height,hidden:!1,verticalScale:o.evaluatedScale[2]};u(n,o.node.globalMatrix),r[0]=e,r[1]=t,j(r,r,n);const l=(r[0]-s.aabb.min[0])/(s.aabb.max[0]-s.aabb.min[0])*qf|0,c=Math.min(63,(r[1]-s.aabb.min[1])/(s.aabb.max[1]-s.aabb.min[1])*qf|0)*qf+Math.min(63,l),h=s.heightmap[c];if(!(h<0&&o.node.footprint)){if(o.hiddenByReplacement)return;return{height:h,maxHeight:o.feature.properties.height,hidden:!1,verticalScale:o.evaluatedScale[2]}}if(o.node.footprint.grid.query(new Te(e,t),new Te(e,t),i),i.length>0)return{height:void 0,maxHeight:o.feature.properties.height,hidden:o.hiddenByReplacement,verticalScale:o.evaluatedScale[2]}}}}function Ly(e,t){return e instanceof Ho&&!e.isLightConstant&&t}function Fy(e,t,i,r,n,o,s,a){let l=(61440&t|(61440&t)>>4)>>8,c=(3840&t|(3840&t)>>4)>>4,u=240&t|(240&t)>>4;i[3]>0&&(l=di(l,255*i[0],i[3]),c=di(c,255*i[1],i[3]),u=di(u,255*i[2],i[3]));const h=l<<8|c,d=u<<8|Math.floor(255*r[3]),p=function(e){const t=Fe(e,0,2);return Math.min(Math.round(.5*t*255),255)}(r[2])<<8|15*r[0]<<4|15*r[1],f=Fe(n[0],0,1),m=Fe(n[1],0,1),g=Fe(n[2],0,1),_=Fe(n[3],0,1);let A,y,v,x;if(f!==m&&s!==o&&m!==f){const e=s-o;y=1/(e*(m-f)),v=-(o+e*f)/(e*(m-f));const t=Fe(n[4],-1,1);x=Math.pow(10,t),A=255*g<<8|255*_}else A=65535,y=0,v=1,x=1;if(e.emplaceBack(h,d,p,A,y,v,x),a){const e=a.length;a.clear();for(let t=0;t>16&65535,a=o?t>>16&65535:65535&t,l=(15&a)<8?15&a:0,c=e.evaluatedRMEA[l],u=e.evaluatedColor[l],h=e.emissionHeightBasedParams[l];let d;if(s&&2===l&&r.lights&&(d=new $a,d.resize(10*r.lights.length)),Fy(i.featureArray,n,u,c,h,i.aabb.min[2],i.aabb.max[2],d),d&&s){s=!1;const e=r.meshes[r.lightMeshIndex];e.featureArray=d,e.featureArray._trim()}}i.featureArray._trim(),n++}}es(Ry,"Tiled3dModelBucket",{omit:["layers"]}),es(Py,"Tiled3dModelFeature");const Dy=["id","tile","layer","source","sourceLayer","state"];class Oy{constructor(e,t,i,r,n){this.type="Feature",this._vectorTileFeature=e,this._z=t,this._x=i,this._y=r,this.properties=e?e.properties:{},this.id=n}clone(){const e=new Oy(this._vectorTileFeature,this._z,this._x,this._y,this.id);return this.state&&(e.state=Object.assign({},this.state)),this.layer&&(e.layer=Object.assign({},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 Dy)void 0!==this[t]&&(e[t]=this[t]);return e}}class zy extends ri{constructor(e,t,i,r){super(),this.id=e,this.type="model",this.models=[],this._loaded=!1,this._options=t,this._modelsInfo=new Map}load(){const e=[];for(const t in this._options.models){const i=this._options.models[t],r=this._modelsInfo.get(t);if(r){const e=r.model;e.position=null!=i.position?new nc(i.position[0],i.position[1]):new nc(0,0),e.orientation=null!=i.orientation?i.orientation:[0,0,0],r.modelSpec=i,zy.applyModelSpecification(e,i),e.computeBoundsAndApplyParent(),this.models.push(e)}else{const r=Bf(this.map._requestManager.transformRequest(i.uri,kt.Model).url).then(e=>{if(!e)return;const r=hm(e),n=new Jf(t,i.uri,i.position,i.orientation,r);zy.applyModelSpecification(n,i),n.computeBoundsAndApplyParent(),this.models.push(n),this._modelsInfo.set(t,{modelSpec:i,model:n})}).catch(e=>{this.fire(new ei(new Error(`Could not load model ${t} from ${i.uri}: ${e.message}`)))});e.push(r)}}Promise.allSettled(e).then(()=>{this._loaded=!0,this.fire(new Yt("data",{dataType:"source",sourceDataType:"metadata"}))}).catch(e=>{this._loaded=!0,this.fire(new ei(new Error(`Could not load models: ${e.message}`)))})}static applyModelSpecification(e,t){t.nodeOverrides&&zy.convertNodeOverrides(e,t.nodeOverrides),t.materialOverrides&&zy.convertMaterialOverrides(e,t.materialOverrides),t.nodeOverrideNames&&(e.nodeOverrideNames=[...t.nodeOverrideNames]),t.materialOverrideNames&&(e.materialOverrideNames=[...t.materialOverrideNames]),t.featureProperties&&(e.featureProperties=t.featureProperties)}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 r={orientation:[0,0,0]};if(i.hasOwnProperty("orientation")){const e=i.orientation;e&&(r.orientation=e)}e.nodeOverrides.set(t,r)})}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 r={color:new li(1,1,1),colorMix:0,emissionStrength:0,opacity:1},n=i["model-color"];void 0!==n&&(r.color.r=n[0],r.color.g=n[1],r.color.b=n[2]);const o=i["model-color-mix-intensity"];void 0!==o&&(r.colorMix=o);const s=i["model-emissive-strength"];void 0!==s&&(r.emissionStrength=s);const a=i["model-opacity"];void 0!==a&&(r.opacity=a),e.materialOverrides.set(t,r)})}onAdd(e){this.map=e,this.load()}hasTransition(){return!1}loaded(){return this._loaded}getModels(){return this.models}loadTile(e,t){}serialize(){return this._options}setProperty(e,t){return!1}reload(){const e=ta(this.id,this.scope);this.map.style.clearSource(e),this.models=[],this._modelsInfo.clear(),this._loaded=!1,this.load()}setModels(e){this.models=[];const t=new Map;for(const i in e){const r=e[i];if(this._modelsInfo.has(i)){const e=this._modelsInfo.get(i);e&&e.modelSpec.uri===r.uri&&t.set(i,e)}}this._modelsInfo=t,this._options.models=e,this._loaded=!1,this.load()}}function Uy(e,t,i,r){const n=1<e.polygon).flat());const g=p?a:null,[_,A]=Np(o,r,h,u,c,s,g,d,f,o.center.lat,e.tileID.canonical),y=e.queryGeometry;return Up(_,A,y.isPointQuery()?y.screenBounds:y.screenGeometry)}},building:class extends aa{constructor(e,t,i,r){super(e,{layout:Pm||(Pm=new Os({visibility:new Fs(zs.layout_building.visibility),"building-facade":new ks(zs.layout_building["building-facade"]),"building-facade-floors":new ks(zs.layout_building["building-facade-floors"]),"building-facade-unit-width":new ks(zs.layout_building["building-facade-unit-width"]),"building-facade-window":new ks(zs.layout_building["building-facade-window"]),"building-roof-shape":new ks(zs.layout_building["building-roof-shape"]),"building-height":new ks(zs.layout_building["building-height"]),"building-base":new ks(zs.layout_building["building-base"]),"building-flood-light-wall-radius":new ks(zs.layout_building["building-flood-light-wall-radius"]),"building-flood-light-ground-radius":new ks(zs.layout_building["building-flood-light-ground-radius"]),"building-flip-roof-orientation":new ks(zs.layout_building["building-flip-roof-orientation"])})),paint:Rm||(Rm=new Os({"building-opacity":new Fs(zs.paint_building["building-opacity"]),"building-ambient-occlusion-intensity":new Fs(zs.paint_building["building-ambient-occlusion-intensity"]),"building-ambient-occlusion-ground-intensity":new Fs(zs.paint_building["building-ambient-occlusion-ground-intensity"]),"building-ambient-occlusion-ground-radius":new Fs(zs.paint_building["building-ambient-occlusion-ground-radius"]),"building-ambient-occlusion-ground-attenuation":new Fs(zs.paint_building["building-ambient-occlusion-ground-attenuation"]),"building-vertical-scale":new Fs(zs.paint_building["building-vertical-scale"]),"building-cast-shadows":new Fs(zs.paint_building["building-cast-shadows"]),"building-color":new ks(zs.paint_building["building-color"]),"building-emissive-strength":new ks(zs.paint_building["building-emissive-strength"]),"building-facade-emissive-chance":new Fs(zs.paint_building["building-facade-emissive-chance"]),"building-cutoff-fade-range":new Fs(zs.paint_building["building-cutoff-fade-range"]),"building-flood-light-color":new Fs(zs.paint_building["building-flood-light-color"]),"building-flood-light-intensity":new Fs(zs.paint_building["building-flood-light-intensity"]),"building-flood-light-ground-attenuation":new Fs(zs.paint_building["building-flood-light-ground-attenuation"]),"building-color-use-theme":new ks({type:"string",default:"default","property-type":"data-driven"}),"building-flood-light-color-use-theme":new ks({type:"string",default:"default","property-type":"data-driven"})}))},t,i,r),this._stats={numRenderedVerticesInShadowPass:0,numRenderedVerticesInTransparentPass:0}}createBucket(e){return new Im(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,r,n,o,s,a,l){let c=this.layout.get("building-height").evaluate(t,i);const u=this.layout.get("building-base").evaluate(t,i),h=e.tile.getBucket(this).getFootprint(t);if(h){if(0!==h.hiddenFlags)return!1;c=h.height}const[d,p]=Np(o,r,u,c,new Te(0,0),s,null,[0,0],1,o.center.lat,e.tileID.canonical),f=e.queryGeometry;return Up(d,p,f.isPointQuery()?f.screenBounds:f.screenGeometry)}},line:class extends aa{constructor(e,t,i,r){const n=tg();super(e,n,t,i,r),n.layout&&(this.layout=new Ls(n.layout)),this.gradientVersion=0,this.hasElevatedBuckets=!1,this.hasNonElevatedBuckets=!1}_handleSpecialPaintPropertyUpdate(e){if("line-gradient"===e){const e=this._transitionablePaint._values["line-gradient"].value.expression;this.stepInterpolant=e._styleExpression&&e._styleExpression.expression instanceof Sn,this.gradientVersion=(this.gradientVersion+1)%Number.MAX_SAFE_INTEGER}}gradientExpression(){return this._transitionablePaint._values["line-gradient"].value.expression}widthExpression(){return this._transitionablePaint._values["line-width"].value.expression}recalculate(e,t){super.recalculate(e,t),this.paint._values["line-floorwidth"]=(()=>{if(rg)return rg;const e=tg();return rg=new ig(e.paint.properties["line-width"].specification),rg.useIntegerZoom=!0,rg})().possiblyEvaluate(this._transitioningPaint._values["line-width"].value,e)}createBucket(e){return new Hm(e)}getProgramIds(){return[this.paint.get("line-pattern").constantOr(1)?"linePattern":"line"]}getDefaultProgramParams(e,t,i){const r=Jm(this);return{config:new Ul(this,{zoom:t,lut:i}),defines:r,overrideFog:!1}}queryRadius(e){const t=e,i=ng(vu("line-width",this,t),vu("line-gap-width",this,t)),r=vu("line-offset",this,t);return i/2+Math.abs(r)+xu(this.paint.get("line-translate"))}queryIntersectsFeature(e,t,i,r,n,o){if(e.queryGeometry.isAboveHorizon)return!1;const s=bu(e.tilespaceGeometry,this.paint.get("line-translate"),this.paint.get("line-translate-anchor"),o.angle,e.pixelToTileUnitsFactor),a=e.pixelToTileUnitsFactor/2*ng(this.paint.get("line-width").evaluate(t,i),this.paint.get("line-gap-width").evaluate(t,i)),l=this.paint.get("line-offset").evaluate(t,i);return l&&(r=function(e,t){const i=[],r=new Te(0,0);for(let n=0;n=3)for(let t=0;t>16&255)/255,(e>>8&255)/255,(255&e)/255,1)}function hv(e,t,i){1===e?(t.rgb_color=uv(i.readVarint()),t.paint="rgb_color"):2===e?(t.linear_gradient_idx=i.readVarint(),t.paint="linear_gradient_idx"):3===e?(t.radial_gradient_idx=i.readVarint(),t.paint="radial_gradient_idx"):5===e?i.readPackedFloat(t.dasharray):6===e?t.dashoffset=i.readFloat():7===e?t.miterlimit=i.readFloat():8===e?t.opacity=i.readVarint():9===e?t.width=i.readFloat():10===e?t.linecap=i.readVarint():11===e&&(t.linejoin=i.readVarint())}function dv(e,t,i){1===e?t.transform=sv(i,i.readVarint()+i.pos):2===e?t.spread_method=i.readVarint():3===e?t.stops.push(pv(i,i.readVarint()+i.pos)):4===e?t.x1=i.readFloat():5===e?t.y1=i.readFloat():6===e?t.x2=i.readFloat():7===e&&(t.y2=i.readFloat())}function pv(e,t){return e.readFields(fv,{offset:0,opacity:255,rgb_color:jy},t)}function fv(e,t,i){1===e?t.offset=i.readFloat():2===e?t.opacity=i.readVarint():3===e&&(t.rgb_color=uv(i.readVarint()))}function mv(e,t,i){1===e?t.transform=sv(i,i.readVarint()+i.pos):2===e?t.spread_method=i.readVarint():3===e?t.stops.push(pv(i,i.readVarint()+i.pos)):4===e?t.cx=i.readFloat():5===e?t.cy=i.readFloat():6===e?t.r=i.readFloat():7===e?t.fx=i.readFloat():8===e?t.fy=i.readFloat():9===e&&(t.fr=i.readFloat())}function gv(e,t,i){1===e?t.transform=sv(i,i.readVarint()+i.pos):2===e?t.clip_path_idx=i.readVarint():3===e&&t.children.push(rv(i,i.readVarint()+i.pos))}function _v(e,t,i){1===e?t.left=t.top=i.readFloat():2===e?t.width=t.height=i.readFloat():3===e?t.top=i.readFloat():4===e?t.height=i.readFloat():5===e?t.mask_type=i.readVarint():6===e?t.mask_idx=i.readVarint():7===e&&t.children.push(rv(i,i.readVarint()+i.pos))}class Av{static calculate(e={},t=[]){const i=new Map,r=new Map;if(0===Object.keys(e).length)return i;t.forEach(e=>{r.set(e.name,e.rgb_color||new li(0,0,0))});for(const[t,n]of Object.entries(e))r.has(t)?i.set(r.get(t).toString(),n):console.warn(`Ignoring unknown image variable "${t}"`);return i}}function yv(e,t=255,i){const r=t/255,n=e.toString(),o=i.has(n)?i.get(n).clone():e.clone();return o.a*=r,o.toString()}function vv(e,t){if(!mt()){const i=document.createElement("canvas");return i.width=e,i.height=t,i}return new OffscreenCanvas(e,t)}function xv(e,t){const i=Av.calculate(t.params,e.metadata?e.metadata.variables:[]),r=e.usvg_tree,n=r.width,o=r.height,s=t.transform?t.transform:new DOMMatrix,a=Math.max(1,Math.round(n*s.a)),l=Math.max(1,Math.round(o*s.d)),c=new DOMMatrix([a/n,0,0,l/o,0,0]),u=vv(a,l).getContext("2d");return bv(u,c,r,r,i),u.getImageData(0,0,a,l)}function bv(e,t,i,r,n){for(const o of r.children)wv(e,t,i,o,n)}function wv(e,t,i,r,n){r.group?(e.save(),function(e,t,i,r,n){const o=null!=r.mask_idx?i.masks[r.mask_idx]:null,s=null!=r.clip_path_idx?i.clip_paths[r.clip_path_idx]:null;if(r.transform&&(t=Rv(r.transform).preMultiplySelf(t)),!function(e,t,i){return 255!==e.opacity||t||i}(r,null!=s,null!=o))return void bv(e,t,i,r,n);const a=vv(e.canvas.width,e.canvas.height),l=a.getContext("2d");bv(l,t,i,r,n),s&&Mv(l,t,i,s),o&&Pv(l,t,i,o,n),e.globalAlpha=r.opacity/255,e.drawImage(a,0,0)}(e,t,i,r.group,n),e.restore()):r.path&&(e.save(),function(e,t,i,r,n){e.setTransform(t),r.paint_order===$y.PAINT_ORDER_FILL_AND_STROKE?(Tv(e,i,r,n),Cv(e,i,r,n)):(Cv(e,i,r,n),Tv(e,i,r,n))}(e,t,i,r.path,n),e.restore())}function Tv(e,t,i,r){const n=i.fill;if(!n)return;const o=n.opacity/255;switch(e.save(),e.beginPath(),Lv(i,e),n.paint){case"rgb_color":e.fillStyle=yv(n.rgb_color,n.opacity,r);break;case"linear_gradient_idx":{const i=t.linear_gradients[n.linear_gradient_idx];i.transform&&e.setTransform(Rv(i.transform).preMultiplySelf(e.getTransform())),e.fillStyle=Bv(e,i,o,r);break}case"radial_gradient_idx":{const i=t.radial_gradients[n.radial_gradient_idx];i.transform&&e.setTransform(Rv(i.transform).preMultiplySelf(e.getTransform())),e.fillStyle=Sv(e,i,o,r)}}e.fill(Ev(i)),e.restore()}function Ev(e){return e.rule===Gy.PATH_RULE_NON_ZERO?"nonzero":e.rule===Gy.PATH_RULE_EVEN_ODD?"evenodd":void 0}function Cv(e,t,i,r){const n=i.stroke;if(!n)return;const o=Fv(i);e.lineWidth=n.width,e.miterLimit=n.miterlimit,e.setLineDash(n.dasharray),e.lineDashOffset=n.dashoffset;const s=n.opacity/255;switch(n.paint){case"rgb_color":e.strokeStyle=yv(n.rgb_color,n.opacity,r);break;case"linear_gradient_idx":e.strokeStyle=Bv(e,t.linear_gradients[n.linear_gradient_idx],s,r,!0);break;case"radial_gradient_idx":e.strokeStyle=Sv(e,t.radial_gradients[n.radial_gradient_idx],s,r,!0)}switch(n.linejoin){case Qy.LINE_JOIN_MITER_CLIP:case Qy.LINE_JOIN_MITER:e.lineJoin="miter";break;case Qy.LINE_JOIN_ROUND:e.lineJoin="round";break;case Qy.LINE_JOIN_BEVEL:e.lineJoin="bevel"}switch(n.linecap){case Hy.LINE_CAP_BUTT:e.lineCap="butt";break;case Hy.LINE_CAP_ROUND:e.lineCap="round";break;case Hy.LINE_CAP_SQUARE:e.lineCap="square"}e.stroke(o)}function Bv(e,t,i,r,n=!1){if(1===t.stops.length){const e=t.stops[0];return yv(e.rgb_color,e.opacity*i,r)}const{x1:o,y1:s,x2:a,y2:l}=t;let c=new DOMPoint(o,s),u=new DOMPoint(a,l);if(n){const e=Rv(t.transform);c=e.transformPoint(c),u=e.transformPoint(u)}const h=e.createLinearGradient(c.x,c.y,u.x,u.y);for(const e of t.stops)h.addColorStop(e.offset,yv(e.rgb_color,e.opacity*i,r));return h}function Sv(e,t,i,r,n=!1){if(1===t.stops.length){const e=t.stops[0];return yv(e.rgb_color,e.opacity*i,r)}const o=Rv(t.transform),{fx:s,fy:a,fr:l,cx:c,cy:u,r:h}=t;let d=new DOMPoint(s,a),p=new DOMPoint(c,u),f=l,m=h;if(n){d=o.transformPoint(d),p=o.transformPoint(p);const e=(o.a+o.d)/2;f=l*e,m=t.r*e}const g=e.createRadialGradient(d.x,d.y,f,p.x,p.y,m);for(const e of t.stops)g.addColorStop(e.offset,yv(e.rgb_color,e.opacity*i,r));return g}function Iv(e,t,i,r){const n=r.transform?Rv(r.transform).preMultiplySelf(t):t,o=vv(e.canvas.width,e.canvas.height),s=o.getContext("2d");for(const e of r.children)if(e.group)Iv(s,n,i,e.group);else if(e.path){const t=e.path,i=new Path2D;i.addPath(Fv(t),n),s.fill(i,Ev(t))}const a=null!=r.clip_path_idx?i.clip_paths[r.clip_path_idx]:null;a&&Mv(s,n,i,a),e.globalCompositeOperation="source-over",e.drawImage(o,0,0)}function Mv(e,t,i,r){const n=vv(e.canvas.width,e.canvas.height);Iv(n.getContext("2d"),t,i,r),e.globalCompositeOperation="destination-in",e.drawImage(n,0,0)}function Pv(e,t,i,r,n){if(0===r.children.length)return;const o=null!=r.mask_idx?i.masks[r.mask_idx]:null;o&&Pv(e,t,i,o,n);const s=e.canvas.width,a=e.canvas.height,l=vv(s,a),c=l.getContext("2d"),u=r.width,h=r.height,d=r.left,p=r.top,f=new Path2D,m=new Path2D;m.rect(d,p,u,h),f.addPath(m,t),c.clip(f);for(const e of r.children)wv(c,t,i,e,n);const g=c.getImageData(0,0,s,a),_=g.data;if(r.mask_type===Wy.MASK_TYPE_LUMINANCE)for(let e=0;e<_.length;e+=4)_[e+3]=_[e+3]/255*(.2126*_[e]+.7152*_[e+1]+.0722*_[e+2]);c.putImageData(g,0,0),e.globalCompositeOperation="destination-in",e.drawImage(l,0,0)}function Rv(e){return e?new DOMMatrix([e.sx,e.ky,e.kx,e.sy,e.tx,e.ty]):new DOMMatrix}function Lv(e,t){const i=e.step;let r=e.diffs[0]*i,n=e.diffs[1]*i;t.moveTo(r,n);for(let o=0,s=2;ot[s])return null}else{const a=1/r[s];let l=(e[s]-i[s])*a,c=(t[s]-i[s])*a;if(l>c){const e=l;l=c,c=e}if(l>n&&(n=l),co)return null}return n}function Uv(e,t,i,r,n,o,s,a,l,c,u){const h=r-e,d=n-t,p=o-i,f=s-e,m=a-t,g=l-i,_=u[1]*g-u[2]*m,A=u[2]*f-u[0]*g,y=u[0]*m-u[1]*f,v=h*_+d*A+p*y;if(Math.abs(v)<1e-15)return null;const x=1/v,b=c[0]-e,w=c[1]-t,T=c[2]-i,E=(b*_+w*A+T*y)*x;if(E<0||E>1)return null;const C=w*p-T*d,B=T*h-b*p,S=b*d-w*h,I=(u[0]*C+u[1]*B+u[2]*S)*x;return I<0||E+I>1?null:(f*C+m*B+g*S)*x}function Nv(e,t,i){return(e-t)/(i-t)}function Vv(e,t,i,r,n,o,s,a,l){const c=1<{const o=r?1:0,s=(e+1)*i-o,a=t*i,l=(t+1)*i-o;n[0]=e*i,n[1]=a,n[2]=s,n[3]=l};let s=new Ov(r);const a=[];for(let t=0;t=1;r/=2){const e=i[i.length-1];s=new Ov(r);for(let t=0;t0;){const{idx:a,t:p,nodex:f,nodey:m,depth:g}=d.pop();if(this.leaves[a]){Vv(f,m,g,e,t,i,r,u,h);const a=1<=e[2])return p}continue}let _=0;for(let d=0;d=l[c[i]]&&(c.splice(i,0,d),t=!0);t||(c[_]=d),_++}}for(let e=0;e<_;e++){const t=c[e];d.push({idx:this.childOffsets[a]+t,t:l[t],nodex:(f<<1)+this._siblingOffset[t][0],nodey:(m<<1)+this._siblingOffset[t][1],depth:g+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,r,n){if(1===e[r].isLeaf(t,i))return;this.childOffsets[n]||(this.childOffsets[n]=this.nodeCount);const o=r-1,s=e[o];let a=0,l=0;for(let e=0;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],r=Wv.getUnpackVector(t);let n=Math.floor((e+r[3])/r[2]);return i[2]=n%256,n=Math.floor(n/256),i[1]=n%256,n=Math.floor(n/256),i[0]=n,i}getPixels(){return new Th({width:this.stride,height:this.stride},this.pixels)}backfillBorder(e,t,i){if(this.dim!==e.dim)throw new Error("dem dimension mismatch");let r=t*this.dim,n=t*this.dim+this.dim,o=i*this.dim,s=i*this.dim+this.dim;switch(t){case-1:r=n-1;break;case 1:n=r+1}switch(i){case-1:o=s-1;break;case 1:s=o+1}const a=-t*this.dim,l=-i*this.dim;for(let t=o;t=1;r--){const n=1===r?1:0,o=2===r?1:0;for(let r=0;r>>1^-(1&e[t]);return e}function ox(e,t){switch(t){case"uint32":return e;case"uint16":for(let t=0;t>4|(61440&i)>>8|(240&r)<<4|61440&r,e[t+1]=15&i|(3840&i)>>4|(15&r)<<8|(3840&r)<<4}return e;case"uint8":for(let t=0;t>6|(192&r)>>4|(192&n)>>2|192&o,e[t+1]=(48&i)>>4|(48&r)>>2|48&n|(48&o)<<2,e[t+2]=(12&i)>>2|12&r|(12&n)<<2|(12&o)<<4,e[t+3]=3&i|(3&r)<<2|(3&n)<<4|(3&o)<<6}return e;default:throw new Error(`Invalid pixel format, "${t}"`)}}es(Wv,"DEMData"),es(jv,"DemMinMaxQuadTree",{omit:["dem"]});var sx=Uint8Array,ax=Uint16Array,lx=Int32Array,cx=new sx([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]),ux=new sx([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]),hx=new sx([16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15]),dx=function(e,t){for(var i=new ax(31),r=0;r<31;++r)i[r]=t+=1<>1|(21845&Ax)<<1;_x[Ax]=((65280&(yx=(61680&(yx=(52428&yx)>>2|(13107&yx)<<2))>>4|(3855&yx)<<4))>>8|(255&yx)<<8)>>1}var vx=function(e,t,i){for(var r=e.length,n=0,o=new ax(t);n>l]=c;return s},xx=new sx(288);for(Ax=0;Ax<144;++Ax)xx[Ax]=8;for(Ax=144;Ax<256;++Ax)xx[Ax]=9;for(Ax=256;Ax<280;++Ax)xx[Ax]=7;for(Ax=280;Ax<288;++Ax)xx[Ax]=8;var bx=new sx(32);for(Ax=0;Ax<32;++Ax)bx[Ax]=5;var wx=vx(xx,9),Tx=vx(bx,5),Ex=function(e){for(var t=e[0],i=1;it&&(t=e[i]);return t},Cx=function(e,t,i){var r=t/8|0;return(e[r]|e[r+1]<<8)>>(7&t)&i},Bx=function(e,t){var i=t/8|0;return(e[i]|e[i+1]<<8|e[i+2]<<16)>>(7&t)},Sx=["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"],Ix=function(e,t,i){var r=new Error(t||Sx[e]);if(r.code=e,Error.captureStackTrace&&Error.captureStackTrace(r,Ix),!i)throw r;return r},Mx=new sx(0),Px="undefined"!=typeof TextDecoder&&new TextDecoder;try{Px.decode(Mx,{stream:!0})}catch(e){}const Rx={gzip_data:"gzip"};class Lx extends Error{constructor(e){super(e),this.name="MRTError"}}const Fx={0:"uint32",1:"uint32",2:"uint16",3:"uint8"},kx={uint32:1,uint16:2,uint8:4},Dx={uint32:Uint32Array,uint16:Uint16Array,uint8:Uint8Array};let Ox;class zx{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 Lx(`Layer '${e}' not found`);return t}getHeaderLength(e){const t=new Uint8Array(e),i=new DataView(e);if(13!==t[0])throw new Lx("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} but got buffer of length ${t.length}`);const r=new Ox(t.subarray(0,i)).readFields(qv,{headerLength:0,x:0,y:0,z:0,layers:[]},void 0);if(!isNaN(this.x)&&(this.x!==r.x||this.y!==r.y||this.z!==r.z))throw new Lx(`Invalid attempt to parse header ${r.z}/${r.x}/${r.y} for tile ${this.z}/${this.x}/${this.y}`);this.x=r.x,this.y=r.y,this.z=r.z;for(const e of r.layers)this.layers[e.name]=new Ux(e,{cacheSize:this._cacheSize});return this}createDecodingTask(e){const t=[],i=this.getLayer(e.layerName);for(let r of e.blockIndices){const n=i.dataIndex[r],o=n.firstByte-e.firstByte,s=n.lastByte-e.firstByte;if(i._blocksInProgress.has(r))continue;const a={layerName:i.name,firstByte:o,lastByte:s,pixelFormat:i.pixelFormat,blockIndex:r,blockShape:[n.bands.length].concat(i.bandShape),buffer:i.buffer,codec:n.codec.codec,filters:n.filters.map(e=>e.filter)};i._blocksInProgress.add(r),t.push(a)}return new Nx(t,()=>{t.forEach(e=>i._blocksInProgress.delete(e.blockIndex))},(e,r)=>{if(t.forEach(e=>i._blocksInProgress.delete(e.blockIndex)),e)throw e;r.forEach(e=>{this.getLayer(e.layerName).processDecodedData(e)})})}}class Ux{constructor({version:e,name:t,units:i,tileSize:r,pixelFormat:n,buffer:o,dataIndex:s},a){if(this.version=e,1!==this.version)throw new Lx(`Cannot parse raster layer encoded with MRT version ${e}`);this.name=t,this.units=i,this.tileSize=r,this.buffer=o,this.pixelFormat=Fx[n],this.dataIndex=s,this.bandShape=[r+2*o,r+2*o,kx[this.pixelFormat]],this._decodedBlocks=new kv(a?a.cacheSize:5),this._blocksInProgress=new Set}get dimension(){return kx[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,r]of this.dataIndex.entries()){for(const[n,o]of r.bands.entries())if(o===e)return{bandIndex:t+n,blockIndex:i,blockBandIndex:n};t+=r.bands.length}break;case"number":for(const[i,r]of this.dataIndex.entries()){if(e>=t&&ethis.cacheSize)throw new Lx(`Number of blocks to decode (${n.size}) exceeds cache size (${this.cacheSize}).`);return{layerName:this.name,firstByte:t,lastByte:i,blockIndices:r}}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 Lx(`Band not found: ${JSON.stringify(e)}`);const r=this._decodedBlocks.get(t.toString());if(!r)throw new Lx(`Data for band ${JSON.stringify(e)} of layer "${this.name}" not decoded.`);const n=this.dataIndex[t],o=this.bandShape.reduce((e,t)=>e*t,1),s=i*o,a=r.subarray(s,s+o);return{data:a,bytes:new Uint8Array(a.buffer).subarray(a.byteOffset,a.byteOffset+a.byteLength),tileSize:this.tileSize,buffer:this.buffer,pixelFormat:this.pixelFormat,dimension:this.dimension,offset:n.offset,scale:n.scale}}}zx.setPbf=function(e){Ox=e};class Nx{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)}}zx.performDecoding=function(e,t){const i=new Uint8Array(e);return Promise.all(t.tasks.map(e=>{const{layerName:t,firstByte:r,lastByte:n,pixelFormat:o,blockShape:s,blockIndex:a,filters:l,codec:c}=e,u=i.subarray(r,n+1),h=new Uint32Array(s[0]*s[1]*s[2]);let d;if("gzip_data"!==c)throw new Lx(`Unhandled codec: ${c}`);return d=function(e,t){if(!globalThis.DecompressionStream&&"gzip_data"===t)return Promise.resolve(((o=function(e){31==e[0]&&139==e[1]&&8==e[2]||Ix(6,"invalid gzip data");var t=e[3],i=10;4&t&&(i+=2+(e[10]|e[11]<<8));for(var r=(t>>3&1)+(t>>4&1);r>0;r-=!e[i++]);return i+(2&t)}(n=e))+8>n.length&&Ix(6,"invalid gzip data"),function(e,t,i){var r=e.length;if(!r||t.f&&!t.l)return i||new sx(0);var n=!i,o=n||2!=t.i,s=t.i;n&&(i=new sx(3*r));var a,l,c=function(e){var t=i.length;if(e>t){var r=new sx(Math.max(2*t,e));r.set(i),i=r}},u=t.f||0,h=t.p||0,d=t.b||0,p=t.l,f=t.d,m=t.m,g=t.n,_=8*r;do{if(!p){u=Cx(e,h,1);var A=Cx(e,h+1,3);if(h+=3,!A){var y=e[(M=4+((h+7)/8|0))-4]|e[M-3]<<8,v=M+y;if(v>r){s&&Ix(0);break}o&&c(d+y),i.set(e.subarray(M,v),d),t.b=d+=y,t.p=h=8*v,t.f=u;continue}if(1==A)p=wx,f=Tx,m=9,g=5;else if(2==A){var x=Cx(e,h,31)+257,b=Cx(e,h+10,15)+4,w=x+Cx(e,h+5,31)+1;h+=14;for(var T=new sx(w),E=new sx(19),C=0;C>4)<16)T[C++]=M;else{var R=0,L=0;for(16==M?(L=3+Cx(e,h,3),h+=2,R=T[C-1]):17==M?(L=3+Cx(e,h,7),h+=3):18==M&&(L=11+Cx(e,h,127),h+=7);L--;)T[C++]=R}}var F=T.subarray(0,x),k=T.subarray(x);m=Ex(F),g=Ex(k),p=vx(F,m),f=vx(k,g)}else Ix(1);if(h>_){s&&Ix(0);break}}o&&c(d+131072);for(var D=(1<>4;if((h+=15&R)>_){s&&Ix(0);break}if(R||Ix(2),U<256)i[d++]=U;else{if(256==U){z=h,p=null;break}var N=U-254;U>264&&(N=Cx(e,h,(1<<(G=cx[C=U-257]))-1)+fx[C],h+=G);var V=f[Bx(e,h)&O],j=V>>4;if(V||Ix(3),h+=15&V,k=gx[j],j>3){var G=ux[j];k+=Bx(e,h)&(1<_){s&&Ix(0);break}o&&c(d+131072);var H=d+N;if(da.length)&&(l=a.length),new sx(a.subarray(0,l))):i.subarray(0,d)}(n.subarray(o,-8),{i:2},new sx(((i=n)[(r=i.length)-4]|i[r-3]<<8|i[r-2]<<16|i[r-1]<<24)>>>0))));var i,r,n,o;const s=Rx[t];if(!s)throw new Error(`Unhandled codec: ${t}`);const a=new globalThis.DecompressionStream(s);return new Response(new Blob([e]).stream().pipeThrough(a)).arrayBuffer().then(e=>new Uint8Array(e))}(u,c).then(e=>(function(e,t){e.readFields(tx,t)}(new Ox(e),h),new Dx[o](h.buffer))),d.then(e=>{for(let t=l.length-1;t>=0;t--)switch(l[t]){case"delta_filter":rx(e,s);break;case"zigzag_filter":nx(e);break;case"bitshuffle_filter":ox(e,o);break;default:throw new Lx(`Unhandled filter "${l[t]}"`)}return{layerName:t,blockIndex:a,data:e}}).catch(e=>{throw e})}))},es(Nx,"MRTDecodingBatch",{omit:["_onCancel","_onComplete"]}),es(zx,"MapboxRasterTile"),es(Ux,"MapboxRasterLayer",{omit:["_blocksInProgress"]});class Vx{constructor(e){this._stringToNumber={},this._numberToString=[];for(let t=0;t=0&&r[3]>=0&&l.insert(a,r[0],r[1],r[2],r[3])}}loadVTLayers(){if(!this.vtLayers){this.vtLayers=new kc(new wg(this.rawTileData)).layers,this.sourceLayerCoder=new Vx(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:r,tileTransform:n,pixelPosMatrix:o,availableImages:s,worldview:a}=t;this.loadVTLayers(),this.serializedLayersCache.clear();const l=t.queryRadius?t.queryRadius:0,c=i.bufferedTilespaceBounds,u=this.grid.query(c.min.x,c.min.y,c.max.x,c.max.y,(e,t,r,n)=>gu(i.bufferedTilespaceGeometry,e-l,t-l,r+l,n+l));u.sort(Hx);let h=null;r.elevation&&u.length>0&&(h=Ey.create(r.elevation,this.tileID));const d={};let p;for(let t=0;t(f||(f=Sc(e,this.tileID.canonical,n)),t.queryIntersectsFeature(i,e,s,f,this.z,r,o,h,a)))}return d}loadMatchingFeature(e,t,i,r,n,o){const{featureIndex:s,bucketIndex:a,sourceLayerIndex:l,layoutVertexArrayOffset:c}=t,u=this.bucketLayerIDs[a],h=i.layers,d=Object.keys(h);if(d.length&&!Qe(d,u))return;const p=i.sourceCache,f=this.sourceLayerCoder.decode(l),m=this.vtLayers[f].feature(s),g=this.getId(m,f);for(let t=0;t`${e.key}: ${e.message}`).join(", ")}`);this.promoteIdExpression=e.value}i=this.promoteIdExpression.evaluate({zoom:0},e)}else i=e.properties[r];"boolean"==typeof i&&(i=Number(i))}return i}}function Gx(e,t,i,r,n){return je(e,(e,o)=>{const s=t instanceof Ls?t.get(o):null;return s&&s.evaluate?s.evaluate(i,r,void 0,n):s})}function Hx(e,t){return t-e}es(jx,"FeatureIndex",{omit:["rawTileData","sourceLayerCoder"]});const Qx=[Int8Array,Uint8Array,Uint8ClampedArray,Int16Array,Uint16Array,Int32Array,Uint32Array,Float32Array,Float64Array];class $x{static from(e){if(!(e instanceof ArrayBuffer))throw new Error("Data must be an instance of ArrayBuffer.");const[t,i]=new Uint8Array(e,0,2);if(219!==t)throw new Error("Data does not appear to be in a KDBush format.");const r=i>>4;if(1!==r)throw new Error(`Got v${r} data when expected v1.`);const n=Qx[15&i];if(!n)throw new Error("Unrecognized array type.");const[o]=new Uint16Array(e,2,1),[s]=new Uint32Array(e,4,1);return new $x(s,o,n,e)}constructor(e,t=64,i=Float64Array,r){if(isNaN(e)||e<0)throw new Error(`Unpexpected numItems value: ${e}.`);this.numItems=+e,this.nodeSize=Math.min(Math.max(+t,2),65535),this.ArrayType=i,this.IndexArrayType=e<65536?Uint16Array:Uint32Array;const n=Qx.indexOf(this.ArrayType),o=2*e*this.ArrayType.BYTES_PER_ELEMENT,s=e*this.IndexArrayType.BYTES_PER_ELEMENT,a=(8-s%8)%8;if(n<0)throw new Error(`Unexpected typed array class: ${i}.`);r&&r instanceof ArrayBuffer?(this.data=r,this.ids=new this.IndexArrayType(this.data,8,e),this.coords=new this.ArrayType(this.data,8+s+a,2*e),this._pos=2*e,this._finished=!0):(this.data=new ArrayBuffer(8+o+s+a),this.ids=new this.IndexArrayType(this.data,8,e),this.coords=new this.ArrayType(this.data,8+s+a,2*e),this._pos=0,this._finished=!1,new Uint8Array(this.data,0,2).set([219,16+n]),new Uint16Array(this.data,2,1)[0]=t,new Uint32Array(this.data,4,1)[0]=e)}add(e,t){const i=this._pos>>1;return this.ids[i]=i,this.coords[this._pos++]=e,this.coords[this._pos++]=t,i}finish(){const e=this._pos>>1;if(e!==this.numItems)throw new Error(`Added ${e} items when expected ${this.numItems}.`);return Zx(this.ids,this.coords,this.nodeSize,0,this.numItems-1,0),this._finished=!0,this}range(e,t,i,r){if(!this._finished)throw new Error("Data not yet indexed - call index.finish().");const{ids:n,coords:o,nodeSize:s}=this,a=[0,n.length-1,0],l=[];for(;a.length;){const c=a.pop()||0,u=a.pop()||0,h=a.pop()||0;if(u-h<=s){for(let s=h;s<=u;s++){const a=o[2*s],c=o[2*s+1];a>=e&&a<=i&&c>=t&&c<=r&&l.push(n[s])}continue}const d=h+u>>1,p=o[2*d],f=o[2*d+1];p>=e&&p<=i&&f>=t&&f<=r&&l.push(n[d]),(0===c?e<=p:t<=f)&&(a.push(h),a.push(d-1),a.push(1-c)),(0===c?i>=p:r>=f)&&(a.push(d+1),a.push(u),a.push(1-c))}return l}within(e,t,i){if(!this._finished)throw new Error("Data not yet indexed - call index.finish().");const{ids:r,coords:n,nodeSize:o}=this,s=[0,r.length-1,0],a=[],l=i*i;for(;s.length;){const c=s.pop()||0,u=s.pop()||0,h=s.pop()||0;if(u-h<=o){for(let i=h;i<=u;i++)Xx(n[2*i],n[2*i+1],e,t)<=l&&a.push(r[i]);continue}const d=h+u>>1,p=n[2*d],f=n[2*d+1];Xx(p,f,e,t)<=l&&a.push(r[d]),(0===c?e-i<=p:t-i<=f)&&(s.push(h),s.push(d-1),s.push(1-c)),(0===c?e+i>=p:t+i>=f)&&(s.push(d+1),s.push(u),s.push(1-c))}return a}}function Zx(e,t,i,r,n,o){if(n-r<=i)return;const s=r+n>>1;Wx(e,t,s,r,n,o),Zx(e,t,i,r,s-1,1-o),Zx(e,t,i,s+1,n,1-o)}function Wx(e,t,i,r,n,o){for(;n>r;){if(n-r>600){const s=n-r+1,a=i-r+1,l=Math.log(s),c=.5*Math.exp(2*l/3),u=.5*Math.sqrt(l*c*(s-c)/s)*(a-s/2<0?-1:1);Wx(e,t,i,Math.max(r,Math.floor(i-a*c/s+u)),Math.min(n,Math.floor(i+(s-a)*c/s+u)),o)}const s=t[2*i+o];let a=r,l=n;for(qx(e,t,r,i),t[2*n+o]>s&&qx(e,t,r,n);as;)l--}t[2*r+o]===s?qx(e,t,r,l):(l++,qx(e,t,l,n)),l<=i&&(r=l+1),i<=l&&(n=l-1)}}function qx(e,t,i,r){Kx(e,i,r),Kx(t,2*i,2*r),Kx(t,2*i+1,2*r+1)}function Kx(e,t,i){const r=e[t];e[t]=e[i],e[i]=r}function Xx(e,t,i,r){const n=e-i,o=t-r;return n*n+o*o}e.$=Yi,e.A=Oi,e.B=ta,e.C=2,e.D=Wp,e.E=ri,e.F=y_,e.G=__,e.H=Ki,e.I=ni,e.J=Us,e.K=qi,e.L=Ji,e.M=Ro,e.N=Io,e.O=Po,e.P=Te,e.Q=jo,e.R=kt,e.S=Ns,e.T=Mf,e.U=Go,e.V=Ay,e.W=$o,e.X=yn,e.Y=_n,e.Z=An,e._=nr,e.a=function(e){return st.API_CDN_URL_REGEX.test(e)},e.a$=ma,e.a0=Xi,e.a1=ai,e.a2=Vs,e.a3=class extends Ay{},e.a4=Lo,e.a5=Mo,e.a6=zs,e.a7=function(e){const t=e.value;return t?Xi(t)?yy(t,!0)?[]:[new Ay(e.key,t,`invalid url "${t}"`)]:[new Ay(e.key,t,`string expected, "${qi(t)}" found`)]:[]},e.a8=Ss,e.a9=Os,e.aA=Fe,e.aB=h,e.aC=Y,e.aD=$l,e.aE=mu,e.aF=cc,e.aG=bc,e.aH=function(e,t){const i={};for(let r=0;r{r(e,i)},t):r(e,i),()=>{}}return n.callbacks.push(r),n.cancel||(n.cancel=i((i,r)=>{n.result=[i,r];for(const e of n.callbacks)this.scheduler?this.scheduler.add(()=>{e(i,r)},t):e(i,r);setTimeout(()=>delete this.entries[e],3e3)})),()=>{n.result||(n.callbacks=n.callbacks.filter(e=>e!==r),n.callbacks.length||(n.cancel(),delete this.entries[e]))}}},e.aL=function(e,t,i){const r=JSON.stringify(e.request);return e.data&&(this.deduped.entries[r]={result:[null,e.data]}),this.deduped.request(r,{type:"parseTile",isSymbolTile:e.isSymbolTile,zoom:e.tileZoom},t=>{const r=Ut(e.request,(e,r,n)=>{e?t(e):r&&t(null,{vectorTile:i?void 0:new kc(new wg(r)),rawData:r,responseHeaders:new Map(n.entries())})});return()=>{r.cancel(),t()}},t)},e.aM=function(e){return e?{cacheControl:e.get("Cache-Control"),expires:e.get("Expires")}:{cacheControl:void 0,expires:void 0}},e.aN=function(e){Bt++,Bt>xt&&(e.getActor().send("enforceCacheSizeLimit",vt),Bt=0)},e.aO=function(e){return e<=1?1:Math.pow(2,Math.floor(Math.log2(e)))},e.aP=Iu,e.aQ=ly,e.aR=fy,e.aS=nc,e.aT=sy,e.aU=function(e,t){const i=document.createElement("video");i.muted=!0,i.onloadstart=function(){t(null,i)};for(let t=0;t{}}},e.aV=Pf,e.aW=zy,e.aX=Ve,e.aY=hA,e.aZ=dc,e.a_=pc,e.aa=Fs,e.ab=class{constructor(e){this.specification=e}possiblyEvaluate(e,t){return Ke(e.expression.evaluate(t))}interpolate(e,t,i){return{x:di(e.x,t.x,i),y:di(e.y,t.y,i),z:di(e.z,t.z,i),azimuthal:di(e.azimuthal,t.azimuthal,i),polar:di(e.polar,t.polar,i)}}},e.ac=Es,e.ad=Qo,e.ae=vc,e.af=j,e.ag=T,e.ah=ke,e.ai=Ls,e.aj=th,e.ak=di,e.al=Ur,e.am=pi,e.an=Se,e.ao=li,e.ap=class{constructor(e){this.specification=e}possiblyEvaluate(e,t){return function([e,t]){const i=Ke([1,e,t]);return{x:i.x,y:i.y,z:i.z}}(e.expression.evaluate(t))}interpolate(e,t,i){return{x:di(e.x,t.x,i),y:di(e.y,t.y,i),z:di(e.z,t.z,i)}}},e.aq=function(e,t,i=0,r=!0){const n=new Te(i,i),o=e.sub(n),s=t.add(n),a=[o,new Te(s.x,o.y),s,new Te(o.x,s.y)];return r&&a.push(o.clone()),a},e.ar=function(e,t){const i=[];for(let r=0;r1)return!1;const i=t.getSource().maxzoom,r=1<1)return t;const n=r.getSource().maxzoom,o=1<{const a=this.getAtTileOffset(e,n,o,s),l=r.upVector(e.canonical,n.x,n.y);return R(l,l,a*r.upVectorScale(e.canonical,t,i).metersToTile),l}}getForTilePoints(e,t,i,r){if(this.isUsingMockSource())return!1;const n=Ey.create(this,e,r);return!!n&&(t.forEach(e=>{e[2]=this.exaggeration()*n.getElevationAt(e[0],e[1],i)}),!0)}getMinMaxForTile(e){if(this.isUsingMockSource())return null;const t=this.findDEMTileFor(e);if(!t||!t.dem)return null;const i=t.dem.tree,r=t.tileID,n=1<0&&i[0]<=e.width&&i[1]>0&&i[1]<=e.height&&!rh(e,new nc(e.center.lat,90)),r[0]>0&&r[0]<=e.width&&r[1]>0&&r[1]<=e.height&&!rh(e,new nc(e.center.lat,-90))]},e.cM=function(e,t){const{scale:i}=e.tileTransform,r=i*Ur/(e.tileSize*Math.pow(2,t.zoom-e.tileID.overscaledZ+e.tileID.canonical.z));return function(e,t,i){var r=t[1],n=t[2],o=t[3],s=i[0],a=i[1];return e[0]=t[0]*s,e[1]=r*s,e[2]=n*a,e[3]=o*a,e}(new Float32Array(4),t.inverseAdjustmentMatrix,[r,r])},e.cN=Vf,e.cO=x,e.cP=Uf,e.cQ=function(e){const t=Uf(e,!0);return r([],[t[0],t[1],t[4],t[5]])},e.cR=p,e.cS=$c,e.cT=f,e.cU=function(e){const{x:t,y:i}=e.point,{lng:r,lat:n}=e._center;return eh(t,i,e.worldSize,r,n)},e.cV=I,e.cW=Ie,e.cX=Mu,e.cY=_u,e.cZ=Zl,e.c_=function(e,t,i){let r=0;for(let i=0;i<2;++i){const n=0;e[i]>n&&(r+=(e[i]-n)*(e[i]-n)),t[i]0?Math.acos(i/r)*Be:0;let o=0!==e||0!==t?Math.atan2(-t,-e)*Be+90:0;return o<0&&(o+=360),[r,o,n]},e.d4=E,e.d5=Ke,e.d6=yc,e.d7=B,e.d8=Jc,e.d9=S,e.dA=Cl,e.dB=class extends vl{constructor(e){super(e),this.current=Il}set(e,t,i){if(this.fetchUniformLocation(e,t))for(let e=0;e<9;e++)if(i[e]!==this.current[e]){this.current=i,this.gl.uniformMatrix3fv(this.location,!1,i);break}}},e.dC=Pe,e.dD=function(e,t,i){const r=th(i.zoom),n=e.style.map._antialias,o=e.terrain&&e.terrain.exaggeration()>0;return 0===r&&!n&&!o},e.dE=function(e){const t=e.pixelsPerMeter,i=t/hc(1,e.center.lat),r=c(new Float64Array(16));return d(r,r,[e.point.x,e.point.y,0]),p(r,r,[i,i,t]),Float32Array.from(r)},e.dF=Qu,e.dG=function(e){const t=mc-5;e=Fe(e,-t,t)/t*90;const i=Math.pow(Math.abs(Math.sin(Se(e))),3);return Math.round(i*(Xl.length-1))},e.dH=function(e,t,i,r){const n=t.getNorth(),o=t.getSouth(),a=t.getWest(),l=t.getEast(),c=1<0){const e=180/r;s(f,f,[e/u+1,0,0,0,e/h+1,0,-.5*e/d,.5*e/p,1])}return f[2]=c,f[5]=e.x,f[8]=e.y,f},e.dI=Vu,e.dJ=function(e,t,i){const r=c(new Float64Array(16)),n=(t/(1<({u_matrix:new Sl(e),u_texsize:new wl(e),u_pixels_to_tile_units:new Pl(e),u_device_pixel_ratio:new bl(e),u_width_scale:new bl(e),u_floor_width_scale:new bl(e),u_image:new xl(e),u_units_to_pixels:new wl(e),u_tile_units_to_pixels:new bl(e),u_alpha_discard_threshold:new bl(e),u_trim_offset:new wl(e),u_trim_fade_range:new wl(e),u_trim_color:new El(e),u_emissive_strength:new bl(e),u_zbias_factor:new bl(e),u_tile_to_meter:new bl(e),u_ground_shadow_factor:new Tl(e),u_pattern_transition:new bl(e)}),e.dW=e=>({u_matrix:new Sl(e),u_pixels_to_tile_units:new Pl(e),u_device_pixel_ratio:new bl(e),u_width_scale:new bl(e),u_floor_width_scale:new bl(e),u_units_to_pixels:new wl(e),u_dash_image:new xl(e),u_gradient_image:new xl(e),u_image_height:new bl(e),u_texsize:new wl(e),u_tile_units_to_pixels:new bl(e),u_alpha_discard_threshold:new bl(e),u_trim_offset:new wl(e),u_trim_fade_range:new wl(e),u_trim_color:new El(e),u_emissive_strength:new bl(e),u_zbias_factor:new bl(e),u_tile_to_meter:new bl(e),u_ground_shadow_factor:new Tl(e)}),e.dX=e=>({u_camera_to_center_distance:new bl(e),u_extrude_scale:new Pl(e),u_device_pixel_ratio:new bl(e),u_matrix:new Sl(e),u_inv_rot_matrix:new Sl(e),u_merc_center:new wl(e),u_tile_id:new Tl(e),u_zoom_transition:new bl(e),u_up_dir:new Tl(e),u_emissive_strength:new bl(e)}),e.dY=Ra,e.dZ=fg,e.d_=class{constructor(e,t,i,r){this.context=e,this.format=r,this.size=i,this.texture=e.gl.createTexture();const[n,o,s]=this.size,{gl:a}=e;a.bindTexture(a.TEXTURE_3D,this.texture),e.pixelStoreUnpackFlipY.set(!1),e.pixelStoreUnpack.set(1),e.pixelStoreUnpackPremultiplyAlpha.set(!1),"data"in t&&t.data&&a.texImage3D(a.TEXTURE_3D,0,this.format,n,o,s,0,Sf(this.format),If(this.format),t.data)}bind(e,t){const{context:i}=this,{gl:r}=i;r.bindTexture(r.TEXTURE_3D,this.texture),e!==this.minFilter&&(r.texParameteri(r.TEXTURE_3D,r.TEXTURE_MAG_FILTER,e),r.texParameteri(r.TEXTURE_3D,r.TEXTURE_MIN_FILTER,e),this.minFilter=e),t!==this.wrapS&&(r.texParameteri(r.TEXTURE_3D,r.TEXTURE_WRAP_S,t),r.texParameteri(r.TEXTURE_3D,r.TEXTURE_WRAP_T,t),this.wrapS=t)}destroy(){const{gl:e}=this.context;e.deleteTexture(this.texture),this.texture=null}},e.da=function(e){return[Math.pow(e[0],1/2.2),Math.pow(e[1],1/2.2),Math.pow(e[2],1/2.2)]},e.db=Bf,e.dc=hm,e.dd=Jf,e.de=yy,e.df=function(e,t){return e.readFields(qy,{icons:[]},t)},e.dg=Xp,e.dh=B_,e.di=C_,e.dj=Ot,e.dk=ys,e.dl=At,e.dm=Jt,e.dn=He,e.dp=function(e){const t=e.indexOf(ea);return t>=0?e.slice(0,t):e},e.dq=function(e){return e.indexOf(ea)>=0},e.dr=function(e){const t=e.lastIndexOf(ea);return t>=0?e.slice(t+1):""},e.ds=function(e){const t=[],i=e.id;return void 0===i&&t.push({message:`layers.${i}: missing required property "id"`}),void 0===e.render&&t.push({message:`layers.${i}: missing required method "render"`}),e.renderingMode&&"2d"!==e.renderingMode&&"3d"!==e.renderingMode&&t.push({message:`layers.${i}: property "renderingMode" must be either "2d" or "3d"`}),t},e.dt=function(e,t,i,r){return"custom"===e.type?new my(e,t):new Vy[e.type](e,t,i,r)},e.du=Ge,e.dv=function(e){const t=e.indexOf(ea);return t>=0?e.slice(t+1):""},e.dw=class extends Oy{constructor(e,t){super(e._vectorTileFeature,e._z,e._x,e._y,e.id),e.state&&(this.state=Object.assign({},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}},e.dx=xs,e.dy=zt,e.dz=function(e){return e({pluginStatus:_s,pluginURL:As}),xs.on("pluginStateChange",e),e},e.e=st,e.e$=function([e,t,i]){const r=Math.hypot(e,t,i),n=Math.atan2(e,i),o=.5*Math.PI-Math.acos(-t/r);return new nc(Ie(n),Ie(o))},e.e0=(e,t,i,r,n,o)=>{const s=e.transform,a="globe"===s.projection.name;let l;if("map"===o.paint.get("circle-pitch-alignment"))if(a){const e=Yu(s.zoom,t.canonical)*s._pixelsPerMercatorPixel;l=Float32Array.from([e,0,0,e])}else l=s.calculatePixelsToTileUnitsMatrix(i);else l=new Float32Array([s.pixelsToGLUnits[0],0,0,s.pixelsToGLUnits[1]]);const c={u_camera_to_center_distance:e.transform.getCameraToCenterDistance(s.projection),u_matrix:e.translatePosMatrix(t.projMatrix,i,o.paint.get("circle-translate"),o.paint.get("circle-translate-anchor")),u_device_pixel_ratio:gt.devicePixelRatio,u_extrude_scale:l,u_inv_rot_matrix:ah,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(a){c.u_inv_rot_matrix=r,c.u_merc_center=n,c.u_tile_id=[t.canonical.x,t.canonical.y,1<{const u=e.transform,h=u.pitch<15?qm(.07,.7,Fe((14-u.zoom)/5,0,1)):.07,d="none"===i.paint.get("line-trim-color-use-theme").constantOr("default");return{u_matrix:Xm(e,t,i,r),u_texsize:t.imageAtlasTexture?t.imageAtlasTexture.size:[0,0],u_pixels_to_tile_units:u.calculatePixelsToTileUnitsMatrix(t),u_device_pixel_ratio:n,u_width_scale:o,u_floor_width_scale:s,u_image:0,u_tile_units_to_pixels:Km(t,u),u_units_to_pixels:[1/u.pixelsToGLUnits[0],1/u.pixelsToGLUnits[1]],u_alpha_discard_threshold:0,u_trim_offset:a,u_trim_fade_range:i.paint.get("line-trim-fade-range"),u_trim_color:i.paint.get("line-trim-color").toPremultipliedRenderColor(d?null:i.lut).toArray01(),u_emissive_strength:i.paint.get("line-emissive-strength"),u_zbias_factor:h,u_tile_to_meter:yc(t.tileID.canonical,0),u_ground_shadow_factor:l,u_pattern_transition:c}},e.e4=(e,t,i,r,n,o,s,a,l,c)=>{const u=e.transform,h=u.calculatePixelsToTileUnitsMatrix(t),d="none"===i.paint.get("line-trim-color-use-theme").constantOr("default"),p=u.pitch<15?qm(.07,.7,Fe((14-u.zoom)/5,0,1)):.07;return{u_matrix:Xm(e,t,i,r),u_pixels_to_tile_units:h,u_device_pixel_ratio:o,u_width_scale:s,u_floor_width_scale:a,u_units_to_pixels:[1/u.pixelsToGLUnits[0],1/u.pixelsToGLUnits[1]],u_dash_image:0,u_gradient_image:1,u_image_height:n,u_texsize:Ym(i)&&t.lineAtlasTexture?t.lineAtlasTexture.size:[0,0],u_tile_units_to_pixels:Km(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_color:i.paint.get("line-trim-color").toPremultipliedRenderColor(d?null:i.lut).toArray01(),u_emissive_strength:i.paint.get("line-emissive-strength"),u_zbias_factor:p,u_tile_to_meter:yc(t.tileID.canonical,0),u_ground_shadow_factor:c}},e.e5=Ne,e.e6=Eh,e.e7=fc,e.e8=Pu,e.e9=_p,e.eA=Uy,e.eB=Xf,e.eC=Zf,e.eD=[1,1,1],e.eE=Ey,e.eF=K,e.eG=function(e,t,i,r){var n=t[0],o=t[1],s=t[2],a=t[3];return e[0]=n+r*(i[0]-n),e[1]=o+r*(i[1]-o),e[2]=s+r*(i[2]-s),e[3]=a+r*(i[3]-a),e},e.eH=Kf,e.eI=Ia,e.eJ=ja,e.eK=function(e,t,r,n,o,s,a,l,c,u,h,d,p,f,m,g){var _=new i(16);return _[0]=e,_[1]=t,_[2]=r,_[3]=n,_[4]=o,_[5]=s,_[6]=a,_[7]=l,_[8]=c,_[9]=u,_[10]=h,_[11]=d,_[12]=p,_[13]=f,_[14]=m,_[15]=g,_},e.eL=ic,e.eM=Va,e.eN=Na,e.eO=class{constructor(){this._updateTime=0,this._sourceIds=[],this._activeRegions=[],this._prevRegions=[],this._globalClipBounds={min:new Te(1/0,1/0),max:new Te(-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=Gd(new Te(0,0),new Te(Ur,Ur),e),r=[];if(t&&!Vd(i,this._globalClipBounds))return r;for(const t of this._activeRegions){if(t.hiddenByOverlap)continue;if(!Vd(i,t))continue;const n=Hd(t.min,t.max,e);r.push({min:n.min,max:n.max,sourceId:this._sourceIds[t.priority],footprint:t.footprint,footprintTileId:t.tileId,order:t.order,clipMask:t.clipMask,clipScope:t.clipScope})}return r}setSources(e){this._setSources(e.map(e=>({getSourceId:()=>e.cache.id,getFootprints:()=>{const t=[];for(const i of e.cache.getVisibleCoordinates()){const r=e.cache.getTile(i).buckets[e.layer];r&&r.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(),r=e.getClipMask(),n=e.getClipScope();for(const e of t){if(!e.footprint)continue;const t=Gd(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:r,clipScope:n})}this._sourceIds.push(e.getSourceId())}_computeReplacement(){this._activeRegions.sort((e,t)=>e.priority-t.priority||Ud(e.min,t.min)||Ud(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],r=this._prevRegions[t];e=i.priority!==r.priority||!Nd(i,r)||i.order!==r.order||i.clipMask!==r.clipMask||!Ee(i.clipScope,r.clipScope),this._activeRegions[t].hiddenByOverlap=r.hiddenByOverlap,++t}}if(e){++this._updateTime;for(const e of this._activeRegions)e.order!==Dd&&(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(;e1){let t=0,i=e(t);for(;t!==i;){let r=t;const n=t;for(;r!==i;){const e=this._activeRegions[r];e.hiddenByOverlap=!1;for(let t=0;t=0;t--)this._addSource(e[t]);this._computeReplacement()}},e.eP=Dd,e.eQ=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 pa,r=new Fa,n=[],o=e+1+2,s=t[0]+1,a=t[0]+1+(1+t.length),l=(e,t,i)=>{let r=e===o-1?e-2:0===e?e:e-1;return r+=i?24575:0,[r,t]};for(let e=0;e0?(_=2*Math.sqrt(g+1),e[3]=.25*_,e[0]=(d-f)/_,e[1]=(p-c)/_,e[2]=(l-u)/_):a>h&&a>m?(_=2*Math.sqrt(1+a-h-m),e[3]=(d-f)/_,e[0]=.25*_,e[1]=(l+u)/_,e[2]=(p+c)/_):h>m?(_=2*Math.sqrt(1+h-a-m),e[3]=(p-c)/_,e[0]=(l+u)/_,e[1]=.25*_,e[2]=(d+f)/_):(_=2*Math.sqrt(1+m-a-h),e[3]=(l-u)/_,e[0]=(p+c)/_,e[1]=(d+f)/_,e[2]=.25*_),e},e.ez=function(e,i){var r=2*Math.acos(i[3]),n=Math.sin(r/2);return n>t?(e[0]=i[0]/n,e[1]=i[1]/n,e[2]=i[2]/n):(e[0]=1,e[1]=0,e[2]=0),r},e.f=function(e){return btoa(encodeURIComponent(e).replace(/%([0-9A-F]{2})/g,(e,t)=>String.fromCharCode(Number("0x"+t))))},e.f0=J,e.f1=Gf,e.f2=function(e){const t=e.navigator?e.navigator.userAgent:null;return!!function(e){if(null==Ye){const t=e.navigator?e.navigator.userAgent:null;Ye=!!e.safari||!(!t||!(/\b(iPad|iPhone|iPod)\b/.test(t)||t.match("Safari")&&!t.match("Chrome")))}return Ye}(e)&&!(!t||!(t.match("Version/15.4")||t.match("Version/15.5")||t.match(/CPU (OS|iPhone OS) (15_4|15_5) like Mac OS X/)))},e.f3=function(e,t){vt=e,xt=t},e.f4=rh,e.f5=ih,e.f6=function(e){const t=[0,0,0],i=c(new Float64Array(16));return h(i,e.pixelMatrix,e.globeMatrix),j(t,t,i),new Te(t[0],t[1])},e.f7=function(){const e=qp;e&&(e.isPreloaded()&&1===e.numActive()?(e.release($p),qp=null):console.warn("Could not clear WebWorkers since there are active Map instances that still reference it. The pre-warmed WebWorker pool can only be cleared when all map instances have been removed with map.remove()"))},e.f8=function(){Xp().acquire($p)},e.f9=bs,e.fA=Mc,e.fB=function(e){let t=0;if(new Uint32Array(e,0,1)[0]!==vf){const i=new Uint32Array(e,0,7),[,,r,n,o,s]=i;t=i.byteLength+n+o+s+o,(r!==e.byteLength||t>=e.byteLength)&&Ze("Invalid b3dm header information.")}return Cf(e,t)},e.fC=function(e,t){const i=hm(e);for(const e of i){for(const t of e.meshes)dm(t);e.lights&&(e.lightMeshIndex=e.meshes.length,e.meshes.push(fm(e.lights,t)))}return i},e.fD=Ry,e.fE=Xe,e.fF=Hp,e.fG=Ts,e.fH=ms,e.fI=function(e){Ct(),null!=wt&&wt.then(t=>{t.keys().then(i=>{for(let r=0;rZe(e.message))}).catch(e=>Ze(e.message))}).catch(e=>Ze(e.message))},e.fa=function(e,t,i=!1){if(_s===ms.deferred||_s===ms.loading||_s===ms.loaded)throw new Error("setRTLTextPlugin cannot be called multiple times.");As=gt.resolveURL(e),_s=ms.deferred,gs=t,vs(),i||ws()},e.fb=function(e){rf=gt.resolveURL(e),of||(of=new Wp(Xp(),new ri)),of.broadcast("setMeshoptUrl",rf)},e.fc=uf,e.fd=function(e){ef=gt.resolveURL(e),of||(of=new Wp(Xp(),new ri)),of.broadcast("setDracoUrl",ef)},e.fe=cf,e.ff=Qp,e.fg=function(e){const t=Et();if(!t)return;const i=t.delete(yt);e&&i.then(()=>e()).catch(e)},e.fh=Zp,e.fi=es,e.fj=bh,e.fk=E_,e.fl=Vx,e.fm=jx,e.fn=Nm,e.fo=Oc,e.fp="hd_road_elevation",e.fq=tu,e.fr=je,e.fs=ld,e.ft=v_,e.fu=A_,e.fv=function(e,t,i,r,n,o,s,a=1,l,c,u){e.createArrays(),e.tilePixelRatio=Ur/(512*e.overscaling),e.compareText={},e.iconsNeedLinear=!1;const h=e.layers[0].layout,d=e.layers[0]._unevaluatedLayout._values,p={};p.scaleFactor=a,p.textSizeScaleRange=h.get("text-size-scale-range"),p.iconSizeScaleRange=h.get("icon-size-scale-range");const[f,m]=p.textSizeScaleRange,[g,_]=p.iconSizeScaleRange;p.textScaleFactor=Fe(p.scaleFactor,f,m),p.iconScaleFactor=Fe(p.scaleFactor,g,_);const A=d["text-size"],y=d["icon-size"];if("composite"===e.textSizeData.kind){const{minZoom:t,maxZoom:i}=e.textSizeData;p.compositeTextSizes=[A.possiblyEvaluate(new Es(t,{worldview:u}),o),A.possiblyEvaluate(new Es(i,{worldview:u}),o)]}if("composite"===e.iconSizeData.kind){const{minZoom:t,maxZoom:i}=e.iconSizeData;p.compositeIconSizes=[y.possiblyEvaluate(new Es(t,{worldview:u}),o),y.possiblyEvaluate(new Es(i,{worldview:u}),o)]}p.layoutTextSize=A.possiblyEvaluate(new Es(s+1,{worldview:u}),o),p.layoutIconSize=y.possiblyEvaluate(new Es(s+1,{worldview:u}),o),p.textMaxSize=A.possiblyEvaluate(new Es(18,{worldview:u}),o);const v=h.get("symbol-placement"),x="map"===h.get("text-rotation-alignment")&&"point"!==v,b=h.get("text-size");let w=!1;const T=[];for(const s of e.features){const a=h.get("text-font").evaluate(s,{},o).join(","),f=b.evaluate(s,{},o)*p.textScaleFactor,m=p.layoutTextSize.evaluate(s,{},o)*p.textScaleFactor,g=p.layoutIconSize.evaluate(s,{},o)*p.iconScaleFactor,_={horizontal:{},vertical:void 0},A=s.text;let y,E=[0,0];if(A){const r=A.toString(),c=h.get("text-letter-spacing").evaluate(s,{},o)*mg,u=h.get("text-line-height").evaluate(s,{},o)*mg,d=as(r)?c:0,p=h.get("text-anchor").evaluate(s,{},o),g=h.get("text-variable-anchor");if(!g){const e=h.get("text-radial-offset").evaluate(s,{},o);if(e)E=Q_(p,[e*mg,j_]);else{const e=h.get("text-offset").evaluate(s,{},o);E=[e[0]*mg,e[1]*mg]}}let y=x?"center":h.get("text-justify").evaluate(s,{},o);const b="point"===v,w=b?h.get("text-max-width").evaluate(s,{},o)*mg:1/0,T=o=>{e.allowVerticalPlacement&&ss(r)&&(_.vertical=Gg(A,t,i,n,a,w,u,p,o,d,E,Ng.vertical,!0,m,f,l))};if(!x&&g){const e="auto"===y?g.map(e=>eA(e)):[y];let r=!1;for(let o=0;o=0||!ss(r)){const e=Gg(A,t,i,n,a,w,u,p,y,d,E,Ng.horizontal,!1,m,f,l);e&&(_.horizontal[y]=e)}T(b?"left":y)}}let C,B,S,I,M,P,R=!1;const L=h.get("icon-text-fit").evaluate(s,{},o);if(s.icon&&s.icon.hasPrimary()){const t=q_(s.icon,e.iconSizeData,d["icon-size"],o,e.zoom,s,l,p.iconScaleFactor,u);C=t.iconPrimary,S=t.iconSecondary;const i=C.toString();if(B=r.get(i),B&&(M=h.get("icon-offset").evaluate(s,{},o),P=h.get("icon-anchor").evaluate(s,{},o),y=e_(n.get(i),S?n.get(S.toString()):void 0,M,P),R=B.sdf,void 0===e.sdfIcons?e.sdfIcons=B.sdf:e.sdfIcons!==B.sdf&&Ze("Style sheet warning: Cannot mix SDF and non-SDF icons in one buffer"),(B.pixelRatio!==e.pixelRatio||0!==h.get("icon-rotate").constantOr(1))&&(e.iconsNeedLinear=!0)),S){const e=S.toString();I=r.get(e)}}w=w||!(!s.icon||!s.icon.hasSecondary());const F=sA(_.horizontal)||_.vertical;e.iconsInText||(e.iconsInText=!!F&&F.iconsInText);const k=m*p.textScaleFactor/mg,{defaultShapedIcon:D,verticallyShapedIcon:O}=tA(e,y,h,s,o,_,k,M,L);"none"!==L&&y&&(i_(y)||r_(y))&&(Z_(0,B,C,y,D,L,c,r,n),Z_(0,I,S,y,D,L,c,r,n),O&&(Z_(0,B,C,y,O,L,c,r,n),Z_(0,I,S,y,O,L,c,r,n))),y=D;const{iconBBox:z,iconVerticalBBox:U}=$_(e,y,O,h,s,o,g,M,p,n,P);T.push({feature:s,shapedTextOrientations:_,shapedText:F,shapedIcon:y,iconPrimary:C,iconSecondary:S,iconOffset:M,iconAnchor:P,verticallyShapedIcon:O,layoutTextSize:m,layoutIconSize:g,textOffset:E,isSDFIcon:R,iconTextFit:L,iconCollisionBounds:z,iconVerticalCollisionBounds:U})}return{featureData:T,sizes:p,hasAnySecondaryIcon:w,textAlongLine:x,symbolPlacement:v}},e.fw=x_,e.fx=function(e,t,i,r,n,o,s,a,l,c){e.iconAtlasPositions=c.iconPositions;const{featureData:u,hasAnySecondaryIcon:h,sizes:d,textAlongLine:p,symbolPlacement:f}=t;for(const t of u){const{shapedIcon:i,verticallyShapedIcon:o,feature:u,shapedTextOrientations:m,shapedText:g,layoutTextSize:_,textOffset:A,isSDFIcon:y,iconPrimary:v,iconSecondary:x,iconTextFit:b,iconOffset:w,iconCollisionBounds:T,iconVerticalCollisionBounds:E}=t;X_(i,c.iconPositions,v,x),X_(o,c.iconPositions,v,x),J_(m,c.iconPositions),K_(v,x,c.iconPositions),(g||i)&&iA(e,u,m,i,o,l,d,_,0,A,y,r,n,s,a,h,b,w,p,f,T,E)}i&&e.generateCollisionDebugBuffers(o,e.collisionBoxArray,d.textScaleFactor)},e.fy=kc,e.fz=Wv,e.g=function(e,t){return zt(Object.assign(e,{method:"GET"}),t)},e.h=function(e){return 0===e.indexOf("mapbox:")},e.i=function(e){return st.API_STYLE_REGEX.test(e)&&!lt(e)},e.j=at,e.k=St,e.l=function(e){return decodeURIComponent(atob(e).split("").map(e=>"%"+("00"+e.charCodeAt(0).toString(16)).slice(-2)).join(""))},e.m=function(e,t){return zt(Object.assign(e,{type:"json"}),t)},e.n=Ht,e.o=gt,e.p=function(e,t){return zt(Object.assign(e,{method:"POST"}),t)},e.q=wh,e.r=mt,e.s=function(e){try{const t=self[e];return t.setItem("_mapbox_test_",1),t.removeItem("_mapbox_test_"),!0}catch(e){return!1}},e.t=function(){return Kp||(Kp=new Zp),Kp},e.u=function(){return function e(t){return t?(t^Math.random()*(16>>t/4)).toString(16):([1e7]+-[1e3]+-4e3+-8e3+-1e11).replace(/[018]/g,e)}()},e.v=function(e){return!!e&&/^[0-9a-f]{8}-[0-9a-f]{4}-[4][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$/i.test(e)},e.w=Ze,e.x=Dv,e.y=ei,e.z=Yt}),r(["./shared"],function(e){function t(e){const t=e?e.url.toString():void 0;return t?performance.getEntriesByName(t):[]}function i(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 r of e)t+=`${i(r)},`;return`${t}]`}let t="{";for(const r of Object.keys(e).sort())t+=`${r}:${i(e[r])},`;return`${t}}`}function r(t){let r="";for(const n of e.bw)r+=`/${i(t[n])}`;return r}class n{constructor(e){this.keyCache={},this._layers={},this._layerConfigs={},e&&this.replace(e)}replace(e,t){this._layerConfigs={},this._layers={},this.update(e,[],t)}update(t,n,o){this._options=o;for(const i of t)this._layerConfigs[i.id]=i,(this._layers[i.id]=e.dt(i,this.scope,null,this._options)).compileFilter(o),this.keyCache[i.id]&&delete this.keyCache[i.id];for(const e of n)delete this.keyCache[e],delete this._layerConfigs[e],delete this._layers[e];this.familiesBySource={};const s=function(e,t){const n={};for(let o=0;othis._layers[e.id]),i=t[0];if("none"===i.visibility)continue;const r=i.source||"";let n=this.familiesBySource[r];n||(n=this.familiesBySource[r]={});const o=i.sourceLayer||"_geojsonTileLayer";let s=n[o];s||(s=n[o]=[]),s.push(t)}}}const o=1*e.fk;class s{constructor(t){const i={},r=[];for(const e in t){const n=t[e],s=i[e]={};for(const e in n.glyphs){const t=n.glyphs[+e];if(!t||0===t.bitmap.width||0===t.bitmap.height)continue;const i=t.metrics.localGlyph?o:1,a={x:0,y:0,w:t.bitmap.width+2*i,h:t.bitmap.height+2*i};r.push(a),s[e]=a}}const{w:n,h:s}=e.G(r),a=new e.fj({width:n||1,height:s||1});for(const r in t){const n=t[r];for(const t in n.glyphs){const s=n.glyphs[+t];if(!s||0===s.bitmap.width||0===s.bitmap.height)continue;const l=i[r][t],c=s.metrics.localGlyph?o:1;e.fj.copy(s.bitmap,a,{x:0,y:0},{x:l.x+c,y:l.y+c},s.bitmap)}}this.image=a,this.positions=i}}function a(e,t,i){e[t]?i&&(e[t].center=i):e[t]={floorIds:new Set,center:i||[0,0],floors:{}}}function l(e,t,i,r){for(const n of t)a(e,n),e[n].floors[i]=r,e[n].floorIds.add(i)}function c(e){return{id:e.properties.id.toString(),center:e.properties.center.toString().split(";").map(Number)}}function u(e){return{id:e.properties.id.toString(),isDefault:!!e.properties.is_default&&e.properties.is_default,connections:e.properties.connected_floor_ids?new Set(e.properties.connected_floor_ids.toString().split(";")):new Set,conflicts:e.properties.conflicted_floor_ids?new Set(e.properties.conflicted_floor_ids.toString().split(";")):new Set,buildings:e.properties.building_ids?new Set(e.properties.building_ids.toString().split(";")):new Set,name:e.properties.name.toString(),zIndex:e.properties.z_index}}function h(e,t){return t.every(t=>e.properties&&null!=e.properties[t])}function d(e){return h(e,["type","id","name"])&&"building"===e.properties.type}function p(e){return h(e,["type","id","name","z_index"])&&"floor"===e.properties.type}e.fi(s,"GlyphAtlas");class f{constructor(t){this.tileID=new e.aP(t.tileID.overscaledZ,t.tileID.wrap,t.tileID.canonical.z,t.tileID.canonical.x,t.tileID.canonical.y),this.tileZoom=t.tileZoom,this.uid=t.uid,this.zoom=t.zoom,this.lut=t.lut,this.canonical=t.tileID.canonical,this.pixelRatio=t.pixelRatio,this.tileSize=t.tileSize,this.source=t.source,this.scope=t.scope,this.overscaling=this.tileID.overscaleFactor(),this.showCollisionBoxes=t.showCollisionBoxes,this.collectResourceTiming=!!t.request&&t.request.collectResourceTiming,this.promoteId=t.promoteId,this.isSymbolTile=t.isSymbolTile,this.tileTransform=e.aY(t.tileID.canonical,t.projection),this.projection=t.projection,this.worldview=t.worldview,this.localizableLayerIds=t.localizableLayerIds,this.brightness=t.brightness,this.extraShadowCaster=!!t.extraShadowCaster,this.tessellationStep=t.tessellationStep,this.scaleFactor=t.scaleFactor,this.worldview=t.worldview,this.indoor=t.indoor}parse(t,i,r,n,o,h){this.status="parsing",this.data=t,this.collisionBoxArray=new e.b2;const f=new e.fl(Object.keys(t.layers).sort()),g=new e.fm(this.tileID,this.promoteId);g.bucketLayerIDs=[];const _={},A=new e.fn(256,256),y={featureIndex:g,iconDependencies:new Map,patternDependencies:new Map,glyphDependencies:{},lineAtlas:A,availableImages:r,brightness:this.brightness,scaleFactor:this.scaleFactor,elevationFeatures:void 0,activeFloors:void 0};if(this.indoor){const i=this.indoor.indoorState.activeFloorsVisible,r=function(t,i,r){const n=function(t,i){if(!t)return e.w("No source layers defined in indoor specification"),i;if(0===t.size)return i;const r=t.difference(i);for(const t of r)e.w(`Missing source layer required in indoor specification: ${t}`);return i.intersection(i)}(i.sourceLayers,new Set(Object.keys(t.layers))),o=i.indoorState,s=function(t,i,r,n){const o=new Set,s=new Set,h=new Set,f=new Map,m={},g=e=>{const t=f.get(e)||new Set;for(const i of o)if((f.get(i)||new Set).has(e)||t.has(i))return!0;return!1};for(const r of i){const i=t.layers[r];if(i)for(let e=0;e=i.maxzoom)continue;if("none"===i.visibility)continue;m(t,this.zoom,y.brightness,r,this.worldview);const o=_[i.id]=i.createBucket({index:g.bucketLayerIDs.length,layers:t,zoom:this.zoom,lut:this.lut,canonical:this.canonical,pixelRatio:this.pixelRatio,overscaling:this.overscaling,collisionBoxArray:this.collisionBoxArray,sourceLayerIndex:c,sourceID:this.source,projection:this.projection.spec,tessellationStep:this.tessellationStep,styleDefinedModelURLs:n,worldview:this.worldview});g.bucketLayerIDs.push(t.map(t=>e.B(t.id,t.scope)));let s=o.prepare?o.prepare():null;null!=s?(s=s.then(()=>o.populate(u,y,this.tileID.canonical,this.tileTransform)),v.push(s)):o.populate(u,y,this.tileID.canonical,this.tileTransform)}}const b=()=>{let i,n,a,l,c,u;A.trim();const d={type:"maybePrepare",isSymbolTile:this.isSymbolTile,zoom:this.zoom},p=()=>{if(i)return this.status="done",h(i);if(this.extraShadowCaster)this.status="done",h(null,{buckets:Object.values(_).filter(e=>!e.isEmpty()),featureIndex:g,collisionBoxArray:null,glyphAtlasImage:null,lineAtlas:null,imageAtlas:null,brightness:y.brightness,glyphMap:null,iconMap:null,glyphPositions:null});else if(n&&a&&l){const t=new s(n),i=new Map;for(const[t,r]of a.entries()){const{imagePosition:n}=e.ft(t,r,e.fu);i.set(t,n)}const h={};for(const o in _){const s=_[o];s instanceof e.b3&&(m(s.layers,this.zoom,y.brightness,r,this.worldview),h[o]=e.fv(s,n,t.positions,a,i,this.tileID.canonical,this.tileZoom,this.scaleFactor,this.pixelRatio,c,this.worldview))}const d={iconsPending:!0,patternsPending:!0};this.rasterizeIfNeeded(o,a,c,()=>{d.iconsPending=!1,v(h,t,d)}),this.rasterizeIfNeeded(o,l,u,()=>{d.patternsPending=!1,v(h,t,d)})}},v=(t,i,n,o)=>{if(n.iconsPending||n.patternsPending)return;const s=new e.fw(a,l,this.lut);for(const i in _){const n=_[i];if(i in t)e.fx(n,t[i],this.showCollisionBoxes,r,this.tileID.canonical,this.tileZoom,this.projection,this.brightness,a,s);else if(n.hasPattern&&(n instanceof e.b9||n instanceof e.ba||n instanceof e.e9)){m(n.layers,this.zoom,y.brightness,r,this.worldview);const e=Object.fromEntries(s.patternPositions);n.addFeatures(y,this.tileID.canonical,e,r,this.tileTransform,this.brightness)}}this.status="done",h(null,{buckets:Object.values(_).filter(e=>!e.isEmpty()),featureIndex:g,collisionBoxArray:this.collisionBoxArray,glyphAtlasImage:i.image,lineAtlas:A,imageAtlas:s,brightness:y.brightness})};if(!this.extraShadowCaster){const t=e.fr(y.glyphDependencies,e=>Object.keys(e).map(Number));Object.keys(t).length?o.send("getGlyphs",{uid:this.uid,stacks:t},(e,t)=>{i||(i=e,n=t,p())},void 0,!1,d):n={};const r=Array.from(y.iconDependencies.keys()).map(t=>e.I.parse(t));r.length?o.send("getImages",{images:r,source:this.source,scope:this.scope,tileID:this.tileID,type:"icons"},(e,t)=>{i||(i=e,a=new Map,c=this.updateImageMapAndGetImageTaskQueue(a,t,y.iconDependencies),p())},void 0,!1,d):(a=new Map,c=new Map);const s=Array.from(y.patternDependencies.keys()).map(t=>e.I.parse(t));s.length?o.send("getImages",{images:s,source:this.source,scope:this.scope,tileID:this.tileID,type:"patterns"},(e,t)=>{i||(i=e,l=new Map,u=this.updateImageMapAndGetImageTaskQueue(l,t,y.patternDependencies),p())},void 0,!1,d):(l=new Map,u=new Map)}if(y.elevationFeatures&&y.elevationFeatures.length>0){const i=[];for(const t of Object.values(_))if(t instanceof e.ba){const e=t.getUnevaluatedPortalGraph();e&&i.push(e)}const r=e.fs.evaluate(i);for(const i of Object.values(_))if(i instanceof e.ba){const e=t.layers[f.decode(i.sourceLayerIndex)];i.setEvaluatedPortalGraph(r,e,this.tileID.canonical,y.availableImages,y.brightness)}}p()};v.length>0?Promise.allSettled(v).then(b).catch(h):b()}updateParameters(t){this.scaleFactor=t.scaleFactor,this.showCollisionBoxes=t.showCollisionBoxes,this.projection=t.projection,this.brightness=t.brightness,this.tileTransform=e.aY(t.tileID.canonical,t.projection),this.extraShadowCaster=t.extraShadowCaster,this.lut=t.lut,this.worldview=t.worldview,this.indoor=t.indoor}rasterizeIfNeeded(e,t,i,r){Array.from(t.values()).some(e=>e.usvg)?this.rasterize(e,t,i,r):r()}updateImageMapAndGetImageTaskQueue(e,t,i){const r=new Map;for(const n of t.keys()){const o=i.get(n)||[];for(const i of o){const n=i.toString(),o=t.get(i.id.toString());o.usvg?r.has(n)||(r.set(n,i),e.set(n,Object.assign({},o))):e.set(n,o)}}return r}rasterize(e,t,i,r){this.rasterizeTask=e.send("rasterizeImages",{scope:this.scope,tasks:i},(e,i)=>{if(!e)for(const[e,r]of i.entries()){const i=Object.assign(t.get(e),{data:r});t.set(e,i)}r()})}cancelRasterize(){this.rasterizeTask&&this.rasterizeTask.cancel()}}function m(t,i,r,n,o){const s=new e.ac(i,{brightness:r,worldview:o});for(const e of t)e.recalculate(s,n)}class g extends e.E{constructor(t,i,r,n,o,s,a){super(),this.actor=t,this.layerIndex=i,this.availableImages=r,this.availableModels=n,this.loadVectorData=s||e.aL,this.loading={},this.loaded={},this.deduped=new e.aK(t.scheduler),this.isSpriteLoaded=o,this.scheduler=t.scheduler,this.brightness=a}loadTile(i,r){const n=i.uid,o=i&&i.request,s=o&&o.collectResourceTiming,a=this.loading[n]=new f(i);a.abort=this.loadVectorData(i,(l,c)=>{const u=!this.loading[n];if(delete this.loading[n],a.cancelRasterize(),u||l||!c)return a.status="done",u||(this.loaded[n]=a),r(l);const h=c.rawData,d={},p=e.aM(c.responseHeaders);p&&p.expires&&(d.expires=p.expires),p&&p.cacheControl&&(d.cacheControl=p.cacheControl),a.vectorTile=c.vectorTile||new e.fy(new e.bs(h));const f=()=>{a.parse(a.vectorTile,this.layerIndex,this.availableImages,this.availableModels,this.actor,(e,i)=>{if(e||!i)return r(e);const n={};if(s){const e=t(o);e.length>0&&(n.resourceTiming=JSON.parse(JSON.stringify(e)))}r(null,Object.assign({rawTileData:h.slice(0),responseHeaders:c.responseHeaders},i,d,n))})};this.isSpriteLoaded?f():this.once("isSpriteLoaded",()=>{this.scheduler?this.scheduler.add(f,{type:"parseTile",isSymbolTile:i.isSymbolTile,zoom:i.tileZoom}):f()}),this.loaded=this.loaded||{},this.loaded[n]=a})}reloadTile(e,t){const i=this.loaded,r=e.uid;if(i&&i[r]){const n=i[r];n.updateParameters(e);const o=(e,i)=>{const r=n.reloadCallback;r&&(delete n.reloadCallback,n.parse(n.vectorTile,this.layerIndex,this.availableImages,this.availableModels,this.actor,r)),t(e,i)};"parsing"===n.status?n.reloadCallback=o:"done"===n.status&&(n.vectorTile?n.parse(n.vectorTile,this.layerIndex,this.availableImages,this.availableModels,this.actor,o):o())}else t(null,void 0)}abortTile(e,t){const i=e.uid,r=this.loading[i];r&&(r.abort&&r.abort(),delete this.loading[i]),t()}removeTile(e,t){const i=this.loaded,r=e.uid;i&&i[r]&&delete i[r],t()}}class _{loadTile(t,i){const{uid:r,encoding:n,rawImageData:o,padding:s}=t,a=ImageBitmap&&o instanceof ImageBitmap?this.getImageData(o,s):o;i(null,new e.fz(r,a,n,s<1))}reloadTile(e,t){t(null,null)}abortTile(e,t){t()}removeTile(e,t){t()}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 i=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),i}}e.br.setPbf(e.bs);class A{constructor(t){this._mrt=new e.br(t.partial?30:1/0),this._isHeaderLoaded=!1,this.uid=t.uid,this.tileID=t.tileID,this.source=t.source}parse(t,i){const r=this._mrt;this.status="parsing",this._entireBuffer=t;try{r.parseHeader(t),this._isHeaderLoaded=!0;const n=[];for(const i in r.layers){const o=r.getLayer(i),s=o.getDataRange(o.getBandList()),a=r.createDecodingTask(s),l=t.slice(s.firstByte,s.lastByte+1),c=e.br.performDecoding(l,a).then(e=>a.complete(null,e)).catch(e=>a.complete(e,null));n.push(c)}Promise.allSettled(n).then(()=>i(null,r)).catch(e=>i(e))}catch(e){i(e)}}}class y{constructor(e){this.actor=e,this.loading={},this.loaded={}}loadTile(t,i){const r=t.uid,n=t.request,o=this.loading[r]=new A(t),{cancel:s}=e.bt(n,(e,t,n)=>{const s=!this.loading[r];if(delete this.loading[r],s||e||!t)return o.status="done",s||(this.loaded[r]=o),i(e);o.parse(t,(e,t)=>{if(e||!t)return i(e);i(null,t,n)}),this.loaded[r]=o});o.abort=s}reloadTile(e,t){t(null,void 0)}abortTile(e,t){const i=e.uid,r=this.loading[i];r&&(r.abort&&r.abort(),delete this.loading[i]),t()}removeTile(e,t){const i=e.uid;this.loaded[i]&&delete this.loaded[i],t()}decodeRasterArray(t,i){e.br.performDecoding(t.buffer,t.task).then(e=>i(null,e)).catch(e=>i(e))}}const v=e.fA.prototype.toGeoJSON;class x{constructor(t){this._feature=t,this.extent=e.al,this.type=t.type,this.properties=t.tags,"id"in t&&!isNaN(t.id)&&(this.id=parseInt(t.id,10))}loadGeometry(){if(1===this._feature.type){const t=[];for(const i of this._feature.geometry)t.push([new e.P(i[0],i[1])]);return t}{const t=[];for(const i of this._feature.geometry){const r=[];for(const t of i)r.push(new e.P(t[0],t[1]));t.push(r)}return t}}toGeoJSON(e,t,i){return v.call(this,e,t,i)}}class b{constructor(t,i){this.name=t,this.extent=e.al,this.length=i.length,this._jsonFeatures=i}feature(e){return new x(this._jsonFeatures[e])}}class w{constructor(t){this.layers={},this.extent=e.al;for(const e of Object.keys(t))this.layers[e]=new b(e,t[e])}}const T=64/4096,E=128;class C{constructor(){this.features=new Map}clear(){this.features.clear()}load(e=[],t){for(const i of e){const e=i.id;if(null==e)continue;let r=this.features.get(e);r&&this.updateCache(r,t),i.geometry?(r=S(i),this.updateCache(r,t),this.features.set(e,r)):this.features.delete(e),this.updateCache(r,t)}}updateCache(e,t){for(const{canonical:i,uid:r}of Object.values(t)){const{z:n,x:o,y:s}=i;B(e,Math.pow(2,n),o,s)&&delete t[r]}}getTile(e,t,i){const r=Math.pow(2,e),n=[];for(const e of this.features.values())B(e,r,t,i)&&n.push(R(e,r,t,i));return{features:n}}getFeatures(){return[...this.features.values()]}}function B({minX:e,minY:t,maxX:i,maxY:r},n,o,s){return e<(o+1+T)/n&&t<(s+1+T)/n&&i>(o-T)/n&&r>(s-T)/n}function S(e){const{id:t,geometry:i,properties:r}=e;if(!i)return;if("GeometryCollection"===i.type)throw new Error("GeometryCollection not supported in dynamic mode.");const{type:n,coordinates:o}=i,s={id:t,type:1,geometry:[],tags:r,minX:1/0,minY:1/0,maxX:-1/0,maxY:-1/0},a=s.geometry;if("Point"===n)I(o,a,s);else if("MultiPoint"===n)for(const e of o)I(e,a,s);else if("LineString"===n)s.type=2,M(o,a,s);else if("MultiLineString"===n)s.type=2,P(o,a,s);else if("Polygon"===n)s.type=3,P(o,a,s,!0);else{if("MultiPolygon"!==n)throw new Error("Input data is not a valid GeoJSON object.");s.type=3;for(const e of o)P(e,a,s,!0)}return s}function I([t,i],r,n){const o=e.aF(t);let s=e.aJ(i);s=s<0?0:s>1?1:s,r.push(o,s),n.minX=Math.min(n.minX,o),n.minY=Math.min(n.minY,s),n.maxX=Math.max(n.maxX,o),n.maxY=Math.max(n.maxY,s)}function M(e,t,i,r=!1,n=!1){const o=[];for(const t of e)I(t,o,i);t.push(o),r&&function(e,t){let i=0;for(let t=0,r=e.length,n=r-2;t0===t)for(let t=0,i=e.length;t=a&&d>=a||(u>=a?(h+=Math.round(m*((a-u)/f)),u=a):d>=a&&(p=h+Math.round(m*((a-u)/f)),d=a),h>=a&&p>=a||(h>=a?(u+=Math.round(f*((a-h)/m)),h=a):p>=a&&(d=u+Math.round(f*((a-h)/m)),p=a),l&&u===l[l.length-1][0]&&h===l[l.length-1][1]||(l=[[u,h]],o.push(l)),l.push([d,p])))))}}function F({name:t,features:i},r){r.writeStringField(1,t),r.writeVarintField(5,e.al);const n=new Map,o=new Map,s={keys:n,values:o,feature:null};for(const e of i)s.feature=e,r.writeMessage(2,k,s);for(const e of n.keys())r.writeStringField(3,e);for(const e of o.keys())r.writeMessage(4,N,e)}function k(e,t){const i=e.feature;void 0!==i.id&&Number.isSafeInteger(+i.id)&&t.writeVarintField(1,+i.id),i.tags&&t.writeMessage(2,D,e),t.writeVarintField(3,i.type),t.writeMessage(4,U,i)}function D({keys:e,values:t,feature:i},r){for(const n of Object.keys(i.tags)){let o=i.tags[n];if(null===o)continue;let s=e.get(n);void 0===s&&(s=e.size,e.set(n,s)),r.writeVarint(s);const a=typeof o;"string"!==a&&"boolean"!==a&&"number"!==a&&(o=JSON.stringify(o));let l=t.get(o);void 0===l&&(l=t.size,t.set(o,l)),r.writeVarint(l)}}function O(e,t){return(t<<3)+(7&e)}function z(e){return e<<1^e>>31}function U(e,t){const{geometry:i,type:r}=e;let n=0,o=0;if(1===r){t.writeVarint(O(1,i.length));for(const e of i){const i=e[0]-n,r=e[1]-o;t.writeVarint(z(i)),t.writeVarint(z(r)),n+=i,o+=r}}else for(const e of i){t.writeVarint(O(1,1));const i=e.length-(3===r?1:0);for(let r=0;re},j=Math.fround||(G=new Float32Array(1),e=>(G[0]=+e,G[0]));var G;const H=3,Q=5,$=6;class Z{constructor(e){this.options=Object.assign(Object.create(V),e),this.trees=new Array(this.options.maxZoom+1),this.stride=this.options.reduce?7:6,this.clusterProps=[]}load(e){const{log:t,minZoom:i,maxZoom:r}=this.options;t&&console.time("total time");const n=`prepare ${e.length} points`;t&&console.time(n),this.points=e;const o=[];for(let t=0;t=i;e--){const i=+Date.now();s=this.trees[e]=this._createTree(this._cluster(s,e)),t&&console.log("z%d: %d clusters in %dms",e,s.numItems,+Date.now()-i)}return t&&console.timeEnd("total time"),this}getClusters(e,t){let i=((e[0]+180)%360+360)%360-180;const r=Math.max(-90,Math.min(90,e[1]));let n=180===e[2]?180:((e[2]+180)%360+360)%360-180;const o=Math.max(-90,Math.min(90,e[3]));if(e[2]-e[0]>=360)i=-180,n=180;else if(i>n){const e=this.getClusters([i,r,180,o],t),s=this.getClusters([-180,r,n,o],t);return e.concat(s)}const s=this.trees[this._limitZoom(t)],a=s.range(K(i),X(o),K(n),X(r)),l=s.data,c=[];for(const e of a){const t=this.stride*e;c.push(l[t+Q]>1?W(l,t,this.clusterProps):this.points[l[t+H]])}return c}getChildren(e){const t=this._getOriginId(e),i=this._getOriginZoom(e),r="No cluster with the specified id.",n=this.trees[i];if(!n)throw new Error(r);const o=n.data;if(t*this.stride>=o.length)throw new Error(r);const s=this.options.radius/(this.options.extent*Math.pow(2,i-1)),a=n.within(o[t*this.stride],o[t*this.stride+1],s),l=[];for(const t of a){const i=t*this.stride;o[i+4]===e&&l.push(o[i+Q]>1?W(o,i,this.clusterProps):this.points[o[i+H]])}if(0===l.length)throw new Error(r);return l}getLeaves(e,t,i){const r=[];return this._appendLeaves(r,e,t=t||10,i=i||0,0),r}getTile(e,t,i){const r=this.trees[this._limitZoom(e)],n=Math.pow(2,e),{extent:o,radius:s}=this.options,a=s/o,l=(i-a)/n,c=(i+1+a)/n,u={features:[]};return this._addTileFeatures(r.range((t-a)/n,l,(t+1+a)/n,c),r.data,t,i,n,u),0===t&&this._addTileFeatures(r.range(1-a/n,l,1,c),r.data,n,i,n,u),t===n-1&&this._addTileFeatures(r.range(0,l,a/n,c),r.data,-1,i,n,u),u.features.length?u:null}getClusterExpansionZoom(e){let t=this._getOriginZoom(e)-1;for(;t<=this.options.maxZoom;){const i=this.getChildren(e);if(t++,1!==i.length)break;e=i[0].properties.cluster_id}return t}_appendLeaves(e,t,i,r,n){const o=this.getChildren(t);for(const t of o){const o=t.properties;if(o&&o.cluster?n+o.point_count<=r?n+=o.point_count:n=this._appendLeaves(e,o.cluster_id,i,r,n):n1;let l,c,u;if(a)l=q(t,e,this.clusterProps),c=t[e],u=t[e+1];else{const i=this.points[t[e+H]];l=i.properties;const[r,n]=i.geometry.coordinates;c=K(r),u=X(n)}const h={type:1,geometry:[[Math.round(this.options.extent*(c*n-i)),Math.round(this.options.extent*(u*n-r))]],tags:l};let d;d=a||this.options.generateId?t[e+H]:this.points[t[e+H]].id,void 0!==d&&(h.id=d),o.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:i,extent:r,reduce:n,minPoints:o}=this.options,s=i/(r*Math.pow(2,t)),a=e.data,l=[],c=this.stride;for(let i=0;it&&(p+=a[i+Q])}if(p>d&&p>=o){let e,o=r*d,s=u*d,f=-1;const m=(i/c<<5)+(t+1)+this.points.length;for(const r of h){const l=r*c;if(a[l+2]<=t)continue;a[l+2]=t;const u=a[l+Q];o+=a[l]*u,s+=a[l+1]*u,a[l+4]=m,n&&(e||(e=this._map(a,i,!0),f=this.clusterProps.length,this.clusterProps.push(e)),n(e,this._map(a,l)))}a[i+4]=m,l.push(o/p,s/p,1/0,m,-1,p),n&&l.push(f)}else{for(let e=0;e1)for(const e of h){const i=e*c;if(!(a[i+2]<=t)){a[i+2]=t;for(let e=0;e>5}_getOriginZoom(e){return(e-this.points.length)%32}_map(e,t,i){if(e[t+Q]>1){const r=this.clusterProps[e[t+$]];return i?Object.assign({},r):r}const r=this.points[e[t+H]].properties,n=this.options.map(r);return i&&n===r?Object.assign({},n):n}}function W(e,t,i){return{type:"Feature",id:e[t+H],properties:q(e,t,i),geometry:{type:"Point",coordinates:[(r=e[t],360*(r-.5)),J(e[t+1])]}};var r}function q(e,t,i){const r=e[t+Q],n=r>=1e4?`${Math.round(r/1e3)}k`:r>=1e3?Math.round(r/100)/10+"k":r,o=e[t+$],s=-1===o?{}:Object.assign({},i[o]);return Object.assign(s,{cluster:!0,cluster_id:e[t+H],point_count:r,point_count_abbreviated:n})}function K(e){return e/360+.5}function X(e){const t=Math.sin(e*Math.PI/180),i=.5-.25*Math.log((1+t)/(1-t))/Math.PI;return i<0?0:i>1?1:i}function J(e){const t=(180-360*e)*Math.PI/180;return 360*Math.atan(Math.exp(t))/Math.PI-90}function Y(e,t,i,r){let n=r;const o=t+(i-t>>1);let s,a=i-t;const l=e[t],c=e[t+1],u=e[i],h=e[i+1];for(let r=t+3;rn)s=r,n=t;else if(t===n){const e=Math.abs(r-o);er&&(s-t>3&&Y(e,t,s,r),e[s+2]=n,i-s>3&&Y(e,s,i,r))}function ee(e,t,i,r,n,o){let s=n-i,a=o-r;if(0!==s||0!==a){const l=((e-i)*s+(t-r)*a)/(s*s+a*a);l>1?(i=n,r=o):l>0&&(i+=s*l,r+=a*l)}return s=e-i,a=t-r,s*s+a*a}function te(e,t,i,r){const n={id:e??null,type:t,geometry:i,tags:r,minX:1/0,minY:1/0,maxX:-1/0,maxY:-1/0};if("Point"===t||"MultiPoint"===t||"LineString"===t)ie(n,i);else if("Polygon"===t)ie(n,i[0]);else if("MultiLineString"===t)for(const e of i)ie(n,e);else if("MultiPolygon"===t)for(const e of i)ie(n,e[0]);return n}function ie(e,t){for(let i=0;i0&&(s+=r?(n*l-a*o)/2:Math.sqrt(Math.pow(a-n,2)+Math.pow(l-o,2))),n=a,o=l}const a=t.length-3;t[2]=1,Y(t,0,a,i),t[a+2]=1,t.size=Math.abs(s),t.start=0,t.end=t.size}function se(e,t,i,r){for(let n=0;n1?1:i}function ce(e,t,i,r,n,o,s,a){if(r/=t,o>=(i/=t)&&s=r)return null;const l=[];for(const t of e){const e=t.geometry;let o=t.type;const s=0===n?t.minX:t.minY,c=0===n?t.maxX:t.maxY;if(s>=i&&c=r)continue;let u=[];if("Point"===o||"MultiPoint"===o)ue(e,u,i,r,n);else if("LineString"===o)he(e,u,i,r,n,!1,a.lineMetrics);else if("MultiLineString"===o)pe(e,u,i,r,n,!1);else if("Polygon"===o)pe(e,u,i,r,n,!0);else if("MultiPolygon"===o)for(const t of e){const e=[];pe(t,e,i,r,n,!0),e.length&&u.push(e)}if(u.length){if(a.lineMetrics&&"LineString"===o){for(const e of u)l.push(te(t.id,o,e,t.tags));continue}"LineString"!==o&&"MultiLineString"!==o||(1===u.length?(o="LineString",u=u[0]):o="MultiLineString"),"Point"!==o&&"MultiPoint"!==o||(o=3===u.length?"Point":"MultiPoint"),l.push(te(t.id,o,u,t.tags))}}return l.length?l:null}function ue(e,t,i,r,n){for(let o=0;o=i&&s<=r&&fe(t,e[o],e[o+1],e[o+2])}}function he(e,t,i,r,n,o,s){let a=de(e);const l=0===n?me:ge;let c,u,h=e.start;for(let d=0;di&&(u=l(a,p,f,g,_,i),s&&(a.start=h+c*u)):A>r?y=i&&(u=l(a,p,f,g,_,i),v=!0),y>r&&A<=r&&(u=l(a,p,f,g,_,r),v=!0),!o&&v&&(s&&(a.end=h+c*u),t.push(a),a=de(e)),s&&(h+=c)}let d=e.length-3;const p=e[d],f=e[d+1],m=0===n?p:f;m>=i&&m<=r&&fe(a,p,f,e[d+2]),d=a.length-3,o&&d>=3&&(a[d]!==a[0]||a[d+1]!==a[1])&&fe(a,a[0],a[1],a[2]),a.length&&t.push(a)}function de(e){const t=[];return t.size=e.size,t.start=e.start,t.end=e.end,t}function pe(e,t,i,r,n,o){for(const s of e)he(s,t,i,r,n,o,!1)}function fe(e,t,i,r){e.push(t,i,r)}function me(e,t,i,r,n,o){const s=(o-t)/(r-t);return fe(e,o,i+(n-i)*s,1),s}function ge(e,t,i,r,n,o){const s=(o-i)/(n-i);return fe(e,t+(r-t)*s,o,1),s}function _e(e,t){const i=[];for(let r=0;r0&&t.size<(n?s:r))return void(i.numPoints+=t.length/3);const a=[];for(let e=0;es)&&(i.numSimplified++,a.push(t[e],t[e+1])),i.numPoints++;n&&function(e,t){let i=0;for(let t=0,r=e.length,n=r-2;t0===t)for(let t=0,i=e.length;t24)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 r=function(e,t){const i=[];if("FeatureCollection"===e.type)for(let r=0;r1&&console.time("creation"),d=this.tiles[h]=xe(e,t,i,r,l),this.tileCoords.push({z:t,x:i,y:r}),c)){c>1&&(console.log("tile z%d-%d-%d (features: %d, points: %d, simplified: %d)",t,i,r,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(i!==o>>e||r!==s>>e)continue}}if(d.source=null,0===e.length)continue;c>1&&console.time("clipping");const p=.5*l.buffer/l.extent,f=.5-p,m=.5+p,g=1+p;let _=null,A=null,y=null,v=null,x=ce(e,u,i-p,i+m,0,d.minX,d.maxX,l),b=ce(e,u,i+f,i+g,0,d.minX,d.maxX,l);e=null,x&&(_=ce(x,u,r-p,r+m,1,d.minY,d.maxY,l),A=ce(x,u,r+f,r+g,1,d.minY,d.maxY,l),x=null),b&&(y=ce(b,u,r-p,r+m,1,d.minY,d.maxY,l),v=ce(b,u,r+f,r+g,1,d.minY,d.maxY,l),b=null),c>1&&console.timeEnd("clipping"),a.push(_||[],t+1,2*i,2*r),a.push(A||[],t+1,2*i,2*r+1),a.push(y||[],t+1,2*i+1,2*r),a.push(v||[],t+1,2*i+1,2*r+1)}}getTile(e,t,i){e=+e,t=+t,i=+i;const r=this.options,{extent:n,debug:o}=r;if(e<0||e>24)return null;const s=1<1&&console.log("drilling down to z%d-%d-%d",e,t,i);let l,c=e,u=t,h=i;for(;!l&&c>0;)c--,u>>=1,h>>=1,l=this.tiles[Ce(c,u,h)];return l&&l.source?(o>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,i),o>1&&console.timeEnd("drilling down"),this.tiles[a]?ye(this.tiles[a],n):null):null}}function Ce(e,t,i){return 32*((1<e.tags&&"3d_elevation_id"in e.tags&&"source"in e.tags&&"elevation"===e.tags.source,s=n.features.filter(e=>o(e));let a={_geojsonTileLayer:n.features};s.length>0&&(a={_geojsonTileLayer:n.features.filter(e=>!o(e)),hd_road_elevation:s});const l=new w(a),c=function(t){const i=new e.bs;for(const e of Object.keys(t))i.writeMessage(3,F,{name:e,features:t[e]});return i.finish()}(a).buffer;i(null,{vectorTile:l,rawData:c})}class Se extends g{constructor(e,t,i,r,n,o,s){super(e,t,i,r,n,Be,s),o&&(this.loadGeoJSON=o),this._dynamicIndex=new C}loadData(i,r){const n=i&&i.request,o=n&&n.collectResourceTiming;this._geoJSONIndex=null,this.loadGeoJSON(i,(s,a)=>{if(s||!a)return r(s);if("object"!=typeof a)return r(new Error(`Input data given to '${i.source}' is not a valid GeoJSON object.`));{try{if(i.filter){const t=e.U(i.filter,{type:"boolean","property-type":"data-driven",overridable:!1,transition:!1});if("error"===t.result)throw new Error(t.value.map(e=>`${e.key}: ${e.message}`).join(", "));a.features=a.features.filter(e=>t.value.evaluate({zoom:0},e))}i.dynamic?("Feature"===a.type&&(a={type:"FeatureCollection",features:[a]}),i.append||(this._dynamicIndex.clear(),this.loaded={}),this._dynamicIndex.load(a.features,this.loaded),i.cluster&&(a.features=this._dynamicIndex.getFeatures())):this.loaded={},this._geoJSONIndex=i.cluster?new Z(function({superclusterOptions:t,clusterProperties:i}){if(!i||!t)return t;const r={},n={},o={accumulated:null,zoom:0},s={properties:null},a=Object.keys(i);for(const t of a){const[o,s]=i[t],a=e.U(s),l=e.U("string"==typeof o?[o,["accumulated"],["get",t]]:o);r[t]=a.value,n[t]=l.value}return t.map=e=>{s.properties=e;const t={};for(const e of a)t[e]=r[e].evaluate(o,s);return t},t.reduce=(e,t)=>{s.properties=t;for(const t of a)o.accumulated=e[t],e[t]=n[t].evaluate(o,s)},t}(i)).load(a.features):i.dynamic?this._dynamicIndex:function(e,t){return new Ee(e,t)}(a,i.geojsonVtOptions)}catch(e){return r(e)}const s={};if(o){const e=t(n);e&&(s.resourceTiming={},s.resourceTiming[i.source]=JSON.parse(JSON.stringify(e)))}r(null,s)}})}reloadTile(e,t){const i=this.loaded;return i&&i[e.uid]?e.partial?t(null,void 0):super.reloadTile(e,t):this.loadTile(e,t)}loadGeoJSON(t,i){if(t.request)e.m(t.request,i);else{if("string"!=typeof t.data)return i(new Error(`Input data given to '${t.source}' is not a valid GeoJSON object.`));setTimeout(()=>{try{return i(null,JSON.parse(t.data))}catch(e){return i(new Error(`Input data given to '${t.source}' is not a valid GeoJSON object.`))}},0)}}getClusterExpansionZoom(e,t){try{t(null,this._geoJSONIndex.getClusterExpansionZoom(e.clusterId))}catch(e){t(e)}}getClusterChildren(e,t){try{t(null,this._geoJSONIndex.getChildren(e.clusterId))}catch(e){t(e)}}getClusterLeaves(e,t){try{t(null,this._geoJSONIndex.getLeaves(e.clusterId,e.limit,e.offset))}catch(e){t(e)}}}class Ie{constructor(t,i,r){this.tileID=new e.aP(t.tileID.overscaledZ,t.tileID.wrap,t.tileID.canonical.z,t.tileID.canonical.x,t.tileID.canonical.y),this.tileZoom=t.tileZoom,this.uid=t.uid,this.zoom=t.zoom,this.canonical=t.tileID.canonical,this.pixelRatio=t.pixelRatio,this.tileSize=t.tileSize,this.source=t.source,this.overscaling=this.tileID.overscaleFactor(),this.projection=t.projection,this.brightness=i,this.worldview=r}parse(t,i,r,n){this.status="parsing";const o=new e.aP(r.tileID.overscaledZ,r.tileID.wrap,r.tileID.canonical.z,r.tileID.canonical.x,r.tileID.canonical.y),s=[],a=i.familiesBySource[r.source],l=new e.fm(o,r.promoteId);l.bucketLayerIDs=[],l.is3DTile=!0,e.fB(t).then(t=>{if(!t)return n(new Error("Could not parse tile"));const i=t.json.extensionsUsed&&t.json.extensionsUsed.includes("MAPBOX_mesh_features")||t.json.asset.extras&&t.json.asset.extras.MAPBOX_mesh_features,c=t.json.extensionsUsed&&t.json.extensionsUsed.includes("EXT_meshopt_compression"),u=new e.ac(this.zoom,{brightness:this.brightness,worldview:this.worldview});for(const n in a)for(const h of a[n]){const n=h[0];l.bucketLayerIDs.push(h.map(t=>e.B(t.id,t.scope))),n.recalculate(u,[]);const a=e.fC(t,1/e.d6(r.tileID.canonical)),d=new e.fD(h,a,o,i,c,this.brightness,l,this.worldview);i||(d.needsUpload=!0),s.push(d),d.evaluate(n)}this.status="done",n(null,{buckets:s,featureIndex:l,collisionBoxArray:null,glyphAtlasImage:null,lineAtlas:null,imageAtlas:null,brightness:null})}).catch(e=>n(new Error(e.message)))}}class Me{constructor(e,t,i,r,n,o,s,a){this.actor=e,this.layerIndex=t,this.availableImages=i,this.availableModels=r,this.brightness=s,this.loading={},this.loaded={},this.worldview=a}loadTile(t,i){const r=t.uid,n=this.loading[r]=new Ie(t,this.brightness,this.worldview);e.bt(t.request,(e,o)=>{const s=!this.loading[r];return delete this.loading[r],s||e?(n.status="done",s||(this.loaded[r]=n),i(e)):o&&0!==o.byteLength?void n.parse(o,this.layerIndex,t,(e,t)=>{n.status="done",this.loaded=this.loaded||{},this.loaded[r]=n,e||!t?i(e):i(null,t)}):(n.status="done",this.loaded[r]=n,i())})}reloadTile(e,t){const i=this.loaded,r=e.uid;if(i&&i[r]){const n=i[r];n.projection=e.projection,n.brightness=e.brightness;const o=(i,r)=>{n.reloadCallback&&(delete n.reloadCallback,this.loadTile(e,t)),t(i,r)};"parsing"===n.status?n.reloadCallback=o:"done"===n.status&&this.loadTile(e,t)}}abortTile(e,t){const i=e.uid;this.loading[i]&&delete this.loading[i],t()}removeTile(e,t){const i=this.loaded,r=e.uid;i&&i[r]&&delete i[r],t()}}class Pe{constructor(t){this.self=t,this.actor=new e.fF(t,this),this.layerIndexes={},this.availableImages={},this.availableModels={},this.isSpriteLoaded={},this.imageRasterizer=new e.x,this.rtlPluginParsingListeners=[],this.projections={},this.defaultProjection=e.cl({name:"mercator"}),this.workerSourceTypes={vector:g,geojson:Se,"raster-dem":_,"raster-array":y,"batched-model":Me},this.workerSources={},this.self.registerWorkerSource=(e,t)=>{if(this.workerSourceTypes[e])throw new Error(`Worker source with name "${e}" already registered.`);this.workerSourceTypes[e]=t},this.self.registerRTLTextPlugin=t=>{if(e.fG.isParsed())throw new Error("RTL text plugin already registered.");e.fG.setState({pluginStatus:e.fH.parsed,pluginURL:e.fG.getPluginURL()}),e.fG.applyArabicShaping=t.applyArabicShaping,e.fG.processBidirectionalText=t.processBidirectionalText,e.fG.processStyledBidirectionalText=t.processStyledBidirectionalText;for(const e of this.rtlPluginParsingListeners)e(null,!0);this.rtlPluginParsingListeners=[]}}clearCaches(e,t,i){delete this.layerIndexes[e],delete this.availableImages[e],delete this.availableModels[e],delete this.workerSources[e],i()}checkIfReady(e,t,i){i()}setReferrer(e,t){this.referrer=t}spriteLoaded(t,i){this.isSpriteLoaded[t]||(this.isSpriteLoaded[t]={});const{scope:r,isLoaded:n}=i;if(this.isSpriteLoaded[t][r]=n,this.workerSources[t]&&this.workerSources[t][r])for(const i in this.workerSources[t][r]){const o=this.workerSources[t][r][i];for(const t in o){const i=o[t];i instanceof g&&(i.isSpriteLoaded=n,i.fire(new e.z("isSpriteLoaded")))}}}setImages(e,t,i){this.availableImages[e]||(this.availableImages[e]={});const{scope:r,images:n}=t;if(this.availableImages[e][r]=n,this.workerSources[e]&&this.workerSources[e][r]){for(const t in this.workerSources[e][r]){const i=this.workerSources[e][r][t];for(const e in i)i[e].availableImages=n}i()}else i()}setModels(e,{scope:t,models:i},r){if(this.availableModels[e]||(this.availableModels[e]={}),this.availableModels[e][t]=i,this.workerSources[e]&&this.workerSources[e][t]){for(const r in this.workerSources[e][t]){const n=this.workerSources[e][t][r];for(const e in n)n[e].availableModels=i}r()}else r()}setProjection(t,i){this.projections[t]=e.cl(i)}setBrightness(e,t,i){this.brightness=t,i()}setWorldview(e,t,i){this.worldview=t,i()}setLayers(e,t,i){this.getLayerIndex(e,t.scope).replace(t.layers,t.options),i()}updateLayers(e,t,i){this.getLayerIndex(e,t.scope).update(t.layers,t.removedIds,t.options),i()}loadTile(e,t,i){t.projection=this.projections[e]||this.defaultProjection,this.getWorkerSource(e,t.type,t.source,t.scope).loadTile(t,i)}decodeRasterArray(e,t,i){this.getWorkerSource(e,t.type,t.source,t.scope).decodeRasterArray(t,i)}reloadTile(e,t,i){t.projection=this.projections[e]||this.defaultProjection,this.getWorkerSource(e,t.type,t.source,t.scope).reloadTile(t,i)}abortTile(e,t,i){this.getWorkerSource(e,t.type,t.source,t.scope).abortTile(t,i)}removeTile(e,t,i){this.getWorkerSource(e,t.type,t.source,t.scope).removeTile(t,i)}removeSource(e,t,i){if(!(this.workerSources[e]&&this.workerSources[e][t.scope]&&this.workerSources[e][t.scope][t.type]&&this.workerSources[e][t.scope][t.type][t.source]))return;const r=this.workerSources[e][t.scope][t.type][t.source];delete this.workerSources[e][t.scope][t.type][t.source],void 0!==r.removeSource?r.removeSource(t,i):i()}loadWorkerSource(e,t,i){try{this.self.importScripts(t.url),i()}catch(e){i(e.toString())}}syncRTLPluginState(t,i,r){if(e.fG.isParsed())r(null,!0);else if(e.fG.isParsing())this.rtlPluginParsingListeners.push(r);else try{e.fG.setState(i);const t=e.fG.getPluginURL();!e.fG.isLoaded()||e.fG.isParsed()||e.fG.isParsing()||null==t||(e.fG.setState({pluginStatus:e.fH.parsing,pluginURL:e.fG.getPluginURL()}),this.self.importScripts(t),e.fG.isParsed()?r(null,!0):this.rtlPluginParsingListeners.push(r))}catch(e){r(e.toString())}}setDracoUrl(e,t){this.dracoUrl=t}getAvailableImages(e,t){this.availableImages[e]||(this.availableImages[e]={});let i=this.availableImages[e][t];return i||(i=[]),i}getAvailableModels(e,t){this.availableModels[e]||(this.availableModels[e]={});let i=this.availableModels[e][t];return i||(i={}),i}getLayerIndex(e,t){this.layerIndexes[e]||(this.layerIndexes[e]={});let i=this.layerIndexes[e][t];return i||(i=this.layerIndexes[e][t]=new n,i.scope=t),i}getWorkerSource(e,t,i,r){const n=this.workerSources;return n[e]||(n[e]={}),n[e][r]||(n[e][r]={}),n[e][r][t]||(n[e][r][t]={}),this.isSpriteLoaded[e]||(this.isSpriteLoaded[e]={}),n[e][r][t][i]||(n[e][r][t][i]=new this.workerSourceTypes[t]({send:(t,i,r,n,o,s)=>this.actor.send(t,i,r,e,o,s),scheduler:this.actor.scheduler},this.getLayerIndex(e,r),this.getAvailableImages(e,r),this.getAvailableModels(e,r),this.isSpriteLoaded[e][r],void 0,this.brightness,this.worldview)),n[e][r][t][i]}rasterizeImagesWorker(e,t,i){const r=new Map;for(const[i,{image:n,imageVariant:o}]of t.tasks.entries()){const s=this.imageRasterizer.rasterize(o,n,t.scope,e);r.set(i,s)}i(void 0,r)}removeRasterizedImages(e,t,i){this.imageRasterizer.removeImagesFromCacheByIds(t.imageIds,t.scope,e),i()}enforceCacheSizeLimit(t,i){e.fI(i)}getWorkerPerformanceMetrics(e,t,i){i(void 0,void 0)}}return e.fE(self)&&(self.worker=new Pe(self)),Pe}),r(["./shared"],function(e){var t="3.16.0";const i={create:"create",load:"load",fullLoad:"fullLoad"},r={mark(e){performance.mark(e)},measure(e,t,i){performance.measure(e,t,i)}};function n(t){const i=t.name.split("?")[0];return e.a(i)&&i.includes("mapbox-gl.js")?"javascript":e.a(i)&&i.includes("mapbox-gl.css")?"css":e.b(i)?"fontRange":e.c(i)?"sprite":e.i(i)?"style":e.d(i)?"tilejson":"other"}var o,s={},a=function(){if(o)return s;function e(e){return!t(e)}function t(t){return"undefined"==typeof window||"undefined"==typeof document?"not a browser":function(){if(!("Worker"in window&&"Blob"in window&&"URL"in window))return!1;var e,t,i=new Blob([""],{type:"text/javascript"}),r=URL.createObjectURL(i);try{t=new Worker(r),e=!0}catch(t){e=!1}return t&&t.terminate(),URL.revokeObjectURL(r),e}()?function(){var e=document.createElement("canvas");e.width=e.height=1;var t=e.getContext("2d");if(!t)return!1;var i=t.getImageData(0,0,1,1);return i&&i.width===e.width}()?(void 0===i[r=t&&t.failIfMajorPerformanceCaveat]&&(i[r]=function(t){var i,r=function(t){var i=document.createElement("canvas"),r=Object.create(e.webGLContextAttributes);return r.failIfMajorPerformanceCaveat=t,i.getContext("webgl2",r)}(t);if(!r)return!1;try{i=r.createShader(r.VERTEX_SHADER)}catch(e){return!1}return!(!i||r.isContextLost())&&(r.shaderSource(i,"void main() {}"),r.compileShader(i),!0===r.getShaderParameter(i,r.COMPILE_STATUS))}(r)),i[r]?document.documentMode?"insufficient ECMAScript 6 support":void 0:"insufficient WebGL2 support"):"insufficient Canvas/getImageData support":"insufficient worker support";var r}o=1,s.supported=e,s.notSupportedReason=t;var i={};return e.webGLContextAttributes={antialias:!1,alpha:!0,stencil:!0,depth:!0},s}();function l(e,t,i){const r=document.createElement(e);return null!=t&&(r.className=t),i&&i.appendChild(r),r}function c(e,t,i){const r=document.createElementNS("http://www.w3.org/2000/svg",e);for(const e of Object.keys(t))r.setAttributeNS(null,e,String(t[e]));return i&&i.appendChild(r),r}const u="undefined"!=typeof document?document.documentElement&&document.documentElement.style:null,h=u&&void 0!==u.userSelect?"userSelect":"WebkitUserSelect";let d;function p(){u&&h&&(d=u[h],u[h]="none")}function f(){u&&h&&(u[h]=d)}function m(e){e.preventDefault(),e.stopPropagation(),window.removeEventListener("click",m,!0)}function g(){window.addEventListener("click",m,!0),window.setTimeout(()=>{window.removeEventListener("click",m,!0)},0)}function _(e,t){const i=e.getBoundingClientRect();return v(e,i,t)}function A(e,t){const i=e.getBoundingClientRect(),r=[];for(let n=0;nthis._skuTokenExpiresAt}transformRequest(e,t){return this._transformRequestFn&&this._transformRequestFn(e,t)||{url:e}}normalizeStyleURL(i,r){if(!e.h(i))return i;const n=E(i);return n.params.push(`sdk=js-${t}`),n.path=`/styles/v1${n.path}`,this._makeAPIURL(n,this._customAccessToken||r)}normalizeGlyphsURL(t,i){if(!e.h(t))return t;const r=E(t);return r.path=`/fonts/v1${r.path}`,this._makeAPIURL(r,this._customAccessToken||i)}normalizeModelURL(t,i){if(!e.h(t))return t;const r=E(t);return r.path=`/models/v1${r.path}`,this._makeAPIURL(r,this._customAccessToken||i)}normalizeSourceURL(t,i,r,n){if(!e.h(t))return t;const o=E(t);return o.path=`/v4/${o.authority}.json`,o.params.push("secure"),r&&o.params.push(`language=${r}`),n&&o.params.push(`worldview=${n}`),this._makeAPIURL(o,this._customAccessToken||i)}normalizeIconsetURL(t,i){const r=E(t);return e.h(t)?(r.path=`/styles/v1${r.path}/iconset.pbf`,this._makeAPIURL(r,this._customAccessToken||i)):C(r)}normalizeSpriteURL(t,i,r,n){const o=E(t);return e.h(t)?(o.path=`/styles/v1${o.path}/sprite${i}${r}`,this._makeAPIURL(o,this._customAccessToken||n)):(o.path+=`${i}${r}`,C(o))}normalizeTileURL(t,i,r){if(this._isSkuTokenExpired()&&this._createSkuToken(),t&&!e.h(t))return t;const n=E(t);n.path=n.path.replace(/(\.(png|jpg)\d*)(?=$)/,`${i||r&&"raster"!==n.authority&&512===r?"@2x":""}${e.k.supported?".webp":"$1"}`),"raster"===n.authority?n.path=`/${e.e.RASTER_URL_PREFIX}${n.path}`:"rasterarrays"===n.authority?n.path=`/${e.e.RASTERARRAYS_URL_PREFIX}${n.path}`:"3dtiles"===n.authority?n.path=`/${e.e.TILES3D_URL_PREFIX}${n.path}`:(n.path=n.path.replace(/^.+\/v4\//,"/"),n.path=`/${e.e.TILE_URL_VERSION}${n.path}`);const o=this._customAccessToken||function(e){for(const t of e){const e=t.match(/^access_token=(.*)$/);if(e)return e[1]}return null}(n.params)||e.e.ACCESS_TOKEN;return e.e.REQUIRE_ACCESS_TOKEN&&o&&this._skuToken&&n.params.push(`sku=${this._skuToken}`),this._makeAPIURL(n,o)}canonicalizeTileURL(t,i){const r=E(t);if(!r.path.match(/^(\/v4\/|\/(raster|rasterarrays)\/v1\/)/)||!r.path.match(/\.[\w]+$/))return t;let n="mapbox://";r.path.match(/^\/raster\/v1\//)?n+=`raster/${r.path.replace(`/${e.e.RASTER_URL_PREFIX}/`,"")}`:r.path.match(/^\/rasterarrays\/v1\//)?n+=`rasterarrays/${r.path.replace(`/${e.e.RASTERARRAYS_URL_PREFIX}/`,"")}`:n+=`tiles/${r.path.replace(`/${e.e.TILE_URL_VERSION}/`,"")}`;let o=r.params;return i&&(o=o.filter(e=>!e.match(/^access_token=/))),o.length&&(n+=`?${o.join("&")}`),n}canonicalizeTileset(t,i){const r=!!i&&e.h(i),n=[];for(const i of t.tiles||[])e.j(i)?n.push(this.canonicalizeTileURL(i,r)):n.push(i);return n}_makeAPIURL(t,i){const r="See https://docs.mapbox.com/api/overview/#access-tokens-and-token-scopes",n=E(e.e.API_URL);if(t.protocol=n.protocol,t.authority=n.authority,"http"===t.protocol){const e=t.params.indexOf("secure");e>=0&&t.params.splice(e,1)}if("/"!==n.path&&(t.path=`${n.path}${t.path}`),!e.e.REQUIRE_ACCESS_TOKEN)return C(t);if(i=i||e.e.ACCESS_TOKEN,!this._silenceAuthErrors){if(!i)throw new Error(`An API access token is required to use Mapbox GL. ${r}`);if("s"===i[0])throw new Error(`Use a public access token (pk.*) with Mapbox GL, not a secret access token (sk.*). ${r}`)}return t.params=t.params.filter(e=>-1===e.indexOf("access_token")),t.params.push(`access_token=${i||""}`),C(t)}}const T=/^(\w+):\/\/([^/?]*)(\/[^?]+)?\??(.+)?/;function E(e){const t=e.match(T);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 C(e){const t=e.params.length?`?${e.params.join("&")}`:"";return`${e.protocol}://${e.authority}${e.path}${t}`}const B="mapbox.eventData";function S(t){if(!t)return null;const i=t.split(".");if(!i||3!==i.length)return null;try{return JSON.parse(e.l(i[1]))}catch(e){return null}}class I{constructor(e){this.type=e,this.anonId=null,this.anonIdTimestamp=null,this.eventData={},this.queue=[],this.pendingRequest=null}getStorageKey(t){const i=S(e.e.ACCESS_TOKEN);let r="";return r=i&&i.u?e.f(i.u):e.e.ACCESS_TOKEN||"",t?`${B}.${t}:${r}`:`${B}:${r}`}fetchEventData(){const t=e.s("localStorage"),i=this.getStorageKey(),r=this.getStorageKey("uuid"),n=this.getStorageKey("uuidTimestamp");if(t)try{const e=localStorage.getItem(i);e&&(this.eventData=JSON.parse(e));const t=localStorage.getItem(r);t&&(this.anonId=t);const o=localStorage.getItem(n);o&&(this.anonIdTimestamp=Number(o));const s=Date.now()-864e5;(!this.anonIdTimestamp||this.anonIdTimestamp=1&&localStorage.setItem(i,JSON.stringify(this.eventData)),s&&localStorage.setItem(n,s.toString())}catch(t){e.w("Unable to write to LocalStorage")}}processRequests(e){}postEvent(t,i,r,n){if(!e.e.EVENTS_URL)return;const o=E(e.e.EVENTS_URL);o.params.push(`access_token=${n||e.e.ACCESS_TOKEN||""}`);const s={event:this.type,created:new Date(t).toISOString()},a=i?Object.assign(s,i):s,l={url:C(o),headers:{"Content-Type":"text/plain"},body:JSON.stringify([a])};this.pendingRequest=e.p(l,e=>{this.pendingRequest=null,r(e),this.saveEventData(),this.processRequests(n)})}queueRequest(e,t){this.queue.push(e),this.processRequests(t)}}const M=new class extends I{constructor(e){super("appUserTurnstile"),this._customAccessToken=e}postTurnstileEvent(t,i){e.e.EVENTS_URL&&e.e.ACCESS_TOKEN&&Array.isArray(t)&&t.some(t=>e.h(t)||e.j(t))&&this.queueRequest(Date.now(),i)}processRequests(i){if(this.pendingRequest||0===this.queue.length)return;this.anonId&&this.anonIdTimestamp&&this.eventData.lastSuccess&&this.eventData.tokenU||this.fetchEventData();const r=S(e.e.ACCESS_TOKEN),n=r?r.u:e.e.ACCESS_TOKEN;let o=n!==this.eventData.tokenU;e.v(this.anonId)||(this.refreshUUID(),o=!0);const s=this.queue.shift();if(this.eventData.lastSuccess){const e=new Date(this.eventData.lastSuccess),t=new Date(s),i=(s-this.eventData.lastSuccess)/864e5;o=o||i>=1||i<-1||e.getDate()!==t.getDate()}else o=!0;o?this.postEvent(s,{sdkIdentifier:"mapbox-gl-js",sdkVersion:t,skuId:x,"enabled.telemetry":!1,userId:this.anonId},e=>{e||(this.eventData.lastSuccess=s,this.eventData.tokenU=n)},i):this.processRequests()}},P=M.postTurnstileEvent.bind(M),R=new class extends I{constructor(){super("map.load"),this.success={},this.skuToken=""}postMapLoadEvent(t,i,r,n){this.skuToken=i,this.errorCb=n,e.e.EVENTS_URL&&(r||e.e.ACCESS_TOKEN?this.queueRequest({id:t,timestamp:Date.now()},r):this.errorCb(new Error(b)))}processRequests(i){if(this.pendingRequest||0===this.queue.length)return;const{id:r,timestamp:n}=this.queue.shift();r&&this.success[r]||(this.anonId&&this.anonIdTimestamp||this.fetchEventData(),e.v(this.anonId)||this.refreshUUID(),this.postEvent(n,{sdkIdentifier:"mapbox-gl-js",sdkVersion:t,skuId:x,skuToken:this.skuToken,userId:this.anonId},e=>{e?this.errorCb(e):r&&(this.success[r]=!0)},i))}remove(){this.errorCb=null}},L=R.postMapLoadEvent.bind(R),F=new class extends I{constructor(){super("style.load"),this.eventIdPerMapInstanceMap=new Map,this.mapInstanceIdMap=new WeakMap}getMapInstanceId(t){let i=this.mapInstanceIdMap.get(t);return i||(i=e.u(),this.mapInstanceIdMap.set(t,i)),i}getEventId(e){const t=this.eventIdPerMapInstanceMap.get(e)||0;return this.eventIdPerMapInstanceMap.set(e,t+1),t}postStyleLoadEvent(t,i){const{map:r,style:n,importedStyles:o}=i;if(!e.e.EVENTS_URL||!t&&!e.e.ACCESS_TOKEN)return;const s=this.getMapInstanceId(r),a={mapInstanceId:s,eventId:this.getEventId(s),style:n};o.length&&(a.importedStyles=o),this.queueRequest({timestamp:Date.now(),payload:a},t)}processRequests(e){if(this.pendingRequest||0===this.queue.length)return;const{timestamp:t,payload:i}=this.queue.shift();this.postEvent(t,i,()=>{},e)}},k=F.postStyleLoadEvent.bind(F),D=new class extends I{constructor(e){super("metrics"),e&&(this.data=e)}postMetricsEvent(t){if(!e.e.EVENTS_URL||!t&&!e.e.ACCESS_TOKEN)return;this.anonId||this.fetchEventData(),e.v(this.anonId)||this.refreshUUID();const i=Object.assign({},this.data,{sessionId:this.anonId});this.queueRequest({timestamp:Date.now(),payload:i},t)}processRequests(e){if(this.pendingRequest||0===this.queue.length)return;const{timestamp:t,payload:i}=this.queue.shift();this.postEvent(t,i,()=>{},e)}}({attributes:[{name:"maps/js/layer-animations/style-with-appearances"}]}),O=D.postMetricsEvent.bind(D),z=new class extends I{constructor(){super("gljs.performance")}postPerformanceEvent(t,i){e.e.EVENTS_URL&&(t||e.e.ACCESS_TOKEN)&&this.queueRequest({timestamp:Date.now(),performanceData:i},t)}processRequests(r){if(this.pendingRequest||0===this.queue.length)return;const{timestamp:o,performanceData:s}=this.queue.shift(),a=function(r){const o=performance.getEntriesByType("resource"),s=performance.getEntriesByType("mark"),a=function(e){const t={};if(e)for(const i in e)if("other"!==i)for(const r of e[i]){const e=`${i}ResolveRangeMin`,n=`${i}ResolveRangeMax`,o=`${i}RequestCount`,s=`${i}RequestCachedCount`;t[e]=Math.min(t[e]||1/0,r.startTime),t[n]=Math.max(t[n]||-1/0,r.responseEnd);const a=e=>{void 0===t[e]&&(t[e]=0),++t[e]};void 0!==r.transferSize&&0===r.transferSize&&a(s),a(o)}return t}(function(e,t){const i={};if(e)for(const r of e){const e=t(r);void 0===i[e]&&(i[e]=[]),i[e].push(r)}return i}(o,n)),l=window.devicePixelRatio,c=navigator.connection||navigator.mozConnection||navigator.webkitConnection,u=c?c.effectiveType:void 0,h={counters:[],metadata:[],attributes:[]},d=(e,t,i)=>{null!=i&&e.push({name:t,value:i.toString()})};for(const e in a)d(h.counters,e,a[e]);if(r.interactionRange[0]!==1/0&&r.interactionRange[1]!==-1/0&&(d(h.counters,"interactionRangeMin",r.interactionRange[0]),d(h.counters,"interactionRangeMax",r.interactionRange[1])),s)for(const e of Object.values(i)){const t=s.find(t=>t.name===e);t&&d(h.counters,e,t.startTime)}return d(h.counters,"visibilityHidden",r.visibilityHidden),d(h.attributes,"style",function(t){if(t)for(const i of t){const t=i.name.split("?")[0];if(e.i(t)){const e=t.split("/").slice(-2);if(2===e.length)return`mapbox://styles/${e[0]}/${e[1]}`}}}(o)),d(h.attributes,"terrainEnabled",r.terrainEnabled?"true":"false"),d(h.attributes,"fogEnabled",r.fogEnabled?"true":"false"),d(h.attributes,"projection",r.projection),d(h.attributes,"zoom",r.zoom),d(h.metadata,"devicePixelRatio",l),d(h.metadata,"connectionEffectiveType",u),d(h.metadata,"navigatorUserAgent",navigator.userAgent),d(h.metadata,"screenWidth",window.screen.width),d(h.metadata,"screenHeight",window.screen.height),d(h.metadata,"windowWidth",window.innerWidth),d(h.metadata,"windowHeight",window.innerHeight),d(h.metadata,"mapWidth",r.width/l),d(h.metadata,"mapHeight",r.height/l),d(h.metadata,"webglRenderer",r.renderer),d(h.metadata,"webglVendor",r.vendor),d(h.metadata,"sdkVersion",t),d(h.metadata,"sdkIdentifier","mapbox-gl-js"),h}(s);for(const e of a.metadata);for(const e of a.counters);for(const e of a.attributes);this.postEvent(o,a,()=>{},r)}},U=z.postPerformanceEvent.bind(z),N=new class extends I{constructor(){super("map.auth"),this.success={},this.skuToken=""}getSession(t,i,r,n){if(!e.e.API_URL||!e.e.SESSION_PATH)return;const o=E(e.e.API_URL+e.e.SESSION_PATH);o.params.push(`sku=${i||""}`),o.params.push(`access_token=${n||e.e.ACCESS_TOKEN||""}`);const s={url:C(o),headers:{"Content-Type":"text/plain"}};this.pendingRequest=e.g(s,e=>{this.pendingRequest=null,r(e),this.saveEventData(),this.processRequests(n)})}getSessionAPI(t,i,r,n){this.skuToken=i,this.errorCb=n,e.e.SESSION_PATH&&e.e.API_URL&&(r||e.e.ACCESS_TOKEN?this.queueRequest({id:t,timestamp:Date.now()},r):this.errorCb(new Error(b)))}processRequests(e){if(this.pendingRequest||0===this.queue.length)return;const{id:t,timestamp:i}=this.queue.shift();t&&this.success[t]||this.getSession(i,this.skuToken,e=>{e?this.errorCb(e):t&&(this.success[t]=!0)},e)}remove(){this.errorCb=null}},V=N.getSessionAPI.bind(N),j=new Set;function G(e,t){t?j.add(e):j.delete(e)}class H{constructor(){this._changed=!1,this._updatedLayers={},this._removedLayers={},this._updatedSourceCaches={},this._updatedPaintProps=new Set,this._updatedImages={}}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={},this._removedLayers={},this._updatedSourceCaches={},this._updatedPaintProps.clear(),this._updatedImages={}}}function Q(e){const{userImage:t}=e;return!!(t&&t.render&&t.render())&&(e.data.replace(new Uint8Array(t.data.buffer)),!0)}class $ extends e.E{constructor(t){super(),this.imageProviders=new Map,this.images=new Map,this.updatedImages=new Map,this.callbackDispatchedThisFrame=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.dirty=!0,this.spriteFormat=t,"raster"!==t&&e.r()&&(this.imageRasterizerDispatcher=new e.D(e.t(),this,"Image Rasterizer Worker",1))}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.patterns.set(t,new Map),this.atlasImage.set(t,new e.q({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.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}get imageRasterizer(){return this._imageRasterizer||(this._imageRasterizer=new e.x),this._imageRasterizer}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){this._validate(e,i)&&this.images.get(t).set(e.toString(),i)}_validate(t,i){let r=!0;return this._validateStretch(i.stretchX,i.data&&i.data.width)||(this.fire(new e.y(new Error(`Image "${t.name}" has invalid "stretchX" value`))),r=!1),this._validateStretch(i.stretchY,i.data&&i.data.height)||(this.fire(new e.y(new Error(`Image "${t.name}" has invalid "stretchY" value`))),r=!1),this._validateContent(i.content,i)||(this.fire(new e.y(new Error(`Image "${t.name}" has invalid "content" value`))),r=!1),r}_validateStretch(e,t){if(!e)return!0;let i=0;for(const r of e){if(r[0]e.I.from(t))}getImages(e,t,i){const r=[],n=[],o=this.imageProviders.get(t);for(const i of e){if(!i.iconsetId){r.push(i);continue}const e=o.get(i.iconsetId);e&&(this.getImage(i,t)?n.push(i):e.addPendingRequest(i))}if(0===r.length)return void this._notify(n,t,i);let s=!0;const a=!!this.loaded.get(t),l=this.images.get(t);if(!a)for(const e of r)l.has(e.toString())||(s=!1);a||s?this._notify(r,t,i):this.requestors.push({ids:r,scope:t,callback:i})}rasterizeImages(e,t){const i=new Map,{tasks:r,scope:n}=e;for(const[e,t]of r.entries()){const r=this.getImage(t.id,n);r&&i.set(e,{image:r,imageVariant:t})}this._rasterizeImages(n,i,t)}_rasterizeImages(t,i,r){if(e.r())this.imageRasterizerDispatcher.getActor().send("rasterizeImagesWorker",{tasks:i,scope:t},r);else{const e=new Map;for(const[r,{image:n,imageVariant:o}]of i.entries())e.set(r,this.imageRasterizer.rasterize(o,n,t,0));r(void 0,e)}}getUpdatedImages(e){return this.updatedImages.get(e)||new Set}_notify(t,i,r){const n=this.images.get(i),o=new Map;for(const i of t){if(!n.get(i.toString())){if(i.iconsetId)continue;this.fire(new e.z("styleimagemissing",{id:i.name}))}const t=n.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 r={data:t.usvg?null:t.data.clone(),pixelRatio:t.pixelRatio,sdf:t.sdf,usvg:t.usvg,version:t.version,stretchX:t.stretchX,stretchY:t.stretchY,content:t.content,hasRenderCallback:Boolean(t.userImage&&t.userImage.render)};t.usvg&&Object.assign(r,{width:t.icon.usvg_tree.width,height:t.icon.usvg_tree.height}),o.set(e.I.toString(i),r)}r(null,o)}getPixelSize(e){const{width:t,height:i}=this.atlasImage.get(e);return{width:t,height:i}}getPattern(t,i,r){const n=t.toString(),o=this.patterns.get(i),s=o.get(n),a=this.getImage(t,i);if(!a)return null;if(s){if(s.position.version===a.version)return s.position;s.position.version=a.version}else{if(a.usvg&&!a.data){const o=this.getPatternInFlightId(n,i);if(this.patternsInFlight.has(o))return null;this.patternsInFlight.add(o);const s=new e.A(t).scaleSelf(e.o.devicePixelRatio),l=new Map([[s.toString(),{image:a,imageVariant:s}]]);return this._rasterizeImages(i,l,(e,t)=>this.storePatternImage(s,i,a,r,t)),null}this.storePattern(t,i,a)}return this._updatePatternAtlas(i,r),o.get(n).position}getPatternInFlightId(t,i){return e.B(t,i)}hasPatternsInFlight(){return 0!==this.patternsInFlight.size}storePatternImage(e,t,i,r,n){const o=e.toString(),s=n?n.get(o):void 0;s&&(i.data=s,this.storePattern(e.id,t,i),this._updatePatternAtlas(t,r),this.patternsInFlight.delete(this.getPatternInFlightId(e.id.toString(),t)))}storePattern(t,i,r){const n={w:r.data.width+2*e.C,h:r.data.height+2*e.C,x:0,y:0},o=new e.F(n,r,e.C);this.patterns.get(i).set(t.toString(),{bin:n,position:o})}destroyAtlasTextures(){for(const e of this.atlasTexture.values())e&&e.destroy();this.atlasTexture.clear()}bind(t,i){const r=t.gl;let n=this.atlasTexture.get(i);n?this.dirty&&(n.update(this.atlasImage.get(i)),this.dirty=!1):(n=new e.T(t,this.atlasImage.get(i),r.RGBA8),this.atlasTexture.set(i,n)),n.bind(r.LINEAR,r.CLAMP_TO_EDGE)}_updatePatternAtlas(t,i){const r=this.patterns.get(t),n=Array.from(r.values()).map(({bin:e})=>e),{w:o,h:s}=e.G(n),a=this.atlasImage.get(t);a.resize({width:o||1,height:s||1});const l=this.images.get(t);for(const[t,{bin:n,position:o}]of r.entries()){let r=o.padding;const s=n.x+r,c=n.y+r,u=l.get(t).data,h=u.width,d=u.height;r=r>1?r-1:r,e.q.copy(u,a,{x:0,y:0},{x:s,y:c},{width:h,height:d},i),e.q.copy(u,a,{x:0,y:d-r},{x:s,y:c-r},{width:h,height:r},i),e.q.copy(u,a,{x:0,y:0},{x:s,y:c+d},{width:h,height:r},i),e.q.copy(u,a,{x:h-r,y:0},{x:s-r,y:c},{width:r,height:d},i),e.q.copy(u,a,{x:0,y:0},{x:s+h,y:c},{width:r,height:d},i),e.q.copy(u,a,{x:h-r,y:d-r},{x:s-r,y:c-r},{width:r,height:r},i),e.q.copy(u,a,{x:0,y:d-r},{x:s+h,y:c-r},{width:r,height:r},i),e.q.copy(u,a,{x:0,y:0},{x:s+h,y:c+d},{width:r,height:r},i),e.q.copy(u,a,{x:h-r,y:0},{x:s-r,y:c+d},{width:r,height:r},i)}this.dirty=!0}beginFrame(){for(const e of this.images.keys())this.callbackDispatchedThisFrame.set(e,new Set)}dispatchRenderCallbacks(e,t){const i=this.images.get(t);for(const r of e){if(this.callbackDispatchedThisFrame.get(t).has(r.toString()))continue;this.callbackDispatchedThisFrame.get(t).add(r.toString());const e=i.get(r.toString());Q(e)&&this.updateImage(r,t,e)}}destroy(){this.imageRasterizerDispatcher&&this.imageRasterizerDispatcher.remove()}}function Z(t){const i=t.value,r=t.valueSpec,n=t.style,o=t.styleSpec,s=t.key,a=t.arrayElementValidator||me;if(!Array.isArray(i))return[new e.V(s,i,`array expected, ${e.K(i)} found`)];if(r.length&&i.length!==r.length)return[new e.V(s,i,`array length ${r.length} expected, length ${i.length} found`)];if(r["min-length"]&&i.lengtho)return[new e.V(i,r,`${r} is greater than the maximum value ${o}`)]}return[]}function q(t){const i=t.key,r=t.value;if(!e.H(r))return[new e.V(i,r,`object expected, ${e.K(r)} found`)];const n=t.valueSpec,o=e.J(r.type);let s,a,l,c={};const u="categorical"!==o&&void 0===r.property,h=!u,d=function(t){const i=t.stops;return Array.isArray(i)&&Array.isArray(i[0])&&e.H(i[0][0])}(r),p=ge({key:t.key,value:t.value,valueSpec:t.styleSpec.function,style:t.style,styleSpec:t.styleSpec,objectElementValidators:{stops:function(t){if("identity"===o)return[new e.V(t.key,t.value,'identity function may not have a "stops" property')];let i=[];const r=t.value;return i=i.concat(Z({key:t.key,value:r,valueSpec:t.valueSpec,style:t.style,styleSpec:t.styleSpec,arrayElementValidator:f})),Array.isArray(r)&&0===r.length&&i.push(new e.V(t.key,r,"array must have at least one stop")),i},default:function(e){return me({key:e.key,value:e.value,valueSpec:n,style:e.style,styleSpec:e.styleSpec})}}});return"identity"===o&&u&&p.push(new e.V(t.key,t.value,'missing required property "property"')),"identity"===o||r.stops||p.push(new e.V(t.key,t.value,'missing required property "stops"')),"exponential"===o&&n.expression&&!e.M(n)&&p.push(new e.V(t.key,t.value,"exponential functions not supported")),t.styleSpec.$version>=8&&(h&&!e.N(n)?p.push(new e.V(t.key,t.value,"property functions not supported")):u&&!e.O(n)&&p.push(new e.V(t.key,t.value,"zoom functions not supported"))),"categorical"!==o&&!d||void 0!==r.property||p.push(new e.V(t.key,t.value,'"property" property is required')),p;function f(t){let i=[];const r=t.value,o=t.key;if(!Array.isArray(r))return[new e.V(o,r,`array expected, ${e.K(r)} found`)];if(2!==r.length)return[new e.V(o,r,`array length 2 expected, length ${r.length} found`)];if(d){if(!e.H(r[0]))return[new e.V(o,r,`object expected, ${e.K(r[0])} found`)];const n=r[0];if(void 0===n.zoom)return[new e.V(o,r,"object stop key must have zoom")];if(void 0===n.value)return[new e.V(o,r,"object stop key must have value")];const s=e.J(n.zoom);if("number"!=typeof s)return[new e.V(o,n.zoom,"stop zoom values must be numbers")];if(l&&l>s)return[new e.V(o,n.zoom,"stop zoom values must appear in ascending order")];s!==l&&(l=s,a=void 0,c={}),i=i.concat(ge({key:`${o}[0]`,value:r[0],valueSpec:{zoom:{}},style:t.style,styleSpec:t.styleSpec,objectElementValidators:{zoom:W,value:m}}))}else i=i.concat(m({key:`${o}[0]`,value:r[0],style:t.style,styleSpec:t.styleSpec},r));return e.Q(e.S(r[1]))?i.concat([new e.V(`${o}[1]`,r[1],"expressions are not allowed in function stops.")]):i.concat(me({key:`${o}[1]`,value:r[1],valueSpec:n,style:t.style,styleSpec:t.styleSpec}))}function m(t,i){const r=e.K(t.value),l=e.J(t.value),u=null!==t.value?t.value:i;if(s){if(r!==s)return[new e.V(t.key,u,`${r} stop domain type must match previous stop domain type ${s}`)]}else s=r;if("number"!==r&&"string"!==r&&"boolean"!==r&&"number"!=typeof l&&"string"!=typeof l&&"boolean"!=typeof l)return[new e.V(t.key,u,"stop domain value must be a number, string, or boolean")];if("number"!==r&&"categorical"!==o){let i=`number expected, ${r} found`;return e.N(n)&&void 0===o&&(i+='\nIf you intended to use a categorical function, specify `"type": "categorical"`.'),[new e.V(t.key,u,i)]}return"categorical"!==o||"number"!==r||"number"==typeof l&&isFinite(l)&&Math.floor(l)===l?"categorical"!==o&&"number"===r&&"number"==typeof l&&"number"==typeof a&&void 0!==a&&lnew e.V(`${t.key}${i.key}`,t.value,i.message));const r=i.value.expression||i.value._styleExpression.expression;if("property"===t.expressionContext&&"text-font"===t.propertyKey&&!r.outputDefined())return[new e.V(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.Z(r))return[new e.V(t.key,t.value,'"feature-state" data expressions are not supported with layout properties.')];if("filter"===t.expressionContext)return X(r,t);if("appearance"===t.expressionContext)return J(r,t);if(t.expressionContext&&0===t.expressionContext.indexOf("cluster")){if(!e.X(r,["zoom","feature-state"]))return[new e.V(t.key,t.value,'"zoom" and "feature-state" expressions are not supported with cluster properties.')];if("cluster-initial"===t.expressionContext&&!e.Y(r))return[new e.V(t.key,t.value,"Feature data expressions are not supported with initial expression part of cluster properties.")]}return[]}function X(t,i){const r=new Set(["zoom","feature-state","pitch","distance-from-center"]);if(i.valueSpec&&i.valueSpec.expression)for(const e of i.valueSpec.expression.parameters)r.delete(e);if(0===r.size)return[];const n=[];return t instanceof e._&&r.has(t.name)?[new e.V(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=>{n.push(...X(e,i))}),n)}function J(t,i){const r=new Set;if(i.valueSpec&&i.valueSpec.expression)for(const e of i.valueSpec.expression.parameters)r.add(e);if(0===r.size)return[];const n=[];return t instanceof e._&&!r.has(t.name)?[new e.V(i.key,i.value,`["${t.name}"] is not an allowed parameter`)]:(t.eachChild(e=>{n.push(...J(e,i))}),n)}function Y(t){const i=t.key,r=t.value,n=t.valueSpec,o=[];return Array.isArray(n.values)?-1===n.values.indexOf(e.J(r))&&o.push(new e.V(i,r,`expected one of [${n.values.join(", ")}], ${JSON.stringify(r)} found`)):-1===Object.keys(n.values).indexOf(e.J(r))&&o.push(new e.V(i,r,`expected one of [${Object.keys(n.values).join(", ")}], ${JSON.stringify(r)} found`)),o}function ee(t){return e.a2(e.S(t.value))?K(Object.assign({},t,{expressionContext:"filter",valueSpec:t.styleSpec[`filter_${t.layerType||"fill"}`]})):te(t)}function te(t){const i=t.value,r=t.key;if(!Array.isArray(i))return[new e.V(r,i,`array expected, ${e.K(i)} found`)];if(i.length<1)return[new e.V(r,i,"filter array must have at least 1 element")];const n=t.styleSpec;let o=Y({key:`${r}[0]`,value:i[0],valueSpec:n.filter_operator});switch(e.J(i[0])){case"<":case"<=":case">":case">=":i.length>=2&&"$type"===e.J(i[1])&&o.push(new e.V(r,i,`"$type" cannot be use with operator "${i[0]}"`));case"==":case"!=":3!==i.length&&o.push(new e.V(r,i,`filter array for operator "${i[0]}" must have 3 elements`));case"in":case"!in":i.length>=2&&(e.a0(i[1])||o.push(new e.V(`${r}[1]`,i[1],`string expected, ${e.K(i[1])} found`)));for(let t=2;t{t in r&&i.push(new e.V(n,r[t],`"${t}" is prohibited for ref layers`))}),o.layers.forEach(i=>{e.J(i.id)===l&&(t=i)}),t?t.ref?i.push(new e.V(n,r.ref,"ref cannot reference another ref layer")):a=e.J(t.type):"string"==typeof l&&i.push(new e.V(n,r.ref,`ref layer "${l}" not found`))}else if("background"!==a&&"sky"!==a&&"slot"!==a)if(r.source)if(e.a0(r.source)){const t=o.sources&&o.sources[r.source],s=t&&e.J(t.type);t?"vector"===s&&"raster"===a?i.push(new e.V(n,r.source,`layer "${r.id}" requires a raster source`)):"raster"===s&&"raster"!==a?i.push(new e.V(n,r.source,`layer "${r.id}" requires a vector source`)):"vector"!==s||r["source-layer"]?"raster-dem"===s&&"hillshade"!==a?i.push(new e.V(n,r.source,"raster-dem source can only be used with layer type 'hillshade'.")):"raster-array"!==s||["raster","raster-particle"].includes(a)?"line"===a&&r.paint&&(r.paint["line-gradient"]||r.paint["line-trim-offset"])&&"geojson"===s&&!t.lineMetrics?i.push(new e.V(n,r,`layer "${r.id}" specifies a line-gradient, which requires the GeoJSON source to have \`lineMetrics\` enabled.`)):"raster-particle"===a&&"raster-array"!==s&&i.push(new e.V(n,r.source,`layer "${r.id}" requires a 'raster-array' source.`)):i.push(new e.V(n,r.source,"raster-array source can only be used with layer type 'raster'.")):i.push(new e.V(n,r,`layer "${r.id}" must specify a "source-layer"`)):i.push(new e.V(n,r.source,`source "${r.source}" not found`))}else i.push(new e.V(`${n}.source`,r.source,'"source" must be a string'));else i.push(new e.V(n,r,'missing required property "source"'));return i=i.concat(ge({key:n,value:r,valueSpec:s.layer,style:t.style,styleSpec:t.styleSpec,objectElementValidators:{"*":()=>[],type:()=>me({key:`${n}.type`,value:r.type,valueSpec:s.layer.type,style:t.style,styleSpec:t.styleSpec,object:r,objectKey:"type"}),filter:e=>ee(Object.assign({layerType:a},e)),layout:e=>ge({layer:r,key:e.key,value:e.value,valueSpec:{},style:e.style,styleSpec:e.styleSpec,objectElementValidators:{"*":e=>ne(Object.assign({layerType:a},e))}}),paint:e=>ge({layer:r,key:e.key,value:e.value,valueSpec:{},style:e.style,styleSpec:e.styleSpec,objectElementValidators:{"*":e=>re(Object.assign({layerType:a,layer:r},e))}}),appearances(t){const i=Z({key:t.key,value:t.value,valueSpec:t.valueSpec,style:t.style,styleSpec:t.styleSpec,arrayElementValidator:t=>function(t){const{key:i,layer:r,layerType:n}=t,o=e.J(t.value),s=e.J(o.name),a=e.J(o.condition),l=ge({key:i,value:o,valueSpec:t.styleSpec.appearance,style:t.style,styleSpec:t.styleSpec,objectElementValidators:{condition:t=>function(t){const i=[];return i.push(...K({key:t.key,value:t.object.condition,valueSpec:e.a6.appearance.condition,expressionContext:"appearance"})),i}(Object.assign({layer:r,layerType:n},t)),properties:t=>function(t){const i=[],{styleSpec:r,layer:n,layerType:o}=t,s=r[`paint_${o}`],a=r[`layout_${o}`],l=t.object[t.objectKey];for(const r in l){const c=r in s?"paint":r in a?"layout":void 0;if(!c){i.push(new e.V(t.key,r,`unknown property "${r}" for layer type "${o}"`));continue}const u=Object.assign({},t,{key:`${t.key}.${r}`,object:l,objectKey:r,layer:n,layerType:o,value:l[r],valueSpec:"paint"===c?s[r]:a[r]});i.push(...ie(u,c))}return i}(Object.assign({layer:r,layerType:n},t))}});return"hidden"!==s&&void 0===a&&l.push(new e.V(t.key,"name",'Appearance with name different than "hidden" must have a condition')),l}(Object.assign({layerType:a,layer:r},t))}),n=Array.isArray(t.value)?t.value:[],o=new Set;return n.forEach((n,s)=>{const a=e.J(n.name);if(a)if(o.has(a)){const n=e.J(r.id);i.push(new e.V(t.key,a,`Duplicated appearance name "${a}" for layer "${n}"`))}else o.add(a)}),i}}})),i}function se({key:t,value:i}){return e.a0(i)?[]:[new e.V(t,i,`string expected, ${e.K(i)} found`)]}const ae={promoteId:function t({key:i,value:r}){if(e.a0(r))return se({key:i,value:r});if(Array.isArray(r)){const t=[],n=e.S(r),o=e.U(n);return"error"===o.result&&o.value.forEach(r=>{t.push(new e.V(`${i}${r.key}`,null,`${r.message}`))}),e.X(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 e.V(`${i}`,null,"promoteId expression should be only feature dependent")),t}if(!e.H(r))return[new e.V(i,r,`string, expression or object expected, "${e.K(r)}" found`)];const n=[];for(const e in r)n.push(...t({key:`${i}.${e}`,value:r[e]}));return n}};function le(t){const i=t.value,r=t.key,n=t.styleSpec,o=t.style;if(!e.H(i))return[new e.V(r,i,`object expected, ${e.K(i)} found`)];if(!("type"in i))return[new e.V(r,i,'"type" is required')];const s=e.J(i.type);let a=[];switch(["vector","raster","raster-dem","raster-array"].includes(s)&&("url"in i||"tiles"in i||a.push(new e.a3(r,i,'Either "url" or "tiles" is required.'))),s){case"vector":case"raster":case"raster-dem":case"raster-array":return a=a.concat(ge({key:r,value:i,valueSpec:n[`source_${s.replace("-","_")}`],style:t.style,styleSpec:n,objectElementValidators:ae})),a;case"geojson":if(a=ge({key:r,value:i,valueSpec:n.source_geojson,style:o,styleSpec:n,objectElementValidators:ae}),"cluster"in i&&"clusterProperties"in i){if(!e.H(i.clusterProperties))return[new e.V(`${r}.clusterProperties`,i,`object expected, ${e.K(i)} found`)];for(const t in i.clusterProperties){const n=i.clusterProperties[t];if(!Array.isArray(n))return[new e.V(`${r}.clusterProperties.${t}`,n,"array expected")];const[o,s]=n,l="string"==typeof o?[o,["accumulated"],["get",t]]:o;a.push(...K({key:`${r}.${t}.map`,value:s,expressionContext:"cluster-map"})),a.push(...K({key:`${r}.${t}.reduce`,value:l,expressionContext:"cluster-reduce"}))}}return a;case"video":return ge({key:r,value:i,valueSpec:n.source_video,style:o,styleSpec:n});case"image":return ge({key:r,value:i,valueSpec:n.source_image,style:o,styleSpec:n});case"canvas":return[new e.V(r,null,"Please use runtime APIs to add canvas sources, rather than including them in stylesheets.","source.canvas")];default:return Y({key:`${r}.type`,value:i.type,valueSpec:{values:ce(n)}})}}function ce(e){return e.source.reduce((t,i)=>{const r=e[i];return"enum"===r.type.type&&(t=t.concat(Object.keys(r.type.values||{}))),t},[])}function ue(t){const i=t.value,r=t.styleSpec,n=r.light,o=t.style;if(void 0===i)return[];if(!e.H(i))return[new e.V("light",i,`object expected, ${e.K(i)} found`)];let s=[];for(const t in i){const a=t.match(/^(.*)-transition$/),l=t.match(/^(.*)-use-theme$/);s=s.concat(l&&n[l[1]]?me({key:t,value:i[t],valueSpec:{type:"string"},style:o,styleSpec:r}):a&&n[a[1]]&&n[a[1]].transition?me({key:t,value:i[t],valueSpec:r.transition,style:o,styleSpec:r}):n[t]?me({key:t,value:i[t],valueSpec:n[t],style:o,styleSpec:r}):[new e.V(t,i[t],`unknown property "${t}"`)])}return s}function he(t){const i=t.value;if(!i)return[];const r=t.key;if(!e.H(i))return[new e.V(r,i,`object expected, ${e.K(i)} found`)];let n=[];const o=t.styleSpec,s=o["light-3d"],a=t.style,l=t.style.lights;for(const t of["type","id"])if(!(t in i))return n=n.concat([new e.V(r,i,`missing property "${t}"`)]),n;if(!e.a0(i.type))return n=n.concat([new e.V(`${r}.type`,i.type,"string expected")]),n;if(l)for(let o=0;o[],array:Z,boolean:function(t){const i=t.value,r=t.key;return e.$(i)?[]:[new e.V(r,i,`boolean expected, ${e.K(i)} found`)]},number:W,color:function({key:t,value:i}){return e.a0(i)?null===e.a1.parseCSSColor(i)?[new e.V(t,i,`color expected, "${i}" found`)]:[]:[new e.V(t,i,`color expected, ${e.K(i)} found`)]},enum:Y,filter:ee,function:q,layer:oe,object:ge,source:le,model:e.a7,light:ue,"light-3d":he,terrain:de,fog:pe,string:se,formatted:function(e){return 0===se(e).length?[]:K(e)},resolvedImage:function(e){return 0===se(e).length?[]:K(e)},projection:function(t){const i=t.value,r=t.styleSpec,n=r.projection,o=t.style;if(e.H(i)){let e=[];for(const t in i)e=e.concat(me({key:t,value:i[t],valueSpec:n[t],style:o,styleSpec:r}));return e}return e.a0(i)?[]:[new e.V("projection",i,`object or string expected, ${e.K(i)} found`)]},import:function(t){const i=t.key,{value:r,styleSpec:n}=t;if(!e.H(r))return[new e.V(i,r,"import must be an object")];const{data:o,...s}=r;Object.defineProperty(s,"__line__",{value:r.__line__,enumerable:!1});let a=ge(Object.assign({},t,{value:s,valueSpec:n.import}));return""===e.J(s.id)&&a.push(new e.V(`${t.key}.id`,s,"import id can't be an empty string")),o&&(a=a.concat(Ae(o,n,{key:`${t.key}.data`}))),a},iconset:function(t){const i=t.value,r=t.key,n=t.styleSpec,o=t.style;if(!e.H(i))return[new e.V(r,i,"object expected")];if(!i.type)return[new e.V(r,i,'"type" is required')];const s=e.J(i.type);let a=[];if(a=a.concat(ge({key:r,value:i,valueSpec:n[`iconset_${s}`],style:o,styleSpec:n})),function(e,t){return!("source"!==e||!t.source)}(s,i)){const t=o.sources&&o.sources[i.source],n=t&&e.J(t.type);t?"raster-array"!==n&&a.push(new e.V(r,i.source,`iconset cannot be used with a source of type ${String(n)}, it only be used with a "raster-array" source type`)):a.push(new e.V(r,i.source,`source "${i.source}" not found`))}return a}};function me(t,i=!1){const r=t.value,n=t.valueSpec,o=t.styleSpec;if(n.expression){if(e.a4(e.J(r)))return q(t);if(e.Q(e.S(r)))return K(t)}if(n.type&&fe[n.type]){const e=fe[n.type](t);return!0===i&&e.length>0&&Array.isArray(t.value)?K(t):e}return ge(Object.assign({},t,{valueSpec:n.type?o[n.type]:n}))}function ge(t){const i=t.key,r=t.value,n=t.valueSpec||{},o=t.objectElementValidators||{},s=t.style,a=t.styleSpec;if(!e.H(r))return[new e.V(i,r,`object expected, ${e.K(r)} found`)];let l=[];for(const t in r){const c=t.split(".")[0];let u;o[c]?u=o[c]:n[c]?u=me:o["*"]?u=o["*"]:n["*"]&&(u=me),u?l=l.concat(u({key:(i?`${i}.`:i)+t,value:r[t],valueSpec:n[c]||n["*"],style:s,styleSpec:a,object:r,objectKey:t},r)):l.push(new e.a3(i,r[t],`unknown property "${t}"`))}for(const t in n){if(o[t])continue;const s=n[t];s.required&&void 0===s.default&&void 0===r[t]&&l.push(new e.V(i,r,`missing required property "${t}"`))}return l}function _e({key:t,value:i}){const r=se({key:t,value:i});if(r.length)return r;const n=i;return-1===n.indexOf("{fontstack}")&&r.push(new e.V(t,i,'"glyphs" url must include a "{fontstack}" token')),-1===n.indexOf("{range}")&&r.push(new e.V(t,i,'"glyphs" url must include a "{range}" token')),r}function Ae(t,i=e.a6,r={}){return ge({key:r.key||"",value:t,valueSpec:Object.assign(i.$root,{"*":{type:"*"}}),styleSpec:i,style:t,objectElementValidators:{glyphs:_e}})}function ye(t,i=e.a6){return Re(Ae(t,i))}const ve=e=>Re(le(e)),xe=e=>Re(ue(e)),be=e=>Re(he(e)),we=e=>Re(de(e)),Te=e=>Re(pe(e)),Ee=t=>Re(function(t){const i=t.value,r=t.style,n=t.styleSpec,o=n.snow;if(void 0===i)return[];if(!e.H(i))return[new e.V("snow",i,`object expected, ${e.K(i)} found`)];let s=[];for(const t in i){const a=t.match(/^(.*)-transition$/);s=s.concat(a&&o[a[1]]&&o[a[1]].transition?me({key:t,value:i[t],valueSpec:n.transition,style:r,styleSpec:n}):o[t]?me({key:t,value:i[t],valueSpec:o[t],style:r,styleSpec:n}):[new e.a3(t,i[t],`unknown property "${t}"`)])}return s}(t)),Ce=t=>Re(function(t){const i=t.value,r=t.style,n=t.styleSpec,o=n.rain;if(void 0===i)return[];if(!e.H(i))return[new e.V("rain",i,`object expected, ${e.K(i)} found`)];let s=[];for(const t in i){const a=t.match(/^(.*)-transition$/);s=s.concat(a&&o[a[1]]&&o[a[1]].transition?me({key:t,value:i[t],valueSpec:n.transition,style:r,styleSpec:n}):o[t]?me({key:t,value:i[t],valueSpec:o[t],style:r,styleSpec:n}):[new e.a3(t,i[t],`unknown property "${t}"`)])}return s}(t)),Be=e=>Re(oe(e)),Se=e=>Re(ee(e)),Ie=e=>Re(re(e)),Me=e=>Re(ne(e)),Pe=t=>Re(e.a7(t));function Re(e){return e.slice().sort((e,t)=>e.line&&t.line?e.line-t.line:0)}function Le(t,i){let r=!1;if(i&&i.length)for(const n of i)n instanceof e.a3?e.w(n.message):(t.fire(new e.y(new Error(n.message))),r=!0);return r}const Fe=e.a6.light;let ke;class De extends e.E{constructor(t,i="flat"){super(),this._transitionable=new e.a8(ke||(ke=new e.a9({anchor:new e.aa(Fe.anchor),position:new e.ab(Fe.position),color:new e.aa(Fe.color),intensity:new e.aa(Fe.intensity)}))),this.setLight(t,i),this._transitioning=this._transitionable.untransitioned()}getLight(){return this._transitionable.serialize()}setLight(e,t,i={}){this._validate(xe,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,r){return(!r||!1!==r.validate)&&Le(this,t.call(ye,Object.assign({value:i,style:{glyphs:!0,sprite:!0},styleSpec:e.a6})))}}const Oe=e.a6.terrain;let ze=class extends e.E{constructor(t,i,r,n,o){super(),this.scope=r,this._transitionable=new e.a8(new e.a9({source:new e.aa(Oe.source),exaggeration:new e.aa(Oe.exaggeration)}),r,n),this._transitionable.setTransitionOrValue(t,n),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.ac(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 r=-1,n=-1,o=1;for(const t of i.zoomStops)o=i.evaluate(new e.ac(t,{worldview:this.worldview})),o>.01?(r=t,n=-1):n=t;return o<.01&&r>0&&n>r?[r,n]:null}isZoomDependent(){const t=this._transitionable._values.exaggeration;return null!=t&&null!=t.value&&null!=t.value.expression&&t.value.expression instanceof e.ad}};const Ue=45,Ne=65,Ve=.05;function je(t,i,r,n){const o=e.ah(Ue,Ne,r),[s,a]=Ge(t,n);let l=1-Math.min(1,Math.exp((i-s)/(a-s)*-6));return l*=l*l,l=Math.min(1,1.00747*l),l*o*t.alpha}function Ge(e,t){const i=.5/Math.tan(.5*t);return[e.range[0]+i,e.range[1]+i]}function He(t,i,r,n,o){const s=e.af([],[i,r,n],o.mercatorFogMatrix);return je(t,e.ag(s),o.pitch,o._fov)}function Qe(t,i,r,n,o,s,a){const l=[[r,n,0],[o,n,0],[o,s,0],[r,s,0]];let c=Number.MAX_VALUE,u=-Number.MAX_VALUE;for(const t of l){const r=e.af([],t,i),n=e.ag(r);c=Math.min(c,n),u=Math.max(u,n)}return[je(t,c,a.pitch,a._fov),je(t,u,a.pitch,a._fov)]}const $e=e.a6.fog;class Ze extends e.E{constructor(t,i,r,n){super();const o=new e.a9({range:new e.aa($e.range),color:new e.aa($e.color),"color-use-theme":new e.aa({type:"string","property-type":"data-constant",default:"default"}),"high-color":new e.aa($e["high-color"]),"high-color-use-theme":new e.aa({type:"string","property-type":"data-constant",default:"default"}),"space-color":new e.aa($e["space-color"]),"space-color-use-theme":new e.aa({type:"string","property-type":"data-constant",default:"default"}),"horizon-blend":new e.aa($e["horizon-blend"]),"star-intensity":new e.aa($e["star-intensity"]),"vertical-range":new e.aa($e["vertical-range"])});this._transitionable=new e.a8(o,r,new Map(n)),this.set(t,n),this._transitioning=this._transitionable.untransitioned(),this._transform=i,this.properties=new e.ai(o),this.scope=r}get state(){const t=this._transform,i="globe"===t.projection.name,r=e.aj(t.zoom),n=this.properties.get("range"),o=[.5,3];return{range:i?[e.ak(o[0],n[0],r),e.ak(o[1],n[1],r)]:n,horizonBlend:this.properties.get("horizon-blend"),alpha:this.properties.get("color").a}}get(){return this._transitionable.serialize()}set(e,t,i={}){if(this._validate(Te,e,i))return;const r=Object.assign({},e);for(const e of Object.keys($e))void 0===r[e]&&(r[e]=$e[e].default);this._options=r,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.ah(Ue,Ne,t))*i.a}getOpacityAtLatLng(t,i){return this._transform.projection.supportsFog?function(t,i,r){const n=e.ae.fromLngLat(i),o=r.elevation?r.elevation.getAtPointOrZero(n):0;return He(t,n.x,n.y,o,r)}(this.state,t,i):0}getOpacityForTile(t){if(!this._transform.projection.supportsFog)return[1,1];const i=this._transform.calculateFogTileMatrix(t.toUnwrapped());return Qe(this.state,i,0,0,e.al,e.al,this._transform)}getOpacityForBounds(e,t,i,r,n){return this._transform.projection.supportsFog?Qe(this.state,e,t,i,r,n,this._transform):[1,1]}getFovAdjustedRange(e){return this._transform.projection.supportsFog?Ge(this.state,e):[0,1]}isVisibleOnFrustum(t){if(!this._transform.projection.supportsFog)return!1;const i=[4,5,6,7];for(const r of i){const i=t.points[r];let n;if(i[2]>=0)n=i;else{const o=t.points[r-4];n=e.am(o,i,o[2]/(o[2]-i[2]))}if(He(this.state,n[0],n[1],0,this._transform)>=Ve)return!0}return!1}updateConfig(e){this._transitionable.setTransitionOrValue(this._options,new Map(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,r){return(!r||!1!==r.validate)&&Le(this,t.call(ye,Object.assign({value:i,style:{glyphs:!0,sprite:!0},styleSpec:e.a6})))}}let We,qe,Ke,Xe,Je=class extends e.E{constructor(t,i,r,n){super();const o=We||(We=new e.a9({density:new e.aa(e.a6.snow.density),intensity:new e.aa(e.a6.snow.intensity),color:new e.aa(e.a6.snow.color),opacity:new e.aa(e.a6.snow.opacity),vignette:new e.aa(e.a6.snow.vignette),"vignette-color":new e.aa(e.a6.snow["vignette-color"]),"center-thinning":new e.aa(e.a6.snow["center-thinning"]),direction:new e.aa(e.a6.snow.direction),"flake-size":new e.aa(e.a6.snow["flake-size"])}));this._transitionable=new e.a8(o,r,new Map(n)),this.set(t,n),this._transitioning=this._transitionable.untransitioned(),this.properties=new e.ai(o),this.scope=r}get state(){const t=this.properties.get("opacity"),i=this.properties.get("color"),r=this.properties.get("direction"),n=e.an(r[0]),o=-Math.max(e.an(r[1]),.01),s=[Math.cos(n)*Math.cos(o),Math.sin(n)*Math.cos(o),Math.sin(o)],a=this.properties.get("vignette"),l=this.properties.get("vignette-color");return l.a=a,{density:this.properties.get("density"),intensity:this.properties.get("intensity"),color:new e.ao(i.r,i.g,i.b,i.a*t),direction:s,centerThinning:this.properties.get("center-thinning"),flakeSize:this.properties.get("flake-size"),vignetteColor:l}}get(){return this._transitionable.serialize()}set(t,i,r={}){if(this._validate(Ee,t,r))return;const n=Object.assign({},t),o=e.a6.snow;for(const e of Object.keys(o))void 0===n[e]&&(n[e]=o[e].default);this._options=n,this._transitionable.setTransitionOrValue(this._options,i)}updateConfig(e){this._transitionable.setTransitionOrValue(this._options,new Map(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,r){return(!r||!1!==r.validate)&&Le(this,t.call(ye,Object.assign({value:i,style:{glyphs:!0,sprite:!0},styleSpec:e.a6})))}},Ye=class extends e.E{constructor(t,i,r,n){super();const o=qe||(qe=new e.a9({density:new e.aa(e.a6.rain.density),intensity:new e.aa(e.a6.rain.intensity),color:new e.aa(e.a6.rain.color),opacity:new e.aa(e.a6.rain.opacity),vignette:new e.aa(e.a6.rain.vignette),"vignette-color":new e.aa(e.a6.rain["vignette-color"]),"center-thinning":new e.aa(e.a6.rain["center-thinning"]),direction:new e.aa(e.a6.rain.direction),"droplet-size":new e.aa(e.a6.rain["droplet-size"]),"distortion-strength":new e.aa(e.a6.rain["distortion-strength"])}));this._transitionable=new e.a8(o,r,new Map(n)),this.set(t,n),this._transitioning=this._transitionable.untransitioned(),this.properties=new e.ai(o),this.scope=r}get state(){const t=this.properties.get("opacity"),i=this.properties.get("color"),r=this.properties.get("direction"),n=e.an(r[0]),o=-Math.max(e.an(r[1]),.01),s=[Math.cos(n)*Math.cos(o),Math.sin(n)*Math.cos(o),Math.sin(o)],a=this.properties.get("vignette-color");return a.a=this.properties.get("vignette"),{density:this.properties.get("density"),intensity:this.properties.get("intensity"),color:new e.ao(i.r,i.g,i.b,i.a*t),direction:s,centerThinning:this.properties.get("center-thinning"),dropletSize:this.properties.get("droplet-size"),distortionStrength:this.properties.get("distortion-strength"),vignetteColor:a}}get(){return this._transitionable.serialize()}set(t,i,r={}){if(this._validate(Ce,t,r))return;const n=Object.assign({},t),o=e.a6.rain;for(const e of Object.keys(o))void 0===n[e]&&(n[e]=o[e].default);this._options=n,this._transitionable.setTransitionOrValue(this._options,i)}updateConfig(e){this._transitionable.setTransitionOrValue(this._options,new Map(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,r){return(!r||!1!==r.validate)&&Le(this,t.call(ye,Object.assign({value:i,style:{glyphs:!0,sprite:!0},styleSpec:e.a6})))}};class et extends e.E{constructor(t,i,r,n){super(),this.scope=r,this._options=t,this.properties=new e.ai(i),this._transitionable=new e.a8(i,r,new Map(n)),this._transitionable.setTransitionOrValue(t.properties),this._transitioning=this._transitionable.untransitioned()}updateConfig(e){this._transitionable.setTransitionOrValue(this._options.properties,new Map(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")}}class tt{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 r,n;if(t instanceof e.P||"number"==typeof t[0]){const o=e.P.convert(t);r=[o],n=i.isPointAboveHorizon(o)}else{const o=e.P.convert(t[0]),s=e.P.convert(t[1]),a=o.add(s)._div(2);r=[o,s],n=e.aq(o,s).every(e=>i.isPointAboveHorizon(e))&&i.isPointAboveHorizon(a)}return new tt(r,n,i)}isPointQuery(){return 1===this.screenBounds.length}bufferedScreenGeometry(t){return e.aq(this.screenBounds[0],1===this.screenBounds.length?this.screenBounds[0]:this.screenBounds[1],t)}bufferedCameraGeometry(t){const i=this.screenBounds[0],r=1===this.screenBounds.length?this.screenBounds[0].add(new e.P(1,1)):this.screenBounds[1],n=e.aq(i,r,0,!1);return this.cameraPoint.y>r.y&&(this.cameraPoint.x>i.x&&this.cameraPoint.x=r.x?n[2]=this.cameraPoint:this.cameraPoint.x<=i.x&&(n[3]=this.cameraPoint)),e.ar(n,t)}bufferedCameraGeometryGlobe(t){const i=this.screenBounds[0],r=1===this.screenBounds.length?this.screenBounds[0].add(new e.P(1,1)):this.screenBounds[1],n=e.aq(i,r,t),o=this.cameraPoint.clone();switch(3*((o.y>i.y)+(o.y>r.y))+((o.x>i.x)+(o.x>r.x))){case 0:n[0]=o,n[4]=o.clone();break;case 1:n.splice(1,0,o);break;case 2:n[1]=o;break;case 3:n.splice(4,0,o);break;case 5:n.splice(2,0,o);break;case 6:n[3]=o;break;case 7:n.splice(3,0,o);break;case 8:n[2]=o}return n}containsTile(t,i,r,n=0){const o=Math.max(t.queryPadding,t.evaluateQueryRenderedFeaturePadding())/i._pixelsPerMercatorPixel+1,s=r?this._bufferedCameraMercator(o,i):this._bufferedScreenMercator(o,i);let a=t.tileID.wrap+(s.unwrapped?n:0);const l=s.polygon.map(i=>e.as(t.tileTransform,i,a));if(!e.at(l,0,0,e.al,e.al))return;a=t.tileID.wrap+(this.screenGeometryMercator.unwrapped?n:0);const c=this.screenGeometryMercator.polygon.map(i=>e.au(t.tileTransform,i,a)),u=c.map(t=>new e.P(t[0],t[1])),h=i.getFreeCameraOptions().position||new e.ae(0,0,0),d=e.au(t.tileTransform,h,a),p=c.map(t=>{const i=e.av(t,t,d);return e.aw(i,i),new e.ax(d,i)}),f=e.ay(t,1,i.zoom)*i._pixelsPerMercatorPixel;return{queryGeometry:this,tilespaceGeometry:u,tilespaceRays:p,bufferedTilespaceGeometry:l,bufferedTilespaceBounds:(m=e.az(l),m.min.x=e.aA(m.min.x,0,e.al),m.min.y=e.aA(m.min.y,0,e.al),m.max.x=e.aA(m.max.x,0,e.al),m.max.y=e.aA(m.max.y,0,e.al),m),tile:t,tileID:t.tileID,pixelToTileUnitsFactor:f};var m}_bufferedScreenMercator(e,t){const i=nt(e);if(this._screenRaycastCache[i])return this._screenRaycastCache[i];{let r;return r="globe"===t.projection.name?this._projectAndResample(this.bufferedScreenGeometry(e),t):{polygon:this.bufferedScreenGeometry(e).map(e=>t.pointCoordinate3D(e)),unwrapped:!0},this._screenRaycastCache[i]=r,r}}_bufferedCameraMercator(e,t){const i=nt(e);if(this._cameraRaycastCache[i])return this._cameraRaycastCache[i];{let r;return r="globe"===t.projection.name?this._projectAndResample(this.bufferedCameraGeometryGlobe(e),t):{polygon:this.bufferedCameraGeometry(e).map(e=>t.pointCoordinate3D(e)),unwrapped:!0},this._cameraRaycastCache[i]=r,r}}_projectAndResample(t,i){const r=function(t,i){const r=e.aB([],i.pixelMatrix,i.globeMatrix),n=[0,-e.aD,0,1],o=[0,e.aD,0,1],s=[0,0,0,1];e.aC(n,n,r),e.aC(o,o,r),e.aC(s,s,r);const a=new e.P(n[0]/n[3],n[1]/n[3]),l=new e.P(o[0]/o[3],o[1]/o[3]),c=e.aE(t,a)&&n[3]1?it(t.slice(0,d),i):[],m=dnew e.P(rt(t.x),t.y)),m=m.map(t=>new e.P(rt(t.x),t.y));const g=[...f];0===g.length&&g.push(m[m.length-1]);const _=e.ak(g[g.length-1].y,(0===m.length?f[0]:m[0]).y,p);let A;return A=c?[new e.P(0,_),new e.P(0,0),new e.P(1,0),new e.P(1,_)]:[new e.P(1,_),new e.P(1,1),new e.P(0,1),new e.P(0,_)],g.push(...A),0===m.length?g.push(f[0]):g.push(...m),{polygon:g.map(t=>new e.ae(t.x,t.y)),unwrapped:!1}}(t,i);if(r)return r;const n=function(t,i){let r=!1,n=-1/0,o=0;for(let e=0;en&&(n=t[e].x,o=e);for(let e=0;e.5&&(n.x{e.x-=1}),{polygon:t,unwrapped:r}}(it(t,i).map(t=>new e.P(rt(t.x),t.y)),i);return{polygon:n.polygon.map(t=>new e.ae(t.x,t.y)),unwrapped:n.unwrapped}}}function it(t,i){return e.aG(t,e=>{const t=i.pointCoordinate3D(e);e.x=t.x,e.y=t.y},1/256)}function rt(e){return e<0?1+e%1:e%1}function nt(e){return 100*e|0}function ot(t,i,r,n,o){const s=function(r,n){if(r)return o(r);if(n){if(t.url&&n.tiles&&t.tiles&&delete t.tiles,n.variants){if(!Array.isArray(n.variants))return o(new Error("variants must be an array"));for(const e of n.variants){if(null==e||"object"!=typeof e||e.constructor!==Object)return o(new Error("variant must be an object"));if(!Array.isArray(e.capabilities))return o(new Error("capabilities must be an array"));if(1===e.capabilities.length&&"meshopt"===e.capabilities[0]){n=Object.assign(n,e);break}}}const r=e.aH(Object.assign({},n,t),["tilejson","tiles","minzoom","maxzoom","attribution","mapbox_logo","bounds","extra_bounds","scheme","tileSize","encoding","vector_layers","raster_layers","worldview_options","worldview_default","worldview"]);r.tiles=i.canonicalizeTileset(r,t.url),o(null,r)}},a=function(e,t,i){if(!e)return null;if(!t&&!i)return e;i=i||e.worldview_default;const r=Object.values(e.language||{});if(0===r.length)return null;const n=Object.values(e.worldview||{});if(0===n.length)return null;const o=r.every(e=>e===t),s=n.every(e=>e===i);return o&&s?e:t in(e.language_options||{})||i in(e.worldview_options||{})?null:e.language_options&&e.worldview_options?e:null}(t.data,r,n);return a?e.o.frame(()=>s(null,a)):t.url?e.m(i.transformRequest(i.normalizeSourceURL(t.url,null,r,n),e.R.Source),s):e.o.frame(()=>{const{data:e,...i}=t;s(null,i)})}function st(t,i){const r=Math.pow(2,i.z),n=Math.floor(e.aF(t.getWest())*r),o=Math.floor(e.aJ(t.getNorth())*r),s=Math.ceil(e.aF(t.getEast())*r),a=Math.ceil(e.aJ(t.getSouth())*r);return i.x>=n&&i.x=o&&i.ythis.maxzoom||e.z{if(this._tileJSONRequest=null,this._loaded=!0,n)i&&console.warn(`Ensure that your requested language string is a valid BCP-47 code or list of codes. Found: ${i}`),r&&console.warn(`Requested worldview strings must be a valid ISO alpha-2 code. Found: ${r}`),this.fire(new e.y(n));else if(o){if(Object.assign(this,o),this.hasWorldviews=!!o.worldview_options,o.worldview_default&&(this.worldviewDefault=o.worldview_default),o.vector_layers){this.vectorLayers=o.vector_layers,this.vectorLayerIds=[],this.localizableLayerIds=new Set;for(const e of o.vector_layers)this.vectorLayerIds.push(e.id),o.worldview&&o.worldview[e.source]&&this.localizableLayerIds.add(e.id)}this.tileBounds=at.fromTileJSON(o),P(o.tiles,this.map._requestManager._customAccessToken),this.fire(new e.z("data",{dataType:"source",sourceDataType:"metadata"})),this.fire(new e.z("data",{dataType:"source",sourceDataType:"content"}))}t&&t(n)})}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.B(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 Object.assign({},this._options)}loadTile(t,i){const r=t.tileID.canonical.url(this.tiles,this.scheme),n=this.map._requestManager.normalizeTileURL(r),o=this.map._requestManager.transformRequest(n,e.R.Tile),s=this.map.style?this.map.style.getLut(this.scope):null,a=s?{image:s.image.clone()}:null,l={request:o,data:void 0,uid:t.uid,tileID:t.tileID,tileZoom:t.tileZoom,zoom:t.tileID.overscaledZ,maxZoom:this.maxzoom,lut:a,tileSize:this.tileSize*t.tileID.overscaleFactor(),type:this.type,source:this.id,scope:this.scope,pixelRatio:e.o.devicePixelRatio,showCollisionBoxes:this.map.showCollisionBoxes,promoteId:this.promoteId,isSymbolTile:t.isSymbolTile,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.indoor?this.map.indoor.getIndoorTileOptions(this.id,this.scope):null};if(this.hasWorldviews&&e.h(r)&&(l.localizableLayerIds=this.localizableLayerIds),l.request.collectResourceTiming=this._collectResourceTiming,t.actor&&"expired"!==t.state)"loading"===t.state?t.reloadCallback=i:t.request=t.actor.send("reloadTile",l,c.bind(this));else if(t.actor=this._tileWorkers[n]=this._tileWorkers[n]||this.dispatcher.getActor(),this.dispatcher.ready)t.request=t.actor.send("loadTile",l,c.bind(this),void 0,!0);else{const i=e.aL.call({deduped:this._deduped},l,(i,r)=>{if(i||!r)c.call(this,i);else{const i=e.aM(r.responseHeaders);l.data={cacheControl:i.cacheControl,expires:i.expires,rawData:r.rawData.slice(0)},t.actor&&t.actor.send("loadTile",l,c.bind(this),void 0,!0)}},!0);t.request={cancel:i}}function c(r,n){return delete t.request,t.aborted?i(null):r&&404!==r.status?i(r):(n&&n.resourceTiming&&(t.resourceTiming=n.resourceTiming),this.map._refreshExpiredTiles&&n&&t.setExpiryData(n),t.loadVectorData(n,this.map.painter),e.aN(this.dispatcher),i(null,n),void(t.reloadCallback&&(this.loadTile(t,t.reloadCallback),t.reloadCallback=null)))}}abortTile(e){e.request&&(e.request.cancel(),delete e.request),e.actor&&e.actor.send("abortTile",{uid:e.uid,type:this.type,source:this.id,scope:this.scope})}unloadTile(e,t){e.actor&&e.actor.send("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 ct extends e.E{constructor(t,i,r,n){super(),this.id=t,this.dispatcher=r,this.setEventedParent(n),this.type="raster",this.minzoom=0,this.maxzoom=22,this.roundZoom=!0,this.scheme="xyz",this.tileSize=512,this._loaded=!1,this._options=Object.assign({type:"raster"},i),Object.assign(this,e.aH(i,["url","scheme","tileSize"]))}load(t){this._loaded=!1,this.fire(new e.z("dataloading",{dataType:"source"}));const i=this.map.getWorldview();this._tileJSONRequest=ot(this._options,this.map._requestManager,null,i,(i,r)=>{this._tileJSONRequest=null,this._loaded=!0,i?this.fire(new e.y(i)):r&&(Object.assign(this,r),r.raster_layers&&(this.rasterLayers=r.raster_layers,this.rasterLayerIds=this.rasterLayers.map(e=>e.id)),this.tileBounds=at.fromTileJSON(r),P(r.tiles),this.fire(new e.z("data",{dataType:"source",sourceDataType:"metadata"})),this.fire(new e.z("data",{dataType:"source",sourceDataType:"content"}))),t&&t(i)})}loaded(){return this._loaded}onAdd(e){this.map=e,this.load()}reload(){this.cancelTileJSONRequest();const t=e.B(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 Object.assign({},this._options)}hasTile(e){return!this.tileBounds||this.tileBounds.contains(e.canonical)}loadTile(t,i){const r=e.o.devicePixelRatio>=2,n=this.map._requestManager.normalizeTileURL(t.tileID.canonical.url(this.tiles,this.scheme),r,this.tileSize);t.request=e.n(this.map._requestManager.transformRequest(n,e.R.Tile),(r,n,o)=>{if(delete t.request,t.aborted)return t.state="unloaded",i(null);if(r)return t.state="errored",i(r);if(!n)return i(null);const s=e.aM(o);this.map._refreshExpiredTiles&&t.setExpiryData(s),t.setTexture(n,this.map.painter),t.state="loaded",e.aN(this.dispatcher),i(null)})}abortTile(e,t){e.request&&(e.request.cancel(),delete e.request),t&&t()}unloadTile(t,i){t.texture&&t.texture instanceof e.T?(t.destroy(!0),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 ut([t,i],r,n,{scaled:o=!0}={}){const{tileSize:s,buffer:a}=n,{x:l,y:c,z:u}=r;if(!isFinite(l)||!isFinite(c)||!isFinite(u))throw new Error("Invalid MRT header");const h=2**u,d=h*e.aF(t),p=h*e.aJ(i);return function([e,t],i,{scaled:r=!0}={}){if(!i)throw new Error("bandView is undefined");const{data:n,tileSize:o,buffer:s,offset:a,scale:l,dimension:c}=i;if(e<-s||e>o+s||t<-s||t>o+s)throw new Error(`Point (${e}, ${t}) out of bounds for tileSize=${o}, buffer=${s}`);const u=(t+s)*(o+2*s)+(e+s);if(4294967295===new Uint32Array(n.buffer)[u])return null;let h=[];h=r?[]:new i.data.constructor(c);for(let e=0;e{if(delete t.request,t.aborted)return t.state="unloaded",i(null);if(r){if("AbortError"===r.name)return;return t.state="errored",i(r)}if(this.map._refreshExpiredTiles&&n){const i=e.aM(o);t.setExpiryData(i)}if(this.partial&&"expired"!==t.state)t.state="empty";else if(!this.partial){if(!n)return i(null);t.state="loaded",t._isHeaderLoaded=!0,t._mrt=n}i(null)};t.request=this.partial?t.fetchHeader(void 0,s.bind(this)):t.actor.send("loadTile",o,s.bind(this),void 0,!0)}abortTile(e){e.request&&(e.request.cancel(),delete e.request),e.actor&&e.actor.send("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(!0);for(const e of i.values())this.map.painter.saveTileTexture(e)}else e.destroy()}prepareTile(t,i,r,n){t._isHeaderLoaded&&("empty"!==t.state&&(t.state="reloading"),t.fetchBandForRender(i,r,n,(i,n)=>{if(i)return t.state="errored",this.fire(new e.y(i)),void this.triggerRepaint(t);n&&(t._isHeaderLoaded=!0,t.setTexturePerLayer(r,n,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,r=i&&i.bands&&i.bands;return r?r[0]:0}getTextureDescriptor(t,i,r){if(!t)return;const n=i.sourceLayer||this.rasterLayerIds&&this.rasterLayerIds[0];if(!n)return;let o=null;i instanceof e.aQ?o=i.paint.get("raster-array-band"):i instanceof e.aR&&(o=i.paint.get("raster-particle-array-band"));const s=o||this.getInitialBand(n);if(null==s)return;if(!t.textureDescriptorPerLayer.get(i.id))return void this.prepareTile(t,n,i.id,s);if(t.updateNeeded(i.id,s)&&!r)return;const a=t.textureDescriptorPerLayer.get(i.id);return Object.assign({},a,{texture:t.texturePerLayer.get(i.id)})}getImages(t,i){const r=new Map;for(const n of t)for(const t of i){const[i,o]=t.split("/"),s=n.getLayer(i);if(!s)continue;if(!s.hasBand(o)||!s.hasDataForBand(o))continue;const{bytes:a,tileSize:l,buffer:c}=s.getBandView(o),u=l+2*c,h={data:new e.q({width:u,height:u},a),pixelRatio:2,sdf:!1,usvg:!1,version:0};r.set(t,h)}return r}queryRasterArrayValueByBandId(t,i,r){const n=i._mrt;return new Promise(o=>{const s={},a=new Set;for(const[l,c]of Object.entries(n.layers)){if(r.layerName&&l!==r.layerName)continue;const u={};s[l]=u;for(const{bands:h}of c.dataIndex)for(const d of h)r.bands&&!r.bands.includes(d)||(a.add(e.B(l,d)),i.fetchBand(l,null,d,i=>{e.o.frame(()=>{u[d]=i?null:ut([t.lng,t.lat],n,c.getBandView(d)),a.delete(e.B(l,d)),0===a.size&&o(s)})},!1))}0===a.size&&o(s)})}_loadTileForQuery(t,i){if(this._loadTileLoaded[t.uid])return void i(null,t._mrt);if(this._loadTilePending[t.uid])return void this._loadTilePending[t.uid].push(i);this._loadTilePending[t.uid]=[i];const r=this.map._requestManager.normalizeTileURL(t.tileID.canonical.url(this.tiles,this.scheme),!1,this.tileSize),n=this.map._requestManager.transformRequest(r,e.R.Tile);t.actor.send("loadTile",{request:n,uid:t.uid,tileID:t.tileID,type:this.type,source:this.id,scope:this.scope,partial:!1},(i,r,n)=>{if(i)return this._loadTilePending[t.uid].forEach(e=>e(i,null)),void delete this._loadTilePending[t.uid];if(!r)return this._loadTilePending[t.uid].forEach(e=>e(null,null)),void delete this._loadTilePending[t.uid];if(this.map._refreshExpiredTiles&&r){const i=e.aM(n);t.setExpiryData(i)}t._mrt=r,t._isHeaderLoaded=!0,t.state="loaded",this._loadTilePending[t.uid].forEach(e=>e(null,r)),this._loadTileLoaded[t.uid]=!0,delete this._loadTilePending[t.uid]},void 0,!0)}queryRasterArrayValueByAllBands(e,t,i){return new Promise((r,n)=>{this._loadTileForQuery(t,(o,s)=>{o?n(o):r(s?this.queryRasterArrayValueByBandId(e,t,i):null)})})}queryRasterArrayValue(t,i){const r=e.aS.convert(t),n=this.findLoadedParent(r);return n&&n._mrt?i.bands||!this.partial?this.queryRasterArrayValueByBandId(r,n,i):this.queryRasterArrayValueByAllBands(r,n,i):Promise.resolve(null)}findLoadedParent(t){const i=e.ae.fromLngLat(t,this.map.transform.tileSize),r=this.maxzoom+1,n=1<0&&(l[new e.aP(t.overscaledZ,o,i.z,n,i.y-1).key]={backfilled:!1},l[new e.aP(t.overscaledZ,t.wrap,i.z,i.x,i.y-1).key]={backfilled:!1},l[new e.aP(t.overscaledZ,a,i.z,s,i.y-1).key]={backfilled:!1}),i.y+1{if(this._loaded=!0,this._pendingLoad=null,i)this.fire(new e.y(i));else{const i={dataType:"source",sourceDataType:this._metadataFired?"content":"metadata"};this._collectResourceTiming&&r&&r.resourceTiming&&r.resourceTiming[this.id]&&(i.resourceTiming=r.resourceTiming[this.id]),t&&(this._partialReload=!0),this.fire(new e.z("data",i)),this._partialReload=!1,this._metadataFired=!0}this._coalesce&&(this._updateWorkerData(t),this._coalesce=!1)})}loaded(){return this._loaded}reload(){const t=e.B(this.id,this.scope);this.map.style.clearSource(t),this._updateWorkerData()}loadTile(t,i){const r=t.actor?"reloadTile":"loadTile";t.actor=this.actor;const n=this.map.style?this.map.style.getLut(this.scope):null,o=n?{image:n.image.clone()}:null,s=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.o.devicePixelRatio,showCollisionBoxes:this.map.showCollisionBoxes,promoteId:this.promoteId,brightness:this.map.style&&this.map.style.getBrightness()||0,extraShadowCaster:t.isExtraShadowCaster,scaleFactor:this.map.getScaleFactor(),partial:s,worldview:this.map.getWorldview(),indoor:this.map.indoor?this.map.indoor.getIndoorTileOptions(this.id,this.scope):null};t.request=this.actor.send(r,a,(e,n)=>s&&!n?(t.state="loaded",i(null)):(delete t.request,t.destroy(),t.aborted?i(null):e?i(e):(t.loadVectorData(n,this.map.painter,"reloadTile"===r),i(null))),void 0,"loadTile"===r)}abortTile(e){e.request&&(e.request.cancel(),delete e.request),e.aborted=!0}unloadTile(e,t){this.actor.send("removeTile",{uid:e.uid,type:this.type,source:this.id,scope:this.scope}),e.destroy()}onRemove(e){this._pendingLoad&&this._pendingLoad.cancel()}serialize(){return Object.assign({},this._options,{type:this.type,data:this._data})}hasTransition(){return!1}},video:class extends e.aT{constructor(e,t,i,r){super(e,t,i,r),this.roundZoom=!0,this.type="video",this.options=t}load(){this._loaded=!1;const t=this.options;this.urls=[];for(const i of t.urls)this.urls.push(this.map._requestManager.transformRequest(i,e.R.Source).url);e.aU(this.urls,(t,i)=>{this._loaded=!0,t?this.fire(new e.y(t)):i&&(this.video=i,this.video.loop=!0,this.video.setAttribute("playsinline",""),this.video.addEventListener("playing",()=>{this.map.triggerRepaint()}),this.map&&this.video.play(),this._finishLoading())})}pause(){this.video&&this.video.pause()}play(){this.video&&this.video.play()}seek(t){if(this.video){const i=this.video.seekable;ti.end(0)?this.fire(new e.y(new e.V(`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.urls,coordinates:this.coordinates}}hasTransition(){return this.video&&!this.video.paused}},image:e.aT,model:e.aW,"batched-model":class extends e.E{constructor(e,t,i,r){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(r)}onAdd(e){this.map=e,this.load()}reload(){this.cancelTileJSONRequest();const t=e.B(this.id,this.scope);this.load(()=>this.map.style.clearSource(t))}cancelTileJSONRequest(){this._tileJSONRequest&&(this._tileJSONRequest.cancel(),this._tileJSONRequest=null)}load(t){this._loaded=!1,this.fire(new e.z("dataloading",{dataType:"source"}));const i=Array.isArray(this.map._language)?this.map._language.join():this.map._language,r=this.map.getWorldview();this._tileJSONRequest=ot(this._options,this.map._requestManager,i,r,(n,o)=>{this._tileJSONRequest=null,this._loaded=!0,n?(i&&console.warn(`Ensure that your requested language string is a valid BCP-47 code or list of codes. Found: ${i}`),r&&2!==r.length&&console.warn(`Requested worldview strings must be a valid ISO alpha-2 code. Found: ${r}`),this.fire(new e.y(n))):o&&(Object.assign(this,o),o.bounds&&(this.tileBounds=new at(o.bounds,this.minzoom,this.maxzoom)),P(o.tiles,this.map._requestManager._customAccessToken),this.fire(new e.z("data",{dataType:"source",sourceDataType:"metadata"})),this.fire(new e.z("data",{dataType:"source",sourceDataType:"content"}))),t&&t(n)})}hasTransition(){return!1}hasTile(e){return!this.tileBounds||this.tileBounds.contains(e.canonical)}loaded(){return this._loaded}loadTile(t,i){const r=this.map._requestManager.normalizeTileURL(t.tileID.canonical.url(this.tiles,this.scheme)),n={request:this.map._requestManager.transformRequest(r,e.R.Tile),data:void 0,uid:t.uid,tileID:t.tileID,tileZoom:t.tileZoom,zoom:t.tileID.overscaledZ,tileSize:this.tileSize*t.tileID.overscaleFactor(),type:this.type,source:this.id,scope:this.scope,showCollisionBoxes:this.map.showCollisionBoxes,isSymbolTile:t.isSymbolTile,brightness:this.map.style&&this.map.style.getBrightness()||0,pixelRatio:e.o.devicePixelRatio,promoteId:this.promoteId};if(t.actor&&"expired"!==t.state)if("loading"===t.state)t.reloadCallback=i;else{if(t.buckets){const e=Object.values(t.buckets);for(const t of e)t.dirty=!0;return void(t.state="loaded")}t.request=t.actor.send("reloadTile",n,o.bind(this))}else t.actor=this.dispatcher.getActor(),t.request=t.actor.send("loadTile",n,o.bind(this),void 0,!0);function o(e,r){return t.aborted?i(null):e&&404!==e.status?i(e):(this.map._refreshExpiredTiles&&r&&t.setExpiryData(r),t.loadModelData(r,this.map.painter),t.state="loaded",void i(null))}}serialize(){return Object.assign({},this._options)}},canvas:class extends e.aT{constructor(t,i,r,n){super(t,i,r,n),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.y(new e.V(`sources.${t}`,null,'"coordinates" property must be an array of 4 longitude/latitude array pairs'))):this.fire(new e.y(new e.V(`sources.${t}`,null,'missing required property "coordinates"'))),i.animate&&"boolean"!=typeof i.animate&&this.fire(new e.y(new e.V(`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.y(new e.V(`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.y(new e.V(`sources.${t}`,null,'missing required property "canvas"'))),this.options=i,this.animate=void 0===i.animate||i.animate}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.y(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.aV||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,r,n){super(),this.id=t,this.type="custom",this._dataType="raster",this._dispatcher=r,this._implementation=i,this.setEventedParent(n),this.scheme="xyz",this.minzoom=0,this.maxzoom=22,this.tileSize=512,this._loaded=!1,this.roundZoom=!0,this._implementation||this.fire(new e.y(new Error(`Missing implementation for ${this.id} custom source`))),this._implementation.loadTile||this.fire(new e.y(new Error(`Missing loadTile implementation for ${this.id} custom source`))),this._implementation.bounds&&(this.tileBounds=new at(this._implementation.bounds,this.minzoom,this.maxzoom)),i.update=this._update.bind(this),i.clearTiles=this._clearTiles.bind(this),i.coveringTiles=this._coveringTiles.bind(this),Object.assign(this,e.aH(i,["dataType","scheme","minzoom","maxzoom","tileSize","attribution","minTileCacheSize","maxTileCacheSize"]))}serialize(){return e.aH(this,["type","scheme","minzoom","maxzoom","tileSize","attribution"])}load(){this._loaded=!0,this.fire(new e.z("data",{dataType:"source",sourceDataType:"metadata"})),this.fire(new e.z("data",{dataType:"source",sourceDataType:"content"}))}loaded(){return this._loaded}onAdd(t){this.map=t,this._loaded=!1,this.fire(new e.z("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:r}=e.canonical;return this._implementation.hasTile({x:t,y:i,z:r})}return!this.tileBounds||this.tileBounds.contains(e.canonical)}loadTile(e,t){const{x:i,y:r,z:n}=e.tileID.canonical,o=new AbortController;e.request=Promise.resolve(this._implementation.loadTile({x:i,y:r,z:n},{signal:o.signal})).then(function(i){return delete e.request,e.aborted?(e.state="unloaded",t(null)):void 0===i?(e.state="errored",t(null)):null===i?(this.loadTileData(e,{width:this.tileSize,height:this.tileSize,data:null}),e.state="loaded",t(null)):function(e){return e instanceof ImageData||e instanceof HTMLCanvasElement||e instanceof ImageBitmap||e instanceof HTMLImageElement}(i)?(this.loadTileData(e,i),e.state="loaded",void t(null)):(e.state="errored",t(new Error(`Can't infer data type for ${this.id}, only raster data supported at the moment`)))}.bind(this)).catch(i=>{"AbortError"!==i.name&&(e.state="errored",t(i))}),e.request.cancel=()=>o.abort()}loadTileData(e,t){e.setTexture(t,this.map.painter)}unloadTile(t,i){if(t.texture&&t.texture instanceof e.T?(t.destroy(!0),t.texture&&t.texture instanceof e.T&&this.map.painter.saveTileTexture(t.texture)):t.destroy(),this._implementation.unloadTile){const{x:e,y:i,z:r}=t.tileID.canonical;this._implementation.unloadTile({x:e,y:i,z:r})}i&&i()}abortTile(e,t){e.request&&e.request.cancel&&(e.request.cancel(),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.B(this.id,this.scope);this.map.style.clearSource(t)}_update(){this.fire(new e.z("data",{dataType:"source",sourceDataType:"content"}))}}},pt=function(t,i,r,n){const o=new dt[i.type](t,i,r,n);if(o.id!==t)throw new Error(`Expected Source id to be ${t} instead of ${o.id}`);return e.aX(["load","abort","unload","serialize","prepare"],o),o};function ft(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 mt(e,t,i,r=""){if(e.uniqueFeatureID){const n=ft(e,t,r);if(i.has(n))return!0;i.add(n)}return!1}function gt(e,t,i,r,n=!1){const o=t.sourceCache.transform,s=t.sourceCache.tilesIn(e,t.has3DLayers,n);s.sort(yt);const a=[];for(const e of s){const s=e.tile.queryRenderedFeatures(t,e,i,r,o,n);Object.keys(s).length&&a.push({wrappedTileID:e.tile.tileID.wrapped().key,queryResults:s})}for(const i in t.layers){const n=t.layers[i];if(n.styleLayer){const i=n.styleLayer.queryRenderedFeatures(e,t.sourceCache,r);Object.keys(i).length&&a.push({wrappedTileID:0,queryResults:i})}}return 0===a.length?{}:function(e){const t={},i={};for(const r of e){const e=r.queryResults,n=r.wrappedTileID,o=i[n]=i[n]||{};for(const i in e){const r=e[i],n=o[i]=o[i]||{},s=t[i]=t[i]||[];for(const e of r)n[e.featureIndex]||(n[e.featureIndex]=!0,s.push(e))}}return t}(a)}function _t(e,t,i,r,n,o){const s={},a=r.queryRenderedSymbols(e),l=[];for(const e of Object.keys(a).map(Number))l.push(n[e]);l.sort(yt);for(const e of l){const r=e.featureIndex.lookupSymbolFeatures(a[e.bucketInstanceId],e.bucketIndex,e.sourceLayerIndex,t,i,o);for(const t in r){const i=s[t]=s[t]||[],n=r[t];n.sort((t,i)=>{const r=e.featureSortOrder;if(r){const e=r.indexOf(t.featureIndex);return r.indexOf(i.featureIndex)-e}return i.featureIndex-t.featureIndex});for(const e of n)i.push(e)}}return s}function At(e,t){const i=e.getRenderableIds().map(t=>e.getTileByID(t)),r=[],n={};for(let e=0;et.getLayer(e)).filter(Boolean);if(0!==e.length){r.layers=e,r.stateDependentLayerIds&&(r.stateDependentLayers=r.stateDependentLayerIds.map(t=>e.filter(e=>e.id===t)[0]));for(const t of e)i[t.fqid]=r}}return i}const xt=32,bt=33,wt=new Uint16Array(8184);for(let e=0;e<2046;e++){let t=e+2,i=0,r=0,n=0,o=0,s=0,a=0;for(1&t?n=o=s=xt:i=r=a=xt;(t>>=1)>1;){const e=i+n>>1,l=r+o>>1;1&t?(n=i,o=r,i=s,r=a):(i=n,r=o,n=s,o=a),s=e,a=l}const l=4*e;wt[l+0]=i,wt[l+1]=r,wt[l+2]=n,wt[l+3]=o}const Tt=new Uint16Array(2178),Et=new Uint8Array(1089),Ct=new Uint16Array(1089);function Bt(e){return 0===e?-.03125:32===e?.03125:0}const St={type:2,extent:e.al,loadGeometry:()=>[[new e.P(0,0),new e.P(e.al+1,0),new e.P(e.al+1,e.al+1),new e.P(0,e.al+1),new e.P(0,0)]]};class It{constructor(t,i,r,n,o,s){this.tileID=t,this.uid=e.b1(),this.uses=0,this.tileSize=i,this.tileZoom=r,this.buckets={},this.expirationTime=null,this.queryPadding=0,this.hasSymbolBuckets=!1,this.hasRTLText=!1,this.dependencies={},this.isRaster=o,n&&n.style&&(this._lastUpdatedBrightness=n.style.getBrightness()),this.expiredRequestCount=0,this.state="loading",n&&n.transform&&(this.projection=n.transform.projection),this.worldview=s,this._hasAppearances=null}registerFadeDuration(t){const i=t+this.timeAdded;ie)t=!1;else if(i)if(this.expirationTimee.appearances&&e.appearances.length>0))return!0;return!1}updateBuckets(t,i){if(!this.latestFeatureIndex)return;if(!t.style)return;const r=this.latestFeatureIndex.loadVTLayers(),n=t.style.listImages(),o=t.style.getBrightness();for(const s in this.buckets){if(!t.style.hasLayer(s))continue;const a=this.buckets[s],l=a.layers[0],c=l.sourceLayer||"_geojsonTileLayer",u=r[c],h=t.style.getLayerSourceCache(l);let d={};h&&(d=h._state.getState(c,void 0));const p=this.imageAtlas?Object.fromEntries(this.imageAtlas.patternPositions):{},f=Object.keys(d).length>0&&!i;if(a.hasAppearances=a.layers.some(e=>e.appearances&&e.appearances.length>0),(f&&0!==a.stateDependentLayers.length||i)&&a.update(d,u,n,p,f?a.stateDependentLayers:a.layers,i,o),f&&0!==a.stateDependentLayers.length||i||a.hasAppearances){const e={zoom:t.transform.zoom,pitch:t.transform.pitch,brightness:t.style.getBrightness()||0,worldview:t.worldview};a.updateAppearances(this.tileID.canonical,d,n,e)}(a instanceof e.b9||a instanceof e.ba)&&t._terrain&&t._terrain.enabled&&h&&a.uploadPending()&&t._terrain._clearRenderCacheForTile(h.id,this.tileID);const m=t&&t.style&&t.style.getOwnLayer(s);m&&(this.queryPadding=Math.max(this.queryPadding,m.queryRadius(a)))}}holdingForFade(){return void 0!==this.symbolFadeHoldUntil}symbolFadeFinished(){return!this.symbolFadeHoldUntil||this.symbolFadeHoldUntil=0;e--){const t=4*e,i=wt[t+0],r=wt[t+1],n=wt[t+2],o=wt[t+3],s=i+n>>1,a=r+o>>1,l=s+a-r,c=a+i-s,u=r*bt+i,h=o*bt+n,d=a*bt+s,p=Math.hypot((Tt[2*u+0]+Tt[2*h+0])/2-Tt[2*d+0],(Tt[2*u+1]+Tt[2*h+1])/2-Tt[2*d+1])>=16;Et[d]=Et[d]||(p?1:0),e<1022&&(Et[d]=Et[d]||Et[(r+c>>1)*bt+(i+l>>1)]||Et[(o+c>>1)*bt+(n+l>>1)])}const o=new e.a$,s=new e.b0;let a=0;function l(t,i){const r=i*bt+t;return 0===Ct[r]&&(o.emplaceBack(Tt[2*r+0],Tt[2*r+1],t*e.al/xt,i*e.al/xt),Ct[r]=++a),Ct[r]-1}function c(e,t,i,r,n,o){const a=e+i>>1,u=t+r>>1;if(Math.abs(e-n)+Math.abs(t-o)>1&&Et[u*bt+a])c(n,o,e,t,a,u),c(i,r,n,o,a,u);else{const a=l(e,t),c=l(i,r),u=l(n,o);s.emplaceBack(a,c,u)}}return c(0,0,xt,xt,xt,0),c(xt,xt,0,0,0,xt),{vertices:o,indices:s}}(this.tileID.canonical,i);n=t.vertices,o=t.indices}else{n=new e.a$,o=new e.b0;for(const{x:e,y:t}of r)n.emplaceBack(e,t,0,0);const t=e.bg(n.int16.subarray(0,4*n.length),void 0,4);for(let e=0;e0&&(l=e.bk(new Float64Array(16),i.globeMatrix)),this._makeGlobeTileDebugBorderBuffer(t,n,i,s,l,a),this._makeGlobeTileDebugTextBuffer(t,n,i,s,l,a)}_globePoint(t,i,r,n,o,s,a){let l=e.bl(t,i,r);if(s){const o=1<.5?d=-1:h<-.5&&(d=1);let p=(t/e.al+r.x)/o+d,f=(i/e.al+r.y)/o;p=(p-c)*n._pixelsPerMercatorPixel+c,f=(f-u)*n._pixelsPerMercatorPixel+u;const m=[p*n.worldSize,f*n.worldSize,0];e.af(m,m,s),l=e.bm(l,m,a)}return e.af(l,l,o)}_makeGlobeTileDebugBorderBuffer(t,i,r,n,o,s){const a=new e.bc,l=new e.bd,c=new e.bn,u=(e,t,u,h,d)=>{const p=(u-e)/(d-1),f=(h-t)/(d-1),m=a.length;for(let u=0;uh*e+t;for(let e=0;e{if(e)i(e);else try{const e=r.getHeaderLength(n);if(e>t)return void(this.request=this.fetchHeader(e,i));r.parseHeader(n),this._isHeaderLoaded=!0;let s=0;for(const e of Object.values(r.layers))s=Math.max(s,e.dataIndex[e.dataIndex.length-1].lastByte);n.byteLength>=s&&(this.entireBuffer=n),i(null,this.entireBuffer||n,o)}catch(e){i(e)}}),this.request}fetchBandForRender(e,t,i,r){this.fetchBand(e,t,i,n=>{if(n)return void r(n);this.updateTextureDescriptor(e,t,i);const o=this.textureDescriptorPerLayer.get(t);r(null,o?o.img:null)})}fetchBand(t,i,r,n,o=!0){const s=this._mrt;if(!this._isHeaderLoaded||!s)return void n(new Error("Tile header is not ready"));const a=this.actor;if(!a)return void n(new Error("Can't fetch tile band without an actor"));let l;const c=e.B(String(r),e.B(this.tileID.key,t));let u=this._taskQueue.get(c);u?u.add(n):(u=new Set,u.add(n),this._taskQueue.set(c,u));const h=(e,t)=>{l.complete(e,t),e?n(e):(u.values().forEach(e=>e(null,t)),this._taskQueue.delete(c))},d=(e,t)=>{if(e)return n(e);const r=a.send("decodeRasterArray",{type:"raster-array",source:this.source,scope:this.scope,tileID:this.tileID,uid:this.uid,buffer:t,task:l},h,void 0,!0);if(null!==i){const e=this._workQueuePerLayer.get(i)||[];e.push(()=>{r&&r.cancel(),l.cancel()}),this._workQueuePerLayer.has(i)||this._workQueuePerLayer.set(i,e)}};let p;try{p=s.getLayer(t)}catch(e){if("reloading"===this.state)return;throw e}if(!p)return void n(new Error(`Unknown sourceLayer "${t}"`));if(p.hasDataForBand(r))return u.values().forEach(e=>e(null,null)),void this._taskQueue.delete(c);const f=p.getDataRange([r]);if(l=s.createDecodingTask(f),!l||l.tasks.length)if(null!==i&&this.flushQueues(i),this.entireBuffer)d(null,this.entireBuffer.slice(f.firstByte,f.lastByte+1));else{const t=Object.assign({},this.requestParams,{headers:{Range:`bytes=${f.firstByte}-${f.lastByte}`}}),r=e.bt(t,d);if(null!==i){const e=this._fetchQueuePerLayer.get(i)||[];e.push(()=>{r.cancel(),l.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,r){if(!this._mrt)return;const n=this._mrt.getLayer(t);if(!n||!n.hasBand(r)||!n.hasDataForBand(r))return;const{bytes:o,tileSize:s,buffer:a,offset:l,scale:c}=n.getBandView(r),u=s+2*a,h=new e.q({width:u,height:u},o),d=this.texturePerLayer.get(i);d&&d instanceof e.T&&d.update(h,{premultiply:!1}),this.textureDescriptorPerLayer.set(i,{layer:t,band:r,img:h,buffer:a,offset:l,tileSize:s,format:n.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}}class Pt{constructor(e,t){this.max=e,this.onRemove=t,this.reset()}reset(){for(const e in this.data)for(const t of this.data[e])t.timeout&&clearTimeout(t.timeout),this.onRemove(t.value);return this.data={},this.order=[],this}add(e,t,i){const r=e.wrapped().key;void 0===this.data[r]&&(this.data[r]=[]);const n={value:t,timeout:void 0};if(void 0!==i&&(n.timeout=setTimeout(()=>{this.remove(e,n)},i)),this.data[r].push(n),this.order.push(r),this.order.length>this.max){const e=this._getAndRemoveByKey(this.order[0]);e&&this.onRemove(e)}return this}has(e){return e.wrapped().key in this.data}getAndRemove(e){return this.has(e)?this._getAndRemoveByKey(e.wrapped().key):null}_getAndRemoveByKey(e){const t=this.data[e].shift();return t.timeout&&clearTimeout(t.timeout),0===this.data[e].length&&delete this.data[e],this.order.splice(this.order.indexOf(e),1),t.value}getByKey(e){const t=this.data[e];return t?t[0].value:null}get(e){return this.has(e)?this.data[e.wrapped().key][0].value:null}remove(e,t){if(!this.has(e))return this;const i=e.wrapped().key,r=void 0===t?0:this.data[i].indexOf(t),n=this.data[i][r];return this.data[i].splice(r,1),n.timeout&&clearTimeout(n.timeout),0===this.data[i].length&&delete this.data[i],this.onRemove(n.value),this.order.splice(this.order.indexOf(i),1),this}setMaxSize(e){for(this.max=e;this.order.length>this.max;){const e=this._getAndRemoveByKey(this.order[0]);e&&this.onRemove(e)}return this}filter(e){const t=[];for(const i in this.data)for(const r of this.data[i])e(r.value)||t.push(r);for(const e of t)this.remove(e.value.tileID,e)}}class Rt{constructor(){this.state={},this.stateChanges={},this.deletedStates={}}updateState(e,t,i){const r=String(t);if(this.stateChanges[e]=this.stateChanges[e]||{},this.stateChanges[e][r]=this.stateChanges[e][r]||{},Object.assign(this.stateChanges[e][r],i),null===this.deletedStates[e]){this.deletedStates[e]={};for(const t in this.state[e])t!==r&&(this.deletedStates[e][t]=null)}else if(this.deletedStates[e]&&null===this.deletedStates[e][r]){this.deletedStates[e][r]={};for(const t in this.state[e][r])i[t]||(this.deletedStates[e][r][t]=null)}else for(const t in i)this.deletedStates[e]&&this.deletedStates[e][r]&&null===this.deletedStates[e][r][t]&&delete this.deletedStates[e][r][t]}removeFeatureState(e,t,i){if(null===this.deletedStates[e])return;const r=String(t);if(this.deletedStates[e]=this.deletedStates[e]||{},i&&void 0!==t)null!==this.deletedStates[e][r]&&(this.deletedStates[e][r]=this.deletedStates[e][r]||{},this.deletedStates[e][r][i]=null);else if(void 0!==t)if(this.stateChanges[e]&&this.stateChanges[e][r])for(i in this.deletedStates[e][r]={},this.stateChanges[e][r])this.deletedStates[e][r][i]=null;else this.deletedStates[e][r]=null;else this.deletedStates[e]=null}getState(e,t){const i=this.state[e]||{},r=this.stateChanges[e]||{},n=this.deletedStates[e];if(null===n)return{};if(void 0!==t){const e=String(t),o=Object.assign({},i[e],r[e]);if(n){const e=n[t];if(null===e)return{};for(const t in e)delete o[t]}return o}const o=Object.assign({},i,r);if(n)for(const e in n)delete o[e];return o}initializeTileState(e,t){e.refreshFeatureState(t)}coalesceChanges(e,t){const i={};for(const e in this.stateChanges){this.state[e]=this.state[e]||{};const t={};for(const i in this.stateChanges[e])this.state[e][i]||(this.state[e][i]={}),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]||{};const t={};if(null===this.deletedStates[e])for(const i in this.state[e])t[i]={},this.state[e][i]={};else for(const i in this.deletedStates[e]){if(null===this.deletedStates[e][i])this.state[e][i]={};else 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.assign(i[e],t)}if(this.stateChanges={},this.deletedStates={},0!==Object.keys(i).length)for(const i in e)e[i].refreshFeatureState(t)}}class Lt extends e.E{constructor(e,t,i){super(),this.id=e,this._onlySymbols=i,t.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))}),t.on("error",()=>{this._sourceErrored=!0}),this._source=t,this._tiles={},this._cache=new Pt(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 Rt,this._isRaster="raster"===this._source.type||"raster-dem"===this._source.type||"raster-array"===this._source.type||"custom"===this._source.type&&"raster"===this._source._dataType}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}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)}_loadTile(e,t){return e.isSymbolTile=this._onlySymbols,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(Ft).map(e=>e.key)}getRenderableIds(t,i){const r=[];for(const e in this._tiles)this._isIdRenderable(+e,t,i)&&r.push(this._tiles[e]);return t?r.sort((t,i)=>{const r=t.tileID,n=i.tileID,o=new e.P(r.canonical.x,r.canonical.y)._rotate(this.transform.angle),s=new e.P(n.canonical.x,n.canonical.y)._rotate(this.transform.angle);return r.overscaledZ-n.overscaledZ||s.y-o.y||s.x-o.x}).map(e=>e.tileID.key):r.map(e=>e.tileID).sort(Ft).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,r,n,o){if(n){if(t.state="errored",404!==n.status)this._source.fire(new e.y(n,{tile:t}));else{if(this._source.fire(new e.z("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)}return}t.timeAdded=e.o.now(),"expired"===r&&(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 s=new Map;o&&o.responseHeaders&&(s=o.responseHeaders),this._source.fire(new e.z("data",{dataType:"source",tile:t,coord:t.tileID,sourceCacheId:this.id,responseHeaders:s}))}_backfillDEM(e){const t=this.getRenderableIds();for(let r=0;r1||(Math.abs(i)>1&&(1===Math.abs(i+n)?i+=n:1===Math.abs(i-n)&&(i-=n)),t.dem&&e.dem&&(e.dem.backfillBorder(t.dem,i,r),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,r){for(const n in this._tiles){let o=this._tiles[n];if(r[n]||!o.hasData()||o.tileID.overscaledZ<=t||o.tileID.overscaledZ>i)continue;let s=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()&&(s=e)}let a=s;for(;a.overscaledZ>t;)if(a=a.scaledTo(a.overscaledZ-1),e[a.key]){r[s.key]=s;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),r=this._getLoadedTile(t);if(r)return r}}_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,r=Math.ceil(e.height/t)+1,n=Math.floor(i*r*5),o="number"==typeof this._minTileCacheSize?Math.max(this._minTileCacheSize,n):n,s="number"==typeof this._maxTileCacheSize?Math.min(this._maxTileCacheSize,o):o;this._cache.setMaxSize(s)}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 r=this._tiles[i];r.tileID=r.tileID.unwrapTo(r.tileID.wrap+t),e[r.tileID.key]=r}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,r,n,o){if(this.transform=t,!this._sourceLoaded||this._paused||this.transform.freezeTileCoverage)return;if(this.usedForTerrain&&!r)return;this.updateCacheSize(t,i),"globe"!==this.transform.projection.name&&this.handleWrapJump(this.transform.center.lng),this._shadowCasterTiles={},this._coveredTiles={};const s="batched-model"===this._source.type;let a,l=this._source.maxzoom;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)}if(this.used||this.usedForTerrain){if(this._source.tileID)a=t.getVisibleUnwrappedCoordinates(this._source.tileID).map(t=>new e.aP(t.canonical.z,t.wrap,t.canonical.z,t.canonical.x,t.canonical.y));else if(0!==this.tileCoverLift){const n=t.clone();n.tileCoverLift=this.tileCoverLift,a=n.coveringTiles({tileSize:i||this._source.tileSize,minzoom:this._source.minzoom,maxzoom:l,roundZoom:this._source.roundZoom&&!r,reparseOverscaled:this._source.reparseOverscaled,isTerrainDEM:this.usedForTerrain,calculateQuadrantVisibility:s}),this._source.minzoom<=1&&"globe"===t.projection.name&&(a.push(new e.aP(1,0,1,0,0)),a.push(new e.aP(1,0,1,1,0)),a.push(new e.aP(1,0,1,0,1)),a.push(new e.aP(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&&!r,reparseOverscaled:this._source.reparseOverscaled,isTerrainDEM:this.usedForTerrain,calculateQuadrantVisibility:s}),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&&!kt(this._source.type)){const e=t.coveringZoomLevel({tileSize:i||this._source.tileSize,roundZoom:this._source.roundZoom&&!r}),l=Math.min(e,this._source.maxzoom);if(s){const e=t.extendTileCover(a,l);for(const t of e)a.push(t)}else if(o){const e=t.extendTileCoverToNearPlane(a,this.transform.getFrustum(l),l);for(const t of e)a.push(t)}else if(this.castsShadows&&n){const e=t.extendTileCover(a,l,n);for(const t of e)this._shadowCasterTiles[t.key]=!0,a.push(t)}}const u=this._updateRetainedTiles(a);if(kt(this._source.type)&&0!==a.length){const t={},i={},r=Object.keys(u);for(const n of r){const r=u[n],o=this._tiles[n];if(!o||o.fadeEndTime&&o.fadeEndTime<=e.o.now())continue;const s=this.findLoadedParent(r,Math.max(r.overscaledZ-Lt.maxOverzooming,this._source.minzoom));s&&(this._addTile(s.tileID),t[s.tileID.key]=s.tileID),i[n]=r}const n=a[a.length-1].overscaledZ;for(const e in this._tiles){const t=this._tiles[e];if(u[e]||!t.hasData())continue;let r=t.tileID;for(;r.overscaledZ>n;){r=r.scaledTo(r.overscaledZ-1);const n=this._tiles[r.key];if(n&&n.hasData()&&i[r.key]){u[e]=t.tileID;break}}}for(const e in t)u[e]||(this._coveredTiles[e]=!0,u[e]=t[e])}for(const e in u)this._tiles[e].clearFadeHold();const h=e.bu(this._tiles,u);for(const e of h){const t=this._tiles[e];t.hasSymbolBuckets&&!t.holdingForFade()?t.setHoldDuration(this.map._fadeDuration):t.hasSymbolBuckets&&!t.symbolFadeFinished()||this._removeTile(+e)}this._updateLoadedParentTileCache(),this._onlySymbols&&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={},r=e.reduce((e,t)=>Math.min(e,t.overscaledZ),1/0),n=e[0].overscaledZ,o=Math.max(n-Lt.maxOverzooming,this._source.minzoom),s=Math.max(n+Lt.maxUnderzooming,this._source.minzoom),a={};for(const i of e){const e=this._addTile(i);t[i.key]=i,e.hasData()||r=this._source.maxzoom){const e=r.children(this._source.maxzoom)[0],i=this.getTile(e);if(i&&i.hasData()){t[e.key]=e;continue}}else{const e=r.children(this._source.maxzoom);if(t[e[0].key]&&t[e[1].key]&&t[e[2].key]&&t[e[3].key])continue}let n=e.wasRequested();for(let s=r.overscaledZ-1;s>=o;--s){const o=r.scaledTo(s);if(i[o.key])break;if(i[o.key]=!0,e=this.getTile(o),!e&&n&&(e=this._addTile(o)),e&&(t[o.key]=o,n=e.wasRequested(),e.hasData()))break}}return t}_updateLoadedParentTileCache(){this._loadedParentTiles={};for(const e in this._tiles){const t=[];let i,r=this._tiles[e].tileID;for(;r.overscaledZ>0;){if(r.key in this._loadedParentTiles){i=this._loadedParentTiles[r.key];break}t.push(r.key);const e=r.scaledTo(r.overscaledZ-1);if(i=this._getLoadedTile(e),i)break;r=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 r=Boolean(i);if(!r){const e=this.map?this.map.painter:null,r=this._source.tileSize*t.overscaleFactor();i="raster-array"===this._source.type?new Mt(t,r,this.transform.tileZoom,e,this._isRaster):new It(t,r,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,r||this._source.fire(new e.z("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,r){const n=[],o=this.transform;if(!o)return n;const s="globe"===o.projection.name,a=e.aF(o.center.lng);for(const l in this._tiles){const c=this._tiles[l];if(r&&c.clearQueryDebugViz(),c.holdingForFade())continue;let u;if(s){const t=c.tileID.canonical;if(0===t.z){const i=[Math.abs(e.aA(a,...Dt(t,-1))-a),Math.abs(e.aA(a,...Dt(t,1))-a)];u=[0,2*i.indexOf(Math.min(...i))-1]}else{const i=[Math.abs(e.aA(a,...Dt(t,-1))-a),Math.abs(e.aA(a,...Dt(t,0))-a),Math.abs(e.aA(a,...Dt(t,1))-a)];u=[i.indexOf(Math.min(...i))-1]}}else u=[0];for(const e of u){const r=t.containsTile(c,o,i,e);r&&n.push(r)}}return n}getShadowCasterCoordinates(){return this._getRenderableCoordinates(!1,!0)}getVisibleCoordinates(e){return this._getRenderableCoordinates(e)}_getRenderableCoordinates(e,t){const i=this.getRenderableIds(e,t).map(e=>this._tiles[e].tileID),r="globe"===this.transform.projection.name;for(const e of i)e.projMatrix=this.transform.calculateProjMatrix(e.toUnwrapped()),e.expandedProjMatrix=r?this.transform.calculateProjMatrix(e.toUnwrapped(),!1,!0):e.projMatrix;return i}sortCoordinatesByDistance(e){const t=e.slice(),i=this.transform._camera.position,r=this.transform._camera.forward(),n={};for(const e of t){const t=1/(1<n[e.key]-n[t.key]),t}hasTransition(){if(this._source.hasTransition())return!0;if(kt(this._source.type))for(const t in this._tiles){const i=this._tiles[t];if(void 0!==i.fadeEndTime&&i.fadeEndTime>=e.o.now())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 r=this._tiles[e];r&&r.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 r=new Map,n=Array.isArray(t)?t:[t],o=this.map.painter.terrain,s=this.usedForTerrain&&o?o.getScaledDemTileSize():this._source.tileSize;for(const e of n){const t=e.coveringTiles({tileSize:s,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)r.set(e.key,e);this.usedForTerrain&&e.updateElevation(!1)}const a=Array.from(r.values());e.bv(a,(e,t)=>{const i=new It(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 Ft(e,t){const i=Math.abs(2*e.wrap)-+(e.wrap<0),r=Math.abs(2*t.wrap)-+(t.wrap<0);return e.overscaledZ-t.overscaledZ||r-i||t.canonical.y-e.canonical.y||t.canonical.x-e.canonical.x}function kt(e){return"raster"===e||"image"===e||"video"===e||"custom"===e}function Dt(e,t){const i=1<0:"building"===i.type?r=!i.isHidden(e)&&i.paint.get("building-opacity")>0:"model"===i.type&&(r=!i.isHidden(e)&&i.paint.get("model-opacity").constantOr(1)>0),this.layersGotHidden=this.layersGotHidden||!r&&t.visible,t.visible=r}}updateZOffset(e,t){this.currentBuildingBuckets=[];for(const e of this.layers){const i=e.layer,r=this.style.getLayerSourceCache(i);let n=1;"fill-extrusion"===i.type?n=e.visible?i.paint.get("fill-extrusion-vertical-scale"):0:"building"===i.type&&(n=e.visible?i.paint.get("building-vertical-scale"):0);let o=r?r.getTile(t):null;if(!o&&r)for(const e in r._tiles){const i=r._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:n})}e.hasAnyZOffset=!1;let i=!1;for(let r=0;r{e in i&&(r[e]=i[e])}),r}function Ut(e){e=e.slice();const t=Object.create(null);for(let i=0;i0?(n-s)/a:0;return this.points[o].mult(1-l).add(this.points[i].mult(l))}}class Jt{constructor(e,t,i){const r=this.boxCells=[],n=this.circleCells=[];this.xCellCount=Math.ceil(e/i),this.yCellCount=Math.ceil(t/i);for(let e=0;ethis.width||r<0||t>this.height)return!n&&[];const s=[];if(e<=0&&t<=0&&this.width<=i&&this.height<=r){if(n)return!0;for(let e=0;e0:s}_queryCircle(e,t,i,r,n){const o=e-i,s=e+i,a=t-i,l=t+i;if(s<0||o>this.width||l<0||a>this.height)return!r&&[];const c=[];return this._forEachCell(o,a,s,l,this._queryCellCircle,c,{hitTest:r,circle:{x:e,y:t,radius:i},seenUids:{box:{},circle:{}}},n),r?c.length>0:c}query(e,t,i,r,n){return this._query(e,t,i,r,!1,n)}hitTest(e,t,i,r,n){return this._query(e,t,i,r,!0,n)}hitTestCircle(e,t,i,r){return this._queryCircle(e,t,i,!0,r)}_queryCell(e,t,i,r,n,o,s,a){const l=s.seenUids,c=this.boxCells[n];if(null!==c){const n=this.bboxes;for(const u of c)if(!l.box[u]){l.box[u]=!0;const c=4*u;if(e<=n[c+2]&&t<=n[c+3]&&i>=n[c+0]&&r>=n[c+1]&&(!a||a(this.boxKeys[u]))){if(s.hitTest)return o.push(!0),!0;o.push({key:this.boxKeys[u],x1:n[c],y1:n[c+1],x2:n[c+2],y2:n[c+3]})}}}const u=this.circleCells[n];if(null!==u){const n=this.circles;for(const c of u)if(!l.circle[c]){l.circle[c]=!0;const u=3*c;if(this._circleAndRectCollide(n[u],n[u+1],n[u+2],e,t,i,r)&&(!a||a(this.circleKeys[c]))){if(s.hitTest)return o.push(!0),!0;{const e=n[u],t=n[u+1],i=n[u+2];o.push({key:this.circleKeys[c],x1:e-i,y1:t-i,x2:e+i,y2:t+i})}}}}}_queryCellCircle(e,t,i,r,n,o,s,a){const l=s.circle,c=s.seenUids,u=this.boxCells[n];if(null!==u){const e=this.bboxes;for(const t of u)if(!c.box[t]){c.box[t]=!0;const i=4*t;if(this._circleAndRectCollide(l.x,l.y,l.radius,e[i+0],e[i+1],e[i+2],e[i+3])&&(!a||a(this.boxKeys[t])))return o.push(!0),!0}}const h=this.circleCells[n];if(null!==h){const e=this.circles;for(const t of h)if(!c.circle[t]){c.circle[t]=!0;const i=3*t;if(this._circlesCollide(e[i],e[i+1],e[i+2],l.x,l.y,l.radius)&&(!a||a(this.circleKeys[t])))return o.push(!0),!0}}}_forEachCell(e,t,i,r,n,o,s,a){const l=this._convertToXCellCoord(e),c=this._convertToYCellCoord(t),u=this._convertToXCellCoord(i),h=this._convertToYCellCoord(r);for(let d=l;d<=u;d++)for(let l=c;l<=h;l++)if(n.call(this,e,t,i,r,this.xCellCount*l+d,o,s,a))return}_convertToXCellCoord(e){return Math.max(0,Math.min(this.xCellCount-1,Math.floor(e*this.xScale)))}_convertToYCellCoord(e){return Math.max(0,Math.min(this.yCellCount-1,Math.floor(e*this.yScale)))}_circlesCollide(e,t,i,r,n,o){const s=r-e,a=n-t,l=i+o;return l*l>s*s+a*a}_circleAndRectCollide(e,t,i,r,n,o,s){const a=(o-r)/2,l=Math.abs(e-(r+a));if(l>a+i)return!1;const c=(s-n)/2,u=Math.abs(t-(n+c));if(u>c+i)return!1;if(l<=a||u<=c)return!0;const h=l-a,d=u-c;return h*h+d*d<=i*i}}const Yt={unknown:0,flipRequired:1,flipNotRequired:2},ei=Math.tan(85*Math.PI/180);function ti(t,i,r,n,o,s,a){const l=e.bB();if(r)if("globe"===s.name){const t=e.bC(o,i);e.aB(l,l,t)}else{const t=e.bD([],a);l[0]=t[0],l[1]=t[1],l[4]=t[2],l[5]=t[3],n||e.bA(l,l,o.angle)}else e.aB(l,o.labelPlaneMatrix,t);return l}function ii(e,t,i,r,n,o,s){const a=ti(e,t,i,r,n,o,s);return"globe"===o.name&&i||(a[2]=a[6]=a[10]=a[14]=0),a}function ri(t,i,r,n,o,s,a){if(r){if("globe"===s.name){const l=ti(t,i,r,n,o,s,a);return e.bk(l,l),e.aB(l,t,l),l}{const i=e.by(t),r=e.bz([]);return r[0]=a[0],r[1]=a[1],r[4]=a[2],r[5]=a[3],e.aB(i,i,r),n||e.bA(i,i,-o.angle),i}}return o.glCoordMatrix}function ni(t,i,r,n){const o=[t,i,r,1];r?e.aC(o,o,n):mi(o,o,n);const s=o[3];return o[0]/=s,o[1]/=s,o[2]/=s,o}function oi(e,t){return Math.min(.5+e/t*.5,1.5)}function si(e,t){const i=e[0]/e[3],r=e[1]/e[3];return i>=-t[0]&&i<=t[0]&&r>=-t[1]&&r<=t[1]}function ai(t,i,r,n,o,s,a,l,c,u,h=1){const d=r.transform,p=n?t.textSizeData:t.iconSizeData,f=e.bJ(p,r.transform.zoom,h),m="globe"===d.projection.name,g=[256/r.width*2+1,256/r.height*2+1],_=n?t.text.dynamicLayoutVertexArray:t.icon.dynamicLayoutVertexArray;_.clear();let A=null;m&&(A=n?t.text.globeExtVertexArray:t.icon.globeExtVertexArray);const y=t.lineVertexArray,v=n?t.text.placedSymbolArray:t.icon.placedSymbolArray,x=r.transform.width/r.transform.height;let b,w=!1;for(let n=0;nMath.abs(r)?{useVertical:!0}:t===e.bK.vertical?n>0?{needsFlipping:!0}:null:i!==Yt.unknown&&function(e,t){return 0===e||Math.abs(t/e)>ei}(r,n)?i===Yt.flipRequired?{needsFlipping:!0}:null:r<0?{needsFlipping:!0}:null}function ui(t,i,r,n,o,s,a,l,c,u,h,d,p,f,m,g,_,A,y,v){const x=i/24,b=t.lineOffsetX*x,w=t.lineOffsetY*x,{lineStartIndex:T,glyphStartIndex:E,numGlyphs:C,segment:B,writingMode:S,flipState:I}=t,M=T+t.lineLength,P=t=>{if(h){const[i,r,n]=t.up,o=u.length;e.bM(h,o+0,i,r,n),e.bM(h,o+1,i,r,n),e.bM(h,o+2,i,r,n),e.bM(h,o+3,i,r,n)}const[i,r,n]=t.point;e.bN(u,i,r,n,t.angle)};if(C>1){const e=li(x,l,b,w,r,d,p,t,c,s,f,g,!1,_,A,y,v);if(!e)return{notEnoughRoom:!0};if(n&&!r){let[i,r,n]=e.first.point,[o,s,l]=e.last.point;[i,r]=ni(i,r,n,a),[o,s]=ni(o,s,l,a);const c=ci(S,I,(o-i)*m,s-r);if(t.flipState=c&&c.needsFlipping?Yt.flipRequired:Yt.flipNotRequired,c)return c}P(e.first);for(let e=E+1;e0?s:di(p,n,i,1,o,void 0,_,A.canonical),l=ci(S,I,(a[0]-i[0])*m,a[1]-i[1]);if(t.flipState=l&&l.needsFlipping?Yt.flipRequired:Yt.flipNotRequired,l)return l}const i=pi(x*l.getoffsetX(E),b,w,r,d,p,B,T,M,c,s,f,g,!1,!1,_,A,y,v);if(!i)return{notEnoughRoom:!0};P(i)}return{}}function hi(e,t,i,r,n){const{x:o,y:s,z:a}=r.projectTilePoint(e.x,e.y,t);if(!n)return ni(o,s,a,i);const[l,c,u]=n.getElevation(e,n.elevation,n.elevationFeature);return ni(o+l,s+c,a+u,i)}function di(t,i,r,n,o,s,a,l){const c=hi(t.sub(i)._unit()._add(t),l,o,a,s);return e.av(c,r,c),e.aw(c,c),e.bG(c,r,c,n)}function pi(t,i,r,n,o,s,a,l,c,u,h,d,p,f,m,g,_,A,y){const v=n?t-i:t+i;let x=v>0?1:-1,b=0;n&&(x*=-1,b=Math.PI),x<0&&(b+=Math.PI);let w=l+a+(x>0?0:1)|0,T=o,E=o,C=0,B=0;const S=Math.abs(v),I=[],M=[];let P=s,R=P,L=e.bE([]);const F=()=>di(R,P,E,S-C+1,h,p,g,_.canonical);for(;C+B<=S;){if(w+=x,w=c)return null;if(E=T,R=P,I.push(E),f&&M.push(R),P=new e.P(u.getx(w),u.gety(w)),T=d[w],!T){const e=hi(P,_.canonical,h,g,p);T=e[3]>0?d[w]=e:F()}C+=B;const t=e.av([],T,E),i=e.bF(E,T);if(r&&i>0&&B>0&&e.bI(L,t)/(B*i)0,y),w=c*b.perspectiveRatio,T=(r.x1*i+a.x-r.padding)*w+b.point.x,E=(r.y1*i+a.y-r.padding)*w+b.point.y,C=(r.x2*i+a.x+r.padding)*w+b.point.x,B=(r.y2*i+a.y+r.padding)*w+b.point.y,S=b.perspectiveRatio<=.55||b.occluded;return!this.isInsideGrid(T,E,C,B)||!l&&this.grid.hitTest(T,E,C,B,h)||S?{box:[],offscreen:!1,occluded:b.occluded}:{box:[T,E,C,B],offscreen:this.isOffscreen(T,E,C,B),occluded:!1}}placeCollisionCircles(t,i,r,n,o,s,a,l,c,u,h,d,p,f,m,g){const _=[],A=this.transform.elevation,y=t.getProjection(),v="road"===t.elevationType,x=!!A||v,b=e.bU.getAtTileOffsetFunc(g,this.transform.center.lat,this.transform.worldSize,y),w=new e.P(r.tileAnchorX,r.tileAnchorY),T=new e.P(r.tileAnchorX,r.tileAnchorY);let{x:E,y:C,z:B}=y.projectTilePoint(T.x,T.y,g.canonical),S=null;if(x){const e=v?t.getElevationFeatureForText(n):null;S={getElevation:b,elevation:A,elevationFeature:e};const[i,r,o]=b(w,A,e);E+=i,C+=r,B+=o}const I="globe"===y.name,M=this.projectAndGetPerspectiveRatio(l,E,C,B,g,I||!!A||this.transform.pitch>0,y),{perspectiveRatio:P}=M,R=(d?a/P:a*P)/e.bX,L=ni(E,C,B,c),F=r.lineOffsetX*R,k=r.lineOffsetY*R,D=e.an(t.layers[0].layout.get("text-max-angle")),O=Math.cos(D),z=M.signedDistanceFromCamera>0?li(R,s,F,k,v&&1===r.flipState,L,T,r,o,c,{},x&&!d?S:null,d&&x,y,g,d,O):null;let U=!1,N=!1,V=!0;if(z&&!M.occluded){const t=.5*f*P+m,r=new e.P(-100,-100),n=new e.P(this.screenRightBoundary,this.screenBottomBoundary),o=new Xt,{first:s,last:a}=z,l=s.path.length;let c=[];for(let e=l-1;e>=1;e--)c.push(s.path[e]);for(let e=1;e(x&&!I&&(i=b(re[3]<=0)&&(c=[]));let g=[];if(c.length>0){let t=1/0,i=-1/0,o=1/0,s=-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]),s=Math.max(s,e[1]);i>=r.x&&t<=n.x&&s>=r.y&&o<=n.y&&(g=[c.map(t=>new e.P(t[0],t[1]))],(tn.x||on.y)&&(g=e.bV(g,r.x,r.y,n.x,n.y)))}for(const e of g){o.reset(e,.25*t);let r=0;r=o.length<=.5*t?1:Math.ceil(o.paddedLength/d)+1;for(let e=0;e0){if(e.aC(l,l,t),this.fogState&&o&&"globe"!==a.name){const t=function(t,i,r,n,o,s){const a=s.calculateFogTileMatrix(o),l=[i,r,n];return e.af(l,l,a),je(t,e.ag(l),s.pitch,s._fov)}(this.fogState,i,r,n,o.toUnwrapped(),this.transform);c=t>.9}}else mi(l,l,t);const u=l[3];return{point:new e.P((l[0]/u+1)/2*this.transform.width+gi,(-l[1]/u+1)/2*this.transform.height+gi),perspectiveRatio:Math.min(.5+this.transform.getCameraToCenterDistance(a)/u*.5,1.5),signedDistanceFromCamera:u,occluded:s&&l[2]>u||c}}isOffscreen(e,t,i,r){return i=this.screenRightBoundary||rthis.screenBottomBoundary}isInsideGrid(e,t,i,r){return i>=0&&e=0&&te.collisionGroupID===t}}return this.collisionGroups[e]}}function Ti(t,i,r,n,o){const{horizontalAlign:s,verticalAlign:a}=e.c0(t),l=-(s-.5)*i,c=-(a-.5)*r,u=e.c1(t,n);return new e.P(l+u[0]*o,c+u[1]*o)}function Ei(t,i,r,n,o){const s=new e.P(t,i);return r&&s._rotate(n?o:-o),s}class Ci{constructor(e,t,i,r,n,o){this.transform=e.clone(),this.projection=e.projection.name,this.collisionIndex=new _i(this.transform,n),this.buildingIndex=o,this.placements={},this.opacities={},this.variableOffsets={},this.stale=!1,this.commitTime=0,this.fadeDuration=t,this.retainedQueryData={},this.collisionGroups=new wi(i),this.collisionCircleArrays={},this.prevPlacement=r,r&&(r.prevPlacement=void 0),this.placedOrientations={}}getBucketParts(t,i,r,n,o=1){const s=r.getBucket(i),a=r.latestFeatureIndex;if(!s||!a||i.fqid!==s.layerIds[0])return;const l=s.layers[0].layout,c=s.layers[0].paint,u=r.collisionBoxArray,h=Math.pow(2,this.transform.zoom-r.tileID.overscaledZ),d=r.tileSize/e.al,p=r.tileID.toUnwrapped();this.transform.setProjection(s.projection);const f=(m=r.tileID,g=s.getProjection(),_=this.transform,g.name===this.projection?_.calculateProjMatrix(m.toUnwrapped()):Wt(_,g,m));var m,g,_;const A="map"===l.get("text-pitch-alignment"),y="map"===l.get("text-rotation-alignment");i.compileFilter(i.options);const v=i.dynamicFilter(),x=i.dynamicFilterNeedsFeature(),b=this.transform.calculatePixelsToTileUnitsMatrix(r),w=ii(f,r.tileID.canonical,A,y,this.transform,s.getProjection(),b);let T=null;const E=s.getProjection().createInversionMatrix(this.transform,r.tileID.canonical);if(A){const t=ri(f,r.tileID.canonical,A,y,this.transform,s.getProjection(),b);T=e.aB([],this.transform.labelPlaneMatrix,t)}let C=null;v&&r.latestFeatureIndex&&(C={unwrappedTileID:p,dynamicFilter:v,dynamicFilterNeedsFeature:x}),this.retainedQueryData[s.bucketInstanceId]=new bi(s.bucketInstanceId,a,s.sourceLayerIndex,s.index,r.tileID);const[B,S]=s.layers[0].layout.get("text-size-scale-range"),I=e.aA(o,B,S),[M,P]=l.get("icon-size-scale-range"),R=e.aA(o,M,P),L={bucket:s,layout:l,paint:c,posMatrix:f,invMatrix:E,mercatorCenter:[e.aF(this.transform.center.lng),e.aJ(this.transform.center.lat)],textLabelPlaneMatrix:w,labelToScreenMatrix:T,clippingData:C,scale:h,textPixelRatio:d,holdingForFade:r.holdingForFade(),collisionBoxArray:u,partiallyEvaluatedTextSize:e.bJ(s.textSizeData,this.transform.zoom,I),partiallyEvaluatedIconSize:e.bJ(s.iconSizeData,this.transform.zoom,R),collisionGroup:this.collisionGroups.get(s.sourceID),latestFeatureIndex:r.latestFeatureIndex};if(n)for(const e of s.sortKeyRanges){const{sortKey:i,symbolInstanceStart:r,symbolInstanceEnd:n}=e;t.push({sortKey:i,symbolInstanceStart:r,symbolInstanceEnd:n,parameters:L})}else t.push({symbolInstanceStart:0,symbolInstanceEnd:s.symbolInstances.length,parameters:L})}attemptAnchorPlacement(e,t,i,r,n,o,s,a,l,c,u,h,d,p,f,m,g,_,A,y,v){const{textOffset0:x,textOffset1:b,crossTileID:w}=f,T=[x,b],E=Ti(e,o,s,T,a),C=this.collisionIndex.placeCollisionBox(g,a,t,i,r,n,Ei(E.x,E.y,l,c,this.transform.angle),p,u,h,d.predicate);if(A){const e=g.getSymbolInstanceIconSize(v,this.transform.zoom,f.placedIconSymbolIndex);if(0===this.collisionIndex.placeCollisionBox(g,e,A,i,r,n,Ei(E.x,E.y,l,c,this.transform.angle),p,u,h,d.predicate).box.length)return}if(C.box.length>0){let t;return this.prevPlacement&&this.prevPlacement.variableOffsets[w]&&this.prevPlacement.placements[w]&&this.prevPlacement.placements[w].text&&(t=this.prevPlacement.variableOffsets[w].anchor),this.variableOffsets[w]={textOffset:T,width:o,height:s,anchor:e,textScale:a,prevAnchor:t},this.markUsedJustification(g,e,f,_),g.allowVerticalPlacement&&(this.markUsedOrientation(g,_,f),this.placedOrientations[w]=_),{shift:E,placedGlyphBoxes:C}}}placeLayerBucketPart(t,i,r,n,o=1){const{bucket:s,layout:a,paint:l,posMatrix:c,textLabelPlaneMatrix:u,labelToScreenMatrix:h,clippingData:d,textPixelRatio:p,mercatorCenter:f,invMatrix:m,holdingForFade:g,collisionBoxArray:_,partiallyEvaluatedTextSize:A,partiallyEvaluatedIconSize:y,collisionGroup:v,latestFeatureIndex:x}=t.parameters,b=a.get("text-optional"),w=a.get("icon-optional"),T=a.get("text-allow-overlap"),E=a.get("icon-allow-overlap"),C="map"===a.get("text-rotation-alignment"),B="map"===a.get("icon-rotation-alignment"),S="map"===a.get("text-pitch-alignment"),I=l.get("symbol-z-offset"),M="sea"===a.get("symbol-elevation-reference"),P=a.get("symbol-placement"),[R,L]=a.get("text-size-scale-range"),[F,k]=a.get("icon-size-scale-range"),D=e.aA(o,R,L),O=e.aA(o,F,k),z=a.get("text-variable-anchor"),U=C&&"point"!==P,N=B&&"point"!==P,V=z&&s.hasTextData(),j=s.hasIconTextFit()&&V&&s.hasIconData();this.transform.setProjection(s.projection);const G=V||U,H=N||j;let Q=T&&(E||!s.hasIconData()||w),$=E&&(T||!s.hasTextData()||b);const Z=!I.isConstant();!s.collisionArrays&&_&&s.deserializeCollisionBoxes(_),r&&n&&s.updateCollisionDebugBuffers(this.transform.zoom,_,D,O);const W=(t,n,o)=>{const{crossTileID:l,numVerticalGlyphVertices:_}=t;let B=null;if(d&&d.dynamicFilterNeedsFeature||Z){const e=this.retainedQueryData[s.bucketInstanceId];B=x.loadFeature({featureIndex:t.featureIndex,bucketIndex:e.bucketIndex,sourceLayerIndex:e.sourceLayerIndex,layoutVertexArrayOffset:0})}if(d&&!(0,d.dynamicFilter)({zoom:this.transform.zoom,pitch:this.transform.pitch,worldview:s.worldview},B,this.retainedQueryData[s.bucketInstanceId].tileID.canonical,new e.P(t.tileAnchorX,t.tileAnchorY),this.transform.calculateDistanceTileData(d.unwrappedTileID)))return this.placements[l]=new vi(!1,!1,!1,!0),void i.add(l);const P=I.evaluate(B,{});if(i.has(l))return;if(g)return void(this.placements[l]=new vi(!1,!1,!1));let R=!1,L=!1,F=!0,k=!1,D=!1,O=null,U={box:null,offscreen:null,occluded:null},N={box:null},V=null,j=null,W=null,q=0,K=0,X=0;o.textFeatureIndex?q=o.textFeatureIndex:t.useRuntimeCollisionCircles&&(q=t.featureIndex),o.verticalTextFeatureIndex&&(K=o.verticalTextFeatureIndex);const J=s.elevationFeatures?s.elevationFeatures[t.elevationFeatureIndex]:void 0,Y=i=>{i.tileID=this.retainedQueryData[s.bucketInstanceId].tileID;const r=this.transform.elevation;i.elevation=M?P:P+e.bU.getAtTileOffset(i.tileID,new e.P(i.tileAnchorX,i.tileAnchorY),r,J),i.elevation+=t.zOffset},ee=o.textBox;if(ee){Y(ee);const i=i=>{let r=e.bK.horizontal;if(s.allowVerticalPlacement&&!i&&this.prevPlacement){const e=this.prevPlacement.placedOrientations[l];e&&(this.placedOrientations[l]=e,r=e,this.markUsedOrientation(s,r,t))}return r},r=(t,i)=>{if(s.allowVerticalPlacement&&_>0&&o.verticalTextBox){for(const r of s.writingModes)if(r===e.bK.vertical?(U=i(),N=U):U=t(),U&&U.box&&U.box.length)break}else U=t()};if(z){let a=z;if(this.prevPlacement&&this.prevPlacement.variableOffsets[l]){const e=this.prevPlacement.variableOffsets[l];a.indexOf(e.anchor)>0&&(a=a.filter(t=>t!==e.anchor),a.unshift(e.anchor))}const u=(e,i,r)=>{const o=s.getSymbolInstanceTextSize(A,t,this.transform.zoom,n),l=(e.x2-e.x1)*o+2*e.padding,u=(e.y2-e.y1)*o+2*e.padding,h=t.hasIconTextFit&&!E?i:null;h&&Y(h);let d={box:[],offscreen:!1,occluded:!1};const g=T?2*a.length:a.length;for(let i=0;i=a.length,t,n,s,r,h,A,y);if(g&&(d=g.placedGlyphBoxes,d&&d.box&&d.box.length)){R=!0,O=g.shift;break}}return d};r(()=>u(ee,o.iconBox,e.bK.horizontal),()=>{const t=o.verticalTextBox;return t&&Y(t),s.allowVerticalPlacement&&!(U&&U.box&&U.box.length)&&_>0&&t?u(t,o.verticalIconBox,e.bK.vertical):{box:null,offscreen:null,occluded:null}}),U&&(R=U.box,F=U.offscreen,k=U.occluded);const h=i(!(!U||!U.box));if(!R&&this.prevPlacement){const e=this.prevPlacement.variableOffsets[l];e&&(this.variableOffsets[l]=e,this.markUsedJustification(s,e.anchor,t,h))}}else{const a=(i,r)=>{const o=s.getSymbolInstanceTextSize(A,t,this.transform.zoom,n),a=this.collisionIndex.placeCollisionBox(s,o,i,f,m,G,new e.P(0,0),T,p,c,v.predicate);return a&&a.box&&a.box.length&&(this.markUsedOrientation(s,r,t),this.placedOrientations[l]=r),a};r(()=>a(ee,e.bK.horizontal),()=>{const t=o.verticalTextBox;return s.allowVerticalPlacement&&_>0&&t?(Y(t),a(t,e.bK.vertical)):{box:null,offscreen:null,occluded:null}}),i(!!(U&&U.box&&U.box.length))}}if(V=U,R=V&&V.box&&V.box.length>0,F=V&&V.offscreen,k=V&&V.occluded,t.useRuntimeCollisionCircles){const i=t.centerJustifiedTextSymbolIndex>=0?t.centerJustifiedTextSymbolIndex:t.verticalPlacedTextSymbolIndex,n=s.text.placedSymbolArray.get(i),o=e.bL(s.textSizeData,A,n),l=a.get("text-padding");j=this.collisionIndex.placeCollisionCircles(s,T,n,i,s.lineVertexArray,s.glyphOffsetArray,o,c,u,h,r,S,v.predicate,t.collisionCircleDiameter*o/e.bX,l,this.retainedQueryData[s.bucketInstanceId].tileID),R=T||j.circles.length>0&&!j.collisionDetected,F=F&&j.offscreen,k=j.occluded}if(o.iconFeatureIndex&&(X=o.iconFeatureIndex),o.iconBox){const i=i=>{Y(i);const r=t.hasIconTextFit&&O?Ei(O.x,O.y,C,S,this.transform.angle):new e.P(0,0),n=s.getSymbolInstanceIconSize(y,this.transform.zoom,t.placedIconSymbolIndex);return this.collisionIndex.placeCollisionBox(s,n,i,f,m,H,r,E,p,c,v.predicate)};N&&N.box&&N.box.length&&o.verticalIconBox?(W=i(o.verticalIconBox),L=W.box.length>0):(W=i(o.iconBox),L=W.box.length>0),F=F&&W.offscreen,D=W.occluded}const te=b||0===t.numHorizontalGlyphVertices&&0===_,ie=w||0===t.numIconVertices;if(te||ie?ie?te||(L=L&&R):R=L&&R:L=R=L&&R,R&&V&&V.box&&this.collisionIndex.insertCollisionBox(V.box,a.get("text-ignore-placement"),s.bucketInstanceId,N&&N.box&&K?K:q,v.ID),L&&W&&this.collisionIndex.insertCollisionBox(W.box,a.get("icon-ignore-placement"),s.bucketInstanceId,X,v.ID),j&&(R&&this.collisionIndex.insertCollisionCircles(j.circles,a.get("text-ignore-placement"),s.bucketInstanceId,q,v.ID),r)){const e=s.bucketInstanceId;let t=this.collisionCircleArrays[e];void 0===t&&(t=this.collisionCircleArrays[e]=new xi);for(let e=0;e=0;--e){const i=t[e];W(s.symbolInstances.get(i),i,s.collisionArrays[i])}s.hasAnyZOffset&&e.w(`${s.layerIds[0]} layer symbol-z-elevate: symbols are not sorted by elevation if symbol-z-order is evaluated to viewport-y`)}else if(s.hasAnyZOffset){const e=s.getSortedIndexesByZOffset();for(let t=0;t=0&&(t.text.placedSymbolArray.get(o).crossTileID=h>=0&&o!==h?0:c),s>=0&&(t.text.placedSymbolArray.get(s).crossTileID=h>=0&&s!==h?0:c),a>=0&&(t.text.placedSymbolArray.get(a).crossTileID=h>=0&&a!==h?0:c),l>=0&&(t.text.placedSymbolArray.get(l).crossTileID=h>=0&&l!==h?0:c)}markUsedOrientation(t,i,r){const n=i===e.bK.horizontal||i===e.bK.horizontalOnly?i:0,o=i===e.bK.vertical?i:0,{leftJustifiedTextSymbolIndex:s,centerJustifiedTextSymbolIndex:a,rightJustifiedTextSymbolIndex:l,verticalPlacedTextSymbolIndex:c}=r,u=t.text.placedSymbolArray;s>=0&&(u.get(s).placedOrientation=n),a>=0&&(u.get(a).placedOrientation=n),l>=0&&(u.get(l).placedOrientation=n),c>=0&&(u.get(c).placedOrientation=o)}commit(e){this.commitTime=e,this.zoomAtLastRecencyCheck=this.transform.zoom;const t=this.prevPlacement;let i=!1;this.prevZoomAdjustment=t?t.zoomAdjustment(this.transform.zoom):0;const r=t?t.symbolFadeChange(e):1,n=t?t.opacities:{},o=t?t.variableOffsets:{},s=t?t.placedOrientations:{};for(const e in this.placements){const t=this.placements[e],o=n[e];o?(this.opacities[e]=new yi(o,r,t.text,t.icon,null,t.clipped),i=i||t.text!==o.text.placed||t.icon!==o.icon.placed):(this.opacities[e]=new yi(null,r,t.text,t.icon,t.skipFade,t.clipped),i=i||t.text||t.icon)}for(const e in n){const t=n[e];if(!this.opacities[e]){const n=new yi(t,r,!1,!1);n.isHidden()||(this.opacities[e]=n,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 s)this.placedOrientations[e]||!this.opacities[e]||this.opacities[e].isHidden()||(this.placedOrientations[e]=s[e]);i?this.lastPlacementChangeTime=e:"number"!=typeof this.lastPlacementChangeTime&&(this.lastPlacementChangeTime=t?t.lastPlacementChangeTime:e)}updateLayerOpacities(e,t,i,r){const n=new Set;for(const o of t){const t=o.getBucket(e);t&&o.latestFeatureIndex&&e.fqid===t.layerIds[0]&&(this.updateBucketOpacities(t,n,o,o.collisionBoxArray,i,r,o.tileID,e.scope),"offset"===t.elevationType&&this.buildingIndex&&this.buildingIndex.updateZOffset(t,o.tileID),"road"===t.elevationType&&t.updateRoadElevation(o.tileID.canonical),t.updateZOffset())}}updateBucketOpacities(t,i,r,n,o,s,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,u=t.layers[0].paint,h=!!t.layers[0].dynamicFilter(),d=new yi(null,0,!1,!1,!0),p=c.get("text-allow-overlap"),f=c.get("icon-allow-overlap"),m=c.get("text-variable-anchor"),g="map"===c.get("text-rotation-alignment"),_="map"===c.get("text-pitch-alignment"),A=u.get("symbol-z-offset"),y="sea"===c.get("symbol-elevation-reference"),v=!A.isConstant(),x=new yi(null,0,p&&(f||!t.hasIconData()||c.get("icon-optional")),f&&(p||!t.hasTextData()||c.get("text-optional")),!0);!t.collisionArrays&&n&&(t.hasIconCollisionBoxData()||t.hasTextCollisionBoxData())&&t.deserializeCollisionBoxes(n);const b=(e,t,i)=>{for(let r=0;r0||p>0,L=T>0,F=this.placedOrientations[f],k=F===e.bK.vertical,D=F===e.bK.horizontal||F===e.bK.horizontalOnly;!R&&!L||P.isHidden()||w++;let O=!1;if((R||L)&&s)for(const i of t.activeReplacements){if(e.bY(i,o,e.bZ.Symbol,l))continue;if(i.min.x>E||E>i.max.x||i.min.y>C||C>i.max.y)continue;const t=e.b_(E,C,a.canonical,i.footprintTileId.canonical);if(O=e.b$(t,i.footprint),O)break}if(R){const e=O?Di:ki(P.text);b(t.text,u,k?Di:e),b(t.text,p,D?Di:e);const i=P.text.isHidden(),{leftJustifiedTextSymbolIndex:r,centerJustifiedTextSymbolIndex:n,rightJustifiedTextSymbolIndex:o,verticalPlacedTextSymbolIndex:s}=c,a=t.text.placedSymbolArray,l=i||k?1:0;r>=0&&(a.get(r).hidden=l),n>=0&&(a.get(n).hidden=l),o>=0&&(a.get(o).hidden=l),s>=0&&(a.get(s).hidden=i||D?1:0);const h=this.variableOffsets[f];h&&this.markUsedJustification(t,h.anchor,c,F);const d=this.placedOrientations[f];d&&(this.markUsedJustification(t,"left",c,d),this.markUsedOrientation(t,d,c))}if(L){const e=O?Di:ki(P.icon),{placedIconSymbolIndex:i,verticalPlacedIconSymbolIndex:r}=c,n=t.icon.placedSymbolArray,o=P.icon.isHidden()?1:0;i>=0&&(b(t.icon,T,k?Di:e),n.get(i).hidden=o),r>=0&&(b(t.icon,c.numVerticalIconVertices,D?Di:e),n.get(r).hidden=o)}if(t.hasIconCollisionBoxData()||t.hasTextCollisionBoxData()){const i=t.collisionArrays[n];if(i){let r=new e.P(0,0),n=!0;if(i.textBox||i.verticalTextBox){if(m){const e=this.variableOffsets[f];e?(r=Ti(e.anchor,e.width,e.height,e.textOffset,e.textScale),g&&r._rotate(_?this.transform.angle:-this.transform.angle)):n=!1}h&&(n=!P.clipped),i.textBox&&Bi(t.textCollisionBox.collisionVertexArray,P.text.placed,!n||k,I,y,r.x,r.y),i.verticalTextBox&&Bi(t.textCollisionBox.collisionVertexArray,P.text.placed,!n||D,I,y,r.x,r.y)}const o=n&&Boolean(!D&&i.verticalIconBox);i.iconBox&&Bi(t.iconCollisionBox.collisionVertexArray,P.icon.placed,o,I,y,c.hasIconTextFit?r.x:0,c.hasIconTextFit?r.y:0),i.verticalIconBox&&Bi(t.iconCollisionBox.collisionVertexArray,P.icon.placed,!o,I,y,c.hasIconTextFit?r.x:0,c.hasIconTextFit?r.y:0)}}}if(t.fullyClipped=0===w,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 this.stale||e-this.lastPlacementChangeTimee}setStale(){this.stale=!0}}function Bi(e,t,i,r,n,o,s){e.emplaceBack(t?1:0,i?1:0,o||0,s||0,r,n?1:0),e.emplaceBack(t?1:0,i?1:0,o||0,s||0,r,n?1:0),e.emplaceBack(t?1:0,i?1:0,o||0,s||0,r,n?1:0),e.emplaceBack(t?1:0,i?1:0,o||0,s||0,r,n?1:0)}const Si=Math.pow(2,25),Ii=Math.pow(2,24),Mi=Math.pow(2,17),Pi=Math.pow(2,16),Ri=Math.pow(2,9),Li=Math.pow(2,8),Fi=Math.pow(2,1);function ki(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*Si+t*Ii+i*Mi+t*Pi+i*Ri+t*Li+i*Fi+t}const Di=0;class Oi{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,r,n,o){const s=this._bucketParts;for(;this._currentTileIndexe.sortKey-t.sortKey));this._currentPartIndex{const t=e.o.now()-s;return!this._forceFullPlacement&&t>2};for(;this._currentPlacementIndex>=0;){const s=i[t[this._currentPlacementIndex]],l=this.placement.collisionIndex.transform.zoom;if("symbol"===s.type&&(!s.minzoom||s.minzoom<=l)&&(!s.maxzoom||s.maxzoom>l)){const t=s,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"),u="viewport-y"===c||"auto"===c&&!("viewport-y"!==c&&l),h=t.layout.get("text-allow-overlap")||t.layout.get("icon-allow-overlap")||t.layout.get("text-ignore-placement")||t.layout.get("icon-ignore-placement"),d=u&&h,p=this._inProgressLayer=this._inProgressLayer||new Oi(t),f=e.B(s.source,s.scope);if(p.continuePlacement(i||d?n[f]:r[f],this.placement,this._showCollisionBoxes,s,a,o))return;delete this._inProgressLayer}this._currentPlacementIndex--}this._done=!0}commit(e){return this.placement.commit(e),this.placement}}const Ui=512/e.al/2;class Ni{constructor(t,i,r){this.tileID=t,this.bucketInstanceId=r,this.index=new e.c3(i.length,16,Int32Array),this.keys=[],this.crossTileIDs=[];const n=t.canonical.x*e.al,o=t.canonical.y*e.al;for(let e=0;ee-t);for(const e of p){const t=this.crossTileIDs[e];if(this.keys[e]===l&&!r.has(t)){r.add(t),i.crossTileID=t;break}}}}}class Vi{constructor(){this.maxCrossTileID=0}generate(){return++this.maxCrossTileID}}class ji{constructor(){this.indexes={},this.usedCrossTileIDs={},this.lng=0}handleWrapJump(e){const t=Math.round((e-this.lng)/360);if(0!==t)for(const e in this.indexes){const i=this.indexes[e],r={};for(const e in i){const n=i[e];n.tileID=n.tileID.unwrapTo(n.tileID.wrap+t),r[n.tileID.key]=n}this.indexes[e]=r}this.lng=e}addBucket(e,t,i){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;ee.overscaledZ)for(const i in n){const o=n[i];o.tileID.isChildOf(e)&&o.findMatches(t.symbolInstances,e,r)}else{const o=n[e.scaledTo(Number(i)).key];o&&o.findMatches(t.symbolInstances,e,r)}}for(let e=0;e{t[e]=!0});for(const e in this.layerIndexes)t[e]||delete this.layerIndexes[e]}}const Hi=771;class Qi{constructor(e,t,i,r){this.blendFunction=e,this.blendColor=t.toNonPremultipliedRenderColor(null),this.mask=i,this.blendEquation=r}}Qi.Replace=[1,0,1,0],Qi.disabled=new Qi(Qi.Replace,e.ao.transparent,[!1,!1,!1,!1]),Qi.unblended=new Qi(Qi.Replace,e.ao.transparent,[!0,!0,!0,!0]),Qi.alphaBlended=new Qi([1,Hi,1,Hi],e.ao.transparent,[!0,!0,!0,!0]),Qi.alphaBlendedNonPremultiplied=new Qi([770,Hi,770,Hi],e.ao.transparent,[!0,!0,!0,!0]),Qi.multiply=new Qi([774,0,774,0],e.ao.transparent,[!0,!0,!0,!0]),Qi.additive=new Qi([1,1,1,1],e.ao.transparent,[!0,!0,!0,!0]);class $i{constructor(e,t,i){this.func=e,this.mask=t,this.range=i}}$i.ReadOnly=!1,$i.ReadWrite=!0,$i.disabled=new $i(519,$i.ReadOnly,[0,1]);const Zi=7680;class Wi{constructor(e,t,i,r,n,o){this.test=e,this.ref=t,this.mask=i,this.fail=r,this.depthFail=n,this.pass=o}}Wi.disabled=new Wi({func:519,mask:0},0,0,Zi,Zi,Zi);const qi=1029,Ki=2305;class Xi{constructor(e,t,i){this.enable=e,this.mode=t,this.frontFace=i}}function Ji(t,i){const r=e.c9(t,3);e.cb(t,i),e.cf(t,3,r)}function Yi(t,i){const r=e.c6([]);return e.c7(r,r,-i),e.c8(r,r,-t),r}function er(t,i){const r=[t[0],t[1],0],n=[i[0],i[1],0];if(e.ag(r)>=1e-15){const t=e.aw([],r);e.c4(n,t,e.bI(n,t)),i[0]=n[0],i[1]=n[1]}const o=e.bH([],i,t);if(e.c5(o)<1e-15)return null;const s=Math.atan2(-o[1],o[0]);return Yi(Math.atan2(Math.sqrt(t[0]*t[0]+t[1]*t[1]),-t[2]),s)}Xi.disabled=new Xi(!1,qi,Ki),Xi.backCCW=new Xi(!0,qi,Ki),Xi.backCW=new Xi(!0,qi,2304),Xi.frontCW=new Xi(!0,1028,2304),Xi.frontCCW=new Xi(!0,1028,Ki);class tr{constructor(e,t){this.position=e,this.orientation=t}get position(){return this._position}set position(t){if(t){const i=t instanceof e.ae?t:new e.ae(t[0],t[1],t[2]);this._renderWorldCopies&&(i.x=e.bS(i.x,0,1)),this._position=i}else this._position=null}lookAtPoint(t,i,r){if(this.orientation=null,!this.position)return;const n=this.position,o=r||(this._elevation?this._elevation.getAtPointOrZero(e.ae.fromLngLat(t)):0),s=e.ae.fromLngLat(t,o),a=[s.x-n.x,s.y-n.y,s.z-n.z];i||(i=[0,0,1]),i[2]=Math.abs(i[2]),this.orientation=er(a,i)}setPitchBearing(t,i){this.orientation=Yi(e.an(t),e.an(-i))}}class ir{constructor(t,i){this._transform=e.bz([]),this.orientation=i,this.position=t}get mercatorPosition(){const t=this.position;return new e.ae(t[0],t[1],t[2])}get position(){const t=e.c9(this._transform,3);return[t[0],t[1],t[2]]}set position(t){var i;t&&e.cf(this._transform,3,[(i=t)[0],i[1],i[2],1])}get orientation(){return this._orientation}set orientation(t){this._orientation=t||e.c6([]),t&&Ji(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=Yi(e,t),Ji(this._transform,this._orientation)}forward(){const t=e.c9(this._transform,2);return[-t[0],-t[1],-t[2]]}up(){const t=e.c9(this._transform,1);return[-t[0],-t[1],-t[2]]}right(){const t=e.c9(this._transform,0);return[t[0],t[1],t[2]]}getCameraToWorld(t,i){const r=new Float64Array(16);return e.bk(r,this.getWorldToCamera(t,i)),r}getCameraToWorldMercator(){return this._transform}getWorldToCameraPosition(t,i,r){const n=this.position;e.c4(n,n,-t);const o=new Float64Array(16);return e.bp(o,[r,r,r]),e.bq(o,o,n),o[10]*=i,o}getWorldToCamera(t,i){const r=new Float64Array(16),n=new Float64Array(4),o=this.position;return e.ca(n,this._orientation),e.c4(o,o,-t),e.cb(r,n),e.bq(r,r,o),r[1]*=-1,r[5]*=-1,r[9]*=-1,r[13]*=-1,r[8]*=i,r[9]*=i,r[10]*=i,r[11]*=i,r}getCameraToClipPerspective(t,i,r,n){const o=new Float64Array(16);return e.cc(o,t,i,r,n),o}getCameraToClipOrthographic(t,i,r,n,o,s){const a=new Float64Array(16);return e.cd(a,t,i,r,n,o,s),a}getDistanceToElevation(t,i=!1){const r=0===t?0:e.ce(t,i?e.a_(this.position[1]):this.position[1]),n=this.forward();return(r-this.position[2])/n[2]}clone(){return new ir([...this.position],[...this.orientation])}}const rr={BaseColor:5,MetallicRoughness:6,Normal:7,Occlusion:8,Emission:9,LUT:10,ShadowMap0:11};class nr{constructor(e=0,t=0,i=0,r=0){if(isNaN(e)||e<0||isNaN(t)||t<0||isNaN(i)||i<0||isNaN(r)||r<0)throw new Error("Invalid value for edge-insets, top, bottom, left and right must all be numbers");this.top=e,this.bottom=t,this.left=i,this.right=r}interpolate(t,i,r){return null!=i.top&&null!=t.top&&(this.top=e.ak(t.top,i.top,r)),null!=i.bottom&&null!=t.bottom&&(this.bottom=e.ak(t.bottom,i.bottom,r)),null!=i.left&&null!=t.left&&(this.left=e.ak(t.left,i.left,r)),null!=i.right&&null!=t.right&&(this.right=e.ak(t.right,i.right,r)),this}getCenter(t,i){const r=e.aA((this.left+t-this.right)/2,0,t),n=e.aA((this.top+i-this.bottom)/2,0,i);return new e.P(r,n)}equals(e){return this.top===e.top&&this.bottom===e.bottom&&this.left===e.left&&this.right===e.right}clone(){return new nr(this.top,this.bottom,this.left,this.right)}toJSON(){return{top:this.top,bottom:this.bottom,left:this.left,right:this.right}}}const or=15;class sr{constructor(t,i,r,n,o,s,a){this.tileSize=512,this._renderWorldCopies=void 0===o||o,this._minZoom=t||0,this._maxZoom=i||22,this._minPitch=r??0,this._maxPitch=n??60,this.setProjection(s),this.setMaxBounds(a),this.width=0,this.height=0,this._center=new e.aS(0,0),this.zoom=0,this.angle=0,this._fov=.6435011087932844,this._pitch=0,this._nearZ=0,this._farZ=0,this._unmodified=!0,this._edgeInsets=new nr,this._projMatrixCache={},this._alignedProjMatrixCache={},this._fogTileMatrixCache={},this._expandedProjMatrixCache={},this._distanceTileDataCache={},this._camera=new ir,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}clone(){const e=new sr(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._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.pitch0&&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 t=this._elevation,i=[[.5,.2],[.3,.5],[.5,.5],[.7,.5],[.5,.8]],r=this.horizonLineFromTop();let n=0,o=0;for(let s=0;s{const l=e.cX(i,t,r,o,s);a.has(l)||(n.push(new e.aP(t,i,r,o,s)),a.add(l))};for(let e=0;e0,f=a.y+10,g=n.wrap-(p?0:1),_=n.wrap+(d?0:1),A=p?a.x-1:h-1,y=d?a.x+1:0;if(o)r[0]<0?(l(c,_,a.z,y,a.y),r[1]<0&&f&&(l(c,u,a.z,a.x,a.y+1),l(c,_,a.z,y,a.y+1)),r[1]>0&&m&&(l(c,u,a.z,a.x,a.y-1),l(c,_,a.z,y,a.y-1))):r[0]>0?(l(c,g,a.z,A,a.y),r[1]<0&&f&&(l(c,u,a.z,a.x,a.y+1),l(c,g,a.z,A,a.y+1)),r[1]>0&&m&&(l(c,u,a.z,a.x,a.y-1),l(c,g,a.z,A,a.y-1))):r[1]<0&&f?l(c,u,a.z,a.x,a.y+1):m&&l(c,u,a.z,a.x,a.y-1);else{const e=n.visibleQuadrants;1&e&&(l(c,g,a.z,A,a.y),m&&(l(c,u,a.z,a.x,a.y-1),l(c,g,a.z,A,a.y-1))),2&e&&(l(c,_,a.z,y,a.y),m&&(l(c,u,a.z,a.x,a.y-1),l(c,_,a.z,y,a.y-1))),4&e&&(l(c,g,a.z,A,a.y),f&&(l(c,u,a.z,a.x,a.y+1),l(c,g,a.z,A,a.y+1))),8&e&&(l(c,_,a.z,y,a.y),f&&(l(c,u,a.z,a.x,a.y+1),l(c,_,a.z,y,a.y+1)))}}const c=[];for(const e of n)n.some(t=>e.isChildOf(t))||c.push(e);if(n=c.filter(e=>!t.some(t=>!!(e.overscaledZ{const t=e.canonical.x+.5-r[0],i=e.canonical.y+.5-r[1];return t*t+i*i{const l=e.cX(i,t,r,s,a);o.has(l)||(n.push(new e.aP(t,i,r,s,a)),o.add(l))},a=t.reduce((e,t)=>Math.max(e,t.overscaledZ),r),l=1<{const n=Math.floor(t[0]),o=Math.floor(t[1]),d=(t[0]-n)*e.al,p=(t[1]-o)*e.al,f=Math.floor(i[0]),m=Math.floor(i[1]),g=(i[0]-f)*e.al,_=(i[1]-m)*e.al;for(let t=-1;t<=1;t++){const i=n+t;if(!(i<0||i>=l)){u.x=d-t*e.al,h.x=g-(i-f)*e.al;for(let t=-1;t<=1;t++){const n=o+t;u.y=p-t*e.al,h.y=_-(n-m)*e.al,e.cY(u,h,c)&&s(a,0,r,i,n)}}}},p=i.points,f=p[e.cu],m=p[e.cv],g=this._projectToGround(f,p[e.cw]),_=this._projectToGround(m,p[e.cx]);return d(f,g),d(m,_),n}_projectToGround(t,i){return e.cy(e.cz(),t,i,t[2]/(t[2]-i[2]))}coveringTiles(t){let i=this.coveringZoomLevel(t);const r=i,n=this.elevation&&this.elevation.exaggeration(),o=n&&!t.isTerrainDEM,s="mercator"===this.projection.name;if(void 0!==t.minzoom&&it.maxzoom&&(i=t.maxzoom);const a=this.locationCoordinate(this.center),l=this.center.lat,c=1<{const i=1/4e4,r=new e.ae(t.x+i,t.y,t.z),n=new e.ae(t.x,t.y+i,t.z),o=t.toLngLat(),s=r.toLngLat(),a=n.toLngLat(),l=this.locationCoordinate(o),c=this.locationCoordinate(s),u=this.locationCoordinate(a),h=Math.hypot(c.x-l.x,c.y-l.y),d=Math.hypot(u.x-l.x,u.y-l.y);return Math.sqrt(h*d)*w/i},E=t=>{const i=x,r=b;return{aabb:e.cE(this,c,0,0,0,t,r,i,this.projection),zoom:0,x:0,y:0,minZ:r,maxZ:i,wrap:t,fullyVisible:!1}},C=[];let B=[];const S=i,I=t.reparseOverscaled?r:i,M=(g-this._centerAltitude)*m,P=e=>{if(!this._elevation||!e.tileID||!s)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=L(e),e.shouldSplit||(i.min[2]=i.max[2]=i.center[2]=this._centerAltitude))},R=(e,t)=>{if(.707*t{if(t.zoom=.9)return!0}else if(o&&(a=t.aabb.distanceZ(_)*m),this.projection.isReprojectedInTileSpace&&r<=5){const i=Math.pow(2,t.zoom),r=T(new e.ae((t.x+.5)/i,(t.y+.5)/i));c=r>.85?1:r}if(!s&&!h){const e=Math.sqrt(i*i+n*n+a*a);let r=(1<0;){const r=C.pop(),n=r.x,a=r.y;let l=r.fullyVisible;const d=()=>"globe"===this.projection.name&&(0===r.y||r.y===(1<>1),d={aabb:s?r.aabb.quadrant(t):e.cE(this,c,r.zoom+1,i,u,r.wrap,r.minZ,r.maxZ,this.projection),zoom:r.zoom+1,x:i,y:u,wrap:r.wrap,fullyVisible:l,tileID:void 0,shouldSplit:void 0,minZ:r.minZ,maxZ:r.maxZ};o&&!h&&(d.tileID=new e.aP(r.zoom+1===S?I:r.zoom+1,r.wrap,r.zoom+1,i,u),P(d)),C.push(d)}else{const o=r.zoom===S?I:r.zoom;if(t.minzoom&&t.minzoom>o)continue;let s=0;if(!l){let i=A?r.aabb.intersectsPrecise(p):r.aabb.intersectsPreciseFlat(p);if(0===i&&d()){const t=new e.cC(r.zoom,n,a);i=e.cD(this,c,t,!0).intersectsPrecise(p)}if(0===i)continue;if(t.calculateQuadrantVisibility)if(p.containsPoint(r.aabb.center))s=15;else for(let e=0;e<4;e++)0!==r.aabb.quadrant(e).intersects(p)&&(s|=1<{const o=[0,0,0,1],s=[e.al,e.al,0,1],a=this.calculateFogTileMatrix(n.tileID.toUnwrapped());e.aC(o,o,a),e.aC(s,s,a);const l=e.cF([],o,s),c=e.cG([],o,s),u=e.c_(l,c);if(0===u)return!0;let h=!1;const d=this._elevation;if(d&&u>i&&0!==r){const i=this.calculateProjMatrix(n.tileID.toUnwrapped());let o;t.isTerrainDEM||(o=d.getMinMaxForTile(n.tileID)),o||(o={min:b,max:x});const s=e.cH(this.rotation),a=[s[0]*e.al,s[1]*e.al,o.max];e.af(a,a,i),h=(1-a[1])*this.height*.5e.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(t){const i=e.aA(t.lat,-e.cI,e.cI),r=this.projection.project(t.lng,i);return new e.P(r.x*this.worldSize,r.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/e.ce(1,this.center.lat)/this.worldSize}setLocationAtPoint(t,i){let r,n;const o=this.centerPoint;if("globe"===this.projection.name){const e=this.worldSize;r=(i.x-o.x)/e,n=(i.y-o.y)/e}else{const e=this.pointCoordinate(i),t=this.pointCoordinate(o);r=e.x-t.x,n=e.y-t.y}const s=this.locationCoordinate(t);this.setLocation(new e.ae(s.x-r,s.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(t,i){const r=i?e.ce(i,t.lat):void 0,n=this.projection.project(t.lng,t.lat);return new e.ae(n.x,n.y,r)}coordinateLocation(e){return this.projection.unproject(e.x,e.y)}pointRayIntersection(t,i){const r=null!=i?i:this._centerAltitude,n=[t.x,t.y,0,1],o=[t.x,t.y,1,1];e.aC(n,n,this.pixelMatrixInverse),e.aC(o,o,this.pixelMatrixInverse);const s=o[3];e.cJ(n,n,1/n[3]),e.cJ(o,o,1/s);const a=n[2],l=o[2];return{p0:n,p1:o,t:a===l?0:(r-a)/(l-a)}}screenPointToMercatorRay(t){const i=[t.x,t.y,0,1],r=[t.x,t.y,1,1];return e.aC(i,i,this.pixelMatrixInverse),e.aC(r,r,this.pixelMatrixInverse),e.cJ(i,i,1/i[3]),e.cJ(r,r,1/r[3]),i[2]=e.ce(i[2],this._center.lat)*this.worldSize,r[2]=e.ce(r[2],this._center.lat)*this.worldSize,e.cJ(i,i,1/this.worldSize),e.cJ(r,r,1/this.worldSize),new e.ax([i[0],i[1],i[2]],e.aw([],e.av([],r,i)))}rayIntersectionCoordinate(t){const{p0:i,p1:r,t:n}=t,o=e.ce(i[2],this._center.lat),s=e.ce(r[2],this._center.lat);return new e.ae(e.ak(i[0],r[0],n)/this.worldSize,e.ak(i[1],r[1],n)/this.worldSize,e.ak(o,s,n))}pointCoordinate(e,t=this._centerAltitude){return this.projection.pointCoordinate(this,e.x,e.y,t)}pointCoordinate3D(t,i){if(!this.elevation)return this.pointCoordinate(t,i);let r=this.projection.pointCoordinate3D(this,t.x,t.y);if(r)return new e.ae(r[0],r[1],r[2]);let n=0,o=this.horizonLineFromTop();if(t.y>o)return this.pointCoordinate(t,i);const s=.02*o,a=t.clone();for(let t=0;t<10&&o-n>s;t++){a.y=e.ak(n,o,.66);const t=this.projection.pointCoordinate3D(this,a.x,a.y);t?(o=a.y,r=t):n=a.y}return r?new e.ae(r[0],r[1],r[2]):this.pointCoordinate(t)}isPointAboveHorizon(e){return this.projection.isPointAboveHorizon(this,e)}isPointOnSurface(t){if(t.y<0||t.y>this.height||t.x<0||t.x>this.width)return!1;if(this.elevation||this.zoom>=e.cK)return!this.isPointAboveHorizon(t);const i=this.pointCoordinate(t);return i.y>=0&&i.y<=1}_coordinatePoint(t,i){const r=i&&this.elevation?this.elevation.getAtPointOrZero(t,this._centerAltitude):this._centerAltitude,n=[t.x*this.worldSize,t.y*this.worldSize,r+t.toAltitude(),1];return e.aC(n,n,this.pixelMatrix),n[3]>0?new e.P(n[0]/n[3],n[1]/n[3]):new e.P(Number.MAX_VALUE,Number.MAX_VALUE)}_getBoundsNonRectangular(){const{top:t,left:i}=this._edgeInsets,r=this.height-this._edgeInsets.bottom,n=this.width-this._edgeInsets.right,o=this.pointLocation3D(new e.P(i,t)),s=this.pointLocation3D(new e.P(n,t)),a=this.pointLocation3D(new e.P(n,r)),l=this.pointLocation3D(new e.P(i,r));let c=Math.min(o.lng,s.lng,a.lng,l.lng),u=Math.max(o.lng,s.lng,a.lng,l.lng),h=Math.min(o.lat,s.lat,a.lat,l.lat),d=Math.max(o.lat,s.lat,a.lat,l.lat);const p=Math.pow(2,-this.zoom)/16*270,f="globe"===this.projection.name?1:4,m=(t,i,r,n,o)=>{const s=(t+r)/2,a=(i+n)/2,l=new e.P(s,a),{lng:g,lat:_}=this.pointLocation3D(l),A=Math.max(0,c-g,h-_,g-u,_-d);c=Math.min(c,g),u=Math.max(u,g),h=Math.min(h,_),d=Math.max(d,_),(op)&&(m(t,i,s,a,o+1),m(s,a,r,n,o+1))};if(m(i,t,n,t,1),m(n,t,n,r,1),m(n,r,i,r,1),m(i,r,i,t,1),"globe"===this.projection.name){const[t,i]=e.cL(this);t?(d=90,u=180,c=-180):i&&(h=-90,u=180,c=-180)}return new e.aI(new e.aS(c,h),new e.aS(u,d))}_getBoundsRectangular(t,i){const{top:r,left:n}=this._edgeInsets,o=this.height-this._edgeInsets.bottom,s=this.width-this._edgeInsets.right,a=new e.P(n,r),l=new e.P(s,r),c=new e.P(s,o),u=new e.P(n,o);let h=this.pointCoordinate(a,t),d=this.pointCoordinate(l,t);const p=this.pointCoordinate(c,i),f=this.pointCoordinate(u,i),m=(e,t)=>(t.y-e.y)/(t.x-e.x);return h.y>1&&d.y>=0?h=new e.ae((1-f.y)/m(f,h)+f.x,1):h.y<0&&d.y<=1&&(h=new e.ae(-f.y/m(f,h)+f.x,0)),d.y>1&&h.y>=0?d=new e.ae((1-p.y)/m(p,d)+p.x,1):d.y<0&&h.y<=1&&(d=new e.ae(-p.y/m(p,d)+p.x,0)),(new e.aI).extend(this.coordinateLocation(h)).extend(this.coordinateLocation(d)).extend(this.coordinateLocation(f)).extend(this.coordinateLocation(p))}_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(t){this.maxBounds=t,this.minLat=-e.cI,this.maxLat=e.cI,this.minLng=-180,this.maxLng=180,t&&(this.minLat=t.getSouth(),this.maxLat=t.getNorth(),this.minLng=t.getWest(),this.maxLng=t.getEast(),this.maxLngh&&(a=h-c),h-ut&&(s=t-l),t-e{for(let o=0;o<16;o++)t[o]=e.ak(i[o],r[o],n)})(a,a,l,e.c$(this.pitch>=or?1:this.pitch/or))}else a=l;const c=e.cO([],l,s);let u=e.cO([],a,s);if(this.projection.isReprojectedInTileSpace){const t=this.locationCoordinate(this.center),i=e.bz([]);e.bq(i,i,[t.x*this.worldSize,t.y*this.worldSize,0]),e.aB(i,i,e.cP(this)),e.bq(i,i,[-t.x*this.worldSize,-t.y*this.worldSize,0]),e.aB(u,u,i),e.aB(c,c,i),this.inverseAdjustmentMatrix=e.cQ(this)}else this.inverseAdjustmentMatrix=[1,0,0,1];if(this.mercatorMatrix=e.cR([],u,[this.worldSize,this.worldSize,this.worldSize/o,1]),this.projMatrix=u,this.invProjMatrix=e.bk(new Float64Array(16),this.projMatrix),i){const i=this._camera.getCameraToClipPerspective(this._fov,this.width/this.height,this._nearZ,1/0);i[8]=2*-t.x/this.width,i[9]=2*t.y/this.height,this.expandedFarZProjMatrix=e.cO([],i,s)}else this.expandedFarZProjMatrix=this.projMatrix;const h=e.bk([],a);this.frustumCorners=e.cS.fromInvProjectionMatrix(h,this.horizonLineFromTop(),this.height),this.cameraFrustum=e.cA.fromInvProjectionMatrix(this.invProjMatrix,this.worldSize,0,!i);const d=new Float32Array(16);e.bz(d),e.cR(d,d,[1,-1,1]),e.cT(d,d,this._pitch),e.bA(d,d,this.angle);const p=e.cc(new Float32Array(16),this._fov,this.width/this.height,this._nearZ,this._farZ);this.starsProjMatrix=e.by(p);const f=(Math.PI/2-this._pitch)*(this.height/this._fov)*this._horizonShift;p[8]=2*-t.x/this.width,p[9]=2*(t.y+f)/this.height,this.skyboxMatrix=e.aB(d,p,d);const m=this.point,g=m.x,_=m.y,A=this.width%2/2,y=this.height%2/2,v=Math.cos(this.angle),x=Math.sin(this.angle),b=g-Math.round(g)+v*A+x*y,w=_-Math.round(_)+v*y+x*A,T=new Float64Array(u);if(e.bq(T,T,[b>.5?b-1:b,w>.5?w-1:w,0]),this.alignedProjMatrix=T,u=e.bB(),e.cR(u,u,[this.width/2,-this.height/2,1]),e.bq(u,u,[1,-1,0]),this.labelPlaneMatrix=u,u=e.bB(),e.cR(u,u,[1,-1,1]),e.bq(u,u,[-1,-1,0]),e.cR(u,u,[2/this.width,2/this.height,1]),this.glCoordMatrix=u,this.pixelMatrix=e.aB(new Float64Array(16),this.labelPlaneMatrix,c),this._calcFogMatrices(),this._distanceTileDataCache={},u=e.bk(new Float64Array(16),this.pixelMatrix),!u)throw new Error("failed to invert matrix");if(this.pixelMatrixInverse=u,"globe"===this.projection.name||this.mercatorFromTransition){this.globeMatrix=e.cU(this);const t=[this.globeMatrix[12],this.globeMatrix[13],this.globeMatrix[14]];this.globeCenterInViewSpace=e.af(t,t,s),this.globeRadius=this.worldSize/2/Math.PI-1}else this.globeMatrix=u;this._projMatrixCache={},this._alignedProjMatrixCache={},this._pixelsToTileUnitsCache={},this._expandedProjMatrixCache={}}_calcFogMatrices(){this._fogTileMatrixCache={};const t=this.cameraWorldSizeForFog,i=this.cameraPixelsPerMeter,r=this._camera.position,n=1/this.height/this._pixelsPerMercatorPixel,o=[t,t,i];e.c4(o,o,n),e.c4(r,r,-1),e.cV(r,r,o);const s=e.bB();e.bq(s,s,r),e.cR(s,s,o),this.mercatorFogMatrix=s,this.worldToFogMatrix=this._camera.getWorldToCameraPosition(t,i,n)}_computeCameraPosition(e){const t=(e=e||this.pixelsPerMeter)/this.pixelsPerMeter,i=this._camera.forward(),r=this.point,n=this._mercatorZfromZoom(this._seaLevelZoom?this._seaLevelZoom:this._zoom)*t-e/this.worldSize*this._centerAltitude;return[r.x/this.worldSize-i[0]*n,r.y/this.worldSize-i[1]*n,e/this.worldSize*this._centerAltitude-i[2]*n]}_updateCameraState(){this.height&&(this._camera.setPitchBearing(this._pitch,this.angle),this._camera.position=this._computeCameraPosition())}_translateCameraConstrained(t){const i=this._maxCameraBoundsDistance()*Math.cos(this._pitch),r=this._camera.position[2],n=t[2];let o=1;this.projection.wrap&&(this.center=this.center.wrap()),n>0&&(o=Math.min((i-r)/n,1)),this._camera.position=e.bG([],this._camera.position,t,o),this._updateStateFromCamera()}_updateStateFromCamera(){const t=this._camera.position,i=this._camera.forward(),{pitch:r,bearing:n}=this._camera.getPitchBearing(),o=e.ce(this._centerAltitude,this.center.lat)*this._pixelsPerMercatorPixel,s=this._mercatorZfromZoom(this._maxZoom)*Math.cos(e.an(this._maxPitch)),a=Math.max((t[2]-o)/Math.cos(r),s),l=this._zoomFromMercatorZ(a);e.bG(t,t,i,a),this._pitch=e.aA(r,e.an(this.minPitch),e.an(this.maxPitch)),this.angle=e.bS(n,-Math.PI,Math.PI),this._setZoom(e.aA(l,this._minZoom,this._maxZoom)),this._updateSeaLevelZoom(),this._center=this.coordinateLocation(new e.ae(t[0],t[1],t[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(null!=this._seaLevelZoom?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(t){let i=0,r=e.cK,n=0,o=1/0;for(;r-i>1e-6&&r>i;){const e=i+.5*(r-i),s=this.tileSize*Math.pow(2,e),a=this.getCameraToCenterDistance(this.projection,e,s),l=this.scaleZoom(a/(Math.max(0,t)*this.tileSize)),c=Math.abs(e-l);cc||i.y>1)return!0}return!1}isHorizonVisible(){return this.pitch+e.cW(this.fovAboveCenter)>88||this.anyCornerOffEdge(new e.P(0,0),new e.P(this.width,this.height))}zoomDeltaToMovement(t,i){const r=e.ag(e.av([],this._camera.position,t)),n=this._zoomFromMercatorZ(r)+i;return r-this._mercatorZfromZoom(n)}getCameraPoint(){if("globe"===this.projection.name){const t=function([t,i,r],n){const o=[t,i,r,1];e.aC(o,o,n);const s=o[3]=Math.max(o[3],1e-6);return o[0]/=s,o[1]/=s,o[2]/=s,o}([this.globeMatrix[12],this.globeMatrix[13],this.globeMatrix[14]],this.pixelMatrix);return new e.P(t[0],t[1])}{const t=Math.tan(this._pitch)*(this.cameraToCenterDistance||1);return this.centerPoint.add(new e.P(0,t))}}getCameraToCenterDistance(t,i=this.zoom,r=this.worldSize){const n=e.cN(t,i,this.width,this.height,1024),o=t.pixelSpaceConversion(this.center.lat,r,n);let s=.5/Math.tan(.5*this._fov)*this.height*o;return this.isOrthographic&&(s=e.ak(1,s,e.c$(this.pitch>=or?1:this.pitch/or))),s}getWorldToCameraMatrix(){const t=this._camera.getWorldToCamera(this.worldSize,"meters"===this.projection.zAxisUnit?this.pixelsPerMeter:1);return"globe"===this.projection.name&&e.aB(t,t,this.globeMatrix),t}getFrustum(t){return e.cA.fromInvProjectionMatrix(this.invProjMatrix,this.worldSize,t,"meters"===this.projection.zAxisUnit)}}const ar=(t,i)=>{if(i>0&&t.terrain&&e.w("Cutoff is currently disabled on terrain"),i<=0||t.terrain)return{shouldRenderCutoff:!1,uniformValues:{u_cutoff_params:[0,0,0,1]}};const r=t.transform,n=Math.max(Math.abs(r._zoom-(t.minCutoffZoom-1)),1),o=r.isLODDisabled(!1)?e.ah(60,45,r.pitch):e.ah(30,15,r.pitch),s=r._farZ-r._nearZ,a=i*r.height,l=((1-(c=o))*r.cameraToCenterDistance+c*(r._farZ+a))*n;var c;return{shouldRenderCutoff:o<1,uniformValues:{u_cutoff_params:[r._nearZ,r._farZ,(l-r._nearZ)/s,(l-a-r._nearZ)/s]}}},lr={cascadeCount:2,normalOffset:3,shadowMapResolution:2048};class cr{constructor(e,t){this.aabb=e,this.lastCascade=t}}class ur{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 cr(t,null)}clear(){this.receivers={}}get(e){return this.receivers[e.key]}computeRequiredCascades(t,i,r){const n=e.d8.fromPoints(t.points);let o=0;for(const t in this.receivers){const s=this.receivers[t];if(!s)continue;if(!n.intersectsAabb(s.aabb))continue;s.aabb.min=n.closestPoint(s.aabb.min),s.aabb.max=n.closestPoint(s.aabb.max);const a=s.aabb.getCorners();for(let t=0;t1||s[1]<-1||s[1]>1){n=!1;break}}if(s.lastCascade=t,o=Math.max(o,t),n)break}}return o+1}}class hr{constructor(e){this.painter=e,this._enabled=!1,this._shadowLayerCount=0,this._numCascadesToRender=0,this._cascades=[],this._groundShadowTiles=[],this._receivers=new ur,this._depthMode=new $i(e.context.gl.LEQUAL,$i.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.useNormalOffset=!1,e.tp.registerParameter(this,["Shadows"],"_forceDisable",{label:"forceDisable"},()=>{this.painter.style.map.triggerRepaint()}),e.tp.registerParameter(lr,["Shadows"],"cascadeCount",{min:1,max:2,step:1}),e.tp.registerParameter(lr,["Shadows"],"normalOffset",{min:0,max:10,step:.05}),e.tp.registerParameter(lr,["Shadows"],"shadowMapResolution",{min:32,max:2048,step:32}),e.tp.registerBinding(this,["Shadows"],"_numCascadesToRender",{readonly:!0,label:"numCascadesToRender"})}destroy(){for(const e of this._cascades)e.texture.destroy(),e.framebuffer.destroy();this._cascades=[]}updateShadowParameters(t,i){const r=this.painter;if(this._enabled=!1,this._shadowLayerCount=0,this._receivers.clear(),!i||!i.properties)return;const n=i.properties.get("shadow-intensity");if(!i.shadowsEnabled()||n<=0)return;if(this._shadowLayerCount=r.style.order.reduce((e,i)=>{const n=r.style._mergedLayers[i];return e+(n.hasShadowPass()&&!n.isHidden(t.zoom)?1:0)},0),this._enabled=this._shadowLayerCount>0,!this.enabled)return;const o=r.context,s=lr.shadowMapResolution,a=lr.shadowMapResolution;if(0===this._cascades.length||lr.shadowMapResolution!==this._cascades[0].texture.size[0]){this._cascades=[];for(let t=0;te.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]&&(l=(i[1]-i[0])*e.exaggeration())}const c=1.5*t.cameraToCenterDistance,u=3*c,h=new Float64Array(16);for(let i=0;i=0)return{};const o=function(t,i,r){const n=r/(1<0&&(e.d7(o[1],o[1],[n[0]*s,0,0]),e.d7(o[2],o[2],[n[0]*s,0,0])),n[1]<0?(e.d7(o[0],o[0],[0,n[1]*s,0]),e.d7(o[1],o[1],[0,n[1]*s,0])):n[1]>0&&(e.d7(o[2],o[2],[0,n[1]*s,0]),e.d7(o[3],o[3],[0,n[1]*s,0]));const a={};return a.vertices=o,a.planes=[dr(o[1],o[0],o[4]),dr(o[2],o[1],o[5]),dr(o[3],o[2],o[6]),dr(o[0],o[3],o[7])],a}addShadowReceiver(t,i,r){this._receivers.add(t,e.d8.fromTileIdAndHeight(t,i,r))}getMaxCascadeForTile(e){const t=this._receivers.get(e);return t&&t.lastCascade?t.lastCascade:0}}function dr(t,i,r){const n=e.av([],r,i),o=e.av([],t,i),s=e.bH([],n,o),a=e.ag(s);return 0===a?[0,0,1,0]:(e.c4(s,s,1/a),[s[0],s[1],s[2],-e.bI(s,i)])}function pr(t){const i=t.properties.get("direction"),r=e.d3(i.x,i.y,i.z);r[2]=e.aA(r[2],0,75);const n=e.d5([r[0],r[1],r[2]]);return e.d4(n.x,n.y,n.z)}function fr(t,i,r){const n="none"===i.properties.get("color-use-theme"),o=i.properties.get("color"),s=i.properties.get("intensity"),a=i.properties.get("direction"),l=[a.x,a.y,a.z],c="none"===r.properties.get("color-use-theme"),u=r.properties.get("color"),h=r.properties.get("intensity"),d=Math.max(e.bI([0,0,1],l),0),p=[0,0,0];e.c4(p,u.toPremultipliedRenderColor(c?null:t.getLut(i.scope)).toArray01Linear().slice(0,3),h);const f=[0,0,0];return e.c4(f,o.toPremultipliedRenderColor(n?null:t.getLut(r.scope)).toArray01Linear().slice(0,3),d*s),e.da([p[0]>0?p[0]/(p[0]+f[0]):0,p[1]>0?p[1]/(p[1]+f[1]):0,p[2]>0?p[2]/(p[2]+f[2]):0])}function mr(t,i,r,n,o,s){const a=t.zoom,l=t.scale,c=t.worldSize,u=1/c,h=t.aspect,d=Math.sqrt(1+h*h)*Math.tan(.5*t.fovX),p=d*d,f=n-r,m=n+r;let g,_;p>f/m?(g=n,_=n*d):(g=.5*m*(1+p),_=.5*Math.sqrt(f*f+2*(n*n+r*r)*p+m*m*p*p));const A=t.projection.pixelsPerMeter(t.center.lat,c),y=t._camera.getCameraToWorldMercator(),v=[0,0,-g*u];e.af(v,v,y);let x=_*u;const b=t._edgeInsets;if(!(0===b.left&&0===b.top&&0===b.right&&0===b.bottom||b.left===b.right&&b.top===b.bottom)){const i=t._camera.getWorldToCamera(t.worldSize,"meters"===t.projection.zAxisUnit?A:1),o=t._camera.getCameraToClipPerspective(t._fov,t.width/t.height,r,n);o[8]=2*-t.centerOffset.x/t.width,o[9]=2*t.centerOffset.y/t.height;const s=new Float64Array(16);e.cO(s,o,i);const u=new Float64Array(16);e.bk(u,s);const h=e.cA.fromInvProjectionMatrix(u,c,a,!0);for(const i of h.points){const r=((w=i)[0]/=l,w[1]/=l,w[2]=e.ce(w[2],t._center.lat),w);x=Math.max(x,e.c5(e.d9([],v,r)))}}var w;x*=o/(o-1);const T=Math.acos(i[2]),E=Math.atan2(-i[0],-i[1]),C=new ir;C.position=v,C.setPitchBearing(T,E);const B=C.getWorldToCamera(c,A),S=x*c,I=Math.min(t._mercatorZfromZoom(17)*c*-2,-2*S),M=C.getCameraToClipOrthographic(-S,S,-S,S,I,(S+s*A)/i[2]),P=new Float64Array(16);e.aB(P,M,B);const R=e.d4(Math.floor(1e6*v[0])/1e6*c,Math.floor(1e6*v[1])/1e6*c,0),L=.5*o,F=[0,0,0];e.af(F,R,P),e.c4(F,F,L);const k=[Math.floor(F[0]),Math.floor(F[1]),Math.floor(F[2])],D=[0,0,0];e.av(D,F,k),e.c4(D,D,-1/L);const O=new Float64Array(16);return e.bz(O),e.bq(O,O,D),e.aB(P,O,P),[P,S]}class gr extends e.E{constructor(e){super(),this.requestManager=e,this.models={"":{}},this.modelUris={"":{}},this.modelByURL={},this.numModelsLoading={}}loadModel(t,i){return e.db(this.requestManager.transformRequest(i,e.R.Model).url).then(r=>{if(!r)return;const n=e.dc(r),o=new e.dd(t,i,void 0,void 0,n);return o.computeBoundsAndApplyParent(),o}).catch(r=>{if(r&&404===r.status)return null;this.fire(new e.y(new Error(`Could not load model ${t} from ${i}: ${r.message}`)))})}load(t,i,r={forceReload:!1}){this.models[i]||(this.models[i]={});const n=Object.keys(t),o=[],s=[];for(const e of n){const n=t[e];this.hasURLBeenRequested(n)&&!r.forceReload||(this.modelByURL[n]={modelId:e,scope:i},o.push(this.loadModel(e,n)),s.push(e)),this.models[i][e]||(this.models[i][e]={model:null,numReferences:1})}this.numModelsLoading[i]=(this.numModelsLoading[i]||0)+s.length,Promise.allSettled(o).then(t=>{for(let e=0;e{this.fire(new e.y(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]={}),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]||{}}addModel(e,t,i){this.models[i]||(this.models[i]={}),this.modelUris[i]||(this.modelUris[i]={});const r=this.requestManager.normalizeModelURL(t);if((this.hasModel(e,i,{exactIdMatch:!0})||this.hasModelBeenAdded(e,i))&&this.modelUris[i][e]===r)this.models[i][e].numReferences++;else if(this.hasURLBeenRequested(r)){const{scope:e,modelId:t}=this.modelByURL[r];this.models[e][t].numReferences++}else this.modelUris[i][e]=r,this.load({[e]:this.modelUris[i][e]},i)}addModelURLs(e,t){this.models[t]||(this.models[t]={}),this.modelUris[t]||(this.modelUris[t]={});const i=this.modelUris[t];for(const t in e)i[t]=this.requestManager.normalizeModelURL(e[t])}reloadModels(e){this.load(this.modelUris[e],e,{forceReload:!0})}addModelsFromBucket(t,i){this.models[i]||(this.models[i]={}),this.modelUris[i]||(this.modelUris[i]={});const r={};for(const n of t)this.hasModel(n,i,{exactIdMatch:!0})||this.hasURLBeenRequested(n)?this.models[i][n].numReferences++:this.modelUris[i][n]&&!this.hasURLBeenRequested(n)?r[n]=this.modelUris[i][n]:!this.hasURLBeenRequested(n)&&e.de(n,!1)&&(this.modelUris[i][n]=this.requestManager.normalizeModelURL(n),r[n]=this.modelUris[i][n]);this.load(r,i)}hasURLBeenRequested(e){return void 0!==this.modelByURL[e]}removeModel(e,t,i=!1,r=!1){if(this.models[t]&&this.models[t][e]&&(this.models[t][e].numReferences--,0===this.models[t][e].numReferences||r)){const r=this.modelUris[t][e];i||delete this.modelUris[t][e],delete this.modelByURL[r];const n=this.models[t][e].model;if(!n)return;delete this.models[t][e],n.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={"":{}},this.modelUris={"":{}},this.modelByURL={},this.numModelsLoading={}}listModels(e){return this.models[e]||(this.models[e]={}),Object.keys(this.models[e])}upload(e,t){this.models[t]||(this.models[t]={});for(const i in this.models[t])this.models[t][i].model&&this.models[t][i].model.upload(e.context)}}const _r=e.a6.colorTheme,Ar=new e.a9({data:new e.aa(_r.data)});function yr(t){if(!t.metadata||!t.metadata.content_area)return;const i=e.o.devicePixelRatio,{left:r,top:n,width:o,height:s}=t.metadata.content_area,a=r*i,l=n*i;return[a,l,a+o*i,l+s*i]}function vr(t){if(t)return t.map(([t,i])=>[t*e.o.devicePixelRatio,i*e.o.devicePixelRatio])}class xr{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 r=this.sourceCache.getSource();if(!(r instanceof ht))return t;const n=i.map(e=>this.sourceCache.getTile(e)),o=r.getImages(n,Array.from(this.pendingRequests));for(const[i,r]of o)t.set(e.I.from({name:i,iconsetId:this.id}),r),this.pendingRequests.delete(i);for(const e of this.pendingRequests)this.missingRequests.add(e);return this.pendingRequests.clear(),t}}const br=(e,t)=>Le(e,t&&t.filter(e=>"source.canvas"!==e.identifier)),wr=e.aH(Nt,["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"]),Tr=e.aH(Nt,["setCenter","setZoom","setBearing","setPitch"]),Er=new Set(["background","sky","slot","custom"]),Cr={version:8,layers:[],sources:{}},Br={duration:300,delay:0};class Sr 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=Object.assign({},Br),this._buildingIndex=new Ot(this),this.crossTileSymbolIndex=new Gi,this._mergedOrder=[],this._drapedFirstOrder=[],this._mergedLayers={},this._mergedIndoor={},this._mergedSourceCaches={},this._mergedOtherSourceCaches={},this._mergedSymbolSourceCaches={},this._clipLayerPresent=!1,this._hasAppearances=!1,this._has3DLayers=!1,this._hasCircleLayers=!1,this._hasSymbolLayers=!1,this._importedAsBasemap=!1,this._changes=i.styleChanges||new H,this.dispatcher=i.dispatcher?i.dispatcher:new e.D(e.dg(),this),i.imageManager?this.imageManager=i.imageManager:(this.imageManager=new $(this.map._spriteFormat),this.imageManager.setEventedParent(this)),this.imageManager.addScope(this.scope),this.glyphManager=i.glyphManager?i.glyphManager:new e.dh(t._requestManager,i.localFontFamily?e.di.all:i.localIdeographFontFamily?e.di.ideographs:e.di.none,i.localFontFamily||i.localIdeographFontFamily),i.modelManager?this.modelManager=i.modelManager:(this.modelManager=new gr(t._requestManager),this.modelManager.setEventedParent(this)),this._layers={},this._sourceCaches={},this._otherSourceCaches={},this._symbolSourceCaches={},this._loaded=!1,this._precompileDone=!1,this._shouldPrecompile=!1,this._availableImages=[],this._availableModels={},this._order=[],this._markersNeedUpdate=!1,this.options=i.configOptions?i.configOptions:new Map,this._configDependentLayers=i.configDependentLayers?i.configDependentLayers:new Set,this._indoorDependentLayers=i.indoorDependentLayers?i.indoorDependentLayers:new Set,this._config=i.config,this._styleColorTheme={lut:null,lutLoading:!1,lutLoadingCorrelationID:0,colorTheme:null,colorThemeOverride:i.colorThemeOverride},this._styleColorThemeForScope={},this._initialConfig=i.initialConfig,this.dispatcher.broadcast("setReferrer",e.dj());const r=this;this._rtlTextPluginCallback=Sr.registerForPluginStateChange(t=>{r.dispatcher.broadcast("syncRTLPluginState",{pluginStatus:t.pluginStatus,pluginURL:t.pluginURL},(t,i)=>{if(e.dk(t),i&&i.every(e=>e))for(const e in r._sourceCaches){const t=r._sourceCaches[e],i=t.getSource().type;"vector"!==i&&"geojson"!==i||t.reload()}})}),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.h(t))return t;const i=e.dl(t);if(!i.startsWith("http"))try{return new URL(i,location.href).toString()}catch(e){return i}return i}return`json://${e.dm(JSON.stringify(t))}`}_diffStyle(t,i,r){this.globalId=this._getGlobalId(t);const n=(e,t)=>{try{t(null,this.setState(e,r))}catch(e){t(e,!1)}};if("string"==typeof t){const r=this.map._requestManager.normalizeStyleURL(t),o=this.map._requestManager.transformRequest(r,e.R.Style);e.m(o,(t,r)=>{t?this.fire(new e.y(t)):r&&n(r,i)})}else"object"==typeof t&&n(t,i)}loadURL(t,i={}){this.fire(new e.z("dataloading",{dataType:"style"}));const r="boolean"==typeof i.validate?i.validate:!e.h(t);this.globalId=this._getGlobalId(t),t=this.map._requestManager.normalizeStyleURL(t,i.accessToken),this.resolvedImports.add(t);const n=this.importsCache.get(t);if(n)return this._load(n,r);const o=this.map._requestManager.transformRequest(t,e.R.Style);this._request=e.m(o,(i,n)=>{if(this._request=null,i)this.fire(new e.y(i));else if(n)return this.importsCache.set(t,n),this._load(n,r)})}loadJSON(t,i={}){this.fire(new e.z("dataloading",{dataType:"style"})),this.globalId=this._getGlobalId(t),this._request=e.o.frame(()=>{this._request=null,this._load(t,!1!==i.validate)})}loadEmpty(){this.fire(new e.z("dataloading",{dataType:"style"})),this._load(Cr,!1)}_loadImports(t,i,r){if(this.importDepth>=4)return e.w("Style doesn't support nesting deeper than 5"),Promise.resolve();const n=[];for(const e of t){const t=this._createFragmentStyle(e),o=new Promise(e=>{t.once("style.import.load",e),t.once("error",e)}).then(()=>this.mergeAll());if(n.push(o),this.resolvedImports.has(e.url)){t.loadEmpty();continue}const s=e.data||this.importsCache.get(e.url);s?(t.loadJSON(s,{validate:i}),this._isInternalStyle(s)&&(t.globalId=null)):e.url?t.loadURL(e.url,{validate:i}):t.loadEmpty();const a={style:t,id:e.id,config:e.config};if(r){const e=this.fragments.findIndex(({id:e})=>e===r);this.fragments=this.fragments.slice(0,e).concat(a).concat(this.fragments.slice(e))}else this.fragments.push(a)}return Promise.allSettled(n)}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.B(t.id,this.scope):t.id;let r;const n=this._initialConfig&&this._initialConfig[i];(t.config||n)&&(r=Object.assign({},t.config,n));const o=new Sr(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:r,configOptions:this.options,colorThemeOverride:t["color-theme"],configDependentLayers:this._configDependentLayers,indoorDependentLayers:this._indoorDependentLayers});return o.setEventedParent(this.map,{style:o}),o}_reloadImports(){this.mergeAll(),this._updateMapProjection(),this.updateConfigDependencies(),this._updateLayers(this._indoorDependentLayers),this.map._triggerCameraUpdate(this.camera),this.dispatcher.broadcast("setLayers",{layers:this._serializeLayers(this._order),scope:this.scope,options:this.options}),this._shouldPrecompile=this.map._precompilePrograms&&this.isRootStyle()}_isInternalStyle(e){return this.isRootStyle()&&(e.fragment||!!e.schema&&!1!==e.fragment)}_load(t,i){if(this._isInternalStyle(t)){const e=Object.assign({},Cr,{imports:[{id:"basemap",data:t,url:""}]},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(e,i)}if(this.updateConfig(this._config,t.schema),i&&br(this,ye(t)))return;this._loaded=!0,this.stylesheet=e.dn(t);const r=()=>{for(const e in t.sources)this.addSource(e,t.sources[e],{validate:!1,isInitialLoad:!0});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,isLoaded:!0})),!this.glyphManager.url&&t.glyphs&&this.glyphManager.setURL(t.glyphs);const r=Ut(this.stylesheet.layers);if(this._order=r.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 De(e.properties,e.id)}else this.setLights(this.stylesheet.lights);this.light||(this.light=new De(this.stylesheet.light)),this._layers={};for(const t of r){const i=e.dt(t,this.scope,this._styleColorTheme.lut,this.options);0!==i.expressionDependencies.configDependencies.size&&this._configDependentLayers.add(i.fqid),i.expressionDependencies.isIndoorDependent&&this._indoorDependentLayers.add(i.fqid),this._hasAppearances=this._hasAppearances||0!==i.getAppearances().length,i.setEventedParent(this,{layer:{id:i.id}}),this._layers[i.id]=i;const r=this.getOwnLayerSourceCache(i),n=!!this.directionalLight&&this.directionalLight.shadowsEnabled();r&&i.canCastShadows()&&n&&(r.castsShadows=!0)}this.stylesheet.featuresets&&this.setFeaturesetSelectors(this.stylesheet.featuresets),this.stylesheet.models&&this.addModelURLs(this.stylesheet.models);const n=this.stylesheet.terrain;n&&(this.checkCanvasFingerprintNoise(),this.disableElevatedTerrain||this.terrainSetForDrapingOnly()||this._createTerrain(n,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.z("data",{dataType:"style"}));const o=this.isRootStyle();t.imports?this._loadImports(t.imports,i).then(()=>{this._reloadImports(),this.fire(new e.z(o?"style.load":"style.import.load"))}).catch(t=>{this.fire(new e.y(new Error("Failed to load imports",t))),this.fire(new e.z(o?"style.load":"style.import.load"))}):(this._reloadImports(),this.fire(new e.z(o?"style.load":"style.import.load")))};this._styleColorTheme.colorTheme=this.stylesheet["color-theme"];const n=this._styleColorTheme.colorThemeOverride?this._styleColorTheme.colorThemeOverride:this._styleColorTheme.colorTheme;if(n){const t=this._evaluateColorThemeData(n);this._loadColorTheme(t).then(()=>{r()}).catch(t=>{e.w(`Couldn't load color theme from the stylesheet: ${t}`),r()})}else this._styleColorTheme.lut=null,r()}isRootStyle(){return 0===this.importDepth}hasAppearances(){return this._hasAppearances}mergeAll(){let e,t,i,r,n,o,s,a,l,c;const u={};this.terrain&&this.terrain.scope!==this.scope&&delete this.terrain,this.forEachFragmentStyle(h=>{if(h.stylesheet){if(null!=h.light&&(e=h.light),h.stylesheet.lights)for(const e of h.stylesheet.lights)"ambient"===e.type&&null!=h.ambientLight&&(t=h.ambientLight),"directional"===e.type&&null!=h.directionalLight&&(i=h.directionalLight);r=this._prioritizeTerrain(r,h.terrain,h.stylesheet.terrain),h.stylesheet.fog&&null!=h.fog&&(n=h.fog),h.stylesheet.snow&&null!=h.snow&&(o=h.snow),h.stylesheet.rain&&null!=h.rain&&(s=h.rain),null!=h.stylesheet.camera&&(c=h.stylesheet.camera),null!=h.stylesheet.projection&&(a=h.stylesheet.projection),null!=h.stylesheet.transition&&(l=h.stylesheet.transition),u[h.scope]=h._styleColorTheme}}),this.light=e,this.ambientLight=t,this.directionalLight=i,this.fog=n,this.snow=o,this.rain=s,this._styleColorThemeForScope=u,null===r?delete this.terrain:this.terrain=r,this.camera=c||{"camera-projection":"perspective"},this.projection=a||{name:"mercator"},this.transition=Object.assign({},Br,l),this.mergeSources(),this.mergeLayers(),this.mergeIndoor()}forEachFragmentStyle(e){const t=i=>{for(const e of i.fragments)t(e.style);e(i)};t(this)}_prioritizeTerrain(e,t,i){const r=e&&0===e.drapeRenderMode;return null===i?t&&0===t.drapeRenderMode?t:r?e:null:null!=t&&(!e||r||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}mergeProjection(){let e;this.forEachFragmentStyle(t=>{null!=t.stylesheet.projection&&(e=t.stylesheet.projection)}),this.projection=e||{name:"mercator"}}mergeSources(){const t={},i={},r={};this.forEachFragmentStyle(n=>{for(const i in n._sourceCaches){const r=e.B(i,n.scope);t[r]=n._sourceCaches[i]}for(const t in n._otherSourceCaches){const r=e.B(t,n.scope);i[r]=n._otherSourceCaches[t]}for(const t in n._symbolSourceCaches){const i=e.B(t,n.scope);r[i]=n._symbolSourceCaches[t]}}),this._mergedSourceCaches=t,this._mergedOtherSourceCaches=i,this._mergedSymbolSourceCaches=r}mergeIndoor(){this.forEachFragmentStyle(t=>{if(t.stylesheet&&t.stylesheet.indoor)for(const i of Object.values(t.stylesheet.indoor)){const r=i,n=e.B(r.sourceId,t.scope);this._mergedIndoor[n]=new Set(r.sourceLayers||[])}})}mergeLayers(){const t={},i=[],r={};this._mergedSlots=[],this._has3DLayers=!1,this._hasCircleLayers=!1,this._hasSymbolLayers=!1,this.forEachFragmentStyle(r=>{for(const n of r._order){const o=r._layers[n];if("slot"===o.type){const i=e.dp(n);if(t[i])continue;t[i]=[]}o.slot&&t[o.slot]?t[o.slot].push(o):i.push(o)}}),this._mergedOrder=[];let n=-1;const o=(i=[])=>{for(const s of i)if("slot"===s.type){const i=e.dp(s.id);t[i]&&o(t[i]),this._mergedSlots.push(i)}else{const t=e.B(s.id,s.scope);this._mergedOrder.push(t),r[t]=s,s.is3D(!!this.terrain)&&(this._has3DLayers=!0,n=this._mergedOrder.length-1),"circle"===s.type&&(this._hasCircleLayers=!0),"symbol"===s.type&&(this._hasSymbolLayers=!0),"clip"===s.type&&(this._clipLayerPresent=!0)}};if(o(i),this._has3DLayers){const e={};for(let t=0;te[t]-e[i])}this._mergedLayers=r,this.updateDrapeFirstLayers(),this._buildingIndex.processLayersChanged()}terrainSetForDrapingOnly(){return!!this.terrain&&0===this.terrain.drapeRenderMode}getCamera(){return this.stylesheet.camera}setCamera(e){return this.stylesheet.camera=Object.assign({},this.stylesheet.camera,e),this.camera=this.stylesheet.camera,this}_evaluateColorThemeData(t){return t.data?function(t,i,r){const n=Object.assign({},i);for(const e of Object.keys(_r))void 0===n[e]&&(n[e]=_r[e].default);const o=new e.a8(Ar,t,new Map(r));return o.setTransitionOrValue(n,r),o.untransitioned().possiblyEvaluate(new e.ac(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((r,n)=>{const o="data:image/png;base64,";if(!t||0===t.length)return this._styleColorTheme.lut=null,this._styleColorTheme.lutLoading=!1,void r();let s=t;s.startsWith(o)||(s=o+s);const a=e.I.from("mapbox-reserved-lut"),l=new Image;l.src=s,l.onerror=()=>{this._styleColorTheme.lutLoading=!1,n(new Error("Failed to load image data"))},l.onload=()=>{if(this._styleColorTheme.lutLoadingCorrelationID!==i)return void r();this._styleColorTheme.lutLoading=!1;const{width:o,height:s,data:c}=e.o.getImageData(l);if(s>32)return void n(new Error("The height of the image must be less than or equal to 32 pixels."));if(o!==s*s)return void n(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.q({width:o,height:s},c),pixelRatio:1,sdf:!1,usvg:!1,version:0});const u=this.imageManager.getImage(a,this.scope);u?(this._styleColorTheme.lut={image:u.data,data:t},r()):n(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.getTerrain()||this.stylesheet.terrain)&&!this.disableElevatedTerrain||this.setTerrainForDraping():this.terrainSetForDrapingOnly()&&this.setTerrain(null,0))}_updateMapProjection(){this.isRootStyle()&&(this.map._useExplicitProjection?this.applyProjectionUpdate():this.map._prioritizeAndUpdateProjection(null,this.projection))}_loadSprite(t){this._spriteRequest=function(t,i,r){let n,o,s;const a=e.o.devicePixelRatio>1?"@2x":"";let l=e.m(i.transformRequest(i.normalizeSpriteURL(t,a,".json"),e.R.SpriteJSON),(e,t)=>{l=null,s||(s=e,n=t,u())}),c=e.n(i.transformRequest(i.normalizeSpriteURL(t,a,".png"),e.R.SpriteImage),(e,t)=>{c=null,s||(s=e,o=t,u())});function u(){if(s)r(s);else if(n&&o){const t=e.o.getImageData(o),i={};for(const r in n){const{width:o,height:s,x:a,y:l,sdf:c,pixelRatio:u,stretchX:h,stretchY:d,content:p}=n[r],f=new e.q({width:o,height:s});e.q.copy(t,f,{x:a,y:l},{x:0,y:0},{width:o,height:s},null),i[r]={data:f,pixelRatio:void 0!==u?u:1,sdf:void 0!==c&&c,stretchX:h,stretchY:d,content:p,usvg:!1,version:0}}r(null,i)}}return{cancel(){l&&(l.cancel(),l=null),c&&(c.cancel(),c=null)}}}(t,this.map._requestManager,(t,i)=>{if(this._spriteRequest=null,t)this.fire(new e.y(t));else if(i){const t=new Map;for(const r in i)t.set(e.I.from(r),i[r]);this.addImages(t)}this.imageManager.setLoaded(!0,this.scope),this.dispatcher.broadcast("spriteLoaded",{scope:this.scope,isLoaded:!0}),this.fire(new e.z("data",{dataType:"style"}))})}addIconset(t,i){if("sprite"===i.type)return void this._loadSprite(i.url);const r=this.getOwnSourceCache(i.source);if(!r)return void this.fire(new e.y(new Error(`Source "${i.source}" as specified by iconset "${t}" does not exist and cannot be used as an iconset source`)));const n=r.getSource();if("raster-array"!==n.type)return void this.fire(new e.y(new Error(`Source "${i.source}" as specified by iconset "${t}" is not a "raster-array" source and cannot be used as an iconset source`)));n.partial=!1;const o=new xr(t,this.scope,r);this.imageManager.addImageProvider(o,this.scope)}removeIconset(e){this.imageManager.removeImageProvider(e,this.scope)}_loadIconset(t){if(!e.h(t)&&"icon_set"!==this.map._spriteFormat||"raster"===this.map._spriteFormat)return void this._loadSprite(t);const i="auto"===this.map._spriteFormat;var r,n;this._spriteRequest=(n=(r,n)=>{if(this._spriteRequest=null,r)i?this._loadSprite(t):this.fire(new e.y(r));else if(n){const t=new Map;for(const i in n)t.set(e.I.from(i),n[i]);this.addImages(t)}this.imageManager.setLoaded(!0,this.scope),this.dispatcher.broadcast("spriteLoaded",{scope:this.scope,isLoaded:!0}),this.fire(new e.z("data",{dataType:"style"}))},e.bt((r=this.map._requestManager).transformRequest(r.normalizeIconsetURL(t),e.R.Iconset),(t,i)=>{if(t)return void n(t);const r={},o=e.df(new e.bs(i));for(const t of o.icons){const i={version:1,pixelRatio:e.o.devicePixelRatio,content:yr(t),stretchX:t.metadata?vr(t.metadata.stretch_x_areas):void 0,stretchY:t.metadata?vr(t.metadata.stretch_y_areas):void 0,sdf:!1,usvg:!0,icon:t};r[t.name]=i}n(null,r)}))}_validateLayer(t){const i=this.getOwnSource(t.source);if(!i)return;const r=t.sourceLayer;r&&("geojson"===i.type||i.vectorLayerIds&&-1===i.vectorLayerIds.indexOf(r))&&this.fire(new e.y(new Error(`Source layer "${r}" 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}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.y(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.y(new Error(`The source '${t}' does not exist in the map's style.`)))}precompilePrograms(e,t){const i=this.map.painter;if(i)for(let r=e.minzoom||0;r<(e.maxzoom||25.5);r++){const r=e.getProgramIds();if(r)for(const n of r){const r=e.getDefaultProgramParams(n,t.zoom,this._styleColorTheme.lut);r&&(i.style=this,this.fog&&(i._fogVisible=!0,r.overrideFog=!0,i.getOrCreateProgram(n,r)),i._fogVisible=!1,r.overrideFog=!1,i.getOrCreateProgram(n,r),(this.stylesheet.terrain||this.stylesheet.projection&&"globe"===this.stylesheet.projection.name)&&(r.overrideRtt=!0,i.getOrCreateProgram(n,r)))}}}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,i!==this._brightness&&(this._brightness=i,this.dispatcher.broadcast("setBrightness",i)),t.worldview!==this._worldview&&(this._worldview=t.worldview,this.dispatcher.broadcast("setWorldview",this._worldview));const r=this._changes.isDirty();let n=!1;if(this._changes.isDirty()){const e=this._changes.getLayerUpdatesByScope();for(const t in e){const{updatedIds:i,removedIds:r}=e[t];(i||r)&&(this._updateWorkerLayers(t,i,r),n=!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 o={};for(const e in this._mergedSourceCaches){const t=this._mergedSourceCaches[e];o[e]=t.used,t.used=!1,t.tileCoverLift=0}for(const e of this._mergedOrder){const i=this._mergedLayers[e];if(i.recalculate(t,this._availableImages),!i.isHidden(t.zoom)){const e=this.getLayerSourceCache(i);e&&(e.used=!0,e.tileCoverLift=Math.max(e.tileCoverLift,i.tileCoverLift()))}!this._precompileDone&&this._shouldPrecompile&&("requestIdleCallback"in window?requestIdleCallback(()=>{this.precompilePrograms(i,t)}):this.precompilePrograms(i,t))}this._shouldPrecompile&&(this._precompileDone=!0),this.terrain&&n&&this.mergeLayers();const s=this.imageManager.getPendingImageProviders();for(const e of s)e.sourceCache.used=!0;for(const t in o){const i=this._mergedSourceCaches[t];o[t]!==i.used&&i.getSource().fire(new e.z("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.z("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 r=this.getFragmentStyle(e);r&&this.dispatcher.broadcast("updateLayers",{layers:t?r._serializeLayers(t):[],scope:e,removedIds:i||[],options:r.options})}setState(t,i){if(this._checkLoaded(),br(this,ye(t)))return!1;(t=e.dn(t)).layers=Ut(t.layers);const r=function(t,i){if(!t)return[{command:Nt.setStyle,args:[i]}];let r=[];try{if(!e.bx(t.version,i.version))return[{command:Nt.setStyle,args:[i]}];if(e.bx(t.center,i.center)||r.push({command:Nt.setCenter,args:[i.center]}),e.bx(t.zoom,i.zoom)||r.push({command:Nt.setZoom,args:[i.zoom]}),e.bx(t.bearing,i.bearing)||r.push({command:Nt.setBearing,args:[i.bearing]}),e.bx(t.pitch,i.pitch)||r.push({command:Nt.setPitch,args:[i.pitch]}),e.bx(t.sprite,i.sprite)||r.push({command:Nt.setSprite,args:[i.sprite]}),e.bx(t.glyphs,i.glyphs)||r.push({command:Nt.setGlyphs,args:[i.glyphs]}),e.bx(t.imports,i.imports)||function(t=[],i=[],r){i=i||[];const n=(t=t||[]).map($t),o=i.map($t),s=t.reduce(Zt,{}),a=i.reduce(Zt,{}),l=n.slice();let c,u,h,d;for(c=0,u=0;c{e.source&&n[e.source]?r.push({command:Nt.removeLayer,args:[e.id]}):s.push(e)});let a=t.terrain;a&&n[a.source]&&(r.push({command:Nt.setTerrain,args:[void 0]}),a=void 0),r=r.concat(o),e.bx(a,i.terrain)||r.push({command:Nt.setTerrain,args:[i.terrain]}),function(t,i,r){i=i||[];const n=(t=t||[]).map($t),o=i.map($t),s=t.reduce(Zt,{}),a=i.reduce(Zt,{}),l=n.slice(),c=Object.create(null);let u,h,d,p,f,m,g;for(u=0,h=0;u!(e.command in Tr));if(0===r.length)return!1;const n=r.filter(e=>!(e.command in wr));if(n.length>0)throw new Error(`Unimplemented: ${n.map(e=>e.command).join(", ")}.`);const o=[];return r.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(){this._availableImages=this.imageManager.listImages(this.scope),this.dispatcher.broadcast("setImages",{scope:this.scope,images:this._availableImages})}_updateWorkerModels(){this._availableModels=this.modelManager.getModelURIs(this.scope),this.dispatcher.broadcast("setModels",{scope:this.scope,models:this._availableModels})}addImages(t){if(0===t.size)return this;for(const[i,r]of t.entries()){if(this.getImage(i))return this.fire(new e.y(new Error(`An image with the name "${i.name}" already exists.`)));this.imageManager.addImage(i,this.scope,r),this._changes.updateImage(i,this.scope)}return this._updateWorkerImages(),this.fire(new e.z("data",{dataType:"style"})),this}addImage(t,i){return this.getImage(t)?this.fire(new e.y(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.z("data",{dataType:"style"})),this)}updateImage(t,i,r=!1){this.imageManager.updateImage(t,this.scope,i),r&&(this._changes.updateImage(t,this.scope),this._updateWorkerImages(),this.fire(new e.z("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.z("data",{dataType:"style"})),this):this.fire(new e.y(new Error("No image with this name exists.")))}listImages(){return this._checkLoaded(),this._availableImages.slice()}addModelURLs(t){return this.modelManager.addModelURLs(t,this.scope),this._updateWorkerModels(),this.fire(new e.z("data",{dataType:"style"})),this}addModel(t,i,r={}){return this._checkLoaded(),this._validate(Pe,`models.${t}`,i,null,r)||(this.modelManager.addModel(t,i,this.scope),this.fire(new e.z("data",{dataType:"style"}))),this}hasModel(e){return this.modelManager.hasModel(e,this.scope)}removeModel(t){return this.hasModel(t)?(this.modelManager.removeModel(t,this.scope,!1,!0),this.fire(new e.z("data",{dataType:"style"})),this):this.fire(new e.y(new Error("No model with this ID exists.")))}listModels(){return this._checkLoaded(),this.modelManager.listModels(this.scope)}addSource(t,i,r={}){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"].indexOf(i.type)>=0&&this._validate(ve,`sources.${t}`,i,null,r))return;this.map&&this.map._collectResourceTiming&&(i.collectResourceTiming=!0);const n=pt(t,i,this.dispatcher,this);n.scope=this.scope,n.setEventedParent(this,()=>({isSourceLoaded:this._isSourceCacheLoaded(n.id),source:n.serialize(),sourceId:n.id}));const o=t=>{const i=(t?"symbol:":"other:")+n.id,r=e.B(i,this.scope),o=this._sourceCaches[i]=new Lt(r,n,t);(t?this._symbolSourceCaches:this._otherSourceCaches)[n.id]=o,o.onAdd(this.map)};o(!1),"vector"!==i.type&&"geojson"!==i.type||o(!0),n.onAdd&&n.onAdd(this.map),r.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.y(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.y(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.y(new Error(`Source "${t}" cannot be removed while iconset "${i[0]}" is using it.`)))}const r=this.getOwnSourceCaches(t);for(const t of r){const i=e.dp(t.id);delete this._sourceCaches[i],this._changes.discardSourceCacheUpdate(t.id),t.fire(new e.z("data",{sourceDataType:"metadata",dataType:"source",sourceId:t.getSource().id})),t.setEventedParent(null),t.clearTiles()}return delete this._otherSourceCaches[t],delete this._symbolSourceCaches[t],this.mergeSources(),i.setEventedParent(null),i.onRemove&&i.onRemove(this.map),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(),!t)return delete this.ambientLight,void delete this.directionalLight;const i=this._getTransitionParameters();for(const r of t){if(this._validate(be,"lights",r))return;switch(r.type){case"ambient":if(this.ambientLight){const e=this.ambientLight;e.set(r),e.updateTransitions(i)}else this.ambientLight=new et(r,Ke||(Ke=new e.a9({color:new e.aa(e.a6.properties_light_ambient.color),"color-use-theme":new e.aa({type:"string",default:"default","property-type":"data-constant"}),intensity:new e.aa(e.a6.properties_light_ambient.intensity)})),this.scope,this.options);break;case"directional":if(this.directionalLight){const e=this.directionalLight;e.set(r),e.updateTransitions(i)}else this.directionalLight=new et(r,Xe||(Xe=new e.a9({direction:new e.ap(e.a6.properties_light_directional.direction),color:new e.aa(e.a6.properties_light_directional.color),"color-use-theme":new e.aa({type:"string",default:"default","property-type":"data-constant"}),intensity:new e.aa(e.a6.properties_light_directional.intensity),"cast-shadows":new e.aa(e.a6.properties_light_directional["cast-shadows"]),"shadow-quality":new e.aa(e.a6.properties_light_directional["shadow-quality"]),"shadow-intensity":new e.aa(e.a6.properties_light_directional["shadow-intensity"])})),this.scope,this.options)}}const r=Object.assign(i,{worldview:this.map.getWorldview()}),n=new e.ac(this.z||0,r);this.ambientLight&&this.ambientLight.recalculate(n),this.directionalLight&&this.directionalLight.recalculate(n),this._brightness=this.calculateLightsBrightness(),this.dispatcher.broadcast("setBrightness",this._brightness)}calculateLightsBrightness(){const t=this.directionalLight,i=this.ambientLight;if(!t||!i)return;const r=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)),n=t.properties.get("color").toNonPremultipliedRenderColor(null).toArray01(),o=t.properties.get("intensity"),s=t.properties.get("direction"),a=1-e.d3(s.x,s.y,s.z)[2]/90,l=r(n)*o*a,c=i.properties.get("color").toNonPremultipliedRenderColor(null).toArray01(),u=i.properties.get("intensity"),h=r(c)*u;return Number(((l+h)/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.dq(t)){const i=e.dr(t),r=this.fragments.find(({id:e})=>e===i);if(!r)return;const n=e.dp(t);return r.style.getFragmentStyle(n)}{const e=this.fragments.find(({id:e})=>e===t);return e?e.style:void 0}}setFeaturesetSelectors(t){if(!t)return;const i={},r=(e,t="")=>`${e}::${t}`;this._featuresetSelectors={};for(const n in t){const o=this._featuresetSelectors[n]=[];for(const s of t[n].selectors){if(s.featureNamespace){const t=this.getOwnLayer(s.layer);if(!t){e.w(`Layer is undefined for selector: ${s.layer}`);continue}const o=r(t.source,t.sourceLayer);if(o in i&&i[o]!==s.featureNamespace){e.w(`"featureNamespace ${s.featureNamespace} of featureset ${n}'s selector is not associated to the same source, skip this selector`);continue}i[o]=s.featureNamespace}let t;if(s.properties)for(const i in s.properties){const r=e.U(s.properties[i]);"success"===r.result&&(t=t||{},t[i]=r.value)}o.push({layerId:s.layer,namespace:s.featureNamespace,properties:t,uniqueFeatureID:s._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 r=this.getFragmentStyle(i),n=r.stylesheet.featuresets;if(!n||!n[t])return this.fire(new e.y(new Error(`The featureset '${t}' does not exist in the map's style and cannot be queried.`))),[];const o=[];for(const e of n[t].selectors){const t=r.getOwnLayer(e.layer);t&&o.push(t)}return o}getConfigProperty(t,i){const r=this.getFragmentStyle(t);if(!r)return null;const n=e.B(i,r.scope),o=r.options.get(n),s=o?o.value||o.default:null;return s?s.serialize():null}isIndoorEnabled(){return Object.keys(this._mergedIndoor).length>0}getIndoorSourceLayers(t,i){const r=e.B(t,i);return this._mergedIndoor[r]}setIndoorData(e,t){this.map.indoor.setIndoorData(t)}updateIndoorDependentLayers(){this._updateLayers(this._indoorDependentLayers),this.map._styleDirty=!0,this.map.triggerRepaint()}setConfigProperty(t,i,r){const n=this.getFragmentStyle(t);if(!n)return;const o=n.stylesheet.schema;if(!o||!o[i])return;const s=e.U(r);if("success"!==s.result)return void br(this,s.value);const a=s.value.expression,l=e.B(i,n.scope),c=n.options.get(l);if(!c)return;let u;const{minValue:h,maxValue:d,stepValue:p,type:f,values:m}=o[i],g=e.U(o[i].default);"success"===g.result&&(u=g.value.expression),u?(this.options.set(l,Object.assign({},c,{value:a,default:u,minValue:h,maxValue:d,stepValue:p,type:f,values:m})),this.updateConfigDependencies(i)):this.fire(new e.y(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 r=i.stylesheet.schema;if(!r)return null;const n={};for(const t in r){const r=e.B(t,i.scope),o=i.options.get(r),s=o?o.value||o.default:null;n[t]=s?s.serialize():null}return n}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 r in i){let n,o;const s=e.U(i[r].default);if("success"===s.result&&(n=s.value.expression),t&&void 0!==t[r]){const i=e.U(t[r]);"success"===i.result&&(o=i.value.expression)}const{minValue:a,maxValue:l,stepValue:c,type:u,values:h}=i[r];if(n){const t=e.B(r,this.scope);this.options.set(t,{default:n,value:o,minValue:a,maxValue:l,stepValue:c,type:u,values:h})}else this.fire(new e.y(new Error(`No schema defined for config option "${r}".`)))}else this.fire(new e.y(new Error("Attempting to set config for a style without schema.")))}_updateLayers(e,t=()=>!0){for(const i of e){const e=this.getLayer(i);e&&t(e)&&(e.possiblyEvaluateVisibility(),this._updateLayer(e),this._changes.setDirty())}}updateConfigDependencies(e){this._updateLayers(this._configDependentLayers,t=>!e||t.expressionDependencies.configDependencies.has(e)),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._changes.setDirty()}addLayer(t,i,r={}){this._checkLoaded();const n=t.id;if(this._layers[n])return void this.fire(new e.y(new Error(`Layer with id "${n}" already exists on this map`)));let o;if("custom"===t.type){if(br(this,e.ds(t)))return;o=e.dt(t,this.scope,this._styleColorTheme.lut,this.options)}else{if("object"==typeof t.source&&(this.addSource(n,t.source),t=e.dn(t),t=Object.assign(t,{source:n})),this._validate(Be,`layers.${n}`,t,{arrayIndex:-1},r))return;o=e.dt(t,this.scope,this._styleColorTheme.lut,this.options),this._validateLayer(o),o.setEventedParent(this,{layer:{id:n}})}const s=e.B(o.source,o.scope);0!==o.expressionDependencies.configDependencies.size&&this._configDependentLayers.add(s),o.expressionDependencies.isIndoorDependent&&this._indoorDependentLayers.add(s);let a=this._order.length;if(i){const t=this._order.indexOf(i);if(-1===t)return void this.fire(new e.y(new Error(`Layer with id "${i}" does not exist on this map.`)));o.slot===this._layers[i].slot?a=t:e.w(`Layer with id "${i}" has a different slot. Layers can only be rearranged within the same slot.`)}this._order.splice(a,0,n),this._layerOrderChanged=!0,this._layers[n]=o;const l=this.getOwnLayerSourceCache(o),c=!!this.directionalLight&&this.directionalLight.shadowsEnabled();l&&o.canCastShadows()&&c&&(l.castsShadows=!0);const u=this._changes.getRemovedLayer(o);if(u&&o.source&&l&&"custom"!==o.type){this._changes.discardLayerRemoval(o);const t=e.B(o.source,o.scope);u.type!==o.type?this._changes.updateSourceCache(t,"clear"):(this._changes.updateSourceCache(t,"reload"),l.pause())}this._updateLayer(o),o.onAdd&&o.onAdd(this.map),o.scope=this.scope,this.mergeLayers()}moveLayer(t,i){this._checkLoaded();const r=this._checkLayer(t);if(!r)return;if(t===i)return;const n=this._order.indexOf(t);this._order.splice(n,1);let o=this._order.length;if(i){const t=this._order.indexOf(i);if(-1===t)return void this.fire(new e.y(new Error(`Layer with id "${i}" does not exist on this map.`)));r.slot===this._layers[i].slot?o=t:e.w(`Layer with id "${i}" has a different slot. Layers can only be rearranged within the same slot.`)}this._order.splice(o,0,t),this._changes.setDirty(),this._layerOrderChanged=!0,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._layerOrderChanged=!0,this._configDependentLayers.delete(t.fqid),this._indoorDependentLayers.delete(t.fqid),this._changes.removeLayer(t);const r=this.getOwnLayerSourceCache(t);if(r&&r.castsShadows){let e=!1;for(const i in this._layers)if(this._layers[i].source===t.source&&this._layers[i].canCastShadows()){e=!0;break}r.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 r=this._checkLayer(e);r&&(r.minzoom===t&&r.maxzoom===i||(null!=t&&(r.minzoom=t),null!=i&&(r.maxzoom=i),this._updateLayer(r)))}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,r={}){this._checkLoaded();const n=this._checkLayer(t);if(n&&!e.bx(n.filter,i))return null==i?(n.filter=void 0,void this._updateLayer(n)):void(this._validate(Se,`layers.${n.id}.filter`,i,{layerType:n.type},r)||(n.filter=e.dn(i),this._updateLayer(n)))}getFilter(t){const i=this._checkLayer(t);if(i)return e.dn(i.filter)}setLayoutProperty(t,i,r,n={}){this._checkLoaded();const o=this._checkLayer(t);if(o&&!e.bx(o.getLayoutProperty(i),r)){if(null!=r&&(!n||!1!==n.validate)&&br(o,Me.call(ye,{key:`layers.${t}.layout.${i}`,layerType:o.type,objectKey:i,value:r,styleSpec:e.a6,style:{glyphs:!0,sprite:!0}})))return;o.setLayoutProperty(i,r),0!==o.expressionDependencies.configDependencies.size&&this._configDependentLayers.add(o.fqid),o.expressionDependencies.isIndoorDependent&&this._indoorDependentLayers.add(o.fqid),this._updateLayer(o)}}setLayerProperty(e,t,i,r={}){this._checkLoaded();const n=this._checkLayer(e);n&&("appearances"===t?(n.setAppearances(i),this._changes.setDirty()):n.isPaintProperty(t)?this.setPaintProperty(e,t,i,r):this.setLayoutProperty(e,t,i,r))}getLayoutProperty(e,t){const i=this._checkLayer(e);if(i)return i.getLayoutProperty(t)}setPaintProperty(t,i,r,n={}){this._checkLoaded();const o=this._checkLayer(t);if(!o)return;if(e.bx(o.getPaintProperty(i),r))return;if(null!=r&&(!n||!1!==n.validate)&&br(o,Ie.call(ye,{key:`layers.${t}.paint.${i}`,layerType:o.type,objectKey:i,value:r,styleSpec:e.a6})))return;const s=o.setPaintProperty(i,r);0!==o.expressionDependencies.configDependencies.size&&this._configDependentLayers.add(o.fqid),o.expressionDependencies.isIndoorDependent&&this._indoorDependentLayers.add(o.fqid),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:r}=t.target,n=this.getFragmentStyle(r),o=n.getFeaturesetLayers(e);for(const{source:e,sourceLayer:r}of o)n.setFeatureState({id:t.id,source:e,sourceLayer:r},i)}else if("layerId"in t.target){const{layerId:e}=t.target,r=this.getLayer(e);this.setFeatureState({id:t.id,source:r.source,sourceLayer:r.sourceLayer},i)}return}const r=t.source,n=t.sourceLayer,o=this._checkSource(r);if(!o)return;const s=o.type;if("geojson"===s&&n)return void this.fire(new e.y(new Error("GeoJSON sources cannot have a sourceLayer parameter.")));if("vector"===s&&!n)return void this.fire(new e.y(new Error("The sourceLayer parameter must be provided for vector source types.")));void 0===t.id&&this.fire(new e.y(new Error("The feature id parameter must be provided.")));const a=this.getOwnSourceCaches(r);for(const e of a)e.setFeatureState(n,t.id,i)}removeFeatureState(t,i){if(this._checkLoaded(),"target"in t){if("featuresetId"in t.target){const{featuresetId:e,importId:r}=t.target,n=this.getFragmentStyle(r),o=n.getFeaturesetLayers(e);for(const{source:e,sourceLayer:r}of o)n.removeFeatureState({id:t.id,source:e,sourceLayer:r},i)}else if("layerId"in t.target){const{layerId:e}=t.target,r=this.getLayer(e);this.removeFeatureState({id:t.id,source:r.source,sourceLayer:r.sourceLayer},i)}return}const r=t.source,n=this._checkSource(r);if(!n)return;const o=n.type,s="vector"===o?t.sourceLayer:void 0;if("vector"===o&&!s)return void this.fire(new e.y(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.y(new Error("A feature id is required to remove its specific state property.")));const a=this.getOwnSourceCaches(r);for(const e of a)e.removeFeatureState(s,t.id,i)}getFeatureState(t){if(this._checkLoaded(),"target"in t){let i;if("featuresetId"in t.target){const{featuresetId:r,importId:n}=t.target,o=this.getFragmentStyle(n),s=o.getFeaturesetLayers(r);for(const{source:r,sourceLayer:n}of s){const s=o.getFeatureState({id:t.id,source:r,sourceLayer:n});if(s&&!i)i=s;else if(!e.bx(i,s))return void this.fire(new e.y(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{layerId:e}=t.target,r=this.getLayer(e);i=this.getFeatureState({id:t.id,source:r.source,sourceLayer:r.sourceLayer})}return i}const i=t.source,r=t.sourceLayer,n=this._checkSource(i);if(n){if("vector"!==n.type||r)return void 0===t.id&&this.fire(new e.y(new Error("The feature id parameter must be provided."))),this.getOwnSourceCaches(i)[0].getFeatureState(r,t.id);this.fire(new e.y(new Error("The sourceLayer parameter must be provided for vector source types.")))}}setTransition(e){return this.stylesheet.transition=Object.assign({},this.stylesheet.transition,e),this.transition=this.stylesheet.transition,this}getTransition(){return Object.assign({},this.stylesheet.transition)}serialize(){this._checkLoaded();const t=this.getTerrain(),i=t&&this.terrain&&this.terrain.scope===this.scope?t:this.stylesheet.terrain;return e.du({version:this.stylesheet.version,name:this.stylesheet.name,metadata:this.stylesheet.metadata,fragment:this.stylesheet.fragment,iconsets:this.stylesheet.iconsets,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,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),r=e.B(t.source,t.scope),n=this._changes.getUpdatedSourceCaches();t.source&&!n[r]&&i&&"raster"!==i.getSource().type&&(this._changes.updateSourceCache(r,"reload"),i.pause()),t.invalidateCompiledFilter()}_flattenAndSortRenderedFeatures(e){const t=e=>this._mergedLayers[e].is3D(!!this.terrain),i=this.order,r={},n=[];for(let o=i.length-1;o>=0;o--){const s=i[o];if(t(s)){r[s]=o;for(const t of e){const e=t[s];if(e)for(const t of e)n.push(t)}}}n.sort((e,t)=>t.intersectionZ-e.intersectionZ);const o=[];for(let s=i.length-1;s>=0;s--){const a=i[s];if(t(a))for(let e=n.length-1;e>=0;e--){const t=n[e].feature;if(t.layer&&r[t.layer.id]{if(Er.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:n})};if(i&&i.layers){if(!Array.isArray(i.layers))return this.fire(new e.y(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.y(new Error(`The layer '${t}' does not exist in the map's style and cannot be queried for features.`))),[];s(i)}}else for(const e in this._layers)s(this._layers[e]);const a=this._queryRenderedFeatures(t,o,r),l=this._flattenAndSortRenderedFeatures(a),c=[];for(const t of l)e.dv(t.layer.id)===this.scope&&c.push(t);return c}queryRenderedFeatureset(t,i,r){let n;i&&!Array.isArray(i)&&i.filter&&(this._validate(Se,"queryRenderedFeatures.filter",i.filter,null,i),n=e.b5(i.filter));const o="mock",s=[];if(i&&i.target)s.push(Object.assign({},i,{targetId:o,filter:n}));else{const e=this.getFeaturesetDescriptors();for(const t of e)s.push({targetId:o,filter:n,target:t});for(const{style:e}of this.fragments){const t=e.getFeaturesetDescriptors();for(const e of t)s.push({targetId:o,filter:n,target:e})}}const a=this.queryRenderedTargets(t,s,r),l=[],c=new Set;for(const t of a)for(const i of t.variants[o])mt(i,t,c)||l.push(new e.dw(t,i));return l}queryRenderedTargets(t,i,r){const n={},o=(e,t,i,r)=>{const o=n[t.id]=n[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),!r)return i.uniqueFeatureID=!1,void o.layers[e.fqid].targets.push(i);o.layers[e.fqid].targets.push(Object.assign({},i,{namespace:r.namespace,properties:r.properties,uniqueFeatureID:r.uniqueFeatureID}))};for(const t of i)if("featuresetId"in t.target){const{featuresetId:i,importId:r}=t.target,n=this.getFragmentStyle(r);if(!n||!n._featuresetSelectors)continue;const s=n._featuresetSelectors[i];if(!s){this.fire(new e.y(new Error(`The featureset '${i}' does not exist in the map's style and cannot be queried for features.`)));continue}for(const e of s){const i=n.getOwnLayer(e.layerId);i&&!Er.has(i.type)&&o(i,n.getOwnLayerSourceCache(i),t,e)}}else if("layerId"in t.target){const{layerId:e}=t.target,i=this.getLayer(e);if(!i||Er.has(i.type))continue;o(i,this.getLayerSourceCache(i),t)}const s=this._queryRenderedFeatures(t,n,r);return this._flattenAndSortRenderedFeatures(s)}_queryRenderedFeatures(e,t,i){const r=[],n=!!this.map._showQueryGeometry,o=tt.createFromScreenPoints(e,i);for(const e in t){const s=gt(o,t[e],this._availableImages,i,n);Object.keys(s).length&&r.push(s)}if(this.placement)for(const e in t){if(!t[e].sourceCache._onlySymbols)continue;const i=_t(o.screenGeometry,t[e],this._availableImages,this.placement.collisionIndex,this.placement.retainedQueryData,this.map.getWorldview());Object.keys(i).length&&r.push(i)}return r}querySourceFeatures(e,t){const i=t&&t.filter;i&&this._validate(Se,"querySourceFeatures.filter",i,null,t);let r=[];const n=this.getOwnSourceCaches(e);for(const e of n)r=r.concat(At(e,t));return r}addSourceType(e,t,i){return Sr.getSourceType(e)?i(new Error(`A source type called "${e}" already exists.`)):(Sr.setSourceType(e,t),t.workerSourceURL?void this.dispatcher.broadcast("loadWorkerSource",{name:e,url:t.workerSourceURL},i):i(null,null))}getFlatLight(){return this.light.getLight()}setFlatLight(t,i,r={}){this._checkLoaded();const n=this.light.getLight();let o=!1;for(const i in t)if(!e.bx(t[i],n[i])){o=!0;break}if(!o)return;const s=this._getTransitionParameters();this.light.setLight(t,i,r),this.light.updateTransitions(s)}getTerrain(){return this.terrain&&1===this.terrain.drapeRenderMode?this.terrain.get():null}setTerrainForDraping(){this.setTerrain({source:"",exaggeration:0},0)}checkCanvasFingerprintNoise(){void 0===this.disableElevatedTerrain&&(this.disableElevatedTerrain=e.o.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 r=t;const n=null==t.source;if(1===i){if(this.disableElevatedTerrain)return;if("object"==typeof r.source){const t="terrain-dem-src";this.addSource(t,r.source),r=e.dn(r),r=Object.assign(r,{source:t})}const t=Object.assign({},r),i={};if(this.terrain&&n){t.source=this.terrain.get().source;const e=this.terrain?this.getFragmentStyle(this.terrain.scope):null;e&&(i.style=e.serialize())}if(this._validate(we,"terrain",t,i))return}if(!this.terrain||this.terrain.scope!==this.scope&&!n||this.terrain&&i!==this.terrain.drapeRenderMode){if(!r)return;this._createTerrain(r,i),this.fire(new e.z("data",{dataType:"style"}))}else{const i=this.terrain,n=i.get();for(const t of Object.keys(e.a6.terrain))!r.hasOwnProperty(t)&&e.a6.terrain[t].default&&(r[t]=e.a6.terrain[t].default);for(const r in t)if(!e.bx(t[r],n[r])){i.set(t,this.options),this.stylesheet.terrain=t;const r=this._getTransitionParameters({duration:0});i.updateTransitions(r),this.fire(new e.z("data",{dataType:"style"}));break}}this.mergeTerrain(),this.updateDrapeFirstLayers(),this._markersNeedUpdate=!0}_createFog(e){const t=this.fog=new Ze(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 Je(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 Ye(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)return delete this.fog,delete this.stylesheet.fog,void(this._markersNeedUpdate=!0);if(this.fog){const i=this.fog;if(!e.bx(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);this._markersNeedUpdate=!0}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.bx(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.bx(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 r=this._evaluateColorThemeData(i);this._loadColorTheme(r).then(()=>{this.fire(new e.z("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.o.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 ze(e,t,this.scope,this.options,this.map.getWorldview());1===t&&(this.stylesheet.terrain=e),this.mergeTerrain(),this.updateDrapeFirstLayers(),this._force3DLayerUpdate();const r=this._getTransitionParameters({duration:0});i.updateTransitions(r)}_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,r,n,o={}){if(o&&!1===o.validate)return!1;const s=Object.assign({},this.serialize());return br(this,t.call(ye,Object.assign({key:i,style:s,value:r,styleSpec:e.a6},n)))}_remove(){this._request&&(this._request.cancel(),this._request=null),this._spriteRequest&&(this._spriteRequest.cancel(),this._spriteRequest=null),e.dx.off("pluginStateChange",this._rtlTextPluginCallback);for(const e in this._mergedLayers)this._mergedLayers[e].setEventedParent(null);for(const e in this._mergedSourceCaches)this._mergedSourceCaches[e].clearTiles(),this._mergedSourceCaches[e].setEventedParent(null);this.imageManager.removeScope(this.scope),this.setEventedParent(null),delete this.fog,delete this.snow,delete this.rain,delete this.terrain,delete this.ambientLight,delete this.directionalLight,this.isRootStyle()&&(this.imageManager.setEventedParent(null),this.imageManager.destroy(),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(e){let t;this.directionalLight&&(t=pr(this.directionalLight));const i=new Set;for(const e in this._mergedLayers){const t=this._mergedLayers[e];t.hasElevation()&&!i.has(t.source)&&i.add(t.source)}for(const r in this._mergedSourceCaches){const n=this._mergedSourceCaches[r],o=i.has(n._source.id);n.update(e,void 0,void 0,t,o)}}_generateCollisionBoxes(){for(const e in this._sourceCaches){const t=this._sourceCaches[e];t.resume(),t.reload()}}_updatePlacement(t,i,r,n,o,s,a=!1){let l=!1,c=!1;const u={},h={};for(const t of this._mergedOrder){const r=this._mergedLayers[t];if("symbol"!==r.type)continue;const n=e.B(r.source,r.scope);let o=u[n];if(!o){const e=this.getLayerSourceCache(r);if(!e)continue;const t=e.getRenderableIds(!0).map(t=>e.getTileByID(t));h[n]=t.slice(),o=u[n]=t.sort((e,t)=>t.tileID.overscaledZ-e.tileID.overscaledZ||(e.tileID.isLessThan(t.tileID)?-1:1))}const s=this.crossTileSymbolIndex.addLayer(r,o,i.center.lng,i.projection);l=l||s}if(this.crossTileSymbolIndex.pruneUnusedLayers(this._mergedOrder),a=a||this._layerOrderChanged||0===n,this._layerOrderChanged&&this.fire(new e.z("neworder")),(a||!this.pauseablePlacement||this.pauseablePlacement.isDone()&&!this.placement.stillRecent(e.o.now(),i.zoom))&&(this.pauseablePlacement=new zi(i,this._mergedOrder,a,r,n,o,this.placement,this.fog&&i.projection.supportsFog?this.fog.state:null,this._buildingIndex),this._layerOrderChanged=!1),this.pauseablePlacement.isDone()?this.placement.setStale():(this.pauseablePlacement.continuePlacement(this._mergedOrder,this._mergedLayers,u,h,this.map.painter.scaleFactor),this.pauseablePlacement.isDone()&&(this.placement=this.pauseablePlacement.commit(e.o.now()),c=!0),l&&this.pauseablePlacement.placement.setStale()),c||l){this._buildingIndex.onNewFrame(i.zoom);for(let t=0;te===t.id))return void this.fire(new e.y(new Error(`Import with id '${t.id}' already exists in the map's style.`)));if(!i)return r.push(t),this._loadImports([t],!0);const n=r.findIndex(({id:e})=>e===i);return-1===n&&this.fire(new e.y(new Error(`Import with id "${i}" does not exist on this map.`))),this.stylesheet.imports=r.slice(0,n).concat(t).concat(r.slice(n)),this._loadImports([t],!0,i)}updateImport(t,i){this._checkLoaded();const r=this.stylesheet.imports||[],n=this.getImportIndex(t);return-1===n?this:"string"==typeof i?(this.setImportUrl(t,i),this):(i.url&&i.url!==r[n].url&&this.setImportUrl(t,i.url),e.bx(i.config,r[n].config)||this.setImportConfig(t,i.config,i.data.schema),e.bx(i.data,r[n].data)||this.setImportData(t,i.data),this)}moveImport(e,t){this._checkLoaded();let i=this.stylesheet.imports||[];const r=this.getImportIndex(e);if(-1===r)return this;const n=this.getImportIndex(t);if(-1===n)return this;const o=i[r],s=this.fragments[r];return i=i.filter(({id:t})=>t!==e),this.fragments=this.fragments.filter(({id:t})=>t!==e),this.stylesheet.imports=i.slice(0,n).concat(o).concat(i.slice(n)),this.fragments=this.fragments.slice(0,n).concat(s).concat(this.fragments.slice(n)),this.mergeLayers(),this}setImportUrl(e,t){this._checkLoaded();const i=this.stylesheet.imports||[],r=this.getImportIndex(e);if(-1===r)return this;i[r].url=t;const n=this.fragments[r];return n.style=this._createFragmentStyle(i[r]),n.style.on("style.import.load",()=>this.mergeAll()),n.style.loadURL(t),this}setImportData(e,t){this._checkLoaded();const i=this.getImportIndex(e),r=this.stylesheet.imports||[];return-1===i?this:t?(this.fragments[i].style.setState(t),this._reloadImports(),this):(delete r[i].data,this.setImportUrl(e,r[i].url))}setImportConfig(e,t,i){this._checkLoaded();const r=this.getImportIndex(e),n=this.stylesheet.imports||[];if(-1===r)return this;t?n[r].config=t:delete n[r].config;const o=this.fragments[r];i&&o.style.stylesheet&&(o.style.stylesheet.schema=i);const s=o.style.stylesheet&&o.style.stylesheet.schema;return o.config=t,o.style.updateConfig(t,s),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.y(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 r=e.B(t,i);return this._mergedOtherSourceCaches[r]}getLayerSourceCache(t){const i=e.B(t.source,t.scope);return"symbol"===t.type?this._mergedSymbolSourceCaches[i]:this._mergedOtherSourceCaches[i]}getSourceCaches(e){if(null==e)return Object.values(this._mergedSourceCaches);const t=[];return this._mergedOtherSourceCaches[e]&&t.push(this._mergedOtherSourceCaches[e]),this._mergedSymbolSourceCaches[e]&&t.push(this._mergedSymbolSourceCaches[e]),t}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)}getImages(t,i,r){this.imageManager.getImages(i.images,i.scope,r),this._updateTilesForChangedImages();const n=t=>{if(t){const r=i.images.map(t=>e.I.toString(t));t.setDependencies(i.tileID.key,i.type,r)}},o=e.B(i.source,i.scope);n(this._mergedOtherSourceCaches[o]),n(this._mergedSymbolSourceCaches[o]),i.images.some(e=>e.iconsetId)&&this.fire(new e.z("data",{dataType:"style"}))}rasterizeImages(e,t,i){this.imageManager.rasterizeImages(t,i)}getGlyphs(e,t,i){this.glyphManager.getGlyphs(t.stacks,i)}getResource(t,i,r){return e.dy(i,r)}getOwnSourceCache(e){return this._otherSourceCaches[e]}getOwnLayerSourceCache(e){return"symbol"===e.type?this._symbolSourceCaches[e.source]:this._otherSourceCaches[e.source]}getOwnSourceCaches(e){const t=[];return this._otherSourceCaches[e]&&t.push(this._otherSourceCaches[e]),this._symbolSourceCaches[e]&&t.push(this._symbolSourceCaches[e]),t}_isSourceCacheLoaded(t){const i=this.getOwnSourceCaches(t);return 0===i.length?(this.fire(new e.y(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),r="building"===e.type;if(e.is3D(!!this.terrain)){if(i||r||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")}destroy(){this._clearWorkerCaches(),this.fragments.forEach(e=>{e.style._remove()}),this.terrainSetForDrapingOnly()&&(delete this.terrain,delete this.stylesheet.terrain)}}Sr.getSourceType=function(e){return dt[e]},Sr.setSourceType=function(e,t){dt[e]=t},Sr.registerForPluginStateChange=e.dz;class Ir extends e.E{constructor(t){super(),this._style=t,this._buildings={},this._activeFloors=new Set,this._activeFloorsVisible=!0,this._indoorState={selectedFloorId:null,lastActiveFloors:null,activeFloorsVisible:!0},e.aX(["_updateUI"],this)}destroy(){this._buildings={},this._activeFloors=new Set,this._indoorState=null}selectFloor(e){e===this._selectedFloorId&&this._activeFloorsVisible||(this._selectedFloorId=e,this._activeFloorsVisible=!0,this._updateActiveFloors())}setActiveFloorsVisibility(e){this._activeFloorsVisible=e,this._updateActiveFloors(),this._updateIndoorSelector()}setIndoorData(e){for(const[t,i]of Object.entries(e.buildings))if(this._buildings[t])for(const e of i.floorIds)this._buildings[t].floors[e]||(this._buildings[t].floors[e]=i.floors[e]);else this._buildings[t]=i;for(const t of e.activeFloors)this._activeFloors.add(t);this._updateIndoorSelector()}getIndoorTileOptions(e,t){const i=this._style.getIndoorSourceLayers(e,t);return i&&this._indoorState?{sourceLayers:i,indoorState:this._indoorState}:null}_updateUI(t,i,r){const n=function(t,i,r,n){let o=null,s=Number.MAX_SAFE_INTEGER;if(n<16)return null;for(const[n,a]of Object.entries(t)){const t=a.center;if(t){const a=i.distanceTo(e.aS.convert(t));a({id:e,name:r.floors[e].name,zIndex:r.floors[e].zIndex})).sort((e,t)=>t.zIndex-e.zIndex);this.fire(new e.z("selector-update",{selectedFloorId:n,activeFloorsVisible:this._activeFloorsVisible,floors:o}))}_updateActiveFloors(){const e=this._activeFloors;this._activeFloors=new Set,this._indoorState={selectedFloorId:this._selectedFloorId,lastActiveFloors:e,activeFloorsVisible:this._activeFloorsVisible},this._style.updateIndoorDependentLayers()}}var Mr="\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",Pr="\nout vec4 glFragColor;highp 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) {highp float depth=ndc_z*0.5+0.5;const 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;}\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}\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 applyLUT(highp sampler3D lut,vec4 col) {vec3 size=vec3(textureSize(lut,0));vec3 uvw=(col.rbg*float(size-1.0)+0.5)/size;return vec4(texture(lut,uvw).rgb*col.a,col.a);}vec3 applyLUT(highp sampler3D lut,vec3 col) {return applyLUT(lut,vec4(col,1.0)).rgb;}",Rr="\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);}vec2 unpack_opacity(const float packedOpacity) {int intOpacity=int(packedOpacity)/2;return vec2(float(intOpacity)/127.0,mod(packedOpacity,2.0));}vec4 decode_color(const vec2 encodedColor) {return vec4(\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(vec2 posWithComposedSkirt)\n{float skirt=float(posWithComposedSkirt.x >=skirtOffset);vec2 pos=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",Lr="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;}",Fr="\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;vec3 elevationVector(vec2 pos) {vec2 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\nvec3 elevationVector(vec2 pos) { return vec3(0,0,1); }\n#endif\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}\n#ifdef TERRAIN_VERTEX_MORPHING\nfloat elevation(vec2 apos) {\n#ifdef ZERO_EXAGGERATION\nreturn 0.0;\n#endif\nfloat nextElevation=currentElevation(apos);float prevElevation=prevElevation(apos);return mix(prevElevation,nextElevation,u_dem_lerp);}\n#else\nfloat elevation(vec2 apos) {\n#ifdef ZERO_EXAGGERATION\nreturn 0.0;\n#endif\nreturn currentElevation(apos);}\n#endif\nvec4 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#else\nfloat elevation(vec2 pos) { return 0.0; }\n#endif\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//DEPTH_OCCLUSION",kr="#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",Dr="#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;\n#ifdef FLIP_Y\nuv.y=1.0-uv.y;\n#endif\nhighp 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",Or="#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",zr="#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;}",Ur="#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//RENDER_SHADOWS",Nr="#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;float shadow_sample(sampler2DShadow shadowmap,highp vec3 pos,highp float bias) {\n#ifdef CLIP_ZERO_TO_ONE\nhighp vec3 coord=vec3(pos.xy*0.5+0.5,pos.z-bias);\n#else\nhighp vec3 coord=vec3(pos.xy*0.5+0.5,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=light_view_pos0.xyz/light_view_pos0.w*0.5+0.5;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 Vr=[];Zr(Mr,Vr),Zr(Rr,Vr),Zr(Pr,Vr);const jr={"_prelude_fog.vertex.glsl":kr,"_prelude_terrain.vertex.glsl":Fr,"_prelude_shadow.vertex.glsl":Ur,"_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":Dr,"_prelude_shadow.fragment.glsl":Nr,"_prelude_lighting.glsl":"\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//LIGHTING_3D_MODE","_prelude_raster_array.glsl":Or,"_prelude_raster_particle.glsl":zr},Gr={};Wr("",Fr),Wr(Dr,kr),Wr(Nr,Ur),Wr(Or,""),Wr(zr,"");const Hr=Wr(Pr,Rr),Qr=Mr;var $r={background:Wr('#include "_prelude_fog.fragment.glsl"\n#include "_prelude_lighting.glsl"\nuniform vec4 u_color;uniform float u_opacity;\n#ifdef LIGHTING_3D_MODE\nin vec4 v_color;\n#endif\nvoid main() {vec4 out_color;\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\nglFragColor=out_color*u_opacity;\n#ifdef OVERDRAW_INSPECTOR\nglFragColor=vec4(1.0);\n#endif\nHANDLE_WIREFRAME_DEBUG;}','#include "_prelude_fog.vertex.glsl"\n#include "_prelude_lighting.glsl"\nin vec2 a_pos;uniform mat4 u_matrix;\n#ifdef LIGHTING_3D_MODE\nuniform mediump vec4 u_color;out vec4 v_color;uniform float u_emissive_strength;\n#endif\nvoid main() {gl_Position=u_matrix*vec4(a_pos,0,1);\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(a_pos);\n#endif\n}'),backgroundPattern:Wr('#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 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 vec2 a_pos;out highp vec2 v_pos;void main() {gl_Position=u_matrix*vec4(a_pos,0,1);v_pos=get_pattern_pos(u_pixel_coord_upper,u_pixel_coord_lower,u_pattern_size,u_pattern_units_to_pixels,a_pos);\n#ifdef FOG\nv_fog_pos=fog_position(a_pos);\n#endif\n}'),building:Wr('#include "_prelude_fog.fragment.glsl"\n#include "_prelude_shadow.fragment.glsl"\n#include "_prelude_lighting.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 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;in float v_depth_shadows;\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\nfloat hash12(in vec2 p) {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);}vec2 get_uv_mask_id(in vec2 q,out float mask,out vec2 id) {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;vec2 uv=modf(p/v_faux_facade_floor,id);vec4 d=(v_faux_facade_floor.xyxy+vec4(-v_faux_facade_window,v_faux_facade_window))*0.5;vec4 edge=d/v_faux_facade_floor.xyxy;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;}float ray_unit_box(in vec3 ray_o,in vec3 ray_d,in vec3 bmin,in vec3 bmax) {vec3 planes=mix(bmin,bmax,step(0.0,ray_d));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 vec3 v,in vec3 v_normalized,in vec3 color,in vec2 id,in mat3 tbn,inout vec3 out_normal,inout float out_emissive) {vec3 out_color=color;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) {mat3 tbn=mat3(v_tbn_0,v_tbn_1,v_tbn_2);vec3 v=vec3(v_pos.xy,v_pos.z/u_tile_to_meter)-u_camera_pos;vec3 view_tangent=transpose(tbn)*v;vec2 q=vec2(v_faux_facade_ed,v_pos.z);float mask=0.0;vec2 id=vec2(0.0);vec2 uv=get_uv_mask_id(q,mask,id);uv*=v_faux_facade_window;vec3 bmin=vec3(0.0,0.0,-window_depth);vec3 bmax=bmin+vec3(v_faux_facade_window,window_depth);vec3 ray_o=vec3(uv,0.0);vec3 ray_d=normalize(view_tangent);float t_min=ray_unit_box(ray_o,ray_d,bmin,bmax);vec3 hit=ray_o+t_min*ray_d;vec3 r=vec3(v_faux_facade_window,-window_depth);hit-=r*0.5;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\nshadowed_lighting_factor=shadowed_light_factor_normal(xy_flipped_normal,v_pos_light_view_0,v_pos_light_view_1,v_depth_shadows);\n#else\nshadowed_lighting_factor=dot(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\ncolor=applyCutout(color,v_pos.z);\n#endif\n#ifdef FEATURE_CUTOUT\ncolor=apply_feature_cutout(color,gl_FragCoord);\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 vec3 a_normal_3;in vec3 a_centroid_3;in float a_flood_light_wall_radius_1i16;in vec4 a_faux_facade_data;in vec2 a_faux_facade_vertical_range;uniform mat4 u_matrix;uniform mat4 u_normal_matrix;uniform highp float u_tile_to_meter;out 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;out float v_depth_shadows;\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 vec2 part_color_emissive\n#pragma mapbox: define-attribute-vertex-shader-only highp vec2 faux_facade_color_emissive\nvoid main() {\n#pragma mapbox: initialize-attribute-custom highp vec2 part_color_emissive\n#pragma mapbox: initialize-attribute-custom highp vec2 faux_facade_color_emissive\n#ifdef FLOOD_LIGHT\nv_flood_radius=(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(part_color_emissive);v_color=vec4(sRGBToLinear(color_emissive.rgb),color_emissive.a);vec3 a_normal_3f=a_normal_3/MAX_INT_16;v_normal=vec3(u_normal_matrix*vec4(a_normal_3f,0.0));float hidden=0.0;\n#ifdef BUILDING_FAUX_FACADE\nv_faux_facade=a_faux_facade_data.x;if (v_faux_facade > 0.0) {v_faux_facade_ed=a_faux_facade_data.x *u_tile_to_meter;float window_x_perc=floor(a_faux_facade_data.y/TWO_POW_8);float window_y_perc=a_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=(a_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=(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(faux_facade_color_emissive);v_faux_color_emissive.rgb=sRGBToLinear(v_faux_color_emissive.rgb);}\n#endif\nv_pos=a_pos_3f;\n#ifdef RENDER_CUTOFF\nvec4 ground=u_matrix*vec4(a_centroid_3,1.0);v_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);v_depth_shadows=gl_Position.w;\n#endif\n#ifdef FOG\nv_fog_pos=fog_position(v_pos);\n#endif\ngl_Position=mix(u_matrix*vec4(v_pos,1),AWAY,hidden);}'),buildingBloom:Wr("in vec4 v_color_emissive;\n#pragma mapbox: define-attribute highp vec4 bloom_attenuation\n#pragma mapbox: initialize-attribute highp vec4 bloom_attenuation\nfloat saturate(float val) {return clamp(val,0.0,1.0);}void main() {float 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\nglFragColor=vec4(v_color_emissive.rgb,1.0)*opacity;}","in vec3 a_pos_3f;\n#pragma mapbox: define-attribute-vertex-shader-only highp vec2 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 vec2 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(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);}"),buildingDepth:Wr("in highp float v_depth;void main() {\n#ifndef DEPTH_TEXTURE\nglFragColor=pack_depth(v_depth);\n#endif\n}","in vec3 a_pos_3f;uniform mat4 u_matrix;out highp float v_depth;void main() {gl_Position=u_matrix*vec4(a_pos_3f,1.0);v_depth=gl_Position.z/gl_Position.w;}"),circle:Wr('#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 vec2 a_pos;\n#ifdef PROJECTION_GLOBE_VIEW\nin vec3 a_pos_3;in vec3 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,-1),radius,stroke_width,view_scale);vec2 c2=pos+calc_offset(vec2(1,-1),radius,stroke_width,view_scale);vec2 c3=pos+calc_offset(vec2(1,1),radius,stroke_width,view_scale);vec2 c4=pos+calc_offset(vec2(-1,1),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 extrude=vec2(mod(a_pos,2.0)*2.0-1.0);vec2 circle_center=floor(a_pos*0.5);vec4 world_center;mat3 surface_vectors;\n#ifdef PROJECTION_GLOBE_VIEW\nvec3 pos_normal_3=a_pos_normal_3/16384.0;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(circle_center)*circle_elevation(circle_center);vec3 globe_pos=a_pos_3+surface_extrusion+globe_elevation;vec3 mercator_elevation=u_up_dir*u_tile_up_scale*circle_elevation(circle_center);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);float height=circle_elevation(circle_center);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:Wr("void main() {glFragColor=vec4(1.0);}","in vec2 a_pos;uniform mat4 u_matrix;void main() {gl_Position=u_matrix*vec4(a_pos,0,1);}"),heatmap:Wr('#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_opacity;uniform float u_intensity;in vec2 a_pos;\n#ifdef PROJECTION_GLOBE_VIEW\nin vec3 a_pos_3;in vec3 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(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(a_pos*0.5);vec3 pos;\n#ifdef PROJECTION_GLOBE_VIEW\nvec3 pos_normal_3=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=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:Wr("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 vec2 a_pos;out vec2 v_pos;void main() {gl_Position=vec4(a_pos,0,1);v_pos=a_pos*0.5+0.5;}"),collisionBox:Wr("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 vec3 a_pos;in vec2 a_anchor_pos;in vec2 a_extrude;in vec2 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() {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(a_anchor_pos));vec3 proj_pos=a_pos+elevationVector(a_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,a_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+=(a_extrude*a_size_scale+a_shift+a_padding)*u_extrude_scale*gl_Position.w*collision_perspective_ratio;v_placed=a_placed.x;v_notUsed=a_placed.y;}'),collisionCircle:Wr("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 vec2 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;float collision=a_flags.x;float vertexIdx=a_flags.y;vec2 quadVertexOffset=vec2(\nmix(-1.0,1.0,float(vertexIdx >=2.0)),mix(-1.0,1.0,float(vertexIdx >=1.0 && vertexIdx <=2.0)));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=collision;gl_Position=vec4(clipPos.xyz/clipPos.w,1.0)+vec4(quadVertexExtent*padding_factor/u_viewport_size*2.0,0.0,0.0);}"),debug:Wr("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 vec2 a_pos;\n#ifdef PROJECTION_GLOBE_VIEW\nin vec3 a_pos_3;\n#endif\nout vec2 v_uv;uniform mat4 u_matrix;uniform float u_overlay_scale;void main() {float h=elevation(a_pos);v_uv=a_pos/8192.0;\n#ifdef PROJECTION_GLOBE_VIEW\ngl_Position=u_matrix*vec4(a_pos_3+elevationVector(a_pos)*h,1);\n#else\ngl_Position=u_matrix*vec4(a_pos*u_overlay_scale,h,1);\n#endif\n}'),elevatedStructuresDepth:Wr("void main() {\n#ifndef DEPTH_TEXTURE\nglFragColor=vec4(0.);\n#endif\n}","in vec2 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;}"),elevatedStructuresDepthReconstruct:Wr("#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);\n#endif\n#endif\nglFragColor=vec4(1.0,0.0,0.0,1.0);}","in vec2 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;}"),elevatedStructures:Wr('#include "_prelude_fog.fragment.glsl"\n#include "_prelude_lighting.glsl"\n#include "_prelude_shadow.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;\n#pragma mapbox: define highp vec4 structure_color\nvoid main() {\n#pragma mapbox: initialize highp vec4 structure_color\nvec3 color=structure_color.xyz;\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 shadowed_lighting_factor=shadowed_light_factor_normal(transformed_normal,v_pos_light_view_0,v_pos_light_view_1,v_depth);color.rgb=apply_lighting(color.rgb,transformed_normal,shadowed_lighting_factor);\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);\n#endif\nglFragColor=out_color;HANDLE_WIREFRAME_DEBUG;}','#include "_prelude_fog.vertex.glsl"\n#include "_prelude_shadow.vertex.glsl"\nin vec2 a_pos;in float a_height;in vec3 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=a_pos_normal_3/16384.0;v_height=a_height;vec3 pos=vec3(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(a_pos);\n#endif\n}'),fill:Wr('#include "_prelude_fog.fragment.glsl"\n#include "_prelude_lighting.glsl"\n#include "_prelude_shadow.fragment.glsl"\n#pragma mapbox: define highp vec4 color\n#pragma mapbox: define lowp float opacity\nuniform float u_emissive_strength;\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\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);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;\n#ifdef INDICATOR_CUTOUT\nif (v_z_offset >=0.0) {out_color=applyCutout(out_color,v_z_offset);}\n#endif\n#ifdef FEATURE_CUTOUT\nout_color=apply_feature_cutout(out_color,gl_FragCoord);\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_shadow.vertex.glsl"\nin vec2 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;\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(a_pos);\n#endif\n#ifdef INDICATOR_CUTOUT\nv_z_offset=z_offset;\n#endif\n}'),fillOutline:Wr('#include "_prelude_fog.fragment.glsl"\n#include "_prelude_lighting.glsl"\n#include "_prelude_shadow.fragment.glsl"\nin highp vec2 v_pos;uniform float u_emissive_strength;\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;\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);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\nout_color=apply_feature_cutout(out_color,gl_FragCoord);\n#endif\nglFragColor=out_color*(alpha*opacity);\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 vec2 a_pos;\n#ifdef ELEVATED_ROADS\nin float a_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;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;\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(a_pos);\n#endif\n}'),fillOutlinePattern:Wr('#include "_prelude_fog.fragment.glsl"\n#include "_prelude_lighting.glsl"\n#include "_prelude_shadow.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;\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\nin highp vec2 v_pos;in highp vec2 v_pos_world;\n#pragma mapbox: define lowp float opacity\n#pragma mapbox: define lowp vec4 pattern\n#ifdef FILL_PATTERN_TRANSITION\n#pragma mapbox: define mediump vec4 pattern_b\n#endif\nvoid main() {\n#pragma mapbox: initialize lowp float opacity\n#pragma mapbox: initialize mediump vec4 pattern\n#ifdef FILL_PATTERN_TRANSITION\n#pragma mapbox: initialize mediump vec4 pattern_b\n#endif\nvec2 pattern_tl=pattern.xy;vec2 pattern_br=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=pattern_b.xy;vec2 pattern_b_br=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_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);out_color.rgb*=mix(u_ground_shadow_factor,vec3(1.0),light);\n#endif\n#endif\n#ifdef FEATURE_CUTOUT\nout_color=apply_feature_cutout(out_color,gl_FragCoord);\n#endif\n#ifdef FOG\nout_color=fog_dither(fog_apply_premultiplied(out_color,v_fog_pos));\n#endif\nglFragColor=out_color*(alpha*opacity);\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 vec2 u_pixel_coord_upper;uniform vec2 u_pixel_coord_lower;uniform float u_tile_units_to_pixels;in vec2 a_pos;\n#ifdef ELEVATED_ROADS\nin float a_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 vec4 pattern\n#ifdef FILL_PATTERN_TRANSITION\n#pragma mapbox: define mediump vec4 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 vec4 pattern\n#ifdef FILL_PATTERN_TRANSITION\n#pragma mapbox: initialize mediump vec4 pattern_b\n#endif\n#pragma mapbox: initialize lowp float pixel_ratio\n#pragma mapbox: initialize highp float z_offset\nvec2 pattern_tl=pattern.xy;vec2 pattern_br=pattern.zw;\n#ifdef ELEVATED_ROADS\nz_offset+=a_road_z_offset;\n#endif\nfloat hidden=float(opacity==0.0);gl_Position=mix(u_matrix*vec4(a_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,a_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(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(a_pos);\n#endif\n}'),fillPattern:Wr('#include "_prelude_fog.fragment.glsl"\n#include "_prelude_lighting.glsl"\n#include "_prelude_shadow.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;\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 vec4 pattern\n#ifdef FILL_PATTERN_TRANSITION\n#pragma mapbox: define mediump vec4 pattern_b\n#endif\nvoid main() {\n#pragma mapbox: initialize lowp float opacity\n#pragma mapbox: initialize mediump vec4 pattern\n#ifdef FILL_PATTERN_TRANSITION\n#pragma mapbox: initialize mediump vec4 pattern_b\n#endif\nvec2 pattern_tl=pattern.xy;vec2 pattern_br=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=pattern_b.xy;vec2 pattern_b_br=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_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);\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\nout_color=apply_feature_cutout(out_color,gl_FragCoord);\n#endif\n#ifdef FOG\nout_color=fog_dither(fog_apply_premultiplied(out_color,v_fog_pos));\n#endif\nglFragColor=out_color*opacity;\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_pixel_coord_upper;uniform vec2 u_pixel_coord_lower;uniform float u_tile_units_to_pixels;in vec2 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 vec4 pattern\n#ifdef FILL_PATTERN_TRANSITION\n#pragma mapbox: define mediump vec4 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 vec4 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 vec4 pattern_b\n#endif\nvec2 pattern_tl=pattern.xy;vec2 pattern_br=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);gl_Position=mix(u_matrix*vec4(a_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,a_pos);\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(a_pos);\n#endif\n}'),fillExtrusion:Wr('#include "_prelude_fog.fragment.glsl"\n#include "_prelude_shadow.fragment.glsl"\n#include "_prelude_lighting.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 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\ncolor=applyCutout(color,h);\n#endif\n#ifdef FEATURE_CUTOUT\ncolor=apply_feature_cutout(color,gl_FragCoord);\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;uniform vec3 u_lightcolor;uniform lowp vec3 u_lightpos;uniform lowp float u_lightintensity;uniform float u_vertical_gradient;uniform lowp float u_opacity;uniform float u_edge_radius;uniform float u_width_scale;in vec4 a_pos_normal_ed;in vec2 a_centroid_pos;\n#ifdef RENDER_WALL_MODE\nin vec3 a_join_normal_inside;\n#endif\n#ifdef PROJECTION_GLOBE_VIEW\nin vec3 a_pos_3;in vec3 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;out 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;vec3 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 pos_nx=floor(a_pos_normal_ed*0.5);vec4 top_up_ny_start=a_pos_normal_ed-2.0*pos_nx;vec3 top_up_ny=top_up_ny_start.xyz;float x_normal=pos_nx.z/8192.0;vec3 normal=top_up_ny.y==1.0 ? vec3(0.0,0.0,1.0) : normalize(vec3(x_normal,(2.0*top_up_ny.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.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=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);c_ele=is_flat_height || is_flat_base ? (centroid_pos.y==0.0 ? 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;pos=vec3(pos_nx.xy,h);\n#else\nh=t > 0.0 ? height : base;pos=vec3(pos_nx.xy,h);\n#endif\n#ifdef PROJECTION_GLOBE_VIEW\nfloat lift=float((t+base) > 0.0)*u_height_lift;h+=lift;vec3 globe_normal=normalize(mix(a_pos_normal_3/16384.0,u_up_dir,u_zoom_transition));vec3 globe_pos=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#ifdef RENDER_CUTOFF\nvec3 centroid_random=vec3(centroid_pos.xy,centroid_pos.x+centroid_pos.y+1.0);vec3 ground_pos=centroid_pos.x==0.0 ? pos.xyz : (centroid_random/8.0);vec4 ground=u_matrix*vec4(ground_pos.xy,ele,1.0);\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 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_WALL_MODE\nvec2 wall_offset=u_width_scale*line_width*(a_join_normal_inside.xy/EXTENT);scaled_pos.xy+=(1.0-a_join_normal_inside.z)*wall_offset*0.5;scaled_pos.xy-=a_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.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.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}'),fillExtrusionDepth:Wr("in highp float v_depth;void main() {\n#ifndef DEPTH_TEXTURE\nglFragColor=pack_depth(v_depth);\n#endif\n}",'#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 vec4 a_pos_normal_ed;in vec2 a_centroid_pos;\n#ifdef RENDER_WALL_MODE\nin vec3 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\nout highp float v_depth;void 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 pos_nx=floor(a_pos_normal_ed.xyz*0.5);mediump vec3 top_up_ny=a_pos_normal_ed.xyz-2.0*pos_nx;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=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);float c_ele=is_flat_height || is_flat_base ? (centroid_pos.y==0.0 ? 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\nvec2 wall_offset=u_width_scale*line_width*(a_join_normal_inside.xy/EXTENT);pos.xy+=(1.0-a_join_normal_inside.z)*wall_offset*0.5;pos.xy-=a_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);v_depth=gl_Position.z/gl_Position.w;}'),fillExtrusionPattern:Wr('#include "_prelude_fog.fragment.glsl"\n#include "_prelude_lighting.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 vec4 pattern\n#ifdef FILL_EXTRUSION_PATTERN_TRANSITION\n#pragma mapbox: define mediump vec4 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 vec4 pattern\n#ifdef FILL_EXTRUSION_PATTERN_TRANSITION\n#pragma mapbox: initialize mediump vec4 pattern_b\n#endif\n#pragma mapbox: initialize highp float pixel_ratio\nvec2 pattern_tl=pattern.xy;vec2 pattern_br=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=pattern_b.xy;vec2 pattern_b_br=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;uniform vec3 u_lightcolor;uniform lowp vec3 u_lightpos;uniform lowp float u_lightintensity;in vec4 a_pos_normal_ed;in vec2 a_centroid_pos;\n#ifdef RENDER_WALL_MODE\nin vec3 a_join_normal_inside;\n#endif\n#ifdef PROJECTION_GLOBE_VIEW\nin vec3 a_pos_3;in vec3 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 vec4 pattern\n#ifdef FILL_EXTRUSION_PATTERN_TRANSITION\n#pragma mapbox: define mediump vec4 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 vec4 pattern\n#ifdef FILL_EXTRUSION_PATTERN_TRANSITION\n#pragma mapbox: initialize mediump vec4 pattern_b\n#endif\n#pragma mapbox: initialize highp float pixel_ratio\n#pragma mapbox: initialize highp float line_width\nvec2 pattern_tl=pattern.xy;vec2 pattern_br=pattern.zw;vec4 pos_nx=floor(a_pos_normal_ed*0.5);mediump vec4 top_up_ny_start=a_pos_normal_ed-2.0*pos_nx;mediump vec3 top_up_ny=top_up_ny_start.xyz;float x_normal=pos_nx.z/8192.0;vec3 normal=top_up_ny.y==1.0 ? vec3(0.0,0.0,1.0) : normalize(vec3(x_normal,(2.0*top_up_ny.z-1.0)*(1.0-abs(x_normal)),0.0));float edgedistance=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.x;float z=t > 0.0 ? height : base;vec2 centroid_pos=vec2(0.0);\n#if defined(HAS_CENTROID) || defined(TERRAIN)\ncentroid_pos=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);c_ele=is_flat_height || is_flat_base ? (centroid_pos.y==0.0 ? 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(a_pos_normal_3/16384.0,u_up_dir,u_zoom_transition));vec3 globe_pos=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\nvec2 wall_offset=u_width_scale*line_width*(a_join_normal_inside.xy/EXTENT);p.xy+=(1.0-a_join_normal_inside.z)*wall_offset*0.5;p.xy-=a_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.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}'),groundShadow:Wr('#include "_prelude_shadow.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\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 vec2 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(a_pos);v_fog_opacity=fog(v_fog_pos);\n#endif\n}'),fillExtrusionGroundEffect:Wr("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\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\nHANDLE_WIREFRAME_DEBUG;\n#endif\n}",'#include "_prelude_fog.vertex.glsl"\nin highp vec4 a_pos_end;in highp float a_angular_offset_factor;in highp float 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\nvec2 p=a_pos_end.xy;vec2 q=floor(a_pos_end.zw*0.5);vec2 start_bottom=a_pos_end.zw-q*2.0;float fl_ground_radius=flood_light_ground_radius;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=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=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}'),hillshadePrepare:Wr("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 vec2 a_pos;in vec2 a_texture_pos;out vec2 v_pos;void main() {gl_Position=u_matrix*vec4(a_pos,0,1);highp vec2 epsilon=1.0/u_dimension;float scale=(u_dimension.x-2.0)/u_dimension.x;v_pos=(a_texture_pos/8192.0)*scale+epsilon;}"),hillshade:Wr('#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 OVERDRAW_INSPECTOR\nglFragColor=vec4(1.0);\n#endif\nHANDLE_WIREFRAME_DEBUG;}','#include "_prelude_fog.vertex.glsl"\nuniform mat4 u_matrix;in vec2 a_pos;in vec2 a_texture_pos;out vec2 v_pos;void main() {gl_Position=u_matrix*vec4(a_pos,0,1);v_pos=a_texture_pos/8192.0;\n#ifdef FOG\nv_fog_pos=fog_position(a_pos);\n#endif\n}'),line:Wr('#include "_prelude_fog.fragment.glsl"\n#include "_prelude_lighting.glsl"\n#include "_prelude_shadow.fragment.glsl"\nuniform lowp float u_device_pixel_ratio;uniform highp float u_width_scale;uniform highp float u_floor_width_scale;uniform float u_alpha_discard_threshold;uniform highp vec2 u_trim_offset;uniform highp vec2 u_trim_fade_range;uniform lowp vec4 u_trim_color;in vec2 v_width2;in vec2 v_normal;in float v_gamma_scale;in highp vec3 v_uv;\n#ifdef ELEVATED_ROADS\nin highp float v_road_z_offset;\n#endif\n#ifdef RENDER_LINE_DASH\nuniform sampler2D u_dash_image;in vec2 v_tex;\n#endif\n#ifdef RENDER_LINE_GRADIENT\nuniform sampler2D u_gradient_image;\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\nfloat luminance(vec3 c) {return (c.r+c.r+c.b+c.g+c.g+c.g)*0.1667;}uniform float u_emissive_strength;\n#pragma mapbox: define highp vec4 color\n#pragma mapbox: define lowp float floorwidth\n#pragma mapbox: define lowp vec4 dash\n#pragma mapbox: define lowp float blur\n#pragma mapbox: define lowp float opacity\n#pragma mapbox: define lowp float border_width\n#pragma mapbox: define lowp vec4 border_color\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 lowp vec4 dash\n#pragma mapbox: initialize lowp float blur\n#pragma mapbox: initialize lowp float opacity\n#pragma mapbox: initialize lowp float border_width\n#pragma mapbox: initialize lowp vec4 border_color\nfloat 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);\n#ifdef RENDER_LINE_DASH\nfloat sdfdist=texture(u_dash_image,v_tex).r;float sdfgamma=1.0/(2.0*u_device_pixel_ratio)/dash.z;float scaled_floorwidth=(floorwidth*u_floor_width_scale);alpha*=linearstep(0.5-sdfgamma/scaled_floorwidth,0.5+sdfgamma/scaled_floorwidth,sdfdist);\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);out_color=mix(out_color,u_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\nfloat edgeBlur=((border_width*u_width_scale)+1.0/u_device_pixel_ratio);float alpha2=clamp(min(dist-(v_width2.t-edgeBlur),v_width2.s-dist)/edgeBlur,0.0,1.0);if (alpha2 < 1.) {float smoothAlpha=smoothstep(0.6,1.0,alpha2);if (border_color.a==0.0) {float 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-smoothAlpha));} else {out_color.rgb*=(0.6 +0.4*smoothAlpha);}} else {out_color=mix(border_color*trim_alpha,out_color,smoothAlpha);}}\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);\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*opacity);\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);\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_shadow.vertex.glsl"\n#include "_prelude_terrain.vertex.glsl"\n#define EXTRUDE_SCALE 0.015873016\nin vec2 a_pos_normal;in vec4 a_data;\n#if defined(ELEVATED) || defined(ELEVATED_ROADS) || defined(VARIABLE_LINE_WIDTH)\nin vec3 a_z_offset_width;\n#endif\n#if defined(RENDER_LINE_GRADIENT) || defined(RENDER_LINE_TRIM_OFFSET)\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 highp 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 float v_gamma_scale;out highp vec3 v_uv;\n#ifdef ELEVATED_ROADS\nout highp float v_road_z_offset;\n#endif\n#ifdef RENDER_LINE_DASH\nuniform vec2 u_texsize;uniform float u_tile_units_to_pixels;out vec2 v_tex;\n#endif\n#ifdef RENDER_LINE_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 lowp vec4 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 lowp float border_width\n#pragma mapbox: define lowp vec4 border_color\nvoid main() {\n#pragma mapbox: initialize highp vec4 color\n#pragma mapbox: initialize lowp float floorwidth\n#pragma mapbox: initialize lowp vec4 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 lowp float border_width\n#pragma mapbox: initialize lowp vec4 border_color\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=a_data.xy-128.0;float a_direction=mod(a_data.z,4.0)-1.0;vec2 pos=floor(a_pos_normal*0.5);mediump vec2 normal=a_pos_normal-2.0*pos;normal.y=normal.y*2.0-1.0;v_normal=normal;gapwidth=gapwidth/2.0;float halfwidth;\n#ifdef VARIABLE_LINE_WIDTH\nfloat left=a_pos_normal.y-2.0*floor(a_pos_normal.y*0.5);halfwidth=(u_width_scale*(left==1.0 ? a_z_offset_width.y : a_z_offset_width.z))/2.0;\n#else\nhalfwidth=(u_width_scale*width)/2.0;\n#endif\noffset=-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);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;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;\n#ifdef CROSS_SLOPE_VERTICAL\nfloat top=a_pos_normal.y-2.0*floor(a_pos_normal.y*0.5);float line_height=2.0*u_tile_to_meter*outset*top*u_pixels_to_tile_units[1][1]+a_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+a_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+a_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 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_TRIM_OFFSET)\nhighp float a_uv_x=a_packed[0];float a_split_index=a_packed[1];highp float line_progress=a_packed[2];\n#ifdef RENDER_LINE_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\nfloat scale=dash.z==0.0 ? 0.0 : u_tile_units_to_pixels/dash.z;float height=dash.y;v_tex=vec2(a_linesofar*scale/(floorwidth*u_floor_width_scale),(-normal.y*height+dash.x+0.5)/u_texsize.y);\n#endif\nv_width2=vec2(outset,inset);\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:Wr('#include "_prelude_fog.fragment.glsl"\n#include "_prelude_lighting.glsl"\n#include "_prelude_shadow.fragment.glsl"\nuniform highp float u_device_pixel_ratio;uniform highp float u_width_scale;uniform highp float u_alpha_discard_threshold;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\nuniform float u_emissive_strength;\n#pragma mapbox: define mediump vec4 pattern\n#ifdef LINE_PATTERN_TRANSITION\n#pragma mapbox: define mediump vec4 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\nvoid main() {\n#pragma mapbox: initialize mediump vec4 pattern\n#ifdef LINE_PATTERN_TRANSITION\n#pragma mapbox: initialize mediump vec4 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\nvec2 pattern_tl=pattern.xy;vec2 pattern_br=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=pattern_b.xy;vec2 pattern_b_br=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,u_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);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 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 vec2 a_pos_normal;in vec4 a_data;\n#if defined(ELEVATED) || defined(ELEVATED_ROADS)\nin vec3 a_z_offset_width;\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 vec4 pattern\n#ifdef LINE_PATTERN_TRANSITION\n#pragma mapbox: define mediump vec4 pattern_b\n#endif\n#pragma mapbox: define mediump float pixel_ratio\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 vec4 pattern\n#ifdef LINE_PATTERN_TRANSITION\n#pragma mapbox: initialize mediump vec4 pattern_b\n#endif\n#pragma mapbox: initialize mediump float pixel_ratio\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=a_data.xy-128.0;float a_direction=mod(a_data.z,4.0)-1.0;vec2 pos=floor(a_pos_normal*0.5);vec2 normal=a_pos_normal-2.0*pos;normal.y=normal.y*2.0-1.0;v_normal=normal;gapwidth=gapwidth/2.0;float halfwidth=(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;\n#ifdef CROSS_SLOPE_VERTICAL\nfloat top=a_pos_normal.y-2.0*floor(a_pos_normal.y*0.5);float line_height=2.0*u_tile_to_meter*outset*top*u_pixels_to_tile_units[1][1]+a_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+a_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+a_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/((pattern.w-pattern.y)*pixel_ratio_inverse);highp float subt_multiple=(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:Wr('#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;\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#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\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 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#define GLOBE_UPSCALE GLOBE_RADIUS/6371008.8\n#ifdef GLOBE_POLES\nin vec3 a_globe_pos;in vec2 a_uv;\n#else\nin vec2 a_pos;in vec2 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;globe_pos+=normalize(globe_pos)*u_raster_elevation*GLOBE_UPSCALE;gl_Position=u_matrix*u_globe_matrix*vec4(globe_pos ,1.0);uv=a_uv;\n#ifdef FOG\nv_fog_pos=fog_position((u_normalize_matrix*vec4(a_globe_pos,1.0)).xyz);\n#endif\n#else\nfloat w=1.0+dot(a_texture_pos,u_perspective_transform);uv=a_texture_pos/8192.0;\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);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);float mercatorY=mercatorYfromLat(latLng[0]);float mercatorX=mercatorXfromLng(latLng[1]); \nv_split_fade=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;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)));}float 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);}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\ngl_Position=u_matrix*vec4(a_pos*w,u_raster_elevation*w,w);\n#ifdef FOG\nv_fog_pos=fog_position(a_pos);\n#endif\n#endif\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 RENDER_CUTOFF\nv_depth=gl_Position.z;\n#endif\n}'),rasterParticle:Wr('#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 vec2 a_pos;in vec2 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=a_texture_pos/8192.0;gl_Position=u_matrix*vec4(a_pos*w,u_raster_elevation*w,w);\n#ifdef FOG\nv_fog_pos=fog_position(a_pos);\n#endif\n#endif\nv_pos0=uv;v_pos1=(v_pos0*u_scale_parent)+u_tl_parent;}'),rasterParticleDraw:Wr("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 float 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(a_index,u_particle_texture_side_len),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:Wr("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 vec2 a_pos;out vec2 v_tex_pos;void main() {vec2 uv=0.5*a_pos+vec2(0.5);v_tex_pos=uv;gl_Position=vec4(a_pos,0.0,1.0);}"),rasterParticleUpdate:Wr('#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 vec2 a_pos;out vec2 v_tex_coord;void main() {v_tex_coord=0.5*(a_pos+vec2(1.0));gl_Position=vec4(a_pos,0.0,1.0);}"),symbol:Wr('#include "_prelude_lighting.glsl"\n#include "_prelude_shadow.fragment.glsl"\n#define SDF_PX 8.0\n#define SDF 1.0\n#define ICON 0.0\nuniform sampler2D u_texture;uniform sampler2D u_texture_icon;uniform highp float u_gamma_scale;uniform lowp float u_device_pixel_ratio;uniform bool u_is_text;uniform bool u_is_halo;uniform lowp float u_scale_factor;\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\n#pragma mapbox: define highp vec4 fill_color\n#pragma mapbox: define highp vec4 halo_color\n#pragma mapbox: define lowp float opacity\n#pragma mapbox: define lowp float halo_width\n#pragma mapbox: define lowp float halo_blur\n#pragma mapbox: define lowp float emissive_strength\nvoid main() {\n#pragma mapbox: initialize highp vec4 fill_color\n#pragma mapbox: initialize highp vec4 halo_color\n#pragma mapbox: initialize lowp float opacity\n#pragma mapbox: initialize lowp float halo_width\n#pragma mapbox: initialize lowp float halo_blur\n#pragma mapbox: initialize lowp float emissive_strength\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;glFragColor=texture(u_texture_icon,tex_icon)*alpha;\n#ifdef OVERDRAW_INSPECTOR\nglFragColor=vec4(1.0);\n#endif\nreturn;}\n#endif\n#ifdef RENDER_SDF\nfloat 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;\n#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#endif\nout_color*=opacity*fade_opacity;\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);\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);\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 APPEARANCE_ICON 1.0\nin vec4 a_pos_offset;in vec4 a_tex_size;in vec4 a_pixeloffset;in vec4 a_projected_pos;in float a_fade_opacity;\n#ifdef Z_OFFSET\nin float a_auto_z_offset;\n#endif\n#ifdef PROJECTION_GLOBE_VIEW\nin vec3 a_globe_anchor;in vec3 a_globe_normal;\n#endif\n#ifdef ICON_TRANSITION\nin vec2 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;uniform mat4 u_inv_matrix;uniform 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;uniform vec3 u_up_vector;uniform vec2 u_texsize_icon;uniform 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#pragma mapbox: define highp vec4 fill_color\n#pragma mapbox: define highp vec4 halo_color\n#pragma mapbox: define lowp float opacity\n#pragma mapbox: define lowp float halo_width\n#pragma mapbox: define lowp float halo_blur\n#pragma mapbox: define lowp float emissive_strength\n#pragma mapbox: define lowp float occlusion_opacity\n#pragma mapbox: define lowp float z_offset\nvoid main() {\n#pragma mapbox: initialize highp vec4 fill_color\n#pragma mapbox: initialize highp vec4 halo_color\n#pragma mapbox: initialize lowp float opacity\n#pragma mapbox: initialize lowp float halo_width\n#pragma mapbox: initialize lowp float halo_blur\n#pragma mapbox: initialize lowp float emissive_strength\n#pragma mapbox: initialize lowp float occlusion_opacity\n#pragma mapbox: initialize lowp float z_offset\nvec2 a_pos=a_pos_offset.xy;vec2 a_offset=a_pos_offset.zw;vec2 a_tex=a_tex_size.xy;vec2 a_size=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_icon=a_size[1]-2.0*a_size_max;vec2 a_pxoffset=a_pixeloffset.xy;vec2 a_min_font_scale=a_pixeloffset.zw/256.0;highp float segment_angle=-a_projected_pos[3];float size;if (a_apperance_icon==APPEARANCE_ICON) {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=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(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);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=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:Wr('#include "_prelude_fog.fragment.glsl"\n#include "_prelude_shadow.fragment.glsl"\n#include "_prelude_lighting.glsl"\nuniform sampler2D u_image0;in 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\nvec3 unlit_base=image_color.rgb*(1.0-image_color.a);vec3 emissive_base=image_color.rgb*image_color.a;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\ncolor.rgb=mix(color.rgb,image_color.rgb,image_color.a);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 vec2 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;gl_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:Wr("precision highp float;in float v_depth;void main() {glFragColor=pack_depth(v_depth);}",'#include "_prelude_terrain.vertex.glsl"\nuniform mat4 u_matrix;in vec2 a_pos;out float v_depth;void main() {float elevation=elevation(a_pos);gl_Position=u_matrix*vec4(a_pos,elevation,1.0);v_depth=gl_Position.z/gl_Position.w;}'),skybox:Wr('#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}',Lr),skyboxGradient:Wr('#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}',Lr),skyboxCapture:Wr("\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;v_position.y*=-1.0;v_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:Wr('#include "_prelude_fog.fragment.glsl"\n#include "_prelude_lighting.glsl"\nuniform sampler2D u_image0;uniform 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;\n#ifdef FLIP_Y\nuv.y=1.0-uv.y;\n#endif\nhighp 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\nraster=apply_lighting_with_emission_ground(raster,raster.a);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\ncolor=apply_lighting_with_emission_ground(color,color.a);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;uniform mat4 u_merc_matrix;uniform float u_zoom_transition;uniform vec2 u_merc_center;uniform mat3 u_grid_matrix;uniform float u_skirt_height;\n#ifdef GLOBE_POLES\nin vec3 a_globe_pos;in vec2 a_uv;\n#else\nin vec2 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;vec2 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:Wr('#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);}"),model:Wr('#include "_prelude_fog.fragment.glsl"\n#include "_prelude_shadow.fragment.glsl"\n#include "_prelude_lighting.glsl"\nuniform float u_opacity;uniform vec3 u_lightcolor;uniform vec3 u_lightpos;uniform float u_lightintensity;uniform 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 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\nif(texColor.w > 0.0) {texColor.rgb/=texColor.w;}texColor.w=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=u_lightpos;vec3 lightColor=u_lightcolor;\n#ifdef LIGHTING_3D_MODE\nlightDir=u_lighting_directional_dir;lightDir.xy=-lightDir.xy;lightColor=u_lighting_directional_color;\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 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\nfinalColor=apply_feature_cutout(finalColor,gl_FragCoord);\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"\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 vec4 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 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 vec4 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\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#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(pbr.xy);vec2 e_r_m=unpack_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(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:Wr("in highp float v_depth;void main() {\n#ifndef DEPTH_TEXTURE\nglFragColor=pack_depth(v_depth);\n#endif\n}","in vec3 a_pos_3f;uniform mat4 u_matrix;out highp float v_depth;\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\nv_depth=gl_Position.z/gl_Position.w;}"),stars:Wr("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_fade_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_fade_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);}"),snowParticle:Wr("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:Wr("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:Wr("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);}"),occlusion:Wr("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 Zr(e,t){const i=e.replace(/\s*\/\/[^\n]*\n/g,"\n").split("\n");for(let e of i)if(e=e.trim(),"#"===e[0]&&e.includes("if")&&!e.includes("endif")){e=e.replace("#","").replace(/ifdef|ifndef|elif|if/g,"").replace(/!|defined|\(|\)|\|\||&&/g,"").replace(/\s+/g," ").trim();const i=e.split(" ");for(const e of i)t.includes(e)||t.push(e)}}function Wr(e,t){const i=/#include\s+"([^"]+)"/g,r=/#pragma mapbox: ([\w\-]+) ([\w]+) ([\w]+) ([\w]+)/g,n={},o=[],s=[];if(e=e.replace(i,(e,t)=>(s.push(t),"")),(t=t.replace(i,(e,t)=>(o.push(t),""))).includes("flat out"))return void console.error('The usage of "flat" qualifier is disallowed, see: https://bugs.webkit.org/show_bug.cgi?id=268071');let a=[...Vr];Zr(e,a),Zr(t,a);for(const e of[...o,...s])jr[e]||console.error(`Undefined include: ${e}`),Gr[e]||(Gr[e]=[],Zr(jr[e],Gr[e])),a=[...a,...Gr[e]];return{fragmentSource:e=e.replace(r,(e,t,i,r,o)=>(n[o]=!0,"define"===t?`\n#ifndef HAS_UNIFORM_u_${o}\nin ${i} ${r} ${o};\n#else\nuniform ${i} ${r} u_${o};\n#endif\n`:"initialize"===t?`\n#ifdef HAS_UNIFORM_u_${o}\n ${i} ${r} ${o} = u_${o};\n#endif\n`:"define-attribute"===t?`\n#ifdef HAS_ATTRIBUTE_a_${o}\n in ${i} ${r} ${o};\n#endif\n`:"initialize-attribute"===t?"":void 0)),vertexSource:t=t.replace(r,(e,t,i,r,o)=>{const s=`MATERIAL_ATTRIBUTE_OFFSET_${o}`,a="float"===r?"vec2":r,l=`GET_ATTRIBUTE_${a}(a_${o}, materialInfo, ${s})`,c=o.match(/color/)?"color":a;return"define-attribute-vertex-shader-only"===t?`\n#ifdef HAS_ATTRIBUTE_a_${o}\nin ${i} ${r} a_${o};\n#endif\n`:n[o]?"define"===t?`\n#ifndef HAS_UNIFORM_u_${o}\nuniform lowp float u_${o}_t;\n #if !defined(${s})\n in ${i} ${a} a_${o};\n #endif\nout ${i} ${r} ${o};\n#else\nuniform ${i} ${r} u_${o};\n#endif\n`:"initialize"===t?"vec4"===c?`\n#ifndef HAS_UNIFORM_u_${o}\n ${o} = a_${o};\n#else\n ${i} ${r} ${o} = u_${o};\n#endif\n`:`\n#if !defined(HAS_UNIFORM_u_${o}) \n #ifdef ${s}\n ${o} = unpack_mix_${c}(${l}, u_${o}_t);\n #else\n ${o} = unpack_mix_${c}(a_${o}, u_${o}_t);\n #endif\n#else\n ${i} ${r} ${o} = u_${o};\n#endif\n`:"define-attribute"===t?`\n#ifdef HAS_ATTRIBUTE_a_${o}\n in ${i} ${r} a_${o};\n out ${i} ${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(${s})\n in ${i} ${a} a_${o};\n #endif \n#else\nuniform ${i} ${r} u_${o};\n#endif\n`:"define-instanced"===t?"mat4"===c?`\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 ${i} ${r} u_${o};\n#endif\n`:`\n#ifdef INSTANCED_ARRAYS\nin ${i} ${a} a_${o};\n#else\nuniform ${i} ${r} u_${o};\n#endif\n`:"initialize-attribute-custom"===t?`\n#ifdef HAS_ATTRIBUTE_a_${o}\n ${i} ${r} ${o} = a_${o};\n#endif\n`:"vec4"===c?`\n#ifndef HAS_UNIFORM_u_${o}\n #ifdef ${s}\n ${i} ${r} ${o} = ${l};\n #else\n ${i} ${r} ${o} = a_${o};\n #endif\n#else\n ${i} ${r} ${o} = u_${o};\n#endif\n`:`\n#ifndef HAS_UNIFORM_u_${o}\n #ifdef ${s}\n ${i} ${r} ${o} = unpack_mix_${c}(${l}, u_${o}_t);\n #else\n ${i} ${r} ${o} = unpack_mix_${c}(a_${o}, u_${o}_t);\n #endif\n#else\n ${i} ${r} ${o} = u_${o};\n#endif\n`}),usedDefines:a,vertexIncludes:o,fragmentIncludes:s}}class qr{constructor(){this.boundProgram=null,this.boundLayoutVertexBuffer=null,this.boundPaintVertexBuffers=[],this.boundIndexBuffer=null,this.boundVertexOffset=null,this.boundDynamicVertexBuffers=[],this.vao=null}bind(e,t,i,r,n,o,s,a){this.context=e;let l=this.boundPaintVertexBuffers.length!==r.length;for(let e=0;!l&&e{const o=r.paint.get("hillshade-shadow-color"),s="none"===r.paint.get("hillshade-shadow-color-use-theme").constantOr("default"),a=r.paint.get("hillshade-highlight-color"),l="none"===r.paint.get("hillshade-highlight-color-use-theme").constantOr("default"),c=r.paint.get("hillshade-accent-color"),u="none"===r.paint.get("hillshade-accent-color-use-theme").constantOr("default"),h=r.paint.get("hillshade-emissive-strength");let d=e.an(r.paint.get("hillshade-illumination-direction"));if("viewport"===r.paint.get("hillshade-illumination-anchor"))d-=t.transform.angle;else if(t.style&&t.style.enable3dLights()&&t.style.directionalLight){const i=t.style.directionalLight.properties.get("direction"),r=e.d3(i.x,i.y,i.z);d=e.an(r[1])}const p=!t.options.moving;return{u_matrix:n||t.transform.calculateProjMatrix(i.tileID.toUnwrapped(),p),u_image:0,u_latrange:Kr(0,i.tileID),u_light:[r.paint.get("hillshade-exaggeration"),d],u_shadow:o.toPremultipliedRenderColor(s?null:r.lut),u_highlight:a.toPremultipliedRenderColor(l?null:r.lut),u_emissive_strength:h,u_accent:c.toPremultipliedRenderColor(u?null:r.lut)}})(t,r,n,t.terrain?i.projMatrix:null);t.uploadCommonUniforms(l,d,i.toUnwrapped());const{tileBoundsBuffer:f,tileBoundsIndexBuffer:m,tileBoundsSegments:g}=t.getTileBoundsBuffers(r);d.draw(t,c.TRIANGLES,o,s,a,Xi.disabled,p,n.id,f,m,g)}function Jr(t,i,r){if(!i.needsDEMTextureUpload)return;const n=t.context,o=n.gl;n.pixelStoreUnpackPremultiplyAlpha.set(!1),i.demTexture=i.demTexture||t.getTileTexture(r.stride);const s=r.getPixels();i.demTexture?i.demTexture.update(s,{premultiply:!1}):i.demTexture=new e.T(n,s,o.R32F,{premultiply:!1}),i.needsDEMTextureUpload=!1}function Yr(t,i,r){const n=t.context,o=n.gl;if(!i.dem)return;const s=i.dem;if(n.activeTexture.set(o.TEXTURE1),Jr(t,i,s),!i.demTexture)return;i.demTexture.bind(o.NEAREST,o.CLAMP_TO_EDGE);const a=s.dim;n.activeTexture.set(o.TEXTURE0);let l=i.hillshadeFBO;if(!l){const t=new e.T(n,{width:a,height:a,data:null},o.RGBA8);t.bind(o.LINEAR,o.CLAMP_TO_EDGE),l=i.hillshadeFBO=n.createFramebuffer(a,a,!0,"renderbuffer"),l.colorAttachment.set(t.texture)}n.bindFramebuffer.set(l.framebuffer),n.viewport.set([0,0,a,a]);const{tileBoundsBuffer:c,tileBoundsIndexBuffer:u,tileBoundsSegments:h}=t.getMercatorTileBoundsBuffers(),d=[];t.linearFloatFilteringSupported()&&d.push("TERRAIN_DEM_FLOAT_FORMAT"),t.getOrCreateProgram("hillshadePrepare",{defines:d}).draw(t,o.TRIANGLES,$i.disabled,Wi.disabled,Qi.unblended,Xi.disabled,((t,i)=>{const r=i.stride,n=e.bB();return e.cd(n,0,e.al,-e.al,0,0,1),e.bq(n,n,[0,-e.al,0]),{u_matrix:n,u_image:1,u_dimension:[r,r],u_zoom:t.overscaledZ}})(i.tileID,s),r.id,c,u,h),i.needsHillshadePrepare=!1}class en{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 tn extends en{getDefault(){return e.ao.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 rn extends en{getDefault(){return 1}set(e){(e!==this.current||this.dirty)&&(this.gl.clearDepth(e),this.current=e,this.dirty=!1)}}class nn extends en{getDefault(){return 0}set(e){(e!==this.current||this.dirty)&&(this.gl.clearStencil(e),this.current=e,this.dirty=!1)}}class on extends en{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 sn extends en{getDefault(){return!0}set(e){(e!==this.current||this.dirty)&&(this.gl.depthMask(e),this.current=e,this.dirty=!1)}}class an extends en{getDefault(){return 255}set(e){(e!==this.current||this.dirty)&&(this.gl.stencilMask(e),this.current=e,this.dirty=!1)}}class ln extends en{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 cn extends en{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 un extends en{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 hn extends en{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 dn extends en{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 pn extends en{getDefault(){return this.gl.LESS}set(e){(e!==this.current||this.dirty)&&(this.gl.depthFunc(e),this.current=e,this.dirty=!1)}}class fn extends en{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 mn extends en{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 gn extends en{getDefault(){return e.ao.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 _n extends en{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 An extends en{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 yn extends en{getDefault(){return this.gl.BACK}set(e){(e!==this.current||this.dirty)&&(this.gl.cullFace(e),this.current=e,this.dirty=!1)}}class vn extends en{getDefault(){return this.gl.CCW}set(e){(e!==this.current||this.dirty)&&(this.gl.frontFace(e),this.current=e,this.dirty=!1)}}let xn=class extends en{getDefault(){return null}set(e){(e!==this.current||this.dirty)&&(this.gl.useProgram(e),this.current=e,this.dirty=!1)}};class bn extends en{getDefault(){return this.gl.TEXTURE0}set(e){(e!==this.current||this.dirty)&&(this.gl.activeTexture(e),this.current=e,this.dirty=!1)}}class wn extends en{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 Tn extends en{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 En extends en{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 Cn extends en{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 Bn extends en{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 Sn extends en{getDefault(){return null}set(e){const t=this.gl;t.bindBuffer(t.ELEMENT_ARRAY_BUFFER,e),this.current=e,this.dirty=!1}}class In extends en{getDefault(){return null}set(e){this.gl&&(e!==this.current||this.dirty)&&(this.gl.bindVertexArray(e),this.current=e,this.dirty=!1)}}class Mn extends en{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 Pn extends en{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 Rn extends en{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 Ln extends en{constructor(e,t){super(e),this.context=e,this.parent=t}getDefault(){return null}}class Fn extends Ln{setDirty(){this.dirty=!0}set(e){if(e===this.current&&!this.dirty)return;this.context.bindFramebuffer.set(this.parent);const t=this.gl;t.framebufferTexture2D(t.FRAMEBUFFER,t.COLOR_ATTACHMENT0,t.TEXTURE_2D,e,0),this.current=e,this.dirty=!1}}class kn extends Ln{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 Dn extends Ln{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 On extends kn{attachment(){return this.gl.DEPTH_STENCIL_ATTACHMENT}}const zn=(e,t,i)=>({u_matrix:e,u_image0:0,u_skirt_height:t,u_ground_shadow_factor:i}),Un=(e,t,i,r,n,o,s,a,l,c,u,h,d,p,f,m)=>({u_proj_matrix:Float32Array.from(e),u_globe_matrix:t,u_normalize_matrix:Float32Array.from(r),u_merc_matrix:i,u_zoom_transition:n,u_merc_center:o,u_image0:0,u_frustum_tl:s,u_frustum_tr:a,u_frustum_br:l,u_frustum_bl:c,u_globe_pos:u,u_globe_radius:h,u_viewport:d,u_grid_matrix:m?Float32Array.from(m):new Float32Array(9),u_skirt_height:p,u_far_z_cutoff:f});function Nn(e,t){return null!=e&&null!=t&&!(!e.hasData()||!t.hasData())&&null!=e.demTexture&&null!=t.demTexture&&e.tileID.key!==t.tileID.key}const Vn=new class{constructor(){this.operations={}}newMorphing(e,t,i,r,n){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:r,phase:0,duration:n,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()}},jn={0:null,1:"TERRAIN_VERTEX_MORPHING"};function Gn(e,t,i){if(0===t)return 0;const r=t<1&&514===i?.25/t:1;return 6*Math.pow(1.5,22-e)*Math.max(t,1)*r}function Hn(e,t){const i=1<({u_matrix:e});function $n(t,i,r,n,o){if(o>0){const s=e.o.now(),a=(s-t.timeAdded)/o,l=i?(s-i.timeAdded)/o:-1,c=r.getSource(),u=n.coveringZoomLevel({tileSize:c.tileSize,roundZoom:c.roundZoom}),h=!i||Math.abs(i.tileID.overscaledZ-u)>Math.abs(t.tileID.overscaledZ-u),d=h&&t.refreshedUponExpiration?1:e.aA(h?a:1-l,0,1);return i?{opacity:1,mix:1-d,isFading:a<1}:{opacity:d,mix:0,isFading:a<1}}return{opacity:1,mix:0,isFading:!1}}class Zn extends Lt{constructor(e){const t=pt("mock-dem",{type:"raster-dem",maxzoom:e.transform.maxZoom},e.style.dispatcher,e.style);super("mock-dem",t,!1),t.setEventedParent(this),this._sourceLoaded=!0}_loadTile(e,t){e.state="loaded",t(null)}}class Wn extends Lt{constructor(e){const t=pt("proxy",{type:"geojson",maxzoom:e.transform.maxZoom},e.style.dispatcher,e.style);super("proxy",t,!1),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 r=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 It(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 r||(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 qn extends e.aP{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 Kn extends e.bU{constructor(t,i){super(),this._debugParams={sortTilesHiZFirst:!0,disableRenderCache:!1},t.tp.registerParameter(this._debugParams,["Terrain"],"sortTilesHiZFirst",{},()=>{this._style.map.triggerRepaint()}),t.tp.registerParameter(this._debugParams,["Terrain"],"disableRenderCache",{},()=>{this._style.map.triggerRepaint()}),t.tp.registerButton(["Terrain"],"Invalidate Render Cache",()=>{this.invalidateRenderCache=!0,this._style.map.triggerRepaint()}),this.painter=t,this.terrainTileForTile={},this.prevTerrainTileForTile={};const[r,n,o]=function(){const t=new e.bc,i=new e.b0,r=131;t.reserve(17161),i.reserve(33800);const n=e.al/128,o=e.al+n/2,s=o+n;for(let i=-n;io||i<0||i>o?24575:0,s=e.aA(Math.round(r),0,e.al),a=e.aA(Math.round(i),0,e.al);t.emplaceBack(s+n,a)}const a=(e,t)=>{const n=t*r+e;i.emplaceBack(n+1,n,n+r),i.emplaceBack(n+r,n+r+1,n+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]}(),s=t.context;this.gridBuffer=s.createVertexBuffer(r,e.be.members),this.gridIndexBuffer=s.createIndexBuffer(n),this.gridSegments=e.bf.simpleSegment(0,0,r.length,n.length),this.gridNoSkirtSegments=e.bf.simpleSegment(0,0,r.length,o),this.proxyCoords=[],this.proxiedCoords={},this._visibleDemTiles=[],this._drapedRenderBatches=[],this._sourceTilesOverlap={},this.proxySourceCache=new Wn(i.map),this.orthoMatrix=e.bB(),e.cd(this.orthoMatrix,"globe"===this.painter.transform.projection.name?.015:0,e.al,0,e.al,0,1);const a=s.gl;this._overlapStencilMode=new Wi({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 Zn(i.map),this._pendingGroundEffectLayers=[]}set style(e){e.on("data",this._onStyleDataEvent.bind(this)),this._style=e,this._style.map.on("moveend",()=>{this._clearLineLayersFromRenderCache()})}update(t,i,r){if(t&&t.terrain){this._style!==t&&(this.style=t,this._evaluationZoom=void 0);const n=t.terrain.properties,o=0===t.terrain.drapeRenderMode,s=t.terrain.isZoomDependent();this._previousUpdateTimestamp=this.enabled?this._updateTimestamp:void 0,this._updateTimestamp=e.o.now();const a=t.terrain&&t.terrain.scope,l=n.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=s?this.calculateExaggeration(i):n.get("exaggeration"),!i.projection.requiresDraping&&s&&0===this._exaggeration)return void this._disable();this.enabled=!0;const u=()=>{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,u(),this._initializing=!0),u(),i.updateElevation(!0,r),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,r=t.getFreeCameraOptions().position.z/t.pixelsPerMeter*t.worldSize;this._previousCameraAltitude=r;const n=null!=i?r-i:Number.MAX_VALUE;if(Math.abs(n)<2)return this._exaggeration;const o=t.zoom,s=this._style.terrain;if(!this._previousUpdateTimestamp)return s.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*n<0&&(c+=a)),this._evaluationZoom=c;const u=s.getExaggeration(c),h=u===s.getExaggeration(Math.max(0,c-.1));if(h&&Math.abs(u-this._exaggeration)<.01)return u;let d=Math.min(.1,.00375*(this._updateTimestamp-l));return(h||u<.1||Math.abs(a)<1e-4)&&(d=Math.min(.2,4*d)),e.ak(this._exaggeration,u,d)}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,r=this.painter.transform;this._initializing&&(this._initializing=0===r._centerAltitude&&-1===this.getAtPointOrZero(e.ae.fromLngLat(r.center),-1),this._emptyDEMTextureDirty=!this._initializing);const n=this.proxyCoords=i.getIds().map(e=>{const t=i.getTileByID(e).tileID;return t.projMatrix=r.calculateProjMatrix(t.toUnwrapped()),t});!function(t,i){const r=i.transform.pointCoordinate(i.transform.getCameraPoint()),n=new e.P(r.x,r.y);t.sort((t,i)=>{if(i.overscaledZ-t.overscaledZ)return i.overscaledZ-t.overscaledZ;const r=new e.P(t.canonical.x+(1<{this.proxyToSource[e.key]={}}),this.terrainTileForTile={};const s=this._style._mergedSourceCaches;for(const e in s){const i=s[e];if(!i.used)continue;if(i!==this.sourceCache&&this.resetTileLookupCache(i.id),this._setupProxiedCoordsForOrtho(i,t[e],o),i.usedForTerrain)continue;const r=t[e];i.getSource().reparseOverscaled&&this._assignTerrainTiles(r)}this.proxiedCoords[i.id]=n.map(e=>new qn(e,e.key,this.orthoMatrix)),this._assignTerrainTiles(n),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 r=this.terrainTileForTile[i],n=r.dem;!n||r.demTexture&&!r.needsDEMTextureUpload||(e.activeTexture.set(t.TEXTURE1),Jr(this.painter,r,n))}}_prepareDemTileUniforms(e,t,i,r){if(!t||null==t.demTexture)return!1;const n=e.tileID.canonical,o=Math.pow(2,t.tileID.canonical.z-n.z),s=r||"";return i[`u_dem_tl${s}`]=[n.x*o%1,n.y*o%1],i[`u_dem_scale${s}`]=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 r=i.dem.tree.minimums[0];return r>0&&e++,t+r},0);return e?t/e:0}_updateEmptyDEMTexture(){const t=this.painter.context,i=t.gl;t.activeTexture.set(i.TEXTURE2);const r=this._getLoadedAreaMinimum(),n=new e.dK({width:1,height:1},new Float32Array([r]));this._emptyDEMTextureDirty=!1;let o=this._emptyDEMTexture;return o?o.update(n,{premultiply:!1}):o=this._emptyDEMTexture=new e.T(t,n,i.R32F,{premultiply:!1}),o}setupElevationDraw(t,i,r){const n=this.painter.context,o=n.gl,s={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.u_exaggeration=this.exaggeration();let a=null,l=null,c=1;if(r&&r.morphing&&this._useVertexMorphing){const e=r.morphing.srcDemTile,i=r.morphing.dstDemTile;c=r.morphing.phase,e&&i&&(this._prepareDemTileUniforms(t,e,s,"_prev")&&(l=e),this._prepareDemTileUniforms(t,i,s)&&(a=i))}const u=e=>e&&e.demTexture&&this.painter.linearFloatFilteringSupported()?o.LINEAR:o.NEAREST;let h=null;var d;if(this.enabled?l&&a?(h=a.demTexture,n.activeTexture.set(o.TEXTURE4),l.demTexture.bind(u(l),o.CLAMP_TO_EDGE),s.u_dem_lerp=c):(a=this.terrainTileForTile[t.tileID.key],h=this._prepareDemTileUniforms(t,a,s)?a.demTexture:this.emptyDEMTexture):h=this.emptyDEMTexture,n.activeTexture.set(o.TEXTURE2),h&&(s.u_dem_size=1===(d=h).size[0]?1:d.size[0]-2,h.bind(u(a),o.CLAMP_TO_EDGE)),this.painter.setupDepthForOcclusion(r&&r.useDepthForOcclusion,i,s),r&&r.useMeterToDem&&a){const t=(1<{if(c===i)return;const r=[jn[i],"PROJECTION_GLOBE_VIEW"];h&&r.push("CUSTOM_ANTIALIASING");const n=t.isTileAffectedByFog(e);l=t.getOrCreateProgram("globeRaster",{defines:r,overrideFog:n}),c=i},p=t.colorModeForRenderPass(),f=new $i(a.LEQUAL,$i.ReadWrite,t.depthRangeFor3D);Vn.update(o);const m=e.dE(u),g=[e.aF(u.center.lng),e.aJ(u.center.lat)],_=t.globeSharedBuffers,A=[u.width*e.o.devicePixelRatio,u.height*e.o.devicePixelRatio],y=Float32Array.from(u.globeMatrix),v={useDenormalizedUpVectorScale:!0};{const u=t.transform,h=Gn(u.zoom,i.exaggeration(),i.sourceCache._source.tileSize);c=-1;const x=a.TRIANGLES;for(const c of n){const n=r.getTile(c),b=Wi.disabled,w=i.prevTerrainTileForTile[c.key],T=i.terrainTileForTile[c.key];Nn(w,T)&&Vn.newMorphing(c.key,w,T,o,250),s.activeTexture.set(a.TEXTURE0),n.texture&&n.texture.bind(a.LINEAR,a.CLAMP_TO_EDGE);const E=Vn.getMorphValuesForProxy(c.key),C=E?1:0;E&&Object.assign(v,{morphing:{srcDemTile:E.from,dstDemTile:E.to,phase:e.dC(E.phase)}});const B=e.dF(c.canonical),S=e.dG(B.getCenter().lat),I=e.dH(c.canonical,B,S,u.worldSize/u._pixelsPerMercatorPixel),M=e.bj(e.dI(c.canonical)),P=Un(u.expandedFarZProjMatrix,y,m,M,e.aj(u.zoom),g,u.frustumCorners.TL,u.frustumCorners.TR,u.frustumCorners.BR,u.frustumCorners.BL,u.globeCenterInViewSpace,u.globeRadius,A,h,u._farZ,I);if(d(c,C),l&&(i.setupElevationDraw(n,l,v),t.uploadCommonUniforms(s,l,c.toUnwrapped()),_)){const[e,i,r]=_.getGridBuffers(S,0!==h);l.draw(t,x,f,b,p,Xi.backCCW,P,"globe_raster",e,i,r)}}}if(_&&(t.renderDefaultNorthPole||t.renderDefaultSouthPole)){const o=["GLOBE_POLES","PROJECTION_GLOBE_VIEW"];h&&o.push("CUSTOM_ANTIALIASING"),l=t.getOrCreateProgram("globeRaster",{defines:o});for(const o of n){const{x:n,y:c,z:h}=o.canonical,d=0===c,m=c===(1<e.draw(t,a.TRIANGLES,f,Wi.disabled,p,Xi.disabled,Un(u.expandedFarZProjMatrix,_,_,T,0,g,u.frustumCorners.TL,u.frustumCorners.TR,u.frustumCorners.BR,u.frustumCorners.BL,u.globeCenterInViewSpace,u.globeRadius,A,0,u._farZ),"globe_pole_raster",i,b,w);i.setupElevationDraw(c,l,v),t.uploadCommonUniforms(s,l,o.toUnwrapped()),d&&t.renderDefaultNorthPole&&E(l,y),m&&t.renderDefaultSouthPole&&(_=e.cR(e.bB(),_,[1,-1,1]),E(l,x))}}}}(t,i,r,n,o);else{const s=t.context,a=s.gl;let l,c;const u=t.shadowRenderer,h=ar(t,t.longestCutoffRange),d=e=>{if(c===e)return;const i=[];i.push(jn[e]),h.shouldRenderCutoff&&i.push("RENDER_CUTOFF"),u&&(i.push("RENDER_SHADOWS","DEPTH_TEXTURE"),u.useNormalOffset&&i.push("NORMAL_OFFSET")),l=t.getOrCreateProgram("terrainRaster",{defines:i}),c=e},p=t.colorModeForRenderPass(),f=new $i(a.LEQUAL,$i.ReadWrite,t.depthRangeFor3D);Vn.update(o);const m=t.transform,g=Gn(m.zoom,i.exaggeration(),i.sourceCache._source.tileSize);let _=[0,0,0];if(u){const e=t.style.directionalLight,i=t.style.ambientLight;e&&i&&(_=fr(t.style,e,i))}{c=-1;const A=a.TRIANGLES,[y,v]=[i.gridIndexBuffer,i.gridSegments];for(const c of n){const n=r.getTile(c),x=Wi.disabled,b=i.prevTerrainTileForTile[c.key],w=i.terrainTileForTile[c.key];Nn(b,w)&&Vn.newMorphing(c.key,b,w,o,250),s.activeTexture.set(a.TEXTURE0),n.texture&&n.texture.bind(a.LINEAR,a.CLAMP_TO_EDGE);const T=Vn.getMorphValuesForProxy(c.key),E=T?1:0;let C;T&&(C={morphing:{srcDemTile:T.from,dstDemTile:T.to,phase:e.dC(T.phase)}});const B=zn(c.projMatrix,Hn(c.canonical,m.renderWorldCopies)?g/10:g,_);if(d(E),!l)continue;i.setupElevationDraw(n,l,C);const S=c.toUnwrapped();u&&u.setupShadows(S,l),t.uploadCommonUniforms(s,l,S,null,h),l.draw(t,A,f,x,p,Xi.backCCW,B,"terrain_raster",i.gridBuffer,y,v)}}}}(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,r=this.painter.context,n=this.proxySourceCache,o=this.proxiedCoords[n.id],s=this._drapedRenderBatches.shift(),a=i.style.order,l=[];let c=0;for(const u of o){const o=n.getTileByID(u.proxyTileKey),h=n.proxyCachedFBO[u.key]?n.proxyCachedFBO[u.key][t]:void 0,d=void 0!==h?n.renderCache[h]:this.pool[c++],p=void 0!==h;if(o.texture=d.tex,p&&!d.dirty){l.push(o.tileID);continue}let f;r.bindFramebuffer.set(d.fb.framebuffer),this.renderedToTile=!1,d.dirty&&(r.clear({color:e.ao.transparent,stencil:0}),d.dirty=!1);for(let e=s.start;e<=s.end;++e){const t=i.style._mergedLayers[a[e]];if(t.isHidden(i.transform.zoom))continue;const n=i.style.getLayerSourceCache(t),o=n?this.proxyToSource[u.key][n.id]:[u];if(!o)continue;const s=o;r.viewport.set([0,0,d.fb.width,d.fb.height]),f!==(n?n.id:null)&&(this._setupStencil(d,o,t,n),f=n?n.id:null),i.renderLayer(i,n,t,s)}if(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 n=i.style.getLayerSourceCache(t),o=n?this.proxyToSource[u.key][n.id]:[u];if(!o)continue;const s=o;r.viewport.set([0,0,d.fb.width,d.fb.height]),f!==(n?n.id:null)&&(this._setupStencil(d,o,t,n),f=n?n.id:null),i.renderLayer(i,n,t,s)}this.renderedToTile?(d.dirty=!0,l.push(o.tileID)):p||--c,5===c&&(c=0,this.renderToBackBuffer(l))}return this.renderToBackBuffer(l),this.renderingToTexture=!1,r.bindFramebuffer.set(null),r.viewport.set([0,0,i.width,i.height]),s.end+1}postRender(){}isLayerOrderingCorrect(e){const t=e.order.length;let i=-1,r=t;for(let n=0;ni}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 r=this._visibleDemTiles.filter(e=>e.dem).map(r=>{const n=r.tileID,o=1<(null!==e.t?e.t:Number.MAX_VALUE)-(null!==t.t?t.t:Number.MAX_VALUE));for(const n of r){if(null==n.t)return null;const r=n.tile.dem.tree.raycast(n.minx,n.miny,n.maxx,n.maxy,e,t,i);if(null!=r)return r}return null}_createFBO(){const t=this.painter.context,i=t.gl,r=this.drapeBufferSize;t.activeTexture.set(i.TEXTURE0);const n=new e.T(t,{width:r[0],height:r[1],data:null},i.RGBA8);n.bind(i.LINEAR,i.CLAMP_TO_EDGE);const o=t.createFramebuffer(r[0],r[1],!0,null);return o.colorAttachment.set(n.texture),o.depthAttachment=new On(t,o.framebuffer),void 0===this._sharedDepthStencil?(this._sharedDepthStencil=t.createRenderbuffer(t.gl.DEPTH_STENCIL,r[0],r[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:n,dirty:!1}}_initFBOPool(){for(;this.pool.length{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 lt){t=!0;break}if(!t)return;const i={};for(let t=0;te>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=r}_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=0;n--){const o=i[n];if(t.getTileByID(o.key),void 0!==t.proxyCachedFBO[o.key]){const i=e[o.key],n=this.proxyToSource[o.key];let s=0;for(const e in n){const t=n[e],o=i[e];if(!o||o.length!==t.length||t.some((t,i)=>t!==o[i]||r[e]&&r[e].hasOwnProperty(t.key))){s=-1;break}++s}for(const e in t.proxyCachedFBO[o.key])t.renderCache[t.proxyCachedFBO[o.key][e]].dirty=s<0||s!==Object.values(i).length}}const n=[...this._drapedRenderBatches];n.sort((e,t)=>t.end-t.start-(e.end-e.start));for(const e of n)for(const r of i){if(t.proxyCachedFBO[r.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[r.key]={},t.proxyCachedFBO[r.key][e.start]=i,t.renderCache[i].dirty=!0)}this._tilesDirty={}}_setupStencil(e,t,i,r){if(!r||!this._sourceTilesOverlap[r.id])return void(this._overlapStencilType&&(this._overlapStencilType=!1));const n=this.painter.context,o=n.gl;if(t.length<=1)return void(this._overlapStencilType=!1);let s;if(i.isTileClipped())s=t.length,this._overlapStencilMode.test={func:o.EQUAL,mask:255},this._overlapStencilType="Clip";else{if(!(t[0].overscaledZ>t[t.length-1].overscaledZ))return void(this._overlapStencilType=!1);s=1,this._overlapStencilMode.test={func:o.GREATER,mask:255},this._overlapStencilType="Mask"}this._stencilRef+s>255&&(n.clear({stencil:0}),this._stencilRef=0),this._stencilRef+=s,this._overlapStencilMode.ref=this._stencilRef,i.isTileClipped()&&this._renderTileClippingMasks(t,this._overlapStencilMode.ref)}clipOrMaskOverlapStencilType(){return"Clip"===this._overlapStencilType||"Mask"===this._overlapStencilType}stencilModeForRTTOverlap(e){return this.renderingToTexture&&this._overlapStencilType?("Clip"===this._overlapStencilType&&(this._overlapStencilMode.ref=this.painter._tileClippingMaskIDs[e.key]),this._overlapStencilMode):Wi.disabled}_renderTileClippingMasks(e,t){const i=this.painter,r=this.painter.context,n=r.gl;i._tileClippingMaskIDs={},r.setColorMode(Qi.disabled),r.setDepthMode($i.disabled);const o=i.getOrCreateProgram("clippingMask");for(const r of e){const e=i._tileClippingMaskIDs[r.key]=--t;o.draw(i,n.TRIANGLES,$i.disabled,new Wi({func:n.ALWAYS,mask:0},e,255,n.KEEP,n.KEEP,n.REPLACE),Qi.disabled,Xi.disabled,Qn(r.projMatrix),"$clipping",i.tileExtentBuffer,i.quadTriangleIndexBuffer,i.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 r=[t.x,t.y,1,1];e.aC(r,r,i.pixelMatrixInverse),e.cJ(r,r,1/r[3]),r[0]/=i.worldSize,r[1]/=i.worldSize;const n=i._camera.position,o=e.ce(1,i.center.lat),s=[n[0],n[1],n[2]/o,0],a=e.d9([],r.slice(0,3),s);e.aw(a,a);const l=this.raycast(s,a,this._exaggeration);return null!==l&&l?(e.bG(s,s,a,l),s[3]=s[2],s[2]*=o,s):null}_setupProxiedCoordsForOrtho(t,i,r){if(t.getSource()instanceof e.aT)return this._setupProxiedCoordsForImageSource(t,i,r);this._findCoveringTileCache[t.id]=this._findCoveringTileCache[t.id]||{};const n=this.proxiedCoords[t.id]=[],o=this.proxyCoords;for(let e=0;et.overscaledZ-e.overscaledZ)}_setupProxiedCoordsForImageSource(t,i,r){if(!t.getSource().loaded())return;const n=this.proxiedCoords[t.id]=[],o=this.proxyCoords,s=t.getSource(),a=s.tileID;if(!a)return;const l=new e.P(a.x,a.y)._div(1<(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)}),u=(t,i)=>{const r=t.wrap+t.canonical.x/(1<s+c.max.x||n+oa+c.max.y};for(let e=0;ee.key===i.tileID.key);if(e)return e}if(i.tileID.key!==t.key){const r=t.canonical.z-i.tileID.canonical.z;let o,s,a;n=e.bB();const l=i.tileID.wrap-t.wrap<0?(o=e.al>>r,s=o*((i.tileID.canonical.x<=n){const r=t.canonical.z-n;i.getSource().reparseOverscaled?(a=Math.max(t.canonical.z+2,i.transform.tileZoom),s=new e.aP(a,t.wrap,n,t.canonical.x>>r,t.canonical.y>>r)):0!==r&&(a=n,s=new e.aP(a,t.wrap,n,t.canonical.x>>r,t.canonical.y>>r))}s.key!==t.key&&(c.push(s.key),r=i.getTile(s))}const u=e=>{c.forEach(t=>{n[t]=e}),c.length=0};for(a-=1;a>=l&&(!r||!r.hasData());a--){r&&u(r.tileID.key);const e=s.calculateScaledKey(a);if(r=i.getTileByID(e),r&&r.hasData())break;const t=n[e];if(null===t)break;void 0===t?c.push(e):r=i.getTileByID(t)}return u(r?r.tileID.key:null),r&&r.hasData()?r: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 Xn(t,i,r){const n=function(t,i,r){const n=e.bI(i,t),o=e.bI(r,[.2126,.7152,.0722]),s=(e,t,i)=>(1-i)*e+i*t,a=s(1-.3*Math.min(o,1),1,Math.min(n+1,1));return s(.92,1,Math.asin(e.aA(i[2],-1,1))/Math.PI+.5)*a}(t,[0,0,1],i),o=[0,0,0];e.c4(o,r.slice(0,3),n);const s=[0,0,0];e.c4(s,i.slice(0,3),t[2]);const a=[0,0,0];return e.d7(a,o,s),e.da(a)}const Jn=["fill","fillOutline","fillPattern","line","linePattern","background","backgroundPattern","hillshade","raster"],Yn=["stars","rainParticle","snowParticle","fillExtrusion","fillExtrusionGroundEffect","elevatedStructures","model","symbol"];class eo{static cacheKey(e,t,i,r){let n=`${t}${r?r.cacheKey:""}`;for(const t of i)e.usedDefines.includes(t)&&(n+=`/${t}`);return n}constructor(t,i,r,n,o,s){const a=t.gl;this.program=a.createProgram(),this.configuration=n,this.name=i,this.fixedDefines=[...s];let l=n?n.defines():[];l=l.concat(s.map(e=>`#define ${e}`));const c="#version 300 es\n";let u=c+l.concat("precision mediump float;",Qr,Hr.fragmentSource).join("\n");for(const e of r.fragmentIncludes)u+=`\n${jr[e]}`;u+=`\n${r.fragmentSource}`;let h=c+l.concat("precision highp float;",Qr,Hr.vertexSource).join("\n");for(const e of r.vertexIncludes)h+=`\n${jr[e]}`;this.forceManualRenderingForInstanceIDShaders=t.forceManualRenderingForInstanceIDShaders&&-1!==r.vertexSource.indexOf("gl_InstanceID"),this.forceManualRenderingForInstanceIDShaders&&(h+="\nuniform int u_instanceID;\n"),h+=`\n${r.vertexSource}`,this.forceManualRenderingForInstanceIDShaders&&(h=h.replaceAll("gl_InstanceID","u_instanceID"));const d=a.createShader(a.FRAGMENT_SHADER);if(a.isContextLost())return void(this.failedToCreate=!0);a.shaderSource(d,u),a.compileShader(d),a.attachShader(this.program,d);const p=a.createShader(a.VERTEX_SHADER);a.isContextLost()?this.failedToCreate=!0:(a.shaderSource(p,h),a.compileShader(p),a.attachShader(this.program,p),this.attributes={},a.linkProgram(this.program),a.deleteShader(p),a.deleteShader(d),this.fixedUniforms=o(t),this.binderUniforms=n?n.getUniforms(t):[],this.forceManualRenderingForInstanceIDShaders&&(this.instancingUniforms=(t=>({u_instanceID:new e.cg(t)}))(t)),(s.includes("TERRAIN")||-1!==i.indexOf("symbol")||-1!==i.indexOf("circle"))&&(this.terrainUniforms=(t=>({u_dem:new e.cg(t),u_dem_prev:new e.cg(t),u_dem_tl:new e.cj(t),u_dem_scale:new e.ci(t),u_dem_tl_prev:new e.cj(t),u_dem_scale_prev:new e.ci(t),u_dem_size:new e.ci(t),u_dem_lerp:new e.ci(t),u_exaggeration:new e.ci(t),u_depth:new e.cg(t),u_depth_size_inv:new e.cj(t),u_depth_range_unpack:new e.cj(t),u_occluder_half_size:new e.ci(t),u_occlusion_depth_offset:new e.ci(t),u_meter_to_dem:new e.ci(t),u_label_plane_matrix_inv:new e.ck(t)}))(t)),s.includes("GLOBE")&&(this.globeUniforms=(t=>({u_tile_tl_up:new e.ch(t),u_tile_tr_up:new e.ch(t),u_tile_br_up:new e.ch(t),u_tile_bl_up:new e.ch(t),u_tile_up_scale:new e.ci(t)}))(t)),s.includes("FOG")&&(this.fogUniforms=(t=>({u_fog_matrix:new e.ck(t),u_fog_range:new e.cj(t),u_fog_color:new e.d2(t),u_fog_horizon_blend:new e.ci(t),u_fog_vertical_limit:new e.cj(t),u_fog_temporal_offset:new e.ci(t),u_frustum_tl:new e.ch(t),u_frustum_tr:new e.ch(t),u_frustum_br:new e.ch(t),u_frustum_bl:new e.ch(t),u_globe_pos:new e.ch(t),u_globe_radius:new e.ci(t),u_globe_transition:new e.ci(t),u_is_globe:new e.cg(t),u_viewport:new e.cj(t)}))(t)),s.includes("RENDER_CUTOFF")&&(this.cutoffUniforms=(t=>({u_cutoff_params:new e.d2(t)}))(t)),s.includes("LIGHTING_3D_MODE")&&(this.lightsUniforms=(t=>({u_lighting_ambient_color:new e.ch(t),u_lighting_directional_dir:new e.ch(t),u_lighting_directional_color:new e.ch(t),u_ground_radiance:new e.ch(t)}))(t)),s.includes("RENDER_SHADOWS")&&(this.shadowUniforms=(t=>({u_light_matrix_0:new e.ck(t),u_light_matrix_1:new e.ck(t),u_fade_range:new e.cj(t),u_shadow_normal_offset:new e.ch(t),u_shadow_intensity:new e.ci(t),u_shadow_texel_size:new e.ci(t),u_shadow_map_resolution:new e.ci(t),u_shadow_direction:new e.ch(t),u_shadow_bias:new e.ch(t),u_shadowmap_0:new e.cg(t),u_shadowmap_1:new e.cg(t)}))(t)))}getAttributeLocation(e,t){let i=this.attributes[t];return void 0===i&&(i=this.attributes[t]=e.getAttribLocation(this.program,t)),i}setTerrainUniformValues(e,t){if(!this.terrainUniforms)return;const i=this.terrainUniforms;if(!this.failedToCreate){e.program.set(this.program);for(const e in t)i[e]&&i[e].set(this.program,e,t[e])}}setGlobeUniformValues(e,t){if(!this.globeUniforms)return;const i=this.globeUniforms;if(!this.failedToCreate){e.program.set(this.program);for(const e in t)i[e]&&i[e].set(this.program,e,t[e])}}setFogUniformValues(e,t){if(!this.fogUniforms)return;const i=this.fogUniforms;if(!this.failedToCreate){e.program.set(this.program);for(const e in t)i[e].set(this.program,e,t[e])}}setCutoffUniformValues(e,t){if(!this.cutoffUniforms)return;const i=this.cutoffUniforms;if(!this.failedToCreate){e.program.set(this.program);for(const e in t)i[e].set(this.program,e,t[e])}}setLightsUniformValues(e,t){if(!this.lightsUniforms)return;const i=this.lightsUniforms;if(!this.failedToCreate){e.program.set(this.program);for(const e in t)i[e].set(this.program,e,t[e])}}setShadowUniformValues(e,t){if(this.failedToCreate||!this.shadowUniforms)return;const i=this.shadowUniforms;e.program.set(this.program);for(const e in t)i[e].set(this.program,e,t[e])}_drawDebugWireframe(t,i,r,n,o,s,a,l,c,u){const h=t.options.wireframe;if(!1===h.terrain&&!1===h.layers2D&&!1===h.layers3D)return;const d=t.context;if(!(()=>!(!h.terrain||"terrainRaster"!==this.name&&"globeRaster"!==this.name)||!(!h.layers2D||t._terrain&&t._terrain.renderingToTexture||!Jn.includes(this.name))||!(!h.layers3D||!Yn.includes(this.name)))())return;const p=d.gl,f=t.wireframeDebugCache.getLinesFromTrianglesBuffer(t.frameCounter,o,d);if(!f)return;const m=[...this.fixedDefines];m.push("DEBUG_WIREFRAME");const g=t.getOrCreateProgram(this.name,{config:this.configuration,defines:m});d.program.set(g.program);const _=(e,t,i)=>{if(t[e]&&i[e])for(const r in t[e])i[e][r]&&i[e][r].set(i.program,r,t[e][r].current)};c&&c.setUniforms(g.program,d,g.binderUniforms,a,{zoom:l}),_("fixedUniforms",this,g),_("terrainUniforms",this,g),_("globeUniforms",this,g),_("fogUniforms",this,g),_("lightsUniforms",this,g),_("shadowUniforms",this,g),f.bind(),d.setColorMode(new Qi([p.ONE,p.ONE_MINUS_SRC_ALPHA,p.ZERO,p.ONE],e.ao.transparent,[!0,!0,!0,!1])),d.setDepthMode(new $i(i.func===p.LESS?p.LEQUAL:i.func,$i.ReadOnly,i.range)),d.setStencilMode(Wi.disabled);const A=3*s.primitiveLength*2,y=3*s.primitiveOffset*2*2;if(this.forceManualRenderingForInstanceIDShaders){const e=u||1;for(let t=0;t1?p.drawElementsInstanced(p.LINES,A,p.UNSIGNED_SHORT,y,u):p.drawElements(p.LINES,A,p.UNSIGNED_SHORT,y);o.bind(),d.program.set(this.program),d.setDepthMode(i),d.setStencilMode(r),d.setColorMode(n)}checkUniforms(e,t,i){if(this.fixedDefines.includes(t))for(const r of Object.keys(i))if(!i[r].initialized)throw new Error(`Program '${this.name}', from draw '${e}': uniform ${r} not set but required by ${t} being defined`)}draw(e,t,i,r,n,o,s,a,l,c,u,h,d,p,f,m){const g=e.context,_=g.gl;if(this.failedToCreate)return;g.program.set(this.program),g.setDepthMode(i),g.setStencilMode(r),g.setColorMode(n),g.setCullFace(o);for(const e of Object.keys(this.fixedUniforms))this.fixedUniforms[e].set(this.program,e,s[e]);p&&p.setUniforms(this.program,g,this.binderUniforms,h,{zoom:d});const A={[_.POINTS]:1,[_.LINES]:2,[_.TRIANGLES]:3,[_.LINE_STRIP]:1}[t];this.checkUniforms(a,"RENDER_SHADOWS",this.shadowUniforms);const y=m&&m>0?1:void 0;for(const o of u.get()){const s=o.vaos||(o.vaos={});if((s[a]||(s[a]=new qr)).bind(g,this,l,p?p.getPaintVertexBuffers():[],c,o.vertexOffset,f||[],y),this.forceManualRenderingForInstanceIDShaders){const e=m||1;for(let i=0;i1?_.drawElementsInstanced(t,o.primitiveLength*A,_.UNSIGNED_SHORT,o.primitiveOffset*A*2,m):c?_.drawElements(t,o.primitiveLength*A,_.UNSIGNED_SHORT,o.primitiveOffset*A*2):_.drawArrays(t,o.vertexOffset,o.vertexLength);t===_.TRIANGLES&&c&&this._drawDebugWireframe(e,i,r,n,c,o,h,d,p,m)}}}function to(t,i,r=0){const n=Math.pow(2,i.tileID.overscaledZ),o=i.tileSize*Math.pow(2,t.transform.tileZoom)/n,s=o*(i.tileID.canonical.x+i.tileID.wrap*n),a=o*i.tileID.canonical.y;return{u_image:0,u_texsize:i.imageAtlasTexture?i.imageAtlasTexture.size:[0,0],u_tile_units_to_pixels:1/e.ay(i,1,t.transform.tileZoom),u_pixel_coord_upper:[s>>16,a>>16],u_pixel_coord_lower:[65535&s,65535&a],u_pattern_transition:r}}const io={terrain:0,flat:1},ro=e.bB(),no=(t,i,r,n,o,s,a,l,c,u,h,d,p,f,m,g,_,A)=>{const y=i.style.light,v=y.properties.get("position"),x=[v.x,v.y,v.z],b=e.dN();"viewport"===y.properties.get("anchor")&&(e.dO(b,-i.transform.angle),e.dP(x,x,b));const w=y.properties.get("color").toPremultipliedRenderColor(null),T=i.transform,E={u_matrix:t,u_lightpos:x,u_lightintensity:y.properties.get("intensity"),u_lightcolor:[w.r,w.g,w.b],u_vertical_gradient:+r,u_opacity:n,u_tile_id:[0,0,0],u_zoom_transition:0,u_inv_rot_matrix:ro,u_merc_center:[0,0],u_up_dir:[0,0,0],u_height_lift:0,u_height_type:io[u],u_base_type:io[h],u_ao:o,u_edge_radius:s,u_width_scale:a,u_flood_light_color:m,u_vertical_scale:g,u_flood_light_intensity:_,u_ground_shadow_factor:A};return"globe"===T.projection.name&&(E.u_tile_id=[l.canonical.x,l.canonical.y,1<({u_matrix:e,u_edge_radius:t,u_width_scale:i,u_vertical_scale:r,u_height_type:io[n],u_base_type:io[o]}),so=(e,t,i,r,n,o,s,a,l,c,u,h,d,p,f,m,g,_)=>{const A=no(e,t,i,r,n,o,s,a,c,u,h,d,p,f,m,g,1,[0,0,0]),y={u_height_factor:-Math.pow(2,a.overscaledZ)/l.tileSize/8};return Object.assign(A,to(t,l,_),y)},ao=(e,t,i,r,n,o,s,a,l,c,u)=>({u_matrix:t,u_opacity:i,u_ao_pass:r?1:0,u_meter_to_tile:n,u_ao:o,u_flood_light_intensity:s,u_flood_light_color:a,u_attenuation:l,u_edge_radius:c,u_fb:0,u_fb_size:u,u_dynamic_offset:1}),lo=(e,t,i)=>({u_matrix:e,u_emissive_strength:t,u_ground_shadow_factor:i}),co=(e,t,i,r,n,o=0)=>Object.assign(lo(e,t,n),to(i,r,o)),uo=(e,t,i,r)=>({u_matrix:e,u_world:i,u_emissive_strength:t,u_ground_shadow_factor:r}),ho=(e,t,i,r,n,o,s=0)=>Object.assign(co(e,t,i,r,o,s),{u_world:n}),po=(e,t)=>({u_matrix:e,u_ground_shadow_factor:t}),fo=(e,t,i,r,n)=>({u_matrix:e,u_camera_pos:[t[0],t[1],t[2]],u_depth_bias:i,u_height_scale:r,u_reset_depth:n}),mo=(e,t,i,r,n,o,s,a,l)=>({u_matrix:e,u_normal_matrix:t,u_opacity:i,u_faux_facade_ao_intensity:r,u_camera_pos:n,u_tile_to_meter:o,u_facade_emissive_chance:s,u_flood_light_color:a,u_flood_light_intensity:l}),go=e=>({u_matrix:e}),_o=e=>({u_matrix:e}),Ao=(t,i,r,n,o,s,a,l)=>{const c=e.al/s.tileSize;return{u_matrix:t,u_inv_rot_matrix:i,u_camera_to_center_distance:r.getCameraToCenterDistance(l),u_extrude_scale:[r.pixelsToGLUnits[0]/c,r.pixelsToGLUnits[1]/c],u_zoom_transition:n,u_tile_id:a,u_merc_center:o}},yo=(e,t,i=1)=>({u_matrix:e,u_color:t,u_overlay:0,u_overlay_scale:i}),vo=e.bB(),xo=(t,i,r,n,o,s,a)=>{const l=t.transform,c="globe"===l.projection.name,u=c?e.dQ(l.zoom,i.canonical)*l._pixelsPerMercatorPixel:e.ay(r,1,s),h={u_matrix:i.projMatrix,u_extrude_scale:u,u_intensity:a,u_inv_rot_matrix:vo,u_merc_center:[0,0],u_tile_id:[0,0,0],u_zoom_transition:0,u_up_dir:[0,0,0]};if(c){h.u_inv_rot_matrix=n,h.u_merc_center=o,h.u_tile_id=[i.canonical.x,i.canonical.y,1<({u_matrix:t,u_normalize_matrix:i,u_globe_matrix:r,u_merc_matrix:n,u_grid_matrix:o,u_tl_parent:s,u_scale_parent:u,u_fade_t:h.mix,u_opacity:h.opacity*d.paint.get("raster-opacity"),u_image0:0,u_image1:1,u_brightness_low:d.paint.get("raster-brightness-min"),u_brightness_high:d.paint.get("raster-brightness-max"),u_saturation_factor:e.dS(d.paint.get("raster-saturation")),u_contrast_factor:e.dR(d.paint.get("raster-contrast")),u_spin_weights:Eo(d.paint.get("raster-hue-rotate")),u_perspective_transform:p,u_raster_elevation:f,u_zoom_transition:a,u_merc_center:l,u_cutoff_params:c,u_colorization_mix:bo(e.dT,g,A),u_colorization_offset:wo(e.dT,_,A),u_color_ramp:m,u_texture_offset:[v/(y+2*v),y/(y+2*v)],u_texture_res:[y+2*v,y+2*v],u_emissive_strength:x});function Eo(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 Co=.05,Bo=(e,t,i,r,n,o,s,a,l,c,u,h)=>({u_matrix:e,u_normalize_matrix:t,u_globe_matrix:i,u_merc_matrix:r,u_grid_matrix:n,u_tl_parent:o,u_scale_parent:c,u_fade_t:u.mix,u_opacity:u.opacity,u_image0:0,u_image1:1,u_raster_elevation:h,u_zoom_transition:s,u_merc_center:a,u_cutoff_params:l}),So=(e,t,i,r,n,o,s,a,l,c)=>({u_particle_texture:e,u_particle_texture_side_len:t,u_tile_offset:i,u_velocity:r,u_color_ramp:o,u_velocity_res:n,u_max_speed:s,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:[Co,Co]}),Io=(e,t,i,r,n,o,s,a,l,c)=>({u_particle_texture:e,u_particle_texture_side_len:t,u_velocity:i,u_velocity_res:r,u_max_speed:n,u_speed_factor:o,u_reset_rate:s,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:[Co,Co]}),Mo=e.bB(),Po=(t,i,r,n,o,s,a,l,c,u,h,d,p,f,m,g,_,A,y,v,x,b,w,T)=>{const E=o.transform,C={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(y),u_rotate_symbol:+r,u_aspect_ratio:E.width/E.height,u_fade_change:o.options.fadeDuration?o.symbolFadeChange:1,u_matrix:s,u_label_plane_matrix:a,u_coord_matrix:l,u_is_text:+u,u_elevation_from_sea:c?1:0,u_pitch_with_map:+n,u_texsize:h,u_texsize_icon:d,u_texture:0,u_texture_icon:1,u_tile_id:[0,0,0],u_zoom_transition:0,u_inv_rot_matrix:Mo,u_merc_center:[0,0],u_camera_forward:[0,0,0],u_ecef_origin:[0,0,0],u_tile_matrix:Mo,u_up_vector:[0,-1,0],u_color_adj_mat:b,u_icon_transition:w||0,u_gamma_scale:n?o.transform.getCameraToCenterDistance(y)*Math.cos(o.terrain?0:o.transform._pitch):1,u_device_pixel_ratio:e.o.devicePixelRatio,u_is_halo:1,u_scale_factor:T||1,u_ground_shadow_factor:v,u_inv_matrix:e.bk(e.bB(),a),u_normal_scale:x,u_lutTexture:rr.LUT};return"globe"===y.name&&(C.u_tile_id=[f.canonical.x,f.canonical.y,1<({u_matrix:e,u_emissive_strength:t,u_opacity:i,u_color:r}),Lo=(t,i,r,n,o,s,a,l,c)=>Object.assign(function(t,i,r,n,o,s){const{width:a,height:l}=n.imageManager.getPixelSize(i),c=Math.pow(2,s.tileID.overscaledZ),u=s.tileSize*Math.pow(2,n.transform.tileZoom)/c,h=u*(s.tileID.canonical.x+s.tileID.wrap*c),d=u*s.tileID.canonical.y;return{u_image:0,u_pattern_tl:r.tl,u_pattern_br:r.br,u_texsize:[a,l],u_pattern_size:r.displaySize,u_pattern_units_to_pixels:o?[n.transform.width,-1*n.transform.height]:[1/e.ay(s,1,n.transform.tileZoom),1/e.ay(s,1,n.transform.tileZoom)],u_pixel_coord_upper:[h>>16,d>>16],u_pixel_coord_lower:[65535&h,65535&d]}}(0,s,a,n,l,c),{u_matrix:t,u_emissive_strength:i,u_opacity:r}),Fo=new Float32Array(e.bz([])),ko=(t,i,r,n,o,s,a,l,c,u,h,d,p,f=[0,0,0],m,g,_)=>{const A=o.style.light,y=A.properties.get("position"),v=[-y.x,-y.y,y.z],x=e.dN();"viewport"===A.properties.get("anchor")&&(e.dO(x,-o.transform.angle),e.dP(v,v,x));const b="MASK"===h.alphaMode,w=A.properties.get("color").toNonPremultipliedRenderColor(null),T=p.paint.get("model-ambient-occlusion-intensity"),E=p.paint.get("model-color").constantOr(e.ao.white).toNonPremultipliedRenderColor(null);return E.a=p.paint.get("model-color-mix-intensity").constantOr(0),_&&(E.r=_[0],E.g=_[1],E.b=_[2],E.a=_[3]),g&&(E.r=g.color.r,E.g=g.color.g,E.b=g.color.b,E.a=g.colorMix,d=g.emissionStrength,s=g.opacity),{u_matrix:t,u_lighting_matrix:i,u_normal_matrix:r,u_node_matrix:n||Fo,u_lightpos:v,u_lightintensity:A.properties.get("intensity"),u_lightcolor:[w.r,w.g,w.b],u_camera_pos:f,u_opacity:s,u_baseTextureIsAlpha:0,u_alphaMask:+b,u_alphaCutoff:h.alphaCutoff,u_baseColorFactor:a.toNonPremultipliedRenderColor(null).toArray01(),u_emissiveFactor:l.toNonPremultipliedRenderColor(null).toArray01(),u_metallicFactor:c,u_roughnessFactor:u,u_baseColorTexture:rr.BaseColor,u_metallicRoughnessTexture:rr.MetallicRoughness,u_normalTexture:rr.Normal,u_occlusionTexture:rr.Occlusion,u_emissionTexture:rr.Emission,u_lutTexture:rr.LUT,u_color_mix:E.toArray01(),u_aoIntensity:T,u_emissive_strength:d,u_occlusionTextureTransform:m||[0,0,0,0]}},Do=(e,t=Fo,i=Fo)=>({u_matrix:e,u_instance:t,u_node_matrix:i}),Oo={fillExtrusion:t=>({u_matrix:new e.ck(t),u_lightpos:new e.ch(t),u_lightintensity:new e.ci(t),u_lightcolor:new e.ch(t),u_vertical_gradient:new e.ci(t),u_opacity:new e.ci(t),u_edge_radius:new e.ci(t),u_width_scale:new e.ci(t),u_ao:new e.cj(t),u_height_type:new e.cg(t),u_base_type:new e.cg(t),u_tile_id:new e.ch(t),u_zoom_transition:new e.ci(t),u_inv_rot_matrix:new e.ck(t),u_merc_center:new e.cj(t),u_up_dir:new e.ch(t),u_height_lift:new e.ci(t),u_flood_light_color:new e.ch(t),u_vertical_scale:new e.ci(t),u_flood_light_intensity:new e.ci(t),u_ground_shadow_factor:new e.ch(t)}),fillExtrusionDepth:t=>({u_matrix:new e.ck(t),u_edge_radius:new e.ci(t),u_width_scale:new e.ci(t),u_vertical_scale:new e.ci(t),u_height_type:new e.cg(t),u_base_type:new e.cg(t)}),fillExtrusionPattern:t=>({u_matrix:new e.ck(t),u_lightpos:new e.ch(t),u_lightintensity:new e.ci(t),u_lightcolor:new e.ch(t),u_vertical_gradient:new e.ci(t),u_height_factor:new e.ci(t),u_edge_radius:new e.ci(t),u_width_scale:new e.ci(t),u_ao:new e.cj(t),u_height_type:new e.cg(t),u_base_type:new e.cg(t),u_tile_id:new e.ch(t),u_zoom_transition:new e.ci(t),u_inv_rot_matrix:new e.ck(t),u_merc_center:new e.cj(t),u_up_dir:new e.ch(t),u_height_lift:new e.ci(t),u_image:new e.cg(t),u_texsize:new e.cj(t),u_pixel_coord_upper:new e.cj(t),u_pixel_coord_lower:new e.cj(t),u_tile_units_to_pixels:new e.ci(t),u_opacity:new e.ci(t),u_pattern_transition:new e.ci(t)}),fillExtrusionGroundEffect:t=>({u_matrix:new e.ck(t),u_opacity:new e.ci(t),u_ao_pass:new e.ci(t),u_meter_to_tile:new e.ci(t),u_ao:new e.cj(t),u_flood_light_intensity:new e.ci(t),u_flood_light_color:new e.ch(t),u_attenuation:new e.ci(t),u_edge_radius:new e.ci(t),u_fb:new e.cg(t),u_fb_size:new e.ci(t),u_dynamic_offset:new e.ci(t)}),fill:t=>({u_matrix:new e.ck(t),u_emissive_strength:new e.ci(t),u_ground_shadow_factor:new e.ch(t)}),fillPattern:t=>({u_matrix:new e.ck(t),u_emissive_strength:new e.ci(t),u_image:new e.cg(t),u_texsize:new e.cj(t),u_pixel_coord_upper:new e.cj(t),u_pixel_coord_lower:new e.cj(t),u_tile_units_to_pixels:new e.ci(t),u_ground_shadow_factor:new e.ch(t),u_pattern_transition:new e.ci(t)}),fillOutline:t=>({u_matrix:new e.ck(t),u_emissive_strength:new e.ci(t),u_world:new e.cj(t),u_ground_shadow_factor:new e.ch(t)}),fillOutlinePattern:t=>({u_matrix:new e.ck(t),u_emissive_strength:new e.ci(t),u_world:new e.cj(t),u_image:new e.cg(t),u_texsize:new e.cj(t),u_pixel_coord_upper:new e.cj(t),u_pixel_coord_lower:new e.cj(t),u_tile_units_to_pixels:new e.ci(t),u_ground_shadow_factor:new e.ch(t),u_pattern_transition:new e.ci(t)}),building:t=>({u_matrix:new e.ck(t),u_normal_matrix:new e.ck(t),u_opacity:new e.ci(t),u_faux_facade_ao_intensity:new e.ci(t),u_camera_pos:new e.ch(t),u_tile_to_meter:new e.ci(t),u_facade_emissive_chance:new e.ci(t),u_flood_light_color:new e.ch(t),u_flood_light_intensity:new e.ci(t)}),buildingBloom:t=>({u_matrix:new e.ck(t)}),buildingDepth:t=>({u_matrix:new e.ck(t)}),elevatedStructuresDepth:t=>({u_matrix:new e.ck(t),u_depth_bias:new e.ci(t)}),elevatedStructures:t=>({u_matrix:new e.ck(t),u_ground_shadow_factor:new e.ch(t)}),elevatedStructuresDepthReconstruct:t=>({u_matrix:new e.ck(t),u_camera_pos:new e.ch(t),u_depth_bias:new e.ci(t),u_height_scale:new e.ci(t),u_reset_depth:new e.ci(t)}),circle:e.dX,collisionBox:t=>({u_matrix:new e.ck(t),u_inv_rot_matrix:new e.ck(t),u_camera_to_center_distance:new e.ci(t),u_extrude_scale:new e.cj(t),u_zoom_transition:new e.ci(t),u_merc_center:new e.cj(t),u_tile_id:new e.ch(t)}),collisionCircle:t=>({u_matrix:new e.ck(t),u_inv_matrix:new e.ck(t),u_camera_to_center_distance:new e.ci(t),u_viewport_size:new e.cj(t)}),debug:t=>({u_color:new e.dA(t),u_matrix:new e.ck(t),u_overlay:new e.cg(t),u_overlay_scale:new e.ci(t)}),clippingMask:t=>({u_matrix:new e.ck(t)}),heatmap:t=>({u_extrude_scale:new e.ci(t),u_intensity:new e.ci(t),u_matrix:new e.ck(t),u_inv_rot_matrix:new e.ck(t),u_merc_center:new e.cj(t),u_tile_id:new e.ch(t),u_zoom_transition:new e.ci(t),u_up_dir:new e.ch(t)}),heatmapTexture:t=>({u_image:new e.cg(t),u_color_ramp:new e.cg(t),u_opacity:new e.ci(t)}),hillshade:t=>({u_matrix:new e.ck(t),u_image:new e.cg(t),u_latrange:new e.cj(t),u_light:new e.cj(t),u_shadow:new e.dA(t),u_highlight:new e.dA(t),u_emissive_strength:new e.ci(t),u_accent:new e.dA(t)}),hillshadePrepare:t=>({u_matrix:new e.ck(t),u_image:new e.cg(t),u_dimension:new e.cj(t),u_zoom:new e.ci(t)}),line:e.dW,linePattern:e.dV,raster:t=>({u_matrix:new e.ck(t),u_normalize_matrix:new e.ck(t),u_globe_matrix:new e.ck(t),u_merc_matrix:new e.ck(t),u_grid_matrix:new e.dB(t),u_tl_parent:new e.cj(t),u_scale_parent:new e.ci(t),u_fade_t:new e.ci(t),u_opacity:new e.ci(t),u_image0:new e.cg(t),u_image1:new e.cg(t),u_brightness_low:new e.ci(t),u_brightness_high:new e.ci(t),u_saturation_factor:new e.ci(t),u_contrast_factor:new e.ci(t),u_spin_weights:new e.ch(t),u_perspective_transform:new e.cj(t),u_raster_elevation:new e.ci(t),u_zoom_transition:new e.ci(t),u_merc_center:new e.cj(t),u_cutoff_params:new e.d2(t),u_colorization_mix:new e.d2(t),u_colorization_offset:new e.ci(t),u_color_ramp:new e.cg(t),u_texture_offset:new e.cj(t),u_texture_res:new e.cj(t),u_emissive_strength:new e.ci(t)}),rasterParticle:t=>({u_matrix:new e.ck(t),u_normalize_matrix:new e.ck(t),u_globe_matrix:new e.ck(t),u_merc_matrix:new e.ck(t),u_grid_matrix:new e.dB(t),u_tl_parent:new e.cj(t),u_scale_parent:new e.ci(t),u_fade_t:new e.ci(t),u_opacity:new e.ci(t),u_image0:new e.cg(t),u_image1:new e.cg(t),u_raster_elevation:new e.ci(t),u_zoom_transition:new e.ci(t),u_merc_center:new e.cj(t),u_cutoff_params:new e.d2(t)}),rasterParticleTexture:t=>({u_texture:new e.cg(t),u_opacity:new e.ci(t)}),rasterParticleDraw:t=>({u_particle_texture:new e.cg(t),u_particle_texture_side_len:new e.ci(t),u_tile_offset:new e.cj(t),u_velocity:new e.cg(t),u_color_ramp:new e.cg(t),u_velocity_res:new e.cj(t),u_max_speed:new e.ci(t),u_uv_offset:new e.cj(t),u_data_scale:new e.cj(t),u_data_offset:new e.ci(t),u_particle_pos_scale:new e.ci(t),u_particle_pos_offset:new e.cj(t)}),rasterParticleUpdate:t=>({u_particle_texture:new e.cg(t),u_particle_texture_side_len:new e.ci(t),u_velocity:new e.cg(t),u_velocity_res:new e.cj(t),u_max_speed:new e.ci(t),u_speed_factor:new e.ci(t),u_reset_rate:new e.ci(t),u_rand_seed:new e.ci(t),u_uv_offset:new e.cj(t),u_data_scale:new e.cj(t),u_data_offset:new e.ci(t),u_particle_pos_scale:new e.ci(t),u_particle_pos_offset:new e.cj(t)}),symbol:t=>({u_is_size_zoom_constant:new e.cg(t),u_is_size_feature_constant:new e.cg(t),u_size_t:new e.ci(t),u_size:new e.ci(t),u_camera_to_center_distance:new e.ci(t),u_rotate_symbol:new e.cg(t),u_aspect_ratio:new e.ci(t),u_fade_change:new e.ci(t),u_matrix:new e.ck(t),u_label_plane_matrix:new e.ck(t),u_coord_matrix:new e.ck(t),u_is_text:new e.cg(t),u_elevation_from_sea:new e.cg(t),u_pitch_with_map:new e.cg(t),u_texsize:new e.cj(t),u_texsize_icon:new e.cj(t),u_texture:new e.cg(t),u_texture_icon:new e.cg(t),u_gamma_scale:new e.ci(t),u_device_pixel_ratio:new e.ci(t),u_tile_id:new e.ch(t),u_zoom_transition:new e.ci(t),u_inv_rot_matrix:new e.ck(t),u_merc_center:new e.cj(t),u_camera_forward:new e.ch(t),u_tile_matrix:new e.ck(t),u_up_vector:new e.ch(t),u_ecef_origin:new e.ch(t),u_is_halo:new e.cg(t),u_icon_transition:new e.ci(t),u_color_adj_mat:new e.ck(t),u_scale_factor:new e.ci(t),u_ground_shadow_factor:new e.ch(t),u_inv_matrix:new e.ck(t),u_normal_scale:new e.ci(t),u_lutTexture:new e.cg(t)}),background:t=>({u_matrix:new e.ck(t),u_emissive_strength:new e.ci(t),u_opacity:new e.ci(t),u_color:new e.dA(t)}),backgroundPattern:t=>({u_matrix:new e.ck(t),u_emissive_strength:new e.ci(t),u_opacity:new e.ci(t),u_image:new e.cg(t),u_pattern_tl:new e.cj(t),u_pattern_br:new e.cj(t),u_texsize:new e.cj(t),u_pattern_size:new e.cj(t),u_pixel_coord_upper:new e.cj(t),u_pixel_coord_lower:new e.cj(t),u_pattern_units_to_pixels:new e.cj(t)}),terrainRaster:t=>({u_matrix:new e.ck(t),u_image0:new e.cg(t),u_skirt_height:new e.ci(t),u_ground_shadow_factor:new e.ch(t)}),skybox:t=>({u_matrix:new e.ck(t),u_sun_direction:new e.ch(t),u_cubemap:new e.cg(t),u_opacity:new e.ci(t),u_temporal_offset:new e.ci(t)}),skyboxGradient:t=>({u_matrix:new e.ck(t),u_color_ramp:new e.cg(t),u_center_direction:new e.ch(t),u_radius:new e.ci(t),u_opacity:new e.ci(t),u_temporal_offset:new e.ci(t)}),skyboxCapture:t=>({u_matrix_3f:new e.dB(t),u_sun_direction:new e.ch(t),u_sun_intensity:new e.ci(t),u_color_tint_r:new e.d2(t),u_color_tint_m:new e.d2(t),u_luminance:new e.ci(t)}),globeRaster:t=>({u_proj_matrix:new e.ck(t),u_globe_matrix:new e.ck(t),u_normalize_matrix:new e.ck(t),u_merc_matrix:new e.ck(t),u_zoom_transition:new e.ci(t),u_merc_center:new e.cj(t),u_image0:new e.cg(t),u_grid_matrix:new e.dB(t),u_skirt_height:new e.ci(t),u_far_z_cutoff:new e.ci(t),u_frustum_tl:new e.ch(t),u_frustum_tr:new e.ch(t),u_frustum_br:new e.ch(t),u_frustum_bl:new e.ch(t),u_globe_pos:new e.ch(t),u_globe_radius:new e.ci(t),u_viewport:new e.cj(t)}),globeAtmosphere:t=>({u_frustum_tl:new e.ch(t),u_frustum_tr:new e.ch(t),u_frustum_br:new e.ch(t),u_frustum_bl:new e.ch(t),u_horizon:new e.ci(t),u_transition:new e.ci(t),u_fadeout_range:new e.ci(t),u_atmosphere_fog_color:new e.d2(t),u_high_color:new e.d2(t),u_space_color:new e.d2(t),u_temporal_offset:new e.ci(t),u_horizon_angle:new e.ci(t)}),model:t=>({u_matrix:new e.ck(t),u_lighting_matrix:new e.ck(t),u_normal_matrix:new e.ck(t),u_node_matrix:new e.ck(t),u_lightpos:new e.ch(t),u_lightintensity:new e.ci(t),u_lightcolor:new e.ch(t),u_camera_pos:new e.ch(t),u_opacity:new e.ci(t),u_baseColorFactor:new e.d2(t),u_emissiveFactor:new e.d2(t),u_metallicFactor:new e.ci(t),u_roughnessFactor:new e.ci(t),u_baseTextureIsAlpha:new e.cg(t),u_alphaMask:new e.cg(t),u_alphaCutoff:new e.ci(t),u_baseColorTexture:new e.cg(t),u_metallicRoughnessTexture:new e.cg(t),u_normalTexture:new e.cg(t),u_occlusionTexture:new e.cg(t),u_emissionTexture:new e.cg(t),u_lutTexture:new e.cg(t),u_color_mix:new e.d2(t),u_aoIntensity:new e.ci(t),u_emissive_strength:new e.ci(t),u_occlusionTextureTransform:new e.d2(t)}),modelDepth:t=>({u_matrix:new e.ck(t),u_instance:new e.ck(t),u_node_matrix:new e.ck(t)}),groundShadow:t=>({u_matrix:new e.ck(t),u_ground_shadow_factor:new e.ch(t)}),stars:t=>({u_matrix:new e.ck(t),u_up:new e.ch(t),u_right:new e.ch(t),u_intensity_multiplier:new e.ci(t)}),snowParticle:t=>({u_modelview:new e.ck(t),u_projection:new e.ck(t),u_time:new e.ci(t),u_cam_pos:new e.ch(t),u_velocityConeAperture:new e.ci(t),u_velocity:new e.ci(t),u_horizontalOscillationRadius:new e.ci(t),u_horizontalOscillationRate:new e.ci(t),u_boxSize:new e.ci(t),u_billboardSize:new e.ci(t),u_simpleShapeParameters:new e.cj(t),u_screenSize:new e.cj(t),u_thinningCenterPos:new e.cj(t),u_thinningShape:new e.ch(t),u_thinningAffectedRatio:new e.ci(t),u_thinningParticleOffset:new e.ci(t),u_particleColor:new e.d2(t),u_direction:new e.ch(t)}),rainParticle:t=>({u_modelview:new e.ck(t),u_projection:new e.ck(t),u_time:new e.ci(t),u_cam_pos:new e.ch(t),u_texScreen:new e.cg(t),u_velocityConeAperture:new e.ci(t),u_velocity:new e.ci(t),u_boxSize:new e.ci(t),u_rainDropletSize:new e.cj(t),u_distortionStrength:new e.ci(t),u_rainDirection:new e.ch(t),u_color:new e.d2(t),u_screenSize:new e.cj(t),u_thinningCenterPos:new e.cj(t),u_thinningShape:new e.ch(t),u_thinningAffectedRatio:new e.ci(t),u_thinningParticleOffset:new e.ci(t),u_shapeDirectionalPower:new e.ci(t),u_shapeNormalPower:new e.ci(t),u_mode:new e.ci(t)}),vignette:t=>({u_vignetteShape:new e.ch(t),u_vignetteColor:new e.d2(t)}),occlusion:t=>({u_matrix:new e.ck(t),u_anchorPos:new e.ch(t),u_screenSizePx:new e.cj(t),u_occluderSizePx:new e.cj(t),u_color:new e.d2(t)})};class zo{constructor(e,t,i,r){this.id=zo.uniqueIdxCounter,zo.uniqueIdxCounter++,this.context=e;const n=e.gl;this.buffer=n.createBuffer(),this.dynamicDraw=Boolean(i),this.context.unbindVAO(),e.bindElementBuffer.set(this.buffer),n.bufferData(n.ELEMENT_ARRAY_BUFFER,t.arrayBuffer,this.dynamicDraw?n.DYNAMIC_DRAW:n.STATIC_DRAW),this.dynamicDraw||r||t.destroy()}bind(){this.context.bindElementBuffer.set(this.buffer)}updateData(e){this.id=zo.uniqueIdxCounter,zo.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)}}zo.uniqueIdxCounter=0;const Uo={Int8:"BYTE",Uint8:"UNSIGNED_BYTE",Int16:"SHORT",Uint16:"UNSIGNED_SHORT",Int32:"INT",Uint32:"UNSIGNED_INT",Float32:"FLOAT"};class No{constructor(e,t,i,r,n,o){this.length=t.length,this.attributes=i,this.itemSize=t.bytesPerElement,this.dynamicDraw=r,this.instanceCount=o,this.context=e;const s=e.gl;this.buffer=s.createBuffer(),e.bindVertexBuffer.set(this.buffer),s.bufferData(s.ARRAY_BUFFER,t.arrayBuffer,this.dynamicDraw?s.DYNAMIC_DRAW:s.STATIC_DRAW),this.dynamicDraw||n||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(let i=0;i0&&e.vertexAttribDivisor(n,i)}}destroy(){this.buffer&&(this.context.gl.deleteBuffer(this.buffer),delete this.buffer)}}class Vo{constructor(e,t,i,r,n){this.context=e,this.width=t,this.height=i;const o=this.framebuffer=e.gl.createFramebuffer();r&&(this.colorAttachment=new Fn(e,o)),n&&(this.depthAttachmentType=n,this.depthAttachment="renderbuffer"===n?new kn(e,o):new Dn(e,o))}destroy(){const e=this.context.gl;if(this.colorAttachment){const t=this.colorAttachment.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)}e.deleteFramebuffer(this.framebuffer)}}class jo{constructor(e,t){this.gl=e,this.clearColor=new tn(this),this.clearDepth=new rn(this),this.clearStencil=new nn(this),this.colorMask=new on(this),this.depthMask=new sn(this),this.stencilMask=new an(this),this.stencilFunc=new ln(this),this.stencilOp=new cn(this),this.stencilTest=new un(this),this.depthRange=new hn(this),this.depthTest=new dn(this),this.depthFunc=new pn(this),this.blend=new fn(this),this.blendFunc=new mn(this),this.blendColor=new gn(this),this.blendEquation=new _n(this),this.cullFace=new An(this),this.cullFaceSide=new yn(this),this.frontFace=new vn(this),this.program=new xn(this),this.activeTexture=new bn(this),this.viewport=new wn(this),this.bindFramebuffer=new Tn(this),this.bindRenderbuffer=new En(this),this.bindTexture=new Cn(this),this.bindVertexBuffer=new Bn(this),this.bindElementBuffer=new Sn(this),this.bindVertexArrayOES=new In(this),this.pixelStoreUnpack=new Mn(this),this.pixelStoreUnpackPremultiplyAlpha=new Pn(this),this.pixelStoreUnpackFlipY=new Rn(this),this.options=t?Object.assign({},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&&-1!==this.renderer.indexOf("PowerVR"),this.options.extTextureFloatLinearForceOff||(this.extTextureFloatLinear=e.getExtension("OES_texture_float_linear")),this.extRenderToTextureHalfFloat=e.getExtension("EXT_color_buffer_half_float"),this.extTimerQuery=e.getExtension("EXT_disjoint_timer_query_webgl2"),this.maxTextureSize=e.getParameter(e.MAX_TEXTURE_SIZE),this.maxPointSize=e.getParameter(e.ALIASED_POINT_SIZE_RANGE)[1]}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 zo(this,e,t,i)}createVertexBuffer(e,t,i,r,n){return new No(this,e,t,i,r,n)}createRenderbuffer(e,t,i){const r=this.gl,n=r.createRenderbuffer();return this.bindRenderbuffer.set(n),r.renderbufferStorage(r.RENDERBUFFER,e,t,i),this.bindRenderbuffer.set(null),n}createFramebuffer(e,t,i,r){return new Vo(this,e,t,i,r)}clear({color:e,depth:t,stencil:i,colorMask:r}){const n=this.gl;let o=0;e&&(o|=n.COLOR_BUFFER_BIT,this.clearColor.set(e.toNonPremultipliedRenderColor(null)),this.colorMask.set(r||[!0,!0,!0,!0])),void 0!==t&&(o|=n.DEPTH_BUFFER_BIT,this.depthRange.set([0,1]),this.clearDepth.set(t),this.depthMask.set(!0)),void 0!==i&&(o|=n.STENCIL_BUFFER_BIT,this.clearStencil.set(i),this.stencilMask.set(255)),n.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.bx(t.blendFunction,Qi.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)}}let Go;function Ho(t,i,r,n,o,s,a){const l=t.context,c=l.gl,u=t.transform,h=[e.aF(u.center.lng),e.aJ(u.center.lat)],d=r.layout.get("symbol-placement"),p=r.layout.get("text-variable-anchor"),f="map"===r.layout.get("icon-rotation-alignment"),m="map"===r.layout.get("text-rotation-alignment"),g="point"!==d,_=[];let A=0,y=0;for(let l=0;l0){const t=e.bB(),i=L;e.cO(t,x.placementInvProjMatrix,u.glCoordMatrix),e.cO(t,t,x.placementViewportMatrix),_.push({circleArray:k,circleOffset:y,transform:i,invTransform:t,projection:x.getProjection()}),A+=k.length/4,y=A}if(!F)continue;t.terrain&&t.terrain.setupElevationDraw(v,R);const D=M?[d.canonical.x,d.canonical.y,1<=0&&(f[y.associatedIconIndex]={x:C,y:B,z:S,angle:L})}else fi(b,d)}if(u){p.clear();const i=t.icon.placedSymbolArray;for(let t=0;t{let i=[0,0,0];if(e){const e=t.style.directionalLight,r=t.style.ambientLight;e&&r&&(i=fr(t.style,e,r))}return i},Q=e=>{C.depthOcclusionForSymbolsAndCircles&&(r.hasOcclusionOpacityProperties||t.terrain)&&(e.push("DEPTH_D24"),e.push("DEPTH_OCCLUSION"))},$=i=>{r.lut&&!w&&(r.lut.texture||(r.lut.texture=new e.d_(t.context,r.lut.image,[r.lut.image.height,r.lut.image.height,r.lut.image.height],T.gl.RGBA8)),T.activeTexture.set(T.gl.TEXTURE0+rr.LUT),r.lut.texture&&r.lut.texture.bind(T.gl.LINEAR,T.gl.CLAMP_TO_EDGE),i.push("APPLY_LUT_ON_GPU"))},Z=()=>{const i=B&&"point"!==r.layout.get("symbol-placement"),a=[];Q(a),$(a);const c=i||V,h="road"===s.elevationType,_=t.shadowRenderer,w=h&&I&&!!_&&_.enabled,T=H(w),S=h&&I&&!t.terrain?F:L,M=r.paint.get("icon-image-cross-fade");t.terrainRenderModeElevated()&&I&&a.push("PITCH_WITH_MAP_TERRAIN"),d&&(a.push("PROJECTION_GLOBE_VIEW"),c&&a.push("PROJECTED_POS_ON_VIEWPORT")),M>0&&s.hasAnySecondaryIcon&&a.push("ICON_TRANSITION"),!s.icon.zOffsetVertexBuffer||h&&t.terrain||a.push("Z_OFFSET"),0===A&&0===y&&0===v&&1===x||a.push("COLOR_ADJUSTMENT"),s.sdfIcons&&a.push("RENDER_SDF"),w&&a.push("RENDER_SHADOWS","DEPTH_TEXTURE","NORMAL_OFFSET"),h&&I&&!t.terrain&&s.icon.orientationVertexBuffer&&a.push("ELEVATED_ROADS");const P=s.icon.programConfigurations.get(r.id),R=t.getOrCreateProgram("symbol",{config:P,defines:a}),D=n.imageAtlasTexture?n.imageAtlasTexture.size:[0,0],z=s.iconSizeData,N=e.bJ(z,C.zoom),Z=I||!C.isOrthographic,W=ti(f,n.tileID.canonical,I,B,C,s.getProjection(),m),q=ri(f,n.tileID.canonical,I,B,C,s.getProjection(),m),K=t.translatePosMatrix(q,n,l,u,!0),X=t.translatePosMatrix(f,n,l,u),J=c?Qo:W,Y=B&&!I&&!i;let ee=U;!O&&!C.mercatorFromTransition||B||(ee=$o(C));const te=d?ee:U,ie=r.getColorAdjustmentMatrix(A,y,v,x),re=Po(z.kind,N,Y,I,t,X,J,K,b,!1,D,[0,0],0,o,p,k,j,te,s.getProjection(),T,G,ie,M,null),ne=n.imageAtlasTexture?n.imageAtlasTexture:null,oe=1!==r.layout.get("icon-size").constantOr(0)||s.iconsNeedLinear,se=s.sdfIcons||t.options.rotating||t.options.zooming||oe||Z?E.LINEAR:E.NEAREST,ae=s.sdfIcons&&0!==r.paint.get("icon-halo-width").constantOr(1),le=t.terrain&&I&&i?e.bk(e.bB(),W):Qo;if(i&&s.icon){const i=e.bU.getAtTileOffsetFunc(o,C.center.lat,C.worldSize,s.getProjection()),a=ii(f,n.tileID.canonical,I,B,C,s.getProjection(),m),l=r.layout.get("icon-size-scale-range"),c=e.aA(t.scaleFactor,l[0],l[1]);ai(s,f,t,!1,a,q,I,g,i,o,c)}return{program:R,buffers:s.icon,uniformValues:re,atlasTexture:ne,atlasTextureIcon:null,atlasInterpolation:se,atlasInterpolationIcon:null,isSDF:s.sdfIcons,hasHalo:ae,depthMode:S,tile:n,renderWithShadows:w,labelPlaneMatrixInv:le}},W=()=>{const i=S&&"point"!==r.layout.get("symbol-placement"),a=[],l=i||D||V,u="road"===s.elevationType,g=t.shadowRenderer,A=u&&M&&!!g&&g.enabled,y=H(A),v=u&&M&&!t.terrain?F:L;t.terrainRenderModeElevated()&&M&&a.push("PITCH_WITH_MAP_TERRAIN"),d&&(a.push("PROJECTION_GLOBE_VIEW"),l&&a.push("PROJECTED_POS_ON_VIEWPORT")),!s.text.zOffsetVertexBuffer||u&&t.terrain||a.push("Z_OFFSET"),s.iconsInText&&a.push("RENDER_TEXT_AND_SYMBOL"),a.push("RENDER_SDF"),A&&a.push("RENDER_SHADOWS","DEPTH_TEXTURE","NORMAL_OFFSET"),u&&M&&!t.terrain&&s.text.orientationVertexBuffer&&a.push("ELEVATED_ROADS"),Q(a);const x=s.text.programConfigurations.get(r.id),w=t.getOrCreateProgram("symbol",{config:x,defines:a});let T,B=[0,0],I=null;const P=s.textSizeData;s.iconsInText&&(B=n.imageAtlasTexture?n.imageAtlasTexture.size:[0,0],I=n.imageAtlasTexture?n.imageAtlasTexture:null,T=M||!C.isOrthographic||t.options.rotating||t.options.zooming||"composite"===P.kind||"camera"===P.kind?E.LINEAR:E.NEAREST);const R=n.glyphAtlasTexture?n.glyphAtlasTexture.size:[0,0],z=r.layout.get("text-size-scale-range"),N=e.aA(t.scaleFactor,z[0],z[1]),$=e.bJ(P,C.zoom,N),Z=ti(f,n.tileID.canonical,M,S,C,s.getProjection(),m),W=ri(f,n.tileID.canonical,M,S,C,s.getProjection(),m),q=t.translatePosMatrix(W,n,c,h,!0),K=t.translatePosMatrix(f,n,c,h),X=l?Qo:Z,J=S&&!M&&!i;let Y=U;!O&&!C.mercatorFromTransition||S||(Y=$o(C));const ee=Po(P.kind,$,J,M,t,K,X,q,b,!0,R,B,0,o,p,k,j,d?Y:U,s.getProjection(),y,G,null,null,N),te=n.glyphAtlasTexture?n.glyphAtlasTexture:null,ie=E.LINEAR,re=0!==r.paint.get("text-halo-width").constantOr(1),ne=t.terrain&&M&&i?e.bk(e.bB(),Z):Qo;if(i&&s.text){const i=e.bU.getAtTileOffsetFunc(o,C.center.lat,C.worldSize,s.getProjection()),r=ii(f,n.tileID.canonical,M,S,C,s.getProjection(),m);ai(s,f,t,!0,r,W,M,_,i,o,N)}return{program:w,buffers:s.text,uniformValues:ee,atlasTexture:te,atlasTextureIcon:I,atlasInterpolation:ie,atlasInterpolationIcon:T,isSDF:!0,hasHalo:re,depthMode:v,tile:n,renderWithShadows:A,labelPlaneMatrixInv:ne}},q=s.icon.segments.get().length,K=s.text.segments.get().length,X=q&&!a.onlyText?Z():null,J=K&&!a.onlyIcons?W():null,Y=r.paint.get("icon-opacity").constantOr(1),ee=r.paint.get("text-opacity").constantOr(1);if(P&&s.canOverlap){R=!0;const t=Y&&!a.onlyText?s.icon.segments.get():[],i=ee&&!a.onlyIcons?s.text.segments.get():[];for(const i of t)z.push({segments:new e.bf([i]),sortKey:i.sortKey,state:X});for(const t of i)z.push({segments:new e.bf([t]),sortKey:t.sortKey,state:J})}else a.onlyText||z.push({segments:Y?s.icon.segments:new e.bf([]),sortKey:0,state:X}),a.onlyIcons||z.push({segments:ee?s.text.segments:new e.bf([]),sortKey:0,state:J})}R&&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:C.depthOcclusionForSymbolsAndCircles,labelPlaneMatrixInv:i.labelPlaneMatrixInv}):t.setupDepthForOcclusion(C.depthOcclusionForSymbolsAndCircles,i.program),T.activeTexture.set(E.TEXTURE0),i.atlasTexture&&i.atlasTexture.bind(i.atlasInterpolation,E.CLAMP_TO_EDGE,!0),i.atlasTextureIcon&&(T.activeTexture.set(E.TEXTURE1),i.atlasTextureIcon&&i.atlasTextureIcon.bind(i.atlasInterpolationIcon,E.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 n=i.uniformValues;n.u_is_halo=1,Ko(i.buffers,e.segments,r,t,i.program,i.depthMode,o,s,n,2),n.u_is_halo=0}else{if(i.isSDF){const n=i.uniformValues;i.hasHalo&&(n.u_is_halo=1,Ko(i.buffers,e.segments,r,t,i.program,i.depthMode,o,s,n,1)),n.u_is_halo=0}Ko(i.buffers,e.segments,r,t,i.program,i.depthMode,o,s,i.uniformValues,1)}}}function Ko(e,t,i,r,n,o,s,a,l,c){const u=[e.dynamicLayoutVertexBuffer,e.opacityVertexBuffer,e.iconTransitioningVertexBuffer,e.globeExtVertexBuffer,e.zOffsetVertexBuffer,e.orientationVertexBuffer];n.draw(r,r.context.gl.TRIANGLES,o,s,a,Xi.disabled,l,i.id,e.layoutVertexBuffer,e.indexBuffer,t,i.paint,r.transform.zoom,e.programConfigurations.get(i.id),u,c)}function Xo(t,i){const r=1<=or?1:t.pitch/or))),2*i}(t.transform),u=t.transform.getFreeCameraOptions().position,h="elevatedStructuresDepthReconstruct",d=t.getOrCreateProgram(h,{defines:["DEPTH_RECONSTRUCTION"]}),p=t.getOrCreateProgram(h);for(const e of n){const n=i.getTile(e),h=n.getBucket(r);if(!h)continue;const f=h.elevatedStructures;if(!f)continue;const m=h.elevationBufferData.heightRange,g=Xo(e.toUnwrapped(),u),_=t.translatePosMatrix(e.projMatrix,n,r.paint.get("fill-translate"),r.paint.get("fill-translate-anchor"));let A,y,v,x;if("initialize"===o){if(!m||m.min>=1||0===f.depthSegments.segments[0].primitiveLength)continue;A=fo(_,g,c,1,0),y=a,v=f.depthSegments,x=d}else if("reset"===o){if(!m||m.min>=0||0===f.maskSegments.segments[0].primitiveLength)continue;A=fo(_,g,0,0,1),y=l,v=f.maskSegments,x=d}else if("geometry"===o){if(0===f.depthSegments.segments[0].primitiveLength)continue;A=fo(_,g,c,1,0),y=a,v=f.depthSegments,x=p}x.draw(t,s.TRIANGLES,y,Wi.disabled,Qi.disabled,Xi.disabled,A,r.id,f.vertexBuffer,f.indexBuffer,v,r.paint,t.transform.zoom)}}function Yo(t,i,r){const{painter:n,sourceCache:o,layer:s,coords:a,colorMode:l,elevationType:c,terrainEnabled:u,pass:h}=t,d=n.context.gl,p=s.paint.get("fill-pattern"),f=s.paint.get("fill-pattern-cross-fade"),m=p.constantOr(null);let g=c;"road"!==c||i&&!u||(g="none");const _="road"===g,A=t.painter.shadowRenderer,y=_&&!!A&&A.enabled,v=new $i(n.context.gl.LEQUAL,$i.ReadOnly,n.depthRangeFor3D);let x=[0,0,0];if(y){const e=n.style.directionalLight,t=n.style.ambientLight;e&&t&&(x=fr(n.style,e,t))}const b=p&&p.constantOr(1),w=(t,h)=>{let p,g,w,T,E;h?(p=b&&!s.getPaintProperty("fill-outline-color")?"fillOutlinePattern":"fillOutline",w=d.LINES):(p=b?"fillPattern":"fill",w=d.TRIANGLES);for(const C of a){const a=o.getTile(C);if(b&&!a.patternsLoaded())continue;const B=a.getBucket(s);if(!B)continue;const S=i?B.elevationBufferData:B.bufferData;if(S.isEmpty())continue;n.prepareDrawTile();const I=S.programConfigurations.get(s.id),M=n.isTileAffectedByFog(C),P=[],R=[];_&&(P.push("ELEVATED_ROADS"),R.push(S.elevatedLayoutVertexBuffer)),y&&P.push("RENDER_SHADOWS","DEPTH_TEXTURE","NORMAL_OFFSET"),b&&(n.context.activeTexture.set(d.TEXTURE0),a.imageAtlasTexture&&a.imageAtlasTexture.bind(d.LINEAR,d.CLAMP_TO_EDGE),I.updatePaintBuffers());let L=!1;if(m&&a.imageAtlas){const t=a.imageAtlas,i=e.e2.from(m),r=i.getPrimary().scaleSelf(e.o.devicePixelRatio).toString(),n=i.getSecondary(),o=t.patternPositions.get(r),s=n?t.patternPositions.get(n.scaleSelf(e.o.devicePixelRatio).toString()):null;L=!!o&&!!s,o&&I.setConstantPatternPositions(o,s)}f>0&&(L||I.getPatternTransitionVertexBuffer("fill-pattern"))&&P.push("FILL_PATTERN_TRANSITION");const F=n.getOrCreateProgram(p,{config:I,overrideFog:M,defines:P}),k=n.translatePosMatrix(C.projMatrix,a,s.paint.get("fill-translate"),s.paint.get("fill-translate-anchor"));y&&A.setupShadows(a.tileID.toUnwrapped(),F,"vector-tile");const D=s.paint.get("fill-emissive-strength");if(h){T=S.lineIndexBuffer,E=S.lineSegments;const e=n.terrain&&n.terrain.renderingToTexture?n.terrain.drapeBufferSize:[d.drawingBufferWidth,d.drawingBufferHeight];g="fillOutlinePattern"===p&&b?ho(k,D,n,a,e,x,f):uo(k,D,e,x)}else T=S.indexBuffer,E=S.triangleSegments,g=b?co(k,D,n,a,x,f):lo(k,D,x);n.uploadCommonUniforms(n.context,F,C.toUnwrapped());let O=t;("road"===c&&!u||"offset"===c)&&(O=v),F.draw(n,w,O,r||n.stencilModeForClipping(C),l,Xi.disabled,g,s.id,S.layoutVertexBuffer,T,E,s.paint,n.transform.zoom,I,R)}};n.renderPass===h&&w(n.depthModeForSublayer(1,"opaque"===n.renderPass?$i.ReadWrite:$i.ReadOnly),!1),"none"===g&&"translucent"===n.renderPass&&s.paint.get("fill-antialias")&&w(n.depthModeForSublayer(s.getPaintProperty("fill-outline-color")?2:0,$i.ReadOnly),!0)}function es(t,i,r,n,o,s,a,l){r.resetLayerRenderingStats(t);const c=t.context,u=c.gl,h=t.transform,d=r.paint.get("fill-extrusion-pattern"),p=r.paint.get("fill-extrusion-pattern-cross-fade"),f=d.constantOr(null),m=d.constantOr(1),g=r.paint.get("fill-extrusion-opacity"),_=t.style.enable3dLights(),A=r.paint.get(_&&!m?"fill-extrusion-ambient-occlusion-wall-radius":"fill-extrusion-ambient-occlusion-radius"),y=[r.paint.get("fill-extrusion-ambient-occlusion-intensity"),A],v=r.layout.get("fill-extrusion-edge-radius"),x=v>0&&!r.paint.get("fill-extrusion-rounded-roof"),b=x?0:v,w="globe"===h.projection.name?e.ea():0,T="globe"===h.projection.name,E=T?e.aj(h.zoom):0,C=[e.aF(h.center.lng),e.aJ(h.center.lat)],B="none"===r.paint.get("fill-extrusion-flood-light-color-use-theme").constantOr("default"),S=r.paint.get("fill-extrusion-flood-light-color").toNonPremultipliedRenderColor(B?null:r.lut).toArray01().slice(0,3),I=r.paint.get("fill-extrusion-flood-light-intensity"),M=r.paint.get("fill-extrusion-vertical-scale"),P=0!==r.paint.get("fill-extrusion-line-width").constantOr(1),R=r.paint.get("fill-extrusion-height-alignment"),L=r.paint.get("fill-extrusion-base-alignment"),F=ar(t,r.paint.get("fill-extrusion-cutoff-fade-range")),k=[];let D;T&&k.push("PROJECTION_GLOBE_VIEW"),y[0]>0&&k.push("FAUX_AO"),x&&k.push("ZERO_ROOF_RADIUS"),l&&k.push("HAS_CENTROID"),I>0&&k.push("FLOOD_LIGHT"),F.shouldRenderCutoff&&k.push("RENDER_CUTOFF"),P&&k.push("RENDER_WALL_MODE");const O="shadow"===t.renderPass,z=t.shadowRenderer,U=O&&!!z,N=O?Xi.disabled:Xi.backCCW;t.shadowRenderer&&(t.shadowRenderer.useNormalOffset=!0);let V=[0,0,0];if(z){const e=t.style.directionalLight,i=t.style.ambientLight;e&&i&&(V=fr(t.style,e,i)),O||(k.push("RENDER_SHADOWS","DEPTH_TEXTURE"),z.useNormalOffset&&k.push("NORMAL_OFFSET")),D=k.concat(["SHADOWS_SINGLE_CASCADE"])}const j=U?"fillExtrusionDepth":m?"fillExtrusionPattern":"fillExtrusion",G=r.getLayerRenderingStats();for(const d of n){const n=i.getTile(d),_=n.getBucket(r);if(!_||_.projection.name!==h.projection.name)continue;let A=!1;z&&(A=0===z.getMaxCascadeForTile(d.toUnwrapped()));const v=t.isTileAffectedByFog(d),x=_.programConfigurations.get(r.id);let B=!1;if(f&&n.imageAtlas){const t=n.imageAtlas,i=e.e2.from(f),r=i.getPrimary().scaleSelf(e.o.devicePixelRatio).toString(),o=i.getSecondary(),s=t.patternPositions.get(r),a=o?t.patternPositions.get(o.scaleSelf(e.o.devicePixelRatio).toString()):null;B=!!s&&!!a,s&&x.setConstantPatternPositions(s,a)}p>0&&(B||x.getPatternTransitionVertexBuffer("fill-extrusion-pattern"))&&k.push("FILL_EXTRUSION_PATTERN_TRANSITION");const U=t.getOrCreateProgram(j,{config:x,defines:A?D:k,overrideFog:v});if(t.terrain&&t.terrain.setupElevationDraw(n,U,{useMeterToDem:!0}),!_.centroidVertexBuffer){const e=U.getAttributeLocation(u,"a_centroid_pos");-1!==e&&u.vertexAttrib2f(e,0,0)}!O&&z&&z.setupShadows(n.tileID.toUnwrapped(),U,"vector-tile"),m&&(t.context.activeTexture.set(u.TEXTURE0),n.imageAtlasTexture&&n.imageAtlasTexture.bind(u.LINEAR,u.CLAMP_TO_EDGE),x.updatePaintBuffers());const H=r.paint.get("fill-extrusion-vertical-gradient"),Q=1/_.tileToMeter;let $;if(O&&z){if(as(n.tileID,_.maxHeight,t))continue;const e=z.calculateShadowPassMatrixFromTile(n.tileID.toUnwrapped());$=oo(e,b,Q,M,R,L)}else{const e=t.translatePosMatrix(d.expandedProjMatrix,n,r.paint.get("fill-extrusion-translate"),r.paint.get("fill-extrusion-translate-anchor")),i=h.projection.createInversionMatrix(h,d.canonical);$=m?so(e,t,H,g,y,b,Q,d,n,w,R,L,E,C,i,S,M,p):no(e,t,H,g,y,b,Q,d,w,R,L,E,C,i,S,M,I,V)}t.uploadCommonUniforms(c,U,d.toUnwrapped(),null,F);let Z=_.segments;if("mercator"===h.projection.name&&!O&&(Z=_.getVisibleSegments(n.tileID,t.terrain,t.transform.getFrustum(0)),!Z.get().length))continue;if(G)if(O)for(const e of Z.get())G.numRenderedVerticesInShadowPass+=e.primitiveLength;else for(const e of Z.get())G.numRenderedVerticesInTransparentPass+=e.primitiveLength;const W=[];(t.terrain||l)&&W.push(_.centroidVertexBuffer),T&&W.push(_.layoutVertexExtBuffer),P&&W.push(_.wallVertexBuffer),U.draw(t,c.gl.TRIANGLES,o,s,a,N,$,r.id,_.layoutVertexBuffer,_.indexBuffer,Z,r.paint,t.transform.zoom,x,W)}t.shadowRenderer&&(t.shadowRenderer.useNormalOffset=!1)}class ts{constructor(){this.translate=[0,0],this.translateAnchor="map",this.edgeRadius=0,this.cutoffFadeRange=0}}function is(t,i,r,n,o,s,a,l,c,u,h,d,p,f,m,g,_,A,y,v){const x=i.context,b=x.gl,w=i.transform,T=i.transform.zoom,E=[],C=t.translate,B=t.translateAnchor,S=t.edgeRadius,I=ar(i,t.cutoffFadeRange);"clear"===h?(E.push("CLEAR_SUBPASS"),v&&(E.push("CLEAR_FROM_TEXTURE"),x.activeTexture.set(b.TEXTURE0),v.bind(b.LINEAR,b.CLAMP_TO_EDGE))):"sdf"===h&&E.push("SDF_SUBPASS"),A&&E.push("HAS_CENTROID"),I.shouldRenderCutoff&&E.push("RENDER_CUTOFF");const M=(e,t,r,o,h)=>{let y=E;null!=t.groundRadiusBuffer&&(y=E.concat("HAS_ATTRIBUTE_a_flood_light_ground_radius"));const b=t.programConfigurations.get(n.id),w=i.isTileAffectedByFog(e),C=i.getOrCreateProgram("fillExtrusionGroundEffect",{config:b,defines:y,overrideFog:w}),B=ao(i,o,d,u,h,[p,f*h],m,g,_,T>=17?0:S*h,v?v.size[0]:0),M=[];A&&M.push(t.hiddenByLandmarkVertexBuffer),null!=t.groundRadiusBuffer&&M.push(t.groundRadiusBuffer),i.uploadCommonUniforms(x,C,e.toUnwrapped(),null,I),C.draw(i,x.gl.TRIANGLES,s,a,l,c,B,n.id,t.vertexBuffer,t.indexBuffer,r,n.paint,T,b,M)};for(const t of o){const o=r.getTile(t),s=o.getBucket(n);if(!s||s.projection.name!==w.projection.name||!s.groundEffect||s.groundEffect&&!s.groundEffect.hasData())continue;const a=s.groundEffect,l=1/s.tileToMeter;{const e=i.translatePosMatrix(t.projMatrix,o,C,B),r=a.getDefaultSegment();M(t,a,r,e,l)}if(y)for(let s=0;s<4;s++){const a=e.e8[s](t),c=r.getTile(a);if(!c)continue;const u=c.getBucket(n);if(!u||u.projection.name!==w.projection.name||!u.groundEffect||u.groundEffect&&!u.groundEffect.hasData())continue;const h=u.groundEffect;let d,p;0===s?(d=[-e.al,0,0],p=1):1===s?(d=[e.al,0,0],p=0):2===s?(d=[0,-e.al,0],p=3):(d=[0,e.al,0],p=2);const f=h.regionSegments[p];if(!f)continue;const m=new Float32Array(16);e.bq(m,t.projMatrix,d),M(t,h,f,i.translatePosMatrix(m,o,C,B),l)}}}function rs(t,i,r,n,o,s,a){0===n.centroidVertexArray.length&&n.createCentroidsBuffer();const l=s?s.findDEMTileFor(r):null;if(!(l&&l.dem||a))return;s&&l&&l.dem&&n.selfDEMTileTimestamp!==l.dem._timestamp&&(n.borderDoneWithNeighborZ=[-1,-1,-1,-1],n.selfDEMTileTimestamp=l.dem._timestamp);const c=t=>new e.P(Math.ceil((t+e.ec)*e.ed),0),u=e=>{const t=i.getSource().minzoom,r=e=>{const t=i.getTileByID(e);if(t&&t.hasData())return t.getBucket(o)},n=[0,-1,1];for(const i of n){if(e.overscaledZ+i(h[0]=Math.min(t.min.y,i.min.y),h[1]=Math.max(t.max.y,i.max.y),h[2]=e.al-i.min.x>t.max.x?i.min.x-e.al:t.max.x,h),p=(t,i)=>(h[0]=Math.min(t.min.x,i.min.x),h[1]=Math.max(t.max.x,i.max.x),h[2]=e.al-i.min.y>t.max.y?i.min.y-e.al:t.max.y,h),f=[(e,t)=>d(e,t),(e,t)=>d(t,e),(e,t)=>p(e,t),(e,t)=>p(t,e)],m=(t,i,n,o,a,c,u)=>{if(!s)return 0;const h=[[c?n:t,c?t:n,0],[c?n:i,c?i:n,0]],d=u<0?e.al+u:u,p=[c?d:(t+i)/2,c?(t+i)/2:d,0];return 0===n&&u<0||0!==n&&u>0?s.getForTilePoints(a,[p],!0,o):h.push(p),s.getForTilePoints(r,h,!0,l),Math.max(h[0][2],h[1][2],p[2])/s.exaggeration()};for(let t=0;t<4;t++){const i=n.borderFeatureIndices[t];if(0===i.length)continue;const o=e.e8[t](r),l=u(o);if(!(l&&l instanceof e.e9))continue;const h=s?s.findDEMTileFor(o):null;if(!(h&&h.dem||a))continue;if(s&&h&&h.dem&&n.borderDEMTileTimestamp[t]!==h.dem._timestamp&&(n.borderDoneWithNeighborZ[t]=-1,n.borderDEMTileTimestamp[t]=h.dem._timestamp),n.borderDoneWithNeighborZ[t]===l.canonical.z)continue;0===l.centroidVertexArray.length&&l.createCentroidsBuffer();const d=(t<2?1:5)-t,p=l.borderDoneWithNeighborZ[d]!==n.canonical.z,A=l.borderFeatureIndices[d];let y=0;if(n.canonical.z!==l.canonical.z){for(const e of i)n.showCentroid(n.featuresOnBorder[e]);if(p)for(const e of A)l.showCentroid(l.featuresOnBorder[e]);n.borderDoneWithNeighborZ[t]=l.canonical.z,l.borderDoneWithNeighborZ[d]=n.canonical.z}for(const r of i){const i=n.featuresOnBorder[r],s=n.centroidData[i.centroidDataIndex],u=i.borders[t];let p;for(;yu[0]+3||e[0]>u[0]-3)break;l.showCentroid(p),y++}if(p&&yu[1]-3)&&(v++,++y!==A.length);)p=l.featuresOnBorder[A[y]];p=l.featuresOnBorder[A[r]];let x=!1;if(v>=1){const e=p.borders[d];Math.abs(u[0]-e[0])<3&&Math.abs(u[1]-e[1])<3&&(v=1,x=!0,y=r+1)}else if(0===v){n.showCentroid(i);continue}const b=l.centroidData[p.centroidDataIndex];a&&x&&(((g=s).flags|(_=b).flags)&e.eb?(g.flags|=e.eb,_.flags|=e.eb):(g.flags&=~e.eb,_.flags&=~e.eb));const w=i.intersectsCount()>1||p.intersectsCount()>1;if(v>1)y=r,s.centroidXY=b.centroidXY=new e.P(0,0);else if(h&&h.dem&&!w){const i=f[t](s,b),r=t%2?e.al-1:0,n=m(i[0],Math.min(e.al-1,i[1]),r,h,o,t<2,i[2]);s.centroidXY=b.centroidXY=c(n)}else w?s.centroidXY=b.centroidXY=new e.P(0,0):(s.centroidXY=n.encodeBorderCentroid(i),b.centroidXY=l.encodeBorderCentroid(p));n.writeCentroidToBuffer(s),l.writeCentroidToBuffer(b)}else n.showCentroid(i)}n.borderDoneWithNeighborZ[t]=l.canonical.z,l.borderDoneWithNeighborZ[d]=n.canonical.z}var g,_;(n.needsCentroidUpdate||!n.centroidVertexBuffer&&0!==n.centroidVertexArray.length)&&n.uploadCentroid(t)}const ns=[1,0,0],os=[0,1,0],ss=[0,0,1];function as(t,i,r){const n=r.transform,o=r.shadowRenderer;if(!o)return!0;const s=t.toUnwrapped(),a=n.tileSize*o._cascades[r.currentShadowCascade].scale;let l=i;if(n.elevation){const e=n.elevation.getMinMaxForTile(t);e&&(l+=e.max)}const c=[...o.shadowDirection];c[2]=-c[2];const u=o.computeSimplifiedTileShadowVolume(s,l,a,c);if(!u)return!1;const h=[ns,os,ss,c,[c[0],0,c[2]],[0,c[1],c[2]]],d="globe"===n.projection.name,p=n.scaleZoom(a),f=e.cA.fromInvProjectionMatrix(n.invProjMatrix,n.worldSize,p,!d),m=o.getCurrentCascadeFrustum();return 0===f.intersectsPrecise(u.vertices,u.planes,h)||0===m.intersectsPrecise(u.vertices,u.planes,h)}function ls(t){const{painter:i,source:r,layer:n,coords:o}=t;let s=t.defines;const a=i.context,l="shadow"===i.renderPass,c="light-beam"===i.renderPass,u=i.shadowRenderer,h=e.ee(i.transform.center.lat,i.transform.zoom),d=ar(i,n.paint.get("building-cutoff-fade-range"));d.shouldRenderCutoff&&(s=s.concat("RENDER_CUTOFF")),t.floodLightIntensity>0&&(s=s.concat("FLOOD_LIGHT"));for(const p of o){const o=r.getTile(p),f=o.getBucket(n);if(!f)continue;u&&0===u.getMaxCascadeForTile(p.toUnwrapped())&&(s=s.concat("SHADOWS_SINGLE_CASCADE"));const m=f.programConfigurations.get(n.id);let g,_,A,y=i.translatePosMatrix(p.expandedProjMatrix,o,[0,0],"map");if(y=e.cR(e.bB(),y,[1,1,t.verticalScale]),l&&u){if(as(o.tileID,f.maxHeight*h,i))continue;let r=u.calculateShadowPassMatrixFromTile(o.tileID.toUnwrapped());r=e.cR(e.bB(),r,[1,1,t.verticalScale]),A=_o(r),g=_=i.getOrCreateProgram("buildingDepth",{config:m,defines:s,overrideFog:!1})}else if(c)g=_=i.getOrCreateProgram("buildingBloom",{config:m,defines:s,overrideFog:!1}),A=go(y);else{const r=i.transform.calculatePosMatrix(p.toUnwrapped(),i.transform.worldSize);e.cR(r,r,[1,1,t.verticalScale]);const n=e.bB();e.cR(n,r,[1,-1,1/h]),e.bk(n,n),e.ef(n,n);const o=i.transform.getFreeCameraOptions().position,a=1<{if(c){const o=e.entranceBloom;r.draw(i,a.gl.TRIANGLES,t.depthMode,Wi.disabled,t.blendMode,Xi.disabled,A,n.id,o.layoutVertexBuffer,o.indexBuffer,o.segmentsBucket,n.paint,i.transform.zoom,m,[o.layoutAttenuationBuffer,o.layoutColorBuffer])}else{const o=e.segmentsBucket;let s=[e.layoutNormalBuffer,e.layoutCentroidBuffer,e.layoutColorBuffer,e.layoutFloodLightDataBuffer];e.layoutFacadePaintBuffer&&(s=s.concat([e.layoutFacadeDataBuffer,e.layoutFacadeVerticalRangeBuffer,e.layoutFacadePaintBuffer])),r.draw(i,a.gl.TRIANGLES,t.depthMode,Wi.disabled,t.blendMode,l?Xi.disabled:Xi.backCW,A,n.id,e.layoutVertexBuffer,e.indexBuffer,o,n.paint,i.transform.zoom,m,s)}};i.uploadCommonUniforms(a,_,p.toUnwrapped(),null,d),f.buildingWithoutFacade&&v(f.buildingWithoutFacade,_),f.buildingWithFacade&&(g!==_&&i.uploadCommonUniforms(a,g,p.toUnwrapped(),null,d),v(f.buildingWithFacade,g))}}function cs(t,i,r,n,o,s,a,l,c,u,h,d,p){const f=t.context.gl,m=t.depthModeForSublayer(1,$i.ReadOnly,f.LEQUAL,!0),g=.1*(1-(_=h))+3*_;var _;const A=t._showOverdrawInspector,y=d,v=new ts;A||is(v,t,i,r,n,m,new Wi({func:f.ALWAYS,mask:255},255,255,f.KEEP,f.KEEP,f.REPLACE),new Qi([f.ONE,f.ONE,f.ONE,f.ONE],e.ao.transparent,[!1,!1,!1,!0],f.MIN),Xi.disabled,o,"sdf",s,a,l,c,u,g,y,!1);{const h=A?Wi.disabled:new Wi({func:f.EQUAL,mask:255},255,255,f.KEEP,f.DECR,f.DECR),d=A?t.colorModeForRenderPass():new Qi([f.ONE_MINUS_DST_ALPHA,f.DST_ALPHA,f.ONE,f.ONE],e.ao.transparent,[!0,!0,!0,!0]);is(v,t,i,r,n,m,h,d,Xi.disabled,o,"color",s,a,l,c,u,g,y,!1)}}function us(t){return[t[0]*e.eg,t[1]*e.eg,t[2]*e.eg,0]}function hs(t,i,r,n,o,s,a,l,c){const u=n.getSource(),h=r.globeSharedBuffers;if(!h)return;let d,p,f;if(i&&(d=n.getTile(i)),u instanceof e.aT?(p=u.texture,f=e.dJ(0,0,r.transform)):d&&i&&(p=d.texture,f=e.dJ(i.canonical.z,i.canonical.x,r.transform)),!p||!f)return;t||(f=e.cR(e.bB(),f,[1,-1,1]));const m=r.context,g=m.gl,_="nearest"===o.paint.get("raster-resampling")?g.NEAREST:g.LINEAR,A=r.colorModeForDrapableLayerRenderPass(s),y=a.defines;y.push("GLOBE_POLES");const v=new $i(g.LEQUAL,$i.ReadWrite,r.depthRangeFor3D),x=Float32Array.from(r.transform.expandedFarZProjMatrix),b=Float32Array.from(e.bj(e.dI(new e.cC(0,0,0))));r.terrain&&r.terrain.prepareDrawTile(),m.activeTexture.set(g.TEXTURE0),p.bind(_,g.CLAMP_TO_EDGE),m.activeTexture.set(g.TEXTURE1),p.bind(_,g.CLAMP_TO_EDGE),"useMipmap"in p&&m.extTextureFilterAnisotropic&&r.transform.pitch>20&&g.texParameterf(g.TEXTURE_2D,m.extTextureFilterAnisotropic.TEXTURE_MAX_ANISOTROPY_EXT,m.extTextureFilterAnisotropicMax);const[w,T,E,C]=i?h.getPoleBuffers(i.canonical.z,!1):h.getPoleBuffers(0,!0),B=o.paint.get("raster-elevation");let S;t?(S=w,r.renderDefaultNorthPole=0!==B):(S=T,r.renderDefaultSouthPole=0!==B);const I=us(a.mix),M=((e,t,i,r,n,o,s,a,l,c,u,h,d)=>To(e,t,i,new Float32Array(16),new Float32Array(9),[0,0],r,[0,0],[0,0,0,0],1,{opacity:1,mix:0},o,[0,0]||[0,0],a,2,c,u,h,1,0,d))(x,b,f,e.aj(r.transform.zoom),0,o,0,B,0,I,a.offset,a.range,s),P=r.getOrCreateProgram("raster",{defines:y});r.uploadCommonUniforms(m,P,null),P.draw(r,g.TRIANGLES,v,c,A,l,M,o.id,S,E,C)}function ds(e){const t=e._nearZ,i=e.projection.farthestPixelDistance(e),r=i-t,n=.2*e.height,o=t+n;return[t,i,(o-n-t)/r,(o-t)/r]}function ps(e,t,i,r){if(e)return t instanceof ht&&e instanceof Mt?t.getTextureDescriptor(e,i,!0):{texture:e.texture,mix:us(r.mix),offset:r.offset,buffer:0,tileSize:1}}var fs=e.eh([{name:"a_index",type:"Int16",components:1}]);class ms{constructor(t,i,r,n){const o={width:r[0],height:r[1],data:null},s=t.gl;this.targetColorTexture=new e.T(t,o,s.RGBA8,{useMipmap:!1}),this.backgroundColorTexture=new e.T(t,o,s.RGBA8,{useMipmap:!1}),this.context=t,this.updateParticleTexture(i,n),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 r=this.context.gl,n=i.width*i.height;this.particleTexture0=new e.T(this.context,i,r.RGBA8,{premultiply:!1,useMipmap:!1}),this.particleTexture1=new e.T(this.context,i,r.RGBA8,{premultiply:!1,useMipmap:!1});const o=new e.ei;o.reserve(n);for(let e=0;e0){const t=e.bi(r.canonical,c),i=e.ek(t);p=e.aB(new Float32Array(16),c.globeMatrix,i),e.aB(p,c.projMatrix,p)}const f=e.bB();f[12]+=2*o/(e.o.devicePixelRatio*c.width),f[13]+=2*s/(e.o.devicePixelRatio*c.height),e.aB(p,f,p);const m=t.getOrCreateProgram("debug",{defines:d}),g=i.getTileByID(r.key);t.terrain&&t.terrain.setupElevationDraw(g,m);const _=$i.disabled,A=Wi.disabled,y=t.colorModeForRenderPass(),v="$debug";l.activeTexture.set(u.TEXTURE0),t.emptyTexture.bind(u.LINEAR,u.CLAMP_TO_EDGE),h?g._makeGlobeTileDebugBuffers(t.context,c):g._makeDebugTileBoundsBuffers(t.context,c.projection);const x=g._tileDebugBuffer||t.debugBuffer,b=g._tileDebugIndexBuffer||t.debugIndexBuffer,w=g._tileDebugSegments||t.debugSegments;if(m.draw(t,u.LINE_STRIP,_,A,y,Xi.disabled,yo(p,n.toPremultipliedRenderColor(null)),v,x,b,w,null,null,null,[g._globeTileDebugBorderBuffer]),a){const e=g.latestRawTileData,i=Math.floor((e&&e.byteLength||0)/1024);let n=r.canonical.toString();r.overscaledZ!==r.canonical.z&&(n+=` => ${r.overscaledZ}`),n+=` ${g.state}`,n+=` ${i}kb`,function(e,t){e.initDebugOverlayCanvas();const i=e.debugOverlayCanvas,r=e.context.gl,n=e.debugOverlayCanvas.getContext("2d");n.clearRect(0,0,i.width,i.height),n.shadowColor="white",n.shadowBlur=2,n.lineWidth=1.5,n.strokeStyle="white",n.textBaseline="top",n.font="bold 36px Open Sans, sans-serif",n.fillText(t,5,5),n.strokeText(t,5,5),e.debugOverlayTexture.update(i),e.debugOverlayTexture.bind(r.LINEAR,r.CLAMP_TO_EDGE)}(t,n)}const T=i.getTile(r).tileSize,E=512/Math.min(T,512)*(r.overscaledZ/c.zoom)*.5,C=g._tileDebugTextBuffer||t.debugBuffer,B=g._tileDebugTextIndexBuffer||t.quadTriangleIndexBuffer,S=g._tileDebugTextSegments||t.debugSegments;m.draw(t,u.TRIANGLES,_,A,Qi.alphaBlended,Xi.disabled,yo(p,e.ao.transparent.toPremultipliedRenderColor(null),E),v,C,B,S,null,null,null,[g._globeTileDebugTextBuffer])}function Es(e,t,i,r){Bs(e,0,t+i/2,e.transform.width,i,r)}function Cs(e,t,i,r){Bs(e,t-i/2,0,i,e.transform.height,r)}function Bs(t,i,r,n,o,s){const a=t.context,l=a.gl;l.enable(l.SCISSOR_TEST),l.scissor(i*e.o.devicePixelRatio,r*e.o.devicePixelRatio,n*e.o.devicePixelRatio,o*e.o.devicePixelRatio),a.clear({color:s}),l.disable(l.SCISSOR_TEST)}const Ss=e.eh([{name:"a_pos_3f",components:3,type:"Float32"}]),{members:Is}=Ss;function Ms(e,t,i,r){e.emplaceBack(t,i,r)}class Ps{constructor(t){this.vertexArray=new e.el,this.indices=new e.b0,Ms(this.vertexArray,-1,-1,1),Ms(this.vertexArray,1,-1,1),Ms(this.vertexArray,-1,1,1),Ms(this.vertexArray,1,1,1),Ms(this.vertexArray,-1,-1,-1),Ms(this.vertexArray,1,-1,-1),Ms(this.vertexArray,-1,1,-1),Ms(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,Is),this.indexBuffer=t.createIndexBuffer(this.indices),this.segment=e.bf.simpleSegment(0,0,36,12)}}function Rs(t,i,r,n,o,s){const a=t.context.gl,l=i.paint.get("sky-atmosphere-color"),c=i.paint.get("sky-atmosphere-halo-color"),u=i.paint.get("sky-atmosphere-sun-intensity"),h=((e,t,i,r,n)=>({u_matrix_3f:e,u_sun_direction:t,u_sun_intensity:i,u_color_tint_r:[r.r,r.g,r.b,r.a],u_color_tint_m:[n.r,n.g,n.b,n.a],u_luminance:5e-5}))(e.en(e.dN(),n),o,u,l.toPremultipliedRenderColor(null),c.toPremultipliedRenderColor(null));a.framebufferTexture2D(a.FRAMEBUFFER,a.COLOR_ATTACHMENT0,a.TEXTURE_CUBE_MAP_POSITIVE_X+s,i.skyboxTexture,0),r.draw(t,a.TRIANGLES,$i.disabled,Wi.disabled,Qi.unblended,Xi.frontCW,h,"skyboxCapture",i.skyboxGeometry.vertexBuffer,i.skyboxGeometry.indexBuffer,i.skyboxGeometry.segment)}const Ls=e.eh([{type:"Float32",name:"a_pos",components:3},{type:"Float32",name:"a_uv",components:2}]);class Fs{constructor(t){const i=new e.eo;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 r=new e.b0;r.emplaceBack(0,1,2),r.emplaceBack(2,3,0),this.vertexBuffer=t.createVertexBuffer(i,Ls.members),this.indexBuffer=t.createIndexBuffer(r),this.segments=e.bf.simpleSegment(0,0,4,2)}destroy(){this.vertexBuffer.destroy(),this.indexBuffer.destroy(),this.segments.destroy()}}const ks=e.eh([{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_fade_opacity",components:1}]);class Ds{constructor(){this.starsCount=16e3,this.sizeMultiplier=.15,this.sizeRange=100,this.intensityRange=200}}class Os{constructor(t){this.colorModeAlphaBlendedWriteRGB=new Qi([1,Hi,1,Hi],e.ao.transparent,[!0,!0,!0,!1]),this.colorModeWriteAlpha=new Qi([1,0,1,0],e.ao.transparent,[!1,!1,!1,!0]),this.params=new Ds,this.updateNeeded=!0,t.tp.registerParameter(this.params,["Stars"],"starsCount",{min:100,max:16e3,step:1},()=>{this.updateNeeded=!0}),t.tp.registerParameter(this.params,["Stars"],"sizeMultiplier",{min:.01,max:2,step:.01}),t.tp.registerParameter(this.params,["Stars"],"sizeRange",{min:0,max:200,step:1},()=>{this.updateNeeded=!0}),t.tp.registerParameter(this.params,["Stars"],"intensityRange",{min:0,max:200,step:1},()=>{this.updateNeeded=!0})}update(t){const i=t.context;if(!this.atmosphereBuffer||this.updateNeeded){this.updateNeeded=!1,this.atmosphereBuffer=new Fs(i);const t=this.params.sizeRange,r=this.params.intensityRange,n=function(t){const i=e.eq(30),r=[];for(let n=0;n{const i="globe"===o.projection.name?["PROJECTION_GLOBE_VIEW","FOG"]:["FOG"];e&&i.push("ALPHA_PASS");const l=t.getOrCreateProgram("globeAtmosphere",{defines:i}),c=((e,t,i,r,n,o,s,a,l,c,u,h)=>({u_frustum_tl:e,u_frustum_tr:t,u_frustum_br:i,u_frustum_bl:r,u_horizon:n,u_transition:o,u_fadeout_range:s,u_atmosphere_fog_color:a.toArray01(),u_high_color:l.toArray01(),u_space_color:c.toArray01(),u_temporal_offset:u,u_horizon_angle:h}))(o.frustumCorners.TL,o.frustumCorners.TR,o.frustumCorners.BR,o.frustumCorners.BL,o.frustumCorners.horizon,a,g,u,d,f,A,x);t.uploadCommonUniforms(r,l);const h=this.atmosphereBuffer;h&&l.draw(t,n.TRIANGLES,s,Wi.disabled,e?this.colorModeWriteAlpha:this.colorModeAlphaBlendedWriteRGB,Xi.backCW,c,e?"atmosphere_glow_alpha":"atmosphere_glow",h.vertexBuffer,h.indexBuffer,h.segments)};b(!1),b(!0)}drawStars(t,i){const r=e.aA(i.properties.get("star-intensity"),0,1);if(0===r)return;const n=t.context,o=n.gl,s=t.transform,a=t.getOrCreateProgram("stars"),l=e.c6([]);e.c8(l,l,-s._pitch),e.c7(l,l,-s.angle),e.c8(l,l,e.an(s._center.lat)),e.es(l,l,-e.an(s._center.lng));const c=e.cb(new Float32Array(16),l),u=e.aB([],s.starsProjMatrix,c),h=e.en([],c),d=e.et([],h),p=[0,1,0];e.dP(p,p,d),e.c4(p,p,this.params.sizeMultiplier);const f=[1,0,0];e.dP(f,f,d),e.c4(f,f,this.params.sizeMultiplier);const m=(g=p,_=f,A=r,{u_matrix:Float32Array.from(u),u_up:g,u_right:_,u_intensity_multiplier:A});var g,_,A;t.uploadCommonUniforms(n,a),this.starsVx&&this.starsIdx&&a.draw(t,o.TRIANGLES,$i.disabled,Wi.disabled,this.colorModeAlphaBlendedWriteRGB,Xi.disabled,m,"atmosphere_stars",this.starsVx,this.starsIdx,this.starsSegments)}}class zs{constructor(){this.visibleTiles=[]}updateBorders(t,i){const r=[],n=[],o=t._getRenderableCoordinates(!1,!0);for(const e of o){const o=t.getTile(e);if(!o.hasData())continue;const s=o.getBucket(i);s&&(s.isEmpty()||(r.push(e.key),n.push({bucket:s,tileID:e.canonical})))}let s=r.length!==this.visibleTiles.length;if(!s){r.sort();for(let e=0;ee.tileID.z-t.tileID.z||e.tileID.x-t.tileID.x||e.tileID.y-t.tileID.y);for(const t of n){const i=new Array,r=new Array,n=t.bucket;for(const e of n.featuresOnBorder)a.has(e.featureId)?r.push(e.footprintIndex):(a.add(e.featureId),i.push(e.footprintIndex));n.updateFootprintHiddenFlags(i,e.eu,!1),n.updateFootprintHiddenFlags(r,e.eu,!0)}}}function Us(t,i){const r=[...t],n=i.cameraWorldSizeForFog/i.worldSize,o=e.bz([]);return e.cR(o,o,[n,n,1]),e.aB(r,o,r),e.aB(r,i.worldToFogMatrix,r),r}function Ns(t,i,r,n,o){const s=r.material,a=n.context,{baseColorTexture:l,metallicRoughnessTexture:c}=s.pbrMetallicRoughness,{normalTexture:u,occlusionTexture:h,emissionTexture:d}=s;function p(e,i,r){if(e&&(t.push(i),a.activeTexture.set(a.gl.TEXTURE0+r),e.gfxTexture)){const{minFilter:t,magFilter:i,wrapS:r,wrapT:n}=e.sampler;e.gfxTexture.bindExtraParam(t,i,r,n)}}p(l,"HAS_TEXTURE_u_baseColorTexture",rr.BaseColor),p(c,"HAS_TEXTURE_u_metallicRoughnessTexture",rr.MetallicRoughness),p(u,"HAS_TEXTURE_u_normalTexture",rr.Normal),p(h,"HAS_TEXTURE_u_occlusionTexture",rr.Occlusion),p(d,"HAS_TEXTURE_u_emissionTexture",rr.Emission),o&&(o.texture||(o.texture=new e.d_(n.context,o.image,[o.image.height,o.image.height,o.image.height],a.gl.RGBA8)),a.activeTexture.set(a.gl.TEXTURE0+rr.LUT),o.texture&&o.texture.bind(a.gl.LINEAR,a.gl.CLAMP_TO_EDGE),t.push("APPLY_LUT_ON_GPU")),r.texcoordBuffer&&(t.push("HAS_ATTRIBUTE_a_uv_2f"),i.push(r.texcoordBuffer)),r.colorBuffer&&(t.push(12===r.colorBuffer.itemSize?"HAS_ATTRIBUTE_a_color_3f":"HAS_ATTRIBUTE_a_color_4f"),i.push(r.colorBuffer)),r.normalBuffer&&(t.push("HAS_ATTRIBUTE_a_normal_3f"),i.push(r.normalBuffer)),r.pbrBuffer&&(t.push("HAS_ATTRIBUTE_a_pbr"),t.push("HAS_ATTRIBUTE_a_heightBasedEmissiveStrength"),i.push(r.pbrBuffer)),"OPAQUE"!==s.alphaMode&&"MASK"!==s.alphaMode||t.push("UNPREMULT_TEXTURE_IN_SHADER"),s.defined||t.push("DIFFUSE_SHADED");const f=n.shadowRenderer;f&&(t.push("RENDER_SHADOWS","DEPTH_TEXTURE"),f.useNormalOffset&&t.push("NORMAL_OFFSET"))}function Vs(t,i,r,n,o,s){const a=r.paint.get("model-opacity").constantOr(1),l=i.context,c=new $i(i.context.gl.LEQUAL,t.isLightMesh?$i.ReadOnly:$i.ReadWrite,i.depthRangeFor3D),u=i.transform,h=t.mesh,d=h.material,p=d.pbrMetallicRoughness,f=i.style.fog;let m;m="pixels"===i.transform.projection.zAxisUnit?[...t.nodeModelMatrix]:e.aB([],n.zScaleMatrix,t.nodeModelMatrix),e.aB(m,n.negCameraPosMatrix,m);const g=e.bk([],m);e.ef(g,g);const _="none"===r.paint.get("model-color-use-theme").constantOr("default"),A=r.paint.get("model-emissive-strength").constantOr(0),y=ko(new Float32Array(t.worldViewProjection),new Float32Array(m),new Float32Array(g),null,i,a,p.baseColorFactor,d.emissiveFactor,p.metallicFactor,p.roughnessFactor,d,A,r,void 0,void 0,t.materialOverride,t.modelColor),v={defines:[]},x=[],b=i.shadowRenderer;b&&(b.useNormalOffset=!1),Ns(v.defines,x,h,i,_?null:r.lut);let w=null;if(f){const e=Us(t.nodeModelMatrix,i.transform);if(w=new Float32Array(e),"globe"!==u.projection.name){const t=h.aabb.min,i=h.aabb.max,[r,n]=f.getOpacityForBounds(e,t[0],t[1],i[0],i[1]);v.overrideFog=r>=Ve||n>=Ve}}const T=ar(i,r.paint.get("model-cutoff-fade-range"));T.shouldRenderCutoff&&v.defines.push("RENDER_CUTOFF");const E=i.getOrCreateProgram("model",v);i.uploadCommonUniforms(l,E,null,w,T),"shadow"!==i.renderPass&&b&&b.setupShadowsFromMatrix(t.nodeModelMatrix,E),E.draw(i,l.gl.TRIANGLES,c,o,s,h.material.doubleSided?Xi.disabled:Xi.backCCW,y,r.id,h.vertexBuffer,h.indexBuffer,h.segments,r.paint,i.transform.zoom,void 0,x)}function js(e,t,i){return"vector"===e.type?t.scope:i?"basemap":""}function Gs(t,i,r,n,o,s,a,l,c){const u=t.transform,h=!!i.isGeometryBloom&&i.isGeometryBloom;if(h&&"shadow"===t.renderPass)return;const d="globe"===u.projection.name?e.eC(r,u):[...r];e.aB(d,d,i.globalMatrix);const p=e.aB([],n,d);if(i.meshes)for(const t of i.meshes){const i=l.get(t.material.name);if(i&&i.opacity<=0)continue;if("BLEND"!==t.material.alphaMode){a.push({mesh:t,depth:0,modelIndex:o,worldViewProjection:p,nodeModelMatrix:d,isLightMesh:h,materialOverride:i,modelColor:c});continue}const r=e.af([],t.centroid,p);!u.isOrthographic&&r[2]<=0||s.push({mesh:t,depth:r[2],modelIndex:o,worldViewProjection:p,nodeModelMatrix:d,isLightMesh:h,materialOverride:i,modelColor:c})}if(i.children)for(const e of i.children)Gs(t,e,r,n,o,s,a,l,c)}function Hs(e,t,i,r){const n=i.shadowRenderer;if(!n)return;const o=n.getShadowPassDepthMode(),s=n.getShadowPassColorMode(),a=n.calculateShadowPassMatrixFromMatrix(t),l=Do(a);i.getOrCreateProgram("modelDepth",{defines:i._shadowMapDebug?[]:["DEPTH_TEXTURE"]}).draw(i,i.context.gl.TRIANGLES,o,Wi.disabled,s,Xi.disabled,l,r.id,e.vertexBuffer,e.indexBuffer,e.segments,r.paint,i.transform.zoom,void 0,void 0)}function Qs(e,t,i,r,n,o){for(const s of n){const n=Object.assign({},r);n.part=s;const a={type:"Unknown",id:t,properties:n},l={orientation:e.paint.get("model-rotation").evaluate(a,i)};o.set(s,l)}}function $s(e,t,i,r,n,o){for(const s of n){const n=Object.assign({},r);n.part=s;const a={type:"Unknown",id:t,properties:n},l={color:e.paint.get("model-color").evaluate(a,i),colorMix:e.paint.get("model-color-mix-intensity").evaluate(a,i),opacity:e.paint.get("model-opacity").evaluate(a,i),emissionStrength:e.paint.get("model-emissive-strength").evaluate(a,i)};o.set(s,l)}}function Zs(e,t,i,r,n,o){if(1===i)for(const i of n)Vs(i,e,t,o[i.modelIndex],Wi.disabled,e.colorModeForRenderPass());else{for(const i of n)Vs(i,e,t,o[i.modelIndex],Wi.disabled,Qi.disabled);for(const i of n)Vs(i,e,t,o[i.modelIndex],e.stencilModeFor3D(),e.colorModeForRenderPass());e.resetStencilClippingMasks()}const s=Qi.additive;for(const i of r)Vs(i,e,t,o[i.modelIndex],Wi.disabled,i.isLightMesh?s:e.colorModeForRenderPass())}function Ws(t,i,r){const n=i.updateZoomBasedPaintProperties(),o=function(t,i,r){let n,o,s,a=t.terrain?t.terrain.exaggeration():0;if(t.terrain&&a>0){const i=t.terrain,o=i.findDEMTileFor(r);o&&o.dem?n=e.eE.create(i,r,o):a=0}if(0===a&&(i.terrainElevationMin=0,i.terrainElevationMax=0),a===i.validForExaggeration&&(0===a||n&&n._demTile&&n._demTile.tileID===i.validForDEMTile.id&&n._dem._timestamp===i.validForDEMTile.timestamp))return!1;for(const e in i.instancesPerModel){const t=i.instancesPerModel[e];for(let e=0;eu&&(u=e.max)}const h=e.aA(n.x,s,a)-n.x,d=e.aA(n.y,l,c)-n.y,p=e.ce(u,i.center.lat)-n.z;return i._zoomFromMercatorZ(Math.sqrt(h*h+d*d+p*p))}function Xs(e,t,i,r,n,o,s){const a=e.context,l="shadow"===e.renderPass,c=e.shadowRenderer,u=l&&c?c.getShadowPassDepthMode():new $i(a.gl.LEQUAL,$i.ReadWrite,e.depthRangeFor3D),h=e.isTileAffectedByFog(o),d="globe"===e.transform.projection.name;if(i.meshes)for(const p of i.meshes){const f=d?[]:["MODEL_POSITION_ON_GPU"],m=[];let g,_,A;const y=!d&&r.instancedDataArray.length>20;y&&f.push("INSTANCED_ARRAYS");const v=ar(e,t.paint.get("model-cutoff-fade-range"));if(v.shouldRenderCutoff&&f.push("RENDER_CUTOFF"),l&&c)g=e.getOrCreateProgram("modelDepth",{defines:f}),_=Do(s.shadowTileMatrix,s.shadowTileMatrix,Float32Array.from(i.globalMatrix)),A=c.getShadowPassColorMode();else{Ns(f,m,p,e,"none"===t.paint.get("model-color-use-theme").constantOr("default")?null:t.lut),g=e.getOrCreateProgram("model",{defines:f,overrideFog:h});const r=p.material,l=r.pbrMetallicRoughness,u=t.paint.get("model-opacity").constantOr(1),d=t.paint.get("model-emissive-strength").constantOr(0);_=ko(o.expandedProjMatrix,Float32Array.from(i.globalMatrix),new Float32Array(16),null,e,u,l.baseColorFactor,r.emissiveFactor,l.metallicFactor,l.roughnessFactor,r,d,t,n),c&&(s.shadowUniformsInitialized?g.setShadowUniformValues(a,c.getShadowUniformValues()):(c.setupShadows(o.toUnwrapped(),g,"model-tile"),s.shadowUniformsInitialized=!0)),A=v.shouldRenderCutoff||u<1||"OPAQUE"!==r.alphaMode?Qi.alphaBlended:Qi.unblended}e.uploadCommonUniforms(a,g,o.toUnwrapped(),null,v);const x=p.material.doubleSided?Xi.disabled:Xi.backCCW;if(y)m.push(r.instancedDataBuffer),g.draw(e,a.gl.TRIANGLES,u,Wi.disabled,A,x,_,t.id,p.vertexBuffer,p.indexBuffer,p.segments,t.paint,e.transform.zoom,void 0,m,r.instancedDataArray.length);else{const i=l?"u_instance":"u_normal_matrix";for(let n=0;nc[1]?a:c,s[0]=r.max[0],a=e.aC(e.eF(),s,o),l=a[1]c[1]?a:c,s[1]=r.min[1],a=e.aC(e.eF(),s,o),l=a[1]c[1]?a:c;const u=e.aA(n[0],0,1),h=100*i.pixelsPerMeter*e.aA(n[1],0,1),d=e.aA(n[2],0,1),p=e.eG(e.eF(),l,c,u),f=Math.tan(.5*i.fovX),m=-p[2]*f;if(0===h)return p[1]<-Math.abs(m)?d:1;const g=(-Math.abs(m)-p[1])/h,_=(e,t,i)=>(1-i)*e+i*t,A=e.aA(_(1,d,g),d,1);return _(1,A,e.aA((i.pitch-20)/20,0,1))}class ia{}class ra{constructor(){this._storage=new Map}getLinesFromTrianglesBuffer(t,i,r){{const e=this._storage.get(i.id);if(e)return e.lastUsedFrameIdx=t,e.buf}const n=r.gl,o=n.getBufferParameter(n.ELEMENT_ARRAY_BUFFER,n.BUFFER_SIZE),s=new ArrayBuffer(o),a=new Int16Array(s);n.getBufferSubData(n.ELEMENT_ARRAY_BUFFER,0,new Int16Array(s));const l=new e.eI;for(let e=0;e30&&(i.buf.destroy(),this._storage.delete(t))}destroy(){for(const[e,t]of this._storage)t.buf.destroy(),this._storage.delete(e)}}class na{constructor(e){this.occluderSize=30,this.depthOffset=-1e-4,e.registerParameter(this,["Occlusion"],"occluderSize",{min:1,max:100,step:1}),e.registerParameter(this,["Occlusion"],"depthOffset",{min:-.05,max:0,step:1e-5})}}const oa=e.eh([{type:"Float32",name:"a_pos_3f",components:3},{type:"Float32",name:"a_uv",components:2},{type:"Float32",name:"a_rainParticleData",components:4}]);class sa{registerParameter(){}registerButton(){}registerBinding(){}refreshUI(){}}class aa{constructor(e,t){this.revealStart=11,this.revealRange=2,e.registerParameter(this,[...t,"Reveal"],"revealStart",{min:0,max:17,step:.05}),e.registerParameter(this,[...t,"Reveal"],"revealRange",{min:.1,max:5.1,step:.05})}}const la=e.eh([{type:"Float32",name:"a_pos_2f",components:2}]);class ca{destroy(){this.vignetteVx&&this.vignetteVx.destroy(),this.vignetteIdx&&this.vignetteIdx.destroy()}draw(t,i){const r=t.getOrCreateProgram("vignette");if(!this.vignetteVx||!this.vignetteIdx){const i=new e.eJ,r=new e.b0;i.emplaceBack(-1,-1),i.emplaceBack(1,-1),i.emplaceBack(1,1),i.emplaceBack(-1,1),r.emplaceBack(0,1,2),r.emplaceBack(0,2,3),this.vignetteVx=t.context.createVertexBuffer(i,la.members),this.vignetteIdx=t.context.createIndexBuffer(r)}const n=e.bf.simpleSegment(0,0,4,6);if(this.vignetteVx&&this.vignetteIdx){t.uploadCommonUniforms(t.context,r);const e={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};r.draw(t,t.context.gl.TRIANGLES,$i.disabled,Wi.disabled,Qi.alphaBlended,Xi.disabled,e,"vignette",this.vignetteVx,this.vignetteIdx,n)}var o}}class ua{constructor(){this._accumulatedOffsetX=0,this._accumulatedOffsetY=0,this._accumulatedElevation=0}update(t,i){const r=t.getFreeCameraOptions().position,n=r.toAltitude(),o=r.toLngLat(),s=e.an(o.lng),a=e.an(o.lat),l=t.pixelsPerMeter/i,c=s*e.eL,u=e.eL*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+u,t=-this._elevationPrev+n;this._accumulatedOffsetX+=(-this._offsetXPrev+c)*l,this._accumulatedOffsetY+=e*l,this._accumulatedElevation+=t*l,this._offsetXPrev=c,this._offsetYPrev=u,this._elevationPrev=n}}getPosition(){return[this._accumulatedOffsetX,this._accumulatedOffsetY,this._accumulatedElevation]}}function ha(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 da(t){const i=e.eq(1323123451230),r=[];for(let n=0;nr)return;const n=pa(0,1,i.revealStart,i.revealStart+i.revealRange,r);if(!this.particlesVx||!this.particlesIdx)return;const o=structuredClone(this._params);let s=[-o.direction.x,o.direction.y,-100];e.aw(s,s);const a=structuredClone(this._vignetteParams);a.strength*=n,o.overrideStyleParameters||(o.intensity=t.style.rain.state.density,o.timeFactor=t.style.rain.state.intensity,o.color=structuredClone(t.style.rain.state.color),s=structuredClone(t.style.rain.state.direction),o.screenThinning.intensity=t.style.rain.state.centerThinning,o.dropletSizeX=t.style.rain.state.dropletSize[0],o.dropletSizeYScale=t.style.rain.state.dropletSize[1]/t.style.rain.state.dropletSize[0],o.distortionStrength=100*t.style.rain.state.distortionStrength,a.strength=1,a.color=structuredClone(t.style.rain.state.vignetteColor));const l=this.updateOnRender(t,o.timeFactor),c=t.context,u=c.gl,h=t.transform;this.screenTexture&&this.screenTexture.size[0]===t.width&&this.screenTexture.size[1]===t.height||(this.screenTexture=new e.T(c,{width:t.width,height:t.height,data:null},u.RGBA8)),o.distortionStrength>0&&(c.activeTexture.set(u.TEXTURE0),this.screenTexture.bind(u.LINEAR,u.CLAMP_TO_EDGE),u.copyTexSubImage2D(u.TEXTURE_2D,0,0,0,0,0,t.width,t.height));const d=t.getOrCreateProgram("rainParticle");t.uploadCommonUniforms(c,d),c.activeTexture.set(u.TEXTURE0),this.screenTexture.bind(u.LINEAR,u.CLAMP_TO_EDGE);const p=[o.color.r,o.color.g,o.color.b,o.color.a],f=(i,r)=>{const n=ha(this._movement.getPosition(),i),a=o.dropletSizeX,c=o.dropletSizeX*o.dropletSizeYScale,f=t.width/2,m=t.height/2,g=pa(0,o.screenThinning.start,0,1,o.screenThinning.intensity),_=pa(.001,o.screenThinning.range,0,1,o.screenThinning.intensity),A=pa(0,o.screenThinning.particleOffset,0,1,o.screenThinning.intensity),y=(v={modelview:l.modelviewMatrix,projection:l.projectionMatrix,time:this._accumulatedTimeFromStart,camPos:n,velocityConeAperture:o.velocityConeAperture,velocity:o.velocity,boxSize:i,rainDropletSize:[a,c],distortionStrength:o.distortionStrength,rainDirection:s,color:p,screenSize:[h.width,h.height],thinningCenterPos:[f,m],thinningShape:[g,_,Math.pow(10,o.screenThinning.fadePower)],thinningAffectedRatio:o.screenThinning.affectedRatio,thinningParticleOffset:A,shapeDirectionalPower:o.shapeDirPower,shapeNormalPower:o.shapeNormalPower,mode:r?0:1},{u_modelview:Float32Array.from(v.modelview),u_projection:Float32Array.from(v.projection),u_time:v.time,u_cam_pos:v.camPos,u_texScreen:0,u_velocityConeAperture:v.velocityConeAperture,u_velocity:v.velocity,u_boxSize:v.boxSize,u_rainDropletSize:v.rainDropletSize,u_distortionStrength:v.distortionStrength,u_rainDirection:v.rainDirection,u_color:v.color,u_screenSize:v.screenSize,u_thinningCenterPos:v.thinningCenterPos,u_thinningShape:v.thinningShape,u_thinningAffectedRatio:v.thinningAffectedRatio,u_thinningParticleOffset:v.thinningParticleOffset,u_shapeDirectionalPower:v.shapeDirectionalPower,u_shapeNormalPower:v.shapeNormalPower,u_mode:v.mode});var v;const x=Math.round(o.intensity*this.particlesCount),b=e.bf.simpleSegment(0,0,4*x,2*x);d.draw(t,u.TRIANGLES,$i.disabled,Wi.disabled,Qi.alphaBlended,Xi.disabled,y,"rain_particles",this.particlesVx,this.particlesIdx,b)};o.distortionStrength>0&&f(o.boxSize,!0),f(o.boxSize,!1),this._vignette.draw(t,a)}}const ga=e.eh([{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}]);class _a extends fa{constructor(e){super(2.25),this._params={overrideStyleParameters:!1,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._revealParams=new aa(e.tp,["Precipitation","Snow"]),this._vignetteParams={strength:.3,start:.78,range:.46,fadePower:.2,color:{r:1,g:1,b:1,a:1}},this.particlesCount=16e3}update(t){const i=t.context;if(!this.particlesVx){const t=da(this.particlesCount),r=new e.eN,n=new e.b0;let o=0;const s=e.eq(1323123451230);for(let e=0;es)return;const a=pa(0,1,o.revealStart,o.revealStart+o.revealRange,s);n.strength*=a,i.overrideStyleParameters||(i.intensity=t.style.snow.state.density,i.timeFactor=t.style.snow.state.intensity,i.color=structuredClone(t.style.snow.state.color),r=structuredClone(t.style.snow.state.direction),i.screenThinning.intensity=t.style.snow.state.centerThinning,i.billboardSize=2.79*t.style.snow.state.flakeSize,n.strength=1,n.color=structuredClone(t.style.snow.state.vignetteColor));const l=this.updateOnRender(t,i.timeFactor);if(!this.particlesVx||!this.particlesIdx)return;const c=t.context,u=c.gl,h=t.transform,d=t.getOrCreateProgram("snowParticle");t.uploadCommonUniforms(c,d),((i,n,o)=>{const s=ha(this._movement.getPosition(),i),a=h.width/2,c=h.height/2,p=pa(0,o.screenThinning.start,0,1,o.screenThinning.intensity),f=pa(.001,o.screenThinning.range,0,1,o.screenThinning.intensity),m=pa(0,o.screenThinning.particleOffset,0,1,o.screenThinning.intensity),g=(_={modelview:l.modelviewMatrix,projection:l.projectionMatrix,time:this._accumulatedTimeFromStart,camPos:s,velocityConeAperture:o.velocityConeAperture,velocity:o.velocity,horizontalOscillationRadius:o.horizontalOscillationRadius,horizontalOscillationRate:o.horizontalOscillationRate,boxSize:i,billboardSize:1*o.billboardSize,simpleShapeParameters:[o.shapeFadeStart,o.shapeFadePower],screenSize:[h.width,h.height],thinningCenterPos:[a,c],thinningShape:[p,f,Math.pow(10,o.screenThinning.fadePower)],thinningAffectedRatio:o.screenThinning.affectedRatio,thinningParticleOffset:m,color:[o.color.r,o.color.g,o.color.b,o.color.a],direction:r},{u_modelview:Float32Array.from(_.modelview),u_projection:Float32Array.from(_.projection),u_time:_.time,u_cam_pos:_.camPos,u_velocityConeAperture:_.velocityConeAperture,u_velocity:_.velocity,u_horizontalOscillationRadius:_.horizontalOscillationRadius,u_horizontalOscillationRate:_.horizontalOscillationRate,u_boxSize:_.boxSize,u_billboardSize:_.billboardSize,u_simpleShapeParameters:_.simpleShapeParameters,u_screenSize:_.screenSize,u_thinningCenterPos:_.thinningCenterPos,u_thinningShape:_.thinningShape,u_thinningAffectedRatio:_.thinningAffectedRatio,u_thinningParticleOffset:_.thinningParticleOffset,u_particleColor:_.color,u_direction:_.direction});var _;const A=Math.round(o.intensity*this.particlesCount),y=e.bf.simpleSegment(0,0,4*A,2*A);this.particlesVx&&this.particlesIdx&&d.draw(t,u.TRIANGLES,$i.disabled,Wi.disabled,Qi.alphaBlended,Xi.disabled,g,"snow_particles",this.particlesVx,this.particlesIdx,y)})(i.boxSize,0,i),this._vignette.draw(t,n)}}const Aa={symbol:function(t,i,r,n,o){if("translucent"!==t.renderPass)return;const s=Wi.disabled,a=t.colorModeForRenderPass(),l=r.layout.get("text-variable-anchor"),c=r.layout.get("text-size-scale-range"),u=e.aA(t.scaleFactor,c[0],c[1]);l&&function(t,i,r,n,o,s,a,l){const c=i.transform,u="map"===o,h="map"===s;for(const i of t){const t=n.getTile(i),o=t.getBucket(r);if(!o||!o.text||!o.text.segments.get().length)continue;const s=e.bJ(o.textSizeData,c.zoom,l),d=Kt(i,o.getProjection(),c),p=c.calculatePixelsToTileUnitsMatrix(t),f=ti(d,t.tileID.canonical,h,u,c,o.getProjection(),p),m=o.hasIconTextFit()&&o.hasIconData();s&&Wo(o,u,h,a,c,f,i,Math.pow(2,c.zoom-t.tileID.overscaledZ),s,m)}}(n,t,r,i,r.layout.get("text-rotation-alignment"),r.layout.get("text-pitch-alignment"),o,u);const h=0!==r.paint.get("icon-opacity").constantOr(1),d=0!==r.paint.get("text-opacity").constantOr(1);void 0!==r.layout.get("symbol-sort-key").constantOr(1)&&(h||d)?qo(t,i,r,n,s,a):(h&&qo(t,i,r,n,s,a,{onlyIcons:!0}),d&&qo(t,i,r,n,s,a,{onlyText:!0})),i.map.showCollisionBoxes&&(Ho(t,i,r,n,r.paint.get("text-translate"),r.paint.get("text-translate-anchor"),!0),Ho(t,i,r,n,r.paint.get("icon-translate"),r.paint.get("icon-translate-anchor"),!1))},circle:function(t,i,r,n){if("translucent"!==t.renderPass)return;const o=r.paint.get("circle-opacity"),s=r.paint.get("circle-stroke-width"),a=r.paint.get("circle-stroke-opacity"),l=void 0!==r.layout.get("circle-sort-key").constantOr(1),c=r.paint.get("circle-emissive-strength");if(0===o.constantOr(1)&&(0===s.constantOr(1)||0===a.constantOr(1)))return;const u=t.context,h=u.gl,d=t.transform,p=!(!t.terrain||!t.terrain.enabled),f=r.layout.get("circle-elevation-reference"),m=t.depthModeForSublayer(0,$i.ReadOnly),g=new $i(t.context.gl.LEQUAL,$i.ReadOnly,t.depthRangeFor3D),_="none"===f||p?m:g,A=Wi.disabled,y=t.colorModeForDrapableLayerRenderPass(c),v="globe"===d.projection.name,x=[e.aF(d.center.lng),e.aJ(d.center.lat)],b=[];for(let o=0;oe.sortKey-t.sortKey);const w={useDepthForOcclusion:d.depthOcclusionForSymbolsAndCircles};for(const e of b){const{programConfiguration:i,program:n,layoutVertexBuffer:o,dynamicBuffers:s,indexBuffer:a,uniformValues:l,tile:c}=e.state,p=e.segments;t.terrain&&t.terrain.setupElevationDraw(c,n,w),t.uploadCommonUniforms(u,n,c.tileID.toUnwrapped()),n.draw(t,h.TRIANGLES,_,A,y,Xi.disabled,l,r.id,o,a,p,r.paint,d.zoom,i,s)}},heatmap:function(t,i,r,n){if(0!==r.paint.get("heatmap-opacity"))if("offscreen"===t.renderPass){const o=t.context,s=o.gl,a=Wi.disabled,l=new Qi([s.ONE,s.ONE,s.ONE,s.ONE],e.ao.transparent,[!0,!0,!0,!0]);!function(e,t,i,r){const n=e.gl,o=t.width*r,s=t.height*r;e.activeTexture.set(n.TEXTURE1),e.viewport.set([0,0,o,s]);let a=i.heatmapFbo;if(!a||a&&(a.width!==o||a.height!==s)){a&&a.destroy();const t=n.createTexture();n.bindTexture(n.TEXTURE_2D,t),n.texParameteri(n.TEXTURE_2D,n.TEXTURE_WRAP_S,n.CLAMP_TO_EDGE),n.texParameteri(n.TEXTURE_2D,n.TEXTURE_WRAP_T,n.CLAMP_TO_EDGE),n.texParameteri(n.TEXTURE_2D,n.TEXTURE_MIN_FILTER,n.LINEAR),n.texParameteri(n.TEXTURE_2D,n.TEXTURE_MAG_FILTER,n.LINEAR),a=i.heatmapFbo=e.createFramebuffer(o,s,!0,null),function(e,t,i,r,n,o){const s=e.gl;s.texImage2D(s.TEXTURE_2D,0,e.extRenderToTextureHalfFloat?s.RGBA16F:s.RGBA,n,o,0,s.RGBA,e.extRenderToTextureHalfFloat?s.HALF_FLOAT:s.UNSIGNED_BYTE,null),r.colorAttachment.set(i)}(e,0,t,a,o,s)}else n.bindTexture(n.TEXTURE_2D,a.colorAttachment.get()),e.bindFramebuffer.set(a.framebuffer)}(o,t,r,"globe"===t.transform.projection.name?.5:.25),o.clear({color:e.ao.transparent});const c=t.transform,u="globe"===c.projection.name,h=u?["PROJECTION_GLOBE_VIEW"]:[],d=u?Xi.frontCCW:Xi.disabled,p=[e.aF(c.center.lng),e.aJ(c.center.lat)];for(let e=0;e({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,r))},line:function(t,i,r,n){if("translucent"!==t.renderPass)return;const o=r.paint.get("line-opacity"),s=r.paint.get("line-width");if(0===o.constantOr(1)||0===s.constantOr(1))return;const a=r.paint.get("line-emissive-strength"),l=r.paint.get("line-occlusion-opacity"),c=r.layout.get("line-elevation-reference"),u="meters"===r.layout.get("line-width-unit"),h="sea"===c,d=!(!t.terrain||!t.terrain.enabled),p=t.context,f=p.gl;if(r.hasElevatedBuckets&&"globe"===t.transform.projection.name)return;const m=r.layout.get("line-cross-slope"),g=void 0!==m,_=m<1,A=t.colorModeForDrapableLayerRenderPass(a),y=t.terrain&&t.terrain.renderingToTexture,v=y?1:e.o.devicePixelRatio,x=r.paint.get("line-dasharray"),b=x.constantOr(1),w=r.layout.get("line-cap"),T=x.constantOr(null),E=w.constantOr(null),C=r.paint.get("line-pattern"),B=C.constantOr(1),S=r.paint.get("line-pattern-cross-fade"),I=C.constantOr(null),M=r.paint.get("line-opacity").constantOr(1);let P=!B&&1!==M||t.depthOcclusion&&l>0&&l<1;const R=r.paint.get("line-gradient"),L=B?"linePattern":"line",F=e.e1(r);let k;if(y&&t.terrain&&t.terrain.clipOrMaskOverlapStencilType()&&(P=!1),0!==l&&t.depthOcclusion){const t=r.paint._values["line-opacity"];t&&t.value&&"constant"===t.value.kind?k=t.value:e.w(`Occlusion opacity for layer ${r.id} is supported only when line-opacity isn't data-driven.`)}"constant"!==s.value.kind&&!1===s.value.isLineProgressConstant&&F.push("VARIABLE_LINE_WIDTH");const D=(n,o,s,a,c,d)=>{for(const m of n){const n=i.getTile(m);if(B&&!n.patternsLoaded())continue;const g=n.getBucket(r);if(!g)continue;if("none"!==g.elevationType&&!c||"none"===g.elevationType&&c)continue;t.prepareDrawTile();const _=[...o],x=t.shadowRenderer,w="road"===g.elevationType&&!!x&&x.enabled;let C=[0,0,0];if(w){const e=t.style.directionalLight,i=t.style.ambientLight;e&&i&&(C=fr(t.style,e,i)),_.push("RENDER_SHADOWS","DEPTH_TEXTURE","NORMAL_OFFSET")}const F=g.programConfigurations.get(r.id);let D=!1;if(I&&n.imageAtlas){const t=e.e2.from(I),i=t.getPrimary().scaleSelf(v).toString(),r=n.imageAtlas.patternPositions.get(i),o=t.getSecondary(),s=o?n.imageAtlas.patternPositions.get(o.scaleSelf(v).toString()):null;D=!!r&&!!s,r&&F.setConstantPatternPositions(r,s)}S>0&&(D||F.getPatternTransitionVertexBuffer("line-pattern"))&&_.push("LINE_PATTERN_TRANSITION");const O=t.isTileAffectedByFog(m),z=t.getOrCreateProgram(L,{config:F,defines:_,overrideFog:O});if(!B&&T&&E&&n.lineAtlas){const e=n.lineAtlas.getDash(T,E);e&&F.setConstantPatternPositions(e)}w&&x.setupShadows(n.tileID.toUnwrapped(),z,"vector-tile");let[U,N]=r.paint.get("line-trim-offset");if("round"===E||"square"===E){const e=1;U!==N&&(0===U&&(U-=e),1===N&&(N+=e))}const V=y?m.projMatrix:null,j=u?1/g.tileToMeter/e.ay(n,1,t.transform.zoom):1,G=u?1/g.tileToMeter/e.ay(n,1,Math.floor(t.transform.zoom)):1,H=B?e.e3(t,n,r,V,v,j,G,[U,N],C,S):e.e4(t,n,r,V,g.lineClipsArray.length,v,j,G,[U,N],C);if(R){const n=g.gradients[r.id];let o=n.texture;if(r.gradientVersion!==n.version){let s=256;if(r.stepInterpolant){const r=i.getSource().maxzoom,n=m.canonical.z===r?Math.ceil(1<{null!=k&&(k.value=M*l),z.draw(t,f.TRIANGLES,s,e,A,Xi.disabled,H,r.id,g.layoutVertexBuffer,g.indexBuffer,g.segments,r.paint,t.transform.zoom,F,[g.layoutVertexBuffer2,g.patternVertexBuffer,g.zOffsetVertexBuffer]),null!=k&&(k.value=M)};if(P&&!c){const e=t.stencilModeForClipping(m).ref;0===e&&y&&p.clear({stencil:0});const i={func:f.EQUAL,mask:255};H.u_alpha_discard_threshold=.8,Q(new Wi(i,e,255,f.KEEP,f.KEEP,f.INVERT)),H.u_alpha_discard_threshold=0,Q(new Wi(i,e,255,f.KEEP,f.KEEP,f.KEEP))}else H.u_alpha_discard_threshold=P&&c&&d?.8:0,Q(c?a:t.stencilModeForClipping(m))}};let O=t.depthModeForSublayer(0,$i.ReadOnly);const z=new $i(t.depthOcclusion?f.GREATER:f.LEQUAL,$i.ReadOnly,t.depthRangeFor3D);if(r.hasNonElevatedBuckets){const i=!y&&t.terrain;0!==l&&i?e.w(`Occlusion opacity for layer ${r.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: ${r.id}.`):D(n,F,O,Wi.disabled,!1,!0)}if(r.hasElevatedBuckets){"hd-road-markup"===c?d||(O=z,F.push("ELEVATED_ROADS")):(F.push("ELEVATED"),O=z,g&&F.push(_?"CROSS_SLOPE_HORIZONTAL":"CROSS_SLOPE_VERTICAL"),h&&F.push("ELEVATION_REFERENCE_SEA"));const e=P?t.stencilModeFor3D():Wi.disabled;t.forceTerrainMode=!0,D(n,F,O,e,!0,!0),P&&D(n,F,O,e,!0,!1),t.forceTerrainMode=!1}P&&(t.resetStencilClippingMasks(),y&&p.clear({stencil:0})),0===l||t.depthOcclusion||y||t.layersWithOcclusionOpacity.push(t.currentLayer)},fill:function(t,i,r,n){const o=r.paint.get("fill-color"),s=r.paint.get("fill-opacity");if(0===s.constantOr(1))return;const a=r.paint.get("fill-emissive-strength"),l=t.colorModeForDrapableLayerRenderPass(a),c=r.paint.get("fill-pattern"),u=t.opaquePassEnabledForLayer()&&!c.constantOr(1)&&1===o.constantOr(e.ao.transparent).a&&1===s.constantOr(0)?"opaque":"translucent";let h="none";"none"!==r.layout.get("fill-elevation-reference")?h="road":0!==r.paint.get("fill-z-offset").constantOr(1)&&(h="offset");const d=!(!t.terrain||!t.terrain.enabled),p={painter:t,sourceCache:i,layer:r,coords:n,colorMode:l,elevationType:h,terrainEnabled:d,pass:u};if("shadow"!==t.renderPass)if("offset"!==h){if(Yo(p,!1),"road"===h){const e=!d&&"translucent"===t.renderPass;e&&Jo(t,i,r,n,"geometry"),Yo(p,!0,Wi.disabled),e&&function(e){const{painter:t,sourceCache:i,layer:r,coords:n,colorMode:o}=e,s=t.context.gl,a=e.painter.shadowRenderer,l=!!a&&a.enabled,c=new $i(t.context.gl.LEQUAL,$i.ReadOnly,t.depthRangeFor3D);let u=[0,0,0];if(l){const e=t.style.directionalLight,i=t.style.ambientLight;e&&i&&(u=fr(t.style,e,i))}const h=e=>{for(const h of n){const n=i.getTile(h),d=n.getBucket(r);if(!d)continue;const p=d.elevatedStructures;if(!p)continue;let f,m;if(e?(f=p.renderableBridgeSegments,m=p.bridgeProgramConfigurations.get(r.id)):(f=p.renderableTunnelSegments,m=p.tunnelProgramConfigurations.get(r.id)),!f||0===f.segments[0].primitiveLength)continue;m.updatePaintBuffers(),t.prepareDrawTile();const g=t.isTileAffectedByFog(h),_=[];l&&_.push("RENDER_SHADOWS","DEPTH_TEXTURE","NORMAL_OFFSET");const A=t.getOrCreateProgram("elevatedStructures",{config:m,overrideFog:g,defines:_}),y=t.translatePosMatrix(h.projMatrix,n,r.paint.get("fill-translate"),r.paint.get("fill-translate-anchor"));l&&a.setupShadows(n.tileID.toUnwrapped(),A,"vector-tile");const v=po(y,u);t.uploadCommonUniforms(t.context,A,h.toUnwrapped()),A.draw(t,s.TRIANGLES,c,Wi.disabled,o,Xi.backCCW,v,r.id,p.vertexBuffer,p.indexBuffer,f,r.paint,t.transform.zoom,m,[p.vertexBufferNormal])}};h(!0),h(!1)}(p)}}else Yo(p,!1,t.stencilModeFor3D());else t.shadowRenderer&&"road"===h&&!d&&function(e){const{painter:t,sourceCache:i,layer:r,coords:n}=e,o=t.context.gl,s=e.painter.shadowRenderer;for(const e of n){const n=i.getTile(e),a=n.getBucket(r);if(!a)continue;const l=a.elevatedStructures;if(!l)continue;if(!l.shadowCasterSegments||0===l.shadowCasterSegments.segments[0].primitiveLength)continue;t.prepareDrawTile();const c=a.bufferData.programConfigurations.get(r.id),u=t.isTileAffectedByFog(e),h=t.getOrCreateProgram("elevatedStructuresDepth",{config:c,overrideFog:u}),d=s.calculateShadowPassMatrixFromTile(n.tileID.toUnwrapped());t.uploadCommonUniforms(t.context,h,e.toUnwrapped());const p={u_matrix:d,u_depth_bias:0};h.draw(t,o.TRIANGLES,s.getShadowPassDepthMode(),Wi.disabled,s.getShadowPassColorMode(),Xi.disabled,p,r.id,l.vertexBuffer,l.indexBuffer,l.shadowCasterSegments,r.paint,t.transform.zoom,c)}}(p)},"fill-extrusion":function(t,i,r,n){const o=r.paint.get("fill-extrusion-opacity"),s=t.context,a=s.gl,l=t.terrain,c=l&&l.renderingToTexture;if(0===o)return;const u=t.conflationActive&&t.style.isLayerClipped(r,i.getSource()),h=t.style.order.indexOf(r.fqid);if(u&&function(e,t,i,r,n){for(const o of r){const r=t.getTile(o).getBucket(i);r&&(r.updateReplacement(o,e.replacementSource,n),r.uploadCentroid(e.context))}}(t,i,r,n,h),l||u)for(const e of n){const n=i.getTile(e).getBucket(r);n&&rs(t.context,i,e,n,r,l,u)}if("shadow"===t.renderPass&&t.shadowRenderer){const s=t.shadowRenderer;if(l&&o<.65&&r._transitionablePaint._values["fill-extrusion-opacity"].value.expression instanceof e.ad)return;const a=s.getShadowPassDepthMode(),c=s.getShadowPassColorMode();es(t,i,r,n,a,Wi.disabled,c,u)}else if("translucent"===t.renderPass){const h=!r.paint.get("fill-extrusion-pattern").constantOr(1),d=r.paint.get("fill-extrusion-color").constantOr(e.ao.white);if(!c&&0!==d.a){const e=new $i(t.context.gl.LEQUAL,$i.ReadWrite,t.depthRangeFor3D);1===o&&h?es(t,i,r,n,e,Wi.disabled,Qi.unblended,u):(es(t,i,r,n,e,Wi.disabled,Qi.disabled,u),es(t,i,r,n,e,t.stencilModeFor3D(),t.colorModeForRenderPass(),u),t.resetStencilClippingMasks())}if(t.style.enable3dLights()&&h&&(!l&&"globe"!==t.transform.projection.name||c)){const o=r.paint.get("fill-extrusion-opacity"),h=r.paint.get("fill-extrusion-ambient-occlusion-intensity"),d=r.paint.get("fill-extrusion-ambient-occlusion-ground-radius"),p=r.paint.get("fill-extrusion-flood-light-intensity"),f="none"===r.paint.get("fill-extrusion-flood-light-color-use-theme").constantOr("default"),m=r.paint.get("fill-extrusion-flood-light-color").toNonPremultipliedRenderColor(f?null:r.lut).toArray01().slice(0,3),g=h>0&&d>0,_=p>0,A=(e,t,i)=>(1-i)*e+i*t,y=new ts;y.translate=r.paint.get("fill-extrusion-translate"),y.translateAnchor=r.paint.get("fill-extrusion-translate-anchor"),y.edgeRadius=r.layout.get("fill-extrusion-edge-radius"),y.cutoffFadeRange=r.paint.get("fill-extrusion-cutoff-fade-range");const v=s=>{const l=t.depthModeForSublayer(1,$i.ReadOnly,a.LEQUAL,!0),c=r.paint.get(s?"fill-extrusion-ambient-occlusion-ground-attenuation":"fill-extrusion-flood-light-ground-attenuation"),f=A(.1,3,c),g=t._showOverdrawInspector;if(!g){const c=new Wi({func:a.ALWAYS,mask:255},255,255,a.KEEP,a.KEEP,a.REPLACE),g=new Qi([a.ONE,a.ONE,a.ONE,a.ONE],e.ao.transparent,[!1,!1,!1,!0],a.MIN);is(y,t,i,r,n,l,c,g,Xi.disabled,s,"sdf",o,h,d,p,m,f,u,!1)}{const c=g?Wi.disabled:new Wi({func:a.EQUAL,mask:255},255,255,a.KEEP,a.DECR,a.DECR),_=g?t.colorModeForRenderPass():new Qi([a.ONE_MINUS_DST_ALPHA,a.DST_ALPHA,a.ONE,a.ONE],e.ao.transparent,[!0,!0,!0,!0]);is(y,t,i,r,n,l,c,_,Xi.disabled,s,"color",o,h,d,p,m,f,u,!1)}};if(c){const c=(s,l,c)=>{const f=t.depthModeForSublayer(1,$i.ReadOnly,a.LEQUAL,!1),g=r.paint.get(s?"fill-extrusion-ambient-occlusion-ground-attenuation":"fill-extrusion-flood-light-ground-attenuation"),_=A(.1,3,g);{const c=new Qi([a.ONE,a.ONE,a.ONE,a.ONE],e.ao.transparent,[!1,!1,!1,!0]);is(y,t,i,r,n,f,Wi.disabled,c,Xi.disabled,s,"clear",o,h,d,p,m,_,u,l)}{const c=new Wi({func:a.ALWAYS,mask:255},255,255,a.KEEP,a.KEEP,a.REPLACE),g=new Qi([a.ONE,a.ONE,a.ONE,a.ONE],e.ao.transparent,[!1,!1,!1,!0],a.MIN);is(y,t,i,r,n,f,c,g,Xi.disabled,s,"sdf",o,h,d,p,m,_,u,l)}{const c=s?a.ZERO:a.ONE_MINUS_DST_ALPHA,g=new Wi({func:a.EQUAL,mask:255},255,255,a.KEEP,a.DECR,a.DECR),A=new Qi([c,a.DST_ALPHA,a.ONE_MINUS_DST_ALPHA,a.ZERO],e.ao.transparent,[!0,!0,!0,!0]);is(y,t,i,r,n,f,g,A,Xi.disabled,s,"color",o,h,d,p,m,_,u,l)}{const g=new Qi([a.ONE,a.ONE,a.ONE,s?a.ZERO:a.ONE],e.ao.transparent,[!1,!1,!1,!0],s?a.FUNC_ADD:a.MAX);is(y,t,i,r,n,f,Wi.disabled,g,Xi.disabled,s,"clear",o,h,d,p,m,_,u,l,c)}};if(g||_){let i;if(t.prepareDrawTile(),l){const t=l.drapeBufferSize[0],r=l.drapeBufferSize[1];i=l.framebufferCopyTexture,i&&(!i||i.size[0]===t&&i.size[1]===r)||(i&&i.destroy(),i=l.framebufferCopyTexture=new e.T(s,new e.q({width:t,height:r}),a.RGBA8)),i.bind(a.LINEAR,a.CLAMP_TO_EDGE),a.copyTexSubImage2D(a.TEXTURE_2D,0,0,0,0,0,t,r)}g&&c(!0,!1,i),_&&c(!1,!0,i)}}else g&&v(!0),_&&v(!1),(g||_)&&t.resetStencilClippingMasks()}}},building:function(e,t,i,r){e.currentLayer0&&o>0,c=!0;const u=i.paint.get("building-vertical-scale");if(u<=0)return;(!e.shadowRenderer||u<1)&&(c=!1);const h=e.conflationActive&&e.style.isLayerClipped(i,t.getSource()),d=e.style.order.indexOf(i.fqid);if(function(e,t,i,r,n,o){for(const s of o){const o=t.getTile(s).getBucket(i);o&&(n&&o.updateReplacement(s,e.replacementSource,r),o.uploadUpdatedIndexBuffer(e.context))}}(e,t,i,d,h,r),function(e,t,i,r){for(const n of r){const r=t.getTile(n).getBucket(i);r&&r.needsEvaluation()&&r.uploadUpdatedColorBuffer(e.context)}}(e,t,i,r),i.resetLayerRenderingStats(e),e.shadowRenderer&&(e.shadowRenderer.useNormalOffset=!0),"shadow"===e.renderPass&&e.shadowRenderer){const n=e.shadowRenderer,o=[],s=n.getShadowPassDepthMode();ls({painter:e,source:t,layer:i,coords:r,defines:o,blendMode:n.getShadowPassColorMode(),depthMode:s,opacity:a,verticalScale:u,facadeEmissiveChance:0,facadeAOIntensity:0,floodLightIntensity:0,floodLightColor:[0,0,0]})}else if("translucent"===e.renderPass){let d=["HAS_ATTRIBUTE_a_part_color_emissive","LIGHTING_3D_MODE"];c&&(d=d.concat("RENDER_SHADOWS","DEPTH_TEXTURE")),e.shadowRenderer&&e.shadowRenderer.useNormalOffset&&(d=d.concat("NORMAL_OFFSET"));const p=i.paint.get("building-facade-emissive-chance"),f=i.paint.get("building-ambient-occlusion-intensity"),m=i.paint.get("building-flood-light-intensity"),g="none"===i.paint.get("building-flood-light-color-use-theme").constantOr("default"),_=i.paint.get("building-flood-light-color").toNonPremultipliedRenderColor(g?null:i.lut).toArray01().slice(0,3),A=i.paint.get("building-flood-light-ground-attenuation"),y=m>0,v=new $i(e.context.gl.LEQUAL,$i.ReadWrite,e.depthRangeFor3D);a<1&&ls({painter:e,source:t,layer:i,coords:r,defines:d,blendMode:Qi.disabled,depthMode:v,opacity:a,verticalScale:u,facadeEmissiveChance:p,facadeAOIntensity:f,floodLightIntensity:m,floodLightColor:_,depthOnly:!0});const x=e.colorModeForRenderPass();ls({painter:e,source:t,layer:i,coords:r,defines:d,blendMode:x,depthMode:v,opacity:a,verticalScale:u,facadeEmissiveChance:p,facadeAOIntensity:f,floodLightIntensity:m,floodLightColor:_}),l&&cs(e,t,i,r,!0,a,n,o,m,_,s,h),y&&cs(e,t,i,r,!1,a,n,o,m,_,A,h)}else if("light-beam"===e.renderPass){const n=["HAS_ATTRIBUTE_a_part_color_emissive","HAS_ATTRIBUTE_a_bloom_attenuation"],o=new $i(e.context.gl.LEQUAL,$i.ReadOnly,e.depthRangeFor3D);ls({painter:e,source:t,layer:i,coords:r,defines:n,blendMode:Qi.alphaBlended,depthMode:o,opacity:a,verticalScale:u,facadeEmissiveChance:0,facadeAOIntensity:0,floodLightIntensity:0,floodLightColor:[0,0,0]})}e.shadowRenderer&&(e.shadowRenderer.useNormalOffset=!1),e.resetStencilClippingMasks()},hillshade:function(e,t,i,r){if("offscreen"!==e.renderPass&&"translucent"!==e.renderPass)return;if(e.style.disableElevatedTerrain)return;const n=e.context,o=e.terrain&&e.terrain.renderingToTexture,[s,a]="translucent"!==e.renderPass||o?[{},r]:e.stencilConfigForOverlap(r);for(const r of a){const n=t.getTile(r);if(n.needsHillshadePrepare&&"offscreen"===e.renderPass)Yr(e,n,i);else if("translucent"===e.renderPass){const t=e.depthModeForSublayer(0,$i.ReadOnly),a=i.paint.get("hillshade-emissive-strength"),l=e.colorModeForDrapableLayerRenderPass(a),c=o&&e.terrain?e.terrain.stencilModeForRTTOverlap(r):s[r.overscaledZ];Xr(e,r,n,i,t,c,l)}}n.viewport.set([0,0,e.width,e.height]),e.resetStencilClippingMasks()},raster:function(t,i,r,n,o,s){if("translucent"!==t.renderPass)return;if(0===r.paint.get("raster-opacity"))return;const a="globe"===t.transform.projection.name,l=0!==r.paint.get("raster-elevation"),c=l&&a;if(t.renderElevatedRasterBackface&&!c)return;const u=t.context,h=u.gl,d=i.getSource(),p=function(t,i,r,n){const o=i.paint.get("raster-color"),s="raster-array"===t.type,a=[],l=i.paint.get("raster-resampling"),c=i.paint.get("raster-color-mix");let u=i.paint.get("raster-color-range");const h=[c[0],c[1],c[2],0],d=c[3];let p="nearest"===l?n.NEAREST:n.LINEAR;if(s&&(a.push("RASTER_ARRAY"),o||a.push("RASTER_COLOR"),"linear"===l&&a.push("RASTER_ARRAY_LINEAR"),p=n.NEAREST,!u&&t.rasterLayers)){const e=t.rasterLayers.find(({id:e})=>e===i.sourceLayer);e&&e.fields&&e.fields.range&&(u=e.fields.range)}if(u=u||[0,1],o){a.push("RASTER_COLOR"),r.activeTexture.set(n.TEXTURE2),i.updateColorRamp(u);let t=i.colorRampTexture;t||(t=i.colorRampTexture=new e.T(r,i.colorRamp,n.RGBA8)),t.bind(n.LINEAR,n.CLAMP_TO_EDGE)}return{mix:h,range:u,offset:d,defines:a,resampling:p}}(d,r,u,h);if(d instanceof e.aT&&!n.length&&!a)return;const f=r.paint.get("raster-emissive-strength"),m=t.colorModeForDrapableLayerRenderPass(f),g=t.terrain&&t.terrain.renderingToTexture,_=!t.options.moving,A="nearest"===r.paint.get("raster-resampling")?h.NEAREST:h.LINEAR;if(d instanceof e.aT&&!n.length&&(d.onNorthPole||d.onSouthPole)){const e=l?t.stencilModeFor3D():Wi.disabled;return void hs(!!d.onNorthPole,null,t,i,r,f,p,Xi.disabled,e)}if(!n.length)return;const[y,v]=d instanceof e.aT||g?[{},n]:t.stencilConfigForOverlap(n),x=v[v.length-1].overscaledZ;c&&p.defines.push("PROJECTION_GLOBE_VIEW"),l&&p.defines.push("RENDER_CUTOFF");const b=(n,o,v)=>{for(const b of n){const n=b.toUnwrapped(),w=i.getTile(b);if(g&&(!w||!w.hasData()))continue;u.activeTexture.set(h.TEXTURE0);const T=ps(w,d,r,p);if(!T||!T.texture)continue;const{texture:E,mix:C,offset:B,tileSize:S,buffer:I}=T;let M,P;g?(M=$i.disabled,P=b.projMatrix):l?(M=new $i(h.LEQUAL,$i.ReadWrite,t.depthRangeFor3D),P=a?Float32Array.from(t.transform.expandedFarZProjMatrix):t.transform.calculateProjMatrix(n,_)):(M=t.depthModeForSublayer(b.overscaledZ-x,1===r.paint.get("raster-opacity")?$i.ReadWrite:$i.ReadOnly,h.LESS),P=t.transform.calculateProjMatrix(n,_));const R=t.terrain&&g?t.terrain.stencilModeForRTTOverlap(b):y[b.overscaledZ],L=s?0:r.paint.get("raster-fade-duration");w.registerFadeDuration(L);const F=i.findLoadedParent(b,0),k=$n(w,F,i,t.transform,L);let D,O;!k.isFading&&w.refreshedUponExpiration&&(w.refreshedUponExpiration=!1),t.terrain&&t.terrain.prepareDrawTile(),u.activeTexture.set(h.TEXTURE0),E.bind(A,h.CLAMP_TO_EDGE),u.activeTexture.set(h.TEXTURE1),F?(F.texture&&F.texture.bind(A,h.CLAMP_TO_EDGE),D=Math.pow(2,F.tileID.overscaledZ-w.tileID.overscaledZ),O=[w.tileID.canonical.x*D%1,w.tileID.canonical.y*D%1]):E.bind(A,h.CLAMP_TO_EDGE),"useMipmap"in E&&u.extTextureFilterAnisotropic&&t.transform.pitch>20&&h.texParameterf(h.TEXTURE_2D,u.extTextureFilterAnisotropic.TEXTURE_MAX_ANISOTROPY_EXT,u.extTextureFilterAnisotropicMax);const z=t.transform;let U;const N=l?ds(z):[0,0,0,0];let V,j,G,H,Q,$=0;if(c&&d instanceof e.aT&&d.coordinates.length>3)V=Float32Array.from(e.bj(e.dI(new e.cC(0,0,0)))),j=Float32Array.from(z.globeMatrix),G=Float32Array.from(e.dE(z)),H=[e.aF(z.center.lng),e.aJ(z.center.lat)],U=d.elevatedGlobePerspectiveTransform,Q=d.elevatedGlobeGridMatrix||new Float32Array(9);else if(c){const t=e.dF(b.canonical);$=e.dG(t.getCenter().lat),V=Float32Array.from(e.bj(e.dI(b.canonical))),j=Float32Array.from(z.globeMatrix),G=Float32Array.from(e.dE(z)),H=[e.aF(z.center.lng),e.aJ(z.center.lat)],U=[0,0],Q=Float32Array.from(e.dH(b.canonical,t,$,z.worldSize/z._pixelsPerMercatorPixel))}else U=d instanceof e.aT?d.perspectiveTransform:[0,0],V=new Float32Array(16),j=new Float32Array(9),G=new Float32Array(16),H=[0,0],Q=new Float32Array(9);const Z=To(P,V,j,G,Q,O||[0,0],e.aj(t.transform.zoom),H,N,D||1,k,r,U,l?r.paint.get("raster-elevation"):0,2,C,B,p.range,S,I,f),W=t.isTileAffectedByFog(b),q=t.getOrCreateProgram("raster",{defines:p.defines,overrideFog:W});if(t.uploadCommonUniforms(u,q,n),d instanceof e.aT){const i=d.elevatedGlobeVertexBuffer,n=d.elevatedGlobeIndexBuffer;if(g||!a)d.boundsBuffer&&d.boundsSegments&&q.draw(t,h.TRIANGLES,M,Wi.disabled,m,Xi.disabled,Z,r.id,d.boundsBuffer,t.quadTriangleIndexBuffer,d.boundsSegments);else if(i&&n){const s=z.zoom<=e.cZ?d.elevatedGlobeSegments:d.getSegmentsForLongitude(z.center.lng);s&&q.draw(t,h.TRIANGLES,M,Wi.disabled,m,o,Z,r.id,i,n,s)}}else if(c){M=new $i(h.LEQUAL,$i.ReadOnly,t.depthRangeFor3D);const e=t.globeSharedBuffers;if(e){const[i,n,s]=e.getGridBuffers($,!1);q.draw(t,h.TRIANGLES,M,v||R,t.colorModeForRenderPass(),o,Z,r.id,i,n,s)}}else{const{tileBoundsBuffer:e,tileBoundsIndexBuffer:i,tileBoundsSegments:n}=t.getTileBoundsBuffers(w);q.draw(t,h.TRIANGLES,M,R,m,Xi.disabled,Z,r.id,e,i,n)}}if(!(d instanceof e.aT)&&c)for(const e of n){const n=e.canonical.y===(1<>>16,2654435769),((e=Math.imul(e^e>>>16,2654435769))>>>0)/4294967296},n=1/1.1;for(let e=0;ee.e8[t](n));f.push(n);const m=n.canonical.x,g=n.canonical.y;for(const e of f){const o=i.getTile(l?e.wrapped():e);if(!o)continue;const a=o.rasterParticleState;if(!a)continue;const u=e.canonical.x+(1<e.tileID)),f&&(u.activeTexture.set(h.TEXTURE0),t.imageManager.bind(t.context,r.scope)),c){const i=t.getOrCreateProgram(v,{overrideFog:!1,overrideRtt:!0}),n=new Float32Array(e.bz([])),u=new e.aP(0,0,0,0,0),d=f?Lo(n,l,a,t,0,r.scope,m,c,{tileID:u,tileSize:p}):Ro(n,l,a,o.toPremultipliedRenderColor(s?null:r.lut));i.draw(t,h.TRIANGLES,A,_,y,Xi.disabled,d,r.id,t.viewportBuffer,t.quadTriangleIndexBuffer,t.viewportSegments)}else for(const e of b){const g=t.isTileAffectedByFog(e),b=t.getOrCreateProgram(v,{overrideFog:g}),w=e.toUnwrapped(),T=n?e.projMatrix:t.transform.calculateProjMatrix(w);t.prepareDrawTile();const E=i?i.getTile(e):x?x[e.key]:new It(e,p,d.zoom,t),C=f?Lo(T,l,a,t,0,r.scope,m,c,{tileID:e,tileSize:p}):Ro(T,l,a,o.toPremultipliedRenderColor(s?null:r.lut));t.uploadCommonUniforms(u,b,w);const{tileBoundsBuffer:B,tileBoundsIndexBuffer:S,tileBoundsSegments:I}=t.getTileBoundsBuffers(E);b.draw(t,h.TRIANGLES,A,_,y,Xi.disabled,C,r.id,B,S,I)}},sky:function(t,i,r){const n=t._atmosphere?e.aj(t.transform.zoom):1,o=r.paint.get("sky-opacity")*n;if(0===o)return;const s=t.context,a=r.paint.get("sky-type"),l=new $i(s.gl.LEQUAL,$i.ReadOnly,[0,1]),c=t.frameCounter/1e3%1;"atmosphere"===a?"offscreen"===t.renderPass?r.needsSkyboxCapture(t)&&(function(t,i){const r=t.context,n=r.gl;let o=i.skyboxFbo;if(!o){o=i.skyboxFbo=r.createFramebuffer(32,32,!0,null),i.skyboxGeometry=new Ps(r),i.skyboxTexture=r.gl.createTexture(),n.bindTexture(n.TEXTURE_CUBE_MAP,i.skyboxTexture),n.texParameteri(n.TEXTURE_CUBE_MAP,n.TEXTURE_WRAP_S,n.CLAMP_TO_EDGE),n.texParameteri(n.TEXTURE_CUBE_MAP,n.TEXTURE_WRAP_T,n.CLAMP_TO_EDGE),n.texParameteri(n.TEXTURE_CUBE_MAP,n.TEXTURE_MIN_FILTER,n.LINEAR),n.texParameteri(n.TEXTURE_CUBE_MAP,n.TEXTURE_MAG_FILTER,n.LINEAR);for(let e=0;e<6;++e)n.texImage2D(n.TEXTURE_CUBE_MAP_POSITIVE_X+e,0,n.RGBA,32,32,0,n.RGBA,n.UNSIGNED_BYTE,null)}r.bindFramebuffer.set(o.framebuffer),r.viewport.set([0,0,32,32]);const s=i.getCenter(t,!0),a=t.getOrCreateProgram("skyboxCapture"),l=new Float64Array(16);e.bz(l),e.em(l,l,.5*-Math.PI),Rs(t,i,a,l,s,0),e.bz(l),e.em(l,l,.5*Math.PI),Rs(t,i,a,l,s,1),e.bz(l),e.cT(l,l,.5*-Math.PI),Rs(t,i,a,l,s,2),e.bz(l),e.cT(l,l,.5*Math.PI),Rs(t,i,a,l,s,3),e.bz(l),Rs(t,i,a,l,s,4),e.bz(l),e.em(l,l,Math.PI),Rs(t,i,a,l,s,5),r.viewport.set([0,0,t.width,t.height])}(t,r),r.markSkyboxValid(t)):"sky"===t.renderPass&&function(e,t,i,r,n){const o=e.context,s=o.gl,a=e.transform,l=e.getOrCreateProgram("skybox");o.activeTexture.set(s.TEXTURE0),s.bindTexture(s.TEXTURE_CUBE_MAP,t.skyboxTexture);const c=((e,t,i,r,n)=>({u_matrix:e,u_sun_direction:t,u_cubemap:0,u_opacity:r,u_temporal_offset:n}))(a.skyboxMatrix,t.getCenter(e,!1),0,r,n);e.uploadCommonUniforms(o,l),l.draw(e,s.TRIANGLES,i,Wi.disabled,e.colorModeForRenderPass(),Xi.backCW,c,"skybox",t.skyboxGeometry.vertexBuffer,t.skyboxGeometry.indexBuffer,t.skyboxGeometry.segment)}(t,r,l,o,c):"gradient"===a&&"sky"===t.renderPass&&function(t,i,r,n,o){const s=t.context,a=s.gl,l=t.transform,c=t.getOrCreateProgram("skyboxGradient");i.skyboxGeometry||(i.skyboxGeometry=new Ps(s)),s.activeTexture.set(a.TEXTURE0);let u=i.colorRampTexture;u||(u=i.colorRampTexture=new e.T(s,i.colorRamp,a.RGBA8)),u.bind(a.LINEAR,a.CLAMP_TO_EDGE);const h=((t,i,r,n,o)=>({u_matrix:t,u_color_ramp:0,u_center_direction:i,u_radius:e.an(r),u_opacity:n,u_temporal_offset:o}))(l.skyboxMatrix,i.getCenter(t,!1),i.paint.get("sky-gradient-radius"),n,o);t.uploadCommonUniforms(s,c),c.draw(t,a.TRIANGLES,r,Wi.disabled,t.colorModeForRenderPass(),Xi.backCW,h,"skyboxGradient",i.skyboxGeometry.vertexBuffer,i.skyboxGeometry.indexBuffer,i.skyboxGeometry.segment)}(t,r,l,o,c)},custom:function(t,i,r,n){const o=t.context,s=r.implementation;if(!t.transform.projection.unsupportedLayers||!t.transform.projection.unsupportedLayers.includes("custom")||t.terrain&&(t.terrain.renderingToTexture||"offscreen"===t.renderPass)&&r.isDraped(i)){if("offscreen"===t.renderPass){const i=s.prerender;if(i){if(t.setCustomLayerDefaults(),o.setColorMode(t.colorModeForRenderPass()),"globe"===t.transform.projection.name){const r=t.transform.pointMerc;i.call(s,o.gl,t.transform.customLayerMatrix(),t.transform.getProjection(),t.transform.globeToMercatorMatrix(),e.aj(t.transform.zoom),[r.x,r.y],t.transform.pixelsPerMeterRatio)}else i.call(s,o.gl,t.transform.customLayerMatrix());o.setDirty(),t.setBaseState()}}else if("translucent"===t.renderPass){if(t.terrain&&t.terrain.renderingToTexture){const e=s.renderToTile;if(e){const i=n[0].canonical,r={x:i.x+n[0].wrap*(s.wrapTileId?0:1<{u&&(u.useNormalOffset=!0,h||(u.enabled=!0))},p=i.getSource();if("light-beam"===t.renderPass&&"batched-model"!==p.type)return;if("vector"===p.type||"geojson"===p.type)return function(t,i,r,n,o){const s=t.transform,a="globe"===s.projection.name,l=s.getFreeCameraOptions().position;if(!t.modelManager)return;const c=t.modelManager;r.modelManager=c;const u=t.shadowRenderer;if(!r._unevaluatedLayout._values.hasOwnProperty("model-id"))return;const h=r._unevaluatedLayout._values["model-id"],d=Object.assign({},r.layout.get("model-id").parameters),p=t.style.order.indexOf(r.fqid);for(const f of n){const n=i.getTile(f).getBucket(r);if(!n||n.projection.name!==s.projection.name)continue;const m=n.getModelUris();if(m&&!n.modelsRequested&&(c.addModelsFromBucket(m,o),n.modelsRequested=!0),a)d.zoom=f.overscaledZ;else{const e=Ks(f,s);d.zoom=e}const g=h.possiblyEvaluate(d);if(Ws(t,n,f),qs.shadowUniformsInitialized=!1,qs.useSingleShadowCascade=!!u&&0===u.getMaxCascadeForTile(f.toUnwrapped()),"shadow"===t.renderPass&&u){if(1===t.currentShadowCascade&&n.isInsideFirstShadowMapFrustum)continue;const i=s.calculatePosMatrix(f.toUnwrapped(),s.worldSize);if(qs.tileMatrix.set(i),qs.shadowTileMatrix=Float32Array.from(u.calculateShadowPassMatrixFromMatrix(i)),qs.aabb.min=[0,0,0],qs.aabb.max[0]=qs.aabb.max[1]=e.al,qs.aabb.max[2]=0,Ys(n,qs,t,r.scope))continue}const _=1<0&&t.style.isLayerClipped(r,i.getSource())&&n.updateReplacement(f,t.replacementSource,p,o)&&(n.uploaded=!1,n.upload(t.context));let y=0;const v=new Array,x=new Array,b=new Array;for(let i in n.instancesPerModel){const s=n.instancesPerModel[i];s.features.length>0&&!a&&(i=g.evaluate(s.features[0].feature,{}));const u=c.getModel(i,o);if(u||c.hasURLBeenRequested(i)||n.modelUris.includes(i)||(n.modelUris.push(i),n.modelsRequested=!1),u&&u.uploaded)if(a){const i=e.c4([],[l.x,l.y,l.z],t.transform.worldSize);e.ev(i,i);for(let r=0;r0&&r.elevationUpdate(e.terrain,n,s,i.source),r.needsReEvaluation(e,o,i)&&r.evaluate(i))}})(t,i,r,n),function(){let c,h,E;b?(c=n.length-1,h=-1,E=-1):(c=0,h=n.length,E=1);const C=new Float64Array(16),B=e.cz(),S=new e.P(0,0);for(let I=c;I!==h;I+=E){const c=n[I],h=i.getTile(c).getBucket(r);if(!h||!h.uploaded)continue;let E=!1;l&&(E=0===l.getMaxCascadeForTile(c.toUnwrapped()));const M=s.calculatePosMatrix(c.toUnwrapped(),s.worldSize),P=h.modelTraits;!y&&b&&(e.bk(C,M),e.af(B,u,C),S.x=B[0],S.y=B[1]);const R=[];h.setFilter(r.filter);for(const i of h.getNodesInfo()){if(i.hiddenByReplacement)continue;if(!i.node.meshes)continue;const r=i.node;let n=0;t.terrain&&r.elevation&&(n=r.elevation*t.terrain.exaggeration());const o=(()=>{const t=i.aabb;return A.min=[...t.min],A.max=[...t.max],A.min[2]+=n,A.max[2]+=n,e.af(A.min,A.min,M),e.af(A.max,A.max,M),A})(),a=i.evaluatedScale;if(a[0]<=1&&a[1]<=1&&a[2]<=1&&0===o.intersects(v))continue;if(!y&&b){const t=1/6;i.cameraCollisionOpacity=u[0]>o.min[0]&&u[0]o.min[1]&&u[1]!b||1===e.opacity&&1===t.opacity?e.deptht.depth?-1:1);for(const i of R){const n=i.nodeInfo,c=n.node;let u=e.aB([],f,i.tileModelMatrix);e.aB(u,d,u);const h=e.bk([],u);e.ef(h,h),e.cR(h,h,Js),u=e.aB(u,u,c.globalMatrix);const p="light-beam"===t.renderPass,m="none"===r.paint.get("model-color-use-theme").constantOr("default"),A=P&e.eH.HasMapboxMeshFeatures,v=A?0:n.evaluatedRMEA[0][2];for(let e=0;e=Ve||n>=Ve}}const B=d.material;let S;B.occlusionTexture&&B.occlusionTexture.offsetScale&&(S=B.occlusionTexture.offsetScale,b.defines.push("OCCLUSION_TEXTURE_TRANSFORM"));const I=t.getOrCreateProgram("model",b);!y&&l&&l.setupShadowsFromMatrix(i.tileModelMatrix,I,l.useNormalOffset),t.uploadCommonUniforms(o,I,null,C);const M=B.pbrMetallicRoughness;M.metallicFactor=.9,M.roughnessFactor=.5;const P=ko(new Float32Array(x),new Float32Array(u),new Float32Array(h),new Float32Array(c.globalMatrix),t,i.opacity,M.baseColorFactor,B.emissiveFactor,M.metallicFactor,M.roughnessFactor,B,v,r,[0,0,0],S);!f&&(n.hasTranslucentParts||i.opacity<1)&&I.draw(t,o.gl.TRIANGLES,g,Wi.disabled,Qi.disabled,Xi.backCCW,P,r.id,d.vertexBuffer,d.indexBuffer,d.segments,r.paint,t.transform.zoom,void 0,w),I.draw(t,o.gl.TRIANGLES,f?_:g,Wi.disabled,f||i.opacity<1||n.hasTranslucentParts?Qi.alphaBlended:Qi.unblended,Xi.backCCW,P,r.id,d.vertexBuffer,d.indexBuffer,d.segments,r.paint,t.transform.zoom,void 0,w)}}}}()}(t,i,r,n),void d();if("model"!==p.type)return;const f=p.getModels(),m=[],g=t.transform.getFreeCameraOptions().position,_=e.c4([],[g.x,g.y,g.z],t.transform.worldSize);e.ev(_,_);const A=[],y=[];let v=0;for(const n of f){const o=i.getFeatureState("",n.id),s={type:"Unknown",id:n.id,properties:n.featureProperties},c=r.paint.get("model-rotation").evaluate(s,o),u=r.paint.get("model-scale").evaluate(s,o),h=r.paint.get("model-translation").evaluate(s,o);Qs(r,n.id,o,n.featureProperties,n.nodeOverrideNames,n.nodeOverrides),$s(r,n.id,o,n.featureProperties,n.materialOverrideNames,n.materialOverrides),n.nodeOverrides.size>0&&n.computeBoundsAndApplyParent(),n.computeModelMatrix(t,c,u,h,l,a,!1);const d=e.bz([]),p=e.ee(n.position.lat,t.transform.zoom),f=e.bp([],[1,1,1/p]);e.bq(d,d,_),m.push({zScaleMatrix:f,negCameraPosMatrix:d});for(const e of n.nodes)Gs(t,e,n.matrix,t.transform.expandedFarZProjMatrix,v,A,y,n.materialOverrides);v++}if(A.sort((e,t)=>t.depth-e.depth),"shadow"!==t.renderPass)Zs(t,r,o,A,y,m),d();else{for(const e of y)Hs(e.mesh,e.nodeModelMatrix,t,r);for(const e of A)Hs(e.mesh,e.nodeModelMatrix,t,r);d()}}},ya={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 r of i){const i=t.getTile(r).getBucket(e);if(i&&("none"!==i.elevationType?e.hasElevatedBuckets=!0:e.hasNonElevatedBuckets=!0,e.hasElevatedBuckets&&e.hasNonElevatedBuckets))break}}}else e.hasNonElevatedBuckets=!0},model:function(e,t,i){const r=t.getSource();if(!r.loaded())return;if("vector"===r.type||"geojson"===r.type){const t=js(r,e,i.style._importedAsBasemap);return void(i.modelManager&&i.modelManager.upload(i,t))}if("batched-model"===r.type)return;if("model"!==r.type)return;const n=r.getModels();for(const e of n)e.upload(i.context)},raster:function(e,t,i){const r=t.getSource();if(!(r instanceof ht&&r.loaded()))return;const n=e.sourceLayer||r.rasterLayerIds&&r.rasterLayerIds[0];if(!n)return;const o=e.paint.get("raster-array-band")||r.getInitialBand(n);if(null==o)return;const s=t.getIds().map(e=>t.getTileByID(e));for(const t of s)t.updateNeeded(e.id,o)&&r.prepareTile(t,n,e.id,o)},"raster-particle":function(e,t,i){const r=t.getSource();if(!(r instanceof ht&&r.loaded()))return;const n=e.sourceLayer||r.rasterLayerIds&&r.rasterLayerIds[0];if(!n)return;const o=e.paint.get("raster-particle-array-band")||r.getInitialBand(n);if(null==o)return;const s=t.getIds().map(e=>t.getTileByID(e));for(const t of s)t.updateNeeded(e.id,o)&&r.prepareTile(t,n,e.id,o)}},va={fill:Jo},xa={fill:function(e,t,i,r){if(!i.layout||"none"===i.layout.get("fill-elevation-reference")||0===i.paint.get("fill-opacity").constantOr(1))return;const n=e.context.gl,o=new $i(n.LEQUAL,$i.ReadOnly,e.depthRangeFor3D),s=new Wi({func:n.ALWAYS,mask:255},255,255,n.KEEP,n.KEEP,n.REPLACE),a=e.transform.getFreeCameraOptions().position,l=e.getOrCreateProgram("elevatedStructuresDepthReconstruct");for(const c of r){const r=t.getTile(c),u=r.getBucket(i);if(!u)continue;const h=u.elevatedStructures;if(!h||0===h.depthSegments.segments[0].primitiveLength)continue;const d=Xo(c.toUnwrapped(),a),p=e.translatePosMatrix(c.projMatrix,r,i.paint.get("fill-translate"),i.paint.get("fill-translate-anchor")),f=fo(p,d,0,1,0);l.draw(e,n.TRIANGLES,o,s,Qi.disabled,Xi.disabled,f,i.id,h.vertexBuffer,h.indexBuffer,h.depthSegments,i.paint,e.transform.zoom)}}};class ba{constructor(t,i,r,n,o,s){this.context=new jo(t,i),this.transform=r,this._tileTextures={},this.frameCopies=[],this.loadTimeStamps=[],this.tp=o,this._timeStamp=e.o.now(),this._averageFPS=0,this._fpsHistory=[],this._dt=0,this._debugParams={forceEnablePrecipitation:!1,showTerrainProxyTiles:!1,fpsWindow:30,continousRedraw:!1,enabledLayers:{}};const a=["fill","line","symbol","circle","heatmap","fill-extrusion","building","raster","raster-particle","hillshade","model","background","sky"];for(const e of a)this._debugParams.enabledLayers[e]=!0;o.registerParameter(this._debugParams,["Terrain"],"showTerrainProxyTiles",{},()=>{this.style.map.triggerRepaint()}),o.registerParameter(this._debugParams,["Precipitation"],"forceEnablePrecipitation"),o.registerParameter(this._debugParams,["FPS"],"fpsWindow",{min:1,max:100,step:1}),o.registerBinding(this._debugParams,["FPS"],"continousRedraw",{readonly:!0,label:"continuous redraw"}),o.registerBinding(this,["FPS"],"_averageFPS",{readonly:!0,label:"value"}),o.registerBinding(this,["FPS"],"_averageFPS",{readonly:!0,label:"graph",view:"graph",min:0,max:200});for(const e of a)o.registerParameter(this._debugParams.enabledLayers,["Debug","Layers"],e);this.occlusionParams=new na(o),this.setup(),this.numSublayers=Lt.maxUnderzooming+Lt.maxOverzooming+1,this.depthEpsilon=1/Math.pow(2,16),this.deferredRenderGpuTimeQueries=[],this.gpuTimers={},this.frameCounter=0,this._backgroundTiles={},this.conflationActive=!1,this.replacementSource=new e.eO,this.longestCutoffRange=0,this.minCutoffZoom=0,this._fogVisible=!1,this._cachedTileFogOpacities={},this._shadowRenderer=new hr(this),this._wireframeDebugCache=new ra,this.renderDefaultNorthPole=!0,this.renderDefaultSouthPole=!0,this.layersWithOcclusionOpacity=[];const l=new e.q({width:1,height:1},Uint8Array.of(0,0,0,0));this.emptyDepthTexture=new e.T(this.context,l,t.RGBA8),this._clippingActiveLastFrame=!1,this.scaleFactor=n,this.worldview=s}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 Kn(this,e));const r=this._terrain;this.transform.elevation=i?r:null,r.update(e,this.transform,t),this.transform.elevation&&!r.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,r]=t.getFovAdjustedRange(this.transform._fov);if(i>r)return void(this.transform.fogCullDistSq=null);const n=i+.78*(r-i);this.transform.fogCullDistSq=n*n}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 Kn(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.o.devicePixelRatio,this.height=i*e.o.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.al,0),i.emplaceBack(0,e.al),i.emplaceBack(e.al,e.al),this.tileExtentBuffer=t.createVertexBuffer(i,e.be.members),this.tileExtentSegments=e.bf.simpleSegment(0,0,4,2);const r=new e.bc;r.emplaceBack(0,0),r.emplaceBack(e.al,0),r.emplaceBack(0,e.al),r.emplaceBack(e.al,e.al),this.debugBuffer=t.createVertexBuffer(r,e.be.members),this.debugSegments=e.bf.simpleSegment(0,0,4,5);const n=new e.bc;n.emplaceBack(-1,-1),n.emplaceBack(1,-1),n.emplaceBack(-1,1),n.emplaceBack(1,1),this.viewportBuffer=t.createVertexBuffer(n,e.be.members),this.viewportSegments=e.bf.simpleSegment(0,0,4,2);const o=new e.a$;o.emplaceBack(0,0,0,0),o.emplaceBack(e.al,0,e.al,0),o.emplaceBack(0,e.al,0,e.al),o.emplaceBack(e.al,e.al,e.al,e.al),this.mercatorBoundsBuffer=t.createVertexBuffer(o,e.bh.members),this.mercatorBoundsSegments=e.bf.simpleSegment(0,0,4,2);const s=new e.b0;s.emplaceBack(0,1,2),s.emplaceBack(2,1,3),this.quadTriangleIndexBuffer=t.createIndexBuffer(s);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.q({width:1,height:1},Uint8Array.of(0,0,0,0)),t.gl.RGBA8),this.identityMat=e.bB();const l=this.context.gl;this.stencilClearMode=new Wi({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 e=this.context.gl;this.nextStencilID=1,this.currentStencilSource=void 0,this._tileClippingMaskIDs={},this.getOrCreateProgram("clippingMask").draw(this,e.TRIANGLES,$i.disabled,this.stencilClearMode,Qi.disabled,Xi.disabled,Qn(this.identityMat),"$clipping",this.viewportBuffer,this.quadTriangleIndexBuffer,this.viewportSegments)}resetStencilClippingMasks(){this.terrain||(this.currentStencilSource=void 0,this._tileClippingMaskIDs={})}_renderTileClippingMasks(e,t,i){if(!t||this.currentStencilSource===t.id||!e.isTileClipped()||!i||0===i.length)return;if(this._tileClippingMaskIDs&&!this.terrain){let e=!1;for(const t of i)if(void 0===this._tileClippingMaskIDs[t.key]){e=!0;break}if(!e)return}this.currentStencilSource=t.id;const r=this.context,n=r.gl;this.nextStencilID+i.length>256&&this.clearStencil(),r.setColorMode(Qi.disabled),r.setDepthMode($i.disabled);const o=this.getOrCreateProgram("clippingMask");this._tileClippingMaskIDs={};for(const e of i){const i=t.getTile(e),r=this._tileClippingMaskIDs[e.key]=this.nextStencilID++,{tileBoundsBuffer:s,tileBoundsIndexBuffer:a,tileBoundsSegments:l}=this.getTileBoundsBuffers(i);o.draw(this,n.TRIANGLES,$i.disabled,new Wi({func:n.ALWAYS,mask:0},r,255,n.KEEP,n.KEEP,n.REPLACE),Qi.disabled,Xi.disabled,Qn(e.projMatrix),"$clipping",s,a,l)}}stencilModeFor3D(){this.currentStencilSource=void 0,this.nextStencilID+1>256&&this.clearStencil();const e=this.nextStencilID++,t=this.context.gl;return new Wi({func:t.NOTEQUAL,mask:255},e,255,t.KEEP,t.KEEP,t.REPLACE)}stencilModeForClipping(e){if(this.terrain)return this.terrain.stencilModeForRTTOverlap(e);const t=this.context.gl;return new Wi({func:t.EQUAL,mask:255},this._tileClippingMaskIDs[e.key],0,t.KEEP,t.KEEP,t.REPLACE)}stencilConfigForOverlap(e){const t=this.context.gl,i=e.sort((e,t)=>t.overscaledZ-e.overscaledZ),r=i[i.length-1].overscaledZ,n=i[0].overscaledZ-r+1;if(n>1){this.currentStencilSource=void 0,this.nextStencilID+n>256&&this.clearStencil();const e={};for(let i=0;ithis.style&&this.style.enable3dLights()&&this.terrain&&this.terrain.renderingToTexture)()&&"translucent"===this.renderPass?new Qi([i.ONE,i.ONE_MINUS_SRC_ALPHA,i.CONSTANT_ALPHA,i.ONE_MINUS_SRC_ALPHA],new e.ao(0,0,0,void 0===t?0:t),[!0,!0,!0,!0]):this.colorModeForRenderPass()}depthModeForSublayer(e,t,i,r=!1){if(this.depthOcclusion)return new $i(this.context.gl.GREATER,$i.ReadOnly,this.depthRangeFor3D);if(!this.opaquePassEnabledForLayer()&&!r)return $i.disabled;const n=1-((1+this.currentLayer)*this.numSublayers+e)*this.depthEpsilon;return new $i(i||this.context.gl.LEQUAL,t,[n,n])}opaquePassEnabledForLayer(){return this.currentLayerthis._debugParams.fpsWindow&&this._fpsHistory.splice(0,this._fpsHistory.length-this._debugParams.fpsWindow),this._averageFPS=Math.round(this._fpsHistory.reduce((e,t)=>e+t/this._fpsHistory.length,0))}render(t,i){const r=e.o.now();this._dt=r-this._timeStamp,this._timeStamp=r,this._wireframeDebugCache.update(this.frameCounter),this._debugParams.continousRedraw=t.map.repaint,this.style=t,this.options=i;const n=this.style._mergedLayers,o=!(!this.terrain||!this.terrain.enabled),s=()=>this.style._getOrder(o).filter(e=>{const t=n[e];return!(t.type in this._debugParams.enabledLayers)||this._debugParams.enabledLayers[t.type]});let a=s(),l=!1,c=!1,u=null;for(const e of a){const t=n[e];"circle"===t.type?l=!0:"building"===t.type?u=t:"symbol"===t.type&&(t.hasOcclusionOpacityProperties?c=!0:l=!0)}let h=a.map(e=>n[e]);const d=this.style._mergedSourceCaches;this.imageManager=t.imageManager,this.modelManager=t.modelManager,this.symbolFadeChange=t.placement.symbolFadeChange(e.o.now()),this.imageManager.beginFrame();let p=0,f=!1;for(const e in d){const t=d[e];t.used&&(t.prepare(this.context),t.getSource().usedInConflation&&++p)}let m=!1;for(const e of h)e.isHidden(this.transform.zoom)||("clip"===e.type&&(m=!0),this.prepareLayer(e));const g={},_={},A={},y={},v={};for(const e in d){const t=d[e];g[e]=t.getVisibleCoordinates(),_[e]=g[e].slice().reverse(),A[e]=t.getVisibleCoordinates(!0).reverse(),y[e]=t.getShadowCasterCoordinates(),v[e]=t.sortCoordinatesByDistance(g[e])}const x=e=>{const t=this.style.getLayerSourceCache(e);return t&&t.used?t.getSource():null};if(p||m||this._clippingActiveLastFrame){const t=[],i=[];let r=0;for(const e of h)this.isSourceForClippingOrConflation(e,x(e))&&(t.push(e),i.push(r)),r++;if(t&&(m||t.length>1)||this._clippingActiveLastFrame){m=!1;const r=[];for(let n=0;n0){const e=x(t);e&&(this.minCutoffZoom=Math.max(e.minzoom,this.minCutoffZoom)),t.minzoom&&(this.minCutoffZoom=Math.max(t.minzoom,this.minCutoffZoom))}t.is3D(o)&&(this.opaquePassCutoff===1/0&&(this.opaquePassCutoff=e),this._lastOcclusionLayer=e)}const b=this.style&&this.style.fog;b?(this._fogVisible=0!==b.getOpacity(this.transform.pitch),this._fogVisible&&"globe"!==this.transform.projection.name&&(this._fogVisible=b.isVisibleOnFrustum(this.transform.cameraFrustum))):this._fogVisible=!1,this._cachedTileFogOpacities={},this.terrain&&(this.terrain.updateTileBinding(A),this.opaquePassCutoff=0,a=s(),h=a.map(e=>n[e]));const w=this._shadowRenderer;if(w){w.updateShadowParameters(this.transform,this.style.directionalLight);for(const e in d)for(const t of g[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.eQ(this.context)),this.style.fog&&this.transform.projection.supportsFog?(this._atmosphere||(this._atmosphere=new Os(this)),this._atmosphere.update(this)):this._atmosphere&&(this._atmosphere.destroy(),this._atmosphere=void 0);const T=this._debugParams.forceEnablePrecipitation||!(!this.style||!this.style.snow),E=this._debugParams.forceEnablePrecipitation||!(!this.style||!this.style.rain);if(T&&!this._snow&&(this._snow=new _a(this)),!T&&this._snow&&(this._snow.destroy(),delete this._snow),E&&!this._rain&&(this._rain=new ma(this)),!E&&this._rain&&(this._rain.destroy(),delete this._rain),this._snow&&this._snow.update(this),this._rain&&this._rain.update(this),u){this.buildingTileBorderManager||(this.buildingTileBorderManager=new zs);const e=this.style.getLayerSourceCache(u);this.buildingTileBorderManager.updateBorders(e,u)}if(!j.has(this.context.gl))return;this.renderPass="offscreen";for(const e of h){const i=t.getLayerSourceCache(e);if(!e.hasOffscreenPass()||e.isHidden(this.transform.zoom))continue;const r=i?_[i.id]:void 0;("custom"===e.type||"raster"===e.type||"raster-particle"===e.type||e.isSky()||r&&r.length)&&this.renderLayer(this,i,e,r)}this.depthRangeFor3D=[0,1-(h.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(),B=(()=>{if(i.showOverdrawInspector)return e.ao.black;const t=this.style.fog;if(t&&this.transform.projection.supportsFog){const i=this.style.getLut(t.scope);if(!C){const r="none"===t.properties.get("color-use-theme"),n=t.properties.get("color").toNonPremultipliedRenderColor(r?null:i).toArray01();return new e.ao(...n)}if(C){const r="none"===t.properties.get("space-color-use-theme"),n=t.properties.get("space-color").toNonPremultipliedRenderColor(r?null:i).toArray01();return new e.ao(...n)}}return e.ao.transparent})();if(this.context.clear({color:B,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=a.length-1;this.currentLayer>=0;this.currentLayer--){const e=h[this.currentLayer],i=t.getLayerSourceCache(e);if(e.isSky())continue;const r=i?(e.is3D(o)?v:_)[i.id]:void 0;this._renderTileClippingMasks(e,i,r),this.renderLayer(this,i,e,r)}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.aj(this.transform.zoom)>0)&&("globe"===this.transform.projection.name||this.transform.isHorizonVisible()))for(this.currentLayer=0;this.currentLayer{for(this.currentLayer=0;this.currentLayer0&&e.hasShadowPass()&&0==--I){{this.clearStencil(),this.resetStencilClippingMasks();const e=this.currentLayer;for(this.currentLayer=0;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=h[this.currentLayer],r=t.getLayerSourceCache(i),n=r?_[r.id]:void 0;this.terrain||this._renderTileClippingMasks(i,r,r?g[r.id]:void 0),this.renderLayer(this,r,i,n)}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;h.forEach(e=>{const r=t.getLayerSourceCache(e);r&&!e.isHidden(this.transform.zoom)&&r.getVisibleCoordinates().length&&(!i||i.getSource().maxzoom0?t.pop():null}terrainRenderModeElevated(){return this.style&&!!this.style.getTerrain()&&!!this.terrain&&!this.terrain.renderingToTexture||this.forceTerrainMode}linearFloatFilteringSupported(){return null!=this.context.extTextureFloatLinear}currentGlobalDefines(e,t,i){const r=void 0===i?this.terrain&&this.terrain.renderingToTexture:i,n=[];return this.style&&this.style.enable3dLights()&&("globeRaster"===e||"terrainRaster"===e?(n.push("LIGHTING_3D_MODE"),n.push("LIGHTING_3D_ALPHA_EMISSIVENESS")):r||n.push("LIGHTING_3D_MODE")),"shadow"===this.renderPass&&(this._shadowMapDebug||n.push("DEPTH_TEXTURE")),this.terrainRenderModeElevated()&&(n.push("TERRAIN"),this.linearFloatFilteringSupported()&&n.push("TERRAIN_DEM_FLOAT_FORMAT")),"globe"===this.transform.projection.name&&n.push("GLOBE"),!this._fogVisible||r||void 0!==t&&!t||n.push("FOG","FOG_DITHERING"),r&&n.push("RENDER_TO_TEXTURE"),this._showOverdrawInspector&&n.push("OVERDRAW_INSPECTOR"),n}getOrCreateProgram(e,t){this.cache=this.cache||{};const i=t&&t.defines||[],r=t&&t.config,n=this.currentGlobalDefines(e,t&&t.overrideFog,t&&t.overrideRtt).concat(i),o=eo.cacheKey($r[e],e,n,r);return this.cache[o]||(this.cache[o]=new eo(this.context,e,$r[e],r,Oo[e],n)),this.cache[o]}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()}prepareDrawTile(){this.terrain&&this.terrain.prepareDrawTile()}uploadCommonLightUniforms(t,i){if(this.style.enable3dLights()){const r=this.style.directionalLight,n=this.style.ambientLight;if(r&&n){const o=((t,i,r)=>{const n=t.properties.get("direction"),o="none"===t.properties.get("color-use-theme"),s=t.properties.get("color").toNonPremultipliedRenderColor(o?null:r.getLut(t.scope)).toArray01(),a=t.properties.get("intensity"),l="none"===i.properties.get("color-use-theme"),c=i.properties.get("color").toNonPremultipliedRenderColor(l?null:r.getLut(i.scope)).toArray01(),u=i.properties.get("intensity"),h=[n.x,n.y,n.z],d=e.dM(c,u),p=e.dM(s,a);return{u_lighting_ambient_color:d,u_lighting_directional_dir:h,u_lighting_directional_color:p,u_ground_radiance:Xn(h,p,d)}})(r,n,this.style);i.setLightsUniformValues(t,o)}}}uploadCommonUniforms(t,i,r,n,o){if(this.uploadCommonLightUniforms(t,i),this.terrain&&this.terrain.renderingToTexture)return;const s=this.style.fog;if(s){const o=s.getOpacity(this.transform.pitch),a=((t,i,r,n,o,s,a,l,c,u,h,d)=>{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]=n;const g=t.frameCounter/1e3%1,[_,A]=i.properties.get("vertical-range");return{u_fog_matrix:r?p.calculateFogTileMatrix(r):d||t.identityMat,u_fog_range:i.getFovAdjustedRange(p._fov),u_fog_color:m,u_fog_horizon_blend:i.properties.get("horizon-blend"),u_fog_vertical_limit:[Math.min(_,A),A],u_fog_temporal_offset:g,u_frustum_tl:o,u_frustum_tr:s,u_frustum_br:a,u_frustum_bl:l,u_globe_pos:c,u_globe_radius:u,u_viewport:h,u_globe_transition:e.aj(p.zoom),u_is_globe:+("globe"===p.projection.name)}})(this,s,r,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.o.devicePixelRatio,this.transform.height*e.o.devicePixelRatio],n);i.setFogUniformValues(t,a)}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 r of i)t[r.key]=e[r.key]||new It(r,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(e){if(!this.style||!this.style.fog)return!1;if("globe"===this.transform.projection.name)return!0;let t=this._cachedTileFogOpacities[e.key];return t||(this._cachedTileFogOpacities[e.key]=t=this.style.fog.getOpacityForTile(e)),t[0]>=Ve||t[1]>=Ve}setupDepthForOcclusion(e,t,i){const r=this.context,n=r.gl,o=!!i;var s;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}),r.activeTexture.set(n.TEXTURE3),e&&this.depthFBO&&this.depthTexture?(this.depthTexture.bind(n.NEAREST,n.CLAMP_TO_EDGE),i.u_depth_size_inv=[1/this.depthFBO.width,1/this.depthFBO.height],i.u_depth_range_unpack=[2/((s=this.depthRangeFor3D)[1]-s[0]),-1-2*s[0]/(s[1]-s[0])],i.u_occluder_half_size=.5*this.occlusionParams.occluderSize,i.u_occlusion_depth_offset=this.occlusionParams.depthOffset):this.emptyDepthTexture.bind(n.NEAREST,n.CLAMP_TO_EDGE),r.activeTexture.set(n.TEXTURE0),o||t.setTerrainUniformValues(r,i)}}function wa(e,t){let i=!1,r=null;const n=()=>{r=null,i&&(e(),r=setTimeout(n,t),i=!1)};return()=>(i=!0,r||n(),r)}class Ta{constructor(t){this._hashName=t&&encodeURIComponent(t),e.aX(["_getCurrentHash","_onHashChange","_updateHash"],this),this._updateHash=wa(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=Ea(e);if(this._hashName){const e=this._hashName;let i=!1;const r=location.hash.slice(1).split("&").map(r=>{const n=r.split("=")[0];return n===e?(i=!0,`${n}=${t}`):r}).filter(e=>e);return i||r.push(`${e}=${t}`),`#${r.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(/(#.+)?$/,this.getHashString()))}}function Ea(e,t){const i=e.getCenter(),r=Math.round(100*e.getZoom())/100,n=Math.ceil((r*Math.LN2+Math.log(512/360/.5))/Math.LN10),o=Math.pow(10,n),s=Math.round(i.lng*o)/o,a=Math.round(i.lat*o)/o,l=e.getBearing(),c=e.getPitch();let u=t?`/${s}/${a}/${r}`:`${r}/${a}/${s}`;return(l||c)&&(u+="/"+Math.round(10*l)/10),c&&(u+=`/${Math.round(c)}`),u}const Ca={linearity:.3,easing:e.eS(0,0,.3,1)},Ba=Object.assign({deceleration:2500,maxSpeed:1400},Ca),Sa=Object.assign({deceleration:20,maxSpeed:1400},Ca),Ia=Object.assign({deceleration:1e3,maxSpeed:360},Ca),Ma=Object.assign({deceleration:1e3,maxSpeed:90},Ca);class Pa{constructor(e){this._map=e,this.clear()}clear(){this._inertiaBuffer=[]}record(t){this._drainInertiaBuffer(),this._inertiaBuffer.push({time:e.o.now(),settings:t})}_drainInertiaBuffer(){const t=this._inertiaBuffer,i=e.o.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 r=this._inertiaBuffer[this._inertiaBuffer.length-1].time-this._inertiaBuffer[0].time,n={};if(i.pan.mag()){const e=La(i.pan.mag(),r,Object.assign({},Ba,t||{}));n.offset=i.pan.mult(e.amount/i.pan.mag()),n.center=this._map.transform.center,Ra(n,e)}if(i.zoom){const e=La(i.zoom,r,Sa);n.zoom=this._map.transform.zoom+e.amount,Ra(n,e)}if(i.bearing){const t=La(i.bearing,r,Ia);n.bearing=this._map.transform.bearing+e.aA(t.amount,-179,179),Ra(n,t)}if(i.pitch){const e=La(i.pitch,r,Ma);n.pitch=this._map.transform.pitch+e.amount,Ra(n,e)}if(n.zoom||n.bearing){const e=void 0===i.pinchAround?i.around:i.pinchAround;n.around=e?this._map.unproject(e):this._map.getCenter()}return this.clear(),n.noMoveStart=!0,n}}function Ra(e,t){(!e.duration||e.durationi.unproject(e)),a=o.reduce((e,t,i,r)=>e.add(t.div(r.length)),new e.P(0,0));super(t,{points:o,point:a,lngLats:s,lngLat:i.unproject(a),originalEvent:r}),this._defaultPrevented=!1}}class Da extends e.z{preventDefault(){this._defaultPrevented=!0}get defaultPrevented(){return this._defaultPrevented}constructor(e,t){super("wheel",{originalEvent:t}),this._defaultPrevented=!1}}class Oa{constructor(e,t){this._map=e,this._clickTolerance=t.clickTolerance}reset(){this._mousedownPos=void 0}wheel(e){return this._firePreventable(new Da(this._map,e))}mousedown(e,t){return this._mousedownPos=t,this._firePreventable(new Fa(e.type,this._map,e))}mouseup(e){this._map.fire(new Fa(e.type,this._map,e))}preclick(e){const t=new MouseEvent("preclick",e);this._map.fire(new Fa(t.type,this._map,t))}click(e,t){this._mousedownPos&&this._mousedownPos.dist(t)>=this._clickTolerance||(this.preclick(e),this._map.fire(new Fa(e.type,this._map,e)))}dblclick(e){return this._firePreventable(new Fa(e.type,this._map,e))}mouseover(e){this._map.fire(new Fa(e.type,this._map,e))}mouseout(e){this._map.fire(new Fa(e.type,this._map,e))}touchstart(e){return this._firePreventable(new ka(e.type,this._map,e))}touchmove(e){this._map.fire(new ka(e.type,this._map,e))}touchend(e){this._map.fire(new ka(e.type,this._map,e))}touchcancel(e){this._map.fire(new ka(e.type,this._map,e))}_firePreventable(e){if(this._map.fire(e),e.defaultPrevented)return{}}isEnabled(){return!0}isActive(){return!1}enable(){}disable(){}}class za{constructor(e){this._map=e}reset(){this._delayContextMenu=!1,this._contextMenuEvent=void 0}mousemove(e){this._map.fire(new Fa(e.type,this._map,e))}mousedown(){this._delayContextMenu=!0}mouseup(){this._delayContextMenu=!1,this._contextMenuEvent&&(this._map.fire(new Fa("contextmenu",this._map,this._contextMenuEvent)),delete this._contextMenuEvent)}contextmenu(e){this._delayContextMenu?this._contextMenuEvent=e:this._map.fire(new Fa(e.type,this._map,e)),this._map.listens("contextmenu")&&e.preventDefault()}isEnabled(){return!0}isActive(){return!1}enable(){}disable(){}}class Ua{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&&(p(),this._startPos=this._lastPos=t,this._active=!0)}mousemoveWindow(e,t){if(!this._active)return;const i=t,r=this._startPos,n=this._lastPos;if(!r||!n||n.equals(i)||!this._box&&i.dist(r){this._box&&(this._box.style.transform=`translate(${o}px,${a}px)`,this._box.style.width=s-o+"px",this._box.style.height=c-a+"px")})}mouseupWindow(t,i){if(!this._active)return;const r=this._startPos,n=i;if(r&&0===t.button){if(this.reset(),g(),r.x!==n.x||r.y!==n.y)return this._map.fire(new e.z("boxzoomend",{originalEvent:t})),{cameraAnimation:e=>e.fitScreenCoordinates(r,n,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),f(),delete this._startPos,delete this._lastPos}_fireEvent(t,i){return this._map.fire(new e.z(t,{originalEvent:i}))}}function Na(e,t){const i={};for(let r=0;rthis.numTouches)&&(this.aborted=!0),this.aborted||(0===this.startTime&&(this.startTime=t.timeStamp),r.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=Na(r,i)))}touchmove(e,t,i){if(this.aborted||!this.centroid)return;const r=Na(i,t);for(const e in this.touches){const t=r[e];(!t||t.dist(this.touches[e])>30)&&(this.aborted=!0)}}touchend(e,t,i){if((!this.centroid||e.timeStamp-this.startTime>500)&&(this.aborted=!0),0===i.length){const e=!this.aborted&&this.centroid;if(this.reset(),e)return e}}}class ja{constructor(e){this.singleTap=new Va(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 r=this.singleTap.touchend(e,t,i);if(r){const t=e.timeStamp-this.lastTime<500,i=!this.lastTap||this.lastTap.dist(r)<30;if(t&&i||this.reset(),this.count++,this.lastTime=e.timeStamp,this.lastTap=r,this.count===this.numTaps)return this.reset(),r}}}class Ga{constructor(){this._zoomIn=new ja({numTouches:1,numTaps:2}),this._zoomOut=new ja({numTouches:2,numTaps:1}),this.reset()}reset(){this._active=!1,this._zoomIn.reset(),this._zoomOut.reset()}touchstart(e,t,i){this._zoomIn.touchstart(e,t,i),this._zoomOut.touchstart(e,t,i)}touchmove(e,t,i){this._zoomIn.touchmove(e,t,i),this._zoomOut.touchmove(e,t,i)}touchend(e,t,i){const r=this._zoomIn.touchend(e,t,i),n=this._zoomOut.touchend(e,t,i);return 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})}):n?(this._active=!0,e.preventDefault(),setTimeout(()=>this.reset(),0),{cameraAnimation:t=>t.easeTo({duration:300,zoom:t.getZoom()-1,around:t.unproject(n)},{originalEvent:e})}):void 0}touchcancel(){this.reset()}enable(){this._enabled=!0}disable(){this._enabled=!1,this.reset()}isEnabled(){return this._enabled}isActive(){return this._active}}const Ha={0:1,2:2},Qa={Control:"ctrlKey",Alt:"altKey",Shift:"shiftKey",Meta:"metaKey"};class $a{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=Ha[t];return void 0===e.buttons||(e.buttons&i)!==i}(e,this._eventButton))this.reset();else if(this._moved||!(t.dist(i)0&&(this._active=!0);const n=Na(r,i),o=new e.P(0,0),s=new e.P(0,0);let a=0;for(const e in n){const t=n[e],i=this._touches[e];i&&(o._add(t),s._add(t.sub(i)),a++,n[e]=t)}if(this._touches=n,a{this._alertContainer.classList.remove("mapboxgl-touch-pan-blocker-show"),this._alertContainer.removeAttribute("role")},500)}}class Xa{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 r=this._firstTwoTouches;if(!r)return;e.preventDefault();const[n,o]=r,s=Ja(i,t,n),a=Ja(i,t,o);if(!s||!a)return;const l=this._aroundCenter?null:s.add(a).div(2);return this._move([s,a],l,e)}touchend(e,t,i){if(!this._firstTwoTouches)return;const[r,n]=this._firstTwoTouches,o=Ja(i,t,r),s=Ja(i,t,n);o&&s||(this._active&&g(),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 Ja(e,t,i){for(let r=0;rMath.abs(e.x)}class nl extends Xa{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,rl(e[0].sub(e[1]))&&(this._valid=!1)}_move(t,i,r){const n=this._lastPoints;if(!n)return;const o=t[0].sub(n[0]),s=t[1].sub(n[1]);return this._map._cooperativeGestures&&!e.eT()&&r.touches.length<3||(this._valid=this.gestureBeginsVertically(o,s,r.timeStamp),!this._valid)?void 0:(this._lastPoints=t,this._active=!0,{pitchDelta:(o.y+s.y)/2*-.5})}gestureBeginsVertically(e,t,i){if(void 0!==this._valid)return this._valid;const r=e.mag()>=2,n=t.mag()>=2;if(!r&&!n)return;if(!r||!n)return null==this._firstMove&&(this._firstMove=i),i-this._firstMove<100&&void 0;const o=e.y>0==t.y>0;return rl(e)&&rl(t)&&o}}const ol={panStep:100,bearingStep:15,pitchStep:10};class sl{constructor(){const e=ol;this._panStep=e.panStep,this._bearingStep=e.bearingStep,this._pitchStep=e.pitchStep,this._rotationDisabled=!1}blur(){this.reset()}reset(){this._active=!1}keydown(e){if(e.altKey||e.ctrlKey||e.metaKey)return;let t=0,i=0,r=0,n=0,o=0;switch(e.keyCode){case 61:case 107:case 171:case 187:t=1;break;case 189:case 109:case 173:t=-1;break;case 37:e.shiftKey?i=-1:(e.preventDefault(),n=-1);break;case 39:e.shiftKey?i=1:(e.preventDefault(),n=1);break;case 38:e.shiftKey?r=1:(e.preventDefault(),o=-1);break;case 40:e.shiftKey?r=-1:(e.preventDefault(),o=1);break;default:return}return this._rotationDisabled&&(i=0,r=0),{cameraAnimation:s=>{const a=s.getZoom();s.easeTo({duration:300,easeId:"keyboardHandler",easing:al,zoom:t?Math.round(a)+t*(e.shiftKey?2:1):a,bearing:s.getBearing()+i*this._bearingStep,pitch:s.getPitch()+r*this._pitchStep,offset:[-n*this._panStep,-o*this._panStep],center:s.getCenter()},{originalEvent:e})}}}enable(){this._enabled=!0}disable(){this._enabled=!1,this.reset()}isEnabled(){return this._enabled}isActive(){return this._active}disableRotation(){this._rotationDisabled=!0}enableRotation(){this._rotationDisabled=!1}}function al(e){return e*(2-e)}const ll=4.000244140625,cl=1/450;class ul{constructor(t,i){this._map=t,this._el=t.getCanvasContainer(),this._handler=i,this._delta=0,this._lastDelta=0,this._defaultZoomRate=.01,this._wheelZoomRate=cl,e.aX(["_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.eT()))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 r=e.o.now(),n=r-(this._lastWheelEventTime||0);this._lastWheelEventTime=r,0!==i&&i%ll==0?this._type="wheel":0!==i&&Math.abs(i)<4?this._type="trackpad":n>400?(this._type=null,this._lastValue=i,this._timeout=window.setTimeout(this._onTimeout,40,t)):this._type||(this._type=Math.abs(n*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)>ll?this._wheelZoomRate:this._defaultZoomRate;let r=2/(1+Math.exp(-Math.abs(this._delta*e)));this._delta<0&&0!==r&&(r=1/r);const n=i(),o=Math.pow(2,n),s="number"==typeof this._targetZoom?t.zoomScale(this._targetZoom):o;this._targetZoom=Math.min(t.maxZoom,Math.max(t.minZoom,t.scaleZoom(s*r))),"wheel"===this._type&&(this._startZoom=n,this._easing=this._smoothOutEasing(200)),this._lastDelta=this._delta,this._delta=0}const r="number"==typeof this._targetZoom?this._targetZoom:i(),n=this._startZoom,o=this._easing;let s,a=!1;if("wheel"===this._type&&n&&o){const t=Math.min((e.o.now()-this._lastWheelEventTime)/200,1),i=o(t);s=e.ak(n,r,i),t<1?this._frameId||(this._frameId=!0):a=!0}else s=r,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=s-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.eU;if(this._prevEase){const t=this._prevEase,r=(e.o.now()-t.start)/t.duration,n=t.easing(r+.01)-t.easing(r),o=.27/Math.sqrt(n*n+1e-4)*.01,s=Math.sqrt(.0729-o*o);i=e.eS(o,s,.25,1)}return this._prevEase={start:e.o.now(),duration:t,easing:i},i}blur(){this.reset()}reset(){this._active=!1}_addScrollZoomBlocker(){this._map&&!this._alertContainer&&(this._alertContainer=l("div","mapboxgl-scroll-zoom-blocker",this._map._container),this._alertContainer.textContent=/(Mac|iPad)/i.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 hl{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 dl{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 pl{constructor(){this._tap=new ja({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 r=t[0],n=r.y-this._swipePoint.y;return this._swipePoint=r,e.preventDefault(),this._active=!0,{zoomDelta:n/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 fl{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 ml{constructor(e,t,i){this._pitchWithRotate=e.pitchWithRotate,this._mouseRotate=t,this._mousePitch=i}enable(){this._mouseRotate.enable(),this._pitchWithRotate&&this._mousePitch.enable()}disable(){this._mouseRotate.disable(),this._mousePitch.disable()}isEnabled(){return this._mouseRotate.isEnabled()&&(!this._pitchWithRotate||this._mousePitch.isEnabled())}isActive(){return this._mouseRotate.isActive()||this._mousePitch.isActive()}}class gl{constructor(e,t,i,r){this._el=e,this._touchZoom=t,this._touchRotate=i,this._tapDragZoom=r,this._rotationDisabled=!1,this._enabled=!0}enable(e){this._touchZoom.enable(e),this._rotationDisabled||this._touchRotate.enable(e),this._tapDragZoom.enable(),this._el.classList.add("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._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()}}const _l=e=>e.zoom||e.drag||e.pitch||e.rotate;class Al extends e.z{}class yl{constructor(){this.constants=[1,1,.01],this.radius=0}setup(t,i){const r=e.av([],i,t);this.radius=e.ag(r[2]<0?e.eW([],r,this.constants):[r[0],r[1],0])}projectRay(t){e.eW(t,t,this.constants),e.aw(t,t),e.eX(t,t,this.constants);const i=e.c4([],t,this.radius);if(i[2]>0){const t=e.c4([],[0,0,1],e.bI(i,[0,0,1])),r=e.c4([],e.aw([],[i[0],i[1],0]),this.radius),n=e.d7([],i,e.c4([],e.av([],e.d7([],r,t),i),2));i[0]=n[0],i[1]=n[1]}return i}}function vl(e){return e.panDelta&&e.panDelta.mag()||e.zoomDelta||e.bearingDelta||e.pitchDelta}class xl{constructor(t,i){this._map=t,this._el=this._map.getCanvasContainer(),this._handlers=[],this._handlersById={},this._changes=[],this._inertia=new Pa(t),this._bearingSnap=i.bearingSnap,this._previousActiveHandlers={},this._trackingEllipsoid=new yl,this._dragOrigin=null,this._eventsInProgress={},this._addDefaultHandlers(i),e.aX(["handleEvent","handleWindowEvent"],this);const r=this._el;this._listeners=[[r,"touchstart",{passive:!0}],[r,"touchmove",{passive:!1}],[r,"touchend",void 0],[r,"touchcancel",void 0],[r,"mousedown",void 0],[r,"mousemove",void 0],[r,"mouseup",void 0],[document,"mousemove",{capture:!0}],[document,"mouseup",void 0],[r,"mouseover",void 0],[r,"mouseout",void 0],[r,"dblclick",void 0],[r,"click",void 0],[r,"keydown",{capture:!1}],[r,"keyup",void 0],[r,"wheel",{passive:!1}],[r,"contextmenu",void 0],[window,"blur",void 0]];for(const[e,t,i]of this._listeners){const r=e===document?this.handleWindowEvent:this.handleEvent;e.addEventListener(t,r,i)}}destroy(){for(const[e,t,i]of this._listeners){const r=e===document?this.handleWindowEvent:this.handleEvent;e.removeEventListener(t,r,i)}}_addDefaultHandlers(e){const t=this._map,i=t.getCanvasContainer();this._add("mapEvent",new Oa(t,e));const r=t.boxZoom=new Ua(t,e);this._add("boxZoom",r);const n=new Ga,o=new dl;t.doubleClickZoom=new hl(o,n),this._add("tapZoom",n),this._add("clickZoom",o);const s=new pl;this._add("tapDragZoom",s);const a=t.touchPitch=new nl(t);this._add("touchPitch",a);const l=new Wa(e),c=new qa(e);t.dragRotate=new ml(e,l,c),this._add("mouseRotate",l,["mousePitch"]),this._add("mousePitch",c,["mouseRotate"]);const u=new Za(e),h=new Ka(t,e);t.dragPan=new fl(i,u,h),this._add("mousePan",u),this._add("touchPan",h,["touchZoom","touchRotate"]);const d=new il,p=new el;t.touchZoomRotate=new gl(i,p,d,s),this._add("touchRotate",d,["touchPan","touchZoom"]),this._add("touchZoom",p,["touchPan","touchRotate"]),this._add("blockableMapEvent",new za(t));const f=t.scrollZoom=new ul(t,this);this._add("scrollZoom",f,["mousePan"]);const m=t.keyboard=new sl;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){if(!this._updatingCamera){for(const{handler:e}of this._handlers)e.reset();this._inertia.clear(),this._fireEvents({},{},e),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!!_l(this._eventsInProgress)||this.isZooming()}_isDragging(){return!!this._eventsInProgress.drag}_blockedByActive(e,t,i){for(const r in e)if(r!==i&&(!t||t.indexOf(r)<0))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}handleEvent(e,t){this._updatingCamera=!0;const i="renderFrame"===e.type,r=i?void 0:e,n={needsRenderFrame:!1},o={},s={},a=e.touches?this._getMapTouches(e.touches):void 0,l=a?A(this._el,a):i?void 0:_(this._el,e);for(const{handlerName:i,handler:c,allowed:u}of this._handlers){if(!c.isEnabled())continue;let h;this._blockedByActive(s,u,i)?c.reset():c[t||e.type]&&(h=c[t||e.type](e,l,a),this.mergeHandlerResult(n,o,h,i,r),h&&h.needsRenderFrame&&this._triggerRenderFrame()),(h||c.isActive())&&(s[i]=c)}const c={};for(const e in this._previousActiveHandlers)s[e]||(c[e]=r);this._previousActiveHandlers=s,(Object.keys(c).length||vl(n))&&(this._changes.push([n,o,c]),this._triggerRenderFrame()),(Object.keys(s).length||vl(n))&&this._map._stop(!0),this._updatingCamera=!1;const{cameraAnimation:u}=n;u&&(this._inertia.clear(),this._fireEvents({},{},!0),this._changes=[],u(this._map))}mergeHandlerResult(e,t,i,r,n){if(!i)return;Object.assign(e,i);const o={handlerName:r,originalEvent:i.originalEvent||n};void 0!==i.zoomDelta&&(t.zoom=o),void 0!==i.panDelta&&(t.drag=o),void 0!==i.pitchDelta&&(t.pitch=o),void 0!==i.bearingDelta&&(t.rotate=o)}_applyChanges(){const t={},i={},r={};for(const[n,o,s]of this._changes)n.panDelta&&(t.panDelta=(t.panDelta||new e.P(0,0))._add(n.panDelta)),n.zoomDelta&&(t.zoomDelta=(t.zoomDelta||0)+n.zoomDelta),n.bearingDelta&&(t.bearingDelta=(t.bearingDelta||0)+n.bearingDelta),n.pitchDelta&&(t.pitchDelta=(t.pitchDelta||0)+n.pitchDelta),void 0!==n.around&&(t.around=n.around),void 0!==n.aroundCoord&&(t.aroundCoord=n.aroundCoord),void 0!==n.pinchAround&&(t.pinchAround=n.pinchAround),n.noInertia&&(t.noInertia=n.noInertia),Object.assign(i,o),Object.assign(r,s);this._updateMapTransform(t,i,r),this._changes=[]}_updateMapTransform(t,i,r){const n=this._map,o=n.transform,s=e=>[e.x,e.y,e.z];if((()=>{const e=this._eventsInProgress.drag;return e&&!this._handlersById[e.handlerName].isActive()})()&&!vl(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&&n._stop(!0),!vl(t))return void this._fireEvents(i,r,!0);let{panDelta:a,zoomDelta:l,bearingDelta:c,pitchDelta:u,around:h,aroundCoord:d,pinchAround:p}=t;o._isCameraConstrained&&(l>0&&(l=0),o._isCameraConstrained=!1),void 0!==p&&(h=p),(l||(e=>i[e]&&!this._eventsInProgress[e])("drag"))&&h&&(this._dragOrigin=s(o.pointCoordinate3D(h)),this._originalZoom=o.zoom,this._trackingEllipsoid.setup(o._camera.position,this._dragOrigin)),o.cameraElevationReference="sea",n._stop(!0),h=h||n.transform.centerPoint,c&&(o.bearing+=c),u&&(o.pitch+=u),o._updateCameraState();const f=[0,0,0];if(a)if("mercator"===o.projection.name){const e=this._trackingEllipsoid.projectRay(o.screenPointToMercatorRay(h).dir),t=this._trackingEllipsoid.projectRay(o.screenPointToMercatorRay(h.sub(a)).dir);f[0]=t[0]-e[0],f[1]=t[1]-e[1]}else{const t=o.pointCoordinate(h);if("globe"===o.projection.name){a=a.rotate(-o.angle);const i=o._pixelsPerMercatorPixel/o.worldSize;f[0]=-a.x*e.eV(e.a_(t.y))*i,f[1]=-a.y*e.eV(o.center.lat)*i}else{const e=o.pointCoordinate(h.sub(a));t&&e&&(f[0]=e.x-t.x,f[1]=e.y-t.y)}}const m=o.zoom,g=[0,0,0];if(l){const t=s(d||o.pointCoordinate3D(h)),i={dir:e.aw([],e.av([],t,o._camera.position))};if(i.dir[2]<0){const r=o.zoomDeltaToMovement(t,l);e.c4(g,i.dir,r)}}const _=e.d7(f,f,g);o._translateCameraConstrained(_),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,r,!0)}_fireEvents(t,i,r){const n=_l(this._eventsInProgress),o=_l(t),s={};for(const e in t){const{originalEvent:i}=t[e];this._eventsInProgress[e]||(s[`${e}start`]=i),this._eventsInProgress[e]=t[e]}!n&&o&&this._fireEvent("movestart",o.originalEvent);for(const e in s)this._fireEvent(e,s[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:r}=this._eventsInProgress[e];this._handlersById[t].isActive()||(delete this._eventsInProgress[e],l=i[t]||r,a[`${e}end`]=l)}for(const e in a)this._fireEvent(e,a[e]);const c=_l(this._eventsInProgress);if(r&&(n||o)&&!c){this._updatingCamera=!0;const t=this._inertia._onMoveEnd(this._map.dragPan._inertiaOptions),i=e=>0!==e&&-this._bearingSnap{this._frameId=void 0,this.handleEvent(new Al("renderFrame",{timeStamp:e})),this._applyChanges()})}_triggerRenderFrame(){void 0===this._frameId&&(this._frameId=this._requestFrame())}}const bl="map.setFreeCameraOptions(...) and map.getFreeCameraOptions() are not yet supported for non-mercator projections.";class wl 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.aX(["_renderFrameCallback"],this)}getCenter(){return new e.aS(this.transform.center.lng,this.transform.center.lat)}setCenter(e,t){return this.jumpTo({center:e},t)}panBy(t,i,r){return t=e.P.convert(t).mult(-1),this.panTo(this.transform.center,Object.assign({offset:t},i),r)}panTo(e,t,i){return this.easeTo(Object.assign({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(Object.assign({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(Object.assign({bearing:e},t),i)}resetNorth(e,t){return this.rotateTo(0,Object.assign({duration:1e3},e),t),this}resetNorthPitch(e,t){return this.easeTo(Object.assign({bearing:0,pitch:0,duration:1e3},e),t),this}snapToNorth(e,t){return Math.abs(this.getBearing())e.aspect?i/(2*Math.tan(.5*e.fovX)*e.aspect):r/(2*Math.tan(.5*e.fovY)*e.aspect)}_cameraForBoundsOnGlobe(t,i,r,n,o,s){const a=t.clone(),l=this._extendCameraOptions(s);a.bearing=n,a.pitch=o;const c=e.aS.convert(i),u=e.aS.convert(r),h=.5*(c.lat+u.lat),d=.5*(c.lng+u.lng),p=e.eY(h,d),f=e.aw([],p),m=e.aw([],e.bH([],f,[0,1,0])),g=e.bH([],m,f),_=[m[0],m[1],m[2],0,g[0],g[1],g[2],0,f[0],f[1],f[2],0,0,0,0,1],A=[p,e.eY(c.lat,c.lng),e.eY(u.lat,c.lng),e.eY(u.lat,u.lng),e.eY(c.lat,u.lng),e.eY(h,c.lng),e.eY(h,u.lng),e.eY(c.lat,d),e.eY(u.lat,d)];let y=e.d8.fromPoints(A.map(t=>[e.bI(m,t),e.bI(g,t),e.bI(f,t)]));const v=e.af([],y.center,_);0===e.eZ(v)&&e.e_(v,0,0,1),e.aw(v,v),e.c4(v,v,e.aD),a.center=e.e$(v);const x=a.getWorldToCameraMatrix(),b=e.bk(new Float64Array(16),x);y=e.d8.applyTransform(y,e.aB([],x,_));const w=this._extendAABB(y,a,l,n);if(!w)return void e.w("Map cannot fit within canvas with the given bounds, padding, and/or offset.");y=w,e.af(v,v,x);const T=.5*(y.max[2]-y.min[2]),E=this._minimumAABBFrustumDistance(a,y),C=e.c4([],[0,0,1],T),B=e.d7(C,v,C),S=E+(0===a.pitch?0:e.bF(v,B)),I=a.globeCenterInViewSpace,M=e.av([],v,[I[0],I[1],I[2]]);e.aw(M,M),e.c4(M,M,S);const P=e.d7([],v,M);e.af(P,P,b);const R=e.eL/e.aD,L=e.ag(P),F=e.ce(Math.max(L*R-e.eL,Number.EPSILON),0),k=Math.min(a.zoomFromMercatorZAdjusted(F),l.maxZoom);return k>.5*(e.cZ+e.cK)?(a.setProjection({name:"mercator"}),a.zoom=k,this._cameraForBounds(a,i,r,n,o,s)):{center:a.center,zoom:k,bearing:n,pitch:o}}_extendAABB(t,i,r,n){const o=.5*((r.padding.left||0)+(r.padding.right||0)),s=.5*((r.padding.top||0)+(r.padding.bottom||0)),a=s,l=o,c=o,u=s,h=i.width-(l+c),d=i.height-(a+u),p=e.av([],t.max,t.min),f=Math.min(h/p[0],d/p[1]),m=Math.min(i.scaleZoom(i.scale*f),r.maxZoom);if(isNaN(m))return null;const g=i.scale/i.zoomScale(m),_=new e.d8([t.min[0]-l*g,t.min[1]-u*g,t.min[2]],[t.max[0]+c*g,t.max[1]+a*g,t.max[2]]),A=("number"==typeof r.offset.x&&"number"==typeof r.offset.y?new e.P(r.offset.x,r.offset.y):e.P.convert(r.offset)).rotate(-e.an(n));return _.center[0]-=A.x*g,_.center[1]+=A.y*g,_}queryTerrainElevation(t,i){const r=this.transform.elevation;return r?(i=Object.assign({},{exaggerated:!0},i),r.getAtPoint(e.ae.fromLngLat(t),null,i.exaggerated)):null}_cameraForBounds(t,i,r,n,o,s){if("globe"===t.projection.name)return this._cameraForBoundsOnGlobe(t,i,r,n,o,s);const a=t.clone(),l=this._extendCameraOptions(s);a.bearing=n,a.pitch=o;const c=e.aS.convert(i),u=e.aS.convert(r),h=new e.aS(c.lng,u.lat),d=new e.aS(u.lng,c.lat),p=a.project(c),f=a.project(u),m=this.queryTerrainElevation(c),g=this.queryTerrainElevation(u),_=this.queryTerrainElevation(h),A=this.queryTerrainElevation(d),y=[[p.x,p.y,Math.min(m||0,g||0,_||0,A||0)],[f.x,f.y,Math.max(m||0,g||0,_||0,A||0)]];let v=e.d8.fromPoints(y);const x=a.getWorldToCameraMatrix(),b=e.bk(new Float64Array(16),x);v=e.d8.applyTransform(v,x);const w=this._extendAABB(v,a,l,n);if(!w)return void e.w("Map cannot fit within canvas with the given bounds, padding, and/or offset.");v=w;const T=.5*e.av([],v.max,v.min)[2],E=this._minimumAABBFrustumDistance(a,v),C=[0,0,1,0];e.aC(C,C,x),e.f0(C,C);const B=e.c4([],C,E+T),S=e.d7([],v.center,B);e.af(v.center,v.center,b),e.af(S,S,b);const I=a.unproject(new e.P(v.center[0],v.center[1])),M=e.f1(a.projection,I),P=Math.pow(2,M),R=Math.min(a._zoomFromMercatorZ(S[2]*a.pixelsPerMeter*P/a.worldSize),l.maxZoom);return a.mercatorFromTransition&&R<.5*(e.cZ+e.cK)?(a.setProjection({name:"globe"}),a.zoom=R,this._cameraForBounds(a,i,r,n,o,s)):{center:I,zoom:R,bearing:n,pitch:o}}fitBounds(e,t,i){const r=this.cameraForBounds(e,t);return this._fitInternal(r,t,i)}fitScreenCoordinates(t,i,r,n,o){const s=e.P.convert(t),a=e.P.convert(i),l=new e.P(Math.min(s.x,a.x),Math.min(s.y,a.y)),c=new e.P(Math.max(s.x,a.x),Math.max(s.y,a.y));if("mercator"===this.transform.projection.name&&this.transform.anyCornerOffEdge(s,a))return this;const u=this.transform.pointLocation3D(l),h=this.transform.pointLocation3D(c),d=this.transform.pointLocation3D(new e.P(l.x,c.y)),p=this.transform.pointLocation3D(new e.P(c.x,l.y)),f=[Math.min(u.lng,h.lng,d.lng,p.lng),Math.min(u.lat,h.lat,d.lat,p.lat)],m=[Math.max(u.lng,h.lng,d.lng,p.lng),Math.max(u.lat,h.lat,d.lat,p.lat)],g=n&&n.pitch?n.pitch:this.getPitch(),_=this._cameraForBounds(this.transform,f,m,r,g,n);return this._fitInternal(_,n,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();const r=t.preloadOnly?this.transform.clone():this.transform;let n=!1,o=!1,s=!1;"zoom"in t&&r.zoom!==+t.zoom&&(n=!0,r.zoom=+t.zoom),void 0!==t.center&&(r.center=e.aS.convert(t.center)),"bearing"in t&&r.bearing!==+t.bearing&&(o=!0,r.bearing=+t.bearing),"pitch"in t&&r.pitch!==+t.pitch&&(s=!0,r.pitch=+t.pitch);const a="number"==typeof t.padding?this._extendPadding(t.padding):t.padding;if(null!=t.padding&&!r.isPaddingEqual(a))if(!1===t.retainPadding){const e=r.clone();e.padding=a,r.setLocationAtPoint(r.center,e.centerPoint)}else r.padding=a;return t.preloadOnly?(this._preloadTiles(r),this):(this.fire(new e.z("movestart",i)).fire(new e.z("move",i)),n&&this.fire(new e.z("zoomstart",i)).fire(new e.z("zoom",i)).fire(new e.z("zoomend",i)),o&&this.fire(new e.z("rotatestart",i)).fire(new e.z("rotate",i)).fire(new e.z("rotateend",i)),s&&this.fire(new e.z("pitchstart",i)).fire(new e.z("pitch",i)).fire(new e.z("pitchend",i)),this.fire(new e.z("moveend",i)))}getFreeCameraOptions(){return this.transform.projection.supportsFreeCamera||e.w(bl),this.transform.getFreeCameraOptions()}setFreeCameraOptions(t,i){const r=this.transform;if(!r.projection.supportsFreeCamera)return e.w(bl),this;this.stop();const n=r.zoom,o=r.pitch,s=r.bearing;r.setFreeCameraOptions(t);const a=n!==r.zoom,l=o!==r.pitch,c=s!==r.bearing;return this.fire(new e.z("movestart",i)).fire(new e.z("move",i)),a&&this.fire(new e.z("zoomstart",i)).fire(new e.z("zoom",i)).fire(new e.z("zoomend",i)),c&&this.fire(new e.z("rotatestart",i)).fire(new e.z("rotate",i)).fire(new e.z("rotateend",i)),l&&this.fire(new e.z("pitchstart",i)).fire(new e.z("pitch",i)).fire(new e.z("pitchend",i)),this.fire(new e.z("moveend",i)),this}easeTo(t,i){this._stop(!1,t.easeId),(!1===(t=Object.assign({offset:[0,0],duration:500,easing:e.eU},t)).animate||this._prefersReducedMotion(t))&&(t.duration=0);const r=this.transform,n=this.getZoom(),o=this.getBearing(),s=this.getPitch(),a=this.getPadding(),l="zoom"in t?+t.zoom:n,c="bearing"in t?this._normalizeBearing(t.bearing,o):o,u="pitch"in t?+t.pitch:s,h=this._extendPadding(t.padding),d=e.P.convert(t.offset);let p,f,m;if("globe"===r.projection.name){const i=e.ae.fromLngLat(r.center),n=d.rotate(-r.angle);i.x+=n.x/r.worldSize,i.y+=n.y/r.worldSize;const o=i.toLngLat(),s=e.aS.convert(t.center||o);this._normalizeCenter(s),p=r.centerPoint.add(n),f=new e.P(i.x,i.y).mult(r.worldSize),m=new e.P(e.aF(s.lng),e.aJ(s.lat)).mult(r.worldSize).sub(f)}else{p=r.centerPoint.add(d);const i=r.pointLocation(p),n=e.aS.convert(t.center||i);this._normalizeCenter(n),f=r.project(i),m=r.project(n).sub(f)}const g=r.zoomScale(l-n);let _,A;t.around&&(_=e.aS.convert(t.around),A=r.locationPoint(_));const y=this._zooming||l!==n,v=this._rotating||o!==c,x=this._pitching||u!==s,b=!r.isPaddingEqual(h),w=!1===t.retainPadding?r.clone():r,T=r=>T=>{if(y&&(r.zoom=e.ak(n,l,T)),v&&(r.bearing=e.ak(o,c,T)),x&&(r.pitch=e.ak(s,u,T)),b&&(w.interpolatePadding(a,h,T),p=w.centerPoint.add(d)),_)r.setLocationAtPoint(_,A);else{const e=r.zoomScale(r.zoom-n),t=l>n?Math.min(2,g):Math.max(.5,g),i=Math.pow(t,1-T),o=r.unproject(f.add(m.mult(T*i)).mult(e));r.setLocationAtPoint(r.renderWorldCopies?o.wrap():o,p)}return t.preloadOnly||this._fireMoveEvents(i),r};if(t.preloadOnly){const e=this._emulate(T,t.duration,r);return this._preloadTiles(e),this}const E={moving:this._moving,zooming:this._zooming,rotating:this._rotating,pitching:this._pitching};return this._zooming=y,this._rotating=v,this._pitching=x,this._padding=b,this._easeId=t.easeId,this._prepareEase(i,t.noMoveStart,E),this._ease(T(r),e=>{"sea"===r.cameraElevationReference&&r.recenterOnTerrain(),this._afterEase(i,e)},t),this}_prepareEase(t,i,r={}){this._moving=!0,this.transform.cameraElevationReference="sea",this.transform._orthographicProjectionAtLowPitch&&0===this.transform.pitch&&"globe"!==this.transform.projection.name&&(this.transform.cameraElevationReference="ground"),i||r.moving||this.fire(new e.z("movestart",t)),this._zooming&&!r.zooming&&this.fire(new e.z("zoomstart",t)),this._rotating&&!r.rotating&&this.fire(new e.z("rotatestart",t)),this._pitching&&!r.pitching&&this.fire(new e.z("pitchstart",t))}_fireMoveEvents(t){this.fire(new e.z("move",t)),this._zooming&&this.fire(new e.z("zoom",t)),this._rotating&&this.fire(new e.z("rotate",t)),this._pitching&&this.fire(new e.z("pitch",t))}_afterEase(t,i){if(this._easeId&&i&&this._easeId===i)return;this._easeId=void 0,this.transform.cameraElevationReference="ground";const r=this._zooming,n=this._rotating,o=this._pitching;this._moving=!1,this._zooming=!1,this._rotating=!1,this._pitching=!1,this._padding=!1,r&&this.fire(new e.z("zoomend",t)),n&&this.fire(new e.z("rotateend",t)),o&&this.fire(new e.z("pitchend",t)),this.fire(new e.z("moveend",t))}flyTo(t,i){if(this._prefersReducedMotion(t)){const r=e.aH(t,["center","zoom","bearing","pitch","around","padding","retainPadding"]);return this.jumpTo(r,i)}this.stop(),t=Object.assign({offset:[0,0],speed:1.2,curve:1.42,easing:e.eU},t);const r=this.transform,n=this.getZoom(),o=this.getBearing(),s=this.getPitch(),a=this.getPadding(),l="zoom"in t?e.aA(+t.zoom,r.minZoom,r.maxZoom):n,c="bearing"in t?this._normalizeBearing(t.bearing,o):o,u="pitch"in t?+t.pitch:s,h=this._extendPadding(t.padding),d=r.zoomScale(l-n),p=e.P.convert(t.offset);let f=r.centerPoint.add(p);const m=r.pointLocation(f),g=e.aS.convert(t.center||m);this._normalizeCenter(g);const _=r.project(m),A=r.project(g).sub(_);let y=t.curve;const v=Math.max(r.width,r.height),x=v/d,b=A.mag();if("minZoom"in t){const i=e.aA(Math.min(t.minZoom,n,l),r.minZoom,r.maxZoom),o=v/r.zoomScale(i-n);y=Math.sqrt(o/b*2)}const w=y*y;function T(e){const t=(x*x-v*v+(e?-1:1)*w*w*b*b)/(2*(e?x:v)*w*b);return Math.log(Math.sqrt(t*t+1)-t)}function E(e){return(Math.exp(e)-Math.exp(-e))/2}function C(e){return(Math.exp(e)+Math.exp(-e))/2}const B=T(0);let S=function(e){return C(B)/C(B+y*e)},I=function(e){return v*((C(B)*(E(t=B+y*e)/C(t))-E(B))/w)/b;var t},M=(T(1)-B)/y;if(Math.abs(b)<1e-6||!isFinite(M)){if(Math.abs(v-x)<1e-6)return this.easeTo(t,i);const e=xt.maxDuration&&(t.duration=0);const P=o!==c,R=u!==s,L=!r.isPaddingEqual(h),F=!1===t.retainPadding?r.clone():r,k=r=>d=>{const m=d*M,y=1/S(m);r.zoom=1===d?l:n+r.scaleZoom(y),P&&(r.bearing=e.ak(o,c,d)),R&&(r.pitch=e.ak(s,u,d)),L&&(F.interpolatePadding(a,h,d),f=F.centerPoint.add(p));const v=1===d?g:r.unproject(_.add(A.mult(I(m))).mult(y));return r.setLocationAtPoint(r.renderWorldCopies?v.wrap():v,f),r._updateCameraOnTerrain(),t.preloadOnly||this._fireMoveEvents(i),r};if(t.preloadOnly){const e=this._emulate(k,t.duration,r);return this._preloadTiles(e),this}return this._zooming=!0,this._rotating=P,this._pitching=R,this._padding=L,this._prepareEase(i,!1),this._ease(k(r),()=>this._afterEase(i),t),this}isEasing(){return!!this._easeFrameId}stop(){return this._stop()}_requestRenderFrame(e){}_cancelRenderFrame(e){}_stop(e,t){if(this._easeFrameId&&(this._cancelRenderFrame(this._easeFrameId),this._easeFrameId=void 0,this._onEaseFrame=void 0),this._onEaseEnd){const e=this._onEaseEnd;this._onEaseEnd=void 0,e.call(this,t)}if(!e){const e=this.handlers;e&&e.stop(!1)}return this}_ease(t,i,r){!1===r.animate||0===r.duration?(t(1),i()):(this._easeStart=e.o.now(),this._easeOptions=r,this._onEaseFrame=t,this._onEaseEnd=i,this._easeFrameId=this._requestRenderFrame(this._renderFrameCallback))}_renderFrameCallback(){const t=Math.min((e.o.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.bS(t,-180,180);const r=Math.abs(t-i);return Math.abs(t-360-i)180?-360:i<-180?360:0}_prefersReducedMotion(t){return this._respectPrefersReducedMotion&&e.o.prefersReducedMotion&&!(t&&t.essential)}_emulate(e,t,i){const r=Math.ceil(15*t/1e3),n=[],o=e(i.clone());for(let e=0;e<=r;e++){const t=o(e/r);n.push(t.clone())}return n}_preloadTiles(e,t){}}class Tl{constructor(t={}){this.options=t,e.aX(["_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=l("div","mapboxgl-ctrl mapboxgl-ctrl-attrib"),this._compactButton=l("button","mapboxgl-ctrl-attrib-button",this._container),this._compactButton.type="button",this._compactButton.addEventListener("click",this._toggleAttribution),this._compactButton.setAttribute("aria-label",i);const r=l("span","mapboxgl-ctrl-icon",this._compactButton);return r.setAttribute("aria-hidden","true"),r.setAttribute("title",i),this._innerContainer=l("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.e.ACCESS_TOKEN}];if(t){const r=i.reduce((e,t,r)=>(t.value&&(e+=`${t.key}=${t.value}${re.length-t.length),e=e.filter((t,i)=>{for(let r=i+1;r=0)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.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 El{constructor(){e.aX(["_updateLogo","_updateCompact"],this)}onAdd(e){this._map=e,this._container=l("div","mapboxgl-ctrl");const t=l("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(i.hasOwnProperty("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 Cl{constructor(){e.aX(["_onIndoorUpdate"],this)}onAdd(e){return this._map=e,this._container=l("div","mapboxgl-ctrl mapboxgl-ctrl-group"),this._map.indoor.on("selector-update",e=>this._onIndoorUpdate(e)),this._container}_createButton(e,t){const i=l("button",e,this._container);return i.type="button",i.addEventListener("click",t),i}_createSeparator(){return l("div","mapboxgl-ctrl-separator",this._container)}_setButtonTitle(e,t){this._map&&(e.setAttribute("aria-label",t),e.textContent=t)}onRemove(){this._container&&this._container.remove(),this._map&&this._map.indoor&&(this._map.indoor.off("selector-update",this._onIndoorUpdate),this._map=null)}getDefaultPosition(){return"right"}_onIndoorUpdate(e){if(!e||!e.floors)return this._model=e,void(this._container.style.display="none");const t=this._model;this._model=e,this._container.style.display="inline-block",this._container.style.borderRadius="8px",t&&Array.from(this._container.children).forEach(e=>e.remove()),e.floors.length>0&&(this.addBuildingsToggleButton(),this.addCurrentFloors(e.floors,e.activeFloorsVisible),this._updateBuildingsButtonState())}addBuildingsToggleButton(){const e=this._createButton("mapboxgl-ctrl-buildings-toggle",()=>{const e=this._map;this._model&&e&&e._setIndoorActiveFloorsVisibility(!this._model.activeFloorsVisible)});l("span","mapboxgl-ctrl-icon",e).setAttribute("aria-hidden","true"),e.classList.add("mapboxgl-ctrl-level-button","mapboxgl-ctrl-buildings-toggle"),this._model&&!this._model.activeFloorsVisible&&e.classList.add("mapboxgl-ctrl-level-button-selected"),this._container.append(e),this._createSeparator()}_updateBuildingsButtonState(){const e=this._container.querySelector(".mapboxgl-ctrl-buildings-toggle");e&&this._model&&(this._model.activeFloorsVisible?e.classList.remove("mapboxgl-ctrl-level-button-selected"):e.classList.add("mapboxgl-ctrl-level-button-selected"))}addCurrentFloors(e,t){for(let i=0;i{this._map._selectIndoorFloor(r.id)});this._setButtonTitle(n,r.zIndex.toString()),this._model&&r.id===this._model.selectedFloorId&&t&&n.classList.add("mapboxgl-ctrl-level-button-selected"),this._container.append(n),i=this._endTime)return this._end;const i=e.dC((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 Il={"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 Ml extends e.z{constructor(e,t,i,r){const{point:n,lngLat:o,originalEvent:s,target:a}=e;super(e.type,{point:n,lngLat:o,originalEvent:s,target:a}),this.preventDefault=()=>{e.preventDefault()},this.id=t,this.interaction=i,this.feature=r}}class Pl{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 r=i.filter;let n=i.type;r&&this.filters.set(t,e.b5(r)),"mouseover"===n&&(n="mouseenter"),"mouseout"===n&&(n="mouseleave");const o=this.interactionsByType.get(n)||new Map;"mouseenter"===n||"mouseleave"===n?(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(n,this.handleType),0===o.size&&this.interactionsByType.set(n,o),o.set(t,i),this.typeById.set(t,n)}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,r]of t)r.target&&i.push({targetId:e,target:r.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 r="mouseenter"===t.type;if(r&&!this.interactionsByType.has(t.type))return void e.w("mouseenter interaction required for mouseleave to work.");const n=Array.from(this.interactionsByType.get(t.type)).reverse(),o=!!i;i=i||this.queryTargets(t.point,n);let s=!1;const a=new Set;for(const l of i){for(const[i,c]of n){if(!c.target)continue;const n=l.variants?l.variants[i]:null;if(n){for(const u of n){if(mt(u,l,a,i))continue;const n=new e.dw(l,u),h=ft(u,l,i);o&&void 0!==n.id&&(n.state=this.map.getFeatureState(n));const d=r?this.prevHoveredFeatures.get(h):null,p=new Ml(t,i,c,n),f=d?d.stop:c.handler(p);if(r&&this.hoveredFeatures.set(h,{feature:l,stop:f}),!1!==f){s=!0;break}}if(s)break}}if(s)break}if(!s)for(const[e,i]of n){const{handler:r,target:n}=i;if(!n&&!1!==r(new Ml(t,e,i,null)))break}}}function Rl(t,i){if(Array.isArray(t)&&Array.isArray(i)){const e=new Set(t),r=new Set(i);return e.size===r.size&&t.every(e=>r.has(e))}return e.bx(t,i)}const Ll={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,transformRequest:null,accessToken:null,fadeDuration:300,respectPrefersReducedMotion:!0,crossSourceCollisions:!0,collectResourceTiming:!1,testMode:!1,precompilePrograms:!0,scaleFactor:1,spriteFormat:"auto"},Fl={showCompass:!0,showZoom:!0,visualizePitch:!1};class kl{constructor(t,i,r=!1){this._clickTolerance=10,this.element=i,this.mouseRotate=new Wa({clickTolerance:t.dragRotate._mouseRotate._clickTolerance}),this.map=t,r&&(this.mousePitch=new qa({clickTolerance:t.dragRotate._mousePitch._clickTolerance})),e.aX(["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),p()}move(e,t){const i=this.map,r=this.mouseRotate.mousemoveWindow(e,t),n=r&&r.bearingDelta;if(n&&i.setBearing(i.getBearing()+n),this.mousePitch){const r=this.mousePitch.mousemoveWindow(e,t),n=r&&r.pitchDelta;n&&i.setPitch(i.getPitch()+n)}}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(){f(),window.removeEventListener("mousemove",this.mousemove),window.removeEventListener("mouseup",this.mouseup)}mousedown(e){this.down(Object.assign({},e,{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=A(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=A(this.element,e.targetTouches)[0],this.move({preventDefault:()=>e.preventDefault()},this._lastPos))}touchend(e){0===e.targetTouches.length&&this._startPos&&this._lastPos&&this._startPos.dist(this._lastPos)r.width||i.y>r.height;r.locationPoint3D(n).distSqr(i)180;){const e=r.locationPoint3D(t);if(e.x>=0&&e.y>=0&&e.x<=r.width&&e.y<=r.height)break;t.lng>r.center.lng?t.lng-=360:t.lng+=360}return t}const Ol={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%)"},zl={rotation:0,rotationAlignment:"auto",pitchAlignment:"auto",occludedOpacity:.2,altitude:0};class Ul extends e.E{constructor(t,i){super(),(t instanceof HTMLElement||i)&&(t=Object.assign({element:t},i)),e.aX(["_update","_onMove","_onUp","_addDragHandler","_onMapClick","_onKeyPress","_clearFadeTimer"],this);const{anchor:r="center",color:n="#3FB1CE",scale:o=1,draggable:s=!1,clickTolerance:a=0,rotation:l=zl.rotation,rotationAlignment:c=zl.rotationAlignment,pitchAlignment:u=zl.pitchAlignment,occludedOpacity:h=zl.occludedOpacity,altitude:d=zl.altitude}=t||{};this._anchor=r,this._color=n,this._scale=o,this._draggable=s,this._clickTolerance=a,this._rotation=l,this._rotationAlignment=c,this._pitchAlignment=u,this._occludedOpacity=h,this._altitude=d,this._state="inactive",this._isDragging=!1,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 Ol)p.remove(`mapboxgl-marker-anchor-${e}`);p.add(`mapboxgl-marker-anchor-${this._anchor}`);const f=t&&t.className?t.className.trim().split(/\s+/):[];p.add(...f),this._popup=null}_createDefaultMarker(){const e=l("div"),t=c("svg",{display:"block",height:41*this._scale+"px",width:27*this._scale+"px",viewBox:"0 0 27 41"},e);if(0===this._altitude){const e=c("radialGradient",{id:"shadowGradient"},c("defs",{},t));c("stop",{offset:"10%","stop-opacity":.4},e),c("stop",{offset:"100%","stop-opacity":.05},e),c("ellipse",{cx:13.5,cy:34.8,rx:10.5,ry:5.25,fill:"url(#shadowGradient)"},t)}return c("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),c("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),c("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.aS.convert(t),this._pos=null,this._popup&&this._popup.setLngLat(this._lngLat),this._update(!0),this}setAltitude(e){return e===this._altitude||(this._defaultMarker&&(0===this._altitude&&0!==e||0!==this._altitude&&0===e)&&(this._element=this._createDefaultMarker()),this._altitude=e||zl.altitude,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,r=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":[r,-1*(t-i+r)],"bottom-right":[-r,-1*(t-i+r)],left:[i,-1*(t-i)],right:[-i,-1*(t-i)]}:this._offset}this._popup=e,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),r=e.getFreeCameraOptions();if(!r.position)return!1;const n=r.position.toLngLat();return n.distanceTo(i)<.9*n.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 r=t.unproject(i,this._altitude);let n;t._showingGlobe()&&e.f4(t.transform,this._lngLat)?n=0:(n=1-t._queryFogOpacity(r),t.transform._terrainEnabled()&&t.getTerrain()&&this._behindTerrain()&&(n*=this._occludedOpacity)),this._element.style.opacity=`${n}`,this._element.style.pointerEvents=n>0?"auto":"none",this._popup&&this._popup._setOpacity(n),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 ${Ol[this._anchor]}\n ${this._calculateXYTransform()} ${this._calculateZTransform()}\n translate(${t.x}px,${t.y}px)\n `}_calculateXYTransform(){const t=this._pos,i=this._map,r=this.getPitchAlignment();if(!i||!t||"map"!==r)return"";if(!i._showingGlobe()){const e=i.getPitch();return e?`rotateX(${e}deg)`:""}const n=e.cW(e.f5(i.transform,this._lngLat)),o=t.sub(e.f6(i.transform)),s=Math.abs(o.x)+Math.abs(o.y);if(0===s)return"";const a=n/s;return`rotateX(${-o.y*a}deg) rotateY(${o.x*a}deg)`}_calculateZTransform(){const t=this._pos,i=this._map;if(!i||!t)return"";let r=0;const n=this.getRotationAlignment();if("map"===n)if(i._showingGlobe()){const t=i.project(new e.aS(this._lngLat.lng,this._lngLat.lat+.001),this._altitude),n=i.project(new e.aS(this._lngLat.lng,this._lngLat.lat-.001),this._altitude).sub(t);r=e.cW(Math.atan2(n.y,n.x))-90}else r=-i.getBearing();else if("horizon"===n){const n=e.ah(4,6,i.getZoom()),o=e.f6(i.transform);o.y+=n*i.transform.height;const s=t.sub(o),a=e.cW(Math.atan2(s.y,s.x));r=(a>90?a-270:a+90)*(1-n)}return r+=this._rotation,r?`rotateZ(${r}deg)`:""}_update(e){cancelAnimationFrame(this._updateFrameId);const t=this._map;t&&(t.transform.renderWorldCopies&&(this._lngLat=Dl(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.getTerrain()||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 r=this._pointerdownPos,n=this._positionDelta;if(r&&n){if(!this._isDragging){const e=this._clickTolerance||i._clickTolerance;if(t.point.dist(r)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");if(t.antialias&&e.f2(window)&&(t.antialias=!1,e.w("Antialiasing is disabled for this WebGL context to avoid browser bug: https://github.com/mapbox/mapbox-gl-js/issues/11609")),super(new sr(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._isInitialLoad=!0,this._crossSourceCollisions=t.crossSourceCollisions,this._collectResourceTiming=t.collectResourceTiming,this._language=this._parseLanguage(t.language),this._worldview=t.worldview,this._renderTaskQueue=new Bl,this._domRenderTaskQueue=new Bl,this._controls=[],this._markers=[],this._popups=[],this._mapId=e.b1(),this._locale=Object.assign({},Il,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._scaleFactorChanged=!1,this._averageElevationLastSampledAt=-1/0,this._averageElevationExaggeration=0,this._averageElevation=new Sl(0),this._interactionRange=[1/0,-1/0],this._visibilityHidden=0,this._useExplicitProjection=!1,this._frameId=0,this._scaleFactor=t.scaleFactor,this._requestManager=new w(t.transformRequest,t.accessToken,t.testMode),this._silenceAuthErrors=!!t.testMode,this._contextCreateOptions=t.contextCreateOptions?Object.assign({},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=t.spriteFormat,e.aX(["_onWindowOnline","_onWindowResize","_onVisibilityChange","_onMapScroll","_contextLost","_contextRestored"],this),this._setupContainer(),this._tp||(this._tp=new sa),this._tp.registerParameter(this,["Debug"],"showOverdrawInspector"),this._tp.registerParameter(this,["Debug"],"showTileBoundaries"),this._tp.registerParameter(this,["Debug"],"showParseStatus"),this._tp.registerParameter(this,["Debug"],"repaint"),this._tp.registerParameter(this,["Debug"],"showTileAABBs"),this._tp.registerParameter(this,["Debug"],"showPadding"),this._tp.registerParameter(this,["Debug"],"showCollisionBoxes",{noSave:!0}),this._tp.registerParameter(this.transform,["Debug"],"freezeTileCoverage",{noSave:!0},()=>{this._update()}),this._tp.registerParameter(this,["Debug","Wireframe"],"showTerrainWireframe"),this._tp.registerParameter(this,["Debug","Wireframe"],"showLayers2DWireframe"),this._tp.registerParameter(this,["Debug","Wireframe"],"showLayers3DWireframe"),this._tp.registerParameter(this,["Scaling"],"_scaleFactor",{min:.1,max:10,step:.1},()=>{this.setScaleFactor(this._scaleFactor)}),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 xl(this,t),this._localFontFamily=t.localFontFamily,this._localIdeographFontFamily=t.localIdeographFontFamily,(t.style||!t.testMode)&&this.setStyle(t.style||e.e.DEFAULT_STYLE,{config:t.config,localFontFamily:this._localFontFamily,localIdeographFontFamily:this._localIdeographFontFamily}),t.projection&&this.setProjection(t.projection),t.hash&&(this._hash=new Ta("string"==typeof t.hash&&t.hash||void 0).addTo(this)),!this._hash||!this._hash._onHashChange()){null==n.center&&null==n.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,Object.assign({},t.fitBoundsOptions,{duration:0})))}this.resize(),t.attributionControl&&this.addControl(new Tl({customAttribution:t.customAttribution})),this._logoControl=new El,this.addControl(this._logoControl,t.logoPosition),this.on("style.load",()=>{this.transform.unmodified&&this.jumpTo(this.style.stylesheet),this._postStyleLoadEvent(),this._postStyleWithAppearanceEvent(),this._setupIndoor()}),this.on("data",t=>{this._update("style"===t.dataType),this.fire(new e.z(`${t.dataType}data`,t))}),this.on("dataloading",t=>{this.fire(new e.z(`${t.dataType}dataloading`,t))}),this._interactions=new Pl(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.y(new Error("Invalid argument to map.addControl(). Argument must be a control with onAdd and onRemove methods.")));const r=t.onAdd(this);this._controls.push(t);const n=this._controlPositions[i];return-1!==i.indexOf("bottom")?n.insertBefore(r,n.firstChild):n.appendChild(r),this}removeControl(t){if(!t||!t.onRemove)return this.fire(new e.y(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.indexOf(e)>-1}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.z("movestart",t)).fire(new e.z("move",t)),this.fire(new e.z("resize",t)),i&&this.fire(new e.z("moveend",t)),this}getBounds(){return this.transform.getBounds()}getMaxBounds(){return this.transform.getMaxBounds()||null}setMaxBounds(t){return this.transform.setMaxBounds(e.aI.convert(t)),this._update()}setMinZoom(t){if((t=t??-2)>=-2&&t<=this.transform.maxZoom)return this.transform.minZoom=t,this._update(),this.getZoom()=this.transform.minZoom)return this.transform.maxZoom=t,this._update(),this.getZoom()>t?this.setZoom(t):this.fire(new e.z("zoomstart")).fire(new e.z("zoom")).fire(new e.z("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()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.z("pitchstart")).fire(new e.z("pitch")).fire(new e.z("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._tp.refreshUI(),this._scaleFactorChanged=!0,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.reloadSources(),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 r;"globe"===i&&t.zoom>=e.cK?(t.setMercatorFromTransition(),r=!0):"mercator"===i&&t.zoom=e.cK?this.transform.setMercatorFromTransition():this.transform.setProjection(t),this.style.applyProjectionUpdate();const n="mercator"===this.transform.getProjection().name&&r!==this.transform.mercatorFromTransition;return(i||n)&&(this.painter.clearBackgroundTiles(),this.style.clearSources(),this._update(!0),this._forceMarkerAndPopupUpdate(!0)),this}project(t,i){return this.transform.locationPoint3D(e.aS.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 r=e=>{let i=[];if(Array.isArray(t)){const r=t.filter(e=>this.getLayer(e));i=r.length?this.queryRenderedFeatures(e,{layers:r}):[]}else i=this.queryRenderedFeatures(e,{target:t});return i};if("mouseenter"===e||"mouseover"===e){let n=!1;const o=t=>{const o=r(t.point);o.length?n||(n=!0,i.call(this,new Fa(e,this,t.originalEvent,{features:o}))):n=!1};return{listener:i,targets:t,delegates:{mousemove:o,mouseout:()=>{n=!1}}}}if("mouseleave"===e||"mouseout"===e){let n=!1;const o=t=>{r(t.point).length?n=!0:n&&(n=!1,i.call(this,new Fa(e,this,t.originalEvent)))},s=t=>{n&&(n=!1,i.call(this,new Fa(e,this,t.originalEvent)))};return{listener:i,targets:t,delegates:{mousemove:o,mouseout:s}}}{const n=e=>{const t=r(e.point);t.length&&(e.features=t,i.call(this,e),delete e.features)};return{listener:i,targets:t,delegates:{[e]:n}}}}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 r=this._createDelegatedListener(e,t,i);this._delegatedListeners=this._delegatedListeners||{},this._delegatedListeners[e]=this._delegatedListeners[e]||[],this._delegatedListeners[e].push(r);for(const e in r.delegates)this.on(e,r.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 r=this._createDelegatedListener(e,t,i);for(const e in r.delegates)this.once(e,r.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 r=this._delegatedListeners?this._delegatedListeners[e]:void 0;return r&&(e=>{for(let r=0;r{if(r){const n="string"==typeof r?r:r instanceof Error?r.message:r.error;e.w(`Unable to perform style diff: ${n}. Rebuilding the style from scratch.`),this._updateStyle(t,i)}else n&&this._update(!0)},()=>this._postStyleLoadEvent()),this):(this._localIdeographFontFamily=i.localIdeographFontFamily,this._localFontFamily=i.localFontFamily,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=Object.assign({},t);t&&t.config&&(i.initialConfig=t.config,delete i.config),this.style=new Sr(this,i).load(e),this.style.setEventedParent(this,{style:this.style})}return this._updateTerrain(),this}_lazyInitEmptyStyle(){this.style||(this.style=new Sr(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.y(new Error("IDs can't be empty."))),!1):!e.dq(t)||(this.fire(new e.y(new Error(`IDs can't contain special symbols: "${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()}addSourceType(e,t,i){this._lazyInitEmptyStyle(),this.style.addSourceType(e,t,i)}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:r=1,sdf:n=!1,stretchX:o,stretchY:s,content:a}={}){this._lazyInitEmptyStyle();const l=e.I.from(t);if(i instanceof HTMLImageElement||ImageBitmap&&i instanceof ImageBitmap){const{width:t,height:c,data:u}=e.o.getImageData(i);this.style.addImage(l,{data:new e.q({width:t,height:c},u),pixelRatio:r,stretchX:o,stretchY:s,content:a,sdf:n,version:0,usvg:!1})}else if(void 0===i.width||void 0===i.height)this.fire(new e.y(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:u}=i,h=i;this.style.addImage(l,{data:new e.q({width:c,height:u},new Uint8Array(h.data)),pixelRatio:r,stretchX:o,stretchY:s,content:a,sdf:n,usvg:!1,version:0,userImage:h}),h.onAdd&&h.onAdd(this,t)}}updateImage(t,i){this._lazyInitEmptyStyle();const r=e.I.from(t),n=this.style.getImage(r);if(!n)return void this.fire(new e.y(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.o.getImageData(i):i,{width:s,height:a,data:l}=o;if(void 0===s||void 0===a)return void this.fire(new e.y(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(s!==(n.usvg?n.icon.usvg_tree.width:n.data.width)||a!==(n.usvg?n.icon.usvg_tree.height:n.data.height))return void this.fire(new e.y(new Error(`The width and height of the updated image (${s}, ${a})\n must be that same as the previous version of the image\n (${n.data.width}, ${n.data.height})`)));const c=!(i instanceof HTMLImageElement||ImageBitmap&&i instanceof ImageBitmap);let u=!1;n.usvg?(n.data=new e.q({width:s,height:a},new Uint8Array(l)),n.usvg=!1,n.icon=void 0,u=!0):n.data.replace(l,c),this.style.updateImage(r,n,u)}hasImage(t){return t?!!this.style&&!!this.style.getImage(e.I.from(t)):(this.fire(new e.y(new Error("Missing required image id"))),!1)}removeImage(t){this.style.removeImage(e.I.from(t))}loadImage(t,i){e.n(this._requestManager.transformRequest(t,e.R.Image),(t,r)=>{i(t,r instanceof HTMLImageElement?e.o.getImageData(r):r)})}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.y(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.style.addImport(t,i).catch(t=>this.fire(new e.y(new Error("Failed to add import",t)))),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,r={}){return this._isValidId(e)?(this.style.setPaintProperty(e,t,i,r),this._update(!0)):this}getPaintProperty(e,t){return this._isValidId(e)?this.style.getPaintProperty(e,t):null}setLayoutProperty(e,t,i,r={}){return this._isValidId(e)?(this.style.setLayoutProperty(e,t,i,r),this._update(!0)):this}getLayoutProperty(e,t){return this._isValidId(e)?this.style.getLayoutProperty(e,t):null}setLayerProperty(e,t,i,r={}){return this._isValidId(e)?(this.style.setLayerProperty(e,t,i,r),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)}_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.aS.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)}_selectIndoorFloor(e){this.indoor.selectFloor(e)}_setIndoorActiveFloorsVisibility(e){this.indoor.setActiveFloorsVisibility(e)}_addIndoorControl(){this._indoorControl||(this._indoorControl=new Cl),this.addControl(this._indoorControl,"right")}_removeIndoorControl(){this._indoorControl&&this.removeControl(this._indoorControl)}_updateContainerDimensions(){if(!this._container)return;const e=this._container.getBoundingClientRect().width||400,t=this._container.getBoundingClientRect().height||300;let i,r,n,o=this._container;for(;o&&(!r||!n);){const e=window.getComputedStyle(o).transform;e&&"none"!==e&&(i=e.match(/matrix.*\((.+)\)/)[1].split(", "),i[0]&&"0"!==i[0]&&"1"!==i[0]&&(r=i[0]),i[3]&&"0"!==i[3]&&"1"!==i[3]&&(n=i[3])),o=o.parentElement}this._containerWidth=r?Math.abs(e/r):e,this._containerHeight=n?Math.abs(t/n):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/.")}_setupIndoor(){this.style.isIndoorEnabled()&&(this.indoor=new Ir(this.style),this.on("load",()=>{this._addIndoorControl(),this.indoor._updateUI(this.transform.zoom,this.transform.center,this.transform.getBounds()),this.on("move",()=>{this.indoor._updateUI(this.transform.zoom,this.transform.center,this.transform.getBounds())}),this.on("idle",()=>{this.indoor._updateUI(this.transform.zoom,this.transform.center,this.transform.getBounds())})}))}_setupContainer(){const e=this._container;e.classList.add("mapboxgl-map"),(this._missingCSSCanary=l("div","mapboxgl-canary",e)).style.visibility="hidden",this._detectMissingCSS();const t=this._canvasContainer=l("div","mapboxgl-canvas-container",e);this._canvas=l("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=l("div","mapboxgl-control-container",e),r=this._controlPositions={};["top-left","top","top-right","right","bottom-right","bottom","bottom-left","left"].forEach(e=>{r[e]=l("div",`mapboxgl-ctrl-${e}`,i)}),this._container.addEventListener("scroll",this._onMapScroll,!1)}_resizeCanvas(t,i){const r=e.o.devicePixelRatio||1;this._canvas.width=r*Math.ceil(t),this._canvas.height=r*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 t=Object.assign({},a.supported.webGLContextAttributes,{failIfMajorPerformanceCaveat:this._failIfMajorPerformanceCaveat,preserveDrawingBuffer:this._preserveDrawingBuffer,antialias:this._antialias||!1}),i=this._canvas.getContext("webgl2",t);i?(G(i,!0),this.painter=new ba(i,this._contextCreateOptions,this.transform,this._scaleFactor,this._tp,this._worldview),this.on("data",e=>{"source"===e.dataType&&this.painter.setTileLoadedFlag(!0)}),e.k.testSupport(i)):this.fire(new e.y(new Error("Failed to initialize WebGL")))}_contextLost(t){t.preventDefault(),this._frame&&(this._frame.cancel(),this._frame=null),this.fire(new e.z("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.reloadModels(),this.style.clearSources()),this._update(),this.fire(new e.z("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 n;this.fire(new e.z("renderstart")),++this._frameId;const o=this.painter.context.extTimerQuery,s=e.o.now(),a=this.painter.context.gl;if(this.listens("gpu-timing-frame")&&(n=a.createQuery(),a.beginQuery(o.TIME_ELAPSED_EXT,n)),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 l=this._isInitialLoad?0:this._fadeDuration;if(this.style&&this._styleDirty){this._styleDirty=!1;const t=this.transform.zoom,i=this.transform.pitch,r=e.o.now(),n=new e.ac(t,{now:r,fadeDuration:l,pitch:i,transition:this.style.transition,worldview:this._worldview});this.style.update(n)}this.style&&this.style.hasFogTransition()&&(this.style._markersNeedUpdate=!0,this._sourcesDirty=!0);let c=!1;this.style&&this._sourcesDirty?(this._sourcesDirty=!1,this.painter._updateFog(this.style),this._updateTerrain(),c=this._updateAverageElevation(s),this.style.updateSources(this.transform),this.style.updateImageProviders(),this.isMoving()||this._forceMarkerAndPopupUpdate()):c=this._updateAverageElevation(s);const u=this.style&&this.style._updatePlacement(this.painter,this.painter.transform,this.showCollisionBoxes,l,this._crossSourceCollisions,this.painter.replacementSource,this._scaleFactorChanged);if(this._scaleFactorChanged&&(this._scaleFactorChanged=!1),u&&(this._placementDirty=u.needsRerender),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:l,isInitialLoad:this._isInitialLoad,showPadding:this.showPadding,gpuTiming:!!this.listens("gpu-timing-layer"),gpuTimingDeferredRender:!!this.listens("gpu-timing-deferred-render"),speedIndexTiming:this.speedIndexTiming}),this.fire(new e.z("render")),this.loaded()&&!this._loaded&&(this._loaded=!0,r.mark(i.load),this.fire(new e.z("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.style.modelManager.isLoaded()&&(this._styleDirty=!0),this.style&&!this._placementDirty&&this.style._releaseSymbolFadeTiles(),n){const t=e.o.now()-s;a.endQuery(o.TIME_ELAPSED_EXT),setTimeout(()=>{const i=a.getQueryParameter(n,a.QUERY_RESULT)/1e6;a.deleteQuery(n),this.fire(new e.z("gpu-timing-frame",{cpuTime:t,gpuTime:i}))},50)}if(this.listens("gpu-timing-layer")){const t=this.painter.collectGpuTimers();setTimeout(()=>{const i=this.painter.queryGpuTimers(t);this.fire(new e.z("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.z("gpu-timing-deferred-render",{gpuTime:i}))},50)}const h=this._sourcesDirty||this._styleDirty||this._placementDirty||c;if(h||this._repaint)this.triggerRepaint();else{const t=this.idle();if(t&&(c=this._updateAverageElevation(s,!0)),c)this.triggerRepaint();else if(this._triggerFrame(!1),t&&(this.fire(new e.z("idle")),this._isInitialLoad=!1,this.speedIndexTiming)){const t=this._calculateSpeedIndex();this.fire(new e.z("speedindexcompleted",{speedIndex:t})),this.speedIndexTiming=!1}}!this._loaded||this._fullyLoaded||h||(this._fullyLoaded=!0,r.mark(i.fullLoad),this._performanceMetricsCollection&&U(this._requestManager._customAccessToken,{width:this.painter.width,height:this.painter.height,interactionRange:this._interactionRange,visibilityHidden:this._visibilityHidden,terrainEnabled:!!this.painter.style.getTerrain(),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 r=this.transform.elevation&&this.transform.elevation.exaggeration()!==this._averageElevationExaggeration;if(r||(t||e-this._averageElevationLastSampledAt>500)&&!this._averageElevation.isEasing(e)){const t=this.transform.averageElevation;let n=this.transform.sampleAverageElevation();null!=this.transform.elevation&&(this._averageElevationExaggeration=this.transform.elevation.exaggeration()),isNaN(n)?n=0:this._averageElevationLastSampledAt=e;const o=Math.abs(t-n);if(o>1){if(this._isInitialLoad||r)return this._averageElevation.jumpTo(n),i(n);this._averageElevation.easeTo(n,e,300)}else if(o>1e-4)return this._averageElevation.jumpTo(n),i(n)}return!!this._averageElevation.isEasing(e)&&i(this._averageElevation.getValue(e))}_authenticate(){V(this._getMapId(),this._requestManager._skuToken,this._requestManager._customAccessToken,t=>{if(t&&(t.message===b||401===t.status)){const t=this.painter.context.gl;G(t,!1),this._logoControl instanceof El&&this._logoControl._updateLogo(),t&&t.clear(t.DEPTH_BUFFER_BIT|t.COLOR_BUFFER_BIT|t.STENCIL_BUFFER_BIT),this._silenceAuthErrors||this.fire(new e.y(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/")))}}),L(this._getMapId(),this._requestManager._skuToken,this._requestManager._customAccessToken,()=>{})}_postStyleLoadEvent(){this.style.globalId&&k(this._requestManager._customAccessToken,{map:this,style:this.style.globalId,importedStyles:this.style.getImportGlobalIds()})}_postStyleWithAppearanceEvent(){this.style.globalId&&this.style.hasAppearances()&&O(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,r=i.createFramebuffer();function n(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,r),this._canvasPixelComparison(n(e),t.canvasCopies.map(n),t.timeStamps)}_canvasPixelComparison(e,t,i){let r=i[1]-i[0];const n=e.length/4;for(let o=0;o{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.bv(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,this._tp.refreshUI(),this._update())}get showParseStatus(){return!!this._showParseStatus}set showParseStatus(e){this._showParseStatus!==e&&(this._showParseStatus=e,this._tp.refreshUI(),this._update())}get showTerrainWireframe(){return!!this._showTerrainWireframe}set showTerrainWireframe(e){this._showTerrainWireframe!==e&&(this._showTerrainWireframe=e,this._tp.refreshUI(),this._update())}get showLayers2DWireframe(){return!!this._showLayers2DWireframe}set showLayers2DWireframe(e){this._showLayers2DWireframe!==e&&(this._showLayers2DWireframe=e,this._tp.refreshUI(),this._update())}get showLayers3DWireframe(){return!!this._showLayers3DWireframe}set showLayers3DWireframe(e){this._showLayers3DWireframe!==e&&(this._showLayers3DWireframe=e,this._tp.refreshUI(),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,this._tp.refreshUI(),this._update())}get showCollisionBoxes(){return!!this._showCollisionBoxes}set showCollisionBoxes(e){this._showCollisionBoxes!==e&&(this._showCollisionBoxes=e,this._tp.refreshUI(),e?this.style._generateCollisionBoxes():this._update())}get showOverdrawInspector(){return!!this._showOverdrawInspector}set showOverdrawInspector(e){this._showOverdrawInspector!==e&&(this._showOverdrawInspector=e,this._tp.refreshUI(),this._update())}get repaint(){return!!this._repaint}set repaint(e){this._repaint!==e&&(this._repaint=e,this._tp.refreshUI(),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,this._tp.refreshUI(),e&&this._update())}_setCacheLimits(t,i){e.f3(t,i)}get version(){return t}},NavigationControl:class{constructor(t={}){this.options=Object.assign({},Fl,t),this._container=l("div","mapboxgl-ctrl mapboxgl-ctrl-group"),this._container.addEventListener("contextmenu",e=>e.preventDefault()),this.options.showZoom&&(e.aX(["_setButtonTitle","_updateZoomButtons"],this),this._zoomInButton=this._createButton("mapboxgl-ctrl-zoom-in",e=>{this._map&&this._map.zoomIn({},{originalEvent:e})}),l("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})}),l("span","mapboxgl-ctrl-icon",this._zoomOutButton).setAttribute("aria-hidden","true")),this.options.showCompass&&(e.aX(["_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=l("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(),r=t===e.getMinZoom();this._zoomInButton.disabled=i,this._zoomOutButton.disabled=r,this._zoomInButton.setAttribute("aria-disabled",i.toString()),this._zoomOutButton.setAttribute("aria-disabled",r.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 kl(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=l("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=Object.assign({geolocation:i},Nl,t),e.aX(["_onSuccess","_onError","_onZoom","_finish","_setupUI","_updateCamera","_updateMarker","_updateMarkerRotation","_onDeviceOrientation"],this),this._updateMarkerRotationThrottled=wa(this._updateMarkerRotation,20),this._numberOfWatches=0}onAdd(e){return this._map=e,this._container=l("div","mapboxgl-ctrl mapboxgl-ctrl-group"),this._checkGeolocationSupport(this._setupUI),this._container}onRemove(){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.longitudet.getEast()||i.latitudet.getNorth())}_setErrorState(){switch(this._watchState){case"WAITING_ACTIVE":this._watchState="ACTIVE_ERROR",this._geolocateButton.classList.remove("mapboxgl-ctrl-geolocate-active"),this._geolocateButton.classList.add("mapboxgl-ctrl-geolocate-active-error");break;case"ACTIVE_LOCK":this._watchState="ACTIVE_ERROR",this._geolocateButton.classList.remove("mapboxgl-ctrl-geolocate-active"),this._geolocateButton.classList.add("mapboxgl-ctrl-geolocate-active-error"),this._geolocateButton.classList.add("mapboxgl-ctrl-geolocate-waiting");break;case"BACKGROUND":this._watchState="BACKGROUND_ERROR",this._geolocateButton.classList.remove("mapboxgl-ctrl-geolocate-background"),this._geolocateButton.classList.add("mapboxgl-ctrl-geolocate-background-error"),this._geolocateButton.classList.add("mapboxgl-ctrl-geolocate-waiting")}}_onSuccess(t){if(this._map){if(this._isOutOfMapMaxBounds(t))return this._setErrorState(),this.fire(new e.z("outofmaxbounds",t)),this._updateMarker(),void this._finish();if(this.options.trackUserLocation)switch(this._lastKnownPosition=t,this._watchState){case"WAITING_ACTIVE":case"ACTIVE_LOCK":case"ACTIVE_ERROR":this._watchState="ACTIVE_LOCK",this._geolocateButton.classList.remove("mapboxgl-ctrl-geolocate-waiting"),this._geolocateButton.classList.remove("mapboxgl-ctrl-geolocate-active-error"),this._geolocateButton.classList.add("mapboxgl-ctrl-geolocate-active");break;case"BACKGROUND":case"BACKGROUND_ERROR":this._watchState="BACKGROUND",this._geolocateButton.classList.remove("mapboxgl-ctrl-geolocate-waiting"),this._geolocateButton.classList.remove("mapboxgl-ctrl-geolocate-background-error"),this._geolocateButton.classList.add("mapboxgl-ctrl-geolocate-background")}this.options.showUserLocation&&"OFF"!==this._watchState&&this._updateMarker(t),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.z("geolocate",Object.assign({coords:t.coords,timestamp:t.timestamp},t.toJSON?{toJSON:t.toJSON.bind(t)}:{}))),this._finish()}}_updateCamera(t){const i=new e.aS(t.coords.longitude,t.coords.latitude),r=t.coords.accuracy,n=this._map.getBearing(),o=Object.assign({bearing:n},this.options.fitBoundsOptions);this._map.fitBounds(i.toBounds(r),o,{geolocateSource:!0})}_updateMarker(t){if(t){const i=new e.aS(t.coords.longitude,t.coords.latitude);this._accuracyCircleMarker.setLngLat(i).addTo(this._map),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.ce(1,t._center.lat)*t.worldSize,r=Math.ceil(2*this._accuracy*i);this._circleElement.style.width=`${r}px`,this._circleElement.style.height=`${r}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.options.trackUserLocation)if(1===t.code){this._watchState="OFF",this._geolocateButton.classList.remove("mapboxgl-ctrl-geolocate-waiting"),this._geolocateButton.classList.remove("mapboxgl-ctrl-geolocate-active"),this._geolocateButton.classList.remove("mapboxgl-ctrl-geolocate-active-error"),this._geolocateButton.classList.remove("mapboxgl-ctrl-geolocate-background"),this._geolocateButton.classList.remove("mapboxgl-ctrl-geolocate-background-error"),this._geolocateButton.disabled=!0;const e=this._map._getUIString("GeolocateControl.LocationNotAvailable");this._geolocateButton.setAttribute("aria-label",e),this._geolocateButton.firstElementChild&&this._geolocateButton.firstElementChild.setAttribute("title",e),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.z("error",t)),this._finish()}}_finish(){this._timeoutId&&clearTimeout(this._timeoutId),this._timeoutId=void 0}_setupUI(t){if(void 0!==this._map){if(this._container.addEventListener("contextmenu",e=>e.preventDefault()),this._geolocateButton=l("button","mapboxgl-ctrl-geolocate",this._container),l("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.");const t=this._map._getUIString("GeolocateControl.LocationNotAvailable");this._geolocateButton.disabled=!0,this._geolocateButton.setAttribute("aria-label",t),this._geolocateButton.firstElementChild&&this._geolocateButton.firstElementChild.setAttribute("title",t)}else{const e=this._map._getUIString("GeolocateControl.FindMyLocation");this._geolocateButton.setAttribute("aria-label",e),this._geolocateButton.firstElementChild&&this._geolocateButton.firstElementChild.setAttribute("title",e)}this.options.trackUserLocation&&(this._geolocateButton.setAttribute("aria-pressed","false"),this._watchState="OFF"),this.options.showUserLocation&&(this._dotElement=l("div","mapboxgl-user-location"),this._dotElement.appendChild(l("div","mapboxgl-user-location-dot")),this._dotElement.appendChild(l("div","mapboxgl-user-location-heading")),this._userLocationDotMarker=new Ul({element:this._dotElement,rotationAlignment:"map",pitchAlignment:"map"}),this._circleElement=l("div","mapboxgl-user-location-accuracy-circle"),this._accuracyCircleMarker=new Ul({element:this._circleElement,pitchAlignment:"map"}),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.trackUserLocation&&this._map.on("movestart",t=>{t.geolocateSource||"ACTIVE_LOCK"!==this._watchState||t.originalEvent&&"resize"===t.originalEvent.type||(this._watchState="BACKGROUND",this._geolocateButton.classList.add("mapboxgl-ctrl-geolocate-background"),this._geolocateButton.classList.remove("mapboxgl-ctrl-geolocate-active"),this.fire(new e.z("trackuserlocationend")))})}}_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._watchState="WAITING_ACTIVE",this.fire(new e.z("trackuserlocationstart"));break;case"WAITING_ACTIVE":case"ACTIVE_LOCK":case"ACTIVE_ERROR":case"BACKGROUND_ERROR":this._numberOfWatches--,this._noTimeout=!1,this._watchState="OFF",this._geolocateButton.classList.remove("mapboxgl-ctrl-geolocate-waiting"),this._geolocateButton.classList.remove("mapboxgl-ctrl-geolocate-active"),this._geolocateButton.classList.remove("mapboxgl-ctrl-geolocate-active-error"),this._geolocateButton.classList.remove("mapboxgl-ctrl-geolocate-background"),this._geolocateButton.classList.remove("mapboxgl-ctrl-geolocate-background-error"),this.fire(new e.z("trackuserlocationend"));break;case"BACKGROUND":this._watchState="ACTIVE_LOCK",this._geolocateButton.classList.remove("mapboxgl-ctrl-geolocate-background"),this._lastKnownPosition&&this._updateCamera(this._lastKnownPosition),this.fire(new e.z("trackuserlocationstart"))}switch(this._watchState){case"WAITING_ACTIVE":this._geolocateButton.classList.add("mapboxgl-ctrl-geolocate-waiting"),this._geolocateButton.classList.add("mapboxgl-ctrl-geolocate-active");break;case"ACTIVE_LOCK":this._geolocateButton.classList.add("mapboxgl-ctrl-geolocate-active");break;case"ACTIVE_ERROR":this._geolocateButton.classList.add("mapboxgl-ctrl-geolocate-waiting"),this._geolocateButton.classList.add("mapboxgl-ctrl-geolocate-active-error");break;case"BACKGROUND":this._geolocateButton.classList.add("mapboxgl-ctrl-geolocate-background");break;case"BACKGROUND_ERROR":this._geolocateButton.classList.add("mapboxgl-ctrl-geolocate-waiting"),this._geolocateButton.classList.add("mapboxgl-ctrl-geolocate-background-error")}if("OFF"===this._watchState&&void 0!==this._geolocationWatchID)this._clearWatch();else if(void 0===this._geolocationWatchID){let e;this._geolocateButton.classList.add("mapboxgl-ctrl-geolocate-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.options.showUserHeading&&this._addDeviceOrientationListener()}}else this.options.geolocation.getCurrentPosition(this._onSuccess,this._onError,this.options.positionOptions),this._timeoutId=window.setTimeout(this._finish,1e4);return!0}_addDeviceOrientationListener(){const e=()=>{"ondeviceorientationabsolute"in window?window.addEventListener("deviceorientationabsolute",this._onDeviceOrientation):window.addEventListener("deviceorientation",this._onDeviceOrientation)};"undefined"!=typeof DeviceMotionEvent&&"function"==typeof DeviceMotionEvent.requestPermission?DeviceOrientationEvent.requestPermission().then(t=>{"granted"===t&&e()}).catch(console.error):e()}_clearWatch(){this.options.geolocation.clearWatch(this._geolocationWatchID),window.removeEventListener("deviceorientation",this._onDeviceOrientation),window.removeEventListener("deviceorientationabsolute",this._onDeviceOrientation),this._geolocationWatchID=void 0,this._geolocateButton.classList.remove("mapboxgl-ctrl-geolocate-waiting"),this._geolocateButton.setAttribute("aria-pressed","false"),this.options.showUserLocation&&this._updateMarker(null)}},AttributionControl:Tl,ScaleControl:class{constructor(t={}){this.options=Object.assign({},Vl,t),this._isNumberFormatSupported=function(){try{return new Intl.NumberFormat("en",{style:"unit",unitDisplay:"short",unit:"meter"}),!0}catch(e){return!1}}(),e.aX(["_update","_setScale","setUnit"],this)}getDefaultPosition(){return"bottom-left"}_update(){const e=this.options.maxWidth||100,t=this._map,i=t._containerHeight/2,r=t._containerWidth/2-e/2,n=t.unproject([r,i]),o=t.unproject([r+e,i]),s=n.distanceTo(o);if("imperial"===this.options.unit){const t=3.2808*s;t>5280?this._setScale(e,t/5280,"mile"):this._setScale(e,t,"foot")}else"nautical"===this.options.unit?this._setScale(e,s/1852,"nautical-mile"):s>=1e3?this._setScale(e,s/1e3,"kilometer"):this._setScale(e,s,"meter")}_setScale(e,t,i){this._map._requestDomTask(()=>{const r=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),n=r/t;this._container.innerHTML=this._isNumberFormatSupported&&"nautical-mile"!==i?new Intl.NumberFormat(this._language,{style:"unit",unitDisplay:"short",unit:i}).format(r):`${r} ${jl[i]}`,this._container.style.width=e*n+"px"})}onAdd(e){return this._map=e,this._language=e.getLanguage(),this._container=l("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.aX(["_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=l("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=l("button","mapboxgl-ctrl-fullscreen",this._controlContainer);l("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:Cl,Popup:class extends e.E{constructor(t){super(),this.options=Object.assign(Object.create(Gl),t),this._altitude=this.options.altitude,e.aX(["_update","_onClose","remove","_onMouseEvent"],this),this._classList=new Set(t&&t.className?t.className.trim().split(/\s+/):[])}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.z("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.z("close")),this}getLngLat(){return this._lngLat}setLngLat(t){this._lngLat=e.aS.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 r;for(i.innerHTML=e;r=i.firstChild,r;)t.appendChild(r);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=l("div","mapboxgl-popup-content",this._container||void 0);if(t.appendChild(e),this.options.closeButton){const e=this._closeButton=l("button","mapboxgl-popup-close-button",t);e.type="button",e.setAttribute("aria-label","Close popup"),e.innerHTML='',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,r=this._pos;if(!t||!i||!r)return"bottom";const n=i.offsetWidth,o=i.offsetHeight,s=r.xt.transform.width-n/2;if(r.y+et.transform.height-o){if(s)return"bottom-left";if(a)return"bottom-right"}return s?"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,r=this._content;if(!i||!this._lngLat&&!this._trackPointer||!r)return;let n=this._container;if(n||(n=this._container=l("div","mapboxgl-popup",i.getContainer()),this._tip=l("div","mapboxgl-popup-tip",n),n.appendChild(r)),this.options.maxWidth&&n.style.maxWidth!==this.options.maxWidth&&(n.style.maxWidth=this.options.maxWidth),i.transform.renderWorldCopies&&!this._trackPointer&&(this._lngLat=Dl(this._lngLat,this._pos,i.transform)),!this._trackPointer||t){const r=this._pos=this._trackPointer&&t instanceof e.P?t:i.project(this._lngLat,this._altitude),n=Ql(this.options.offset),o=this._anchor=this._getAnchor(n.y),s=Ql(this.options.offset,o),a=r.add(s).round();i._requestDomTask(()=>{this._container&&o&&(this._container.style.transform=`${Ol[o]} translate(${a.x}px,${a.y}px)`)})}if(!this._marker&&i._showingGlobe()){const t=e.f4(i.transform,this._lngLat)?0:1;this._setOpacity(t)}this._updateClassList()}_focusFirstElement(){if(!this.options.focusAfterOpen||!this._container)return;const e=this._container.querySelector(Hl);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:Ul,Style:Sr,LngLat:e.aS,LngLatBounds:e.aI,Point:e.P,MercatorCoordinate:e.ae,FreeCameraOptions:tr,Evented:e.E,config:e.e,prewarm:e.f8,clearPrewarmedResources:e.f7,get accessToken(){return e.e.ACCESS_TOKEN},set accessToken(t){e.e.ACCESS_TOKEN=t},get baseApiUrl(){return e.e.API_URL},set baseApiUrl(t){e.e.API_URL=t},get workerCount(){return e.fh.workerCount},set workerCount(t){e.fh.workerCount=t},get maxParallelImageRequests(){return e.e.MAX_PARALLEL_IMAGE_REQUESTS},set maxParallelImageRequests(t){e.e.MAX_PARALLEL_IMAGE_REQUESTS=t},clearStorage(t){e.fg(t)},get workerUrl(){return e.ff.workerUrl},set workerUrl(t){e.ff.workerUrl=t},get workerClass(){return e.ff.workerClass},set workerClass(t){e.ff.workerClass=t},get workerParams(){return e.ff.workerParams},set workerParams(t){e.ff.workerParams=t},get dracoUrl(){return e.fe()},set dracoUrl(t){e.fd(t)},get meshoptUrl(){return e.fc()},set meshoptUrl(t){e.fb(t)},setNow:e.o.setNow,restoreNow:e.o.restoreNow};return $l});var n=i;return n}();var Ze=He($e.exports),We=e({__proto__:null,default:Ze},[$e.exports]),qe={exports:{}};qe.exports=function(){var e={},t={};function i(i,r,n){if(t[i]=n,"index"===i){var o="var sharedModule = {}; ("+t.shared+")(sharedModule); ("+t.worker+")(sharedModule);",s={};return t.shared(s),t.index(e,s),"undefined"!=typeof window&&e.setWorkerUrl(window.URL.createObjectURL(new Blob([o],{type:"text/javascript"}))),e}}i("shared",["exports"],function(e){function t(e,t,i,r){return new(i||(i=Promise))(function(n,o){function s(e){try{l(r.next(e))}catch(e){o(e)}}function a(e){try{l(r.throw(e))}catch(e){o(e)}}function l(e){var t;e.done?n(e.value):(t=e.value,t instanceof i?t:new i(function(e){e(t)})).then(s,a)}l((r=r.apply(e,t||[])).next())})}function i(e,t){this.x=e,this.y=t}function r(e){return e&&e.__esModule&&Object.prototype.hasOwnProperty.call(e,"default")?e.default:e}var n,o;"function"==typeof SuppressedError&&SuppressedError,i.prototype={clone(){return new i(this.x,this.y)},add(e){return this.clone()._add(e)},sub(e){return this.clone()._sub(e)},multByPoint(e){return this.clone()._multByPoint(e)},divByPoint(e){return this.clone()._divByPoint(e)},mult(e){return this.clone()._mult(e)},div(e){return this.clone()._div(e)},rotate(e){return this.clone()._rotate(e)},rotateAround(e,t){return this.clone()._rotateAround(e,t)},matMult(e){return this.clone()._matMult(e)},unit(){return this.clone()._unit()},perp(){return this.clone()._perp()},round(){return this.clone()._round()},mag(){return Math.sqrt(this.x*this.x+this.y*this.y)},equals(e){return this.x===e.x&&this.y===e.y},dist(e){return Math.sqrt(this.distSqr(e))},distSqr(e){const t=e.x-this.x,i=e.y-this.y;return t*t+i*i},angle(){return Math.atan2(this.y,this.x)},angleTo(e){return Math.atan2(this.y-e.y,this.x-e.x)},angleWith(e){return this.angleWithSep(e.x,e.y)},angleWithSep(e,t){return Math.atan2(this.x*t-this.y*e,this.x*e+this.y*t)},_matMult(e){const t=e[2]*this.x+e[3]*this.y;return this.x=e[0]*this.x+e[1]*this.y,this.y=t,this},_add(e){return this.x+=e.x,this.y+=e.y,this},_sub(e){return this.x-=e.x,this.y-=e.y,this},_mult(e){return this.x*=e,this.y*=e,this},_div(e){return this.x/=e,this.y/=e,this},_multByPoint(e){return this.x*=e.x,this.y*=e.y,this},_divByPoint(e){return this.x/=e.x,this.y/=e.y,this},_unit(){return this._div(this.mag()),this},_perp(){const e=this.y;return this.y=this.x,this.x=-e,this},_rotate(e){const t=Math.cos(e),i=Math.sin(e),r=i*this.x+t*this.y;return this.x=t*this.x-i*this.y,this.y=r,this},_rotateAround(e,t){const i=Math.cos(e),r=Math.sin(e),n=t.y+r*(this.x-t.x)+i*(this.y-t.y);return this.x=t.x+i*(this.x-t.x)-r*(this.y-t.y),this.y=n,this},_round(){return this.x=Math.round(this.x),this.y=Math.round(this.y),this},constructor:i},i.convert=function(e){if(e instanceof i)return e;if(Array.isArray(e))return new i(+e[0],+e[1]);if(void 0!==e.x&&void 0!==e.y)return new i(+e.x,+e.y);throw new Error("Expected [x, y] or {x, y} point format")};var s=function(){if(o)return n;function e(e,t,i,r){this.cx=3*e,this.bx=3*(i-e)-this.cx,this.ax=1-this.cx-this.bx,this.cy=3*t,this.by=3*(r-t)-this.cy,this.ay=1-this.cy-this.by,this.p1x=e,this.p1y=t,this.p2x=i,this.p2y=r}return o=1,n=e,e.prototype={sampleCurveX:function(e){return((this.ax*e+this.bx)*e+this.cx)*e},sampleCurveY:function(e){return((this.ay*e+this.by)*e+this.cy)*e},sampleCurveDerivativeX:function(e){return(3*this.ax*e+2*this.bx)*e+this.cx},solveCurveX:function(e,t){if(void 0===t&&(t=1e-6),e<0)return 0;if(e>1)return 1;for(var i=e,r=0;r<8;r++){var n=this.sampleCurveX(i)-e;if(Math.abs(n)n?s=i:a=i,i=.5*(a-s)+s;return i},solve:function(e,t){return this.sampleCurveY(this.solveCurveX(e,t))}},n}(),a=r(s);let l,c;function u(){return null==l&&(l="undefined"!=typeof OffscreenCanvas&&new OffscreenCanvas(1,1).getContext("2d")&&"function"==typeof createImageBitmap),l}function h(){if(null==c&&(c=!1,u())){const e=5,t=new OffscreenCanvas(e,e).getContext("2d",{willReadFrequently:!0});if(t){for(let i=0;i4&&void 0!==arguments[4]?arguments[4]:"zyx",o=Math.PI/360;t*=o,r*=o,i*=o;var s=Math.sin(t),a=Math.cos(t),l=Math.sin(i),c=Math.cos(i),u=Math.sin(r),h=Math.cos(r);switch(n){case"xyz":e[0]=s*c*h+a*l*u,e[1]=a*l*h-s*c*u,e[2]=a*c*u+s*l*h,e[3]=a*c*h-s*l*u;break;case"xzy":e[0]=s*c*h-a*l*u,e[1]=a*l*h-s*c*u,e[2]=a*c*u+s*l*h,e[3]=a*c*h+s*l*u;break;case"yxz":e[0]=s*c*h+a*l*u,e[1]=a*l*h-s*c*u,e[2]=a*c*u-s*l*h,e[3]=a*c*h+s*l*u;break;case"yzx":e[0]=s*c*h+a*l*u,e[1]=a*l*h+s*c*u,e[2]=a*c*u-s*l*h,e[3]=a*c*h-s*l*u;break;case"zxy":e[0]=s*c*h-a*l*u,e[1]=a*l*h+s*c*u,e[2]=a*c*u+s*l*h,e[3]=a*c*h-s*l*u;break;case"zyx":e[0]=s*c*h-a*l*u,e[1]=a*l*h+s*c*u,e[2]=a*c*u-s*l*h,e[3]=a*c*h+s*l*u;break;default:throw new Error("Unknown angle order "+n)}return e}function B(){var e=new p(2);return p!=Float32Array&&(e[0]=0,e[1]=0),e}function S(e,t){var i=new p(2);return i[0]=e,i[1]=t,i}g(),b=new p(4),p!=Float32Array&&(b[0]=0,b[1]=0,b[2]=0,b[3]=0),g(),A(1,0,0),A(0,1,0),E(),E(),f(),B();const I=8192;function M(e,t,i){return t*(I/(e.tileSize*Math.pow(2,i-e.tileID.overscaledZ)))}function P(e,t){return(e%t+t)%t}function R(e,t,i){return e*(1-i)+t*i}function L(e){if(e<=0)return 0;if(e>=1)return 1;const t=e*e,i=t*e;return 4*(e<.5?i:3*(e-t)+i-.75)}function F(e,t,i,r){const n=new a(e,t,i,r);return e=>n.solve(e)}const k=F(.25,.1,.25,1);function D(e,t,i){return Math.min(i,Math.max(t,e))}function O(e,t,i){const r=i-t,n=((e-t)%r+r)%r+t;return n===t?i:n}function z(e,...t){for(const i of t)for(const t in i)e[t]=i[t];return e}let U=1;function N(e,t,i){const r={};for(const i in e)r[i]=t.call(this,e[i],i,e);return r}function V(e,t,i){const r={};for(const i in e)t.call(this,e[i],i,e)&&(r[i]=e[i]);return r}function j(e){return Array.isArray(e)?e.map(j):"object"==typeof e&&e?N(e,j):e}const G={};function H(e){G[e]||("undefined"!=typeof console&&console.warn(e),G[e]=!0)}function Q(e,t,i){return(i.y-e.y)*(t.x-e.x)>(t.y-e.y)*(i.x-e.x)}function $(e){return"undefined"!=typeof WorkerGlobalScope&&void 0!==e&&e instanceof WorkerGlobalScope}let Z=null;function W(e){return"undefined"!=typeof ImageBitmap&&e instanceof ImageBitmap}const q="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAYAAAAfFcSJAAAAC0lEQVQYV2NgAAIAAAUAAarVyFEAAAAASUVORK5CYII=";function K(e,i,r,n,o){return t(this,void 0,void 0,function*(){if("undefined"==typeof VideoFrame)throw new Error("VideoFrame not supported");const t=new VideoFrame(e,{timestamp:0});try{const s=null==t?void 0:t.format;if(!s||!s.startsWith("BGR")&&!s.startsWith("RGB"))throw new Error(`Unrecognized format ${s}`);const a=s.startsWith("BGR"),l=new Uint8ClampedArray(n*o*4);if(yield t.copyTo(l,function(e,t,i,r,n){const o=4*Math.max(-t,0),s=(Math.max(0,i)-i)*r*4+o,a=4*r,l=Math.max(0,t),c=Math.max(0,i);return{rect:{x:l,y:c,width:Math.min(e.width,t+r)-l,height:Math.min(e.height,i+n)-c},layout:[{offset:s,stride:a}]}}(e,i,r,n,o)),a)for(let e=0;e{e.removeEventListener(t,i,r)}}}function ee(e){return e*Math.PI/180}function te(e){return e/Math.PI*180}const ie={touchstart:!0,touchmove:!0,touchmoveWindow:!0,touchend:!0,touchcancel:!0},re={dblclick:!0,click:!0,mouseover:!0,mouseout:!0,mousedown:!0,mousemove:!0,mousemoveWindow:!0,mouseup:!0,mouseupWindow:!0,contextmenu:!0,wheel:!0},ne="AbortError";function oe(){return new Error(ne)}const se={MAX_PARALLEL_IMAGE_REQUESTS:16,MAX_PARALLEL_IMAGE_REQUESTS_PER_FRAME:8,MAX_TILE_CACHE_ZOOM_LEVELS:5,REGISTERED_PROTOCOLS:{},WORKER_URL:""};function ae(e){return se.REGISTERED_PROTOCOLS[e.substring(0,e.indexOf("://"))]}const le="global-dispatcher";class ce extends Error{constructor(e,t,i,r){super(`AJAXError: ${t} (${e}): ${i}`),this.status=e,this.statusText=t,this.url=i,this.body=r}}const ue=()=>$(self)?self.worker&&self.worker.referrer:("blob:"===window.location.protocol?window.parent:window).location.href,he=function(e,i){if(/:\/\//.test(e.url)&&!/^https?:|^file:/.test(e.url)){const t=ae(e.url);if(t)return t(e,i);if($(self)&&self.worker&&self.worker.actor)return self.worker.actor.sendAsync({type:"GR",data:e,targetMapId:le},i)}if(!(/^file:/.test(r=e.url)||/^file:/.test(ue())&&!/^\w+:/.test(r))){if(fetch&&Request&&AbortController&&Object.prototype.hasOwnProperty.call(Request.prototype,"signal"))return function(e,i){return t(this,void 0,void 0,function*(){const t=new Request(e.url,{method:e.method||"GET",body:e.body,credentials:e.credentials,headers:e.headers,cache:e.cache,referrer:ue(),signal:i.signal});let r,n;"json"!==e.type||t.headers.has("Accept")||t.headers.set("Accept","application/json");try{r=yield fetch(t)}catch(t){throw new ce(0,t.message,e.url,new Blob)}if(!r.ok){const t=yield r.blob();throw new ce(r.status,r.statusText,e.url,t)}n="arrayBuffer"===e.type||"image"===e.type?r.arrayBuffer():"json"===e.type?r.json():r.text();const o=yield n;if(i.signal.aborted)throw oe();return{data:o,cacheControl:r.headers.get("Cache-Control"),expires:r.headers.get("Expires")}})}(e,i);if($(self)&&self.worker&&self.worker.actor)return self.worker.actor.sendAsync({type:"GR",data:e,mustQueue:!0,targetMapId:le},i)}var r;return function(e,t){return new Promise((i,r)=>{var n;const o=new XMLHttpRequest;o.open(e.method||"GET",e.url,!0),"arrayBuffer"!==e.type&&"image"!==e.type||(o.responseType="arraybuffer");for(const t in e.headers)o.setRequestHeader(t,e.headers[t]);"json"===e.type&&(o.responseType="text",(null===(n=e.headers)||void 0===n?void 0:n.Accept)||o.setRequestHeader("Accept","application/json")),o.withCredentials="include"===e.credentials,o.onerror=()=>{r(new Error(o.statusText))},o.onload=()=>{if(!t.signal.aborted)if((o.status>=200&&o.status<300||0===o.status)&&null!==o.response){let t=o.response;if("json"===e.type)try{t=JSON.parse(o.response)}catch(e){return void r(e)}i({data:t,cacheControl:o.getResponseHeader("Cache-Control"),expires:o.getResponseHeader("Expires")})}else{const t=new Blob([o.response],{type:o.getResponseHeader("Content-Type")});r(new ce(o.status,o.statusText,e.url,t))}},t.signal.addEventListener("abort",()=>{o.abort(),r(oe())}),o.send(e.body)})}(e,i)};function de(e){if(!e||e.indexOf("://")<=0||0===e.indexOf("data:image/")||0===e.indexOf("blob:"))return!0;const t=new URL(e),i=window.location;return t.protocol===i.protocol&&t.host===i.host}function pe(e,t,i){i[e]&&-1!==i[e].indexOf(t)||(i[e]=i[e]||[],i[e].push(t))}function fe(e,t,i){if(i&&i[e]){const r=i[e].indexOf(t);-1!==r&&i[e].splice(r,1)}}class me{constructor(e,t={}){z(this,t),this.type=e}}class ge extends me{constructor(e,t={}){super("error",z({error:e},t))}}class _e{on(e,t){return this._listeners=this._listeners||{},pe(e,t,this._listeners),{unsubscribe:()=>{this.off(e,t)}}}off(e,t){return fe(e,t,this._listeners),fe(e,t,this._oneTimeListeners),this}once(e,t){return t?(this._oneTimeListeners=this._oneTimeListeners||{},pe(e,t,this._oneTimeListeners),this):new Promise(t=>this.once(e,t))}fire(e,t){"string"==typeof e&&(e=new me(e,t||{}));const i=e.type;if(this.listens(i)){e.target=this;const t=this._listeners&&this._listeners[i]?this._listeners[i].slice():[];for(const i of t)i.call(this,e);const r=this._oneTimeListeners&&this._oneTimeListeners[i]?this._oneTimeListeners[i].slice():[];for(const t of r)fe(i,t,this._oneTimeListeners),t.call(this,e);const n=this._eventedParent;n&&(z(e,"function"==typeof this._eventedParentData?this._eventedParentData():this._eventedParentData),n.fire(e))}else e instanceof ge&&console.error(e.error);return this}listens(e){return this._listeners&&this._listeners[e]&&this._listeners[e].length>0||this._oneTimeListeners&&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}}var Ae={$version:8,$root:{version:{required:!0,type:"enum",values:[8]},name:{type:"string"},metadata:{type:"*"},center:{type:"array",value:"number"},centerAltitude:{type:"number"},zoom:{type:"number"},bearing:{type:"number",default:0,period:360,units:"degrees"},pitch:{type:"number",default:0,units:"degrees"},roll:{type:"number",default:0,units:"degrees"},state:{type:"state",default:{}},light:{type:"light"},sky:{type:"sky"},projection:{type:"projection"},terrain:{type:"terrain"},sources:{required:!0,type:"sources"},sprite:{type:"sprite"},glyphs:{type:"string"},"font-faces":{type:"array",value:"fontFaces"},transition:{type:"transition"},layers:{required:!0,type:"array",value:"layer"}},sources:{"*":{type:"source"}},source:["source_vector","source_raster","source_raster_dem","source_geojson","source_video","source_image"],source_vector:{type:{required:!0,type:"enum",values:{vector:{}}},url:{type:"string"},tiles:{type:"array",value:"string"},bounds:{type:"array",value:"number",length:4,default:[-180,-85.051129,180,85.051129]},scheme:{type:"enum",values:{xyz:{},tms:{}},default:"xyz"},minzoom:{type:"number",default:0},maxzoom:{type:"number",default:22},attribution:{type:"string"},promoteId:{type:"promoteId"},volatile:{type:"boolean",default:!1},encoding:{type:"enum",values:{mvt:{},mlt:{}},default:"mvt"},"*":{type:"*"}},source_raster:{type:{required:!0,type:"enum",values:{raster:{}}},url:{type:"string"},tiles:{type:"array",value:"string"},bounds:{type:"array",value:"number",length:4,default:[-180,-85.051129,180,85.051129]},minzoom:{type:"number",default:0},maxzoom:{type:"number",default:22},tileSize:{type:"number",default:512,units:"pixels"},scheme:{type:"enum",values:{xyz:{},tms:{}},default:"xyz"},attribution:{type:"string"},volatile:{type:"boolean",default:!1},"*":{type:"*"}},source_raster_dem:{type:{required:!0,type:"enum",values:{"raster-dem":{}}},url:{type:"string"},tiles:{type:"array",value:"string"},bounds:{type:"array",value:"number",length:4,default:[-180,-85.051129,180,85.051129]},minzoom:{type:"number",default:0},maxzoom:{type:"number",default:22},tileSize:{type:"number",default:512,units:"pixels"},attribution:{type:"string"},encoding:{type:"enum",values:{terrarium:{},mapbox:{},custom:{}},default:"mapbox"},redFactor:{type:"number",default:1},blueFactor:{type:"number",default:1},greenFactor:{type:"number",default:1},baseShift:{type:"number",default:0},volatile:{type:"boolean",default:!1},"*":{type:"*"}},source_geojson:{type:{required:!0,type:"enum",values:{geojson:{}}},data:{required:!0,type:"*"},maxzoom:{type:"number",default:18},attribution:{type:"string"},buffer:{type:"number",default:128,maximum:512,minimum:0},filter:{type:"*"},tolerance:{type:"number",default:.375},cluster:{type:"boolean",default:!1},clusterRadius:{type:"number",default:50,minimum:0},clusterMaxZoom:{type:"number"},clusterMinPoints:{type:"number"},clusterProperties:{type:"*"},lineMetrics:{type:"boolean",default:!1},generateId:{type:"boolean",default:!1},promoteId:{type:"promoteId"}},source_video:{type:{required:!0,type:"enum",values:{video:{}}},urls:{required:!0,type:"array",value:"string"},coordinates:{required:!0,type:"array",length:4,value:{type:"array",length:2,value:"number"}}},source_image:{type:{required:!0,type:"enum",values:{image:{}}},url:{required:!0,type:"string"},coordinates:{required:!0,type:"array",length:4,value:{type:"array",length:2,value:"number"}}},layer:{id:{type:"string",required:!0},type:{type:"enum",values:{fill:{},line:{},symbol:{},circle:{},heatmap:{},"fill-extrusion":{},raster:{},hillshade:{},"color-relief":{},background:{}},required:!0},metadata:{type:"*"},source:{type:"string"},"source-layer":{type:"string"},minzoom:{type:"number",minimum:0,maximum:24},maxzoom:{type:"number",minimum:0,maximum:24},filter:{type:"filter"},layout:{type:"layout"},paint:{type:"paint"}},layout:["layout_fill","layout_line","layout_circle","layout_heatmap","layout_fill-extrusion","layout_symbol","layout_raster","layout_hillshade","layout_color-relief","layout_background"],layout_background:{visibility:{type:"enum",values:{visible:{},none:{}},default:"visible","property-type":"constant"}},layout_fill:{"fill-sort-key":{type:"number",expression:{interpolated:!1,parameters:["zoom","feature"]},"property-type":"data-driven"},visibility:{type:"enum",values:{visible:{},none:{}},default:"visible","property-type":"constant"}},layout_circle:{"circle-sort-key":{type:"number",expression:{interpolated:!1,parameters:["zoom","feature"]},"property-type":"data-driven"},visibility:{type:"enum",values:{visible:{},none:{}},default:"visible","property-type":"constant"}},layout_heatmap:{visibility:{type:"enum",values:{visible:{},none:{}},default:"visible","property-type":"constant"}},"layout_fill-extrusion":{visibility:{type:"enum",values:{visible:{},none:{}},default:"visible","property-type":"constant"}},layout_line:{"line-cap":{type:"enum",values:{butt:{},round:{},square:{}},default:"butt",expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"},"line-join":{type:"enum",values:{bevel:{},round:{},miter:{}},default:"miter",expression:{interpolated:!1,parameters:["zoom","feature"]},"property-type":"data-driven"},"line-miter-limit":{type:"number",default:2,requires:[{"line-join":"miter"}],expression:{interpolated:!0,parameters:["zoom"]},"property-type":"data-constant"},"line-round-limit":{type:"number",default:1.05,requires:[{"line-join":"round"}],expression:{interpolated:!0,parameters:["zoom"]},"property-type":"data-constant"},"line-sort-key":{type:"number",expression:{interpolated:!1,parameters:["zoom","feature"]},"property-type":"data-driven"},visibility:{type:"enum",values:{visible:{},none:{}},default:"visible","property-type":"constant"}},layout_symbol:{"symbol-placement":{type:"enum",values:{point:{},line:{},"line-center":{}},default:"point",expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"},"symbol-spacing":{type:"number",default:250,minimum:1,units:"pixels",requires:[{"symbol-placement":"line"}],expression:{interpolated:!0,parameters:["zoom"]},"property-type":"data-constant"},"symbol-avoid-edges":{type:"boolean",default:!1,expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"},"symbol-sort-key":{type:"number",expression:{interpolated:!1,parameters:["zoom","feature"]},"property-type":"data-driven"},"symbol-z-order":{type:"enum",values:{auto:{},"viewport-y":{},source:{}},default:"auto",expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"},"icon-allow-overlap":{type:"boolean",default:!1,requires:["icon-image",{"!":"icon-overlap"}],expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"},"icon-overlap":{type:"enum",values:{never:{},always:{},cooperative:{}},requires:["icon-image"],expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"},"icon-ignore-placement":{type:"boolean",default:!1,requires:["icon-image"],expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"},"icon-optional":{type:"boolean",default:!1,requires:["icon-image","text-field"],expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"},"icon-rotation-alignment":{type:"enum",values:{map:{},viewport:{},auto:{}},default:"auto",requires:["icon-image"],expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"},"icon-size":{type:"number",default:1,minimum:0,units:"factor of the original icon size",requires:["icon-image"],expression:{interpolated:!0,parameters:["zoom","feature"]},"property-type":"data-driven"},"icon-text-fit":{type:"enum",values:{none:{},width:{},height:{},both:{}},default:"none",requires:["icon-image","text-field"],expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"},"icon-text-fit-padding":{type:"array",value:"number",length:4,default:[0,0,0,0],units:"pixels",requires:["icon-image","text-field",{"icon-text-fit":["both","width","height"]}],expression:{interpolated:!0,parameters:["zoom"]},"property-type":"data-constant"},"icon-image":{type:"resolvedImage",tokens:!0,expression:{interpolated:!1,parameters:["zoom","feature"]},"property-type":"data-driven"},"icon-rotate":{type:"number",default:0,period:360,units:"degrees",requires:["icon-image"],expression:{interpolated:!0,parameters:["zoom","feature"]},"property-type":"data-driven"},"icon-padding":{type:"padding",default:[2],units:"pixels",requires:["icon-image"],expression:{interpolated:!0,parameters:["zoom","feature"]},"property-type":"data-driven"},"icon-keep-upright":{type:"boolean",default:!1,requires:["icon-image",{"icon-rotation-alignment":"map"},{"symbol-placement":["line","line-center"]}],expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"},"icon-offset":{type:"array",value:"number",length:2,default:[0,0],requires:["icon-image"],expression:{interpolated:!0,parameters:["zoom","feature"]},"property-type":"data-driven"},"icon-anchor":{type:"enum",values:{center:{},left:{},right:{},top:{},bottom:{},"top-left":{},"top-right":{},"bottom-left":{},"bottom-right":{}},default:"center",requires:["icon-image"],expression:{interpolated:!1,parameters:["zoom","feature"]},"property-type":"data-driven"},"icon-pitch-alignment":{type:"enum",values:{map:{},viewport:{},auto:{}},default:"auto",requires:["icon-image"],expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"},"text-pitch-alignment":{type:"enum",values:{map:{},viewport:{},auto:{}},default:"auto",requires:["text-field"],expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"},"text-rotation-alignment":{type:"enum",values:{map:{},viewport:{},"viewport-glyph":{},auto:{}},default:"auto",requires:["text-field"],expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"},"text-field":{type:"formatted",default:"",tokens:!0,expression:{interpolated:!1,parameters:["zoom","feature"]},"property-type":"data-driven"},"text-font":{type:"array",value:"string",default:["Open Sans Regular","Arial Unicode MS Regular"],requires:["text-field"],expression:{interpolated:!1,parameters:["zoom","feature"]},"property-type":"data-driven"},"text-size":{type:"number",default:16,minimum:0,units:"pixels",requires:["text-field"],expression:{interpolated:!0,parameters:["zoom","feature"]},"property-type":"data-driven"},"text-max-width":{type:"number",default:10,minimum:0,units:"ems",requires:["text-field"],expression:{interpolated:!0,parameters:["zoom","feature"]},"property-type":"data-driven"},"text-line-height":{type:"number",default:1.2,units:"ems",requires:["text-field"],expression:{interpolated:!0,parameters:["zoom"]},"property-type":"data-constant"},"text-letter-spacing":{type:"number",default:0,units:"ems",requires:["text-field"],expression:{interpolated:!0,parameters:["zoom","feature"]},"property-type":"data-driven"},"text-justify":{type:"enum",values:{auto:{},left:{},center:{},right:{}},default:"center",requires:["text-field"],expression:{interpolated:!1,parameters:["zoom","feature"]},"property-type":"data-driven"},"text-radial-offset":{type:"number",units:"ems",default:0,requires:["text-field"],"property-type":"data-driven",expression:{interpolated:!0,parameters:["zoom","feature"]}},"text-variable-anchor":{type:"array",value:"enum",values:{center:{},left:{},right:{},top:{},bottom:{},"top-left":{},"top-right":{},"bottom-left":{},"bottom-right":{}},requires:["text-field",{"symbol-placement":["point"]}],expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"},"text-variable-anchor-offset":{type:"variableAnchorOffsetCollection",requires:["text-field",{"symbol-placement":["point"]}],expression:{interpolated:!0,parameters:["zoom","feature"]},"property-type":"data-driven"},"text-anchor":{type:"enum",values:{center:{},left:{},right:{},top:{},bottom:{},"top-left":{},"top-right":{},"bottom-left":{},"bottom-right":{}},default:"center",requires:["text-field",{"!":"text-variable-anchor"}],expression:{interpolated:!1,parameters:["zoom","feature"]},"property-type":"data-driven"},"text-max-angle":{type:"number",default:45,units:"degrees",requires:["text-field",{"symbol-placement":["line","line-center"]}],expression:{interpolated:!0,parameters:["zoom"]},"property-type":"data-constant"},"text-writing-mode":{type:"array",value:"enum",values:{horizontal:{},vertical:{}},requires:["text-field",{"symbol-placement":["point"]}],expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"},"text-rotate":{type:"number",default:0,period:360,units:"degrees",requires:["text-field"],expression:{interpolated:!0,parameters:["zoom","feature"]},"property-type":"data-driven"},"text-padding":{type:"number",default:2,minimum:0,units:"pixels",requires:["text-field"],expression:{interpolated:!0,parameters:["zoom"]},"property-type":"data-constant"},"text-keep-upright":{type:"boolean",default:!0,requires:["text-field",{"text-rotation-alignment":"map"},{"symbol-placement":["line","line-center"]}],expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"},"text-transform":{type:"enum",values:{none:{},uppercase:{},lowercase:{}},default:"none",requires:["text-field"],expression:{interpolated:!1,parameters:["zoom","feature"]},"property-type":"data-driven"},"text-offset":{type:"array",value:"number",units:"ems",length:2,default:[0,0],requires:["text-field",{"!":"text-radial-offset"}],expression:{interpolated:!0,parameters:["zoom","feature"]},"property-type":"data-driven"},"text-allow-overlap":{type:"boolean",default:!1,requires:["text-field",{"!":"text-overlap"}],expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"},"text-overlap":{type:"enum",values:{never:{},always:{},cooperative:{}},requires:["text-field"],expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"},"text-ignore-placement":{type:"boolean",default:!1,requires:["text-field"],expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"},"text-optional":{type:"boolean",default:!1,requires:["text-field","icon-image"],expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"},visibility:{type:"enum",values:{visible:{},none:{}},default:"visible","property-type":"constant"}},layout_raster:{visibility:{type:"enum",values:{visible:{},none:{}},default:"visible","property-type":"constant"}},layout_hillshade:{visibility:{type:"enum",values:{visible:{},none:{}},default:"visible","property-type":"constant"}},"layout_color-relief":{visibility:{type:"enum",values:{visible:{},none:{}},default:"visible","property-type":"constant"}},filter:{type:"array",value:"*"},filter_operator:{type:"enum",values:{"==":{},"!=":{},">":{},">=":{},"<":{},"<=":{},in:{},"!in":{},all:{},any:{},none:{},has:{},"!has":{}}},geometry_type:{type:"enum",values:{Point:{},LineString:{},Polygon:{}}},function:{expression:{type:"expression"},stops:{type:"array",value:"function_stop"},base:{type:"number",default:1,minimum:0},property:{type:"string",default:"$zoom"},type:{type:"enum",values:{identity:{},exponential:{},interval:{},categorical:{}},default:"exponential"},colorSpace:{type:"enum",values:{rgb:{},lab:{},hcl:{}},default:"rgb"},default:{type:"*",required:!1}},function_stop:{type:"array",minimum:0,maximum:24,value:["number","color"],length:2},expression:{type:"array",value:"*",minimum:1},light:{anchor:{type:"enum",default:"viewport",values:{map:{},viewport:{}},"property-type":"data-constant",transition:!1,expression:{interpolated:!1,parameters:["zoom"]}},position:{type:"array",default:[1.15,210,30],length:3,value:"number","property-type":"data-constant",transition:!0,expression:{interpolated:!0,parameters:["zoom"]}},color:{type:"color","property-type":"data-constant",default:"#ffffff",expression:{interpolated:!0,parameters:["zoom"]},transition:!0},intensity:{type:"number","property-type":"data-constant",default:.5,minimum:0,maximum:1,expression:{interpolated:!0,parameters:["zoom"]},transition:!0}},sky:{"sky-color":{type:"color","property-type":"data-constant",default:"#88C6FC",expression:{interpolated:!0,parameters:["zoom"]},transition:!0},"horizon-color":{type:"color","property-type":"data-constant",default:"#ffffff",expression:{interpolated:!0,parameters:["zoom"]},transition:!0},"fog-color":{type:"color","property-type":"data-constant",default:"#ffffff",expression:{interpolated:!0,parameters:["zoom"]},transition:!0},"fog-ground-blend":{type:"number","property-type":"data-constant",default:.5,minimum:0,maximum:1,expression:{interpolated:!0,parameters:["zoom"]},transition:!0},"horizon-fog-blend":{type:"number","property-type":"data-constant",default:.8,minimum:0,maximum:1,expression:{interpolated:!0,parameters:["zoom"]},transition:!0},"sky-horizon-blend":{type:"number","property-type":"data-constant",default:.8,minimum:0,maximum:1,expression:{interpolated:!0,parameters:["zoom"]},transition:!0},"atmosphere-blend":{type:"number","property-type":"data-constant",default:.8,minimum:0,maximum:1,expression:{interpolated:!0,parameters:["zoom"]},transition:!0}},terrain:{source:{type:"string",required:!0},exaggeration:{type:"number",minimum:0,default:1}},projection:{type:{type:"projectionDefinition",default:"mercator","property-type":"data-constant",transition:!1,expression:{interpolated:!0,parameters:["zoom"]}}},paint:["paint_fill","paint_line","paint_circle","paint_heatmap","paint_fill-extrusion","paint_symbol","paint_raster","paint_hillshade","paint_color-relief","paint_background"],paint_fill:{"fill-antialias":{type:"boolean",default:!0,expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"},"fill-opacity":{type:"number",default:1,minimum:0,maximum:1,transition:!0,expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"},"fill-color":{type:"color",default:"#000000",transition:!0,requires:[{"!":"fill-pattern"}],expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"},"fill-outline-color":{type:"color",transition:!0,requires:[{"!":"fill-pattern"},{"fill-antialias":!0}],expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"},"fill-translate":{type:"array",value:"number",length:2,default:[0,0],transition:!0,units:"pixels",expression:{interpolated:!0,parameters:["zoom"]},"property-type":"data-constant"},"fill-translate-anchor":{type:"enum",values:{map:{},viewport:{}},default:"map",requires:["fill-translate"],expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"},"fill-pattern":{type:"resolvedImage",transition:!0,expression:{interpolated:!1,parameters:["zoom","feature"]},"property-type":"cross-faded-data-driven"}},"paint_fill-extrusion":{"fill-extrusion-opacity":{type:"number",default:1,minimum:0,maximum:1,transition:!0,expression:{interpolated:!0,parameters:["zoom"]},"property-type":"data-constant"},"fill-extrusion-color":{type:"color",default:"#000000",transition:!0,requires:[{"!":"fill-extrusion-pattern"}],expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"},"fill-extrusion-translate":{type:"array",value:"number",length:2,default:[0,0],transition:!0,units:"pixels",expression:{interpolated:!0,parameters:["zoom"]},"property-type":"data-constant"},"fill-extrusion-translate-anchor":{type:"enum",values:{map:{},viewport:{}},default:"map",requires:["fill-extrusion-translate"],expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"},"fill-extrusion-pattern":{type:"resolvedImage",transition:!0,expression:{interpolated:!1,parameters:["zoom","feature"]},"property-type":"cross-faded-data-driven"},"fill-extrusion-height":{type:"number",default:0,minimum:0,units:"meters",transition:!0,expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"},"fill-extrusion-base":{type:"number",default:0,minimum:0,units:"meters",transition:!0,requires:["fill-extrusion-height"],expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"},"fill-extrusion-vertical-gradient":{type:"boolean",default:!0,transition:!1,expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"}},paint_line:{"line-opacity":{type:"number",default:1,minimum:0,maximum:1,transition:!0,expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"},"line-color":{type:"color",default:"#000000",transition:!0,requires:[{"!":"line-pattern"}],expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"},"line-translate":{type:"array",value:"number",length:2,default:[0,0],transition:!0,units:"pixels",expression:{interpolated:!0,parameters:["zoom"]},"property-type":"data-constant"},"line-translate-anchor":{type:"enum",values:{map:{},viewport:{}},default:"map",requires:["line-translate"],expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"},"line-width":{type:"number",default:1,minimum:0,transition:!0,units:"pixels",expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"},"line-gap-width":{type:"number",default:0,minimum:0,transition:!0,units:"pixels",expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"},"line-offset":{type:"number",default:0,transition:!0,units:"pixels",expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"},"line-blur":{type:"number",default:0,minimum:0,transition:!0,units:"pixels",expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"},"line-dasharray":{type:"array",value:"number",minimum:0,transition:!0,units:"line widths",requires:[{"!":"line-pattern"}],expression:{interpolated:!1,parameters:["zoom","feature"]},"property-type":"cross-faded-data-driven"},"line-pattern":{type:"resolvedImage",transition:!0,expression:{interpolated:!1,parameters:["zoom","feature"]},"property-type":"cross-faded-data-driven"},"line-gradient":{type:"color",transition:!1,requires:[{"!":"line-dasharray"},{"!":"line-pattern"},{source:"geojson",has:{lineMetrics:!0}}],expression:{interpolated:!0,parameters:["line-progress"]},"property-type":"color-ramp"}},paint_circle:{"circle-radius":{type:"number",default:5,minimum:0,transition:!0,units:"pixels",expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"},"circle-color":{type:"color",default:"#000000",transition:!0,expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"},"circle-blur":{type:"number",default:0,transition:!0,expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"},"circle-opacity":{type:"number",default:1,minimum:0,maximum:1,transition:!0,expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"},"circle-translate":{type:"array",value:"number",length:2,default:[0,0],transition:!0,units:"pixels",expression:{interpolated:!0,parameters:["zoom"]},"property-type":"data-constant"},"circle-translate-anchor":{type:"enum",values:{map:{},viewport:{}},default:"map",requires:["circle-translate"],expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"},"circle-pitch-scale":{type:"enum",values:{map:{},viewport:{}},default:"map",expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"},"circle-pitch-alignment":{type:"enum",values:{map:{},viewport:{}},default:"viewport",expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"},"circle-stroke-width":{type:"number",default:0,minimum:0,transition:!0,units:"pixels",expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"},"circle-stroke-color":{type:"color",default:"#000000",transition:!0,expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"},"circle-stroke-opacity":{type:"number",default:1,minimum:0,maximum:1,transition:!0,expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"}},paint_heatmap:{"heatmap-radius":{type:"number",default:30,minimum:1,transition:!0,units:"pixels",expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"},"heatmap-weight":{type:"number",default:1,minimum:0,transition:!1,expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"},"heatmap-intensity":{type:"number",default:1,minimum:0,transition:!0,expression:{interpolated:!0,parameters:["zoom"]},"property-type":"data-constant"},"heatmap-color":{type:"color",default:["interpolate",["linear"],["heatmap-density"],0,"rgba(0, 0, 255, 0)",.1,"royalblue",.3,"cyan",.5,"lime",.7,"yellow",1,"red"],transition:!1,expression:{interpolated:!0,parameters:["heatmap-density"]},"property-type":"color-ramp"},"heatmap-opacity":{type:"number",default:1,minimum:0,maximum:1,transition:!0,expression:{interpolated:!0,parameters:["zoom"]},"property-type":"data-constant"}},paint_symbol:{"icon-opacity":{type:"number",default:1,minimum:0,maximum:1,transition:!0,requires:["icon-image"],expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"},"icon-color":{type:"color",default:"#000000",transition:!0,requires:["icon-image"],expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"},"icon-halo-color":{type:"color",default:"rgba(0, 0, 0, 0)",transition:!0,requires:["icon-image"],expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"},"icon-halo-width":{type:"number",default:0,minimum:0,transition:!0,units:"pixels",requires:["icon-image"],expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"},"icon-halo-blur":{type:"number",default:0,minimum:0,transition:!0,units:"pixels",requires:["icon-image"],expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"},"icon-translate":{type:"array",value:"number",length:2,default:[0,0],transition:!0,units:"pixels",requires:["icon-image"],expression:{interpolated:!0,parameters:["zoom"]},"property-type":"data-constant"},"icon-translate-anchor":{type:"enum",values:{map:{},viewport:{}},default:"map",requires:["icon-image","icon-translate"],expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"},"text-opacity":{type:"number",default:1,minimum:0,maximum:1,transition:!0,requires:["text-field"],expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"},"text-color":{type:"color",default:"#000000",transition:!0,overridable:!0,requires:["text-field"],expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"},"text-halo-color":{type:"color",default:"rgba(0, 0, 0, 0)",transition:!0,requires:["text-field"],expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"},"text-halo-width":{type:"number",default:0,minimum:0,transition:!0,units:"pixels",requires:["text-field"],expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"},"text-halo-blur":{type:"number",default:0,minimum:0,transition:!0,units:"pixels",requires:["text-field"],expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"},"text-translate":{type:"array",value:"number",length:2,default:[0,0],transition:!0,units:"pixels",requires:["text-field"],expression:{interpolated:!0,parameters:["zoom"]},"property-type":"data-constant"},"text-translate-anchor":{type:"enum",values:{map:{},viewport:{}},default:"map",requires:["text-field","text-translate"],expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"}},paint_raster:{"raster-opacity":{type:"number",default:1,minimum:0,maximum:1,transition:!0,expression:{interpolated:!0,parameters:["zoom"]},"property-type":"data-constant"},"raster-hue-rotate":{type:"number",default:0,period:360,transition:!0,units:"degrees",expression:{interpolated:!0,parameters:["zoom"]},"property-type":"data-constant"},"raster-brightness-min":{type:"number",default:0,minimum:0,maximum:1,transition:!0,expression:{interpolated:!0,parameters:["zoom"]},"property-type":"data-constant"},"raster-brightness-max":{type:"number",default:1,minimum:0,maximum:1,transition:!0,expression:{interpolated:!0,parameters:["zoom"]},"property-type":"data-constant"},"raster-saturation":{type:"number",default:0,minimum:-1,maximum:1,transition:!0,expression:{interpolated:!0,parameters:["zoom"]},"property-type":"data-constant"},"raster-contrast":{type:"number",default:0,minimum:-1,maximum:1,transition:!0,expression:{interpolated:!0,parameters:["zoom"]},"property-type":"data-constant"},"raster-resampling":{type:"enum",values:{linear:{},nearest:{}},default:"linear",expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"},"raster-fade-duration":{type:"number",default:300,minimum:0,transition:!1,units:"milliseconds",expression:{interpolated:!0,parameters:["zoom"]},"property-type":"data-constant"}},paint_hillshade:{"hillshade-illumination-direction":{type:"numberArray",default:335,minimum:0,maximum:359,transition:!1,expression:{interpolated:!0,parameters:["zoom"]},"property-type":"data-constant"},"hillshade-illumination-altitude":{type:"numberArray",default:45,minimum:0,maximum:90,transition:!1,expression:{interpolated:!0,parameters:["zoom"]},"property-type":"data-constant"},"hillshade-illumination-anchor":{type:"enum",values:{map:{},viewport:{}},default:"viewport",expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"},"hillshade-exaggeration":{type:"number",default:.5,minimum:0,maximum:1,transition:!0,expression:{interpolated:!0,parameters:["zoom"]},"property-type":"data-constant"},"hillshade-shadow-color":{type:"colorArray",default:"#000000",transition:!0,expression:{interpolated:!0,parameters:["zoom"]},"property-type":"data-constant"},"hillshade-highlight-color":{type:"colorArray",default:"#FFFFFF",transition:!0,expression:{interpolated:!0,parameters:["zoom"]},"property-type":"data-constant"},"hillshade-accent-color":{type:"color",default:"#000000",transition:!0,expression:{interpolated:!0,parameters:["zoom"]},"property-type":"data-constant"},"hillshade-method":{type:"enum",values:{standard:{},basic:{},combined:{},igor:{},multidirectional:{}},default:"standard",expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"}},"paint_color-relief":{"color-relief-opacity":{type:"number",default:1,minimum:0,maximum:1,transition:!0,expression:{interpolated:!0,parameters:["zoom"]},"property-type":"data-constant"},"color-relief-color":{type:"color",transition:!1,expression:{interpolated:!0,parameters:["elevation"]},"property-type":"color-ramp"}},paint_background:{"background-color":{type:"color",default:"#000000",transition:!0,requires:[{"!":"background-pattern"}],expression:{interpolated:!0,parameters:["zoom"]},"property-type":"data-constant"},"background-pattern":{type:"resolvedImage",transition:!0,expression:{interpolated:!1,parameters:["zoom"]},"property-type":"cross-faded"},"background-opacity":{type:"number",default:1,minimum:0,maximum:1,transition:!0,expression:{interpolated:!0,parameters:["zoom"]},"property-type":"data-constant"}},transition:{duration:{type:"number",default:300,minimum:0,units:"milliseconds"},delay:{type:"number",default:0,minimum:0,units:"milliseconds"}},"property-type":{"data-driven":{type:"property-type"},"cross-faded":{type:"property-type"},"cross-faded-data-driven":{type:"property-type"},"color-ramp":{type:"property-type"},"data-constant":{type:"property-type"},constant:{type:"property-type"}},promoteId:{"*":{type:"string"}}};const ye=["type","source","source-layer","minzoom","maxzoom","filter","layout"];function ve(e,t){const i={};for(const t in e)"ref"!==t&&(i[t]=e[t]);return ye.forEach(e=>{e in t&&(i[e]=t[e])}),i}function xe(e,t){if(Array.isArray(e)){if(!Array.isArray(t)||e.length!==t.length)return!1;for(let i=0;i`:"value"===e.itemType.kind?"array":`array<${t}>`}return e.kind}const Xe=[Fe,ke,De,Oe,ze,Ue,Ge,Ne,qe(Ve),He,$e,Qe,Ze,We];function Je(e,t){if("error"===t.kind)return null;if("array"===e.kind){if("array"===t.kind&&(0===t.N&&"value"===t.itemType.kind||!Je(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 Xe)if(!Je(e,t))return null}return`Expected ${Ke(e)} but found ${Ke(t)} instead.`}function Ye(e,t){return t.some(t=>t.kind===e.kind)}function et(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 tt(e,t){return"array"===e.kind&&"array"===t.kind?e.itemType.kind===t.itemType.kind&&"number"==typeof e.N:e.kind===t.kind}const it=.96422,rt=.82521,nt=4/29,ot=6/29,st=3*ot*ot,at=ot*ot*ot,lt=Math.PI/180,ct=180/Math.PI;function ut(e){return(e%=360)<0&&(e+=360),e}function ht([e,t,i,r]){let n,o;const s=pt((.2225045*(e=dt(e))+.7168786*(t=dt(t))+.0606169*(i=dt(i)))/1);e===t&&t===i?n=o=s:(n=pt((.4360747*e+.3850649*t+.1430804*i)/it),o=pt((.0139322*e+.0971045*t+.7141733*i)/rt));const a=116*s-16;return[a<0?0:a,500*(n-s),200*(s-o),r]}function dt(e){return e<=.04045?e/12.92:Math.pow((e+.055)/1.055,2.4)}function pt(e){return e>at?Math.pow(e,1/3):e/st+nt}function ft([e,t,i,r]){let n=(e+16)/116,o=isNaN(t)?n:n+t/500,s=isNaN(i)?n:n-i/200;return n=1*gt(n),o=it*gt(o),s=rt*gt(s),[mt(3.1338561*o-1.6168667*n-.4906146*s),mt(-.9787684*o+1.9161415*n+.033454*s),mt(.0719453*o-.2289914*n+1.4052427*s),r]}function mt(e){return(e=e<=.00304?12.92*e:1.055*Math.pow(e,1/2.4)-.055)<0?0:e>1?1:e}function gt(e){return e>ot?e*e*e:st*(e-nt)}const _t=Object.hasOwn||function(e,t){return Object.prototype.hasOwnProperty.call(e,t)};function At(e,t){return _t(e,t)?e[t]:void 0}function yt(e){return parseInt(e.padEnd(2,e),16)/255}function vt(e,t){return xt(t?e/100:e,0,1)}function xt(e,t,i){return Math.min(Math.max(t,e),i)}function bt(e){return!e.some(Number.isNaN)}const wt={aliceblue:[240,248,255],antiquewhite:[250,235,215],aqua:[0,255,255],aquamarine:[127,255,212],azure:[240,255,255],beige:[245,245,220],bisque:[255,228,196],black:[0,0,0],blanchedalmond:[255,235,205],blue:[0,0,255],blueviolet:[138,43,226],brown:[165,42,42],burlywood:[222,184,135],cadetblue:[95,158,160],chartreuse:[127,255,0],chocolate:[210,105,30],coral:[255,127,80],cornflowerblue:[100,149,237],cornsilk:[255,248,220],crimson:[220,20,60],cyan:[0,255,255],darkblue:[0,0,139],darkcyan:[0,139,139],darkgoldenrod:[184,134,11],darkgray:[169,169,169],darkgreen:[0,100,0],darkgrey:[169,169,169],darkkhaki:[189,183,107],darkmagenta:[139,0,139],darkolivegreen:[85,107,47],darkorange:[255,140,0],darkorchid:[153,50,204],darkred:[139,0,0],darksalmon:[233,150,122],darkseagreen:[143,188,143],darkslateblue:[72,61,139],darkslategray:[47,79,79],darkslategrey:[47,79,79],darkturquoise:[0,206,209],darkviolet:[148,0,211],deeppink:[255,20,147],deepskyblue:[0,191,255],dimgray:[105,105,105],dimgrey:[105,105,105],dodgerblue:[30,144,255],firebrick:[178,34,34],floralwhite:[255,250,240],forestgreen:[34,139,34],fuchsia:[255,0,255],gainsboro:[220,220,220],ghostwhite:[248,248,255],gold:[255,215,0],goldenrod:[218,165,32],gray:[128,128,128],green:[0,128,0],greenyellow:[173,255,47],grey:[128,128,128],honeydew:[240,255,240],hotpink:[255,105,180],indianred:[205,92,92],indigo:[75,0,130],ivory:[255,255,240],khaki:[240,230,140],lavender:[230,230,250],lavenderblush:[255,240,245],lawngreen:[124,252,0],lemonchiffon:[255,250,205],lightblue:[173,216,230],lightcoral:[240,128,128],lightcyan:[224,255,255],lightgoldenrodyellow:[250,250,210],lightgray:[211,211,211],lightgreen:[144,238,144],lightgrey:[211,211,211],lightpink:[255,182,193],lightsalmon:[255,160,122],lightseagreen:[32,178,170],lightskyblue:[135,206,250],lightslategray:[119,136,153],lightslategrey:[119,136,153],lightsteelblue:[176,196,222],lightyellow:[255,255,224],lime:[0,255,0],limegreen:[50,205,50],linen:[250,240,230],magenta:[255,0,255],maroon:[128,0,0],mediumaquamarine:[102,205,170],mediumblue:[0,0,205],mediumorchid:[186,85,211],mediumpurple:[147,112,219],mediumseagreen:[60,179,113],mediumslateblue:[123,104,238],mediumspringgreen:[0,250,154],mediumturquoise:[72,209,204],mediumvioletred:[199,21,133],midnightblue:[25,25,112],mintcream:[245,255,250],mistyrose:[255,228,225],moccasin:[255,228,181],navajowhite:[255,222,173],navy:[0,0,128],oldlace:[253,245,230],olive:[128,128,0],olivedrab:[107,142,35],orange:[255,165,0],orangered:[255,69,0],orchid:[218,112,214],palegoldenrod:[238,232,170],palegreen:[152,251,152],paleturquoise:[175,238,238],palevioletred:[219,112,147],papayawhip:[255,239,213],peachpuff:[255,218,185],peru:[205,133,63],pink:[255,192,203],plum:[221,160,221],powderblue:[176,224,230],purple:[128,0,128],rebeccapurple:[102,51,153],red:[255,0,0],rosybrown:[188,143,143],royalblue:[65,105,225],saddlebrown:[139,69,19],salmon:[250,128,114],sandybrown:[244,164,96],seagreen:[46,139,87],seashell:[255,245,238],sienna:[160,82,45],silver:[192,192,192],skyblue:[135,206,235],slateblue:[106,90,205],slategray:[112,128,144],slategrey:[112,128,144],snow:[255,250,250],springgreen:[0,255,127],steelblue:[70,130,180],tan:[210,180,140],teal:[0,128,128],thistle:[216,191,216],tomato:[255,99,71],turquoise:[64,224,208],violet:[238,130,238],wheat:[245,222,179],white:[255,255,255],whitesmoke:[245,245,245],yellow:[255,255,0],yellowgreen:[154,205,50]};function Tt(e,t,i){return e+i*(t-e)}function Et(e,t,i){return e.map((e,r)=>Tt(e,t[r],i))}class Ct{constructor(e,t,i,r=1,n=!0){this.r=e,this.g=t,this.b=i,this.a=r,n||(this.r*=r,this.g*=r,this.b*=r,r||this.overwriteGetter("rgb",[e,t,i,r]))}static parse(e){if(e instanceof Ct)return e;if("string"!=typeof e)return;const t=function(e){if("transparent"===(e=e.toLowerCase().trim()))return[0,0,0,0];const t=At(wt,e);if(t){const[e,i,r]=t;return[e/255,i/255,r/255,1]}if(e.startsWith("#")&&/^#(?:[0-9a-f]{3,4}|[0-9a-f]{6}|[0-9a-f]{8})$/.test(e)){const t=e.length<6?1:2;let i=1;return[yt(e.slice(i,i+=t)),yt(e.slice(i,i+=t)),yt(e.slice(i,i+=t)),yt(e.slice(i,i+t)||"ff")]}if(e.startsWith("rgb")){const t=e.match(/^rgba?\(\s*([\de.+-]+)(%)?(?:\s+|\s*(,)\s*)([\de.+-]+)(%)?(?:\s+|\s*(,)\s*)([\de.+-]+)(%)?(?:\s*([,\/])\s*([\de.+-]+)(%)?)?\s*\)$/);if(t){const[e,i,r,n,o,s,a,l,c,u,h,d]=t,p=[n||" ",a||" ",u].join("");if(" "===p||" /"===p||",,"===p||",,,"===p){const e=[r,s,c].join(""),t="%%%"===e?100:""===e?255:0;if(t){const e=[xt(+i/t,0,1),xt(+o/t,0,1),xt(+l/t,0,1),h?vt(+h,d):1];if(bt(e))return e}}return}}const i=e.match(/^hsla?\(\s*([\de.+-]+)(?:deg)?(?:\s+|\s*(,)\s*)([\de.+-]+)%(?:\s+|\s*(,)\s*)([\de.+-]+)%(?:\s*([,\/])\s*([\de.+-]+)(%)?)?\s*\)$/);if(i){const[e,t,r,n,o,s,a,l,c]=i,u=[r||" ",o||" ",a].join("");if(" "===u||" /"===u||",,"===u||",,,"===u){const e=[+t,xt(+n,0,100),xt(+s,0,100),l?vt(+l,c):1];if(bt(e))return function([e,t,i,r]){function n(r){const n=(r+e/30)%12,o=t*Math.min(i,1-i);return i-o*Math.max(-1,Math.min(n-3,9-n,1))}return e=ut(e),t/=100,i/=100,[n(0),n(8),n(4),r]}(e)}}}(e);return t?new Ct(...t,!1):void 0}get rgb(){const{r:e,g:t,b:i,a:r}=this,n=r||1/0;return this.overwriteGetter("rgb",[e/n,t/n,i/n,r])}get hcl(){return this.overwriteGetter("hcl",function(e){const[t,i,r,n]=ht(e),o=Math.sqrt(i*i+r*r);return[Math.round(1e4*o)?ut(Math.atan2(r,i)*ct):NaN,o,t,n]}(this.rgb))}get lab(){return this.overwriteGetter("lab",ht(this.rgb))}overwriteGetter(e,t){return Object.defineProperty(this,e,{value:t}),t}toString(){const[e,t,i,r]=this.rgb;return`rgba(${[e,t,i].map(e=>Math.round(255*e)).join(",")},${r})`}static interpolate(e,t,i,r="rgb"){switch(r){case"rgb":{const[r,n,o,s]=Et(e.rgb,t.rgb,i);return new Ct(r,n,o,s,!1)}case"hcl":{const[r,n,o,s]=e.hcl,[a,l,c,u]=t.hcl;let h,d;if(isNaN(r)||isNaN(a))isNaN(r)?isNaN(a)?h=NaN:(h=a,1!==o&&0!==o||(d=l)):(h=r,1!==c&&0!==c||(d=n));else{let e=a-r;a>r&&e>180?e-=360:a180&&(e+=360),h=r+i*e}const[p,f,m,g]=function([e,t,i,r]){return e=isNaN(e)?0:e*lt,ft([i,Math.cos(e)*t,Math.sin(e)*t,r])}([h,null!=d?d:Tt(n,l,i),Tt(o,c,i),Tt(s,u,i)]);return new Ct(p,f,m,g,!1)}case"lab":{const[r,n,o,s]=ft(Et(e.lab,t.lab,i));return new Ct(r,n,o,s,!1)}}}}Ct.black=new Ct(0,0,0,1),Ct.white=new Ct(1,1,1,1),Ct.transparent=new Ct(0,0,0,0),Ct.red=new Ct(1,0,0,1);class Bt{constructor(e,t,i){this.sensitivity=e?t?"variant":"case":t?"accent":"base",this.locale=i,this.collator=new Intl.Collator(this.locale?this.locale:[],{sensitivity:this.sensitivity,usage:"search"})}compare(e,t){return this.collator.compare(e,t)}resolvedLocale(){return new Intl.Collator(this.locale?this.locale:[]).resolvedOptions().locale}}const St=["bottom","center","top"];class It{constructor(e,t,i,r,n,o){this.text=e,this.image=t,this.scale=i,this.fontStack=r,this.textColor=n,this.verticalAlign=o}}class Mt{constructor(e){this.sections=e}static fromString(e){return new Mt([new It(e,null,null,null,null,null)])}isEmpty(){return 0===this.sections.length||!this.sections.some(e=>0!==e.text.length||e.image&&0!==e.image.name.length)}static factory(e){return e instanceof Mt?e:Mt.fromString(e)}toString(){return 0===this.sections.length?"":this.sections.map(e=>e.text).join("")}}class Pt{constructor(e){this.values=e.slice()}static parse(e){if(e instanceof Pt)return e;if("number"==typeof e)return new Pt([e,e,e,e]);if(Array.isArray(e)&&!(e.length<1||e.length>4)){for(const t of e)if("number"!=typeof t)return;switch(e.length){case 1:e=[e[0],e[0],e[0],e[0]];break;case 2:e=[e[0],e[1],e[0],e[1]];break;case 3:e=[e[0],e[1],e[2],e[1]]}return new Pt(e)}}toString(){return JSON.stringify(this.values)}static interpolate(e,t,i){return new Pt(Et(e.values,t.values,i))}}class Rt{constructor(e){this.values=e.slice()}static parse(e){if(e instanceof Rt)return e;if("number"==typeof e)return new Rt([e]);if(Array.isArray(e)){for(const t of e)if("number"!=typeof t)return;return new Rt(e)}}toString(){return JSON.stringify(this.values)}static interpolate(e,t,i){return new Rt(Et(e.values,t.values,i))}}class Lt{constructor(e){this.values=e.slice()}static parse(e){if(e instanceof Lt)return e;if("string"==typeof e){const t=Ct.parse(e);if(!t)return;return new Lt([t])}if(!Array.isArray(e))return;const t=[];for(const i of e){if("string"!=typeof i)return;const e=Ct.parse(i);if(!e)return;t.push(e)}return new Lt(t)}toString(){return JSON.stringify(this.values)}static interpolate(e,t,i,r="rgb"){const n=[];if(e.values.length!=t.values.length)throw new Error(`colorArray: Arrays have mismatched length (${e.values.length} vs. ${t.values.length}), cannot interpolate.`);for(let o=0;o=0&&e<=255&&"number"==typeof t&&t>=0&&t<=255&&"number"==typeof i&&i>=0&&i<=255?void 0===r||"number"==typeof r&&r>=0&&r<=1?null:`Invalid rgba value [${[e,t,i,r].join(", ")}]: 'a' must be between 0 and 1.`:`Invalid rgba value [${("number"==typeof r?[e,t,i,r]:[e,t,i]).join(", ")}]: 'r', 'g', and 'b' must be between 0 and 255.`}function Nt(e){if(null===e||"string"==typeof e||"boolean"==typeof e||"number"==typeof e||e instanceof zt||e instanceof Ct||e instanceof Bt||e instanceof Mt||e instanceof Pt||e instanceof Rt||e instanceof Lt||e instanceof Dt||e instanceof Ot)return!0;if(Array.isArray(e)){for(const t of e)if(!Nt(t))return!1;return!0}if("object"==typeof e){for(const t in e)if(!Nt(e[t]))return!1;return!0}return!1}function Vt(e){if(null===e)return Fe;if("string"==typeof e)return De;if("boolean"==typeof e)return Oe;if("number"==typeof e)return ke;if(e instanceof Ct)return ze;if(e instanceof zt)return Ue;if(e instanceof Bt)return je;if(e instanceof Mt)return Ge;if(e instanceof Pt)return He;if(e instanceof Rt)return $e;if(e instanceof Lt)return Qe;if(e instanceof Dt)return We;if(e instanceof Ot)return Ze;if(Array.isArray(e)){const t=e.length;let i;for(const t of e){const e=Vt(t);if(i){if(i===e)continue;i=Ve;break}i=e}return qe(i||Ve,t)}return Ne}function jt(e){const t=typeof e;return null===e?"":"string"===t||"number"===t||"boolean"===t?String(e):e instanceof Ct||e instanceof zt||e instanceof Mt||e instanceof Pt||e instanceof Rt||e instanceof Lt||e instanceof Dt||e instanceof Ot?e.toString():JSON.stringify(e)}class Gt{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(!Nt(e[1]))return t.error("invalid value");const i=e[1];let r=Vt(i);const n=t.expectedType;return"array"!==r.kind||0!==r.N||!n||"array"!==n.kind||"number"==typeof n.N&&0!==n.N||(r=n),new Gt(r,i)}evaluate(){return this.value}eachChild(){}outputDefined(){return!0}}const Ht={string:De,number:ke,boolean:Oe,object:Ne};class Qt{constructor(e,t){this.type=e,this.args=t}static parse(e,t){if(e.length<2)return t.error("Expected at least one argument.");let i,r=1;const n=e[0];if("array"===n){let n,o;if(e.length>2){const i=e[1];if("string"!=typeof i||!(i in Ht)||"object"===i)return t.error('The item type argument of "array" must be one of string, number, boolean',1);n=Ht[i],r++}else n=Ve;if(e.length>3){if(null!==e[2]&&("number"!=typeof e[2]||e[2]<0||e[2]!==Math.floor(e[2])))return t.error('The length argument to "array" must be a positive integer literal',2);o=e[2],r++}i=qe(n,o)}else{if(!Ht[n])throw new Error(`Types doesn't contain name = ${n}`);i=Ht[n]}const o=[];for(;re.outputDefined())}}const $t={"to-boolean":Oe,"to-color":ze,"to-number":ke,"to-string":De};class Zt{constructor(e,t){this.type=e,this.args=t}static parse(e,t){if(e.length<2)return t.error("Expected at least one argument.");const i=e[0];if(!$t[i])throw new Error(`Can't parse ${i} as it is not part of the known types`);if(("to-boolean"===i||"to-string"===i)&&2!==e.length)return t.error("Expected one argument.");const r=$t[i],n=[];for(let i=1;i4?`Invalid rgba value ${JSON.stringify(t)}: expected an array containing either three or four numeric values.`:Ut(t[0],t[1],t[2],t[3]),!i))return new Ct(t[0]/255,t[1]/255,t[2]/255,t[3])}throw new Ft(i||`Could not parse color from value '${"string"==typeof t?t:JSON.stringify(t)}'`)}case"padding":{let t;for(const i of this.args){t=i.evaluate(e);const r=Pt.parse(t);if(r)return r}throw new Ft(`Could not parse padding from value '${"string"==typeof t?t:JSON.stringify(t)}'`)}case"numberArray":{let t;for(const i of this.args){t=i.evaluate(e);const r=Rt.parse(t);if(r)return r}throw new Ft(`Could not parse numberArray from value '${"string"==typeof t?t:JSON.stringify(t)}'`)}case"colorArray":{let t;for(const i of this.args){t=i.evaluate(e);const r=Lt.parse(t);if(r)return r}throw new Ft(`Could not parse colorArray from value '${"string"==typeof t?t:JSON.stringify(t)}'`)}case"variableAnchorOffsetCollection":{let t;for(const i of this.args){t=i.evaluate(e);const r=Dt.parse(t);if(r)return r}throw new Ft(`Could not parse variableAnchorOffsetCollection from value '${"string"==typeof t?t:JSON.stringify(t)}'`)}case"number":{let t=null;for(const i of this.args){if(t=i.evaluate(e),null===t)return 0;const r=Number(t);if(!isNaN(r))return r}throw new Ft(`Could not convert ${JSON.stringify(t)} to number.`)}case"formatted":return Mt.fromString(jt(this.args[0].evaluate(e)));case"resolvedImage":return Ot.fromString(jt(this.args[0].evaluate(e)));case"projectionDefinition":return this.args[0].evaluate(e);default:return jt(this.args[0].evaluate(e))}}eachChild(e){this.args.forEach(e)}outputDefined(){return this.args.every(e=>e.outputDefined())}}const Wt=["Unknown","Point","LineString","Polygon"];class qt{constructor(){this.globals=null,this.feature=null,this.featureState=null,this.formattedSection=null,this._parseColorCache=new Map,this.availableImages=null,this.canonical=null}id(){return this.feature&&"id"in this.feature?this.feature.id:null}geometryType(){return this.feature?"number"==typeof this.feature.type?Wt[this.feature.type]:this.feature.type:null}geometry(){return this.feature&&"geometry"in this.feature?this.feature.geometry:null}canonicalID(){return this.canonical}properties(){return this.feature&&this.feature.properties||{}}parseColor(e){let t=this._parseColorCache.get(e);return t||(t=Ct.parse(e),this._parseColorCache.set(e,t)),t}}class Kt{constructor(e,t,i=[],r,n=new Le,o=[]){this.registry=e,this.path=i,this.key=i.map(e=>`[${e}]`).join(""),this.scope=n,this.errors=o,this.expectedType=r,this._isConstant=t}parse(e,t,i,r,n={}){return t?this.concat(t,i,r)._parse(e,n):this._parse(e,n)}_parse(e,t){function i(e,t,i){return"assert"===i?new Qt(t,[e]):"coerce"===i?new Zt(t,[e]):e}if(null!==e&&"string"!=typeof e&&"boolean"!=typeof e&&"number"!=typeof e||(e=["literal",e]),Array.isArray(e)){if(0===e.length)return this.error('Expected an array with at least one element. If you wanted a literal array, use ["literal", []].');const r=e[0];if("string"!=typeof r)return this.error(`Expression name must be a string, but found ${typeof r} instead. If you wanted a literal array, use ["literal", [...]].`,0),null;const n=this.registry[r];if(n){let r=n.parse(e,this);if(!r)return null;if(this.expectedType){const e=this.expectedType,n=r.type;if("string"!==e.kind&&"number"!==e.kind&&"boolean"!==e.kind&&"object"!==e.kind&&"array"!==e.kind||"value"!==n.kind){if("projectionDefinition"===e.kind&&["string","array"].includes(n.kind)||["color","formatted","resolvedImage"].includes(e.kind)&&["value","string"].includes(n.kind)||["padding","numberArray"].includes(e.kind)&&["value","number","array"].includes(n.kind)||"colorArray"===e.kind&&["value","string","array"].includes(n.kind)||"variableAnchorOffsetCollection"===e.kind&&["value","array"].includes(n.kind))r=i(r,e,t.typeAnnotation||"coerce");else if(this.checkSubtype(e,n))return null}else r=i(r,e,t.typeAnnotation||"assert")}if(!(r instanceof Gt)&&"resolvedImage"!==r.type.kind&&this._isConstant(r)){const t=new qt;try{r=new Gt(r.type,r.evaluate(t))}catch(e){return this.error(e.message),null}}return r}return this.error(`Unknown expression "${r}". If you wanted a literal array, use ["literal", [...]].`,0)}return this.error(void 0===e?"'undefined' value invalid. Use null instead.":"object"==typeof e?'Bare objects invalid. Use ["literal", {...}] instead.':`Expected an array, but found ${typeof e} instead.`)}concat(e,t,i){const r="number"==typeof e?this.path.concat(e):this.path,n=i?this.scope.concat(i):this.scope;return new Kt(this.registry,this._isConstant,r,t||null,n,this.errors)}error(e,...t){const i=`${this.key}${t.map(e=>`[${e}]`).join("")}`;this.errors.push(new Re(i,e))}checkSubtype(e,t){const i=Je(e,t);return i&&this.error(i),i}}class Xt{constructor(e,t){this.type=t.type,this.bindings=[].concat(e),this.result=t}evaluate(e){return this.result.evaluate(e)}eachChild(e){for(const t of this.bindings)e(t[1]);e(this.result)}static parse(e,t){if(e.length<4)return t.error(`Expected at least 3 arguments, but found ${e.length-1} instead.`);const i=[];for(let r=1;r=i.length)throw new Ft(`Array index out of bounds: ${t} > ${i.length-1}.`);if(t!==Math.floor(t))throw new Ft(`Array index must be an integer, but found ${t} instead.`);return i[t]}eachChild(e){e(this.index),e(this.input)}outputDefined(){return!1}}class ei{constructor(e,t){this.type=Oe,this.needle=e,this.haystack=t}static parse(e,t){if(3!==e.length)return t.error(`Expected 2 arguments, but found ${e.length-1} instead.`);const i=t.parse(e[1],1,Ve),r=t.parse(e[2],2,Ve);return i&&r?Ye(i.type,[Oe,De,ke,Fe,Ve])?new ei(i,r):t.error(`Expected first argument to be of type boolean, string, number or null, but found ${Ke(i.type)} instead`):null}evaluate(e){const t=this.needle.evaluate(e),i=this.haystack.evaluate(e);if(!i)return!1;if(!et(t,["boolean","string","number","null"]))throw new Ft(`Expected first argument to be of type boolean, string, number or null, but found ${Ke(Vt(t))} instead.`);if(!et(i,["string","array"]))throw new Ft(`Expected second argument to be of type array or string, but found ${Ke(Vt(i))} instead.`);return i.indexOf(t)>=0}eachChild(e){e(this.needle),e(this.haystack)}outputDefined(){return!0}}class ti{constructor(e,t,i){this.type=ke,this.needle=e,this.haystack=t,this.fromIndex=i}static parse(e,t){if(e.length<=2||e.length>=5)return t.error(`Expected 2 or 3 arguments, but found ${e.length-1} instead.`);const i=t.parse(e[1],1,Ve),r=t.parse(e[2],2,Ve);if(!i||!r)return null;if(!Ye(i.type,[Oe,De,ke,Fe,Ve]))return t.error(`Expected first argument to be of type boolean, string, number or null, but found ${Ke(i.type)} instead`);if(4===e.length){const n=t.parse(e[3],3,ke);return n?new ti(i,r,n):null}return new ti(i,r)}evaluate(e){const t=this.needle.evaluate(e),i=this.haystack.evaluate(e);if(!et(t,["boolean","string","number","null"]))throw new Ft(`Expected first argument to be of type boolean, string, number or null, but found ${Ke(Vt(t))} instead.`);let r;if(this.fromIndex&&(r=this.fromIndex.evaluate(e)),et(i,["string"])){const e=i.indexOf(t,r);return-1===e?-1:[...i.slice(0,e)].length}if(et(i,["array"]))return i.indexOf(t,r);throw new Ft(`Expected second argument to be of type array or string, but found ${Ke(Vt(i))} instead.`)}eachChild(e){e(this.needle),e(this.haystack),this.fromIndex&&e(this.fromIndex)}outputDefined(){return!1}}class ii{constructor(e,t,i,r,n,o){this.inputType=e,this.type=t,this.input=i,this.cases=r,this.outputs=n,this.otherwise=o}static parse(e,t){if(e.length<5)return t.error(`Expected at least 4 arguments, but found only ${e.length-1}.`);if(e.length%2!=1)return t.error("Expected an even number of arguments.");let i,r;t.expectedType&&"value"!==t.expectedType.kind&&(r=t.expectedType);const n={},o=[];for(let s=2;sNumber.MAX_SAFE_INTEGER)return c.error(`Branch labels must be integers no larger than ${Number.MAX_SAFE_INTEGER}.`);if("number"==typeof e&&Math.floor(e)!==e)return c.error("Numeric branch labels must be integer values.");if(i){if(c.checkSubtype(i,Vt(e)))return null}else i=Vt(e);if(void 0!==n[String(e)])return c.error("Branch labels must be unique.");n[String(e)]=o.length}const u=t.parse(l,s,r);if(!u)return null;r=r||u.type,o.push(u)}const s=t.parse(e[1],1,Ve);if(!s)return null;const a=t.parse(e[e.length-1],e.length-1,r);return a?"value"!==s.type.kind&&t.concat(1).checkSubtype(i,s.type)?null:new ii(i,r,s,n,o,a):null}evaluate(e){const t=this.input.evaluate(e);return(Vt(t)===this.inputType&&this.outputs[this.cases[t]]||this.otherwise).evaluate(e)}eachChild(e){e(this.input),this.outputs.forEach(e),e(this.otherwise)}outputDefined(){return this.outputs.every(e=>e.outputDefined())&&this.otherwise.outputDefined()}}class ri{constructor(e,t,i){this.type=e,this.branches=t,this.otherwise=i}static parse(e,t){if(e.length<4)return t.error(`Expected at least 3 arguments, but found only ${e.length-1}.`);if(e.length%2!=0)return t.error("Expected an odd number of arguments.");let i;t.expectedType&&"value"!==t.expectedType.kind&&(i=t.expectedType);const r=[];for(let n=1;nt.outputDefined())&&this.otherwise.outputDefined()}}class ni{constructor(e,t,i,r){this.type=e,this.input=t,this.beginIndex=i,this.endIndex=r}static parse(e,t){if(e.length<=2||e.length>=5)return t.error(`Expected 2 or 3 arguments, but found ${e.length-1} instead.`);const i=t.parse(e[1],1,Ve),r=t.parse(e[2],2,ke);if(!i||!r)return null;if(!Ye(i.type,[qe(Ve),De,Ve]))return t.error(`Expected first argument to be of type array or string, but found ${Ke(i.type)} instead`);if(4===e.length){const n=t.parse(e[3],3,ke);return n?new ni(i.type,i,r,n):null}return new ni(i.type,i,r)}evaluate(e){const t=this.input.evaluate(e),i=this.beginIndex.evaluate(e);let r;if(this.endIndex&&(r=this.endIndex.evaluate(e)),et(t,["string"]))return[...t].slice(i,r).join("");if(et(t,["array"]))return t.slice(i,r);throw new Ft(`Expected first argument to be of type array or string, but found ${Ke(Vt(t))} instead.`)}eachChild(e){e(this.input),e(this.beginIndex),this.endIndex&&e(this.endIndex)}outputDefined(){return!1}}function oi(e,t){const i=e.length-1;let r,n,o=0,s=i,a=0;for(;o<=s;)if(a=Math.floor((o+s)/2),r=e[a],n=e[a+1],r<=t){if(a===i||tt))throw new Ft("Input is not a number.");s=a-1}return 0}class si{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,ke);if(!i)return null;const r=[];let n=null;t.expectedType&&"value"!==t.expectedType.kind&&(n=t.expectedType);for(let i=1;i=o)return t.error('Input/output pairs for "step" expressions must be arranged with input values in strictly ascending order.',a);const c=t.parse(s,l,n);if(!c)return null;n=n||c.type,r.push([o,c])}return new si(n,i,r)}evaluate(e){const t=this.labels,i=this.outputs;if(1===t.length)return i[0].evaluate(e);const r=this.input.evaluate(e);if(r<=t[0])return i[0].evaluate(e);const n=t.length;return r>=t[n-1]?i[n-1].evaluate(e):i[oi(t,r)].evaluate(e)}eachChild(e){e(this.input);for(const t of this.outputs)e(t)}outputDefined(){return this.outputs.every(e=>e.outputDefined())}}function ai(e){return e&&e.__esModule&&Object.prototype.hasOwnProperty.call(e,"default")?e.default:e}var li,ci,ui=function(){if(ci)return li;function e(e,t,i,r){this.cx=3*e,this.bx=3*(i-e)-this.cx,this.ax=1-this.cx-this.bx,this.cy=3*t,this.by=3*(r-t)-this.cy,this.ay=1-this.cy-this.by,this.p1x=e,this.p1y=t,this.p2x=i,this.p2y=r}return ci=1,li=e,e.prototype={sampleCurveX:function(e){return((this.ax*e+this.bx)*e+this.cx)*e},sampleCurveY:function(e){return((this.ay*e+this.by)*e+this.cy)*e},sampleCurveDerivativeX:function(e){return(3*this.ax*e+2*this.bx)*e+this.cx},solveCurveX:function(e,t){if(void 0===t&&(t=1e-6),e<0)return 0;if(e>1)return 1;for(var i=e,r=0;r<8;r++){var n=this.sampleCurveX(i)-e;if(Math.abs(n)n?s=i:a=i,i=.5*(a-s)+s;return i},solve:function(e,t){return this.sampleCurveY(this.solveCurveX(e,t))}},li}(),hi=ai(ui);class di{constructor(e,t,i,r,n){this.type=e,this.operator=t,this.interpolation=i,this.input=r,this.labels=[],this.outputs=[];for(const[e,t]of n)this.labels.push(e),this.outputs.push(t)}static interpolationFactor(e,t,i,r){let n=0;if("exponential"===e.name)n=pi(t,e.base,i,r);else if("linear"===e.name)n=pi(t,1,i,r);else if("cubic-bezier"===e.name){const o=e.controlPoints;n=new hi(o[0],o[1],o[2],o[3]).solve(pi(t,1,i,r))}return n}static parse(e,t){let[i,r,n,...o]=e;if(!Array.isArray(r)||0===r.length)return t.error("Expected an interpolation type expression.",1);if("linear"===r[0])r={name:"linear"};else if("exponential"===r[0]){const e=r[1];if("number"!=typeof e)return t.error("Exponential interpolation requires a numeric base.",1,1);r={name:"exponential",base:e}}else{if("cubic-bezier"!==r[0])return t.error(`Unknown interpolation type ${String(r[0])}`,1,0);{const e=r.slice(1);if(4!==e.length||e.some(e=>"number"!=typeof e||e<0||e>1))return t.error("Cubic bezier interpolation requires four numeric arguments with values between 0 and 1.",1);r={name:"cubic-bezier",controlPoints:e}}}if(e.length-1<4)return t.error(`Expected at least 4 arguments, but found only ${e.length-1}.`);if((e.length-1)%2!=0)return t.error("Expected an even number of arguments.");if(n=t.parse(n,2,ke),!n)return null;const s=[];let a=null;"interpolate-hcl"!==i&&"interpolate-lab"!==i||t.expectedType==Qe?t.expectedType&&"value"!==t.expectedType.kind&&(a=t.expectedType):a=ze;for(let e=0;e=i)return t.error('Input/output pairs for "interpolate" expressions must be arranged with input values in strictly ascending order.',n);const c=t.parse(r,l,a);if(!c)return null;a=a||c.type,s.push([i,c])}return tt(a,ke)||tt(a,Ue)||tt(a,ze)||tt(a,He)||tt(a,$e)||tt(a,Qe)||tt(a,We)||tt(a,qe(ke))?new di(a,i,r,n,s):t.error(`Type ${Ke(a)} is not interpolatable.`)}evaluate(e){const t=this.labels,i=this.outputs;if(1===t.length)return i[0].evaluate(e);const r=this.input.evaluate(e);if(r<=t[0])return i[0].evaluate(e);const n=t.length;if(r>=t[n-1])return i[n-1].evaluate(e);const o=oi(t,r),s=di.interpolationFactor(this.interpolation,r,t[o],t[o+1]),a=i[o].evaluate(e),l=i[o+1].evaluate(e);switch(this.operator){case"interpolate":switch(this.type.kind){case"number":return Tt(a,l,s);case"color":return Ct.interpolate(a,l,s);case"padding":return Pt.interpolate(a,l,s);case"colorArray":return Lt.interpolate(a,l,s);case"numberArray":return Rt.interpolate(a,l,s);case"variableAnchorOffsetCollection":return Dt.interpolate(a,l,s);case"array":return Et(a,l,s);case"projectionDefinition":return zt.interpolate(a,l,s)}case"interpolate-hcl":switch(this.type.kind){case"color":return Ct.interpolate(a,l,s,"hcl");case"colorArray":return Lt.interpolate(a,l,s,"hcl")}case"interpolate-lab":switch(this.type.kind){case"color":return Ct.interpolate(a,l,s,"lab");case"colorArray":return Lt.interpolate(a,l,s,"lab")}}}eachChild(e){e(this.input);for(const t of this.outputs)e(t)}outputDefined(){return this.outputs.every(e=>e.outputDefined())}}function pi(e,t,i,r){const n=r-i,o=e-i;return 0===n?0:1===t?o/n:(Math.pow(t,o)-1)/(Math.pow(t,n)-1)}const fi={color:Ct.interpolate,number:Tt,padding:Pt.interpolate,numberArray:Rt.interpolate,colorArray:Lt.interpolate,variableAnchorOffsetCollection:Dt.interpolate,array:Et};class mi{constructor(e,t){this.type=e,this.args=t}static parse(e,t){if(e.length<2)return t.error("Expected at least one argument.");let i=null;const r=t.expectedType;r&&"value"!==r.kind&&(i=r);const n=[];for(const r of e.slice(1)){const e=t.parse(r,1+n.length,i,void 0,{typeAnnotation:"omit"});if(!e)return null;i=i||e.type,n.push(e)}if(!i)throw new Error("No output type");const o=r&&n.some(e=>Je(r,e.type));return new mi(o?Ve:i,n)}evaluate(e){let t,i=null,r=0;for(const n of this.args)if(r++,i=n.evaluate(e),i&&i instanceof Ot&&!i.available&&(t||(t=i.name),i=null,r===this.args.length&&(i=t)),null!==i)break;return i}eachChild(e){this.args.forEach(e)}outputDefined(){return this.args.every(e=>e.outputDefined())}}function gi(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 _i(e,t,i,r){return 0===r.compare(t,i)}function Ai(e,t,i){const r="=="!==e&&"!="!==e;return class n{constructor(e,t,i){this.type=Oe,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,Ve);if(!o)return null;if(!gi(i,o.type))return t.concat(1).error(`"${i}" comparisons are not supported for type '${Ke(o.type)}'.`);let s=t.parse(e[2],2,Ve);if(!s)return null;if(!gi(i,s.type))return t.concat(2).error(`"${i}" comparisons are not supported for type '${Ke(s.type)}'.`);if(o.type.kind!==s.type.kind&&"value"!==o.type.kind&&"value"!==s.type.kind)return t.error(`Cannot compare types '${Ke(o.type)}' and '${Ke(s.type)}'.`);r&&("value"===o.type.kind&&"value"!==s.type.kind?o=new Qt(s.type,[o]):"value"!==o.type.kind&&"value"===s.type.kind&&(s=new Qt(o.type,[s])));let a=null;if(4===e.length){if("string"!==o.type.kind&&"string"!==s.type.kind&&"value"!==o.type.kind&&"value"!==s.type.kind)return t.error("Cannot use collator to compare non-string types.");if(a=t.parse(e[3],3,je),!a)return null}return new n(o,s,a)}evaluate(n){const o=this.lhs.evaluate(n),s=this.rhs.evaluate(n);if(r&&this.hasUntypedArgument){const t=Vt(o),i=Vt(s);if(t.kind!==i.kind||"string"!==t.kind&&"number"!==t.kind)throw new Ft(`Expected arguments for "${e}" to be (string, string) or (number, number), but found (${t.kind}, ${i.kind}) instead.`)}if(this.collator&&!r&&this.hasUntypedArgument){const e=Vt(o),i=Vt(s);if("string"!==e.kind||"string"!==i.kind)return t(n,o,s)}return this.collator?i(n,o,s,this.collator.evaluate(n)):t(n,o,s)}eachChild(e){e(this.lhs),e(this.rhs),this.collator&&e(this.collator)}outputDefined(){return!0}}}const yi=Ai("==",function(e,t,i){return t===i},_i),vi=Ai("!=",function(e,t,i){return t!==i},function(e,t,i,r){return!_i(0,t,i,r)}),xi=Ai("<",function(e,t,i){return t",function(e,t,i){return t>i},function(e,t,i,r){return r.compare(t,i)>0}),wi=Ai("<=",function(e,t,i){return t<=i},function(e,t,i,r){return r.compare(t,i)<=0}),Ti=Ai(">=",function(e,t,i){return t>=i},function(e,t,i,r){return r.compare(t,i)>=0});class Ei{constructor(e,t,i){this.type=je,this.locale=i,this.caseSensitive=e,this.diacriticSensitive=t}static parse(e,t){if(2!==e.length)return t.error("Expected one argument.");const i=e[1];if("object"!=typeof i||Array.isArray(i))return t.error("Collator options argument must be an object.");const r=t.parse(void 0!==i["case-sensitive"]&&i["case-sensitive"],1,Oe);if(!r)return null;const n=t.parse(void 0!==i["diacritic-sensitive"]&&i["diacritic-sensitive"],1,Oe);if(!n)return null;let o=null;return i.locale&&(o=t.parse(i.locale,1,De),!o)?null:new Ei(r,n,o)}evaluate(e){return new Bt(this.caseSensitive.evaluate(e),this.diacriticSensitive.evaluate(e),this.locale?this.locale.evaluate(e):null)}eachChild(e){e(this.caseSensitive),e(this.diacriticSensitive),this.locale&&e(this.locale)}outputDefined(){return!1}}class Ci{constructor(e,t,i,r,n){this.type=De,this.number=e,this.locale=t,this.currency=i,this.minFractionDigits=r,this.maxFractionDigits=n}static parse(e,t){if(3!==e.length)return t.error("Expected two arguments.");const i=t.parse(e[1],1,ke);if(!i)return null;const r=e[2];if("object"!=typeof r||Array.isArray(r))return t.error("NumberFormat options argument must be an object.");let n=null;if(r.locale&&(n=t.parse(r.locale,1,De),!n))return null;let o=null;if(r.currency&&(o=t.parse(r.currency,1,De),!o))return null;let s=null;if(r["min-fraction-digits"]&&(s=t.parse(r["min-fraction-digits"],1,ke),!s))return null;let a=null;return r["max-fraction-digits"]&&(a=t.parse(r["max-fraction-digits"],1,ke),!a)?null:new Ci(i,n,o,s,a)}evaluate(e){return new Intl.NumberFormat(this.locale?this.locale.evaluate(e):[],{style:this.currency?"currency":"decimal",currency:this.currency?this.currency.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.minFractionDigits&&e(this.minFractionDigits),this.maxFractionDigits&&e(this.maxFractionDigits)}outputDefined(){return!1}}class Bi{constructor(e){this.type=Ge,this.sections=e}static parse(e,t){if(e.length<2)return t.error("Expected at least one argument.");const i=e[1];if(!Array.isArray(i)&&"object"==typeof i)return t.error("First argument must be an image or text section.");const r=[];let n=!1;for(let i=1;i<=e.length-1;++i){const o=e[i];if(n&&"object"==typeof o&&!Array.isArray(o)){n=!1;let e=null;if(o["font-scale"]&&(e=t.parse(o["font-scale"],1,ke),!e))return null;let i=null;if(o["text-font"]&&(i=t.parse(o["text-font"],1,qe(De)),!i))return null;let s=null;if(o["text-color"]&&(s=t.parse(o["text-color"],1,ze),!s))return null;let a=null;if(o["vertical-align"]){if("string"==typeof o["vertical-align"]&&!St.includes(o["vertical-align"]))return t.error(`'vertical-align' must be one of: 'bottom', 'center', 'top' but found '${o["vertical-align"]}' instead.`);if(a=t.parse(o["vertical-align"],1,De),!a)return null}const l=r[r.length-1];l.scale=e,l.font=i,l.textColor=s,l.verticalAlign=a}else{const o=t.parse(e[i],1,Ve);if(!o)return null;const s=o.type.kind;if("string"!==s&&"value"!==s&&"null"!==s&&"resolvedImage"!==s)return t.error("Formatted text type must be 'string', 'value', 'image' or 'null'.");n=!0,r.push({content:o,scale:null,font:null,textColor:null,verticalAlign:null})}}return new Bi(r)}evaluate(e){return new Mt(this.sections.map(t=>{const i=t.content.evaluate(e);return Vt(i)===Ze?new It("",i,null,null,null,t.verticalAlign?t.verticalAlign.evaluate(e):null):new It(jt(i),null,t.scale?t.scale.evaluate(e):null,t.font?t.font.evaluate(e).join(","):null,t.textColor?t.textColor.evaluate(e):null,t.verticalAlign?t.verticalAlign.evaluate(e):null)}))}eachChild(e){for(const t of this.sections)e(t.content),t.scale&&e(t.scale),t.font&&e(t.font),t.textColor&&e(t.textColor),t.verticalAlign&&e(t.verticalAlign)}outputDefined(){return!1}}class Si{constructor(e){this.type=Ze,this.input=e}static parse(e,t){if(2!==e.length)return t.error("Expected two arguments.");const i=t.parse(e[1],1,De);return i?new Si(i):t.error("No image name provided.")}evaluate(e){const t=this.input.evaluate(e),i=Ot.fromString(t);return i&&e.availableImages&&(i.available=e.availableImages.indexOf(t)>-1),i}eachChild(e){e(this.input)}outputDefined(){return!1}}class Ii{constructor(e){this.type=ke,this.input=e}static parse(e,t){if(2!==e.length)return t.error(`Expected 1 argument, but found ${e.length-1} instead.`);const i=t.parse(e[1],1);return i?"array"!==i.type.kind&&"string"!==i.type.kind&&"value"!==i.type.kind?t.error(`Expected argument of type string or array, but found ${Ke(i.type)} instead.`):new Ii(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 Ft(`Expected value to be of type string or array, but found ${Ke(Vt(t))} instead.`)}eachChild(e){e(this.input)}outputDefined(){return!1}}const Mi=8192;function Pi(e,t){const i=(180+e[0])/360,r=(180-180/Math.PI*Math.log(Math.tan(Math.PI/4+e[1]*Math.PI/360)))/360,n=Math.pow(2,t.z);return[Math.round(i*n*Mi),Math.round(r*n*Mi)]}function Ri(e,t){const i=Math.pow(2,t.z);return[(n=(e[0]/Mi+t.x)/i,360*n-180),(r=(e[1]/Mi+t.y)/i,360/Math.PI*Math.atan(Math.exp((180-360*r)*Math.PI/180))-90)];var r,n}function Li(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 Fi(e,t){return!(e[0]<=t[0]||e[2]>=t[2]||e[1]<=t[1]||e[3]>=t[3])}function ki(e,t,i){const r=e[0]-t[0],n=e[1]-t[1],o=e[0]-i[0],s=e[1]-i[1];return r*s-o*n==0&&r*o<=0&&n*s<=0}function Di(e,t,i,r){return 0!=(n=[r[0]-i[0],r[1]-i[1]])[0]*(o=[t[0]-e[0],t[1]-e[1]])[1]-n[1]*o[0]&&!(!ji(e,t,i,r)||!ji(i,r,e,t));var n,o}function Oi(e,t,i){for(const r of i)for(let i=0;i(n=e)[1]!=(s=a[t+1])[1]>n[1]&&n[0]<(s[0]-o[0])*(n[1]-o[1])/(s[1]-o[1])+o[0]&&(r=!r)}var n,o,s;return r}function Ui(e,t){for(const i of t)if(zi(e,i))return!0;return!1}function Ni(e,t){for(const i of e)if(!zi(i,t))return!1;for(let i=0;i0&&a<0||s<0&&a>0}function Gi(e,t,i){const r=[];for(let n=0;ni[2]){const t=.5*r;let n=e[0]-i[0]>t?-r:i[0]-e[0]>t?r:0;0===n&&(n=e[0]-i[2]>t?-r:i[2]-e[0]>t?r:0),e[0]+=n}Li(t,e)}function $i(e,t,i,r){const n=Math.pow(2,r.z)*Mi,o=[r.x*Mi,r.y*Mi],s=[];for(const r of e)for(const e of r){const r=[e.x+o[0],e.y+o[1]];Qi(r,t,i,n),s.push(r)}return s}function Zi(e,t,i,r){const n=Math.pow(2,r.z)*Mi,o=[r.x*Mi,r.y*Mi],s=[];for(const i of e){const e=[];for(const r of i){const i=[r.x+o[0],r.y+o[1]];Li(t,i),e.push(i)}s.push(e)}if(t[2]-t[0]<=n/2){(a=t)[0]=a[1]=1/0,a[2]=a[3]=-1/0;for(const e of s)for(const r of e)Qi(r,t,i,n)}var a;return s}class Wi{constructor(e,t){this.type=Oe,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(Nt(e[1])){const t=e[1];if("FeatureCollection"===t.type){const e=[];for(const i of t.features){const{type:t,coordinates:r}=i.geometry;"Polygon"===t&&e.push(r),"MultiPolygon"===t&&e.push(...r)}if(e.length)return new Wi(t,{type:"MultiPolygon",coordinates:e})}else if("Feature"===t.type){const e=t.geometry.type;if("Polygon"===e||"MultiPolygon"===e)return new Wi(t,t.geometry)}else if("Polygon"===t.type||"MultiPolygon"===t.type)return new Wi(t,t)}return t.error("'within' expression requires valid geojson object that contains polygon geometry type.")}evaluate(e){if(null!=e.geometry()&&null!=e.canonicalID()){if("Point"===e.geometryType())return function(e,t){const i=[1/0,1/0,-1/0,-1/0],r=[1/0,1/0,-1/0,-1/0],n=e.canonicalID();if("Polygon"===t.type){const o=Gi(t.coordinates,r,n),s=$i(e.geometry(),i,r,n);if(!Fi(i,r))return!1;for(const e of s)if(!zi(e,o))return!1}if("MultiPolygon"===t.type){const o=Hi(t.coordinates,r,n),s=$i(e.geometry(),i,r,n);if(!Fi(i,r))return!1;for(const e of s)if(!Ui(e,o))return!1}return!0}(e,this.geometries);if("LineString"===e.geometryType())return function(e,t){const i=[1/0,1/0,-1/0,-1/0],r=[1/0,1/0,-1/0,-1/0],n=e.canonicalID();if("Polygon"===t.type){const o=Gi(t.coordinates,r,n),s=Zi(e.geometry(),i,r,n);if(!Fi(i,r))return!1;for(const e of s)if(!Ni(e,o))return!1}if("MultiPolygon"===t.type){const o=Hi(t.coordinates,r,n),s=Zi(e.geometry(),i,r,n);if(!Fi(i,r))return!1;for(const e of s)if(!Vi(e,o))return!1}return!0}(e,this.geometries)}return!1}eachChild(){}outputDefined(){return!0}}let qi=class{constructor(e=[],t=(e,t)=>et?1:0){if(this.data=e,this.length=this.data.length,this.compare=t,this.length>0)for(let e=(this.length>>1)-1;e>=0;e--)this._down(e)}push(e){this.data.push(e),this._up(this.length++)}pop(){if(0===this.length)return;const e=this.data[0],t=this.data.pop();return--this.length>0&&(this.data[0]=t,this._down(0)),e}peek(){return this.data[0]}_up(e){const{data:t,compare:i}=this,r=t[e];for(;e>0;){const n=e-1>>1,o=t[n];if(i(r,o)>=0)break;t[e]=o,e=n}t[e]=r}_down(e){const{data:t,compare:i}=this,r=this.length>>1,n=t[e];for(;e=0)break;t[e]=t[r],e=r}t[e]=n}};function Ki(e,t,i=0,r=e.length-1,n=Ji){for(;r>i;){if(r-i>600){const o=r-i+1,s=t-i+1,a=Math.log(o),l=.5*Math.exp(2*a/3),c=.5*Math.sqrt(a*l*(o-l)/o)*(s-o/2<0?-1:1);Ki(e,t,Math.max(i,Math.floor(t-s*l/o+c)),Math.min(r,Math.floor(t+(o-s)*l/o+c)),n)}const o=e[t];let s=i,a=r;for(Xi(e,i,t),n(e[r],o)>0&&Xi(e,i,r);s0;)a--}0===n(e[i],o)?Xi(e,i,a):(a++,Xi(e,a,r)),a<=t&&(i=a+1),t<=a&&(r=a-1)}}function Xi(e,t,i){const r=e[t];e[t]=e[i],e[i]=r}function Ji(e,t){return et?1:0}function Yi(e,t){if(e.length<=1)return[e];const i=[];let r,n;for(const t of e){const e=tr(t);0!==e&&(t.area=Math.abs(e),void 0===n&&(n=e<0),n===e<0?(r&&i.push(r),r=[t]):r.push(t))}if(r&&i.push(r),t>1)for(let e=0;e1?(l=e[a+1][0],c=e[a+1][1]):d>0&&(l+=u/this.kx*d,c+=h/this.ky*d)),u=this.wrap(t[0]-l)*this.kx,h=(t[1]-c)*this.ky;const p=u*u+h*h;p180;)e-=360;return e}}function sr(e,t){return t[0]-e[0]}function ar(e){return e[1]-e[0]+1}function lr(e,t){return e[1]>=e[0]&&e[1]e[1])return[null,null];const i=ar(e);if(t){if(2===i)return[e,null];const t=Math.floor(i/2);return[[e[0],e[0]+t],[e[0]+t,e[1]]]}if(1===i)return[e,null];const r=Math.floor(i/2)-1;return[[e[0],e[0]+r],[e[0]+r+1,e[1]]]}function ur(e,t){if(!lr(t,e.length))return[1/0,1/0,-1/0,-1/0];const i=[1/0,1/0,-1/0,-1/0];for(let r=t[0];r<=t[1];++r)Li(i,e[r]);return i}function hr(e){const t=[1/0,1/0,-1/0,-1/0];for(const i of e)for(const e of i)Li(t,e);return t}function dr(e){return e[0]!==-1/0&&e[1]!==-1/0&&e[2]!==1/0&&e[3]!==1/0}function pr(e,t,i){if(!dr(e)||!dr(t))return NaN;let r=0,n=0;return e[2]t[2]&&(r=e[0]-t[2]),e[1]>t[3]&&(n=e[1]-t[3]),e[3]=r)return r;if(Fi(n,o)){if(vr(e,t))return 0}else if(vr(t,e))return 0;let s=1/0;for(const r of e)for(let e=0,n=r.length,o=n-1;e0;){const n=s.pop();if(n[0]>=o)continue;const l=n[1],c=t?50:100;if(ar(l)<=c){if(!lr(l,e.length))return NaN;if(t){const t=yr(e,l,i,r);if(isNaN(t)||0===t)return t;o=Math.min(o,t)}else for(let t=l[0];t<=l[1];++t){const n=Ar(e[t],i,r);if(o=Math.min(o,n),0===o)return 0}}else{const i=cr(l,t);br(s,o,r,e,a,i[0]),br(s,o,r,e,a,i[1])}}return o}function Er(e,t,i,r,n,o=1/0){let s=Math.min(o,n.distance(e[0],i[0]));if(0===s)return s;const a=new qi([[0,[0,e.length-1],[0,i.length-1]]],sr);for(;a.length>0;){const o=a.pop();if(o[0]>=s)continue;const l=o[1],c=o[2],u=t?50:100,h=r?50:100;if(ar(l)<=u&&ar(c)<=h){if(!lr(l,e.length)&&lr(c,i.length))return NaN;let o;if(t&&r)o=gr(e,l,i,c,n),s=Math.min(s,o);else if(t&&!r){const t=e.slice(l[0],l[1]+1);for(let e=c[0];e<=c[1];++e)if(o=fr(i[e],t,n),s=Math.min(s,o),0===s)return s}else if(!t&&r){const t=i.slice(c[0],c[1]+1);for(let i=l[0];i<=l[1];++i)if(o=fr(e[i],t,n),s=Math.min(s,o),0===s)return s}else o=_r(e,l,i,c,n),s=Math.min(s,o)}else{const o=cr(l,t),u=cr(c,r);wr(a,s,n,e,i,o[0],u[0]),wr(a,s,n,e,i,o[0],u[1]),wr(a,s,n,e,i,o[1],u[0]),wr(a,s,n,e,i,o[1],u[1])}}return s}function Cr(e){return"MultiPolygon"===e.type?e.coordinates.map(e=>({type:"Polygon",coordinates:e})):"MultiLineString"===e.type?e.coordinates.map(e=>({type:"LineString",coordinates:e})):"MultiPoint"===e.type?e.coordinates.map(e=>({type:"Point",coordinates:e})):[e]}class Br{constructor(e,t){this.type=ke,this.geojson=e,this.geometries=t}static parse(e,t){if(2!==e.length)return t.error(`'distance' expression requires exactly one argument, but found ${e.length-1} instead.`);if(Nt(e[1])){const t=e[1];if("FeatureCollection"===t.type)return new Br(t,t.features.map(e=>Cr(e.geometry)).flat());if("Feature"===t.type)return new Br(t,Cr(t.geometry));if("type"in t&&"coordinates"in t)return new Br(t,Cr(t))}return t.error("'distance' expression requires valid geojson object that contains polygon geometry type.")}evaluate(e){if(null!=e.geometry()&&null!=e.canonicalID()){if("Point"===e.geometryType())return function(e,t){const i=e.geometry(),r=i.flat().map(t=>Ri([t.x,t.y],e.canonical));if(0===i.length)return NaN;const n=new or(r[0][1]);let o=1/0;for(const e of t){switch(e.type){case"Point":o=Math.min(o,Er(r,!1,[e.coordinates],!1,n,o));break;case"LineString":o=Math.min(o,Er(r,!1,e.coordinates,!0,n,o));break;case"Polygon":o=Math.min(o,Tr(r,!1,e.coordinates,n,o))}if(0===o)return o}return o}(e,this.geometries);if("LineString"===e.geometryType())return function(e,t){const i=e.geometry(),r=i.flat().map(t=>Ri([t.x,t.y],e.canonical));if(0===i.length)return NaN;const n=new or(r[0][1]);let o=1/0;for(const e of t){switch(e.type){case"Point":o=Math.min(o,Er(r,!0,[e.coordinates],!1,n,o));break;case"LineString":o=Math.min(o,Er(r,!0,e.coordinates,!0,n,o));break;case"Polygon":o=Math.min(o,Tr(r,!0,e.coordinates,n,o))}if(0===o)return o}return o}(e,this.geometries);if("Polygon"===e.geometryType())return function(e,t){const i=e.geometry();if(0===i.length||0===i[0].length)return NaN;const r=Yi(i,0).map(t=>t.map(t=>t.map(t=>Ri([t.x,t.y],e.canonical)))),n=new or(r[0][0][0][1]);let o=1/0;for(const e of t)for(const t of r){switch(e.type){case"Point":o=Math.min(o,Tr([e.coordinates],!1,t,n,o));break;case"LineString":o=Math.min(o,Tr(e.coordinates,!0,t,n,o));break;case"Polygon":o=Math.min(o,xr(t,e.coordinates,n,o))}if(0===o)return o}return o}(e,this.geometries)}return NaN}eachChild(){}outputDefined(){return!0}}class Sr{constructor(e){this.type=Ve,this.key=e}static parse(e,t){if(2!==e.length)return t.error(`Expected 1 argument, but found ${e.length-1} instead.`);const i=e[1];return null==i?t.error("Global state property must be defined."):"string"!=typeof i?t.error(`Global state property must be string, but found ${typeof e[1]} instead.`):new Sr(i)}evaluate(e){var t;const i=null===(t=e.globals)||void 0===t?void 0:t.globalState;return i&&0!==Object.keys(i).length?At(i,this.key):null}eachChild(){}outputDefined(){return!1}}const Ir={"==":yi,"!=":vi,">":bi,"<":xi,">=":Ti,"<=":wi,array:Qt,at:Yt,boolean:Qt,case:ri,coalesce:mi,collator:Ei,format:Bi,image:Si,in:ei,"index-of":ti,interpolate:di,"interpolate-hcl":di,"interpolate-lab":di,length:Ii,let:Xt,literal:Gt,match:ii,number:Qt,"number-format":Ci,object:Qt,slice:ni,step:si,string:Qt,"to-boolean":Zt,"to-color":Zt,"to-number":Zt,"to-string":Zt,var:Jt,within:Wi,distance:Br,"global-state":Sr};class Mr{constructor(e,t,i,r){this.name=e,this.type=t,this._evaluate=i,this.args=r}evaluate(e){return this._evaluate(e,this.args)}eachChild(e){this.args.forEach(e)}outputDefined(){return!1}static parse(e,t){const i=e[0],r=Mr.definitions[i];if(!r)return t.error(`Unknown expression "${i}". If you wanted a literal array, use ["literal", [...]].`,0);const n=Array.isArray(r)?r[0]:r.type,o=Array.isArray(r)?[[r[1],r[2]]]:r.overloads,s=o.filter(([t])=>!Array.isArray(t)||t.length===e.length-1);let a=null;for(const[r,o]of s){a=new Kt(t.registry,kr,t.path,null,t.scope);const s=[];let l=!1;for(let t=1;t{return t=e,Array.isArray(t)?`(${t.map(Ke).join(", ")})`:`(${Ke(t.type)}...)`;var t}).join(" | "),r=[];for(let i=1;i{i=t?i&&kr(e):i&&e instanceof Gt}),!!i&&Dr(e)&&zr(e,["zoom","heatmap-density","elevation","line-progress","accumulated","is-supported-script"])}function Dr(e){if(e instanceof Mr){if("get"===e.name&&1===e.args.length)return!1;if("feature-state"===e.name)return!1;if("has"===e.name&&1===e.args.length)return!1;if("properties"===e.name||"geometry-type"===e.name||"id"===e.name)return!1;if(/^filter-/.test(e.name))return!1}if(e instanceof Wi)return!1;if(e instanceof Br)return!1;let t=!0;return e.eachChild(e=>{t&&!Dr(e)&&(t=!1)}),t}function Or(e){if(e instanceof Mr&&"feature-state"===e.name)return!1;let t=!0;return e.eachChild(e=>{t&&!Or(e)&&(t=!1)}),t}function zr(e,t){if(e instanceof Mr&&t.indexOf(e.name)>=0)return!1;let i=!0;return e.eachChild(e=>{i&&!zr(e,t)&&(i=!1)}),i}function Ur(e){return{result:"success",value:e}}function Nr(e){return{result:"error",value:e}}function Vr(e){return"data-driven"===e["property-type"]||"cross-faded-data-driven"===e["property-type"]}function jr(e){return!!e.expression&&e.expression.parameters.indexOf("zoom")>-1}function Gr(e){return!!e.expression&&e.expression.interpolated}function Hr(e){return e instanceof Number?"number":e instanceof String?"string":e instanceof Boolean?"boolean":Array.isArray(e)?"array":null===e?"null":typeof e}function Qr(e){return"object"==typeof e&&null!==e&&!Array.isArray(e)&&Vt(e)===Ne}function $r(e){return e}function Zr(e,t){const i=e.stops&&"object"==typeof e.stops[0][0],r=i||!(i||void 0!==e.property),n=e.type||(Gr(t)?"exponential":"interval"),o=function(e){switch(e.type){case"color":return Ct.parse;case"padding":return Pt.parse;case"numberArray":return Rt.parse;case"colorArray":return Lt.parse;default:return null}}(t);if(o&&((e=Pe({},e)).stops&&(e.stops=e.stops.map(e=>[e[0],o(e[1])])),e.default=o(e.default?e.default:t.default)),e.colorSpace&&"rgb"!==(s=e.colorSpace)&&"hcl"!==s&&"lab"!==s)throw new Error(`Unknown color space: "${e.colorSpace}"`);var s;const a=function(e){switch(e){case"exponential":return Xr;case"interval":return Kr;case"categorical":return qr;case"identity":return Jr;default:throw new Error(`Unknown function type "${e}"`)}}(n);let l,c;if("categorical"===n){l=Object.create(null);for(const t of e.stops)l[t[0]]=t[1];c=typeof e.stops[0][0]}if(i){const i={},r=[];for(let t=0;te[0]),evaluate:({zoom:i},r)=>Xr({stops:n,base:e.base},t,i).evaluate(i,r)}}if(r){const i="exponential"===n?{name:"exponential",base:void 0!==e.base?e.base:1}:null;return{kind:"camera",interpolationType:i,interpolationFactor:di.interpolationFactor.bind(void 0,i),zoomStops:e.stops.map(e=>e[0]),evaluate:({zoom:i})=>a(e,t,i,l,c)}}return{kind:"source",evaluate(i,r){const n=r&&r.properties?r.properties[e.property]:void 0;return void 0===n?Wr(e.default,t.default):a(e,t,n,l,c)}}}function Wr(e,t,i){return void 0!==e?e:void 0!==t?t:void 0!==i?i:void 0}function qr(e,t,i,r,n){return Wr(typeof i===n?r[i]:void 0,e.default,t.default)}function Kr(e,t,i){if("number"!==Hr(i))return Wr(e.default,t.default);const r=e.stops.length;if(1===r)return e.stops[0][1];if(i<=e.stops[0][0])return e.stops[0][1];if(i>=e.stops[r-1][0])return e.stops[r-1][1];const n=oi(e.stops.map(e=>e[0]),i);return e.stops[n][1]}function Xr(e,t,i){const r=void 0!==e.base?e.base:1;if("number"!==Hr(i))return Wr(e.default,t.default);const n=e.stops.length;if(1===n)return e.stops[0][1];if(i<=e.stops[0][0])return e.stops[0][1];if(i>=e.stops[n-1][0])return e.stops[n-1][1];const o=oi(e.stops.map(e=>e[0]),i),s=function(e,t,i,r){const n=r-i,o=e-i;return 0===n?0:1===t?o/n:(Math.pow(t,o)-1)/(Math.pow(t,n)-1)}(i,r,e.stops[o][0],e.stops[o+1][0]),a=e.stops[o][1],l=e.stops[o+1][1],c=fi[t.type]||$r;return"function"==typeof a.evaluate?{evaluate(...t){const i=a.evaluate.apply(void 0,t),r=l.evaluate.apply(void 0,t);if(void 0!==i&&void 0!==r)return c(i,r,s,e.colorSpace)}}:c(a,l,s,e.colorSpace)}function Jr(e,t,i){switch(t.type){case"color":i=Ct.parse(i);break;case"formatted":i=Mt.fromString(i.toString());break;case"resolvedImage":i=Ot.fromString(i.toString());break;case"padding":i=Pt.parse(i);break;case"colorArray":i=Lt.parse(i);break;case"numberArray":i=Rt.parse(i);break;default:Hr(i)===t.type||"enum"===t.type&&t.values[i]||(i=void 0)}return Wr(i,e.default,t.default)}Mr.register(Ir,{error:[{kind:"error"},[De],(e,[t])=>{throw new Ft(t.evaluate(e))}],typeof:[De,[Ve],(e,[t])=>Ke(Vt(t.evaluate(e)))],"to-rgba":[qe(ke,4),[ze],(e,[t])=>{const[i,r,n,o]=t.evaluate(e).rgb;return[255*i,255*r,255*n,o]}],rgb:[ze,[ke,ke,ke],Pr],rgba:[ze,[ke,ke,ke,ke],Pr],has:{type:Oe,overloads:[[[De],(e,[t])=>Rr(t.evaluate(e),e.properties())],[[De,Ne],(e,[t,i])=>Rr(t.evaluate(e),i.evaluate(e))]]},get:{type:Ve,overloads:[[[De],(e,[t])=>Lr(t.evaluate(e),e.properties())],[[De,Ne],(e,[t,i])=>Lr(t.evaluate(e),i.evaluate(e))]]},"feature-state":[Ve,[De],(e,[t])=>Lr(t.evaluate(e),e.featureState||{})],properties:[Ne,[],e=>e.properties()],"geometry-type":[De,[],e=>e.geometryType()],id:[Ve,[],e=>e.id()],zoom:[ke,[],e=>e.globals.zoom],"heatmap-density":[ke,[],e=>e.globals.heatmapDensity||0],elevation:[ke,[],e=>e.globals.elevation||0],"line-progress":[ke,[],e=>e.globals.lineProgress||0],accumulated:[Ve,[],e=>void 0===e.globals.accumulated?null:e.globals.accumulated],"+":[ke,Fr(ke),(e,t)=>{let i=0;for(const r of t)i+=r.evaluate(e);return i}],"*":[ke,Fr(ke),(e,t)=>{let i=1;for(const r of t)i*=r.evaluate(e);return i}],"-":{type:ke,overloads:[[[ke,ke],(e,[t,i])=>t.evaluate(e)-i.evaluate(e)],[[ke],(e,[t])=>-t.evaluate(e)]]},"/":[ke,[ke,ke],(e,[t,i])=>t.evaluate(e)/i.evaluate(e)],"%":[ke,[ke,ke],(e,[t,i])=>t.evaluate(e)%i.evaluate(e)],ln2:[ke,[],()=>Math.LN2],pi:[ke,[],()=>Math.PI],e:[ke,[],()=>Math.E],"^":[ke,[ke,ke],(e,[t,i])=>Math.pow(t.evaluate(e),i.evaluate(e))],sqrt:[ke,[ke],(e,[t])=>Math.sqrt(t.evaluate(e))],log10:[ke,[ke],(e,[t])=>Math.log(t.evaluate(e))/Math.LN10],ln:[ke,[ke],(e,[t])=>Math.log(t.evaluate(e))],log2:[ke,[ke],(e,[t])=>Math.log(t.evaluate(e))/Math.LN2],sin:[ke,[ke],(e,[t])=>Math.sin(t.evaluate(e))],cos:[ke,[ke],(e,[t])=>Math.cos(t.evaluate(e))],tan:[ke,[ke],(e,[t])=>Math.tan(t.evaluate(e))],asin:[ke,[ke],(e,[t])=>Math.asin(t.evaluate(e))],acos:[ke,[ke],(e,[t])=>Math.acos(t.evaluate(e))],atan:[ke,[ke],(e,[t])=>Math.atan(t.evaluate(e))],min:[ke,Fr(ke),(e,t)=>Math.min(...t.map(t=>t.evaluate(e)))],max:[ke,Fr(ke),(e,t)=>Math.max(...t.map(t=>t.evaluate(e)))],abs:[ke,[ke],(e,[t])=>Math.abs(t.evaluate(e))],round:[ke,[ke],(e,[t])=>{const i=t.evaluate(e);return i<0?-Math.round(-i):Math.round(i)}],floor:[ke,[ke],(e,[t])=>Math.floor(t.evaluate(e))],ceil:[ke,[ke],(e,[t])=>Math.ceil(t.evaluate(e))],"filter-==":[Oe,[De,Ve],(e,[t,i])=>e.properties()[t.value]===i.value],"filter-id-==":[Oe,[Ve],(e,[t])=>e.id()===t.value],"filter-type-==":[Oe,[De],(e,[t])=>e.geometryType()===t.value],"filter-<":[Oe,[De,Ve],(e,[t,i])=>{const r=e.properties()[t.value],n=i.value;return typeof r==typeof n&&r{const i=e.id(),r=t.value;return typeof i==typeof r&&i":[Oe,[De,Ve],(e,[t,i])=>{const r=e.properties()[t.value],n=i.value;return typeof r==typeof n&&r>n}],"filter-id->":[Oe,[Ve],(e,[t])=>{const i=e.id(),r=t.value;return typeof i==typeof r&&i>r}],"filter-<=":[Oe,[De,Ve],(e,[t,i])=>{const r=e.properties()[t.value],n=i.value;return typeof r==typeof n&&r<=n}],"filter-id-<=":[Oe,[Ve],(e,[t])=>{const i=e.id(),r=t.value;return typeof i==typeof r&&i<=r}],"filter->=":[Oe,[De,Ve],(e,[t,i])=>{const r=e.properties()[t.value],n=i.value;return typeof r==typeof n&&r>=n}],"filter-id->=":[Oe,[Ve],(e,[t])=>{const i=e.id(),r=t.value;return typeof i==typeof r&&i>=r}],"filter-has":[Oe,[Ve],(e,[t])=>t.value in e.properties()],"filter-has-id":[Oe,[],e=>null!==e.id()&&void 0!==e.id()],"filter-type-in":[Oe,[qe(De)],(e,[t])=>t.value.indexOf(e.geometryType())>=0],"filter-id-in":[Oe,[qe(Ve)],(e,[t])=>t.value.indexOf(e.id())>=0],"filter-in-small":[Oe,[De,qe(Ve)],(e,[t,i])=>i.value.indexOf(e.properties()[t.value])>=0],"filter-in-large":[Oe,[De,qe(Ve)],(e,[t,i])=>function(e,t,i,r){for(;i<=r;){const n=i+r>>1;if(t[n]===e)return!0;t[n]>e?r=n-1:i=n+1}return!1}(e.properties()[t.value],i.value,0,i.value.length-1)],all:{type:Oe,overloads:[[[Oe,Oe],(e,[t,i])=>t.evaluate(e)&&i.evaluate(e)],[Fr(Oe),(e,t)=>{for(const i of t)if(!i.evaluate(e))return!1;return!0}]]},any:{type:Oe,overloads:[[[Oe,Oe],(e,[t,i])=>t.evaluate(e)||i.evaluate(e)],[Fr(Oe),(e,t)=>{for(const i of t)if(i.evaluate(e))return!0;return!1}]]},"!":[Oe,[Oe],(e,[t])=>!t.evaluate(e)],"is-supported-script":[Oe,[De],(e,[t])=>{const i=e.globals&&e.globals.isSupportedScript;return!i||i(t.evaluate(e))}],upcase:[De,[De],(e,[t])=>t.evaluate(e).toUpperCase()],downcase:[De,[De],(e,[t])=>t.evaluate(e).toLowerCase()],concat:[De,Fr(Ve),(e,t)=>t.map(t=>jt(t.evaluate(e))).join("")],"resolved-locale":[De,[je],(e,[t])=>t.evaluate(e).resolvedLocale()]});class Yr{constructor(e,t,i){this.expression=e,this._warningHistory={},this._evaluator=new qt,this._defaultValue=t?function(e){if("color"===e.type&&Qr(e.default))return new Ct(0,0,0,0);switch(e.type){case"color":return Ct.parse(e.default)||null;case"padding":return Pt.parse(e.default)||null;case"numberArray":return Rt.parse(e.default)||null;case"colorArray":return Lt.parse(e.default)||null;case"variableAnchorOffsetCollection":return Dt.parse(e.default)||null;case"projectionDefinition":return zt.parse(e.default)||null;default:return void 0===e.default?null:e.default}}(t):null,this._enumValues=t&&"enum"===t.type?t.values:null,this._globalState=i}evaluateWithoutErrorHandling(e,t,i,r,n,o){return this._globalState&&(e=cn(e,this._globalState)),this._evaluator.globals=e,this._evaluator.feature=t,this._evaluator.featureState=i,this._evaluator.canonical=r,this._evaluator.availableImages=n||null,this._evaluator.formattedSection=o,this.expression.evaluate(this._evaluator)}evaluate(e,t,i,r,n,o){this._globalState&&(e=cn(e,this._globalState)),this._evaluator.globals=e,this._evaluator.feature=t||null,this._evaluator.featureState=i||null,this._evaluator.canonical=r,this._evaluator.availableImages=n||null,this._evaluator.formattedSection=o||null;try{const e=this.expression.evaluate(this._evaluator);if(null==e||"number"==typeof e&&e!=e)return this._defaultValue;if(this._enumValues&&!(e in this._enumValues))throw new Ft(`Expected value to be one of ${Object.keys(this._enumValues).map(e=>JSON.stringify(e)).join(", ")}, but found ${JSON.stringify(e)} instead.`);return e}catch(e){return this._warningHistory[e.message]||(this._warningHistory[e.message]=!0,"undefined"!=typeof console&&console.warn(e.message)),this._defaultValue}}}function en(e){return Array.isArray(e)&&e.length>0&&"string"==typeof e[0]&&e[0]in Ir}function tn(e,t,i){const r=new Kt(Ir,kr,[],t?function(e){const t={color:ze,string:De,number:ke,enum:De,boolean:Oe,formatted:Ge,padding:He,numberArray:$e,colorArray:Qe,projectionDefinition:Ue,resolvedImage:Ze,variableAnchorOffsetCollection:We};return"array"===e.type?qe(t[e.value]||Ve,e.length):t[e.type]}(t):void 0),n=r.parse(e,void 0,void 0,void 0,t&&"string"===t.type?{typeAnnotation:"coerce"}:void 0);return n?Ur(new Yr(n,t,i)):Nr(r.errors)}class rn{constructor(e,t,i){this.kind=e,this._styleExpression=t,this.isStateDependent="constant"!==e&&!Or(t.expression),this.globalStateRefs=ln(t.expression),this._globalState=i}evaluateWithoutErrorHandling(e,t,i,r,n,o){return this._globalState&&(e=cn(e,this._globalState)),this._styleExpression.evaluateWithoutErrorHandling(e,t,i,r,n,o)}evaluate(e,t,i,r,n,o){return this._globalState&&(e=cn(e,this._globalState)),this._styleExpression.evaluate(e,t,i,r,n,o)}}class nn{constructor(e,t,i,r,n){this.kind=e,this.zoomStops=i,this._styleExpression=t,this.isStateDependent="camera"!==e&&!Or(t.expression),this.globalStateRefs=ln(t.expression),this.interpolationType=r,this._globalState=n}evaluateWithoutErrorHandling(e,t,i,r,n,o){return this._globalState&&(e=cn(e,this._globalState)),this._styleExpression.evaluateWithoutErrorHandling(e,t,i,r,n,o)}evaluate(e,t,i,r,n,o){return this._globalState&&(e=cn(e,this._globalState)),this._styleExpression.evaluate(e,t,i,r,n,o)}interpolationFactor(e,t,i){return this.interpolationType?di.interpolationFactor(this.interpolationType,e,t,i):0}}function on(e,t,i){const r=tn(e,t,i);if("error"===r.result)return r;const n=r.value.expression,o=Dr(n);if(!o&&!Vr(t))return Nr([new Re("","data expressions not supported")]);const s=zr(n,["zoom"]);if(!s&&!jr(t))return Nr([new Re("","zoom expressions not supported")]);const a=an(n);return a||s?a instanceof Re?Nr([a]):a instanceof di&&!Gr(t)?Nr([new Re("",'"interpolate" expressions cannot be used with this property')]):Ur(a?new nn(o?"camera":"composite",r.value,a.labels,a instanceof di?a.interpolation:void 0,i):new rn(o?"constant":"source",r.value,i)):Nr([new Re("",'"zoom" expression may only be used as input to a top-level "step" or "interpolate" expression.')])}class sn{constructor(e,t){this._parameters=e,this._specification=t,Pe(this,Zr(this._parameters,this._specification))}static deserialize(e){return new sn(e._parameters,e._specification)}static serialize(e){return{_parameters:e._parameters,_specification:e._specification}}}function an(e){let t=null;if(e instanceof Xt)t=an(e.result);else if(e instanceof mi){for(const i of e.args)if(t=an(i),t)break}else(e instanceof si||e instanceof di)&&e.input instanceof Mr&&"zoom"===e.input.name&&(t=e);return t instanceof Re||e.eachChild(e=>{const i=an(e);i instanceof Re?t=i:!t&&i?t=new Re("",'"zoom" expression may only be used as input to a top-level "step" or "interpolate" expression.'):t&&i&&t!==i&&(t=new Re("",'Only one zoom-based "step" or "interpolate" subexpression may be used in an expression.'))}),t}function ln(e,t=new Set){return e instanceof Sr&&t.add(e.key),e.eachChild(e=>{ln(e,t)}),t}function cn(e,t){const{zoom:i,heatmapDensity:r,elevation:n,lineProgress:o,isSupportedScript:s,accumulated:a}=null!=e?e:{};return{zoom:i,heatmapDensity:r,elevation:n,lineProgress:o,isSupportedScript:s,accumulated:a,globalState:t}}function un(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(!un(t)&&"boolean"!=typeof t)return!1;return!0;default:return!0}}const hn={type:"boolean",default:!1,transition:!1,"property-type":"data-driven",expression:{interpolated:!1,parameters:["zoom","feature"]}};function dn(e,t){if(null==e)return{filter:()=>!0,needGeometry:!1,getGlobalStateRefs:()=>new Set};un(e)||(e=mn(e));const i=tn(e,hn,t);if("error"===i.result)throw new Error(i.value.map(e=>`${e.key}: ${e.message}`).join(", "));return{filter:(e,t,r)=>i.value.evaluate(e,t,{},r),needGeometry:fn(e),getGlobalStateRefs:()=>ln(i.value.expression)}}function pn(e,t){return et?1:0}function fn(e){if(!Array.isArray(e))return!1;if("within"===e[0]||"distance"===e[0])return!0;for(let t=1;t"===t||"<="===t||">="===t?gn(e[1],e[2],t):"any"===t?(i=e.slice(1),["any"].concat(i.map(mn))):"all"===t?["all"].concat(e.slice(1).map(mn)):"none"===t?["all"].concat(e.slice(1).map(mn).map(yn)):"in"===t?_n(e[1],e.slice(2)):"!in"===t?yn(_n(e[1],e.slice(2))):"has"===t?An(e[1]):"!has"!==t||yn(An(e[1]));var i}function gn(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 _n(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(pn)]]:["filter-in-small",e,["literal",t]]}}function An(e){switch(e){case"$type":return!0;case"$id":return["filter-has-id"];default:return["filter-has",e]}}function yn(e){return["!",e]}function vn(e){const t=typeof e;if("number"===t||"boolean"===t||"string"===t||null==e)return JSON.stringify(e);if(Array.isArray(e)){let t="[";for(const i of e)t+=`${vn(i)},`;return`${t}]`}const i=Object.keys(e).sort();let r="{";for(let t=0;tr.maximum?[new Me(t,i,`${i} is greater than the maximum value ${r.maximum}`)]:[]}function Sn(e){const t=e.valueSpec,i=wn(e.value.type);let r,n,o,s={};const a="categorical"!==i&&void 0===e.value.property,l=!a,c="array"===Hr(e.value.stops)&&"array"===Hr(e.value.stops[0])&&"object"===Hr(e.value.stops[0][0]),u=En({key:e.key,value:e.value,valueSpec:e.styleSpec.function,validateSpec:e.validateSpec,style:e.style,styleSpec:e.styleSpec,objectElementValidators:{stops:function(e){if("identity"===i)return[new Me(e.key,e.value,'identity function may not have a "stops" property')];let t=[];const r=e.value;return t=t.concat(Cn({key:e.key,value:r,valueSpec:e.valueSpec,validateSpec:e.validateSpec,style:e.style,styleSpec:e.styleSpec,arrayElementValidator:h})),"array"===Hr(r)&&0===r.length&&t.push(new Me(e.key,r,"array must have at least one stop")),t},default:function(e){return e.validateSpec({key:e.key,value:e.value,valueSpec:t,validateSpec:e.validateSpec,style:e.style,styleSpec:e.styleSpec})}}});return"identity"===i&&a&&u.push(new Me(e.key,e.value,'missing required property "property"')),"identity"===i||e.value.stops||u.push(new Me(e.key,e.value,'missing required property "stops"')),"exponential"===i&&e.valueSpec.expression&&!Gr(e.valueSpec)&&u.push(new Me(e.key,e.value,"exponential functions not supported")),e.styleSpec.$version>=8&&(l&&!Vr(e.valueSpec)?u.push(new Me(e.key,e.value,"property functions not supported")):a&&!jr(e.valueSpec)&&u.push(new Me(e.key,e.value,"zoom functions not supported"))),"categorical"!==i&&!c||void 0!==e.value.property||u.push(new Me(e.key,e.value,'"property" property is required')),u;function h(e){let i=[];const r=e.value,a=e.key;if("array"!==Hr(r))return[new Me(a,r,`array expected, ${Hr(r)} found`)];if(2!==r.length)return[new Me(a,r,`array length 2 expected, length ${r.length} found`)];if(c){if("object"!==Hr(r[0]))return[new Me(a,r,`object expected, ${Hr(r[0])} found`)];if(void 0===r[0].zoom)return[new Me(a,r,"object stop key must have zoom")];if(void 0===r[0].value)return[new Me(a,r,"object stop key must have value")];if(o&&o>wn(r[0].zoom))return[new Me(a,r[0].zoom,"stop zoom values must appear in ascending order")];wn(r[0].zoom)!==o&&(o=wn(r[0].zoom),n=void 0,s={}),i=i.concat(En({key:`${a}[0]`,value:r[0],valueSpec:{zoom:{}},validateSpec:e.validateSpec,style:e.style,styleSpec:e.styleSpec,objectElementValidators:{zoom:Bn,value:d}}))}else i=i.concat(d({key:`${a}[0]`,value:r[0],validateSpec:e.validateSpec,style:e.style,styleSpec:e.styleSpec},r));return en(Tn(r[1]))?i.concat([new Me(`${a}[1]`,r[1],"expressions are not allowed in function stops.")]):i.concat(e.validateSpec({key:`${a}[1]`,value:r[1],valueSpec:t,validateSpec:e.validateSpec,style:e.style,styleSpec:e.styleSpec}))}function d(e,o){const a=Hr(e.value),l=wn(e.value),c=null!==e.value?e.value:o;if(r){if(a!==r)return[new Me(e.key,c,`${a} stop domain type must match previous stop domain type ${r}`)]}else r=a;if("number"!==a&&"string"!==a&&"boolean"!==a)return[new Me(e.key,c,"stop domain value must be a number, string, or boolean")];if("number"!==a&&"categorical"!==i){let r=`number expected, ${a} found`;return Vr(t)&&void 0===i&&(r+='\nIf you intended to use a categorical function, specify `"type": "categorical"`.'),[new Me(e.key,c,r)]}return"categorical"!==i||"number"!==a||isFinite(l)&&Math.floor(l)===l?"categorical"!==i&&"number"===a&&void 0!==n&&lnew Me(`${e.key}${t.key}`,e.value,t.message));const i=t.value.expression||t.value._styleExpression.expression;if("property"===e.expressionContext&&"text-font"===e.propertyKey&&!i.outputDefined())return[new Me(e.key,e.value,`Invalid data expression for "${e.propertyKey}". Output values must be contained as literals within the expression.`)];if("property"===e.expressionContext&&"layout"===e.propertyType&&!Or(i))return[new Me(e.key,e.value,'"feature-state" data expressions are not supported with layout properties.')];if("filter"===e.expressionContext&&!Or(i))return[new Me(e.key,e.value,'"feature-state" data expressions are not supported with filters.')];if(e.expressionContext&&0===e.expressionContext.indexOf("cluster")){if(!zr(i,["zoom","feature-state"]))return[new Me(e.key,e.value,'"zoom" and "feature-state" expressions are not supported with cluster properties.')];if("cluster-initial"===e.expressionContext&&!Dr(i))return[new Me(e.key,e.value,"Feature data expressions are not supported with initial expression part of cluster properties.")]}return[]}function Mn(e){const t=e.key,i=e.value,r=Hr(i);return"string"!==r?[new Me(t,i,`color expected, ${r} found`)]:Ct.parse(String(i))?[]:[new Me(t,i,`color expected, "${i}" found`)]}function Pn(e){const t=e.key,i=e.value,r=e.valueSpec,n=[];return Array.isArray(r.values)?-1===r.values.indexOf(wn(i))&&n.push(new Me(t,i,`expected one of [${r.values.join(", ")}], ${JSON.stringify(i)} found`)):-1===Object.keys(r.values).indexOf(wn(i))&&n.push(new Me(t,i,`expected one of [${Object.keys(r.values).join(", ")}], ${JSON.stringify(i)} found`)),n}function Rn(e){return un(Tn(e.value))?In(Pe({},e,{expressionContext:"filter",valueSpec:{value:"boolean"}})):Ln(e)}function Ln(e){const t=e.value,i=e.key;if("array"!==Hr(t))return[new Me(i,t,`array expected, ${Hr(t)} found`)];const r=e.styleSpec;let n,o=[];if(t.length<1)return[new Me(i,t,"filter array must have at least 1 element")];switch(o=o.concat(Pn({key:`${i}[0]`,value:t[0],valueSpec:r.filter_operator,style:e.style,styleSpec:e.styleSpec})),wn(t[0])){case"<":case"<=":case">":case">=":t.length>=2&&"$type"===wn(t[1])&&o.push(new Me(i,t,`"$type" cannot be use with operator "${t[0]}"`));case"==":case"!=":3!==t.length&&o.push(new Me(i,t,`filter array for operator "${t[0]}" must have 3 elements`));case"in":case"!in":t.length>=2&&(n=Hr(t[1]),"string"!==n&&o.push(new Me(`${i}[1]`,t[1],`string expected, ${n} found`)));for(let s=2;s{e in i&&t.push(new Me(r,i[e],`"${e}" is prohibited for ref layers`))}),n.layers.forEach(t=>{wn(t.id)===a&&(e=t)}),e?e.ref?t.push(new Me(r,i.ref,"ref cannot reference another ref layer")):s=wn(e.type):t.push(new Me(r,i.ref,`ref layer "${a}" not found`))}else if("background"!==s)if(i.source){const e=n.sources&&n.sources[i.source],o=e&&wn(e.type);e?"vector"===o&&"raster"===s?t.push(new Me(r,i.source,`layer "${i.id}" requires a raster source`)):"raster-dem"!==o&&"hillshade"===s||"raster-dem"!==o&&"color-relief"===s?t.push(new Me(r,i.source,`layer "${i.id}" requires a raster-dem source`)):"raster"===o&&"raster"!==s?t.push(new Me(r,i.source,`layer "${i.id}" requires a vector source`)):"vector"!==o||i["source-layer"]?"raster-dem"===o&&"hillshade"!==s&&"color-relief"!==s?t.push(new Me(r,i.source,"raster-dem source can only be used with layer type 'hillshade' or 'color-relief'.")):"line"!==s||!i.paint||!i.paint["line-gradient"]||"geojson"===o&&e.lineMetrics||t.push(new Me(r,i,`layer "${i.id}" specifies a line-gradient, which requires a GeoJSON source with \`lineMetrics\` enabled.`)):t.push(new Me(r,i,`layer "${i.id}" must specify a "source-layer"`)):t.push(new Me(r,i.source,`source "${i.source}" not found`))}else t.push(new Me(r,i,'missing required property "source"'));return t=t.concat(En({key:r,value:i,valueSpec:o.layer,style:e.style,styleSpec:e.styleSpec,validateSpec:e.validateSpec,objectElementValidators:{"*":()=>[],type:()=>e.validateSpec({key:`${r}.type`,value:i.type,valueSpec:o.layer.type,style:e.style,styleSpec:e.styleSpec,validateSpec:e.validateSpec,object:i,objectKey:"type"}),filter:Rn,layout:e=>En({layer:i,key:e.key,value:e.value,style:e.style,styleSpec:e.styleSpec,validateSpec:e.validateSpec,objectElementValidators:{"*":e=>Dn(Pe({layerType:s},e))}}),paint:e=>En({layer:i,key:e.key,value:e.value,style:e.style,styleSpec:e.styleSpec,validateSpec:e.validateSpec,objectElementValidators:{"*":e=>kn(Pe({layerType:s},e))}})}})),t}function zn(e){const t=e.value,i=e.key,r=Hr(t);return"string"!==r?[new Me(i,t,`string expected, ${r} found`)]:[]}const Un={promoteId:function({key:e,value:t}){if("string"===Hr(t))return zn({key:e,value:t});{const i=[];for(const r in t)i.push(...zn({key:`${e}.${r}`,value:t[r]}));return i}}};function Nn(e){const t=e.value,i=e.key,r=e.styleSpec,n=e.style,o=e.validateSpec;if(!t.type)return[new Me(i,t,'"type" is required')];const s=wn(t.type);let a;switch(s){case"vector":case"raster":return a=En({key:i,value:t,valueSpec:r[`source_${s.replace("-","_")}`],style:e.style,styleSpec:r,objectElementValidators:Un,validateSpec:o}),a;case"raster-dem":return a=function(e){var t;const i=null!==(t=e.sourceName)&&void 0!==t?t:"",r=e.value,n=e.styleSpec,o=n.source_raster_dem,s=e.style;let a=[];const l=Hr(r);if(void 0===r)return a;if("object"!==l)return a.push(new Me("source_raster_dem",r,`object expected, ${l} found`)),a;const c="custom"===wn(r.encoding),u=["redFactor","greenFactor","blueFactor","baseShift"],h=e.value.encoding?`"${e.value.encoding}"`:"Default";for(const t in r)!c&&u.includes(t)?a.push(new Me(t,r[t],`In "${i}": "${t}" is only valid when "encoding" is set to "custom". ${h} encoding found`)):o[t]?a=a.concat(e.validateSpec({key:t,value:r[t],valueSpec:o[t],validateSpec:e.validateSpec,style:s,styleSpec:n})):a.push(new Me(t,r[t],`unknown property "${t}"`));return a}({sourceName:i,value:t,style:e.style,styleSpec:r,validateSpec:o}),a;case"geojson":if(a=En({key:i,value:t,valueSpec:r.source_geojson,style:n,styleSpec:r,validateSpec:o,objectElementValidators:Un}),t.cluster)for(const e in t.clusterProperties){const[r,n]=t.clusterProperties[e],o="string"==typeof r?[r,["accumulated"],["get",e]]:r;a.push(...In({key:`${i}.${e}.map`,value:n,expressionContext:"cluster-map"})),a.push(...In({key:`${i}.${e}.reduce`,value:o,expressionContext:"cluster-reduce"}))}return a;case"video":return En({key:i,value:t,valueSpec:r.source_video,style:n,validateSpec:o,styleSpec:r});case"image":return En({key:i,value:t,valueSpec:r.source_image,style:n,validateSpec:o,styleSpec:r});case"canvas":return[new Me(i,null,"Please use runtime APIs to add canvas sources, rather than including them in stylesheets.","source.canvas")];default:return Pn({key:`${i}.type`,value:t.type,valueSpec:{values:["vector","raster","raster-dem","geojson","video","image"]}})}}function Vn(e){const t=e.value,i=e.styleSpec,r=i.light,n=e.style;let o=[];const s=Hr(t);if(void 0===t)return o;if("object"!==s)return o=o.concat([new Me("light",t,`object expected, ${s} found`)]),o;for(const s in t){const a=s.match(/^(.*)-transition$/);o=o.concat(a&&r[a[1]]&&r[a[1]].transition?e.validateSpec({key:s,value:t[s],valueSpec:i.transition,validateSpec:e.validateSpec,style:n,styleSpec:i}):r[s]?e.validateSpec({key:s,value:t[s],valueSpec:r[s],validateSpec:e.validateSpec,style:n,styleSpec:i}):[new Me(s,t[s],`unknown property "${s}"`)])}return o}function jn(e){const t=e.value,i=e.styleSpec,r=i.sky,n=e.style,o=Hr(t);if(void 0===t)return[];if("object"!==o)return[new Me("sky",t,`object expected, ${o} found`)];let s=[];for(const o in t)s=s.concat(r[o]?e.validateSpec({key:o,value:t[o],valueSpec:r[o],style:n,styleSpec:i}):[new Me(o,t[o],`unknown property "${o}"`)]);return s}function Gn(e){const t=e.value,i=e.styleSpec,r=i.terrain,n=e.style;let o=[];const s=Hr(t);if(void 0===t)return o;if("object"!==s)return o=o.concat([new Me("terrain",t,`object expected, ${s} found`)]),o;for(const s in t)o=o.concat(r[s]?e.validateSpec({key:s,value:t[s],valueSpec:r[s],validateSpec:e.validateSpec,style:n,styleSpec:i}):[new Me(s,t[s],`unknown property "${s}"`)]);return o}function Hn(e){let t=[];const i=e.value,r=e.key;if(Array.isArray(i)){const n=[],o=[];for(const s in i)i[s].id&&n.includes(i[s].id)&&t.push(new Me(r,i,`all the sprites' ids must be unique, but ${i[s].id} is duplicated`)),n.push(i[s].id),i[s].url&&o.includes(i[s].url)&&t.push(new Me(r,i,`all the sprites' URLs must be unique, but ${i[s].url} is duplicated`)),o.push(i[s].url),t=t.concat(En({key:`${r}[${s}]`,value:i[s],valueSpec:{id:{type:"string",required:!0},url:{type:"string",required:!0}},validateSpec:e.validateSpec}));return t}return zn({key:r,value:i})}function Qn(e){return t=e.value,Boolean(t)&&t.constructor===Object?[]:[new Me(e.key,e.value,`object expected, ${Hr(e.value)} found`)];var t}const $n={"*":()=>[],array:Cn,boolean:function(e){const t=e.value,i=e.key,r=Hr(t);return"boolean"!==r?[new Me(i,t,`boolean expected, ${r} found`)]:[]},number:Bn,color:Mn,constants:bn,enum:Pn,filter:Rn,function:Sn,layer:On,object:En,source:Nn,light:Vn,sky:jn,terrain:Gn,projection:function(e){const t=e.value,i=e.styleSpec,r=i.projection,n=e.style,o=Hr(t);if(void 0===t)return[];if("object"!==o)return[new Me("projection",t,`object expected, ${o} found`)];let s=[];for(const o in t)s=s.concat(r[o]?e.validateSpec({key:o,value:t[o],valueSpec:r[o],style:n,styleSpec:i}):[new Me(o,t[o],`unknown property "${o}"`)]);return s},projectionDefinition:function(e){const t=e.key;let i=e.value;i=i instanceof String?i.valueOf():i;const r=Hr(i);return"array"!==r||function(e){return Array.isArray(e)&&3===e.length&&"string"==typeof e[0]&&"string"==typeof e[1]&&"number"==typeof e[2]}(i)||function(e){return!!["interpolate","step","literal"].includes(e[0])}(i)?["array","string"].includes(r)?[]:[new Me(t,i,`projection expected, invalid type "${r}" found`)]:[new Me(t,i,`projection expected, invalid array ${JSON.stringify(i)} found`)]},string:zn,formatted:function(e){return 0===zn(e).length?[]:In(e)},resolvedImage:function(e){return 0===zn(e).length?[]:In(e)},padding:function(e){const t=e.key,i=e.value;if("array"===Hr(i)){if(i.length<1||i.length>4)return[new Me(t,i,`padding requires 1 to 4 values; ${i.length} values found`)];const r={type:"number"};let n=[];for(let o=0;o[]}})),e.constants&&(i=i.concat(bn({key:"constants",value:e.constants}))),Xn(i)}function Kn(e){return function(t){return e(Object.assign({},t,{validateSpec:Zn}))}}function Xn(e){return[].concat(e).sort((e,t)=>e.line-t.line)}function Jn(e){return function(...t){return Xn(e.apply(this,t))}}qn.source=Jn(Kn(Nn)),qn.sprite=Jn(Kn(Hn)),qn.glyphs=Jn(Kn(Wn)),qn.light=Jn(Kn(Vn)),qn.sky=Jn(Kn(jn)),qn.terrain=Jn(Kn(Gn)),qn.state=Jn(Kn(Qn)),qn.layer=Jn(Kn(On)),qn.filter=Jn(Kn(Rn)),qn.paintProperty=Jn(Kn(kn)),qn.layoutProperty=Jn(Kn(Dn));const Yn=Ae,eo=qn,to=eo.light,io=eo.sky,ro=eo.paintProperty,no=eo.layoutProperty;function oo(e,t){let i=!1;if(t&&t.length)for(const r of t)e.fire(new ge(new Error(r.message))),i=!0;return i}class so{constructor(e,t,i){const r=this.cells=[];if(e instanceof ArrayBuffer){this.arrayBuffer=e;const n=new Int32Array(this.arrayBuffer);e=n[0],this.d=(t=n[1])+2*(i=n[2]);for(let e=0;e=c[l+0]&&r>=c[l+1])?(s[h]=!0,o.push(n[h])):s[h]=!1}}}}_forEachCell(e,t,i,r,n,o,s,a){const l=this._convertToCellCoord(e),c=this._convertToCellCoord(t),u=this._convertToCellCoord(i),h=this._convertToCellCoord(r);for(let d=l;d<=u;d++)for(let l=c;l<=h;l++){const c=this.d*l+d;if((!a||a(this._convertFromCellCoord(d),this._convertFromCellCoord(l),this._convertFromCellCoord(d+1),this._convertFromCellCoord(l+1)))&&n.call(this,e,t,i,r,c,o,s,a))return}}_convertFromCellCoord(e){return(e-this.padding)/this.scale}_convertToCellCoord(e){return Math.max(0,Math.min(this.d-1,Math.floor(e*this.scale)+this.padding))}toArrayBuffer(){if(this.arrayBuffer)return this.arrayBuffer;const e=this.cells,t=3+this.cells.length+1+1;let i=0;for(let e=0;e=0)continue;const o=e[r];n[r]=ao[i].shallow.indexOf(r)>=0?o:po(o,t)}e instanceof Error&&(n.message=e.message)}if(n.$name)throw new Error("$name property is reserved for worker serialization logic.");return"Object"!==i&&(n.$name=i),n}function fo(e){if(ho(e))return e;if(Array.isArray(e))return e.map(fo);if("object"!=typeof e)throw new Error("can't deserialize object of type "+typeof e);const t=uo(e)||"Object";if(!ao[t])throw new Error(`can't deserialize unregistered class ${t}`);const{klass:i}=ao[t];if(!i)throw new Error(`can't deserialize unregistered class ${t}`);if(i.deserialize)return i.deserialize(e);const r=Object.create(i.prototype);for(const i of Object.keys(e)){if("$name"===i)continue;const n=e[i];r[i]=ao[t].shallow.indexOf(i)>=0?n:fo(n)}return r}class mo{constructor(){this.first=!0}update(e,t){const i=Math.floor(e);return this.first?(this.first=!1,this.lastIntegerZoom=i,this.lastIntegerZoomTime=0,this.lastZoom=e,this.lastFloorZoom=i,!0):(this.lastFloorZoom>i?(this.lastIntegerZoom=i+1,this.lastIntegerZoomTime=t):this.lastFloorZoom{try{return new RegExp(`\\p{sc=${e}}`,"u").source}catch(e){return null}}).filter(e=>e);return new RegExp(t.join("|"),"u")}const bo=xo(["Arab","Dupl","Mong","Ougr","Syrc"]);function wo(e){return!bo.test(String.fromCodePoint(e))}function To(e){return!(_o(e)||(t=e,/[\xA7\xA9\xAE\xB1\xBC-\xBE\xD7\xF7\u2016\u2020\u2021\u2030\u2031\u203B\u203C\u2042\u2047-\u2049\u2051\u2100-\u218F\u221E\u2234\u2235\u2300-\u2307\u230C-\u231F\u2324-\u2328\u232B\u237D-\u239A\u23BE-\u23CD\u23CF\u23D1-\u23DB\u23E2-\u2422\u2424-\u24FF\u25A0-\u2619\u2620-\u2767\u2776-\u2793\u2B12-\u2B2F\u2B50-\u2B59\u2BB8-\u2BEB\u3000-\u303F\u30A0-\u30FF\uE000-\uF8FF\uFE30-\uFE6F\uFF00-\uFFEF\uFFFC\uFFFD]|[\uDB80-\uDBFF][\uDC00-\uDFFF]/gim.test(String.fromCodePoint(t))));var t}const Eo=xo(["Adlm","Arab","Armi","Avst","Chrs","Cprt","Egyp","Elym","Gara","Hatr","Hebr","Hung","Khar","Lydi","Mand","Mani","Mend","Merc","Mero","Narb","Nbat","Nkoo","Orkh","Palm","Phli","Phlp","Phnx","Prti","Rohg","Samr","Sarb","Sogo","Syrc","Thaa","Todr","Yezi"]);function Co(e){return Eo.test(String.fromCodePoint(e))}function Bo(e,t){return!(!t&&Co(e)||/[\u0900-\u0DFF\u0F00-\u109F\u1780-\u17FF]/gim.test(String.fromCodePoint(e)))}function So(e){for(const t of e)if(Co(t.codePointAt(0)))return!0;return!1}const Io=new class{constructor(){this.TIMEOUT=5e3,this.applyArabicShaping=null,this.processBidirectionalText=null,this.processStyledBidirectionalText=null,this.pluginStatus="unavailable",this.pluginURL=null,this.loadScriptResolve=()=>{}}setState(e){this.pluginStatus=e.pluginStatus,this.pluginURL=e.pluginURL}getState(){return{pluginStatus:this.pluginStatus,pluginURL:this.pluginURL}}setMethods(e){if(Io.isParsed())throw new Error("RTL text plugin already registered.");this.applyArabicShaping=e.applyArabicShaping,this.processBidirectionalText=e.processBidirectionalText,this.processStyledBidirectionalText=e.processStyledBidirectionalText,this.loadScriptResolve()}isParsed(){return null!=this.applyArabicShaping&&null!=this.processBidirectionalText&&null!=this.processStyledBidirectionalText}getRTLTextPluginStatus(){return this.pluginStatus}syncState(e,i){return t(this,void 0,void 0,function*(){if(this.isParsed())return this.getState();if("loading"!==e.pluginStatus)return this.setState(e),e;const t=e.pluginURL,r=new Promise(e=>{this.loadScriptResolve=e});i(t);const n=new Promise(e=>setTimeout(()=>e(),this.TIMEOUT));if(yield Promise.race([r,n]),this.isParsed()){const e={pluginStatus:"loaded",pluginURL:t};return this.setState(e),e}throw this.setState({pluginStatus:"error",pluginURL:""}),new Error(`RTL Text Plugin failed to import scripts from ${t}`)})}};class Mo{constructor(e,t){this.isSupportedScript=Po,this.zoom=e,t?(this.now=t.now||0,this.fadeDuration=t.fadeDuration||0,this.zoomHistory=t.zoomHistory||new mo,this.transition=t.transition||{}):(this.now=0,this.fadeDuration=0,this.zoomHistory=new mo,this.transition={})}crossFadingFactor(){return 0===this.fadeDuration?1:Math.min((this.now-this.zoomHistory.lastIntegerZoomTime)/this.fadeDuration,1)}getCrossfadeParameters(){const e=this.zoom,t=e-Math.floor(e),i=this.crossFadingFactor();return e>this.zoomHistory.lastIntegerZoom?{fromScale:2,toScale:1,t:t+(1-t)*i}:{fromScale:.5,toScale:1,t:1-(1-i)*t}}}function Po(e){return function(e,t){for(const i of e)if(!Bo(i.codePointAt(0),t))return!1;return!0}(e,"loaded"===Io.getRTLTextPluginStatus())}const Ro="-transition";class Lo{constructor(e,t,i){this.property=e,this.value=t,this.expression=function(e,t,i){if(Qr(e))return new sn(e,t);if(en(e)){const r=on(e,t,i);if("error"===r.result)throw new Error(r.value.map(e=>`${e.key}: ${e.message}`).join(", "));return r.value}{let i=e;return"color"===t.type&&"string"==typeof e?i=Ct.parse(e):"padding"!==t.type||"number"!=typeof e&&!Array.isArray(e)?"numberArray"!==t.type||"number"!=typeof e&&!Array.isArray(e)?"colorArray"!==t.type||"string"!=typeof e&&!Array.isArray(e)?"variableAnchorOffsetCollection"===t.type&&Array.isArray(e)?i=Dt.parse(e):"projectionDefinition"===t.type&&"string"==typeof e&&(i=zt.parse(e)):i=Lt.parse(e):i=Rt.parse(e):i=Pt.parse(e),{globalStateRefs:new Set,_globalState:null,kind:"constant",evaluate:()=>i}}}(void 0===t?e.specification.default:t,e.specification,i)}isDataDriven(){return"source"===this.expression.kind||"composite"===this.expression.kind}getGlobalStateRefs(){return this.expression.globalStateRefs||new Set}possiblyEvaluate(e,t,i){return this.property.possiblyEvaluate(this,e,t,i)}}class Fo{constructor(e,t){this.property=e,this.value=new Lo(e,void 0,t)}transitioned(e,t){return new Do(this.property,this.value,t,z({},e.transition,this.transition),e.now)}untransitioned(){return new Do(this.property,this.value,null,{},0)}}class ko{constructor(e,t){this._properties=e,this._values=Object.create(e.defaultTransitionablePropertyValues),this._globalState=t}getValue(e){return j(this._values[e].value.value)}setValue(e,t){Object.prototype.hasOwnProperty.call(this._values,e)||(this._values[e]=new Fo(this._values[e].property,this._globalState)),this._values[e].value=new Lo(this._values[e].property,null===t?void 0:j(t),this._globalState)}getTransition(e){return j(this._values[e].transition)}setTransition(e,t){Object.prototype.hasOwnProperty.call(this._values,e)||(this._values[e]=new Fo(this._values[e].property,this._globalState)),this._values[e].transition=j(t)||void 0}serialize(){const e={};for(const t of Object.keys(this._values)){const i=this.getValue(t);void 0!==i&&(e[t]=i);const r=this.getTransition(t);void 0!==r&&(e[`${t}${Ro}`]=r)}return e}transitioned(e,t){const i=new Oo(this._properties);for(const r of Object.keys(this._values))i._values[r]=this._values[r].transitioned(e,t._values[r]);return i}untransitioned(){const e=new Oo(this._properties);for(const t of Object.keys(this._values))e._values[t]=this._values[t].untransitioned();return e}}class Do{constructor(e,t,i,r,n){this.property=e,this.value=t,this.begin=n+r.delay||0,this.end=this.begin+r.duration||0,e.specification.transition&&(r.delay||r.duration)&&(this.prior=i)}possiblyEvaluate(e,t,i){const r=e.now||0,n=this.value.possiblyEvaluate(e,t,i),o=this.prior;if(o){if(r>this.end)return this.prior=null,n;if(this.value.isDataDriven())return this.prior=null,n;if(rr.zoomHistory.lastIntegerZoom?{from:e,to:t}:{from:i,to:t}}interpolate(e){return e}}class Ho{constructor(e){this.specification=e}possiblyEvaluate(e,t,i,r){if(void 0!==e.value){if("constant"===e.expression.kind){const n=e.expression.evaluate(t,null,{},i,r);return this._calculate(n,n,n,t)}return this._calculate(e.expression.evaluate(new Mo(Math.floor(t.zoom-1),t)),e.expression.evaluate(new Mo(Math.floor(t.zoom),t)),e.expression.evaluate(new Mo(Math.floor(t.zoom+1),t)),t)}}_calculate(e,t,i,r){return r.zoom>r.zoomHistory.lastIntegerZoom?{from:e,to:t}:{from:i,to:t}}interpolate(e){return e}}class Qo{constructor(e){this.specification=e}possiblyEvaluate(e,t,i,r){return!!e.expression.evaluate(t,null,{},i,r)}interpolate(){return!1}}class $o{constructor(e){this.properties=e,this.defaultPropertyValues={},this.defaultTransitionablePropertyValues={},this.defaultTransitioningPropertyValues={},this.defaultPossiblyEvaluatedValues={},this.overridableProperties=[];for(const t in e){const i=e[t];i.specification.overridable&&this.overridableProperties.push(t);const r=this.defaultPropertyValues[t]=new Lo(i,void 0,void 0),n=this.defaultTransitionablePropertyValues[t]=new Fo(i,void 0);this.defaultTransitioningPropertyValues[t]=n.untransitioned(),this.defaultPossiblyEvaluatedValues[t]=r.possiblyEvaluate({})}}}lo("DataDrivenProperty",jo),lo("DataConstantProperty",Vo),lo("CrossFadedDataDrivenProperty",Go),lo("CrossFadedProperty",Ho),lo("ColorRampProperty",Qo);class Zo extends _e{constructor(e,t,i){if(super(),this.id=e.id,this.type=e.type,this._globalState=i,this._featureFilter={filter:()=>!0,needGeometry:!1,getGlobalStateRefs:()=>new Set},"custom"!==e.type&&(this.metadata=e.metadata,this.minzoom=e.minzoom,this.maxzoom=e.maxzoom,"background"!==e.type&&(this.source=e.source,this.sourceLayer=e["source-layer"],this.filter=e.filter,this._featureFilter=dn(e.filter,i)),t.layout&&(this._unevaluatedLayout=new zo(t.layout,i)),t.paint)){this._transitionablePaint=new ko(t.paint,i);for(const t in e.paint)this.setPaintProperty(t,e.paint[t],{validate:!1});for(const t in e.layout)this.setLayoutProperty(t,e.layout[t],{validate:!1});this._transitioningPaint=this._transitionablePaint.untransitioned(),this.paint=new No(t.paint)}}setFilter(e){this.filter=e,this._featureFilter=dn(e,this._globalState)}getCrossfadeParameters(){return this._crossfadeParameters}getLayoutProperty(e){return"visibility"===e?this.visibility:this._unevaluatedLayout.getValue(e)}getLayoutAffectingGlobalStateRefs(){const e=new Set;if(this._unevaluatedLayout)for(const t in this._unevaluatedLayout._values){const i=this._unevaluatedLayout._values[t];for(const t of i.getGlobalStateRefs())e.add(t)}for(const t of this._featureFilter.getGlobalStateRefs())e.add(t);return e}getPaintAffectingGlobalStateRefs(){var e;const t=new globalThis.Map;if(this._transitionablePaint)for(const i in this._transitionablePaint._values){const r=this._transitionablePaint._values[i].value;for(const n of r.getGlobalStateRefs()){const o=null!==(e=t.get(n))&&void 0!==e?e:[];o.push({name:i,value:r.value}),t.set(n,o)}}return t}setLayoutProperty(e,t,i={}){null!=t&&this._validate(no,`layers.${this.id}.layout.${e}`,e,t,i)||("visibility"!==e?this._unevaluatedLayout.setValue(e,t):this.visibility=t)}getPaintProperty(e){return e.endsWith(Ro)?this._transitionablePaint.getTransition(e.slice(0,-11)):this._transitionablePaint.getValue(e)}setPaintProperty(e,t,i={}){if(null!=t&&this._validate(ro,`layers.${this.id}.paint.${e}`,e,t,i))return!1;if(e.endsWith(Ro))return this._transitionablePaint.setTransition(e.slice(0,-11),t||void 0),!1;{const i=this._transitionablePaint._values[e],r="cross-faded-data-driven"===i.property.specification["property-type"],n=i.value.isDataDriven(),o=i.value;this._transitionablePaint.setValue(e,t),this._handleSpecialPaintPropertyUpdate(e);const s=this._transitionablePaint._values[e].value;return s.isDataDriven()||n||r||this._handleOverridablePaintPropertyUpdate(e,o,s)}}_handleSpecialPaintPropertyUpdate(e){}_handleOverridablePaintPropertyUpdate(e,t,i){return!1}isHidden(e,t=!1){return!!(this.minzoom&&e<(t?Math.floor(this.minzoom):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){e.getCrossfadeParameters&&(this._crossfadeParameters=e.getCrossfadeParameters()),this._unevaluatedLayout&&(this.layout=this._unevaluatedLayout.possiblyEvaluate(e,void 0,t)),this.paint=this._transitioningPaint.possiblyEvaluate(e,void 0,t)}serialize(){const e={id:this.id,type:this.type,source:this.source,"source-layer":this.sourceLayer,metadata:this.metadata,minzoom:this.minzoom,maxzoom:this.maxzoom,filter:this.filter,layout:this._unevaluatedLayout&&this._unevaluatedLayout.serialize(),paint:this._transitionablePaint&&this._transitionablePaint.serialize()};return this.visibility&&(e.layout=e.layout||{},e.layout.visibility=this.visibility),V(e,(e,t)=>!(void 0===e||"layout"===t&&!Object.keys(e).length||"paint"===t&&!Object.keys(e).length))}_validate(e,t,i,r,n={}){return(!n||!1!==n.validate)&&oo(this,e.call(eo,{key:t,layerType:this.type,objectKey:i,value:r,styleSpec:Ae,style:{glyphs:!0,sprite:!0}}))}is3D(){return!1}isTileClipped(){return!1}hasOffscreenPass(){return!1}resize(){}isStateDependent(){for(const e in this.paint._values){const t=this.paint.get(e);if(t instanceof Uo&&Vr(t.property.specification)&&("source"===t.value.kind||"composite"===t.value.kind)&&t.value.isStateDependent)return!0}return!1}}let Wo;var qo={get paint(){return Wo=Wo||new $o({"raster-opacity":new Vo(Ae.paint_raster["raster-opacity"]),"raster-hue-rotate":new Vo(Ae.paint_raster["raster-hue-rotate"]),"raster-brightness-min":new Vo(Ae.paint_raster["raster-brightness-min"]),"raster-brightness-max":new Vo(Ae.paint_raster["raster-brightness-max"]),"raster-saturation":new Vo(Ae.paint_raster["raster-saturation"]),"raster-contrast":new Vo(Ae.paint_raster["raster-contrast"]),"raster-resampling":new Vo(Ae.paint_raster["raster-resampling"]),"raster-fade-duration":new Vo(Ae.paint_raster["raster-fade-duration"])})}};class Ko extends Zo{constructor(e,t){super(e,qo,t)}}const Xo={Int8:Int8Array,Uint8:Uint8Array,Int16:Int16Array,Uint16:Uint16Array,Int32:Int32Array,Uint32:Uint32Array,Float32:Float32Array};class Jo{constructor(e,t){this._structArray=e,this._pos1=t*this.size,this._pos2=this._pos1/2,this._pos4=this._pos1/4,this._pos8=this._pos1/8}}class Yo{constructor(){this.isTransferred=!1,this.capacity=-1,this.resize(0)}static serialize(e,t){return e._trim(),t&&(e.isTransferred=!0,t.push(e.arrayBuffer)),{length:e.length,arrayBuffer:e.arrayBuffer}}static deserialize(e){const t=Object.create(this.prototype);return t.arrayBuffer=e.arrayBuffer,t.length=e.length,t.capacity=e.arrayBuffer.byteLength/t.bytesPerElement,t._refreshViews(),t}_trim(){this.length!==this.capacity&&(this.capacity=this.length,this.arrayBuffer=this.arrayBuffer.slice(0,this.length*this.bytesPerElement),this._refreshViews())}clear(){this.length=0}resize(e){this.reserve(e),this.length=e}reserve(e){if(e>this.capacity){this.capacity=Math.max(e,Math.floor(5*this.capacity),128),this.arrayBuffer=new ArrayBuffer(this.capacity*this.bytesPerElement);const t=this.uint8;this._refreshViews(),t&&this.uint8.set(t)}}_refreshViews(){throw new Error("_refreshViews() must be implemented by each concrete StructArray layout")}}function es(e,t=1){let i=0,r=0;return{members:e.map(e=>{const n=Xo[e.type].BYTES_PER_ELEMENT,o=i=ts(i,Math.max(t,n)),s=e.components||1;return r=Math.max(r,n),i+=n*s,{name:e.name,type:e.type,components:s,offset:o}}),size:ts(i,Math.max(r,t)),alignment:t}}function ts(e,t){return Math.ceil(e/t)*t}class is extends Yo{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer)}emplaceBack(e,t){const i=this.length;return this.resize(i+1),this.emplace(i,e,t)}emplace(e,t,i){const r=2*e;return this.int16[r+0]=t,this.int16[r+1]=i,e}}is.prototype.bytesPerElement=4,lo("StructArrayLayout2i4",is);class rs extends Yo{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer)}emplaceBack(e,t,i){const r=this.length;return this.resize(r+1),this.emplace(r,e,t,i)}emplace(e,t,i,r){const n=3*e;return this.int16[n+0]=t,this.int16[n+1]=i,this.int16[n+2]=r,e}}rs.prototype.bytesPerElement=6,lo("StructArrayLayout3i6",rs);class ns extends Yo{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer)}emplaceBack(e,t,i,r){const n=this.length;return this.resize(n+1),this.emplace(n,e,t,i,r)}emplace(e,t,i,r,n){const o=4*e;return this.int16[o+0]=t,this.int16[o+1]=i,this.int16[o+2]=r,this.int16[o+3]=n,e}}ns.prototype.bytesPerElement=8,lo("StructArrayLayout4i8",ns);class os extends Yo{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer)}emplaceBack(e,t,i,r,n,o){const s=this.length;return this.resize(s+1),this.emplace(s,e,t,i,r,n,o)}emplace(e,t,i,r,n,o,s){const a=6*e;return this.int16[a+0]=t,this.int16[a+1]=i,this.int16[a+2]=r,this.int16[a+3]=n,this.int16[a+4]=o,this.int16[a+5]=s,e}}os.prototype.bytesPerElement=12,lo("StructArrayLayout2i4i12",os);class ss extends Yo{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer)}emplaceBack(e,t,i,r,n,o){const s=this.length;return this.resize(s+1),this.emplace(s,e,t,i,r,n,o)}emplace(e,t,i,r,n,o,s){const a=4*e,l=8*e;return this.int16[a+0]=t,this.int16[a+1]=i,this.uint8[l+4]=r,this.uint8[l+5]=n,this.uint8[l+6]=o,this.uint8[l+7]=s,e}}ss.prototype.bytesPerElement=8,lo("StructArrayLayout2i4ub8",ss);class as extends Yo{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer)}emplaceBack(e,t){const i=this.length;return this.resize(i+1),this.emplace(i,e,t)}emplace(e,t,i){const r=2*e;return this.float32[r+0]=t,this.float32[r+1]=i,e}}as.prototype.bytesPerElement=8,lo("StructArrayLayout2f8",as);class ls extends Yo{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.uint16=new Uint16Array(this.arrayBuffer)}emplaceBack(e,t,i,r,n,o,s,a,l,c){const u=this.length;return this.resize(u+1),this.emplace(u,e,t,i,r,n,o,s,a,l,c)}emplace(e,t,i,r,n,o,s,a,l,c,u){const h=10*e;return this.uint16[h+0]=t,this.uint16[h+1]=i,this.uint16[h+2]=r,this.uint16[h+3]=n,this.uint16[h+4]=o,this.uint16[h+5]=s,this.uint16[h+6]=a,this.uint16[h+7]=l,this.uint16[h+8]=c,this.uint16[h+9]=u,e}}ls.prototype.bytesPerElement=20,lo("StructArrayLayout10ui20",ls);class cs extends Yo{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.uint16=new Uint16Array(this.arrayBuffer)}emplaceBack(e,t,i,r,n,o,s,a){const l=this.length;return this.resize(l+1),this.emplace(l,e,t,i,r,n,o,s,a)}emplace(e,t,i,r,n,o,s,a,l){const c=8*e;return this.uint16[c+0]=t,this.uint16[c+1]=i,this.uint16[c+2]=r,this.uint16[c+3]=n,this.uint16[c+4]=o,this.uint16[c+5]=s,this.uint16[c+6]=a,this.uint16[c+7]=l,e}}cs.prototype.bytesPerElement=16,lo("StructArrayLayout8ui16",cs);class us extends Yo{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer),this.uint16=new Uint16Array(this.arrayBuffer)}emplaceBack(e,t,i,r,n,o,s,a,l,c,u,h){const d=this.length;return this.resize(d+1),this.emplace(d,e,t,i,r,n,o,s,a,l,c,u,h)}emplace(e,t,i,r,n,o,s,a,l,c,u,h,d){const p=12*e;return this.int16[p+0]=t,this.int16[p+1]=i,this.int16[p+2]=r,this.int16[p+3]=n,this.uint16[p+4]=o,this.uint16[p+5]=s,this.uint16[p+6]=a,this.uint16[p+7]=l,this.int16[p+8]=c,this.int16[p+9]=u,this.int16[p+10]=h,this.int16[p+11]=d,e}}us.prototype.bytesPerElement=24,lo("StructArrayLayout4i4ui4i24",us);class hs extends Yo{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer)}emplaceBack(e,t,i){const r=this.length;return this.resize(r+1),this.emplace(r,e,t,i)}emplace(e,t,i,r){const n=3*e;return this.float32[n+0]=t,this.float32[n+1]=i,this.float32[n+2]=r,e}}hs.prototype.bytesPerElement=12,lo("StructArrayLayout3f12",hs);class ds extends Yo{_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}}ds.prototype.bytesPerElement=4,lo("StructArrayLayout1ul4",ds);class ps extends Yo{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer),this.uint32=new Uint32Array(this.arrayBuffer),this.uint16=new Uint16Array(this.arrayBuffer)}emplaceBack(e,t,i,r,n,o,s,a,l){const c=this.length;return this.resize(c+1),this.emplace(c,e,t,i,r,n,o,s,a,l)}emplace(e,t,i,r,n,o,s,a,l,c){const u=10*e,h=5*e;return this.int16[u+0]=t,this.int16[u+1]=i,this.int16[u+2]=r,this.int16[u+3]=n,this.int16[u+4]=o,this.int16[u+5]=s,this.uint32[h+3]=a,this.uint16[u+8]=l,this.uint16[u+9]=c,e}}ps.prototype.bytesPerElement=20,lo("StructArrayLayout6i1ul2ui20",ps);class fs extends Yo{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer)}emplaceBack(e,t,i,r,n,o){const s=this.length;return this.resize(s+1),this.emplace(s,e,t,i,r,n,o)}emplace(e,t,i,r,n,o,s){const a=6*e;return this.int16[a+0]=t,this.int16[a+1]=i,this.int16[a+2]=r,this.int16[a+3]=n,this.int16[a+4]=o,this.int16[a+5]=s,e}}fs.prototype.bytesPerElement=12,lo("StructArrayLayout2i2i2i12",fs);class ms extends Yo{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer)}emplaceBack(e,t,i,r,n){const o=this.length;return this.resize(o+1),this.emplace(o,e,t,i,r,n)}emplace(e,t,i,r,n,o){const s=4*e,a=8*e;return this.float32[s+0]=t,this.float32[s+1]=i,this.float32[s+2]=r,this.int16[a+6]=n,this.int16[a+7]=o,e}}ms.prototype.bytesPerElement=16,lo("StructArrayLayout2f1f2i16",ms);class gs extends Yo{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer)}emplaceBack(e,t,i,r,n,o){const s=this.length;return this.resize(s+1),this.emplace(s,e,t,i,r,n,o)}emplace(e,t,i,r,n,o,s){const a=16*e,l=4*e,c=8*e;return this.uint8[a+0]=t,this.uint8[a+1]=i,this.float32[l+1]=r,this.float32[l+2]=n,this.int16[c+6]=o,this.int16[c+7]=s,e}}gs.prototype.bytesPerElement=16,lo("StructArrayLayout2ub2f2i16",gs);class _s extends Yo{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.uint16=new Uint16Array(this.arrayBuffer)}emplaceBack(e,t,i){const r=this.length;return this.resize(r+1),this.emplace(r,e,t,i)}emplace(e,t,i,r){const n=3*e;return this.uint16[n+0]=t,this.uint16[n+1]=i,this.uint16[n+2]=r,e}}_s.prototype.bytesPerElement=6,lo("StructArrayLayout3ui6",_s);class As extends Yo{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer),this.uint16=new Uint16Array(this.arrayBuffer),this.uint32=new Uint32Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer)}emplaceBack(e,t,i,r,n,o,s,a,l,c,u,h,d,p,f,m,g){const _=this.length;return this.resize(_+1),this.emplace(_,e,t,i,r,n,o,s,a,l,c,u,h,d,p,f,m,g)}emplace(e,t,i,r,n,o,s,a,l,c,u,h,d,p,f,m,g,_){const A=24*e,y=12*e,v=48*e;return this.int16[A+0]=t,this.int16[A+1]=i,this.uint16[A+2]=r,this.uint16[A+3]=n,this.uint32[y+2]=o,this.uint32[y+3]=s,this.uint32[y+4]=a,this.uint16[A+10]=l,this.uint16[A+11]=c,this.uint16[A+12]=u,this.float32[y+7]=h,this.float32[y+8]=d,this.uint8[v+36]=p,this.uint8[v+37]=f,this.uint8[v+38]=m,this.uint32[y+10]=g,this.int16[A+22]=_,e}}As.prototype.bytesPerElement=48,lo("StructArrayLayout2i2ui3ul3ui2f3ub1ul1i48",As);class ys extends Yo{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer),this.uint16=new Uint16Array(this.arrayBuffer),this.uint32=new Uint32Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer)}emplaceBack(e,t,i,r,n,o,s,a,l,c,u,h,d,p,f,m,g,_,A,y,v,x,b,w,T,E,C,B){const S=this.length;return this.resize(S+1),this.emplace(S,e,t,i,r,n,o,s,a,l,c,u,h,d,p,f,m,g,_,A,y,v,x,b,w,T,E,C,B)}emplace(e,t,i,r,n,o,s,a,l,c,u,h,d,p,f,m,g,_,A,y,v,x,b,w,T,E,C,B,S){const I=32*e,M=16*e;return this.int16[I+0]=t,this.int16[I+1]=i,this.int16[I+2]=r,this.int16[I+3]=n,this.int16[I+4]=o,this.int16[I+5]=s,this.int16[I+6]=a,this.int16[I+7]=l,this.uint16[I+8]=c,this.uint16[I+9]=u,this.uint16[I+10]=h,this.uint16[I+11]=d,this.uint16[I+12]=p,this.uint16[I+13]=f,this.uint16[I+14]=m,this.uint16[I+15]=g,this.uint16[I+16]=_,this.uint16[I+17]=A,this.uint16[I+18]=y,this.uint16[I+19]=v,this.uint16[I+20]=x,this.uint16[I+21]=b,this.uint16[I+22]=w,this.uint32[M+12]=T,this.float32[M+13]=E,this.float32[M+14]=C,this.uint16[I+30]=B,this.uint16[I+31]=S,e}}ys.prototype.bytesPerElement=64,lo("StructArrayLayout8i15ui1ul2f2ui64",ys);class vs extends Yo{_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}}vs.prototype.bytesPerElement=4,lo("StructArrayLayout1f4",vs);class xs extends Yo{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.uint16=new Uint16Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer)}emplaceBack(e,t,i){const r=this.length;return this.resize(r+1),this.emplace(r,e,t,i)}emplace(e,t,i,r){const n=3*e;return this.uint16[6*e+0]=t,this.float32[n+1]=i,this.float32[n+2]=r,e}}xs.prototype.bytesPerElement=12,lo("StructArrayLayout1ui2f12",xs);class bs extends Yo{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.uint32=new Uint32Array(this.arrayBuffer),this.uint16=new Uint16Array(this.arrayBuffer)}emplaceBack(e,t,i){const r=this.length;return this.resize(r+1),this.emplace(r,e,t,i)}emplace(e,t,i,r){const n=4*e;return this.uint32[2*e+0]=t,this.uint16[n+2]=i,this.uint16[n+3]=r,e}}bs.prototype.bytesPerElement=8,lo("StructArrayLayout1ul2ui8",bs);class ws extends Yo{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.uint16=new Uint16Array(this.arrayBuffer)}emplaceBack(e,t){const i=this.length;return this.resize(i+1),this.emplace(i,e,t)}emplace(e,t,i){const r=2*e;return this.uint16[r+0]=t,this.uint16[r+1]=i,e}}ws.prototype.bytesPerElement=4,lo("StructArrayLayout2ui4",ws);class Ts extends Yo{_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}}Ts.prototype.bytesPerElement=2,lo("StructArrayLayout1ui2",Ts);class Es extends Yo{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer)}emplaceBack(e,t,i,r){const n=this.length;return this.resize(n+1),this.emplace(n,e,t,i,r)}emplace(e,t,i,r,n){const o=4*e;return this.float32[o+0]=t,this.float32[o+1]=i,this.float32[o+2]=r,this.float32[o+3]=n,e}}Es.prototype.bytesPerElement=16,lo("StructArrayLayout4f16",Es);class Cs extends Jo{get anchorPointX(){return this._structArray.int16[this._pos2+0]}get anchorPointY(){return this._structArray.int16[this._pos2+1]}get x1(){return this._structArray.int16[this._pos2+2]}get y1(){return this._structArray.int16[this._pos2+3]}get x2(){return this._structArray.int16[this._pos2+4]}get y2(){return this._structArray.int16[this._pos2+5]}get featureIndex(){return this._structArray.uint32[this._pos4+3]}get sourceLayerIndex(){return this._structArray.uint16[this._pos2+8]}get bucketIndex(){return this._structArray.uint16[this._pos2+9]}get anchorPoint(){return new i(this.anchorPointX,this.anchorPointY)}}Cs.prototype.size=20;class Bs extends ps{get(e){return new Cs(this,e)}}lo("CollisionBoxArray",Bs);class Ss extends Jo{get anchorX(){return this._structArray.int16[this._pos2+0]}get anchorY(){return this._structArray.int16[this._pos2+1]}get glyphStartIndex(){return this._structArray.uint16[this._pos2+2]}get numGlyphs(){return this._structArray.uint16[this._pos2+3]}get vertexStartIndex(){return this._structArray.uint32[this._pos4+2]}get lineStartIndex(){return this._structArray.uint32[this._pos4+3]}get lineLength(){return this._structArray.uint32[this._pos4+4]}get segment(){return this._structArray.uint16[this._pos2+10]}get lowerSize(){return this._structArray.uint16[this._pos2+11]}get upperSize(){return this._structArray.uint16[this._pos2+12]}get lineOffsetX(){return this._structArray.float32[this._pos4+7]}get lineOffsetY(){return this._structArray.float32[this._pos4+8]}get writingMode(){return this._structArray.uint8[this._pos1+36]}get placedOrientation(){return this._structArray.uint8[this._pos1+37]}set placedOrientation(e){this._structArray.uint8[this._pos1+37]=e}get hidden(){return this._structArray.uint8[this._pos1+38]}set hidden(e){this._structArray.uint8[this._pos1+38]=e}get crossTileID(){return this._structArray.uint32[this._pos4+10]}set crossTileID(e){this._structArray.uint32[this._pos4+10]=e}get associatedIconIndex(){return this._structArray.int16[this._pos2+22]}}Ss.prototype.size=48;class Is extends As{get(e){return new Ss(this,e)}}lo("PlacedSymbolArray",Is);class Ms extends Jo{get anchorX(){return this._structArray.int16[this._pos2+0]}get anchorY(){return this._structArray.int16[this._pos2+1]}get rightJustifiedTextSymbolIndex(){return this._structArray.int16[this._pos2+2]}get centerJustifiedTextSymbolIndex(){return this._structArray.int16[this._pos2+3]}get leftJustifiedTextSymbolIndex(){return this._structArray.int16[this._pos2+4]}get verticalPlacedTextSymbolIndex(){return this._structArray.int16[this._pos2+5]}get placedIconSymbolIndex(){return this._structArray.int16[this._pos2+6]}get verticalPlacedIconSymbolIndex(){return this._structArray.int16[this._pos2+7]}get key(){return this._structArray.uint16[this._pos2+8]}get textBoxStartIndex(){return this._structArray.uint16[this._pos2+9]}get textBoxEndIndex(){return this._structArray.uint16[this._pos2+10]}get verticalTextBoxStartIndex(){return this._structArray.uint16[this._pos2+11]}get verticalTextBoxEndIndex(){return this._structArray.uint16[this._pos2+12]}get iconBoxStartIndex(){return this._structArray.uint16[this._pos2+13]}get iconBoxEndIndex(){return this._structArray.uint16[this._pos2+14]}get verticalIconBoxStartIndex(){return this._structArray.uint16[this._pos2+15]}get verticalIconBoxEndIndex(){return this._structArray.uint16[this._pos2+16]}get featureIndex(){return this._structArray.uint16[this._pos2+17]}get numHorizontalGlyphVertices(){return this._structArray.uint16[this._pos2+18]}get numVerticalGlyphVertices(){return this._structArray.uint16[this._pos2+19]}get numIconVertices(){return this._structArray.uint16[this._pos2+20]}get numVerticalIconVertices(){return this._structArray.uint16[this._pos2+21]}get useRuntimeCollisionCircles(){return this._structArray.uint16[this._pos2+22]}get crossTileID(){return this._structArray.uint32[this._pos4+12]}set crossTileID(e){this._structArray.uint32[this._pos4+12]=e}get textBoxScale(){return this._structArray.float32[this._pos4+13]}get collisionCircleDiameter(){return this._structArray.float32[this._pos4+14]}get textAnchorOffsetStartIndex(){return this._structArray.uint16[this._pos2+30]}get textAnchorOffsetEndIndex(){return this._structArray.uint16[this._pos2+31]}}Ms.prototype.size=64;class Ps extends ys{get(e){return new Ms(this,e)}}lo("SymbolInstanceArray",Ps);class Rs extends vs{getoffsetX(e){return this.float32[1*e+0]}}lo("GlyphOffsetArray",Rs);class Ls extends rs{getx(e){return this.int16[3*e+0]}gety(e){return this.int16[3*e+1]}gettileUnitDistanceFromAnchor(e){return this.int16[3*e+2]}}lo("SymbolLineVertexArray",Ls);class Fs extends Jo{get textAnchor(){return this._structArray.uint16[this._pos2+0]}get textOffset0(){return this._structArray.float32[this._pos4+1]}get textOffset1(){return this._structArray.float32[this._pos4+2]}}Fs.prototype.size=12;class ks extends xs{get(e){return new Fs(this,e)}}lo("TextAnchorOffsetArray",ks);class Ds extends Jo{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]}}Ds.prototype.size=8;class Os extends bs{get(e){return new Ds(this,e)}}lo("FeatureIndexArray",Os);class zs extends is{}class Us extends is{}class Ns extends is{}class Vs extends os{}class js extends ss{}class Gs extends as{}class Hs extends ls{}class Qs extends cs{}class $s extends us{}class Zs extends hs{}class Ws extends ds{}class qs extends fs{}class Ks extends gs{}class Xs extends _s{}class Js extends ws{}const Ys=es([{name:"a_pos",components:2,type:"Int16"}],4),{members:ea}=Ys;class ta{constructor(e=[]){this._forceNewSegmentOnNextPrepare=!1,this.segments=e}prepareSegment(e,t,i,r){const n=this.segments[this.segments.length-1];return e>ta.MAX_VERTEX_ARRAY_LENGTH&&H(`Max vertices per segment is ${ta.MAX_VERTEX_ARRAY_LENGTH}: bucket requested ${e}. Consider using the \`fillLargeMeshArrays\` function if you require meshes with more than ${ta.MAX_VERTEX_ARRAY_LENGTH} vertices.`),this._forceNewSegmentOnNextPrepare||!n||n.vertexLength+e>ta.MAX_VERTEX_ARRAY_LENGTH||n.sortKey!==r?this.createNewSegment(t,i,r):n}createNewSegment(e,t,i){const r={vertexOffset:e.length,primitiveOffset:t.length,vertexLength:0,primitiveLength:0,vaos:{}};return void 0!==i&&(r.sortKey=i),this._forceNewSegmentOnNextPrepare=!1,this.segments.push(r),r}getOrCreateLatestSegment(e,t,i){return this.prepareSegment(0,e,t,i)}forceNewSegmentOnNextPrepare(){this._forceNewSegmentOnNextPrepare=!0}get(){return this.segments}destroy(){for(const e of this.segments)for(const t in e.vaos)e.vaos[t].destroy()}static simpleSegment(e,t,i,r){return new ta([{vertexOffset:e,primitiveOffset:t,vertexLength:i,primitiveLength:r,vaos:{},sortKey:0}])}}function ia(e,t){return 256*(e=D(Math.floor(e),0,255))+D(Math.floor(t),0,255)}ta.MAX_VERTEX_ARRAY_LENGTH=Math.pow(2,16)-1,lo("SegmentVector",ta);const ra=es([{name:"a_pattern_from",components:4,type:"Uint16"},{name:"a_pattern_to",components:4,type:"Uint16"},{name:"a_pixel_ratio_from",components:1,type:"Uint16"},{name:"a_pixel_ratio_to",components:1,type:"Uint16"}]),na=es([{name:"a_dasharray_from",components:4,type:"Uint16"},{name:"a_dasharray_to",components:4,type:"Uint16"}]);var oa,sa,aa,la={exports:{}},ca={exports:{}},ua={exports:{}},ha=function(){if(aa)return la.exports;aa=1;var e=(oa||(oa=1,ca.exports=function(e,t){var i,r,n,o,s,a,l,c;for(r=e.length-(i=3&e.length),n=t,s=3432918353,a=461845907,c=0;c>>16)*s&65535)<<16)&4294967295)<<15|l>>>17))*a+(((l>>>16)*a&65535)<<16)&4294967295)<<13|n>>>19))+((5*(n>>>16)&65535)<<16)&4294967295))+((58964+(o>>>16)&65535)<<16);switch(l=0,i){case 3:l^=(255&e.charCodeAt(c+2))<<16;case 2:l^=(255&e.charCodeAt(c+1))<<8;case 1:n^=l=(65535&(l=(l=(65535&(l^=255&e.charCodeAt(c)))*s+(((l>>>16)*s&65535)<<16)&4294967295)<<15|l>>>17))*a+(((l>>>16)*a&65535)<<16)&4294967295}return n^=e.length,n=2246822507*(65535&(n^=n>>>16))+((2246822507*(n>>>16)&65535)<<16)&4294967295,n=3266489909*(65535&(n^=n>>>13))+((3266489909*(n>>>16)&65535)<<16)&4294967295,(n^=n>>>16)>>>0}),ca.exports),t=(sa||(sa=1,ua.exports=function(e,t){for(var i,r=e.length,n=t^r,o=0;r>=4;)i=1540483477*(65535&(i=255&e.charCodeAt(o)|(255&e.charCodeAt(++o))<<8|(255&e.charCodeAt(++o))<<16|(255&e.charCodeAt(++o))<<24))+((1540483477*(i>>>16)&65535)<<16),n=1540483477*(65535&n)+((1540483477*(n>>>16)&65535)<<16)^(i=1540483477*(65535&(i^=i>>>24))+((1540483477*(i>>>16)&65535)<<16)),r-=4,++o;switch(r){case 3:n^=(255&e.charCodeAt(o+2))<<16;case 2:n^=(255&e.charCodeAt(o+1))<<8;case 1:n=1540483477*(65535&(n^=255&e.charCodeAt(o)))+((1540483477*(n>>>16)&65535)<<16)}return n=1540483477*(65535&(n^=n>>>13))+((1540483477*(n>>>16)&65535)<<16),(n^=n>>>15)>>>0}),ua.exports);return la.exports=e,la.exports.murmur3=e,la.exports.murmur2=t,la.exports}(),da=r(ha);class pa{constructor(){this.ids=[],this.positions=[],this.indexed=!1}add(e,t,i,r){this.ids.push(fa(e)),this.positions.push(t,i,r)}getPositions(e){if(!this.indexed)throw new Error("Trying to get index, but feature positions are not indexed");const t=fa(e);let i=0,r=this.ids.length-1;for(;i>1;this.ids[e]>=t?r=e:i=e+1}const n=[];for(;this.ids[i]===t;)n.push({index:this.positions[3*i],start:this.positions[3*i+1],end:this.positions[3*i+2]}),i++;return n}static serialize(e,t){const i=new Float64Array(e.ids),r=new Uint32Array(e.positions);return ma(i,r,0,i.length-1),t&&t.push(i.buffer,r.buffer),{ids:i,positions:r}}static deserialize(e){const t=new pa;return t.ids=e.ids,t.positions=e.positions,t.indexed=!0,t}}function fa(e){const t=+e;return!isNaN(t)&&t<=Number.MAX_SAFE_INTEGER?t:da(String(e))}function ma(e,t,i,r){for(;i>1];let o=i-1,s=r+1;for(;;){do{o++}while(e[o]n);if(o>=s)break;ga(e,o,s),ga(t,3*o,3*s),ga(t,3*o+1,3*s+1),ga(t,3*o+2,3*s+2)}s-i`u_${e}`),this.type=i}setUniform(e,t,i){e.set(i.constantOr(this.value))}getBinding(e,t,i){return"color"===this.type?new va(e,t):new Aa(e,t)}}class Ta{constructor(e,t){this.uniformNames=t.map(e=>`u_${e}`),this.patternFrom=null,this.patternTo=null,this.pixelRatioFrom=1,this.pixelRatioTo=1}setConstantPatternPositions(e,t){this.pixelRatioFrom=t.pixelRatio,this.pixelRatioTo=e.pixelRatio,this.patternFrom=t.tlbr,this.patternTo=e.tlbr}setConstantDashPositions(e,t){this.dashTo=[0,e.y,e.height,e.width],this.dashFrom=[0,t.y,t.height,t.width]}setUniform(e,t,i,r){let n=null;"u_pattern_to"===r?n=this.patternTo:"u_pattern_from"===r?n=this.patternFrom:"u_dasharray_to"===r?n=this.dashTo:"u_dasharray_from"===r?n=this.dashFrom:"u_pixel_ratio_to"===r?n=this.pixelRatioTo:"u_pixel_ratio_from"===r&&(n=this.pixelRatioFrom),null!==n&&e.set(n)}getBinding(e,t,i){return"u_pattern"===i.substr(0,9)||"u_dasharray_"===i.substr(0,12)?new ya(e,t):new Aa(e,t)}}class Ea{constructor(e,t,i,r){this.expression=e,this.type=i,this.maxValue=0,this.paintVertexAttributes=t.map(e=>({name:`a_${e}`,type:"Float32",components:"color"===i?2:1,offset:0})),this.paintVertexArray=new r}populatePaintArray(e,t,i){const r=this.paintVertexArray.length,n=this.expression.evaluate(new Mo(0,i),t,{},i.canonical,[],i.formattedSection);this.paintVertexArray.resize(e),this._setPaintValue(r,e,n)}updatePaintArray(e,t,i,r,n){const o=this.expression.evaluate(new Mo(0,n),i,r);this._setPaintValue(e,t,o)}_setPaintValue(e,t,i){if("color"===this.type){const r=ba(i);for(let i=e;i`u_${e}_t`),this.type=i,this.useIntegerZoom=r,this.zoom=n,this.maxValue=0,this.paintVertexAttributes=t.map(e=>({name:`a_${e}`,type:"Float32",components:"color"===i?4:2,offset:0})),this.paintVertexArray=new o}populatePaintArray(e,t,i){const r=this.expression.evaluate(new Mo(this.zoom,i),t,{},i.canonical,[],i.formattedSection),n=this.expression.evaluate(new Mo(this.zoom+1,i),t,{},i.canonical,[],i.formattedSection),o=this.paintVertexArray.length;this.paintVertexArray.resize(e),this._setPaintValue(o,e,r,n)}updatePaintArray(e,t,i,r,n){const o=this.expression.evaluate(new Mo(this.zoom,n),i,r),s=this.expression.evaluate(new Mo(this.zoom+1,n),i,r);this._setPaintValue(e,t,o,s)}_setPaintValue(e,t,i,r){if("color"===this.type){const n=ba(i),o=ba(r);for(let i=e;i`#define HAS_UNIFORM_${e}`))}return e}getBinderAttributes(){const e=[];for(const t in this.binders){const i=this.binders[t];if(i instanceof Ea||i instanceof Ca)for(let t=0;t!0){this.programConfigurations={};for(const r of e)this.programConfigurations[r.id]=new Ma(r,t,i);this.needsUpload=!1,this._featureMap=new pa,this._bufferOffset=0}populatePaintArrays(e,t,i,r){for(const i in this.programConfigurations)this.programConfigurations[i].populatePaintArrays(e,t,r);void 0!==t.id&&this._featureMap.add(t.id,i,this._bufferOffset,e),this._bufferOffset=e,this.needsUpload=!0}updatePaintArrays(e,t,i,r){for(const n of i)this.needsUpload=this.programConfigurations[n.id].updatePaintArrays(e,this._featureMap,t,n,r)||this.needsUpload}get(e){return this.programConfigurations[e]}upload(e){if(this.needsUpload){for(const t in this.programConfigurations)this.programConfigurations[t].upload(e);this.needsUpload=!1}}destroy(){for(const e in this.programConfigurations)this.programConfigurations[e].destroy()}}function Ra(e,t){return{"text-opacity":["opacity"],"icon-opacity":["opacity"],"text-color":["fill_color"],"icon-color":["fill_color"],"text-halo-color":["halo_color"],"icon-halo-color":["halo_color"],"text-halo-blur":["halo_blur"],"icon-halo-blur":["halo_blur"],"text-halo-width":["halo_width"],"icon-halo-width":["halo_width"],"line-gap-width":["gapwidth"],"line-dasharray":["dasharray_to","dasharray_from"],"line-pattern":["pattern_to","pattern_from","pixel_ratio_to","pixel_ratio_from"],"fill-pattern":["pattern_to","pattern_from","pixel_ratio_to","pixel_ratio_from"],"fill-extrusion-pattern":["pattern_to","pattern_from","pixel_ratio_to","pixel_ratio_from"]}[e]||[e.replace(`${t}-`,"").replace(/-/g,"_")]}function La(e,t,i){const r={color:{source:as,composite:Es},number:{source:vs,composite:as}},n=function(e){return{"line-pattern":{source:Hs,composite:Hs},"fill-pattern":{source:Hs,composite:Hs},"fill-extrusion-pattern":{source:Hs,composite:Hs},"line-dasharray":{source:Qs,composite:Qs}}[e]}(e);return n&&n[i]||r[t][i]}lo("ConstantBinder",wa),lo("CrossFadedConstantBinder",Ta),lo("SourceExpressionBinder",Ea),lo("CrossFadedPatternBinder",Sa),lo("CrossFadedDasharrayBinder",Ia),lo("CompositeExpressionBinder",Ca),lo("ProgramConfiguration",Ma,{omit:["_buffers"]}),lo("ProgramConfigurationSet",Pa);const Fa=Math.pow(2,14)-1,ka=-Fa-1;function Da(e){const t=I/e.extent,i=e.loadGeometry();for(let e=0;ei.x+1||oi.y+1)&&H("Geometry exceeds allowed extent, reduce your vector tile buffer size")}}return i}function Oa(e,t){return{type:e.type,id:e.id,properties:e.properties,geometry:t?Da(e):[]}}const za=-32768;function Ua(e,t,i,r,n){e.emplaceBack(za+8*t+r,za+8*i+n)}class Na{constructor(e){this.zoom=e.zoom,this.overscaling=e.overscaling,this.layers=e.layers,this.layerIds=this.layers.map(e=>e.id),this.index=e.index,this.hasDependencies=!1,this.layoutVertexArray=new Us,this.indexArray=new Xs,this.segments=new ta,this.programConfigurations=new Pa(e.layers,e.zoom),this.stateDependentLayerIds=this.layers.filter(e=>e.isStateDependent()).map(e=>e.id)}populate(e,t,i){const r=this.layers[0],n=[];let o=null,s=!1,a="heatmap"===r.type;if("circle"===r.type){const e=r;o=e.layout.get("circle-sort-key"),s=!o.isConstant(),a=a||"map"===e.paint.get("circle-pitch-alignment")}const l=a?t.subdivisionGranularity.circle:1;for(const{feature:t,id:r,index:a,sourceLayerIndex:l}of e){const e=this.layers[0]._featureFilter.needGeometry,c=Oa(t,e);if(!this.layers[0]._featureFilter.filter(new Mo(this.zoom),c,i))continue;const u=s?o.evaluate(c,{},i):void 0,h={id:r,properties:t.properties,type:t.type,sourceLayerIndex:l,index:a,geometry:e?c.geometry:Da(t),patterns:{},sortKey:u};n.push(h)}s&&n.sort((e,t)=>e.sortKey-t.sortKey);for(const r of n){const{geometry:n,index:o,sourceLayerIndex:s}=r,a=e[o].feature;this.addFeature(r,n,o,i,l),t.featureIndex.insert(a,n,o,s,this.index)}}update(e,t,i){this.stateDependentLayers.length&&this.programConfigurations.updatePaintArrays(e,t,this.stateDependentLayers,{imagePositions:i})}isEmpty(){return 0===this.layoutVertexArray.length}uploadPending(){return!this.uploaded||this.programConfigurations.needsUpload}upload(e){this.uploaded||(this.layoutVertexBuffer=e.createVertexBuffer(this.layoutVertexArray,ea),this.indexBuffer=e.createIndexBuffer(this.indexArray)),this.programConfigurations.upload(e),this.uploaded=!0}destroy(){this.layoutVertexBuffer&&(this.layoutVertexBuffer.destroy(),this.indexBuffer.destroy(),this.programConfigurations.destroy(),this.segments.destroy())}addFeature(e,t,i,r,n=1){let o;switch(n){case 1:o=[0,7];break;case 3:o=[0,2,5,7];break;case 5:o=[0,1,3,4,6,7];break;case 7:o=[0,1,2,3,4,5,6,7];break;default:throw new Error(`Invalid circle bucket granularity: ${n}; valid values are 1, 3, 5, 7.`)}const s=o.length;for(const i of t)for(const t of i){const i=t.x,r=t.y;if(i<0||i>=I||r<0||r>=I)continue;const n=this.segments.prepareSegment(s*s,this.layoutVertexArray,this.indexArray,e.sortKey),a=n.vertexLength;for(let e=0;e1){if(Qa(e,t))return!0;for(let r=0;r1?i:i.sub(t)._mult(n)._add(t))}function qa(e,t){let i,r,n,o=!1;for(let s=0;st.y!=n.y>t.y&&t.x<(n.x-r.x)*(t.y-r.y)/(n.y-r.y)+r.x&&(o=!o)}return o}function Ka(e,t){let i=!1;for(let r=0,n=e.length-1;rt.y!=s.y>t.y&&t.x<(s.x-o.x)*(t.y-o.y)/(s.y-o.y)+o.x&&(i=!i)}return i}function Xa(e,t,i){const r=i[0],n=i[2];if(e.xn.x&&t.x>n.x||e.yn.y&&t.y>n.y)return!1;const o=Q(e,t,i[0]);return o!==Q(e,t,i[1])||o!==Q(e,t,i[2])||o!==Q(e,t,i[3])}function Ja(e,t,i){const r=t.paint.get(e).value;return"constant"===r.kind?r.value:i.programConfigurations.get(t.id).getMaxValue(e)}function Ya(e){return Math.sqrt(e[0]*e[0]+e[1]*e[1])}function el(e,t,r,n,o){if(!t[0]&&!t[1])return e;const s=i.convert(t)._mult(o);"viewport"===r&&s._rotate(-n);const a=[];for(let t=0;tsl(e,t,i,r))}(l,n,s,a),p=c),ol({queryGeometry:d,size:p,transform:n,unwrappedTileID:s,getElevation:a,pitchAlignment:h,pitchScale:u},r)}}class hl extends Na{}let dl;lo("HeatmapBucket",hl,{omit:["layers"]});var pl={get paint(){return dl=dl||new $o({"heatmap-radius":new jo(Ae.paint_heatmap["heatmap-radius"]),"heatmap-weight":new jo(Ae.paint_heatmap["heatmap-weight"]),"heatmap-intensity":new Vo(Ae.paint_heatmap["heatmap-intensity"]),"heatmap-color":new Qo(Ae.paint_heatmap["heatmap-color"]),"heatmap-opacity":new Vo(Ae.paint_heatmap["heatmap-opacity"])})}};function fl(e,{width:t,height:i},r,n){if(n){if(n instanceof Uint8ClampedArray)n=new Uint8Array(n.buffer);else if(n.length!==t*i*r)throw new RangeError(`mismatched image size. expected: ${n.length} but got: ${t*i*r}`)}else n=new Uint8Array(t*i*r);return e.width=t,e.height=i,e.data=n,e}function ml(e,{width:t,height:i},r){if(t===e.width&&i===e.height)return;const n=fl({},{width:t,height:i},r);gl(e,n,{x:0,y:0},{x:0,y:0},{width:Math.min(e.width,t),height:Math.min(e.height,i)},r),e.width=t,e.height=i,e.data=n.data}function gl(e,t,i,r,n,o){if(0===n.width||0===n.height)return t;if(n.width>e.width||n.height>e.height||i.x>e.width-n.width||i.y>e.height-n.height)throw new RangeError("out of range source coordinates for image copy");if(n.width>t.width||n.height>t.height||r.x>t.width-n.width||r.y>t.height-n.height)throw new RangeError("out of range destination coordinates for image copy");const s=e.data,a=t.data;if(s===a)throw new Error("srcData equals dstData, so image is already copied");for(let l=0;l{t[e.evaluationKey]=s;const a=e.expression.evaluate(t);n.setPixel(r/4/i,o/4,a)};if(e.clips)for(let t=0,n=0;tthis.max&&(this.max=i),i=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)}unpack(e,t,i){return e*this.redFactor+t*this.greenFactor+i*this.blueFactor-this.baseShift}pack(e){return Il(e,this.getUnpackVector())}getPixels(){return new Al({width:this.stride,height:this.stride},new Uint8Array(this.data.buffer))}backfillBorder(e,t,i){if(this.dim!==e.dim)throw new Error("dem dimension mismatch");let r=t*this.dim,n=t*this.dim+this.dim,o=i*this.dim,s=i*this.dim+this.dim;switch(t){case-1:r=n-1;break;case 1:n=r+1}switch(i){case-1:o=s-1;break;case 1:s=o+1}const a=-t*this.dim,l=-i*this.dim;for(let t=o;t0)for(let n=t;n=t;n-=r)o=rc(n/r|0,e[n],e[n+1],o);return o&&Xl(o,o.next)&&(nc(o),o=o.next),o}function Dl(e,t){if(!e)return e;t||(t=e);let i,r=e;do{if(i=!1,r.steiner||!Xl(r,r.next)&&0!==Kl(r.prev,r,r.next))r=r.next;else{if(nc(r),r=t=r.prev,r===r.next)break;i=!0}}while(i||r!==t);return t}function Ol(e,t,i,r,n,o,s){if(!e)return;!s&&o&&function(e,t,i,r){let n=e;do{0===n.z&&(n.z=Ql(n.x,n.y,t,i,r)),n.prevZ=n.prev,n.nextZ=n.next,n=n.next}while(n!==e);n.prevZ.nextZ=null,n.prevZ=null,function(e){let t,i=1;do{let r,n=e;e=null;let o=null;for(t=0;n;){t++;let s=n,a=0;for(let e=0;e0||l>0&&s;)0!==a&&(0===l||!s||n.z<=s.z)?(r=n,n=n.nextZ,a--):(r=s,s=s.nextZ,l--),o?o.nextZ=r:e=r,r.prevZ=o,o=r;n=s}o.nextZ=null,i*=2}while(t>1)}(n)}(e,r,n,o);let a=e;for(;e.prev!==e.next;){const l=e.prev,c=e.next;if(o?Ul(e,r,n,o):zl(e))t.push(l.i,e.i,c.i),nc(e),e=c.next,a=c.next;else if((e=c)===a){s?1===s?Ol(e=Nl(Dl(e),t),t,i,r,n,o,2):2===s&&Vl(e,t,i,r,n,o):Ol(Dl(e),t,i,r,n,o,1);break}}}function zl(e){const t=e.prev,i=e,r=e.next;if(Kl(t,i,r)>=0)return!1;const n=t.x,o=i.x,s=r.x,a=t.y,l=i.y,c=r.y,u=Math.min(n,o,s),h=Math.min(a,l,c),d=Math.max(n,o,s),p=Math.max(a,l,c);let f=r.next;for(;f!==t;){if(f.x>=u&&f.x<=d&&f.y>=h&&f.y<=p&&Wl(n,a,o,l,s,c,f.x,f.y)&&Kl(f.prev,f,f.next)>=0)return!1;f=f.next}return!0}function Ul(e,t,i,r){const n=e.prev,o=e,s=e.next;if(Kl(n,o,s)>=0)return!1;const a=n.x,l=o.x,c=s.x,u=n.y,h=o.y,d=s.y,p=Math.min(a,l,c),f=Math.min(u,h,d),m=Math.max(a,l,c),g=Math.max(u,h,d),_=Ql(p,f,t,i,r),A=Ql(m,g,t,i,r);let y=e.prevZ,v=e.nextZ;for(;y&&y.z>=_&&v&&v.z<=A;){if(y.x>=p&&y.x<=m&&y.y>=f&&y.y<=g&&y!==n&&y!==s&&Wl(a,u,l,h,c,d,y.x,y.y)&&Kl(y.prev,y,y.next)>=0)return!1;if(y=y.prevZ,v.x>=p&&v.x<=m&&v.y>=f&&v.y<=g&&v!==n&&v!==s&&Wl(a,u,l,h,c,d,v.x,v.y)&&Kl(v.prev,v,v.next)>=0)return!1;v=v.nextZ}for(;y&&y.z>=_;){if(y.x>=p&&y.x<=m&&y.y>=f&&y.y<=g&&y!==n&&y!==s&&Wl(a,u,l,h,c,d,y.x,y.y)&&Kl(y.prev,y,y.next)>=0)return!1;y=y.prevZ}for(;v&&v.z<=A;){if(v.x>=p&&v.x<=m&&v.y>=f&&v.y<=g&&v!==n&&v!==s&&Wl(a,u,l,h,c,d,v.x,v.y)&&Kl(v.prev,v,v.next)>=0)return!1;v=v.nextZ}return!0}function Nl(e,t){let i=e;do{const r=i.prev,n=i.next.next;!Xl(r,n)&&Jl(r,i,i.next,n)&&tc(r,n)&&tc(n,r)&&(t.push(r.i,i.i,n.i),nc(i),nc(i.next),i=e=n),i=i.next}while(i!==e);return Dl(i)}function Vl(e,t,i,r,n,o){let s=e;do{let e=s.next.next;for(;e!==s.prev;){if(s.i!==e.i&&ql(s,e)){let a=ic(s,e);return s=Dl(s,s.next),a=Dl(a,a.next),Ol(s,t,i,r,n,o,0),void Ol(a,t,i,r,n,o,0)}e=e.next}s=s.next}while(s!==e)}function jl(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 Gl(e,t){const i=function(e,t){let i=t;const r=e.x,n=e.y;let o,s=-1/0;if(Xl(e,i))return i;do{if(Xl(e,i.next))return i.next;if(n<=i.y&&n>=i.next.y&&i.next.y!==i.y){const e=i.x+(n-i.y)*(i.next.x-i.x)/(i.next.y-i.y);if(e<=r&&e>s&&(s=e,o=i.x=i.x&&i.x>=l&&r!==i.x&&Zl(no.x||i.x===o.x&&Hl(o,i)))&&(o=i,u=t)}i=i.next}while(i!==a);return o}(e,t);if(!i)return t;const r=ic(i,e);return Dl(r,r.next),Dl(i,i.next)}function Hl(e,t){return Kl(e.prev,e,t.prev)<0&&Kl(t.next,e,e.next)<0}function Ql(e,t,i,r,n){return(e=1431655765&((e=858993459&((e=252645135&((e=16711935&((e=(e-i)*n|0)|e<<8))|e<<4))|e<<2))|e<<1))|(t=1431655765&((t=858993459&((t=252645135&((t=16711935&((t=(t-r)*n|0)|t<<8))|t<<4))|t<<2))|t<<1))<<1}function $l(e){let t=e,i=e;do{(t.x=(e-s)*(o-a)&&(e-s)*(r-a)>=(i-s)*(t-a)&&(i-s)*(o-a)>=(n-s)*(r-a)}function Wl(e,t,i,r,n,o,s,a){return!(e===s&&t===a)&&Zl(e,t,i,r,n,o,s,a)}function ql(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&&Jl(i,i.next,e,t))return!0;i=i.next}while(i!==e);return!1}(e,t)&&(tc(e,t)&&tc(t,e)&&function(e,t){let i=e,r=!1;const n=(e.x+t.x)/2,o=(e.y+t.y)/2;do{i.y>o!=i.next.y>o&&i.next.y!==i.y&&n<(i.next.x-i.x)*(o-i.y)/(i.next.y-i.y)+i.x&&(r=!r),i=i.next}while(i!==e);return r}(e,t)&&(Kl(e.prev,e,t.prev)||Kl(e,t.prev,t))||Xl(e,t)&&Kl(e.prev,e,e.next)>0&&Kl(t.prev,t,t.next)>0)}function Kl(e,t,i){return(t.y-e.y)*(i.x-t.x)-(t.x-e.x)*(i.y-t.y)}function Xl(e,t){return e.x===t.x&&e.y===t.y}function Jl(e,t,i,r){const n=ec(Kl(e,t,i)),o=ec(Kl(e,t,r)),s=ec(Kl(i,r,e)),a=ec(Kl(i,r,t));return n!==o&&s!==a||!(0!==n||!Yl(e,i,t))||!(0!==o||!Yl(e,r,t))||!(0!==s||!Yl(i,e,r))||!(0!==a||!Yl(i,t,r))}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 ec(e){return e>0?1:e<0?-1:0}function tc(e,t){return Kl(e.prev,e,e.next)<0?Kl(e,t,e.next)>=0&&Kl(e,e.prev,t)>=0:Kl(e,t,e.prev)<0||Kl(e,e.next,t)<0}function ic(e,t){const i=oc(e.i,e.x,e.y),r=oc(t.i,t.x,t.y),n=e.next,o=t.prev;return e.next=t,t.prev=e,i.next=n,n.prev=i,r.next=i,i.prev=r,o.next=r,r.prev=o,r}function rc(e,t,i,r){const n=oc(e,t,i);return r?(n.next=r.next,n.prev=r,r.next.prev=n,r.next=n):(n.prev=n,n.next=n),n}function nc(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 oc(e,t,i){return{i:e,x:t,y:i,prev:null,next:null,z:0,prevZ:null,nextZ:null,steiner:!1}}class sc{constructor(e,t){if(t>e)throw new Error("Min granularity must not be greater than base granularity.");this._baseZoomGranularity=e,this._minGranularity=t}getGranularityForZoomLevel(e){return Math.max(Math.floor(this._baseZoomGranularity/(1<32767||t>32767)throw new Error("Vertex coordinates are out of signed 16 bit integer range.");const i=0|Math.round(e),r=0|Math.round(t),n=this._getKey(i,r);if(this._vertexDictionary.has(n))return this._vertexDictionary.get(n);const o=this._vertexBuffer.length/2;return this._vertexDictionary.set(n,o),this._vertexBuffer.push(i,r),o}_subdivideTrianglesScanline(e){if(this._granularity<2)return function(e,t){const i=[];for(let r=0;r0?(i.push(n),i.push(s),i.push(o)):(i.push(n),i.push(o),i.push(s))}return i}(this._vertexBuffer,e);const t=[],i=e.length;for(let r=0;r=1||y<=0)||m&&(an)){c>=r&&c<=n&&o.push(i[(e+1)%3]);continue}!m&&A>0&&o.push(this._vertexToIndex(s+d*A,a+p*A));const v=s+d*Math.max(A,0),x=s+d*Math.min(y,1);f||this._generateIntraEdgeVertices(o,s,a,l,c,v,x),!m&&y<1&&o.push(this._vertexToIndex(s+d*y,a+p*y)),(m||c>=r&&c<=n)&&o.push(i[(e+1)%3]),!m&&(c<=r||c>=n)&&this._generateInterEdgeVertices(o,s,a,l,c,u,h,x,r,n)}return o}_generateIntraEdgeVertices(e,t,i,r,n,o,s){const a=r-t,l=n-i,c=0===l,u=c?Math.min(t,r):Math.min(o,s),h=c?Math.max(t,r):Math.max(o,s),d=Math.floor(u/this._granularityCellSize)+1,p=Math.ceil(h/this._granularityCellSize)-1;if(c?t=d;r--){const n=r*this._granularityCellSize;e.push(this._vertexToIndex(n,i+l*(n-t)/a))}}_generateInterEdgeVertices(e,t,i,r,n,o,s,a,l,c){const u=n-i,h=o-r,d=s-n,p=(l-n)/d,f=(c-n)/d,m=Math.min(p,f),g=Math.max(p,f),_=r+h*m;let A=Math.floor(Math.min(_,a)/this._granularityCellSize)+1,y=Math.ceil(Math.max(_,a)/this._granularityCellSize)-1,v=a<_;const x=0===d;if(x&&(s===l||s===c))return;if(x||m>=1||g<=0){const e=i-s,r=o+(t-o)*Math.min((l-s)/e,(c-s)/e);A=Math.floor(Math.min(r,a)/this._granularityCellSize)+1,y=Math.ceil(Math.max(r,a)/this._granularityCellSize)-1,v=a0?c:l;if(v)for(let t=A;t<=y;t++)e.push(this._vertexToIndex(t*this._granularityCellSize,b));else for(let t=y;t>=A;t--)e.push(this._vertexToIndex(t*this._granularityCellSize,b))}_generateOutline(e){const t=[];for(const i of e){const e=dc(i,this._granularity,!0),r=this._pointArrayToIndices(e),n=[];for(let e=1;en!=(o===lc)?(e.push(t),e.push(i),e.push(this._vertexToIndex(r,o)),e.push(i),e.push(this._vertexToIndex(n,o)),e.push(this._vertexToIndex(r,o))):(e.push(i),e.push(t),e.push(this._vertexToIndex(r,o)),e.push(this._vertexToIndex(n,o)),e.push(i),e.push(this._vertexToIndex(r,o)))}_fillPoles(e,t,i){const r=this._vertexBuffer,n=I,o=e.length;for(let s=2;s80*i){a=e[0],l=e[1];let t=a,r=l;for(let o=i;ot&&(t=i),n>r&&(r=n)}c=Math.max(t-a,r-l),c=0!==c?32767/c:0}return Ol(o,s,i,a,l,c,0),s}(i,r),t=this._convertIndices(i,e);n=this._subdivideTrianglesScanline(t)}catch(e){console.error(e)}let o=[];return t&&(o=this._generateOutline(e)),this._ensureNoPoleVertices(),this._handlePoles(n),{verticesFlattened:this._vertexBuffer,indicesTriangles:n,indicesLineList:o}}_convertIndices(e,t){const i=[];for(let r=0;r0?(Math.floor(A/a)+1)*a:(Math.ceil(A/a)-1)*a,t=m>0?(Math.floor(y/a)+1)*a:(Math.ceil(y/a)-1)*a,r=Math.abs(A-e),n=Math.abs(y-t),o=Math.abs(A-u),s=Math.abs(y-h),c=d?r/g:Number.POSITIVE_INFINITY,v=p?n/_:Number.POSITIVE_INFINITY;if((o<=r||!d)&&(s<=n||!p))break;if(c=0?s-1:o-1,n=(a+1)%o,l=e[2*t[r]],c=e[2*t[n]],u=e[2*t[s]],h=e[2*t[s]+1],d=e[2*t[a]+1];let p=!1;if(lc)p=!1;else{const i=d-h,o=-(e[2*t[a]]-u),s=h((c-u)*i+(e[2*t[n]+1]-h)*o)*s&&(p=!0)}if(p){const e=t[r],n=t[s],l=t[a];e!==n&&e!==l&&n!==l&&i.push(l,n,e),s--,s<0&&(s=o-1)}else{const e=t[n],r=t[s],l=t[a];e!==r&&e!==l&&r!==l&&i.push(l,r,e),a++,a>=o&&(a=0)}if(r===n)break}}function fc(e,t,i,r,n,o,s,a,l){const c=n.length/2,u=s&&a&&l;if(cta.MAX_VERTEX_ARRAY_LENGTH&&(c=e.createNewSegment(t,i),l=a.count,m=!0,g=!0,_=!0,u=0);const A=mc(s,r,o,a,d,m,c),y=mc(s,r,o,a,p,g,c),v=mc(s,r,o,a,f,_,c);i.emplaceBack(u+A-l,u+y-l,u+v-l),c.primitiveLength++}}(t,i,r,n,o,e),u&&function(e,t,i,r,n,o){const s=[];for(let e=0;eta.MAX_VERTEX_ARRAY_LENGTH&&(c=e.createNewSegment(t,i),l=a.count,f=!0,m=!0,u=0);const g=mc(s,r,o,a,n,f,c),_=mc(s,r,o,a,h,m,c);i.emplaceBack(u+g-l,u+_-l),c.primitiveLength++}}}(s,i,a,n,l,e),t.forceNewSegmentOnNextPrepare(),null==s||s.forceNewSegmentOnNextPrepare()}function mc(e,t,i,r,n,o,s){if(o){const o=r.count;return i(t[2*n],t[2*n+1]),e[n]=r.count,r.count++,s.vertexLength++,o}return e[n]}class gc{constructor(e){this.zoom=e.zoom,this.overscaling=e.overscaling,this.layers=e.layers,this.layerIds=this.layers.map(e=>e.id),this.index=e.index,this.hasDependencies=!1,this.patternFeatures=[],this.layoutVertexArray=new Ns,this.indexArray=new Xs,this.indexArray2=new Js,this.programConfigurations=new Pa(e.layers,e.zoom),this.segments=new ta,this.segments2=new ta,this.stateDependentLayerIds=this.layers.filter(e=>e.isStateDependent()).map(e=>e.id)}populate(e,t,i){this.hasDependencies=Ll("fill",this.layers,t);const r=this.layers[0].layout.get("fill-sort-key"),n=!r.isConstant(),o=[];for(const{feature:s,id:a,index:l,sourceLayerIndex:c}of e){const e=this.layers[0]._featureFilter.needGeometry,u=Oa(s,e);if(!this.layers[0]._featureFilter.filter(new Mo(this.zoom),u,i))continue;const h=n?r.evaluate(u,{},i,t.availableImages):void 0,d={id:a,properties:s.properties,type:s.type,sourceLayerIndex:c,index:l,geometry:e?u.geometry:Da(s),patterns:{},sortKey:h};o.push(d)}n&&o.sort((e,t)=>e.sortKey-t.sortKey);for(const r of o){const{geometry:n,index:o,sourceLayerIndex:s}=r;if(this.hasDependencies){const e=Fl("fill",this.layers,r,{zoom:this.zoom},t);this.patternFeatures.push(e)}else this.addFeature(r,n,o,i,{},t.subdivisionGranularity);t.featureIndex.insert(e[o].feature,n,o,s,this.index)}}update(e,t,i){this.stateDependentLayers.length&&this.programConfigurations.updatePaintArrays(e,t,this.stateDependentLayers,{imagePositions:i})}addFeatures(e,t,i){for(const r of this.patternFeatures)this.addFeature(r,r.geometry,r.index,t,i,e.subdivisionGranularity)}isEmpty(){return 0===this.layoutVertexArray.length}uploadPending(){return!this.uploaded||this.programConfigurations.needsUpload}upload(e){this.uploaded||(this.layoutVertexBuffer=e.createVertexBuffer(this.layoutVertexArray,Rl),this.indexBuffer=e.createIndexBuffer(this.indexArray),this.indexBuffer2=e.createIndexBuffer(this.indexArray2)),this.programConfigurations.upload(e),this.uploaded=!0}destroy(){this.layoutVertexBuffer&&(this.layoutVertexBuffer.destroy(),this.indexBuffer.destroy(),this.indexBuffer2.destroy(),this.programConfigurations.destroy(),this.segments.destroy(),this.segments2.destroy())}addFeature(e,t,i,r,n,o){for(const e of Yi(t,500)){const t=hc(e,r,o.fill.getGranularityForZoomLevel(r.z)),i=this.layoutVertexArray;fc((e,t)=>{i.emplaceBack(e,t)},this.segments,this.layoutVertexArray,this.indexArray,t.verticesFlattened,t.indicesTriangles,this.segments2,this.indexArray2,t.indicesLineList)}this.programConfigurations.populatePaintArrays(this.layoutVertexArray.length,e,i,{imagePositions:n,canonical:r})}}let _c,Ac;lo("FillBucket",gc,{omit:["layers","patternFeatures"]});var yc={get paint(){return Ac=Ac||new $o({"fill-antialias":new Vo(Ae.paint_fill["fill-antialias"]),"fill-opacity":new jo(Ae.paint_fill["fill-opacity"]),"fill-color":new jo(Ae.paint_fill["fill-color"]),"fill-outline-color":new jo(Ae.paint_fill["fill-outline-color"]),"fill-translate":new Vo(Ae.paint_fill["fill-translate"]),"fill-translate-anchor":new Vo(Ae.paint_fill["fill-translate-anchor"]),"fill-pattern":new Go(Ae.paint_fill["fill-pattern"])})},get layout(){return _c=_c||new $o({"fill-sort-key":new jo(Ae.layout_fill["fill-sort-key"])})}};class vc extends Zo{constructor(e,t){super(e,yc,t)}recalculate(e,t){super.recalculate(e,t);const i=this.paint._values["fill-outline-color"];"constant"===i.value.kind&&void 0===i.value.value&&(this.paint._values["fill-outline-color"]=this.paint._values["fill-color"])}createBucket(e){return new gc(e)}queryRadius(){return Ya(this.paint.get("fill-translate"))}queryIntersectsFeature({queryGeometry:e,geometry:t,transform:i,pixelsToTileUnits:r}){return Ga(el(e,this.paint.get("fill-translate"),this.paint.get("fill-translate-anchor"),-i.bearingInRadians,r),t)}isTileClipped(){return!0}}const xc=es([{name:"a_pos",components:2,type:"Int16"},{name:"a_normal_ed",components:4,type:"Int16"}],4),bc=es([{name:"a_centroid",components:2,type:"Int16"}],4),{members:wc}=xc;class Tc{constructor(e,t,i,r,n){this.properties={},this.extent=i,this.type=0,this.id=void 0,this._pbf=e,this._geometry=-1,this._keys=r,this._values=n,e.readFields(Ec,this,t)}loadGeometry(){const e=this._pbf;e.pos=this._geometry;const t=e.readVarint()+e.pos,r=[];let n,o=1,s=0,a=0,l=0;for(;e.pos>3}if(s--,1===o||2===o)a+=e.readSVarint(),l+=e.readSVarint(),1===o&&(n&&r.push(n),n=[]),n&&n.push(new i(a,l));else{if(7!==o)throw new Error(`unknown command ${o}`);n&&n.push(n[0].clone())}}return n&&r.push(n),r}bbox(){const e=this._pbf;e.pos=this._geometry;const t=e.readVarint()+e.pos;let i=1,r=0,n=0,o=0,s=1/0,a=-1/0,l=1/0,c=-1/0;for(;e.pos>3}if(r--,1===i||2===i)n+=e.readSVarint(),o+=e.readSVarint(),na&&(a=n),oc&&(c=o);else if(7!==i)throw new Error(`unknown command ${i}`)}return[s,l,a,c]}toGeoJSON(e,t,i){const r=this.extent*Math.pow(2,i),n=this.extent*e,o=this.extent*t,s=this.loadGeometry();function a(e){return[360*(e.x+n)/r-180,360/Math.PI*Math.atan(Math.exp((1-2*(e.y+o)/r)*Math.PI))-90]}function l(e){return e.map(a)}let c;if(1===this.type){const e=[];for(const t of s)e.push(t[0]);const t=l(e);c=1===e.length?{type:"Point",coordinates:t[0]}:{type:"MultiPoint",coordinates:t}}else if(2===this.type){const e=s.map(l);c=1===e.length?{type:"LineString",coordinates:e[0]}:{type:"MultiLineString",coordinates:e}}else{if(3!==this.type)throw new Error("unknown feature type");{const e=function(e){const t=e.length;if(t<=1)return[e];const i=[];let r,n;for(let o=0;o=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 Tc(this._pbf,t,this.extent,this._keys,this._values)}}function Sc(e,t,i){15===e?t.version=i.readVarint():1===e?t.name=i.readString():5===e?t.extent=i.readVarint():2===e?t._features.push(i.pos):3===e?t._keys.push(i.readString()):4===e&&t._values.push(function(e){let t=null;const i=e.readVarint()+e.pos;for(;e.pos>3;t=1===i?e.readString():2===i?e.readFloat():3===i?e.readDouble():4===i?e.readVarint64():5===i?e.readVarint():6===i?e.readSVarint():7===i?e.readBoolean():null}if(null==t)throw new Error("unknown feature value");return t}(i))}class Ic{constructor(e,t){this.layers=e.readFields(Mc,{},t)}}function Mc(e,t,i){if(3===e){const e=new Bc(i,i.readVarint()+i.pos);e.length&&(t[e.name]=e)}}const Pc=Math.pow(2,13);function Rc(e,t,i,r,n,o,s,a){e.emplaceBack(t,i,2*Math.floor(r*Pc)+s,n*Pc*2,o*Pc*2,Math.round(a))}class Lc{constructor(e){this.zoom=e.zoom,this.overscaling=e.overscaling,this.layers=e.layers,this.layerIds=this.layers.map(e=>e.id),this.index=e.index,this.hasDependencies=!1,this.layoutVertexArray=new Vs,this.centroidVertexArray=new zs,this.indexArray=new Xs,this.programConfigurations=new Pa(e.layers,e.zoom),this.segments=new ta,this.stateDependentLayerIds=this.layers.filter(e=>e.isStateDependent()).map(e=>e.id)}populate(e,t,i){this.features=[],this.hasDependencies=Ll("fill-extrusion",this.layers,t);for(const{feature:r,id:n,index:o,sourceLayerIndex:s}of e){const e=this.layers[0]._featureFilter.needGeometry,a=Oa(r,e);if(!this.layers[0]._featureFilter.filter(new Mo(this.zoom),a,i))continue;const l={id:n,sourceLayerIndex:s,index:o,geometry:e?a.geometry:Da(r),properties:r.properties,type:r.type,patterns:{}};this.hasDependencies?this.features.push(Fl("fill-extrusion",this.layers,l,{zoom:this.zoom},t)):this.addFeature(l,l.geometry,o,i,{},t.subdivisionGranularity),t.featureIndex.insert(r,l.geometry,o,s,this.index,!0)}}addFeatures(e,t,i){for(const r of this.features){const{geometry:n}=r;this.addFeature(r,n,r.index,t,i,e.subdivisionGranularity)}}update(e,t,i){this.stateDependentLayers.length&&this.programConfigurations.updatePaintArrays(e,t,this.stateDependentLayers,{imagePositions:i})}isEmpty(){return 0===this.layoutVertexArray.length&&0===this.centroidVertexArray.length}uploadPending(){return!this.uploaded||this.programConfigurations.needsUpload}upload(e){this.uploaded||(this.layoutVertexBuffer=e.createVertexBuffer(this.layoutVertexArray,wc),this.centroidVertexBuffer=e.createVertexBuffer(this.centroidVertexArray,bc.members,!0),this.indexBuffer=e.createIndexBuffer(this.indexArray)),this.programConfigurations.upload(e),this.uploaded=!0}destroy(){this.layoutVertexBuffer&&(this.layoutVertexBuffer.destroy(),this.indexBuffer.destroy(),this.programConfigurations.destroy(),this.segments.destroy(),this.centroidVertexBuffer.destroy())}addFeature(e,t,i,r,n,o){for(const i of Yi(t,500)){const t={x:0,y:0,sampleCount:0},n=this.layoutVertexArray.length;this.processPolygon(t,r,e,i,o);const s=this.layoutVertexArray.length-n,a=Math.floor(t.x/t.sampleCount),l=Math.floor(t.y/t.sampleCount);for(let e=0;e{Rc(c,e,t,0,0,1,1,0)},this.segments,this.layoutVertexArray,this.indexArray,l.verticesFlattened,l.indicesTriangles)}_generateSideFaces(e,t){let i=0;for(let r=1;rta.MAX_VERTEX_ARRAY_LENGTH&&(t.segment=this.segments.prepareSegment(4,this.layoutVertexArray,this.indexArray));const s=n.sub(o)._perp()._unit(),a=o.dist(n);i+a>32768&&(i=0),Rc(this.layoutVertexArray,n.x,n.y,s.x,s.y,0,0,i),Rc(this.layoutVertexArray,n.x,n.y,s.x,s.y,0,1,i),i+=a,Rc(this.layoutVertexArray,o.x,o.y,s.x,s.y,0,0,i),Rc(this.layoutVertexArray,o.x,o.y,s.x,s.y,0,1,i);const l=t.segment.vertexLength;this.indexArray.emplaceBack(l,l+2,l+1),this.indexArray.emplaceBack(l+1,l+2,l+3),t.segment.vertexLength+=4,t.segment.primitiveLength+=2}}}function Fc(e,t){for(let i=0;iI)||e.y===t.y&&(e.y<0||e.y>I)}function Dc(e){return e.every(e=>e.x<0)||e.every(e=>e.x>I)||e.every(e=>e.y<0)||e.every(e=>e.y>I)}let Oc;lo("FillExtrusionBucket",Lc,{omit:["layers","features"]});var zc={get paint(){return Oc=Oc||new $o({"fill-extrusion-opacity":new Vo(Ae["paint_fill-extrusion"]["fill-extrusion-opacity"]),"fill-extrusion-color":new jo(Ae["paint_fill-extrusion"]["fill-extrusion-color"]),"fill-extrusion-translate":new Vo(Ae["paint_fill-extrusion"]["fill-extrusion-translate"]),"fill-extrusion-translate-anchor":new Vo(Ae["paint_fill-extrusion"]["fill-extrusion-translate-anchor"]),"fill-extrusion-pattern":new Go(Ae["paint_fill-extrusion"]["fill-extrusion-pattern"]),"fill-extrusion-height":new jo(Ae["paint_fill-extrusion"]["fill-extrusion-height"]),"fill-extrusion-base":new jo(Ae["paint_fill-extrusion"]["fill-extrusion-base"]),"fill-extrusion-vertical-gradient":new Vo(Ae["paint_fill-extrusion"]["fill-extrusion-vertical-gradient"])})}};class Uc extends Zo{constructor(e,t){super(e,zc,t)}createBucket(e){return new Lc(e)}queryRadius(){return Ya(this.paint.get("fill-extrusion-translate"))}is3D(){return!0}queryIntersectsFeature({queryGeometry:e,feature:t,featureState:r,geometry:n,transform:o,pixelsToTileUnits:s,pixelPosMatrix:a}){const l=el(e,this.paint.get("fill-extrusion-translate"),this.paint.get("fill-extrusion-translate-anchor"),-o.bearingInRadians,s),c=this.paint.get("fill-extrusion-height").evaluate(t,r),u=this.paint.get("fill-extrusion-base").evaluate(t,r),h=function(e,t){const r=[];for(const n of e){const e=[n.x,n.y,0,1];T(e,e,t),r.push(new i(e[0]/e[3],e[1]/e[3]))}return r}(l,a),d=function(e,t,r,n){const o=[],s=[],a=n[8]*t,l=n[9]*t,c=n[10]*t,u=n[11]*t,h=n[8]*r,d=n[9]*r,p=n[10]*r,f=n[11]*r;for(const t of e){const e=[],r=[];for(const o of t){const t=o.x,s=o.y,m=n[0]*t+n[4]*s+n[12],g=n[1]*t+n[5]*s+n[13],_=n[2]*t+n[6]*s+n[14],A=n[3]*t+n[7]*s+n[15],y=_+c,v=A+u,x=m+h,b=g+d,w=_+p,T=A+f,E=new i((m+a)/v,(g+l)/v);E.z=y/v,e.push(E);const C=new i(x/T,b/T);C.z=w/T,r.push(C)}o.push(e),s.push(r)}return[o,s]}(n,u,c,a);return function(e,t,i){let r=1/0;Ga(i,t)&&(r=Vc(i,t[0]));for(let n=0;ne.id),this.index=e.index,this.hasDependencies=!1,this.patternFeatures=[],this.lineClipsArray=[],this.gradients={},this.layers.forEach(e=>{this.gradients[e.id]={}}),this.layoutVertexArray=new js,this.layoutVertexArray2=new Gs,this.indexArray=new Xs,this.programConfigurations=new Pa(e.layers,e.zoom),this.segments=new ta,this.maxLineLength=0,this.stateDependentLayerIds=this.layers.filter(e=>e.isStateDependent()).map(e=>e.id)}populate(e,t,i){this.hasDependencies=Ll("line",this.layers,t)||this.hasLineDasharray(this.layers);const r=this.layers[0].layout.get("line-sort-key"),n=!r.isConstant(),o=[];for(const{feature:t,id:s,index:a,sourceLayerIndex:l}of e){const e=this.layers[0]._featureFilter.needGeometry,c=Oa(t,e);if(!this.layers[0]._featureFilter.filter(new Mo(this.zoom),c,i))continue;const u=n?r.evaluate(c,{},i):void 0,h={id:s,properties:t.properties,type:t.type,sourceLayerIndex:l,index:a,geometry:e?c.geometry:Da(t),patterns:{},dashes:{},sortKey:u};o.push(h)}n&&o.sort((e,t)=>e.sortKey-t.sortKey);for(const r of o){const{geometry:n,index:o,sourceLayerIndex:s}=r;this.hasDependencies?(Ll("line",this.layers,t)?Fl("line",this.layers,r,{zoom:this.zoom},t):this.hasLineDasharray(this.layers)&&this.addLineDashDependencies(this.layers,r,this.zoom,t),this.patternFeatures.push(r)):this.addFeature(r,n,o,i,{},{},t.subdivisionGranularity),t.featureIndex.insert(e[o].feature,n,o,s,this.index)}}update(e,t,i,r){this.stateDependentLayers.length&&this.programConfigurations.updatePaintArrays(e,t,this.stateDependentLayers,{imagePositions:i,dashPositions:r})}addFeatures(e,t,i,r){for(const n of this.patternFeatures)this.addFeature(n,n.geometry,n.index,t,i,r,e.subdivisionGranularity)}isEmpty(){return 0===this.layoutVertexArray.length}uploadPending(){return!this.uploaded||this.programConfigurations.needsUpload}upload(e){this.uploaded||(0!==this.layoutVertexArray2.length&&(this.layoutVertexBuffer2=e.createVertexBuffer(this.layoutVertexArray2,Qc)),this.layoutVertexBuffer=e.createVertexBuffer(this.layoutVertexArray,Gc),this.indexBuffer=e.createIndexBuffer(this.indexArray)),this.programConfigurations.upload(e),this.uploaded=!0}destroy(){this.layoutVertexBuffer&&(this.layoutVertexBuffer.destroy(),this.indexBuffer.destroy(),this.programConfigurations.destroy(),this.segments.destroy())}lineFeatureClips(e){if(e.properties&&Object.prototype.hasOwnProperty.call(e.properties,"mapbox_clip_start")&&Object.prototype.hasOwnProperty.call(e.properties,"mapbox_clip_end"))return{start:+e.properties.mapbox_clip_start,end:+e.properties.mapbox_clip_end}}addFeature(e,t,i,r,n,o,s){const a=this.layers[0].layout,l=a.get("line-join").evaluate(e,{}),c=a.get("line-cap"),u=a.get("line-miter-limit"),h=a.get("line-round-limit");this.lineClips=this.lineFeatureClips(e);for(const i of t)this.addLine(i,e,l,c,u,h,r,s);this.programConfigurations.populatePaintArrays(this.layoutVertexArray.length,e,i,{imagePositions:n,dashPositions:o,canonical:r})}addLine(e,t,i,r,n,o,s,a){if(this.distance=0,this.scaledDistance=0,this.totalDistance=0,e=dc(e,s?a.line.getGranularityForZoomLevel(s.z):1),this.lineClips){this.lineClipsArray.push(this.lineClips);for(let t=0;t=2&&e[c-1].equals(e[c-2]);)c--;let u=0;for(;u0;if(x&&t>u){const e=p.dist(f);if(e>2*h){const t=p.sub(p.sub(f)._mult(h/e)._round());this.updateDistance(f,t),this.addCurrentVertex(t,g,0,0,d),f=t}}const w=f&&m;let T=w?i:l?"butt":r;if(w&&"round"===T&&(yn&&(T="bevel"),"bevel"===T&&(y>2&&(T="flipbevel"),y100)s=_.mult(-1);else{const e=y*g.add(_).mag()/g.sub(_).mag();s._perp()._mult(e*(b?-1:1))}this.addCurrentVertex(p,s,0,0,d),this.addCurrentVertex(p,s.mult(-1),0,0,d)}else if("bevel"===T||"fakeround"===T){const e=-Math.sqrt(y*y-1),t=b?e:0,i=b?0:e;if(f&&this.addCurrentVertex(p,g,t,i,d),"fakeround"===T){const e=Math.round(180*v/Math.PI/20);for(let t=1;t2*h){const t=p.add(m.sub(p)._mult(h/e)._round());this.updateDistance(p,t),this.addCurrentVertex(t,_,0,0,d),p=t}}}}addCurrentVertex(e,t,i,r,n,o=!1){const s=t.y*r-t.x,a=-t.y-t.x*r;this.addHalfVertex(e,t.x+t.y*i,t.y-t.x*i,o,!1,i,n),this.addHalfVertex(e,s,a,o,!0,-r,n),this.distance>Zc/2&&0===this.totalDistance&&(this.distance=0,this.updateScaledDistance(),this.addCurrentVertex(e,t,i,r,n,o))}addHalfVertex({x:e,y:t},i,r,n,o,s,a){const l=.5*(this.lineClips?this.scaledDistance*(Zc-1):this.scaledDistance);this.layoutVertexArray.emplaceBack((e<<1)+(n?1:0),(t<<1)+(o?1:0),Math.round(63*i)+128,Math.round(63*r)+128,1+(0===s?0:s<0?-1:1)|(63&l)<<2,l>>6),this.lineClips&&this.layoutVertexArray2.emplaceBack((this.scaledDistance-this.lineClips.start)/(this.lineClips.end-this.lineClips.start),this.lineClipsArray.length);const c=a.vertexLength++;this.e1>=0&&this.e2>=0&&(this.indexArray.emplaceBack(this.e1,c,this.e2),a.primitiveLength++),o?this.e2=c:this.e1=c}updateScaledDistance(){this.scaledDistance=this.lineClips?this.lineClips.start+(this.lineClips.end-this.lineClips.start)*this.distance/this.totalDistance:this.distance}updateDistance(e,t){this.distance+=e.dist(t),this.updateScaledDistance()}hasLineDasharray(e){for(const t of e){const e=t.paint.get("line-dasharray");if(e&&!e.isConstant())return!0}return!1}addLineDashDependencies(e,t,i,r){for(const n of e){const e=n.paint.get("line-dasharray");if(!e||"constant"===e.value.kind)continue;const o="round"===n.layout.get("line-cap"),s={dasharray:e.value.evaluate({zoom:i-1},t,{}),round:o},a={dasharray:e.value.evaluate({zoom:i},t,{}),round:o},l={dasharray:e.value.evaluate({zoom:i+1},t,{}),round:o},c=`${s.dasharray.join(",")},${s.round}`,u=`${a.dasharray.join(",")},${a.round}`,h=`${l.dasharray.join(",")},${l.round}`;r.dashDependencies[c]=s,r.dashDependencies[u]=a,r.dashDependencies[h]=l,t.dashes[n.id]={min:c,mid:u,max:h}}}}let qc,Kc;lo("LineBucket",Wc,{omit:["layers","patternFeatures"]});var Xc={get paint(){return Kc=Kc||new $o({"line-opacity":new jo(Ae.paint_line["line-opacity"]),"line-color":new jo(Ae.paint_line["line-color"]),"line-translate":new Vo(Ae.paint_line["line-translate"]),"line-translate-anchor":new Vo(Ae.paint_line["line-translate-anchor"]),"line-width":new jo(Ae.paint_line["line-width"]),"line-gap-width":new jo(Ae.paint_line["line-gap-width"]),"line-offset":new jo(Ae.paint_line["line-offset"]),"line-blur":new jo(Ae.paint_line["line-blur"]),"line-dasharray":new Go(Ae.paint_line["line-dasharray"]),"line-pattern":new Go(Ae.paint_line["line-pattern"]),"line-gradient":new Qo(Ae.paint_line["line-gradient"])})},get layout(){return qc=qc||new $o({"line-cap":new Vo(Ae.layout_line["line-cap"]),"line-join":new jo(Ae.layout_line["line-join"]),"line-miter-limit":new Vo(Ae.layout_line["line-miter-limit"]),"line-round-limit":new Vo(Ae.layout_line["line-round-limit"]),"line-sort-key":new jo(Ae.layout_line["line-sort-key"])})}};class Jc extends jo{possiblyEvaluate(e,t){return t=new Mo(Math.floor(t.zoom),{now:t.now,fadeDuration:t.fadeDuration,zoomHistory:t.zoomHistory,transition:t.transition}),super.possiblyEvaluate(e,t)}evaluate(e,t,i,r){return t=z({},t,{zoom:Math.floor(t.zoom)}),super.evaluate(e,t,i,r)}}let Yc;class eu extends Zo{constructor(e,t){super(e,Xc,t),this.gradientVersion=0,Yc||(Yc=new Jc(Xc.paint.properties["line-width"].specification),Yc.useIntegerZoom=!0)}_handleSpecialPaintPropertyUpdate(e){if("line-gradient"===e){const e=this.gradientExpression();this.stepInterpolant=!!function(e){return void 0!==e._styleExpression}(e)&&e._styleExpression.expression instanceof si,this.gradientVersion=(this.gradientVersion+1)%Number.MAX_SAFE_INTEGER}}gradientExpression(){return this._transitionablePaint._values["line-gradient"].value.expression}recalculate(e,t){super.recalculate(e,t),this.paint._values["line-floorwidth"]=Yc.possiblyEvaluate(this._transitioningPaint._values["line-width"].value,e)}createBucket(e){return new Wc(e)}queryRadius(e){const t=e,i=tu(Ja("line-width",this,t),Ja("line-gap-width",this,t)),r=Ja("line-offset",this,t);return i/2+Math.abs(r)+Ya(this.paint.get("line-translate"))}queryIntersectsFeature({queryGeometry:e,feature:t,featureState:r,geometry:n,transform:o,pixelsToTileUnits:s}){const a=el(e,this.paint.get("line-translate"),this.paint.get("line-translate-anchor"),-o.bearingInRadians,s),l=s/2*tu(this.paint.get("line-width").evaluate(t,r),this.paint.get("line-gap-width").evaluate(t,r)),c=this.paint.get("line-offset").evaluate(t,r);return c&&(n=function(e,t){const r=[];for(let n=0;n=3)for(let t=0;t0?t+2*e:e}const iu=es([{name:"a_pos_offset",components:4,type:"Int16"},{name:"a_data",components:4,type:"Uint16"},{name:"a_pixeloffset",components:4,type:"Int16"}],4),ru=es([{name:"a_projected_pos",components:3,type:"Float32"}],4);es([{name:"a_fade_opacity",components:1,type:"Uint32"}],4);const nu=es([{name:"a_placed",components:2,type:"Uint8"},{name:"a_shift",components:2,type:"Float32"},{name:"a_box_real",components:2,type:"Int16"}]);es([{type:"Int16",name:"anchorPointX"},{type:"Int16",name:"anchorPointY"},{type:"Int16",name:"x1"},{type:"Int16",name:"y1"},{type:"Int16",name:"x2"},{type:"Int16",name:"y2"},{type:"Uint32",name:"featureIndex"},{type:"Uint16",name:"sourceLayerIndex"},{type:"Uint16",name:"bucketIndex"}]);const ou=es([{name:"a_pos",components:2,type:"Int16"},{name:"a_anchor_pos",components:2,type:"Int16"},{name:"a_extrude",components:2,type:"Int16"}],4),su=es([{name:"a_pos",components:2,type:"Float32"},{name:"a_radius",components:1,type:"Float32"},{name:"a_flags",components:2,type:"Int16"}],4);function au(e,t,i){return e.sections.forEach(e=>{e.text=function(e,t,i){const r=t.layout.get("text-transform").evaluate(i,{});return"uppercase"===r?e=e.toLocaleUpperCase():"lowercase"===r&&(e=e.toLocaleLowerCase()),Io.applyArabicShaping&&(e=Io.applyArabicShaping(e)),e}(e.text,t,i)}),e}es([{name:"triangle",components:3,type:"Uint16"}]),es([{type:"Int16",name:"anchorX"},{type:"Int16",name:"anchorY"},{type:"Uint16",name:"glyphStartIndex"},{type:"Uint16",name:"numGlyphs"},{type:"Uint32",name:"vertexStartIndex"},{type:"Uint32",name:"lineStartIndex"},{type:"Uint32",name:"lineLength"},{type:"Uint16",name:"segment"},{type:"Uint16",name:"lowerSize"},{type:"Uint16",name:"upperSize"},{type:"Float32",name:"lineOffsetX"},{type:"Float32",name:"lineOffsetY"},{type:"Uint8",name:"writingMode"},{type:"Uint8",name:"placedOrientation"},{type:"Uint8",name:"hidden"},{type:"Uint32",name:"crossTileID"},{type:"Int16",name:"associatedIconIndex"}]),es([{type:"Int16",name:"anchorX"},{type:"Int16",name:"anchorY"},{type:"Int16",name:"rightJustifiedTextSymbolIndex"},{type:"Int16",name:"centerJustifiedTextSymbolIndex"},{type:"Int16",name:"leftJustifiedTextSymbolIndex"},{type:"Int16",name:"verticalPlacedTextSymbolIndex"},{type:"Int16",name:"placedIconSymbolIndex"},{type:"Int16",name:"verticalPlacedIconSymbolIndex"},{type:"Uint16",name:"key"},{type:"Uint16",name:"textBoxStartIndex"},{type:"Uint16",name:"textBoxEndIndex"},{type:"Uint16",name:"verticalTextBoxStartIndex"},{type:"Uint16",name:"verticalTextBoxEndIndex"},{type:"Uint16",name:"iconBoxStartIndex"},{type:"Uint16",name:"iconBoxEndIndex"},{type:"Uint16",name:"verticalIconBoxStartIndex"},{type:"Uint16",name:"verticalIconBoxEndIndex"},{type:"Uint16",name:"featureIndex"},{type:"Uint16",name:"numHorizontalGlyphVertices"},{type:"Uint16",name:"numVerticalGlyphVertices"},{type:"Uint16",name:"numIconVertices"},{type:"Uint16",name:"numVerticalIconVertices"},{type:"Uint16",name:"useRuntimeCollisionCircles"},{type:"Uint32",name:"crossTileID"},{type:"Float32",name:"textBoxScale"},{type:"Float32",name:"collisionCircleDiameter"},{type:"Uint16",name:"textAnchorOffsetStartIndex"},{type:"Uint16",name:"textAnchorOffsetEndIndex"}]),es([{type:"Float32",name:"offsetX"}]),es([{type:"Int16",name:"x"},{type:"Int16",name:"y"},{type:"Int16",name:"tileUnitDistanceFromAnchor"}]),es([{type:"Uint16",name:"textAnchor"},{type:"Float32",components:2,name:"textOffset"}]);var lu=24;const cu={"!":"︕","#":"#",$:"$","%":"%","&":"&","(":"︵",")":"︶","*":"*","+":"+",",":"︐","-":"︲",".":"・","/":"/",":":"︓",";":"︔","<":"︿","=":"=",">":"﹀","?":"︖","@":"@","[":"﹇","\\":"\","]":"﹈","^":"^",_:"︳","`":"`","{":"︷","|":"―","}":"︸","~":"~","¢":"¢","£":"£","¥":"¥","¦":"¦","¬":"¬","¯":" ̄","–":"︲","—":"︱","‘":"﹃","’":"﹄","“":"﹁","”":"﹂","…":"︙","⋯":"︙","‧":"・","₩":"₩","、":"︑","。":"︒","〈":"︿","〉":"﹀","《":"︽","》":"︾","「":"﹁","」":"﹂","『":"﹃","』":"﹄","【":"︻","】":"︼","〔":"︹","〕":"︺","〖":"︗","〗":"︘","!":"︕","(":"︵",")":"︶",",":"︐","-":"︲",".":"・",":":"︓",";":"︔","<":"︿",">":"﹀","?":"︖","[":"﹇","]":"﹈","_":"︳","{":"︷","|":"―","}":"︸","⦅":"︵","⦆":"︶","。":"︒","「":"﹁","」":"﹂"},uu={10:!0,32:!0,38:!0,41:!0,43:!0,45:!0,47:!0,173:!0,183:!0,8203:!0,8208:!0,8211:!0,8231:!0},hu={40:!0};function du(e,t,i,r,n,o){if("fontStack"in t){const r=i[t.fontStack],o=r&&r[e];return o?o.metrics.advance*t.scale+n:0}{const e=r[t.imageName];return e?e.displaySize[0]*t.scale*lu/o+n:0}}function pu(e,t,i,r){const n=Math.pow(e-t,2);return r?eMath.max(e,this.sections[t].scale),0)}getMaxImageSize(e){let t=0,i=0;for(let r=0;ri))}addImageSection(e){const t=e.image?e.image.name:"";if(0===t.length)return void H("Can't add FormattedSection with an empty image.");const i=this.getNextImageSectionCharCode();i?(this.text+=String.fromCharCode(i),this.sections.push({scale:1,verticalAlign:e.verticalAlign||"bottom",imageName:t}),this.sectionIndex.push(this.sections.length-1)):H("Reached maximum number of images 6401")}getNextImageSectionCharCode(){return this.imageSectionID?this.imageSectionID>=63743?null:++this.imageSectionID:(this.imageSectionID=57344,this.imageSectionID)}determineLineBreaks(e,t,i,r,n){const o=[],s=this.determineAverageLineWidth(e,t,i,r,n),a=this.hasZeroWidthSpaces();let l=0,c=0;const u=this.text[Symbol.iterator]();let h=u.next();const d=this.text[Symbol.iterator]();d.next();let p=d.next();const f=this.text[Symbol.iterator]();f.next(),f.next();let m=f.next();for(;!h.done;){const t=this.getSection(c),g=h.value.codePointAt(0);if(Ao(g)||(l+=du(g,t,i,r,e,n)),!p.done){const e=go(g),i=p.value.codePointAt(0);(uu[g]||e||"imageName"in t||!m.done&&hu[i])&&o.push(mu(c+1,l,s,o,fu(g,i,e&&a),!1))}c++,h=u.next(),p=d.next(),m=f.next()}return gu(mu(this.length(),l,s,o,0,!0))}determineAverageLineWidth(e,t,i,r,n){let o=0,s=0;for(const t of this.text){const a=this.getSection(s);o+=du(t.codePointAt(0),a,i,r,e,n),s++}return o/Math.max(1,Math.ceil(o/t))}}const Au=4294967296,yu=1/Au,vu="undefined"==typeof TextDecoder?null:new TextDecoder("utf-8");class xu{constructor(e=new Uint8Array(16)){this.buf=ArrayBuffer.isView(e)?e:new Uint8Array(e),this.dataView=new DataView(this.buf.buffer),this.pos=0,this.type=0,this.length=this.buf.length}readFields(e,t,i=this.length){for(;this.pos>3,n=this.pos;this.type=7&i,e(r,t,this),this.pos===n&&this.skip(i)}return t}readMessage(e,t){return this.readFields(e,t,this.readVarint()+this.pos)}readFixed32(){const e=this.dataView.getUint32(this.pos,!0);return this.pos+=4,e}readSFixed32(){const e=this.dataView.getInt32(this.pos,!0);return this.pos+=4,e}readFixed64(){const e=this.dataView.getUint32(this.pos,!0)+this.dataView.getUint32(this.pos+4,!0)*Au;return this.pos+=8,e}readSFixed64(){const e=this.dataView.getUint32(this.pos,!0)+this.dataView.getInt32(this.pos+4,!0)*Au;return this.pos+=8,e}readFloat(){const e=this.dataView.getFloat32(this.pos,!0);return this.pos+=4,e}readDouble(){const e=this.dataView.getFloat64(this.pos,!0);return this.pos+=8,e}readVarint(e){const t=this.buf;let i,r;return r=t[this.pos++],i=127&r,r<128?i:(r=t[this.pos++],i|=(127&r)<<7,r<128?i:(r=t[this.pos++],i|=(127&r)<<14,r<128?i:(r=t[this.pos++],i|=(127&r)<<21,r<128?i:(r=t[this.pos],i|=(15&r)<<28,function(e,t,i){const r=i.buf;let n,o;if(o=r[i.pos++],n=(112&o)>>4,o<128)return bu(e,n,t);if(o=r[i.pos++],n|=(127&o)<<3,o<128)return bu(e,n,t);if(o=r[i.pos++],n|=(127&o)<<10,o<128)return bu(e,n,t);if(o=r[i.pos++],n|=(127&o)<<17,o<128)return bu(e,n,t);if(o=r[i.pos++],n|=(127&o)<<24,o<128)return bu(e,n,t);if(o=r[i.pos++],n|=(1&o)<<31,o<128)return bu(e,n,t);throw new Error("Expected varint not more than 10 bytes")}(i,e,this)))))}readVarint64(){return this.readVarint(!0)}readSVarint(){const e=this.readVarint();return e%2==1?(e+1)/-2:e/2}readBoolean(){return Boolean(this.readVarint())}readString(){const e=this.readVarint()+this.pos,t=this.pos;return this.pos=e,e-t>=12&&vu?vu.decode(this.buf.subarray(t,e)):function(e,t,i){let r="",n=t;for(;n239?4:t>223?3:t>191?2:1;if(n+c>i)break;1===c?t<128&&(l=t):2===c?(o=e[n+1],128==(192&o)&&(l=(31&t)<<6|63&o,l<=127&&(l=null))):3===c?(o=e[n+1],s=e[n+2],128==(192&o)&&128==(192&s)&&(l=(15&t)<<12|(63&o)<<6|63&s,(l<=2047||l>=55296&&l<=57343)&&(l=null))):4===c&&(o=e[n+1],s=e[n+2],a=e[n+3],128==(192&o)&&128==(192&s)&&128==(192&a)&&(l=(15&t)<<18|(63&o)<<12|(63&s)<<6|63&a,(l<=65535||l>=1114112)&&(l=null))),null===l?(l=65533,c=1):l>65535&&(l-=65536,r+=String.fromCharCode(l>>>10&1023|55296),l=56320|1023&l),r+=String.fromCharCode(l),n+=c}return r}(this.buf,t,e)}readBytes(){const e=this.readVarint()+this.pos,t=this.buf.subarray(this.pos,e);return this.pos=e,t}readPackedVarint(e=[],t){const i=this.readPackedEnd();for(;this.pos127;);else if(2===t)this.pos=this.readVarint()+this.pos;else if(5===t)this.pos+=4;else{if(1!==t)throw new Error(`Unimplemented type: ${t}`);this.pos+=8}}writeTag(e,t){this.writeVarint(e<<3|t)}realloc(e){let t=this.length||16;for(;t268435455||e<0?function(e,t){let i,r;if(e>=0?(i=e%4294967296|0,r=e/4294967296|0):(i=~(-e%4294967296),r=~(-e/4294967296),4294967295^i?i=i+1|0:(i=0,r=r+1|0)),e>=0x10000000000000000||e<-0x10000000000000000)throw new Error("Given varint doesn't fit into 10 bytes");t.realloc(10),function(e,t,i){i.buf[i.pos++]=127&e|128,e>>>=7,i.buf[i.pos++]=127&e|128,e>>>=7,i.buf[i.pos++]=127&e|128,e>>>=7,i.buf[i.pos++]=127&e|128,i.buf[i.pos]=127&(e>>>=7)}(i,0,t),function(e,t){const i=(7&e)<<4;t.buf[t.pos++]|=i|((e>>>=3)?128:0),e&&(t.buf[t.pos++]=127&e|((e>>>=7)?128:0),e&&(t.buf[t.pos++]=127&e|((e>>>=7)?128:0),e&&(t.buf[t.pos++]=127&e|((e>>>=7)?128:0),e&&(t.buf[t.pos++]=127&e|((e>>>=7)?128:0),e&&(t.buf[t.pos++]=127&e)))))}(r,t)}(e,this):(this.realloc(4),this.buf[this.pos++]=127&e|(e>127?128:0),e<=127||(this.buf[this.pos++]=127&(e>>>=7)|(e>127?128:0),e<=127||(this.buf[this.pos++]=127&(e>>>=7)|(e>127?128:0),e<=127||(this.buf[this.pos++]=e>>>7&127))))}writeSVarint(e){this.writeVarint(e<0?2*-e-1:2*e)}writeBoolean(e){this.writeVarint(+e)}writeString(e){e=String(e),this.realloc(4*e.length),this.pos++;const t=this.pos;this.pos=function(e,t,i){for(let r,n,o=0;o55295&&r<57344){if(!n){r>56319||o+1===t.length?(e[i++]=239,e[i++]=191,e[i++]=189):n=r;continue}if(r<56320){e[i++]=239,e[i++]=191,e[i++]=189,n=r;continue}r=n-55296<<10|r-56320|65536,n=null}else n&&(e[i++]=239,e[i++]=191,e[i++]=189,n=null);r<128?e[i++]=r:(r<2048?e[i++]=r>>6|192:(r<65536?e[i++]=r>>12|224:(e[i++]=r>>18|240,e[i++]=r>>12&63|128),e[i++]=r>>6&63|128),e[i++]=63&r|128)}return i}(this.buf,e,this.pos);const i=this.pos-t;i>=128&&wu(t,i,this),this.pos=t-1,this.writeVarint(i),this.pos+=i}writeFloat(e){this.realloc(4),this.dataView.setFloat32(this.pos,e,!0),this.pos+=4}writeDouble(e){this.realloc(8),this.dataView.setFloat64(this.pos,e,!0),this.pos+=8}writeBytes(e){const t=e.length;this.writeVarint(t),this.realloc(t);for(let i=0;i=128&&wu(i,r,this),this.pos=i-1,this.writeVarint(r),this.pos+=r}writeMessage(e,t,i){this.writeTag(e,2),this.writeRawMessage(t,i)}writePackedVarint(e,t){t.length&&this.writeMessage(e,Tu,t)}writePackedSVarint(e,t){t.length&&this.writeMessage(e,Eu,t)}writePackedBoolean(e,t){t.length&&this.writeMessage(e,Su,t)}writePackedFloat(e,t){t.length&&this.writeMessage(e,Cu,t)}writePackedDouble(e,t){t.length&&this.writeMessage(e,Bu,t)}writePackedFixed32(e,t){t.length&&this.writeMessage(e,Iu,t)}writePackedSFixed32(e,t){t.length&&this.writeMessage(e,Mu,t)}writePackedFixed64(e,t){t.length&&this.writeMessage(e,Pu,t)}writePackedSFixed64(e,t){t.length&&this.writeMessage(e,Ru,t)}writeBytesField(e,t){this.writeTag(e,2),this.writeBytes(t)}writeFixed32Field(e,t){this.writeTag(e,5),this.writeFixed32(t)}writeSFixed32Field(e,t){this.writeTag(e,5),this.writeSFixed32(t)}writeFixed64Field(e,t){this.writeTag(e,1),this.writeFixed64(t)}writeSFixed64Field(e,t){this.writeTag(e,1),this.writeSFixed64(t)}writeVarintField(e,t){this.writeTag(e,0),this.writeVarint(t)}writeSVarintField(e,t){this.writeTag(e,0),this.writeSVarint(t)}writeStringField(e,t){this.writeTag(e,2),this.writeString(t)}writeFloatField(e,t){this.writeTag(e,5),this.writeFloat(t)}writeDoubleField(e,t){this.writeTag(e,1),this.writeDouble(t)}writeBooleanField(e,t){this.writeVarintField(e,+t)}}function bu(e,t,i){return i?4294967296*t+(e>>>0):4294967296*(t>>>0)+(e>>>0)}function wu(e,t,i){const r=t<=16383?1:t<=2097151?2:t<=268435455?3:Math.floor(Math.log(t)/(7*Math.LN2));i.realloc(r);for(let t=i.pos-1;t>=e;t--)i.buf[t+r]=i.buf[t]}function Tu(e,t){for(let i=0;it.h-e.h);const r=[{x:0,y:0,w:Math.max(Math.ceil(Math.sqrt(t/.95)),i),h:1/0}];let n=0,o=0;for(const t of e)for(let e=r.length-1;e>=0;e--){const i=r[e];if(!(t.w>i.w||t.h>i.h)){if(t.x=i.x,t.y=i.y,o=Math.max(o,t.y+t.h),n=Math.max(n,t.x+t.w),t.w===i.w&&t.h===i.h){const t=r.pop();t&&eg.toCodeUnitIndex(e));const e=y(g.toString(),A);for(const t of e){const e=[...t].map(()=>0);_.push(new _u(t,g.sections,e))}}else if(v){_=[],A=A.map(e=>g.toCodeUnitIndex(e));let e=0;const t=[];for(const i of g.text)t.push(...Array(i.length).fill(g.sectionIndex[e])),e++;const i=v(g.text,t,A);for(const e of i){const t=[];let i="";for(const r of e[0])t.push(e[1][i.length]),i+=r;_.push(new _u(e[0],g.sections,t))}}else _=function(e,t){const i=[];let r=0;for(const n of t)i.push(e.substring(r,n)),r=n;return rc){const e=Math.ceil(o/c);n*=e/s,s=e}return{x1:r,y1:n,x2:r+o,y2:n+s}}function Ku(e,t,i,r,n,o){const s=e.image;let a;if(s.content){const e=s.content,t=s.pixelRatio||1;a=[e[0]/t,e[1]/t,s.displaySize[0]-e[2]/t,s.displaySize[1]-e[3]/t]}const l=t.left*o,c=t.right*o;let u,h,d,p;"width"===i||"both"===i?(p=n[0]+l-r[3],h=n[0]+c+r[1]):(p=n[0]+(l+c-s.displaySize[0])/2,h=p+s.displaySize[0]);const f=t.top*o,m=t.bottom*o;return"height"===i||"both"===i?(u=n[1]+f-r[0],d=n[1]+m+r[2]):(u=n[1]+(f+m-s.displaySize[1])/2,d=u+s.displaySize[1]),{image:s,top:u,right:h,bottom:d,left:p,collisionPadding:a}}lo("ImagePosition",Ou),lo("ImageAtlas",zu),e.ay=void 0,(Uu=e.ay||(e.ay={}))[Uu.none=0]="none",Uu[Uu.horizontal=1]="horizontal",Uu[Uu.vertical=2]="vertical",Uu[Uu.horizontalOnly=3]="horizontalOnly";const Xu=128,Ju=32640;function Yu(e,t){const{expression:i}=t;if("constant"===i.kind)return{kind:"constant",layoutSize:i.evaluate(new Mo(e+1))};if("source"===i.kind)return{kind:"source"};{const{zoomStops:t,interpolationType:r}=i;let n=0;for(;ne.id),this.index=t.index,this.pixelRatio=t.pixelRatio,this.sourceLayerIndex=t.sourceLayerIndex,this.hasDependencies=!1,this.hasRTLText=!1,this.sortKeyRanges=[],this.collisionCircleArray=[];const i=this.layers[0]._unevaluatedLayout._values;this.textSizeData=Yu(this.zoom,i["text-size"]),this.iconSizeData=Yu(this.zoom,i["icon-size"]);const r=this.layers[0].layout,n=r.get("symbol-sort-key"),o=r.get("symbol-z-order");this.canOverlap="never"!==eh(r,"text-overlap","text-allow-overlap")||"never"!==eh(r,"icon-overlap","icon-allow-overlap")||r.get("text-ignore-placement")||r.get("icon-ignore-placement"),this.sortFeaturesByKey="viewport-y"!==o&&!n.isConstant(),this.sortFeaturesByY=("viewport-y"===o||"auto"===o&&!this.sortFeaturesByKey)&&this.canOverlap,"point"===r.get("symbol-placement")&&(this.writingModes=r.get("text-writing-mode").map(t=>e.ay[t])),this.stateDependentLayerIds=this.layers.filter(e=>e.isStateDependent()).map(e=>e.id),this.sourceID=t.sourceID}createArrays(){this.text=new oh(new Pa(this.layers,this.zoom,e=>/^text/.test(e))),this.icon=new oh(new Pa(this.layers,this.zoom,e=>/^icon/.test(e))),this.glyphOffsetArray=new Rs,this.lineVertexArray=new Ls,this.symbolInstances=new Ps,this.textAnchorOffsets=new ks}calculateGlyphDependencies(e,t,i,r,n){for(const o of e)if(t[o.codePointAt(0)]=!0,(i||r)&&n){const e=cu[o];e&&(t[e.codePointAt(0)]=!0)}}populate(t,i,r){const n=this.layers[0],o=n.layout,s=o.get("text-font"),a=o.get("text-field"),l=o.get("icon-image"),c=("constant"!==a.value.kind||a.value.value instanceof Mt&&!a.value.value.isEmpty()||a.value.value.toString().length>0)&&("constant"!==s.value.kind||s.value.value.length>0),u="constant"!==l.value.kind||!!l.value.value||Object.keys(l.parameters).length>0,h=o.get("symbol-sort-key");if(this.features=[],!c&&!u)return;const d=i.iconDependencies,p=i.glyphDependencies,f=i.availableImages,m=new Mo(this.zoom);for(const{feature:i,id:a,index:l,sourceLayerIndex:g}of t){const t=n._featureFilter.needGeometry,_=Oa(i,t);if(!n._featureFilter.filter(m,_,r))continue;let A,y;if(t||(_.geometry=Da(i)),c){const e=n.getValueAndResolveTokens("text-field",_,r,f),t=Mt.factory(e),i=this.hasRTLText=this.hasRTLText||nh(t);(!i||"unavailable"===Io.getRTLTextPluginStatus()||i&&Io.isParsed())&&(A=au(t,n,_))}if(u){const e=n.getValueAndResolveTokens("icon-image",_,r,f);y=e instanceof Ot?e:Ot.fromString(e)}if(!A&&!y)continue;const v=this.sortFeaturesByKey?h.evaluate(_,{},r):void 0;if(this.features.push({id:a,text:A,icon:y,index:l,sourceLayerIndex:g,geometry:_.geometry,properties:i.properties,type:Tc.types[i.type],sortKey:v}),y&&(d[y.name]=!0),A){const t=s.evaluate(_,{},r).join(","),i="viewport"!==o.get("text-rotation-alignment")&&"point"!==o.get("symbol-placement");this.allowVerticalPlacement=this.writingModes&&this.writingModes.indexOf(e.ay.vertical)>=0;for(const e of A.sections)if(e.image)d[e.image.name]=!0;else{const r=yo(A.toString()),n=e.fontStack||t,o=p[n]=p[n]||{};this.calculateGlyphDependencies(e.text,o,i,this.allowVerticalPlacement,r)}}}"line"===o.get("symbol-placement")&&(this.features=function(e){const t={},i={},r=[];let n=0;function o(t){r.push(e[t]),n++}function s(e,t,n){const o=i[e];return delete i[e],i[t]=o,r[o].geometry[0].pop(),r[o].geometry[0]=r[o].geometry[0].concat(n[0]),o}function a(e,i,n){const o=t[i];return delete t[i],t[e]=o,r[o].geometry[0].shift(),r[o].geometry[0]=n[0].concat(r[o].geometry[0]),o}function l(e,t,i){const r=i?t[0][t[0].length-1]:t[0][0];return`${e}:${r.x}:${r.y}`}for(let c=0;ce.geometry)}(this.features)),this.sortFeaturesByKey&&this.features.sort((e,t)=>e.sortKey-t.sortKey)}update(e,t,i){this.stateDependentLayers.length&&(this.text.programConfigurations.updatePaintArrays(e,t,this.layers,{imagePositions:i}),this.icon.programConfigurations.updatePaintArrays(e,t,this.layers,{imagePositions:i}))}isEmpty(){return 0===this.symbolInstances.length&&!this.hasRTLText}uploadPending(){return!this.uploaded||this.text.programConfigurations.needsUpload||this.icon.programConfigurations.needsUpload}upload(e){!this.uploaded&&this.hasDebugData()&&(this.textCollisionBox.upload(e),this.iconCollisionBox.upload(e)),this.text.upload(e,this.sortFeaturesByY,!this.uploaded,this.text.programConfigurations.needsUpload),this.icon.upload(e,this.sortFeaturesByY,!this.uploaded,this.icon.programConfigurations.needsUpload),this.uploaded=!0}destroyDebugData(){this.textCollisionBox.destroy(),this.iconCollisionBox.destroy()}destroy(){this.text.destroy(),this.icon.destroy(),this.hasDebugData()&&this.destroyDebugData()}addToLineVertexArray(e,t){const i=this.lineVertexArray.length;if(void 0!==e.segment){let i=e.dist(t[e.segment+1]),r=e.dist(t[e.segment]);const n={};for(let r=e.segment+1;r=0;i--)n[i]={x:t[i].x,y:t[i].y,tileUnitDistanceFromAnchor:r},i>0&&(r+=t[i-1].dist(t[i]));for(let e=0;e0}hasIconData(){return this.icon.segments.get().length>0}hasDebugData(){return this.textCollisionBox&&this.iconCollisionBox}hasTextCollisionBoxData(){return this.hasDebugData()&&this.textCollisionBox.segments.get().length>0}hasIconCollisionBoxData(){return this.hasDebugData()&&this.iconCollisionBox.segments.get().length>0}addIndicesForPlacedSymbol(e,t){const i=e.placedSymbolArray.get(t),r=i.vertexStartIndex+4*i.numGlyphs;for(let t=i.vertexStartIndex;tr[e]-r[t]||n[t]-n[e]),o}addToSortKeyRanges(e,t){const i=this.sortKeyRanges[this.sortKeyRanges.length-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&&!(this.text.segments.get().length>1||this.icon.segments.get().length>1)){this.symbolInstanceIndexes=this.getSortedSymbolIndexes(e),this.sortedAngle=e,this.text.indexArray.clear(),this.icon.indexArray.clear(),this.featureSortOrder=[];for(const e of this.symbolInstanceIndexes){const t=this.symbolInstances.get(e);this.featureSortOrder.push(t.featureIndex),[t.rightJustifiedTextSymbolIndex,t.centerJustifiedTextSymbolIndex,t.leftJustifiedTextSymbolIndex].forEach((e,t,i)=>{e>=0&&i.indexOf(e)===t&&this.addIndicesForPlacedSymbol(this.text,e)}),t.verticalPlacedTextSymbolIndex>=0&&this.addIndicesForPlacedSymbol(this.text,t.verticalPlacedTextSymbolIndex),t.placedIconSymbolIndex>=0&&this.addIndicesForPlacedSymbol(this.icon,t.placedIconSymbolIndex),t.verticalPlacedIconSymbolIndex>=0&&this.addIndicesForPlacedSymbol(this.icon,t.verticalPlacedIconSymbolIndex)}this.text.indexBuffer&&this.text.indexBuffer.updateData(this.text.indexArray),this.icon.indexBuffer&&this.icon.indexBuffer.updateData(this.icon.indexArray)}}}let lh,ch;lo("SymbolBucket",ah,{omit:["layers","collisionBoxArray","features","compareText"]}),ah.MAX_GLYPHS=65535,ah.addDynamicAttributes=rh;var uh={get paint(){return ch=ch||new $o({"icon-opacity":new jo(Ae.paint_symbol["icon-opacity"]),"icon-color":new jo(Ae.paint_symbol["icon-color"]),"icon-halo-color":new jo(Ae.paint_symbol["icon-halo-color"]),"icon-halo-width":new jo(Ae.paint_symbol["icon-halo-width"]),"icon-halo-blur":new jo(Ae.paint_symbol["icon-halo-blur"]),"icon-translate":new Vo(Ae.paint_symbol["icon-translate"]),"icon-translate-anchor":new Vo(Ae.paint_symbol["icon-translate-anchor"]),"text-opacity":new jo(Ae.paint_symbol["text-opacity"]),"text-color":new jo(Ae.paint_symbol["text-color"],{runtimeType:ze,getOverride:e=>e.textColor,hasOverride:e=>!!e.textColor}),"text-halo-color":new jo(Ae.paint_symbol["text-halo-color"]),"text-halo-width":new jo(Ae.paint_symbol["text-halo-width"]),"text-halo-blur":new jo(Ae.paint_symbol["text-halo-blur"]),"text-translate":new Vo(Ae.paint_symbol["text-translate"]),"text-translate-anchor":new Vo(Ae.paint_symbol["text-translate-anchor"])})},get layout(){return lh=lh||new $o({"symbol-placement":new Vo(Ae.layout_symbol["symbol-placement"]),"symbol-spacing":new Vo(Ae.layout_symbol["symbol-spacing"]),"symbol-avoid-edges":new Vo(Ae.layout_symbol["symbol-avoid-edges"]),"symbol-sort-key":new jo(Ae.layout_symbol["symbol-sort-key"]),"symbol-z-order":new Vo(Ae.layout_symbol["symbol-z-order"]),"icon-allow-overlap":new Vo(Ae.layout_symbol["icon-allow-overlap"]),"icon-overlap":new Vo(Ae.layout_symbol["icon-overlap"]),"icon-ignore-placement":new Vo(Ae.layout_symbol["icon-ignore-placement"]),"icon-optional":new Vo(Ae.layout_symbol["icon-optional"]),"icon-rotation-alignment":new Vo(Ae.layout_symbol["icon-rotation-alignment"]),"icon-size":new jo(Ae.layout_symbol["icon-size"]),"icon-text-fit":new Vo(Ae.layout_symbol["icon-text-fit"]),"icon-text-fit-padding":new Vo(Ae.layout_symbol["icon-text-fit-padding"]),"icon-image":new jo(Ae.layout_symbol["icon-image"]),"icon-rotate":new jo(Ae.layout_symbol["icon-rotate"]),"icon-padding":new jo(Ae.layout_symbol["icon-padding"]),"icon-keep-upright":new Vo(Ae.layout_symbol["icon-keep-upright"]),"icon-offset":new jo(Ae.layout_symbol["icon-offset"]),"icon-anchor":new jo(Ae.layout_symbol["icon-anchor"]),"icon-pitch-alignment":new Vo(Ae.layout_symbol["icon-pitch-alignment"]),"text-pitch-alignment":new Vo(Ae.layout_symbol["text-pitch-alignment"]),"text-rotation-alignment":new Vo(Ae.layout_symbol["text-rotation-alignment"]),"text-field":new jo(Ae.layout_symbol["text-field"]),"text-font":new jo(Ae.layout_symbol["text-font"]),"text-size":new jo(Ae.layout_symbol["text-size"]),"text-max-width":new jo(Ae.layout_symbol["text-max-width"]),"text-line-height":new Vo(Ae.layout_symbol["text-line-height"]),"text-letter-spacing":new jo(Ae.layout_symbol["text-letter-spacing"]),"text-justify":new jo(Ae.layout_symbol["text-justify"]),"text-radial-offset":new jo(Ae.layout_symbol["text-radial-offset"]),"text-variable-anchor":new Vo(Ae.layout_symbol["text-variable-anchor"]),"text-variable-anchor-offset":new jo(Ae.layout_symbol["text-variable-anchor-offset"]),"text-anchor":new jo(Ae.layout_symbol["text-anchor"]),"text-max-angle":new Vo(Ae.layout_symbol["text-max-angle"]),"text-writing-mode":new Vo(Ae.layout_symbol["text-writing-mode"]),"text-rotate":new jo(Ae.layout_symbol["text-rotate"]),"text-padding":new Vo(Ae.layout_symbol["text-padding"]),"text-keep-upright":new Vo(Ae.layout_symbol["text-keep-upright"]),"text-transform":new jo(Ae.layout_symbol["text-transform"]),"text-offset":new jo(Ae.layout_symbol["text-offset"]),"text-allow-overlap":new Vo(Ae.layout_symbol["text-allow-overlap"]),"text-overlap":new Vo(Ae.layout_symbol["text-overlap"]),"text-ignore-placement":new Vo(Ae.layout_symbol["text-ignore-placement"]),"text-optional":new Vo(Ae.layout_symbol["text-optional"])})}};class hh{constructor(e){if(void 0===e.property.overrides)throw new Error("overrides must be provided to instantiate FormatSectionOverride class");this.type=e.property.overrides?e.property.overrides.runtimeType:Fe,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}}lo("FormatSectionOverride",hh,{omit:["defaultValue"]});class dh extends Zo{constructor(e,t){super(e,uh,t)}recalculate(e,t){if(super.recalculate(e,t),"auto"===this.layout.get("icon-rotation-alignment")&&(this.layout._values["icon-rotation-alignment"]="point"!==this.layout.get("symbol-placement")?"map":"viewport"),"auto"===this.layout.get("text-rotation-alignment")&&(this.layout._values["text-rotation-alignment"]="point"!==this.layout.get("symbol-placement")?"map":"viewport"),"auto"===this.layout.get("text-pitch-alignment")&&(this.layout._values["text-pitch-alignment"]="map"===this.layout.get("text-rotation-alignment")?"map":"viewport"),"auto"===this.layout.get("icon-pitch-alignment")&&(this.layout._values["icon-pitch-alignment"]=this.layout.get("icon-rotation-alignment")),"point"===this.layout.get("symbol-placement")){const e=this.layout.get("text-writing-mode");if(e){const t=[];for(const i of e)t.indexOf(i)<0&&t.push(i);this.layout._values["text-writing-mode"]=t}else this.layout._values["text-writing-mode"]=["horizontal"]}this._setPaintOverrides()}getValueAndResolveTokens(e,t,i,r){const n=this.layout.get(e).evaluate(t,{},i,r),o=this._unevaluatedLayout._values[e];return o.isDataDriven()||en(o.value)||!n?n:function(e,t){return t.replace(/{([^{}]+)}/g,(t,i)=>e&&i in e?String(e[i]):"")}(t.properties,n)}createBucket(e){return new ah(e)}queryRadius(){return 0}queryIntersectsFeature(){throw new Error("Should take a different path in FeatureIndex")}_setPaintOverrides(){for(const e of uh.paint.overridableProperties){if(!dh.hasPaintOverride(this.layout,e))continue;const t=this.paint.get(e),i=new hh(t),r=new Yr(i,t.property.specification);let n=null;n="constant"===t.value.kind||"source"===t.value.kind?new rn("source",r):new nn("composite",r,t.value.zoomStops),this.paint._values[e]=new Uo(t.property,n,t.parameters)}}_handleOverridablePaintPropertyUpdate(e,t,i){return!(!this.layout||t.isDataDriven()||i.isDataDriven())&&dh.hasPaintOverride(this.layout,e)}static hasPaintOverride(e,t){const i=e.get("text-field"),r=uh.paint.properties[t];let n=!1;const o=e=>{for(const t of e)if(r.overrides&&r.overrides.hasOverride(t))return void(n=!0)};if("constant"===i.value.kind&&i.value.value instanceof Mt)o(i.value.value.sections);else if("source"===i.value.kind||"composite"===i.value.kind){const e=t=>{n||(t instanceof Gt&&Vt(t.value)===Ge?o(t.value.sections):t instanceof Bi?o(t.sections):t.eachChild(e))},t=i.value;t._styleExpression&&e(t._styleExpression.expression)}return n}}let ph;var fh={get paint(){return ph=ph||new $o({"background-color":new Vo(Ae.paint_background["background-color"]),"background-pattern":new Ho(Ae.paint_background["background-pattern"]),"background-opacity":new Vo(Ae.paint_background["background-opacity"])})}};class mh extends Zo{constructor(e,t){super(e,fh,t)}}class gh extends Zo{constructor(e,t){super(e,{},t),this.onAdd=e=>{this.implementation.onAdd&&this.implementation.onAdd(e,e.painter.context.gl)},this.onRemove=e=>{this.implementation.onRemove&&this.implementation.onRemove(e,e.painter.context.gl)},this.implementation=e}is3D(){return"3d"===this.implementation.renderingMode}hasOffscreenPass(){return void 0!==this.implementation.prerender}recalculate(){}updateTransitions(){}hasTransition(){return!1}serialize(){throw new Error("Custom layers cannot be serialized")}}class _h{constructor(e){this._methodToThrottle=e,this._triggered=!1,"undefined"!=typeof MessageChannel&&(this._channel=new MessageChannel,this._channel.port2.onmessage=()=>{this._triggered=!1,this._methodToThrottle()})}trigger(){this._triggered||(this._triggered=!0,this._channel?this._channel.port1.postMessage(!0):setTimeout(()=>{this._triggered=!1,this._methodToThrottle()},0))}remove(){delete this._channel,this._methodToThrottle=()=>{}}}const Ah={once:!0},yh=6371008.8;class vh{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 vh(O(this.lng,-180,180),this.lat)}toArray(){return[this.lng,this.lat]}toString(){return`LngLat(${this.lng}, ${this.lat})`}distanceTo(e){const t=Math.PI/180,i=this.lat*t,r=e.lat*t,n=Math.sin(i)*Math.sin(r)+Math.cos(i)*Math.cos(r)*Math.cos((e.lng-this.lng)*t);return yh*Math.acos(Math.min(n,1))}static convert(e){if(e instanceof vh)return e;if(Array.isArray(e)&&(2===e.length||3===e.length))return new vh(Number(e[0]),Number(e[1]));if(!Array.isArray(e)&&"object"==typeof e&&null!==e)return new vh(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: , lat: }, an object {lon: , lat: }, or an array of [, ]")}}const xh=2*Math.PI*yh;function bh(e){return xh*Math.cos(e*Math.PI/180)}function wh(e){return(180+e)/360}function Th(e){return(180-180/Math.PI*Math.log(Math.tan(Math.PI/4+e*Math.PI/360)))/360}function Eh(e,t){return e/bh(t)}function Ch(e){return 360*e-180}function Bh(e){return 360/Math.PI*Math.atan(Math.exp((180-360*e)*Math.PI/180))-90}function Sh(e,t){return e*bh(Bh(t))}class Ih{constructor(e,t,i=0){this.x=+e,this.y=+t,this.z=+i}static fromLngLat(e,t=0){const i=vh.convert(e);return new Ih(wh(i.lng),Th(i.lat),Eh(t,i.lat))}toLngLat(){return new vh(Ch(this.x),Bh(this.y))}toAltitude(){return Sh(this.z,this.y)}meterInMercatorCoordinateUnits(){return 1/xh*(e=Bh(this.y),1/Math.cos(e*Math.PI/180));var e}}function Mh(e,t,i){var r=2*Math.PI*6378137/256/Math.pow(2,i);return[e*r-2*Math.PI*6378137/2,t*r-2*Math.PI*6378137/2]}class Ph{constructor(e,t,i){if(!function(e,t,i){return!(e<0||e>25||i<0||i>=Math.pow(2,e)||t<0||t>=Math.pow(2,e))}(e,t,i))throw new Error(`x=${t}, y=${i}, z=${e} outside of bounds. 0<=x<${Math.pow(2,e)}, 0<=y<${Math.pow(2,e)} 0<=z<=25 `);this.z=e,this.x=t,this.y=i,this.key=Fh(0,e,e,t,i)}equals(e){return this.z===e.z&&this.x===e.x&&this.y===e.y}url(e,t,i){const r=(o=this.y,s=this.z,a=Mh(256*(n=this.x),256*(o=Math.pow(2,s)-o-1),s),l=Mh(256*(n+1),256*(o+1),s),a[0]+","+a[1]+","+l[0]+","+l[1]);var n,o,s,a,l;const c=function(e,t,i){let r,n="";for(let o=e;o>0;o--)r=1<1?"@2x":"").replace(/{quadkey}/g,c).replace(/{bbox-epsg-3857}/g,r)}isChildOf(e){const t=this.z-e.z;return t>0&&e.x===this.x>>t&&e.y===this.y>>t}getTilePoint(e){const t=Math.pow(2,this.z);return new i((e.x*t-this.x)*I,(e.y*t-this.y)*I)}toString(){return`${this.z}/${this.x}/${this.y}`}}class Rh{constructor(e,t){this.wrap=e,this.canonical=t,this.key=Fh(e,t.z,t.z,t.x,t.y)}}class Lh{constructor(e,t,i,r,n){if(this.terrainRttPosMatrix32f=null,e= z; overscaledZ = ${e}; z = ${i}`);this.overscaledZ=e,this.wrap=t,this.canonical=new Ph(i,+r,+n),this.key=Fh(t,e,i,r,n)}clone(){return new Lh(this.overscaledZ,this.wrap,this.canonical.z,this.canonical.x,this.canonical.y)}equals(e){return this.overscaledZ===e.overscaledZ&&this.wrap===e.wrap&&this.canonical.equals(e.canonical)}scaledTo(e){if(e>this.overscaledZ)throw new Error(`targetZ > this.overscaledZ; targetZ = ${e}; overscaledZ = ${this.overscaledZ}`);const t=this.canonical.z-e;return e>this.canonical.z?new Lh(e,this.wrap,this.canonical.z,this.canonical.x,this.canonical.y):new Lh(e,this.wrap,e,this.canonical.x>>t,this.canonical.y>>t)}isOverscaled(){return this.overscaledZ>this.canonical.z}calculateScaledKey(e,t){if(e>this.overscaledZ)throw new Error(`targetZ > this.overscaledZ; targetZ = ${e}; overscaledZ = ${this.overscaledZ}`);const i=this.canonical.z-e;return e>this.canonical.z?Fh(this.wrap*+t,e,this.canonical.z,this.canonical.x,this.canonical.y):Fh(this.wrap*+t,e,e,this.canonical.x>>i,this.canonical.y>>i)}isChildOf(e){if(e.wrap!==this.wrap)return!1;if(this.overscaledZ-e.overscaledZ<=0)return!1;if(0===e.overscaledZ)return this.overscaledZ>0;const t=this.canonical.z-e.canonical.z;return!(t<0)&&e.canonical.x===this.canonical.x>>t&&e.canonical.y===this.canonical.y>>t}children(e){if(this.overscaledZ>=e)return[new Lh(this.overscaledZ+1,this.wrap,this.canonical.z,this.canonical.x,this.canonical.y)];const t=this.canonical.z+1,i=2*this.canonical.x,r=2*this.canonical.y;return[new Lh(t,this.wrap,t,i,r),new Lh(t,this.wrap,t,i+1,r),new Lh(t,this.wrap,t,i,r+1),new Lh(t,this.wrap,t,i+1,r+1)]}isLessThan(e){return this.wrape.wrap)&&(this.overscaledZe.overscaledZ)&&(this.canonical.xe.canonical.x)&&this.canonical.ye.key===i);t>-1&&e.addOrUpdateProperties.splice(t,1)}return(e.removeAllProperties||t.removeAllProperties)&&(i.removeAllProperties=!0),(e.removeProperties||t.removeProperties)&&(i.removeProperties=[...e.removeProperties||[],...t.removeProperties||[]]),(e.addOrUpdateProperties||t.addOrUpdateProperties)&&(i.addOrUpdateProperties=[...e.addOrUpdateProperties||[],...t.addOrUpdateProperties||[]]),(e.newGeometry||t.newGeometry)&&(i.newGeometry=t.newGeometry||e.newGeometry),i}function Oh(e){var t,i;if(!e)return{};const r={};return r.removeAll=e.removeAll,r.remove=new Set(e.remove||[]),r.add=new Map(null===(t=e.add)||void 0===t?void 0:t.map(e=>[e.id,e])),r.update=new Map(null===(i=e.update)||void 0===i?void 0:i.map(e=>[e.id,e])),r}lo("CanonicalTileID",Ph),lo("OverscaledTileID",Lh,{omit:["terrainRttPosMatrix32f"]});class zh{constructor(e){this._stringToNumber={},this._numberToString=[];for(let t=0;t=this._numberToString.length)throw new Error(`Out of bounds. Index requested n=${e} can't be >= this._numberToString.length ${this._numberToString.length}`);return this._numberToString[e]}}class Uh{constructor(e,t,i,r,n){this.type="Feature",this._vectorTileFeature=e,e._z=t,e._x=i,e._y=r,this.properties=e.properties,this.id=n}get geometry(){return void 0===this._geometry&&(this._geometry=this._vectorTileFeature.toGeoJSON(this._vectorTileFeature._x,this._vectorTileFeature._y,this._vectorTileFeature._z).geometry),this._geometry}set geometry(e){this._geometry=e}toJSON(){const e={geometry:this.geometry};for(const t in this)"_geometry"!==t&&"_vectorTileFeature"!==t&&(e[t]=this[t]);return e}}class Nh{_name;dataBuffer;nullabilityBuffer;_size;constructor(e,t,i){this._name=e,this.dataBuffer=t,"number"==typeof i?this._size=i:(this.nullabilityBuffer=i,this._size=i.size())}getValue(e){return this.nullabilityBuffer&&!this.nullabilityBuffer.get(e)?null:this.getValueFromBuffer(e)}has(e){return this.nullabilityBuffer&&this.nullabilityBuffer.get(e)||!this.nullabilityBuffer}get name(){return this._name}get size(){return this._size}}class Vh extends Nh{}class jh extends Vh{getValueFromBuffer(e){return this.dataBuffer[e]}}class Gh extends Vh{getValueFromBuffer(e){return this.dataBuffer[e]}}class Hh extends Nh{delta;constructor(e,t,i,r){super(e,t,r),this.delta=i}}class Qh extends Hh{constructor(e,t,i,r){super(e,Int32Array.of(t),i,r)}getValueFromBuffer(e){return this.dataBuffer[0]+e*this.delta}}class $h extends Nh{constructor(e,t,i){super(e,Int32Array.of(t),i)}getValueFromBuffer(e){return this.dataBuffer[0]}}class Zh{_name;_geometryVector;_idVector;_propertyVectors;_extent;propertyVectorsMap;constructor(e,t,i,r,n=4096){this._name=e,this._geometryVector=t,this._idVector=i,this._propertyVectors=r,this._extent=n}get name(){return this._name}get idVector(){return this._idVector}get geometryVector(){return this._geometryVector}get propertyVectors(){return this._propertyVectors}getPropertyVector(e){return this.propertyVectorsMap||(this.propertyVectorsMap=new Map(this._propertyVectors.map(e=>[e.name,e]))),this.propertyVectorsMap.get(e)}*[Symbol.iterator](){const e=this.geometryVector[Symbol.iterator]();let t=0;for(;t>4,n<128)return 4294967296*r+(e>>>0);if(n=t[i.get()],i.increment(),r|=(127&n)<<3,n<128)return 4294967296*r+(e>>>0);if(n=t[i.get()],i.increment(),r|=(127&n)<<10,n<128)return 4294967296*r+(e>>>0);if(n=t[i.get()],i.increment(),r|=(127&n)<<17,n<128)return 4294967296*r+(e>>>0);if(n=t[i.get()],i.increment(),r|=(127&n)<<24,n<128)return 4294967296*r+(e>>>0);if(n=t[i.get()],i.increment(),r|=(1&n)<<31,n<128)return 4294967296*r+(e>>>0);throw new Error("Expected varint not more than 10 bytes")}(i,e,t)))))}function cd(e,t,i,r){throw new Error("FastPFor is not implemented yet.")}function ud(e){return e>>>1^-(1&e)}function hd(e){return e>>1n^-(1n&e)}function dd(e,t){let i=0n,r=0,n=t.get();for(;n=64)throw new Error("Varint too long")}return t.set(n),i}function pd(e,t,i){const r=new Int32Array(i);let n=0;for(let i=0;i=4)for(let r=e[0];i>>1^-(1&e[0]),e[1]=e[1]>>>1^-(1&e[1]);const t=e.length/4*4;let i=2;if(t>=4)for(;i>>1^-(1&t))+e[i-2],e[i+1]=(r>>>1^-(1&r))+e[i-1],e[i+2]=(n>>>1^-(1&n))+e[i],e[i+3]=(o>>>1^-(1&o))+e[i+1]}for(;i!=e.length;i+=2)e[i]=(e[i]>>>1^-(1&e[i]))+e[i-2],e[i+1]=(e[i+1]>>>1^-(1&e[i+1]))+e[i-1]}function Ad(e,t,i){return Math.min(i,Math.max(t,e))}!function(e){e.NONE="NONE",e.DELTA="DELTA",e.COMPONENTWISE_DELTA="COMPONENTWISE_DELTA",e.RLE="RLE",e.MORTON="MORTON",e.PDE="PDE"}(Kh||(Kh={})),function(e){e.NONE="NONE",e.FAST_PFOR="FAST_PFOR",e.VARINT="VARINT",e.ALP="ALP"}(Xh||(Xh={})),function(e){e.NONE="NONE",e.SINGLE="SINGLE",e.SHARED="SHARED",e.VERTEX="VERTEX",e.MORTON="MORTON",e.FSST="FSST"}(Jh||(Jh={})),function(e){e.VERTEX="VERTEX",e.INDEX="INDEX",e.STRING="STRING",e.KEY="KEY"}(Yh||(Yh={})),function(e){e.VAR_BINARY="VAR_BINARY",e.GEOMETRIES="GEOMETRIES",e.PARTS="PARTS",e.RINGS="RINGS",e.TRIANGLES="TRIANGLES",e.SYMBOL="SYMBOL",e.DICTIONARY="DICTIONARY"}(ed||(ed={}));class yd{_physicalStreamType;_logicalStreamType;_logicalLevelTechnique1;_logicalLevelTechnique2;_physicalLevelTechnique;_numValues;_byteLength;constructor(e,t,i,r,n,o,s){this._physicalStreamType=e,this._logicalStreamType=t,this._logicalLevelTechnique1=i,this._logicalLevelTechnique2=r,this._physicalLevelTechnique=n,this._numValues=o,this._byteLength=s}static decode(e,t){const i=e[t.get()],r=Object.values(qh)[i>>4];let n=null;switch(r){case qh.DATA:n=new od(Object.values(Jh)[15&i]);break;case qh.OFFSET:n=new od(null,Object.values(Yh)[15&i]);break;case qh.LENGTH:n=new od(null,null,Object.values(ed)[15&i])}t.increment();const o=e[t.get()],s=Object.values(Kh)[o>>5],a=Object.values(Kh)[o>>2&7],l=Object.values(Xh)[3&o];t.increment();const c=sd(e,t,2);return new yd(r,n,s,a,l,c[0],c[1])}get physicalStreamType(){return this._physicalStreamType}get logicalStreamType(){return this._logicalStreamType}get logicalLevelTechnique1(){return this._logicalLevelTechnique1}get logicalLevelTechnique2(){return this._logicalLevelTechnique2}get physicalLevelTechnique(){return this._physicalLevelTechnique}get numValues(){return this._numValues}get byteLength(){return this._byteLength}getDecompressedCount(){return this._numValues}}class vd extends yd{num_bits;coordinate_shift;constructor(e,t,i,r,n,o,s,a,l){super(e,t,i,r,n,o,s),this.num_bits=a,this.coordinate_shift=l}static decode(e,t){const i=yd.decode(e,t),r=sd(e,t,2);return new vd(i.physicalStreamType,i.logicalStreamType,i.logicalLevelTechnique1,i.logicalLevelTechnique2,i.physicalLevelTechnique,i.numValues,i.byteLength,r[0],r[1])}static decodePartial(e,t,i){const r=sd(t,i,2);return new vd(e.physicalStreamType,e.logicalStreamType,e.logicalLevelTechnique1,e.logicalLevelTechnique2,e.physicalLevelTechnique,e.numValues,e.byteLength,r[0],r[1])}numBits(){return this.num_bits}coordinateShift(){return this.coordinate_shift}}class xd extends yd{_runs;_numRleValues;constructor(e,t,i,r,n,o,s,a,l){super(e,t,i,r,n,o,s),this._runs=a,this._numRleValues=l}static decode(e,t){const i=yd.decode(e,t),r=sd(e,t,2);return new xd(i.physicalStreamType,i.logicalStreamType,i.logicalLevelTechnique1,i.logicalLevelTechnique2,i.physicalLevelTechnique,i.numValues,i.byteLength,r[0],r[1])}static decodePartial(e,t,i){const r=sd(t,i,2);return new xd(e.physicalStreamType,e.logicalStreamType,e.logicalLevelTechnique1,e.logicalLevelTechnique2,e.physicalLevelTechnique,e.numValues,e.byteLength,r[0],r[1])}get runs(){return this._runs}get numRleValues(){return this._numRleValues}getDecompressedCount(){return this._numRleValues}}class bd{static decode(e,t){const i=yd.decode(e,t);return i.logicalLevelTechnique1===Kh.MORTON?vd.decodePartial(i,e,t):Kh.RLE!==i.logicalLevelTechnique1&&Kh.RLE!==i.logicalLevelTechnique2||Xh.NONE===i.physicalLevelTechnique?i:xd.decodePartial(i,e,t)}}!function(e){e[e.FLAT=0]="FLAT",e[e.CONST=1]="CONST",e[e.SEQUENCE=2]="SEQUENCE",e[e.DICTIONARY=3]="DICTIONARY",e[e.FSST_DICTIONARY=4]="FSST_DICTIONARY"}(td||(td={}));class wd{values;_size;constructor(e,t){this.values=e,this._size=t}get(e){const t=Math.floor(e/8);return 1==(this.values[t]>>e%8&1)}set(e,t){const i=Math.floor(e/8);this.values[i]=this.values[i]|(t?1:0)<>e%8&1}size(){return this._size}getBuffer(){return this.values}}class Td{constructor(){}static decodeIntStream(e,t,i,r,n){const o=Td.decodePhysicalLevelTechnique(e,t,i);return this.decodeIntBuffer(o,i,r,n)}static decodeLengthStreamToOffsetBuffer(e,t,i){const r=Td.decodePhysicalLevelTechnique(e,t,i);return this.decodeLengthToOffsetBuffer(r,i)}static decodePhysicalLevelTechnique(e,t,i){const r=i.physicalLevelTechnique;if(r===Xh.FAST_PFOR)return cd();if(r===Xh.VARINT)return sd(e,t,i.numValues);if(r===Xh.NONE){const r=t.get();t.add(i.byteLength);const n=e.subarray(r,t.get());return new Int32Array(n)}throw new Error("Specified physicalLevelTechnique is not supported (yet).")}static decodeConstIntStream(e,t,i,r){const n=Td.decodePhysicalLevelTechnique(e,t,i);if(1===n.length){const e=n[0];return r?ud(e):e}return r?function(e){return ud(e[1])}(n):function(e){return e[1]}(n)}static decodeSequenceIntStream(e,t,i){return function(e){if(2==e.length){const t=ud(e[1]);return[t,t]}return[ud(e[2]),ud(e[3])]}(Td.decodePhysicalLevelTechnique(e,t,i))}static decodeSequenceLongStream(e,t,i){return function(e){if(2==e.length){const t=hd(e[1]);return[t,t]}return[hd(e[2]),hd(e[3])]}(ad(e,t,i.numValues))}static decodeLongStream(e,t,i,r){const n=ad(e,t,i.numValues);return this.decodeLongBuffer(n,i,r)}static decodeLongFloat64Stream(e,t,i,r){const n=function(e,t,i){const r=new Float64Array(t);for(let n=0;n>>1^-(1&e[0]);const t=e.length/4*4;let i=1;if(t>=4)for(;i>>1^-(1&t))+e[i-1],e[i+1]=(r>>>1^-(1&r))+e[i],e[i+2]=(n>>>1^-(1&n))+e[i+1],e[i+3]=(o>>>1^-(1&o))+e[i+2]}for(;i!=e.length;++i)e[i]=(e[i]>>>1^-(1&e[i]))+e[i-1]}(e),e);case Kh.RLE:return function(e,t,i){return i?function(e,t,i){const r=new Int32Array(i);let n=0;for(let i=0;i>>1^-(1&s),r.fill(s,n,n+o),n+=o}return r}(e,t.runs,t.numRleValues):pd(e,t.runs,t.numRleValues)}(e,t,i);case Kh.MORTON:return gd(e),e;case Kh.COMPONENTWISE_DELTA:return r?(function(e,t,i,r){let n=e[0]>>>1^-(1&e[0]),o=e[1]>>>1^-(1&e[1]);e[0]=Ad(Math.round(n*t),i,r),e[1]=Ad(Math.round(o*t),i,r);const s=e.length/16;let a=2;if(s>=4)for(;a>>1^-(1&s))+n,u=(l>>>1^-(1&l))+o;e[a]=Ad(Math.round(c*t),i,r),e[a+1]=Ad(Math.round(u*t),i,r);const h=e[a+2],d=e[a+3];n=(h>>>1^-(1&h))+c,o=(d>>>1^-(1&d))+u,e[a+2]=Ad(Math.round(n*t),i,r),e[a+3]=Ad(Math.round(o*t),i,r)}for(;a!=e.length;a+=2)n+=e[a]>>>1^-(1&e[a]),o+=e[a+1]>>>1^-(1&e[a+1]),e[a]=Ad(Math.round(n*t),i,r),e[a+1]=Ad(Math.round(o*t),i,r)}(e,r.scale,r.min,r.max),e):(_d(e),e);case Kh.NONE:return i&&function(e){for(let t=0;t>>1^-(1&i)}}(e),e;default:throw new Error(`The specified Logical level technique is not supported: ${t.logicalLevelTechnique1}`)}}static decodeLongBuffer(e,t,i){switch(t.logicalLevelTechnique1){case Kh.DELTA:return t.logicalLevelTechnique2===Kh.RLE?function(e,t,i){const r=new BigInt64Array(i);let n=0,o=0n;for(let i=0;i>1n^-(1n&e[0]);const t=e.length/4*4;let i=1;if(t>=4)for(;i>1n^-(1n&t))+e[i-1],e[i+1]=(r>>1n^-(1n&r))+e[i],e[i+2]=(n>>1n^-(1n&n))+e[i+1],e[i+3]=(o>>1n^-(1n&o))+e[i+2]}for(;i!=e.length;++i)e[i]=(e[i]>>1n^-(1n&e[i]))+e[i-1]}(e),e);case Kh.RLE:return function(e,t,i){return i?function(e,t,i){const r=new BigInt64Array(i);let n=0;for(let i=0;i>1n^-(1n&s),r.fill(s,n,n+o),n+=o}return r}(e,t.runs,t.numRleValues):fd(e,t.runs,t.numRleValues)}(e,t,i);case Kh.NONE:return i&&function(e){for(let t=0;t>1n^-(1n&i)}}(e),e;default:throw new Error(`The specified Logical level technique is not supported: ${t.logicalLevelTechnique1}`)}}static decodeFloat64Buffer(e,t,i){switch(t.logicalLevelTechnique1){case Kh.DELTA:return t.logicalLevelTechnique2===Kh.RLE&&(e=md(e,t.runs,t.numRleValues)),function(e){e[0]=e[0]%2==1?(e[0]+1)/-2:e[0]/2;const t=e.length/4*4;let i=1;if(t>=4)for(;i>>1^-(1&n),t[r]=t[r-1]+i}return t}(e);if(t.logicalLevelTechnique1===Kh.RLE&&t.logicalLevelTechnique2===Kh.NONE)return function(e,t,i){const r=new Int32Array(i+1);r[0]=0;let n=1,o=r[0];for(let i=0;i>>1^-(1&a);for(let e=n;e>>1^-(1&t[0]):0,r=1):i[0]=0;let n=1;for(;n!=i.length;++n)i[n]=e.get(n)?i[n-1]+(t[r]>>>1^-(1&t[r++])):i[n-1];return i}(r,e);case Kh.RLE:return function(e,t,i,r){const n=t;return i?function(e,t,i){const r=new Int32Array(e.size());let n=0;for(let o=0;o>>1^-(1&a);for(let t=n;t>>1^-(1&e)}else i[n]=0;return i}(r,e):function(e,t){const i=new Int32Array(e.size());let r=0,n=0;for(;n!=i.length;++n)i[n]=e.get(n)?t[r++]:0;return i}(r,e),e;default:throw new Error("The specified Logical level technique is not supported")}}static decodeNullableLongBuffer(e,t,i,r){switch(t.logicalLevelTechnique1){case Kh.DELTA:return t.logicalLevelTechnique2===Kh.RLE&&(e=fd(e,t.runs,t.numRleValues)),function(e,t){const i=new BigInt64Array(e.size());let r=0;e.get(0)?(i[0]=e.get(0)?t[0]>>1n^-(1n&t[0]):0n,r=1):i[0]=0n;let n=1;for(;n!=i.length;++n)i[n]=e.get(n)?i[n-1]+(t[r]>>1n^-(1n&t[r++])):i[n-1];return i}(r,e);case Kh.RLE:return function(e,t,i,r){const n=t;return i?function(e,t,i){const r=new BigInt64Array(e.size());let n=0;for(let o=0;o>1n^-(1n&a);for(let t=n;t>1n^-(1n&e)}else i[n]=0n;return i}(r,e):function(e,t){const i=new BigInt64Array(e.size());let r=0,n=0;for(;n!=i.length;++n)i[n]=e.get(n)?t[r++]:0n;return i}(r,e),e;default:throw new Error("The specified Logical level technique is not supported")}}static getVectorType(e,t,i,r){const n=e.logicalLevelTechnique1;if(n===Kh.RLE)return 1===e.runs?td.CONST:td.FLAT;const o=t instanceof wd?t.size():t;if(n===Kh.DELTA&&e.logicalLevelTechnique2===Kh.RLE){const t=e.runs,n=2;if(e.numRleValues!==o)return td.FLAT;if(1===t)return td.SEQUENCE;if(2===t){const t=r.get();let o;if(e.physicalLevelTechnique===Xh.VARINT)o=sd(i,r,4);else{const e=r.get();o=new Int32Array(i.buffer,i.byteOffset+e,4)}if(r.set(t),o[2]===n&&o[3]===n)return td.SEQUENCE}}return 1===e.numValues?td.CONST:td.FLAT}}class Ed extends Vh{getValueFromBuffer(e){return this.dataBuffer[e]}}class Cd extends Hh{constructor(e,t,i,r){super(e,BigInt64Array.of(t),i,r)}getValueFromBuffer(e){return this.dataBuffer[0]+BigInt(e)*this.delta}}class Bd{_geometryOffsets;_partOffsets;_ringOffsets;constructor(e,t,i){this._geometryOffsets=e,this._partOffsets=t,this._ringOffsets=i}get geometryOffsets(){return this._geometryOffsets}get partOffsets(){return this._partOffsets}get ringOffsets(){return this._ringOffsets}}class Sd{tileExtent;_numBits;_coordinateShift;minBound;maxBound;constructor(e,t){this._coordinateShift=e<0?Math.abs(e):0,this.tileExtent=t+this._coordinateShift,this._numBits=Math.ceil(Math.log2(this.tileExtent)),this.minBound=e,this.maxBound=t}validateCoordinates(e){if(e.xthis.maxBound||e.y>this.maxBound)throw new Error("The specified tile buffer size is currently not supported.")}numBits(){return this._numBits}coordinateShift(){return this._coordinateShift}}class Id extends Sd{encode(e){this.validateCoordinates(e);const t=e.x+this._coordinateShift,i=e.y+this._coordinateShift;let r=0;for(let e=0;e>1)-this._coordinateShift}}decodeMorton(e){let t=0;for(let i=0;i>i;return t}static decode(e,t,i){return{x:Id.decodeMorton(e,t)-i,y:Id.decodeMorton(e>>1,t)-i}}static decodeMorton(e,t){let i=0;for(let r=0;r>r;return i}}!function(e){e[e.POINT=0]="POINT",e[e.LINESTRING=1]="LINESTRING",e[e.POLYGON=2]="POLYGON",e[e.MULTIPOINT=3]="MULTIPOINT",e[e.MULTILINESTRING=4]="MULTILINESTRING",e[e.MULTIPOLYGON=5]="MULTIPOLYGON"}(id||(id={})),function(e){e[e.POINT=0]="POINT",e[e.LINESTRING=1]="LINESTRING",e[e.POLYGON=2]="POLYGON"}(rd||(rd={})),function(e){e[e.MORTON=0]="MORTON",e[e.VEC_2=1]="VEC_2",e[e.VEC_3=2]="VEC_3"}(nd||(nd={}));class Md{createPoint(e){return[[e]]}createMultiPoint(e){return e.map(e=>[e])}createLineString(e){return[e]}createMultiLineString(e){return e}createPolygon(e,t){return[e,...t]}createMultiPolygon(e){return e.flat()}}function Pd(e){const t=new Array(e.numGeometries);let r=1,n=1,o=1,s=0;const a=new Md;let l=0,c=0;const u=e.mortonSettings,h=e.topologyVector,d=h.geometryOffsets,p=h.partOffsets,f=h.ringOffsets,m=e.vertexOffsets,g=e.containsPolygonGeometry(),_=e.vertexBuffer;for(let h=0;h0&&t.push(t[0]),h.push(t)}e[t]=h,o&&c++}break;case id.MULTIPOLYGON:{const u=o[c]-o[c-1];c++;const h=[];for(let e=0;e0&&t.push(t[0]),h.push(t)}}e[t]=h}}return e}[Symbol.iterator](){return null}}class jd extends Vd{_numGeometries;_geometryType;constructor(e,t,i,r,n,o){super(i,r,n,o),this._numGeometries=e,this._geometryType=t}static create(e,t,i,r,n,o){return new jd(e,t,i,r,n,o)}geometryType(e){return this._geometryType}get numGeometries(){return this._numGeometries}containsSingleGeometryType(){return!0}}class Gd extends Vd{_geometryTypes;constructor(e,t,i,r,n){super(t,i,r,n),this._geometryTypes=e}static create(e,t,i,r,n){return new Gd(e,t,i,r,n)}geometryType(e){return this._geometryTypes[e]}get numGeometries(){return this._geometryTypes.length}containsSingleGeometryType(){return!1}}function Hd(e,t,i,r,n){const o=bd.decode(e,i);let s=null,a=null,l=null,c=null,u=null,h=null,d=null,p=null;if(Td.getVectorType(o,r,e,i)===td.CONST){const f=Td.decodeConstIntStream(e,i,o,!1);for(let r=0;ri?t[o++]:1);return r}function $d(e,t,i,r){const n=new Int32Array(t[t.length-1]+1);let o=0;n[0]=o;let s=1,a=0;for(let l=0;l=12?Yd.decode(e.subarray(t,i)):function(e,t,i){let r="",n=t;for(;n239?4:t>223?3:t>191?2:1;if(n+c>i)break;1===c?t<128&&(l=t):2===c?(o=e[n+1],128==(192&o)&&(l=(31&t)<<6|63&o,l<=127&&(l=null))):3===c?(o=e[n+1],s=e[n+2],128==(192&o)&&128==(192&s)&&(l=(15&t)<<12|(63&o)<<6|63&s,(l<=2047||l>=55296&&l<=57343)&&(l=null))):4===c&&(o=e[n+1],s=e[n+2],a=e[n+3],128==(192&o)&&128==(192&s)&&128==(192&a)&&(l=(15&t)<<18|(63&o)<<12|(63&s)<<6|63&a,(l<=65535||l>=1114112)&&(l=null))),null===l?(l=65533,c=1):l>65535&&(l-=65536,r+=String.fromCharCode(l>>>10&1023|55296),l=56320|1023&l),r+=String.fromCharCode(l),n+=c}return r}(e,t,i)}class tp extends Nh{offsetBuffer;constructor(e,t,i,r){super(e,i,r),this.offsetBuffer=t}}class ip extends tp{textEncoder;constructor(e,t,i,r){super(e,t,i,r??t.length-1),this.textEncoder=new TextEncoder}getValueFromBuffer(e){return ep(this.dataBuffer,this.offsetBuffer[e],this.offsetBuffer[e+1])}}class rp extends tp{indexBuffer;textEncoder;constructor(e,t,i,r,n){super(e,i,r,n??t.length),this.indexBuffer=t,this.indexBuffer=t,this.textEncoder=new TextEncoder}getValueFromBuffer(e){const t=this.indexBuffer[e];return ep(this.dataBuffer,this.offsetBuffer[t],this.offsetBuffer[t+1])}}class np extends tp{indexBuffer;symbolOffsetBuffer;symbolTableBuffer;textEncoder;symbolLengthBuffer;lengthBuffer;decodedDictionary;constructor(e,t,i,r,n,o,s){super(e,i,r,s),this.indexBuffer=t,this.symbolOffsetBuffer=n,this.symbolTableBuffer=o,this.textEncoder=new TextEncoder}getValueFromBuffer(e){null==this.decodedDictionary&&(null==this.symbolLengthBuffer&&(this.symbolLengthBuffer=this.offsetToLengthBuffer(this.symbolOffsetBuffer),this.lengthBuffer=this.offsetToLengthBuffer(this.offsetBuffer)),this.decodedDictionary=function(e,t,i){const r=[],n=new Array(t.length).fill(0);for(let e=1;e1?6:4,i.type="physicalType",t.scalarType=i,t.type="scalarType",t}case 4:{const e={nullable:!1,columnScope:0},t={type:"physicalType",physicalType:0};return e.type="complexType",e.complexType=t,e}case 30:{const e={nullable:!1,columnScope:0},t={type:"physicalType",physicalType:1};return e.type="complexType",e.complexType=t,e}default:return this.mapScalarType(e)}}static columnTypeHasName(e){return e>=10}static columnTypeHasChildren(e){return 30===e}static hasStreamCount(e){if("id"===e.name)return!1;if("scalarType"===e.type){const t=e.scalarType;if("physicalType"===t.type)switch(t.physicalType){case 0:case 1:case 2:case 3:case 4:case 5:case 6:case 7:case 8:default:return!1;case 9:return!0}else if("logicalType"===t.type)return!1}else if("complexType"===e.type){const t=e.complexType;if("physicalType"===t.type)switch(t.physicalType){case 0:case 1:return!0;default:return!1}}return console.warn("Unexpected column type in hasStreamCount",e),!1}static mapScalarType(e){let t=null;switch(e){case 10:case 11:t=0;break;case 12:case 13:t=1;break;case 14:case 15:t=2;break;case 16:case 17:t=3;break;case 18:case 19:t=4;break;case 20:case 21:t=5;break;case 22:case 23:t=6;break;case 24:case 25:t=7;break;case 26:case 27:t=8;break;case 28:case 29:t=9;break;default:return null}const i={};i.nullable=!!(1&e),i.columnScope=0;const r={type:"physicalType"};return r.physicalType=t,i.type="scalarType",i.scalarType=r,i}}const cp=new TextDecoder;function up(e,t){const i=sd(e,t,1)[0];if(0===i)return"";const r=t.get(),n=e.subarray(r,r+i);return t.add(i),cp.decode(n)}function hp(e,t){const i=sd(e,t,1)[0]>>>0,r=!!(4&i),n=!!(2&i),o=sd(e,t,1)[0]>>>0,s={};if(1&i&&(s.nullable=!0),n){const n={};if(r?(n.type="logicalType",n.logicalType=o):(n.type="physicalType",n.physicalType=o),8&i){const i=sd(e,t,1)[0]>>>0;n.children=new Array(i);for(let r=0;r>>0,r=lp.decodeColumnType(i);if(!r)throw new Error(`Unsupported column type code: ${i}`);if(lp.columnTypeHasName(i)?r.name=up(e,t):i>=0&&i<=3?r.name="id":4===i&&(r.name="geometry"),lp.columnTypeHasChildren(i)){const i=sd(e,t,1)[0]>>>0,n=r.complexType;n.children=new Array(i);for(let r=0;r>>0,o=sd(e,t,1)[0]>>>0;r.columns=new Array(o);for(let i=0;ithis.projectPoint(e,t,i,r))}toGeoJSON(e,t,i){const r=this.extent*Math.pow(2,i),n=this.extent*e,o=this.extent*t,s=this.loadGeometry();let a;switch(this.type){case 1:{const e=[];for(const t of s)e.push(t[0]);const t=this.projectLine(e,n,o,r);a=1===e.length?{type:"Point",coordinates:t[0]}:{type:"MultiPoint",coordinates:t};break}case 2:{const e=s.map(e=>this.projectLine(e,n,o,r));a=1===e.length?{type:"LineString",coordinates:e[0]}:{type:"MultiLineString",coordinates:e};break}case 3:{const e=Yi(s),t=[];for(const i of e)t.push(i.map(e=>this.projectLine(e,n,o,r)));a=1===t.length?{type:"Polygon",coordinates:t[0]}:{type:"MultiPolygon",coordinates:t};break}default:throw new Error(`unknown feature type: ${this.type}`)}const l={type:"Feature",geometry:a,properties:this.properties};return null!=this.id&&(l.id=this.id),l}loadGeometry(){const e=[];for(const t of this._featureData.geometry.coordinates){const r=[];for(const e of t)r.push(new i(e.x,e.y));e.push(r)}return e}bbox(){return[0,0,0,0]}}class gp{constructor(e){this.features=[],this.featureTable=e,this.name=e.name,this.extent=e.extent,this.version=2,this.features=e.getFeatures(),this.length=this.features.length}feature(e){return new mp(this.features[e],this.extent)}}class _p{constructor(e){this.layers={};const t=function(e,t,i=!0){const r=new Wh(0),n=[];for(;r.get()>>0,s=r.get()+o;if(s>e.length)throw new Error(`Block overruns tile: ${s} > ${e.length}`);if(1!=sd(e,r,1)[0]>>>0){r.set(s);continue}const a=pp(e,r),l=a[1],c=a[0].featureTables[0];let u=null,h=null;const d=[];let p=0;for(const n of c.columns){const o=n.name;if("id"===o){let t=null;if(n.nullable){const i=bd.decode(e,r),n=r.get(),o=Xd(e,i.numValues,r);r.set(n+i.byteLength),t=new wd(o,i.numValues)}const s=bd.decode(e,r);p=s.getDecompressedCount(),u=fp(e,n,r,o,s,t??p,i)}else if("geometry"===o){const i=sd(e,r,1)[0];if(0===p){const t=r.get();p=bd.decode(e,r).getDecompressedCount(),r.set(t)}h=Hd(e,i,r,p,t)}else{const t=lp.hasStreamCount(n)?sd(e,r,1)[0]:1;if(0===t&&"scalarType"===n.type)continue;const i=sp(e,r,n,t,p,void 0);i&&(Array.isArray(i)?d.push(...i):d.push(i))}}const f=new Zh(c.name,h,u,d,l);n.push(f),r.set(s)}return n}(new Uint8Array(e));this.layers=t.reduce((e,t)=>Object.assign(Object.assign({},e),{[t.name]:new gp(t)}),{})}}class Ap{constructor(){this.minX=1/0,this.maxX=-1/0,this.minY=1/0,this.maxY=-1/0}extend(e){return this.minX=Math.min(this.minX,e.x),this.minY=Math.min(this.minY,e.y),this.maxX=Math.max(this.maxX,e.x),this.maxY=Math.max(this.maxY,e.y),this}expandBy(e){return this.minX-=e,this.minY-=e,this.maxX+=e,this.maxY+=e,(this.minX>this.maxX||this.minY>this.maxY)&&(this.minX=1/0,this.maxX=-1/0,this.minY=1/0,this.maxY=-1/0),this}shrinkBy(e){return this.expandBy(-e)}map(e){const t=new Ap;return t.extend(e(new i(this.minX,this.minY))),t.extend(e(new i(this.maxX,this.minY))),t.extend(e(new i(this.minX,this.maxY))),t.extend(e(new i(this.maxX,this.maxY))),t}static fromPoints(e){const t=new Ap;for(const i of e)t.extend(i);return t}contains(e){return e.x>=this.minX&&e.x<=this.maxX&&e.y>=this.minY&&e.y<=this.maxY}empty(){return this.minX>this.maxX}width(){return this.maxX-this.minX}height(){return this.maxY-this.minY}covers(e){return!this.empty()&&!e.empty()&&e.minX>=this.minX&&e.maxX<=this.maxX&&e.minY>=this.minY&&e.maxY<=this.maxY}intersects(e){return!this.empty()&&!e.empty()&&e.minX<=this.maxX&&e.maxX>=this.minX&&e.minY<=this.maxY&&e.maxY>=this.minY}}const yp="_geojsonTileLayer";class vp{constructor(e,t){this.tileID=e,this.x=e.canonical.x,this.y=e.canonical.y,this.z=e.canonical.z,this.grid=new so(I,16,0),this.grid3D=new so(I,16,0),this.featureIndexArray=new Os,this.promoteId=t}insert(e,t,i,r,n,o){const s=this.featureIndexArray.length;this.featureIndexArray.emplaceBack(i,r,n);const a=o?this.grid3D:this.grid;for(let e=0;e=0&&r[3]>=0&&a.insert(s,r[0],r[1],r[2],r[3])}}loadVTLayers(){return this.vtLayers||(this.vtLayers="mlt"!==this.encoding?new Ic(new xu(this.rawTileData)).layers:new _p(this.rawTileData).layers,this.sourceLayerCoder=new zh(this.vtLayers?Object.keys(this.vtLayers).sort():[yp])),this.vtLayers}query(e,t,r,n){this.loadVTLayers();const o=e.params,s=I/e.tileSize/e.scale,a=dn(o.filter,o.globalState),l=e.queryGeometry,c=e.queryPadding*s,u=Ap.fromPoints(l),h=this.grid.query(u.minX-c,u.minY-c,u.maxX+c,u.maxY+c),d=Ap.fromPoints(e.cameraQueryGeometry).expandBy(c),p=this.grid3D.query(d.minX,d.minY,d.maxX,d.maxY,(t,r,n,o)=>function(e,t,r,n,o){for(const i of e)if(t<=i.x&&r<=i.y&&n>=i.x&&o>=i.y)return!0;const s=[new i(t,r),new i(t,o),new i(n,o),new i(n,r)];if(e.length>2)for(const t of s)if(Ka(e,t))return!0;for(let t=0;t(d||(d=Da(t)),i.queryIntersectsFeature({queryGeometry:l,feature:t,featureState:r,geometry:d,zoom:this.z,transform:e.transform,pixelsToTileUnits:s,pixelPosMatrix:e.pixelPosMatrix,unwrappedTileID:this.tileID.toUnwrapped(),getElevation:e.getElevation})))}return f}loadMatchingFeature(e,t,i,r,n,o,s,a,l,c,u){const h=this.bucketLayerIDs[t];if(o&&!h.some(e=>o.has(e)))return;const d=this.sourceLayerCoder.decode(i),p=this.vtLayers[d].feature(r);if(n.needGeometry){const e=Oa(p,!0);if(!n.filter(new Mo(this.tileID.overscaledZ),e,this.tileID.canonical))return}else if(!n.filter(new Mo(this.tileID.overscaledZ),p))return;const f=this.getId(p,d);for(let t=0;t{const s=t instanceof No?t.get(o):null;return s&&s.evaluate?s.evaluate(i,r,n):s})}function bp(e,t){return t-e}function wp(e,t,r,n,o){const s=[];for(let a=0;a=n&&u.x>=n||(a.x>=n?a=new i(n,a.y+(n-a.x)/(u.x-a.x)*(u.y-a.y))._round():u.x>=n&&(u=new i(n,a.y+(n-a.x)/(u.x-a.x)*(u.y-a.y))._round()),a.y>=o&&u.y>=o||(a.y>=o?a=new i(a.x+(o-a.y)/(u.y-a.y)*(u.x-a.x),o)._round():u.y>=o&&(u=new i(a.x+(o-a.y)/(u.y-a.y)*(u.x-a.x),o)._round()),c&&a.equals(c[c.length-1])||(c=[a],s.push(c)),c.push(u)))))}}return s}function Tp(e,t,i,r,n){switch(t){case 1:return function(e,t,i,r){const n=[];for(const o of e)for(const e of o){const o=0===r?e.x:e.y;o>=t&&o<=i&&n.push([e])}return n}(e,i,r,n);case 2:return Cp(e,i,r,n,!1);case 3:return Cp(e,i,r,n,!0)}return[]}function Ep(e,t,r,n,o){const s=0===n?Bp:Sp;let a=[];const l=[];for(let i=0;it&&a.push(s(c,u,t)):h>r?d=t&&(a.push(s(c,u,t)),p=!0),d>r&&h<=r&&(a.push(s(c,u,r)),p=!0),!o&&p&&(l.push(a),a=[])}const c=e.length-1,u=0===n?e[c].x:e[c].y;return u>=t&&u<=r&&a.push(e[c]),o&&a.length>0&&!a[0].equals(a[a.length-1])&&a.push(new i(a[0].x,a[0].y)),a.length>0&&l.push(a),l}function Cp(e,t,i,r,n){const o=[];for(const s of e){const e=Ep(s,t,i,r,n);e.length>0&&o.push(...e)}return o}function Bp(e,t,r){return new i(r,e.y+(r-e.x)/(t.x-e.x)*(t.y-e.y))}function Sp(e,t,r){return new i(e.x+(r-e.y)/(t.y-e.y)*(t.x-e.x),r)}lo("FeatureIndex",vp,{omit:["rawTileData","sourceLayerCoder"]});class Ip extends i{constructor(e,t,i,r){super(e,t),this.angle=i,void 0!==r&&(this.segment=r)}clone(){return new Ip(this.x,this.y,this.angle,this.segment)}}function Mp(e,t,i,r,n){if(void 0===t.segment||0===i)return!0;let o=t,s=t.segment+1,a=0;for(;a>-i/2;){if(s--,s<0)return!1;a-=e[s].dist(o),o=e[s]}a+=e[s].dist(e[s+1]),s++;const l=[];let c=0;for(;ar;)c-=l.shift().angleDelta;if(c>n)return!1;s++,a+=t.dist(i)}return!0}function Pp(e){let t=0;for(let i=0;ic){const u=(c-l)/o,h=fi.number(r.x,n.x,u),d=fi.number(r.y,n.y,u),p=new Ip(h,d,n.angleTo(r),i);return p._round(),!s||Mp(e,p,a,s,t)?p:void 0}l+=o}}function kp(e,t,i,r,n,o,s,a,l){const c=Rp(r,o,s),u=Lp(r,n),h=u*s,d=0===e[0].x||e[0].x===l||0===e[0].y||e[0].y===l;return t-h=0&&_=0&&A=0&&d+c<=u){const i=new Ip(_,A,m,t);i._round(),r&&!Mp(e,i,o,r,n)||p.push(i)}}h+=f}return a||p.length||s||(p=Dp(e,h/2,i,r,n,o,s,!0,l)),p}function Op(e,t,r,n){const o=[],s=e.image,a=s.pixelRatio,l=s.paddedRect.w-2,c=s.paddedRect.h-2;let u={x1:e.left,y1:e.top,x2:e.right,y2:e.bottom};const h=s.stretchX||[[0,l]],d=s.stretchY||[[0,c]],p=(e,t)=>e+t[1]-t[0],f=h.reduce(p,0),m=d.reduce(p,0),g=l-f,_=c-m;let A=0,y=f,v=0,x=m,b=0,w=g,T=0,E=_;if(s.content&&n){const t=s.content,i=t[2]-t[0],r=t[3]-t[1];(s.textFitWidth||s.textFitHeight)&&(u=qu(e)),A=zp(h,0,t[0]),v=zp(d,0,t[1]),y=zp(h,t[0],t[2]),x=zp(d,t[1],t[3]),b=t[0]-A,T=t[1]-v,w=i-y,E=r-x}const C=u.x1,B=u.y1,S=u.x2-C,I=u.y2-B,M=(e,n,o,l)=>{const c=Np(e.stretch-A,y,S,C),u=Vp(e.fixed-b,w,e.stretch,f),h=Np(n.stretch-v,x,I,B),d=Vp(n.fixed-T,E,n.stretch,m),p=Np(o.stretch-A,y,S,C),g=Vp(o.fixed-b,w,o.stretch,f),_=Np(l.stretch-v,x,I,B),M=Vp(l.fixed-T,E,l.stretch,m),P=new i(c,h),R=new i(p,h),L=new i(p,_),F=new i(c,_),k=new i(u/a,d/a),D=new i(g/a,M/a),O=t*Math.PI/180;if(O){const e=Math.sin(O),t=Math.cos(O),i=[t,-e,e,t];P._matMult(i),R._matMult(i),F._matMult(i),L._matMult(i)}const z=e.stretch+e.fixed,U=n.stretch+n.fixed;return{tl:P,tr:R,bl:F,br:L,tex:{x:s.paddedRect.x+1+z,y:s.paddedRect.y+1+U,w:o.stretch+o.fixed-z,h:l.stretch+l.fixed-U},writingMode:void 0,glyphOffset:[0,0],sectionIndex:0,pixelOffsetTL:k,pixelOffsetBR:D,minFontScaleX:w/a/S,minFontScaleY:E/a/I,isSDF:r}};if(n&&(s.stretchX||s.stretchY)){const e=Up(h,g,f),t=Up(d,_,m);for(let i=0;i0&&(r=Math.max(10,r),this.circleDiameter=r)}else{const c=(null===(h=s.image)||void 0===h?void 0:h.content)&&(s.image.textFitWidth||s.image.textFitHeight)?qu(s):{x1:s.left,y1:s.top,x2:s.right,y2:s.bottom};c.y1=c.y1*a-l[0],c.y2=c.y2*a+l[2],c.x1=c.x1*a-l[3],c.x2=c.x2*a+l[1];const d=s.collisionPadding;if(d&&(c.x1-=d[0]*a,c.y1-=d[1]*a,c.x2+=d[2]*a,c.y2+=d[3]*a),u){const e=new i(c.x1,c.y1),t=new i(c.x2,c.y1),r=new i(c.x1,c.y2),n=new i(c.x2,c.y2),o=u*Math.PI/180;e._rotate(o),t._rotate(o),r._rotate(o),n._rotate(o),c.x1=Math.min(e.x,t.x,r.x,n.x),c.x2=Math.max(e.x,t.x,r.x,n.x),c.y1=Math.min(e.y,t.y,r.y,n.y),c.y2=Math.max(e.y,t.y,r.y,n.y)}e.emplaceBack(t.x,t.y,c.x1,c.y1,c.x2,c.y2,r,n,o)}this.boxEndIndex=e.length}}class Gp{constructor(e=[],t=(e,t)=>et?1:0){if(this.data=e,this.length=this.data.length,this.compare=t,this.length>0)for(let e=(this.length>>1)-1;e>=0;e--)this._down(e)}push(e){this.data.push(e),this._up(this.length++)}pop(){if(0===this.length)return;const e=this.data[0],t=this.data.pop();return--this.length>0&&(this.data[0]=t,this._down(0)),e}peek(){return this.data[0]}_up(e){const{data:t,compare:i}=this,r=t[e];for(;e>0;){const n=e-1>>1,o=t[n];if(i(r,o)>=0)break;t[e]=o,e=n}t[e]=r}_down(e){const{data:t,compare:i}=this,r=this.length>>1,n=t[e];for(;e=0)break;t[e]=t[r],e=r}t[e]=n}}function Hp(e,t=1,r=!1){const n=Ap.fromPoints(e[0]),o=Math.min(n.width(),n.height());let s=o/2;const a=new Gp([],Qp),{minX:l,minY:c,maxX:u,maxY:h}=n;if(0===o)return new i(l,c);for(let t=l;td.d||!d.d)&&(d=i,r&&console.log("found best %d after %d probes",Math.round(1e4*i.d)/1e4,p)),i.max-d.d<=t||(s=i.h/2,a.push(new $p(i.p.x-s,i.p.y-s,s,e)),a.push(new $p(i.p.x+s,i.p.y-s,s,e)),a.push(new $p(i.p.x-s,i.p.y+s,s,e)),a.push(new $p(i.p.x+s,i.p.y+s,s,e)),p+=4)}return r&&(console.log(`num probes: ${p}`),console.log(`best distance: ${d.d}`)),d.p}function Qp(e,t){return t.max-e.max}function $p(e,t,r,n){this.p=new i(e,t),this.h=r,this.d=function(e,t){let i=!1,r=1/0;for(let n=0;ne.y!=a.y>e.y&&e.x<(a.x-n.x)*(e.y-n.y)/(a.y-n.y)+n.x&&(i=!i),r=Math.min(r,Wa(e,n,a))}}return(i?1:-1)*Math.sqrt(r)}(this.p,n),this.max=this.d+this.h*Math.SQRT2}var Zp;e.aO=void 0,(Zp=e.aO||(e.aO={}))[Zp.center=1]="center",Zp[Zp.left=2]="left",Zp[Zp.right=3]="right",Zp[Zp.top=4]="top",Zp[Zp.bottom=5]="bottom",Zp[Zp["top-left"]=6]="top-left",Zp[Zp["top-right"]=7]="top-right",Zp[Zp["bottom-left"]=8]="bottom-left",Zp[Zp["bottom-right"]=9]="bottom-right";const Wp=Number.POSITIVE_INFINITY;function qp(e,t){return t[1]!==Wp?function(e,t,i){let r=0,n=0;switch(t=Math.abs(t),i=Math.abs(i),e){case"top-right":case"top-left":case"top":n=i-7;break;case"bottom-right":case"bottom-left":case"bottom":n=7-i}switch(e){case"top-right":case"bottom-right":case"right":r=-t;break;case"top-left":case"bottom-left":case"left":r=t}return[r,n]}(e,t[0],t[1]):function(e,t){let i=0,r=0;t<0&&(t=0);const n=t/Math.SQRT2;switch(e){case"top-right":case"top-left":r=n-7;break;case"bottom-right":case"bottom-left":r=7-n;break;case"bottom":r=7-t;break;case"top":r=t-7}switch(e){case"top-right":case"bottom-right":i=-n;break;case"top-left":case"bottom-left":i=n;break;case"left":i=t;break;case"right":i=-t}return[i,r]}(e,t[0])}function Kp(e,t,i){var r;const n=e.layout,o=null===(r=n.get("text-variable-anchor-offset"))||void 0===r?void 0:r.evaluate(t,{},i);if(o){const e=o.values,t=[];for(let i=0;ie*lu);r.startsWith("top")?n[1]-=7:r.startsWith("bottom")&&(n[1]+=7),t[i+1]=n}return new Dt(t)}const s=n.get("text-variable-anchor");if(s){let r;r=void 0!==e._unevaluatedLayout.getValue("text-radial-offset")?[n.get("text-radial-offset").evaluate(t,{},i)*lu,Wp]:n.get("text-offset").evaluate(t,{},i).map(e=>e*lu);const o=[];for(const e of s)o.push(e,qp(e,r));return new Dt(o)}return null}function Xp(e){switch(e){case"right":case"top-right":case"bottom-right":return"right";case"left":case"top-left":case"bottom-left":return"left"}return"center"}function Jp(t,i,r,n,o,s,a,l,c,u,h,d){let p=s.textMaxSize.evaluate(i,{});void 0===p&&(p=a);const f=t.layers[0].layout,m=f.get("icon-offset").evaluate(i,{},h),g=ef(r.horizontal),_=a/24,A=t.tilePixelRatio*_,y=t.tilePixelRatio*p/24,v=t.tilePixelRatio*l,x=t.tilePixelRatio*f.get("symbol-spacing"),b=f.get("text-padding")*t.tilePixelRatio,w=function(e,t,i,r=1){const n=e.get("icon-padding").evaluate(t,{},i),o=n&&n.values;return[o[0]*r,o[1]*r,o[2]*r,o[3]*r]}(f,i,h,t.tilePixelRatio),T=f.get("text-max-angle")/180*Math.PI,E="viewport"!==f.get("text-rotation-alignment")&&"point"!==f.get("symbol-placement"),C="map"===f.get("icon-rotation-alignment")&&"point"!==f.get("symbol-placement"),B=f.get("symbol-placement"),S=x/2,M=f.get("icon-text-fit");let P;n&&"none"!==M&&(t.allowVerticalPlacement&&r.vertical&&(P=Ku(n,r.vertical,M,f.get("icon-text-fit-padding"),m,_)),g&&(n=Ku(n,g,M,f.get("icon-text-fit-padding"),m,_)));const R=h?d.line.getGranularityForZoomLevel(h.z):1,L=(l,d)=>{d.x<0||d.x>=I||d.y<0||d.y>=I||function(t,i,r,n,o,s,a,l,c,u,h,d,p,f,m,g,_,A,y,v,x,b,w,T,E){const C=t.addToLineVertexArray(i,r);let B,S,I,M,P=0,R=0,L=0,F=0,k=-1,D=-1;const O={};let z=da("");if(t.allowVerticalPlacement&&n.vertical){const e=l.layout.get("text-rotate").evaluate(x,{},T)+90;I=new jp(c,i,u,h,d,n.vertical,p,f,m,e),a&&(M=new jp(c,i,u,h,d,a,_,A,m,e))}if(o){const r=l.layout.get("icon-rotate").evaluate(x,{}),n="none"!==l.layout.get("icon-text-fit"),s=Op(o,r,w,n),p=a?Op(a,r,w,n):void 0;S=new jp(c,i,u,h,d,o,_,A,!1,r),P=4*s.length;const f=t.iconSizeData;let m=null;"source"===f.kind?(m=[Xu*l.layout.get("icon-size").evaluate(x,{})],m[0]>Ju&&H(`${t.layerIds[0]}: Value for "icon-size" is >= 255. Reduce your "icon-size".`)):"composite"===f.kind&&(m=[Xu*b.compositeIconSizes[0].evaluate(x,{},T),Xu*b.compositeIconSizes[1].evaluate(x,{},T)],(m[0]>Ju||m[1]>Ju)&&H(`${t.layerIds[0]}: Value for "icon-size" is >= 255. Reduce your "icon-size".`)),t.addSymbols(t.icon,s,m,v,y,x,e.ay.none,i,C.lineStartIndex,C.lineLength,-1,T),k=t.icon.placedSymbolArray.length-1,p&&(R=4*p.length,t.addSymbols(t.icon,p,m,v,y,x,e.ay.vertical,i,C.lineStartIndex,C.lineLength,-1,T),D=t.icon.placedSymbolArray.length-1)}const U=Object.keys(n.horizontal);for(const r of U){const o=n.horizontal[r];if(!B){z=da(o.text);const e=l.layout.get("text-rotate").evaluate(x,{},T);B=new jp(c,i,u,h,d,o,p,f,m,e)}const a=1===o.positionedLines.length;if(L+=Yp(t,i,o,s,l,m,x,g,C,n.vertical?e.ay.horizontal:e.ay.horizontalOnly,a?U:[r],O,k,b,T),a)break}n.vertical&&(F+=Yp(t,i,n.vertical,s,l,m,x,g,C,e.ay.vertical,["vertical"],O,D,b,T));const N=B?B.boxStartIndex:t.collisionBoxArray.length,V=B?B.boxEndIndex:t.collisionBoxArray.length,j=I?I.boxStartIndex:t.collisionBoxArray.length,G=I?I.boxEndIndex:t.collisionBoxArray.length,Q=S?S.boxStartIndex:t.collisionBoxArray.length,$=S?S.boxEndIndex:t.collisionBoxArray.length,Z=M?M.boxStartIndex:t.collisionBoxArray.length,W=M?M.boxEndIndex:t.collisionBoxArray.length;let q=-1;const K=(e,t)=>e&&e.circleDiameter?Math.max(e.circleDiameter,t):t;q=K(B,q),q=K(I,q),q=K(S,q),q=K(M,q);const X=q>-1?1:0;X&&(q*=E/lu),t.glyphOffsetArray.length>=ah.MAX_GLYPHS&&H("Too many glyphs being rendered in a tile. See https://github.com/mapbox/mapbox-gl-js/issues/2907"),void 0!==x.sortKey&&t.addToSortKeyRanges(t.symbolInstances.length,x.sortKey);const J=Kp(l,x,T),[Y,ee]=function(t,i){const r=t.length,n=null==i?void 0:i.values;if((null==n?void 0:n.length)>0)for(let i=0;i=0?O.right:-1,O.center>=0?O.center:-1,O.left>=0?O.left:-1,O.vertical||-1,k,D,z,N,V,j,G,Q,$,Z,W,u,L,F,P,R,X,0,p,q,Y,ee)}(t,d,l,r,n,o,P,t.layers[0],t.collisionBoxArray,i.index,i.sourceLayerIndex,t.index,A,[b,b,b,b],E,c,v,w,C,m,i,s,u,h,a)};if("line"===B)for(const e of wp(i.geometry,0,0,I,I)){const i=dc(e,R),o=kp(i,x,T,r.vertical||g,n,24,y,t.overscaling,I);for(const e of o)g&&tf(t,g.text,S,e)||L(i,e)}else if("line-center"===B){for(const e of i.geometry)if(e.length>1){const t=dc(e,R),i=Fp(t,T,r.vertical||g,n,24,y);i&&L(t,i)}}else if("Polygon"===i.type)for(const e of Yi(i.geometry,0)){const t=Hp(e,16);L(dc(e[0],R,!0),new Ip(t.x,t.y,0))}else if("LineString"===i.type)for(const e of i.geometry){const t=dc(e,R);L(t,new Ip(t[0].x,t[0].y,0))}else if("Point"===i.type)for(const e of i.geometry)for(const t of e)L([t],new Ip(t.x,t.y,0))}function Yp(e,t,r,n,o,s,a,l,c,u,h,d,p,f,m){const g=function(e,t,r,n,o,s,a,l){const c=n.layout.get("text-rotate").evaluate(s,{})*Math.PI/180,u=[];for(const e of t.positionedLines)for(const n of e.positionedGlyphs){if(!n.rect)continue;const s=n.rect||{};let h=4,d=!0,p=1,f=0;const m=(o||l)&&n.vertical,g=n.metrics.advance*n.scale/2;if(l&&t.verticalizable&&(f=e.lineOffset/2-(n.imageName?-(lu-n.metrics.width*n.scale)/2:(n.scale-1)*lu)),n.imageName){const e=a[n.imageName];d=e.sdf,p=e.pixelRatio,h=1/p}const _=o?[n.x+g,n.y]:[0,0];let A=o?[0,0]:[n.x+g+r[0],n.y+r[1]-f],y=[0,0];m&&(y=A,A=[0,0]);const v=n.metrics.isDoubleResolution?2:1,x=(n.metrics.left-h)*n.scale-g+A[0],b=(-n.metrics.top-h)*n.scale+A[1],w=x+s.w/v*n.scale/p,T=b+s.h/v*n.scale/p,E=new i(x,b),C=new i(w,b),B=new i(x,T),S=new i(w,T);if(m){const e=new i(-g,g- -17),t=-Math.PI/2,r=12-g,o=new i(22-r,-(n.imageName?r:0)),s=new i(...y);E._rotateAround(t,e)._add(o)._add(s),C._rotateAround(t,e)._add(o)._add(s),B._rotateAround(t,e)._add(o)._add(s),S._rotateAround(t,e)._add(o)._add(s)}if(c){const e=Math.sin(c),t=Math.cos(c),i=[t,-e,e,t];E._matMult(i),C._matMult(i),B._matMult(i),S._matMult(i)}const I=new i(0,0),M=new i(0,0);u.push({tl:E,tr:C,bl:B,br:S,tex:s,writingMode:t.writingMode,glyphOffset:_,sectionIndex:n.sectionIndex,isSDF:d,pixelOffsetTL:I,pixelOffsetBR:M,minFontScaleX:0,minFontScaleY:0})}return u}(0,r,l,o,s,a,n,e.allowVerticalPlacement),_=e.textSizeData;let A=null;"source"===_.kind?(A=[Xu*o.layout.get("text-size").evaluate(a,{})],A[0]>Ju&&H(`${e.layerIds[0]}: Value for "text-size" is >= 255. Reduce your "text-size".`)):"composite"===_.kind&&(A=[Xu*f.compositeTextSizes[0].evaluate(a,{},m),Xu*f.compositeTextSizes[1].evaluate(a,{},m)],(A[0]>Ju||A[1]>Ju)&&H(`${e.layerIds[0]}: Value for "text-size" is >= 255. Reduce your "text-size".`)),e.addSymbols(e.text,g,A,l,s,a,u,t,c.lineStartIndex,c.lineLength,p,m);for(const t of h)d[t]=e.text.placedSymbolArray.length-1;return 4*g.length}function ef(e){for(const t in e)return e[t];return null}function tf(e,t,i,r){const n=e.compareText;if(t in n){const e=n[t];for(let t=e.length-1;t>=0;t--)if(r.dist(e[t])>4;if(1!==r)throw new Error(`Got v${r} data when expected v1.`);const n=rf[15&i];if(!n)throw new Error("Unrecognized array type.");const[o]=new Uint16Array(e,2,1),[s]=new Uint32Array(e,4,1);return new nf(s,o,n,e)}constructor(e,t=64,i=Float64Array,r){if(isNaN(e)||e<0)throw new Error(`Unpexpected numItems value: ${e}.`);this.numItems=+e,this.nodeSize=Math.min(Math.max(+t,2),65535),this.ArrayType=i,this.IndexArrayType=e<65536?Uint16Array:Uint32Array;const n=rf.indexOf(this.ArrayType),o=2*e*this.ArrayType.BYTES_PER_ELEMENT,s=e*this.IndexArrayType.BYTES_PER_ELEMENT,a=(8-s%8)%8;if(n<0)throw new Error(`Unexpected typed array class: ${i}.`);r&&r instanceof ArrayBuffer?(this.data=r,this.ids=new this.IndexArrayType(this.data,8,e),this.coords=new this.ArrayType(this.data,8+s+a,2*e),this._pos=2*e,this._finished=!0):(this.data=new ArrayBuffer(8+o+s+a),this.ids=new this.IndexArrayType(this.data,8,e),this.coords=new this.ArrayType(this.data,8+s+a,2*e),this._pos=0,this._finished=!1,new Uint8Array(this.data,0,2).set([219,16+n]),new Uint16Array(this.data,2,1)[0]=t,new Uint32Array(this.data,4,1)[0]=e)}add(e,t){const i=this._pos>>1;return this.ids[i]=i,this.coords[this._pos++]=e,this.coords[this._pos++]=t,i}finish(){const e=this._pos>>1;if(e!==this.numItems)throw new Error(`Added ${e} items when expected ${this.numItems}.`);return of(this.ids,this.coords,this.nodeSize,0,this.numItems-1,0),this._finished=!0,this}range(e,t,i,r){if(!this._finished)throw new Error("Data not yet indexed - call index.finish().");const{ids:n,coords:o,nodeSize:s}=this,a=[0,n.length-1,0],l=[];for(;a.length;){const c=a.pop()||0,u=a.pop()||0,h=a.pop()||0;if(u-h<=s){for(let s=h;s<=u;s++){const a=o[2*s],c=o[2*s+1];a>=e&&a<=i&&c>=t&&c<=r&&l.push(n[s])}continue}const d=h+u>>1,p=o[2*d],f=o[2*d+1];p>=e&&p<=i&&f>=t&&f<=r&&l.push(n[d]),(0===c?e<=p:t<=f)&&(a.push(h),a.push(d-1),a.push(1-c)),(0===c?i>=p:r>=f)&&(a.push(d+1),a.push(u),a.push(1-c))}return l}within(e,t,i){if(!this._finished)throw new Error("Data not yet indexed - call index.finish().");const{ids:r,coords:n,nodeSize:o}=this,s=[0,r.length-1,0],a=[],l=i*i;for(;s.length;){const c=s.pop()||0,u=s.pop()||0,h=s.pop()||0;if(u-h<=o){for(let i=h;i<=u;i++)cf(n[2*i],n[2*i+1],e,t)<=l&&a.push(r[i]);continue}const d=h+u>>1,p=n[2*d],f=n[2*d+1];cf(p,f,e,t)<=l&&a.push(r[d]),(0===c?e-i<=p:t-i<=f)&&(s.push(h),s.push(d-1),s.push(1-c)),(0===c?e+i>=p:t+i>=f)&&(s.push(d+1),s.push(u),s.push(1-c))}return a}}function of(e,t,i,r,n,o){if(n-r<=i)return;const s=r+n>>1;sf(e,t,s,r,n,o),of(e,t,i,r,s-1,1-o),of(e,t,i,s+1,n,1-o)}function sf(e,t,i,r,n,o){for(;n>r;){if(n-r>600){const s=n-r+1,a=i-r+1,l=Math.log(s),c=.5*Math.exp(2*l/3),u=.5*Math.sqrt(l*c*(s-c)/s)*(a-s/2<0?-1:1);sf(e,t,i,Math.max(r,Math.floor(i-a*c/s+u)),Math.min(n,Math.floor(i+(s-a)*c/s+u)),o)}const s=t[2*i+o];let a=r,l=n;for(af(e,t,r,i),t[2*n+o]>s&&af(e,t,r,n);as;)l--}t[2*r+o]===s?af(e,t,r,l):(l++,af(e,t,l,n)),l<=i&&(r=l+1),i<=l&&(n=l-1)}}function af(e,t,i,r){lf(e,i,r),lf(t,2*i,2*r),lf(t,2*i+1,2*r+1)}function lf(e,t,i){const r=e[t];e[t]=e[i],e[i]=r}function cf(e,t,i,r){const n=e-i,o=t-r;return n*n+o*o}var uf;e.cG=void 0,(uf=e.cG||(e.cG={})).create="create",uf.load="load",uf.fullLoad="fullLoad";let hf=null,df=[];const pf=1e3/60,ff="loadTime",mf="fullLoadTime",gf={mark(e){performance.mark(e)},frame(e){const t=e;null!=hf&&df.push(t-hf),hf=t},clearMetrics(){hf=null,df=[],performance.clearMeasures(ff),performance.clearMeasures(mf);for(const t in e.cG)performance.clearMarks(e.cG[t])},getPerformanceMetrics(){performance.measure(ff,e.cG.create,e.cG.load),performance.measure(mf,e.cG.create,e.cG.fullLoad);const t=performance.getEntriesByName(ff)[0].duration,i=performance.getEntriesByName(mf)[0].duration,r=df.length,n=1/(df.reduce((e,t)=>e+t,0)/r/1e3),o=df.filter(e=>e>pf).reduce((e,t)=>e+(t-pf)/pf,0);return{loadTime:t,fullLoadTime:i,fps:n,percentDroppedFrames:o/(r+o)*100,totalFrames:r}}};e.$=h,e.A=p,e.B=oo,e.C=eo,e.D=Vo,e.E=_e,e.F=function([e,t,i]){return t+=90,t*=Math.PI/180,i*=Math.PI/180,{x:e*Math.cos(t)*Math.sin(i),y:e*Math.sin(t)*Math.sin(i),z:e*Math.cos(i)}},e.G=fi,e.H=Mo,e.I=Ou,e.J=io,e.K=function(e){if(null==Z){const t=e.navigator?e.navigator.userAgent:null;Z=!!e.safari||!(!t||!(/\b(iPad|iPhone|iPod)\b/.test(t)||t.match("Safari")&&!t.match("Chrome")))}return Z},e.L=class{constructor(e,t){this.target=e,this.mapId=t,this.resolveRejects={},this.tasks={},this.taskQueue=[],this.abortControllers={},this.messageHandlers={},this.invoker=new _h(()=>this.process()),this.subscription=Y(this.target,"message",e=>this.receive(e),!1),this.globalScope=$(self)?e:window}registerMessageHandler(e,t){this.messageHandlers[e]=t}unregisterMessageHandler(e){delete this.messageHandlers[e]}sendAsync(e,t){return new Promise((i,r)=>{const n=Math.round(1e18*Math.random()).toString(36).substring(0,10),o=t?Y(t.signal,"abort",()=>{null==o||o.unsubscribe(),delete this.resolveRejects[n];const t={id:n,type:"",origin:location.origin,targetMapId:e.targetMapId,sourceMapId:this.mapId};this.target.postMessage(t)},Ah):null;this.resolveRejects[n]={resolve:e=>{null==o||o.unsubscribe(),i(e)},reject:e=>{null==o||o.unsubscribe(),r(e)}};const s=[],a=Object.assign(Object.assign({},e),{id:n,sourceMapId:this.mapId,origin:location.origin,data:po(e.data,s)});this.target.postMessage(a,{transfer:s})})}receive(e){const t=e.data,i=t.id;if(!("file://"!==t.origin&&"file://"!==location.origin&&"resource://android"!==t.origin&&"resource://android"!==location.origin&&t.origin!==location.origin||t.targetMapId&&this.mapId!==t.targetMapId)){if(""===t.type){delete this.tasks[i];const e=this.abortControllers[i];return delete this.abortControllers[i],void(e&&e.abort())}if($(self)||t.mustQueue)return this.tasks[i]=t,this.taskQueue.push(i),void this.invoker.trigger();this.processTask(i,t)}}process(){if(0===this.taskQueue.length)return;const e=this.taskQueue.shift(),t=this.tasks[e];delete this.tasks[e],this.taskQueue.length>0&&this.invoker.trigger(),t&&this.processTask(e,t)}processTask(e,i){return t(this,void 0,void 0,function*(){if(""===i.type){const t=this.resolveRejects[e];if(delete this.resolveRejects[e],!t)return;return void(i.error?t.reject(fo(i.error)):t.resolve(fo(i.data)))}if(!this.messageHandlers[i.type])return void this.completeTask(e,new Error(`Could not find a registered handler for ${i.type}, map ID: ${this.mapId}, available handlers: ${Object.keys(this.messageHandlers).join(", ")}`));const t=fo(i.data),r=new AbortController;this.abortControllers[e]=r;try{const n=yield this.messageHandlers[i.type](i.sourceMapId,t,r);this.completeTask(e,null,n)}catch(t){this.completeTask(e,t)}})}completeTask(e,t,i){const r=[];delete this.abortControllers[e];const n={id:e,type:"",sourceMapId:this.mapId,origin:location.origin,error:t?po(t):null,data:po(i,r)};this.target.postMessage(n,{transfer:r})}remove(){this.invoker.remove(),this.subscription.unsubscribe()}},e.M=le,e.N=function(){var e=new p(16);return p!=Float32Array&&(e[1]=0,e[2]=0,e[3]=0,e[4]=0,e[6]=0,e[7]=0,e[8]=0,e[9]=0,e[11]=0,e[12]=0,e[13]=0,e[14]=0),e[0]=1,e[5]=1,e[10]=1,e[15]=1,e},e.O=function(e,t,i){var r,n,o,s,a,l,c,u,h,d,p,f,m=i[0],g=i[1],_=i[2];return t===e?(e[12]=t[0]*m+t[4]*g+t[8]*_+t[12],e[13]=t[1]*m+t[5]*g+t[9]*_+t[13],e[14]=t[2]*m+t[6]*g+t[10]*_+t[14],e[15]=t[3]*m+t[7]*g+t[11]*_+t[15]):(n=t[1],o=t[2],s=t[3],a=t[4],l=t[5],c=t[6],u=t[7],h=t[8],d=t[9],p=t[10],f=t[11],e[0]=r=t[0],e[1]=n,e[2]=o,e[3]=s,e[4]=a,e[5]=l,e[6]=c,e[7]=u,e[8]=h,e[9]=d,e[10]=p,e[11]=f,e[12]=r*m+a*g+h*_+t[12],e[13]=n*m+l*g+d*_+t[13],e[14]=o*m+c*g+p*_+t[14],e[15]=s*m+u*g+f*_+t[15]),e},e.P=i,e.Q=function(e,t,i){var r=i[0],n=i[1],o=i[2];return e[0]=t[0]*r,e[1]=t[1]*r,e[2]=t[2]*r,e[3]=t[3]*r,e[4]=t[4]*n,e[5]=t[5]*n,e[6]=t[6]*n,e[7]=t[7]*n,e[8]=t[8]*o,e[9]=t[9]*o,e[10]=t[10]*o,e[11]=t[11]*o,e[12]=t[12],e[13]=t[13],e[14]=t[14],e[15]=t[15],e},e.R=Al,e.S=function(e,t,i){var r=t[0],n=t[1],o=t[2],s=t[3],a=t[4],l=t[5],c=t[6],u=t[7],h=t[8],d=t[9],p=t[10],f=t[11],m=t[12],g=t[13],_=t[14],A=t[15],y=i[0],v=i[1],x=i[2],b=i[3];return e[0]=y*r+v*a+x*h+b*m,e[1]=y*n+v*l+x*d+b*g,e[2]=y*o+v*c+x*p+b*_,e[3]=y*s+v*u+x*f+b*A,e[4]=(y=i[4])*r+(v=i[5])*a+(x=i[6])*h+(b=i[7])*m,e[5]=y*n+v*l+x*d+b*g,e[6]=y*o+v*c+x*p+b*_,e[7]=y*s+v*u+x*f+b*A,e[8]=(y=i[8])*r+(v=i[9])*a+(x=i[10])*h+(b=i[11])*m,e[9]=y*n+v*l+x*d+b*g,e[10]=y*o+v*c+x*p+b*_,e[11]=y*s+v*u+x*f+b*A,e[12]=(y=i[12])*r+(v=i[13])*a+(x=i[14])*h+(b=i[15])*m,e[13]=y*n+v*l+x*d+b*g,e[14]=y*o+v*c+x*p+b*_,e[15]=y*s+v*u+x*f+b*A,e},e.T=Bl,e.U=function(e,t){const i={};for(let r=0;r0||(null===(n=i.addOrUpdateProperties)||void 0===n?void 0:n.length)>0;if((o||s)&&(t=Object.assign({},t),e.set(i.id,t),o&&(t.geometry=i.newGeometry),s)){if(t.properties=i.removeAllProperties?{}:Object.assign({},t.properties||{}),i.removeProperties)for(const e of i.removeProperties)delete t.properties[e];if(i.addOrUpdateProperties)for(const{key:e,value:r}of i.addOrUpdateProperties)t.properties[e]=r}}},e.a9=yp,e.aA=function(e,t){var i=t[0],r=t[1],n=t[2],o=t[3],s=t[4],a=t[5],l=t[6],c=t[7],u=t[8],h=t[9],d=t[10],p=t[11],f=t[12],m=t[13],g=t[14],_=t[15],A=i*a-r*s,y=i*l-n*s,v=i*c-o*s,x=r*l-n*a,b=r*c-o*a,w=n*c-o*l,T=u*m-h*f,E=u*g-d*f,C=u*_-p*f,B=h*g-d*m,S=h*_-p*m,I=d*_-p*g,M=A*I-y*S+v*B+x*C-b*E+w*T;return M?(e[0]=(a*I-l*S+c*B)*(M=1/M),e[1]=(n*S-r*I-o*B)*M,e[2]=(m*w-g*b+_*x)*M,e[3]=(d*b-h*w-p*x)*M,e[4]=(l*C-s*I-c*E)*M,e[5]=(i*I-n*C+o*E)*M,e[6]=(g*v-f*w-_*y)*M,e[7]=(u*w-d*v+p*y)*M,e[8]=(s*S-a*C+c*T)*M,e[9]=(r*C-i*S-o*T)*M,e[10]=(f*b-m*v+_*A)*M,e[11]=(h*v-u*b-p*A)*M,e[12]=(a*E-s*B-l*T)*M,e[13]=(i*B-r*E+n*T)*M,e[14]=(m*y-f*x-g*A)*M,e[15]=(u*x-h*y+d*A)*M,e):null},e.aB=B,e.aC=function(e){var t=e[0],i=e[1];return Math.sqrt(t*t+i*i)},e.aD=function(e){return e[0]=0,e[1]=0,e},e.aE=function(e,t,i){return e[0]=t[0]*i,e[1]=t[1]*i,e},e.aF=rh,e.aG=T,e.aH=function(e,t,r,n){const o=t.y-e.y,s=t.x-e.x,a=n.y-r.y,l=n.x-r.x,c=a*s-l*o;if(0===c)return null;const u=(l*(e.y-r.y)-a*(e.x-r.x))/c;return new i(e.x+u*s,e.y+u*o)},e.aI=wp,e.aJ=Va,e.aK=function(e){let t=1/0,i=1/0,r=-1/0,n=-1/0;for(const o of e)t=Math.min(t,o.x),i=Math.min(i,o.y),r=Math.max(r,o.x),n=Math.max(n,o.y);return[t,i,r,n]},e.aL=lu,e.aM=M,e.aN=function(e,t,i,r,n=!1){if(!i[0]&&!i[1])return[0,0];const o=n?"map"===r?-e.bearingInRadians:0:"viewport"===r?e.bearingInRadians:0;if(o){const e=Math.sin(o),t=Math.cos(o);i=[i[0]*t-i[1]*e,i[0]*e+i[1]*t]}return[n?i[0]:M(t,i[0],e.zoom),n?i[1]:M(t,i[1],e.zoom)]},e.aP=eh,e.aQ=Xp,e.aR=Vu,e.aS=nf,e.aT=es,e.aU=ac,e.aV=zs,e.aW=ta,e.aX=Xs,e.aY=te,e.aZ=Sh,e.a_=v,e.aa=Ih,e.ab=Ap,e.ac=25,e.ad=Ph,e.ae=e=>{const t=window.document.createElement("video");return t.muted=!0,new Promise(i=>{t.onloadstart=()=>{i(t)};for(const i of e){const e=window.document.createElement("source");de(i)||(t.crossOrigin="Anonymous"),e.src=i,t.appendChild(e)}})},e.af=Me,e.ag=function(){return U++},e.ah=Bs,e.ai=ah,e.aj=dn,e.ak=Oa,e.al=Uh,e.am=function(e){const t={};if(e.replace(/(?:^|(?:\s*\,\s*))([^\x00-\x20\(\)<>@\,;\:\\"\/\[\]\?\=\{\}\x7F]+)(?:\=(?:([^\x00-\x20\(\)<>@\,;\:\\"\/\[\]\?\=\{\}\x7F]+)|(?:\"((?:[^"\\]|\\.)*)\")))?/g,(e,i,r,n)=>{const o=r||n;return t[i]=!o||o.toLowerCase(),""}),t["max-age"]){const e=parseInt(t["max-age"],10);isNaN(e)?delete t["max-age"]:t["max-age"]=e}return t},e.an=D,e.ao=85.051129,e.ap=ee,e.aq=function(e){return Math.pow(2,e)},e.ar=m,e.as=Eh,e.at=function(e){return Math.log(e)/Math.LN2},e.au=function(e){var t=e[0],i=e[1];return t*t+i*i},e.av=class{constructor(e,t){this.max=e,this.onRemove=t,this.reset()}reset(){for(const e in this.data)for(const t of this.data[e])t.timeout&&clearTimeout(t.timeout),this.onRemove(t.value);return this.data={},this.order=[],this}add(e,t,i){const r=e.wrapped().key;void 0===this.data[r]&&(this.data[r]=[]);const n={value:t,timeout:void 0};if(void 0!==i&&(n.timeout=setTimeout(()=>{this.remove(e,n)},i)),this.data[r].push(n),this.order.push(r),this.order.length>this.max){const e=this._getAndRemoveByKey(this.order[0]);e&&this.onRemove(e)}return this}has(e){return e.wrapped().key in this.data}getAndRemove(e){return this.has(e)?this._getAndRemoveByKey(e.wrapped().key):null}_getAndRemoveByKey(e){const t=this.data[e].shift();return t.timeout&&clearTimeout(t.timeout),0===this.data[e].length&&delete this.data[e],this.order.splice(this.order.indexOf(e),1),t.value}getByKey(e){const t=this.data[e];return t?t[0].value:null}get(e){return this.has(e)?this.data[e.wrapped().key][0].value:null}remove(e,t){if(!this.has(e))return this;const i=e.wrapped().key,r=void 0===t?0:this.data[i].indexOf(t),n=this.data[i][r];return this.data[i].splice(r,1),n.timeout&&clearTimeout(n.timeout),0===this.data[i].length&&delete this.data[i],this.onRemove(n.value),this.order.splice(this.order.indexOf(i),1),this}setMaxSize(e){for(this.max=e;this.order.length>this.max;){const e=this._getAndRemoveByKey(this.order[0]);e&&this.onRemove(e)}return this}filter(e){const t=[];for(const i in this.data)for(const r of this.data[i])e(r.value)||t.push(r);for(const e of t)this.remove(e.value.tileID,e)}},e.aw=function(e){if(!e.length)return new Set;const t=Math.max(...e.map(e=>e.canonical.z));let i=1/0,r=-1/0,n=1/0,o=-1/0;const s=[];for(const a of e){const{x:e,y:l,z:c}=a.canonical,u=Math.pow(2,t-c),h=e*u,d=l*u;s.push({id:a,x:h,y:d}),hr&&(r=h),do&&(o=d)}const a=new Set;for(const e of s)e.x!==i&&e.x!==r&&e.y!==n&&e.y!==o||a.add(e.id);return a},e.ax=function(e,t){let i=0,r=0;if("constant"===e.kind)r=e.layoutSize;else if("source"!==e.kind){const{interpolationType:n,minZoom:o,maxZoom:s}=e,a=n?D(di.interpolationFactor(n,t,o,s),0,1):0;"camera"===e.kind?r=fi.number(e.minSize,e.maxSize,a):i=a}return{uSizeT:i,uSize:r}},e.az=function(e,{uSize:t,uSizeT:i},{lowerSize:r,upperSize:n}){return"source"===e.kind?r/Xu:"composite"===e.kind?fi.number(r/Xu,n/Xu,i):t},e.b=W,e.b$=class extends _a{constructor(e,t){super(e,t),this.current=xa}set(e){if(e[12]!==this.current[12]||e[0]!==this.current[0])return this.current=e,void this.gl.uniformMatrix4fv(this.location,!1,e);for(let t=1;t<16;t++)if(e[t]!==this.current[t]){this.current=e,this.gl.uniformMatrix4fv(this.location,!1,e);break}}},e.b0=function(e){var t=new p(3);return t[0]=e[0],t[1]=e[1],t[2]=e[2],t},e.b1=function(e,t,i){return e[0]=t[0]-i[0],e[1]=t[1]-i[1],e[2]=t[2]-i[2],e},e.b2=function(e,t){var i=t[0],r=t[1],n=t[2],o=i*i+r*r+n*n;return o>0&&(o=1/Math.sqrt(o)),e[0]=t[0]*o,e[1]=t[1]*o,e[2]=t[2]*o,e},e.b3=x,e.b4=function(e,t){return e[0]*t[0]+e[1]*t[1]+e[2]*t[2]},e.b5=function(e,t,i){return e[0]=t[0]*i[0],e[1]=t[1]*i[1],e[2]=t[2]*i[2],e[3]=t[3]*i[3],e},e.b6=_,e.b7=function(e,t,i){const r=t[0]*i[0]+t[1]*i[1]+t[2]*i[2];return 0===r?null:(-(e[0]*i[0]+e[1]*i[1]+e[2]*i[2])-i[3])/r},e.b8=w,e.b9=function(e,t,i){return e[0]=t[0]*i,e[1]=t[1]*i,e[2]=t[2]*i,e[3]=t[3]*i,e},e.bA=C,e.bB=function(e,t,i){var r=i[0],n=i[1],o=i[2],s=i[3],a=t[0],l=t[1],c=t[2],u=n*c-o*l,h=o*a-r*c,d=r*l-n*a;return e[0]=a+s*(u+=u)+n*(d+=d)-o*(h+=h),e[1]=l+s*h+o*u-r*d,e[2]=c+s*d+r*h-n*u,e},e.bC=function(e,t,i){const r=(n=[e[0],e[1],e[2],t[0],t[1],t[2],i[0],i[1],i[2]])[0]*((u=n[8])*(s=n[4])-(a=n[5])*(c=n[7]))+n[1]*(-u*(o=n[3])+a*(l=n[6]))+n[2]*(c*o-s*l);var n,o,s,a,l,c,u;if(0===r)return null;const h=x([],[t[0],t[1],t[2]],[i[0],i[1],i[2]]),d=x([],[i[0],i[1],i[2]],[e[0],e[1],e[2]]),p=x([],[e[0],e[1],e[2]],[t[0],t[1],t[2]]),f=v([],h,-e[3]);return y(f,f,v([],d,-t[3])),y(f,f,v([],p,-i[3])),v(f,f,1/r),f},e.bD=yh,e.bE=function(){return new Float64Array(4)},e.bF=function(e,t,i,r){var n=[],o=[];return n[0]=t[0]-i[0],n[1]=t[1]-i[1],n[2]=t[2]-i[2],o[0]=n[0]*Math.cos(r)-n[1]*Math.sin(r),o[1]=n[0]*Math.sin(r)+n[1]*Math.cos(r),o[2]=n[2],e[0]=o[0]+i[0],e[1]=o[1]+i[1],e[2]=o[2]+i[2],e},e.bG=function(e,t,i,r){var n=[],o=[];return n[0]=t[0]-i[0],n[1]=t[1]-i[1],n[2]=t[2]-i[2],o[0]=n[0],o[1]=n[1]*Math.cos(r)-n[2]*Math.sin(r),o[2]=n[1]*Math.sin(r)+n[2]*Math.cos(r),e[0]=o[0]+i[0],e[1]=o[1]+i[1],e[2]=o[2]+i[2],e},e.bH=function(e,t,i,r){var n=[],o=[];return n[0]=t[0]-i[0],n[1]=t[1]-i[1],n[2]=t[2]-i[2],o[0]=n[2]*Math.sin(r)+n[0]*Math.cos(r),o[1]=n[1],o[2]=n[2]*Math.cos(r)-n[0]*Math.sin(r),e[0]=o[0]+i[0],e[1]=o[1]+i[1],e[2]=o[2]+i[2],e},e.bI=function(e,t,i){var r=Math.sin(i),n=Math.cos(i),o=t[0],s=t[1],a=t[2],l=t[3],c=t[8],u=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*n-c*r,e[1]=s*n-u*r,e[2]=a*n-h*r,e[3]=l*n-d*r,e[8]=o*r+c*n,e[9]=s*r+u*n,e[10]=a*r+h*n,e[11]=l*r+d*n,e},e.bJ=function(e,t){const i=P(e,360),r=P(t,360),n=r-i,o=r>i?n-360:n+360;return Math.abs(n)0?s:-s},e.bM=function(e,t){const i=P(e,2*Math.PI),r=P(t,2*Math.PI);return Math.min(Math.abs(i-r),Math.abs(i-r+2*Math.PI),Math.abs(i-r-2*Math.PI))},e.bN=function(){const e={},t=Ae.$version;for(const i in Ae.$root){const r=Ae.$root[i];if(r.required){let n=null;n="version"===i?t:"array"===r.type?[]:{},null!=n&&(e[i]=n)}}return e},e.bO=ue,e.bP=mo,e.bQ=function e(t,i){if(Array.isArray(t)){if(!Array.isArray(i)||t.length!==i.length)return!1;for(let r=0;r"raster"===e.type,e.bU=j,e.bV=function(e,t){if(!e)return[{command:"setStyle",args:[t]}];let i=[];try{if(!xe(e.version,t.version))return[{command:"setStyle",args:[t]}];xe(e.center,t.center)||i.push({command:"setCenter",args:[t.center]}),xe(e.state,t.state)||i.push({command:"setGlobalState",args:[t.state]}),xe(e.centerAltitude,t.centerAltitude)||i.push({command:"setCenterAltitude",args:[t.centerAltitude]}),xe(e.zoom,t.zoom)||i.push({command:"setZoom",args:[t.zoom]}),xe(e.bearing,t.bearing)||i.push({command:"setBearing",args:[t.bearing]}),xe(e.pitch,t.pitch)||i.push({command:"setPitch",args:[t.pitch]}),xe(e.roll,t.roll)||i.push({command:"setRoll",args:[t.roll]}),xe(e.sprite,t.sprite)||i.push({command:"setSprite",args:[t.sprite]}),xe(e.glyphs,t.glyphs)||i.push({command:"setGlyphs",args:[t.glyphs]}),xe(e.transition,t.transition)||i.push({command:"setTransition",args:[t.transition]}),xe(e.light,t.light)||i.push({command:"setLight",args:[t.light]}),xe(e.terrain,t.terrain)||i.push({command:"setTerrain",args:[t.terrain]}),xe(e.sky,t.sky)||i.push({command:"setSky",args:[t.sky]}),xe(e.projection,t.projection)||i.push({command:"setProjection",args:[t.projection]});const r={},n=[];!function(e,t,i,r){let n;for(n in t=t||{},e=e||{})Object.prototype.hasOwnProperty.call(e,n)&&(Object.prototype.hasOwnProperty.call(t,n)||Te(n,i,r));for(n in t)Object.prototype.hasOwnProperty.call(t,n)&&(Object.prototype.hasOwnProperty.call(e,n)?xe(e[n],t[n])||("geojson"===e[n].type&&"geojson"===t[n].type&&Ce(e,t,n)?be(i,{command:"setGeoJSONSourceData",args:[n,t[n].data]}):Ee(n,t,i,r)):we(n,t,i))}(e.sources,t.sources,n,r);const o=[];e.layers&&e.layers.forEach(e=>{"source"in e&&r[e.source]?i.push({command:"removeLayer",args:[e.id]}):o.push(e)}),i=i.concat(n),function(e,t,i){t=t||[];const r=(e=e||[]).map(Se),n=t.map(Se),o=e.reduce(Ie,{}),s=t.reduce(Ie,{}),a=r.slice(),l=Object.create(null);let c,u,h,d,p;for(let e=0,t=0;ed?(n=Math.acos(o),s=Math.sin(n),a=Math.sin((1-r)*n)/s,l=Math.sin(r*n)/s):(a=1-r,l=r),e[0]=a*c+l*f,e[1]=a*u+l*m,e[2]=a*h+l*g,e[3]=a*p+l*_,e},e.bm=function(e){const t=new Float64Array(9);var i,r,n,o,s,a,l,c,u,h,d,p,f,m,g,_,A,y;h=(n=(r=e)[0])*(l=n+n),d=(o=r[1])*l,f=(s=r[2])*l,m=s*(c=o+o),_=(a=r[3])*l,A=a*c,y=a*(u=s+s),(i=t)[0]=1-(p=o*c)-(g=s*u),i[3]=d-y,i[6]=f+A,i[1]=d+y,i[4]=1-h-g,i[7]=m-_,i[2]=f-A,i[5]=m+_,i[8]=1-h-p;const v=te(-Math.asin(D(t[2],-1,1)));let x,b;return Math.hypot(t[5],t[8])<.001?(x=0,b=-te(Math.atan2(t[3],t[4]))):(x=te(0===t[5]&&0===t[8]?0:Math.atan2(t[5],t[8])),b=te(0===t[1]&&0===t[0]?0:Math.atan2(t[1],t[0]))),{roll:x,pitch:v+90,bearing:b}},e.bn=function(e,t){return e.roll==t.roll&&e.pitch==t.pitch&&e.bearing==t.bearing},e.bo=Ct,e.bp=Aa,e.bq=lc,e.br=cc,e.bs=sc,e.bt=R,e.bu=L,e.bv=zt,e.bw=function(e,t,i,r,n){return R(r,n,D((e-t)/(i-t),0,1))},e.bx=P,e.by=function(){return new Float64Array(3)},e.bz=function(e,t,i,r){return e[0]=t[0]+i[0]*r,e[1]=t[1]+i[1]*r,e[2]=t[2]+i[2]*r,e},e.c=oe,e.c$=class{constructor(e){this._marks={start:[e.url,"start"].join("#"),end:[e.url,"end"].join("#"),measure:e.url.toString()},performance.mark(this._marks.start)}finish(){performance.mark(this._marks.end);let e=performance.getEntriesByName(this._marks.measure);return 0===e.length&&(performance.measure(this._marks.measure,this._marks.start,this._marks.end),e=performance.getEntriesByName(this._marks.measure),performance.clearMarks(this._marks.start),performance.clearMarks(this._marks.end),performance.clearMeasures(this._marks.measure)),e}},e.c0=ya,e.c1=class extends _a{constructor(e,t){super(e,t),this.current=[0,0,0]}set(e){e[0]===this.current[0]&&e[1]===this.current[1]&&e[2]===this.current[2]||(this.current=e,this.gl.uniform3f(this.location,e[0],e[1],e[2]))}},e.c2=class extends _a{constructor(e,t){super(e,t),this.current=[0,0]}set(e){e[0]===this.current[0]&&e[1]===this.current[1]||(this.current=e,this.gl.uniform2f(this.location,e[0],e[1]))}},e.c3=f,e.c4=function(e,t){var i=Math.sin(t),r=Math.cos(t);return e[0]=r,e[1]=i,e[2]=0,e[3]=-i,e[4]=r,e[5]=0,e[6]=0,e[7]=0,e[8]=1,e},e.c5=function(e,t,i){var r=t[0],n=t[1],o=t[2];return e[0]=r*i[0]+n*i[3]+o*i[6],e[1]=r*i[1]+n*i[4]+o*i[7],e[2]=r*i[2]+n*i[5]+o*i[8],e},e.c6=function(e,t,i,r,n,o,s){var a=1/(t-i),l=1/(r-n),c=1/(o-s);return e[0]=-2*a,e[1]=0,e[2]=0,e[3]=0,e[4]=0,e[5]=-2*l,e[6]=0,e[7]=0,e[8]=0,e[9]=0,e[10]=2*c,e[11]=0,e[12]=(t+i)*a,e[13]=(n+r)*l,e[14]=(s+o)*c,e[15]=1,e},e.c7=class extends _a{constructor(e,t){super(e,t),this.current=new Array}set(e){if(e!=this.current){this.current=e;const t=new Float32Array(4*e.length);for(let i=0;i25||r<0||r>=1||i<0||i>=1)},e.cD=function(e,t){return e[0]=t[0],e[1]=0,e[2]=0,e[3]=0,e[4]=0,e[5]=t[1],e[6]=0,e[7]=0,e[8]=0,e[9]=0,e[10]=t[2],e[11]=0,e[12]=0,e[13]=0,e[14]=0,e[15]=1,e},e.cE=class extends rs{},e.cF=gf,e.cH=function(e){return e.message===ne},e.cI=ce,e.cJ=function(e,t){se.REGISTERED_PROTOCOLS[e]=t},e.cK=function(e){delete se.REGISTERED_PROTOCOLS[e]},e.cL=function(e,t){const i={};for(let r=0;re*lu)}let y=a?"center":r.get("text-justify").evaluate(n,{},t.canonical);const v="point"===r.get("symbol-placement")?r.get("text-max-width").evaluate(n,{},t.canonical)*lu:1/0,x=()=>{t.bucket.allowVerticalPlacement&&yo(o)&&(f.vertical=Nu(m,t.glyphMap,t.glyphPositions,t.imagePositions,u,v,s,g,"left",p,_,e.ay.vertical,!0,d,h))};if(!a&&A){const i=new Set;if("auto"===y)for(let e=0;e=this.maxEntries){const e=this.map.keys().next().value;this.map.delete(e)}this.map.set(e,t)}clear(){this.map.clear()}},e.cZ=Ic,e.c_=_p,e.ca=su,e.cb=class extends _s{},e.cc=vl,e.cd=function(e){return e<=1?1:Math.pow(2,Math.ceil(Math.log(e)/Math.LN2))},e.ce=yl,e.cf=function(e,t,i){var r=t[0],n=t[1],o=t[2],s=i[3]*r+i[7]*n+i[11]*o+i[15];return e[0]=(i[0]*r+i[4]*n+i[8]*o+i[12])/(s=s||1),e[1]=(i[1]*r+i[5]*n+i[9]*o+i[13])/s,e[2]=(i[2]*r+i[6]*n+i[10]*o+i[14])/s,e},e.cg=class extends ns{},e.ch=class extends Ts{},e.ci=function(e,t){return e[0]===t[0]&&e[1]===t[1]&&e[2]===t[2]&&e[3]===t[3]&&e[4]===t[4]&&e[5]===t[5]&&e[6]===t[6]&&e[7]===t[7]&&e[8]===t[8]&&e[9]===t[9]&&e[10]===t[10]&&e[11]===t[11]&&e[12]===t[12]&&e[13]===t[13]&&e[14]===t[14]&&e[15]===t[15]},e.cj=function(e,t){var i=e[0],r=e[1],n=e[2],o=e[3],s=e[4],a=e[5],l=e[6],c=e[7],u=e[8],h=e[9],p=e[10],f=e[11],m=e[12],g=e[13],_=e[14],A=e[15],y=t[0],v=t[1],x=t[2],b=t[3],w=t[4],T=t[5],E=t[6],C=t[7],B=t[8],S=t[9],I=t[10],M=t[11],P=t[12],R=t[13],L=t[14],F=t[15];return Math.abs(i-y)<=d*Math.max(1,Math.abs(i),Math.abs(y))&&Math.abs(r-v)<=d*Math.max(1,Math.abs(r),Math.abs(v))&&Math.abs(n-x)<=d*Math.max(1,Math.abs(n),Math.abs(x))&&Math.abs(o-b)<=d*Math.max(1,Math.abs(o),Math.abs(b))&&Math.abs(s-w)<=d*Math.max(1,Math.abs(s),Math.abs(w))&&Math.abs(a-T)<=d*Math.max(1,Math.abs(a),Math.abs(T))&&Math.abs(l-E)<=d*Math.max(1,Math.abs(l),Math.abs(E))&&Math.abs(c-C)<=d*Math.max(1,Math.abs(c),Math.abs(C))&&Math.abs(u-B)<=d*Math.max(1,Math.abs(u),Math.abs(B))&&Math.abs(h-S)<=d*Math.max(1,Math.abs(h),Math.abs(S))&&Math.abs(p-I)<=d*Math.max(1,Math.abs(p),Math.abs(I))&&Math.abs(f-M)<=d*Math.max(1,Math.abs(f),Math.abs(M))&&Math.abs(m-P)<=d*Math.max(1,Math.abs(m),Math.abs(P))&&Math.abs(g-R)<=d*Math.max(1,Math.abs(g),Math.abs(R))&&Math.abs(_-L)<=d*Math.max(1,Math.abs(_),Math.abs(L))&&Math.abs(A-F)<=d*Math.max(1,Math.abs(A),Math.abs(F))},e.ck=function(e,t){return e[0]=t[0],e[1]=t[1],e[2]=t[2],e[3]=t[3],e[4]=t[4],e[5]=t[5],e[6]=t[6],e[7]=t[7],e[8]=t[8],e[9]=t[9],e[10]=t[10],e[11]=t[11],e[12]=t[12],e[13]=t[13],e[14]=t[14],e[15]=t[15],e},e.cl=e=>"symbol"===e.type,e.cm=e=>"circle"===e.type,e.cn=e=>"heatmap"===e.type,e.co=e=>"line"===e.type,e.cp=e=>"fill"===e.type,e.cq=e=>"fill-extrusion"===e.type,e.cr=e=>"hillshade"===e.type,e.cs=e=>"color-relief"===e.type,e.ct=e=>"background"===e.type,e.cu=e=>"custom"===e.type,e.cv=F,e.cw=function(e,t,i){const r=S(t.x-i.x,t.y-i.y),n=S(e.x-i.x,e.y-i.y);var o,s;return te(Math.atan2(r[0]*n[1]-r[1]*n[0],(o=r)[0]*(s=n)[0]+o[1]*s[1]))},e.cx=k,e.cy=function(e,t){return re[t]&&(e instanceof MouseEvent||e instanceof WheelEvent)},e.cz=function(e,t){return ie[t]&&"touches"in e},e.d=de,e.d0=function(e,i,r,n,o){return t(this,void 0,void 0,function*(){if(h())try{return yield K(e,i,r,n,o)}catch(e){}return function(e,t,i,r,n){const o=e.width,s=e.height;X&&J||(X=new OffscreenCanvas(o,s),J=X.getContext("2d",{willReadFrequently:!0})),X.width=o,X.height=s,J.drawImage(e,0,0,o,s);const a=J.getImageData(t,i,r,n);return J.clearRect(0,0,o,s),a.data}(e,i,r,n,o)})},e.d1=Sl,e.d2=r,e.d3=tn,e.d4=Io,e.e=z,e.f=e=>t(void 0,void 0,void 0,function*(){if(0===e.byteLength)return createImageBitmap(new ImageData(1,1));const t=new Blob([new Uint8Array(e)],{type:"image/png"});try{return createImageBitmap(t)}catch(e){throw new Error(`Could not load image because of ${e.message}. Please make sure to use a supported image type such as PNG or JPEG. Note that SVGs are not supported.`)}}),e.g=ae,e.h=e=>new Promise((t,i)=>{const r=new Image;r.onload=()=>{t(r),URL.revokeObjectURL(r.src),r.onload=null,window.requestAnimationFrame(()=>{r.src=q})},r.onerror=()=>i(new Error("Could not load image. Please make sure to use a supported image type such as PNG or JPEG. Note that SVGs are not supported."));const n=new Blob([new Uint8Array(e)],{type:"image/png"});r.src=e.byteLength?URL.createObjectURL(n):q}),e.i=$,e.j=(e,t)=>he(z(e,{type:"json"}),t),e.k=ge,e.l=me,e.m=he,e.n=(e,t)=>he(z(e,{type:"arrayBuffer"}),t),e.o=function(e){return new xu(e).readFields(Lu,[])},e.p=Du,e.q=function(e){return/[\u02EA\u02EB\u1100-\u11FF\u2E80-\u2FDF\u3000-\u30FF\u3105-\u312F\u3131-\u318E\u31A0-\u4DBF\u4E00-\uA48C\uA490-\uA4C6\uA960-\uA97C\uAC00-\uD7C6\uD7CB-\uD7FB\uF900-\uFA6D\uFA70-\uFAD9\uFE10-\uFE1F\uFE30-\uFE4F\uFF00-\uFFEF]|\uD81B[\uDFE0-\uDFFF]|[\uD81C-\uD822\uD840-\uD868\uD86A-\uD86D\uD86F-\uD872\uD874-\uD879\uD880-\uD883\uD885-\uD88C][\uDC00-\uDFFF]|\uD823[\uDC00-\uDCD5\uDCFF-\uDD1E\uDD80-\uDDF2]|\uD82B[\uDFF0-\uDFFF]|\uD82C[\uDC00-\uDEFB]|\uD83C[\uDE00-\uDEFF]|\uD869[\uDC00-\uDEDF\uDF00-\uDFFF]|\uD86E[\uDC00-\uDC1D\uDC20-\uDFFF]|\uD873[\uDC00-\uDEAD\uDEB0-\uDFFF]|\uD87A[\uDC00-\uDFE0\uDFF0-\uDFFF]|\uD87B[\uDC00-\uDE5D]|\uD87E[\uDC00-\uDE1D]|\uD884[\uDC00-\uDF4A\uDF50-\uDFFF]|\uD88D[\uDC00-\uDC79]/gim.test(String.fromCodePoint(e))},e.r=_l,e.s=Y,e.t=$o,e.u=Ae,e.v=Yn,e.w=H,e.x=ko,e.y=to,e.z=Ro}),i("worker",["./shared"],function(e){class t{constructor(e,t){this.keyCache={},e&&this.replace(e,t)}replace(e,t){this._layerConfigs={},this._layers={},this.update(e,[],t)}update(t,i,r){for(const i of t){this._layerConfigs[i.id]=i;const t=this._layers[i.id]=e.bS(i,r);t._featureFilter=e.aj(t.filter,r),this.keyCache[i.id]&&delete this.keyCache[i.id]}for(const e of i)delete this.keyCache[e],delete this._layerConfigs[e],delete this._layers[e];this.familiesBySource={};const n=e.cL(Object.values(this._layerConfigs),this.keyCache);for(const t of n){const i=t.map(e=>this._layers[e.id]),r=i[0];if("none"===r.visibility)continue;const n=r.source||"";let o=this.familiesBySource[n];o||(o=this.familiesBySource[n]={});const s=r.sourceLayer||e.a9;let a=o[s];a||(a=o[s]=[]),a.push(i)}}}class i{constructor(t){const i={},r=[];for(const e in t){const n=t[e],o=i[e]={};for(const e in n){const t=n[+e];if(!t||0===t.bitmap.width||0===t.bitmap.height)continue;const i={x:0,y:0,w:t.bitmap.width+2,h:t.bitmap.height+2};r.push(i),o[e]={rect:i,metrics:t.metrics}}}const{w:n,h:o}=e.p(r),s=new e.r({width:n||1,height:o||1});for(const r in t){const n=t[r];for(const t in n){const o=n[+t];if(!o||0===o.bitmap.width||0===o.bitmap.height)continue;const a=i[r][t].rect;e.r.copy(o.bitmap,s,{x:0,y:0},{x:a.x+1,y:a.y+1},o.bitmap)}}this.image=s,this.positions=i}}e.cM("GlyphAtlas",i);class r{constructor(t){this.tileID=new e.a1(t.tileID.overscaledZ,t.tileID.wrap,t.tileID.canonical.z,t.tileID.canonical.x,t.tileID.canonical.y),this.uid=t.uid,this.zoom=t.zoom,this.pixelRatio=t.pixelRatio,this.tileSize=t.tileSize,this.source=t.source,this.overscaling=this.tileID.overscaleFactor(),this.showCollisionBoxes=t.showCollisionBoxes,this.collectResourceTiming=!!t.collectResourceTiming,this.returnDependencies=!!t.returnDependencies,this.promoteId=t.promoteId,this.inFlightDependencies=[]}parse(t,r,o,s,a){return e._(this,void 0,void 0,function*(){this.status="parsing",this.data=t,this.collisionBoxArray=new e.ah;const l=new e.cN(Object.keys(t.layers).sort()),c=new e.cO(this.tileID,this.promoteId);c.bucketLayerIDs=[];const u={},h={featureIndex:c,iconDependencies:{},patternDependencies:{},glyphDependencies:{},dashDependencies:{},availableImages:o,subdivisionGranularity:a},d=r.familiesBySource[this.source];for(const i in d){const r=t.layers[i];if(!r)continue;1===r.version&&e.w(`Vector tile source "${this.source}" layer "${i}" does not use vector tile spec v2 and therefore may have some rendering errors.`);const s=l.encode(i),a=[];for(let e=0;ee.id)))}}const p=e.bX(h.glyphDependencies,e=>Object.keys(e).map(Number));this.inFlightDependencies.forEach(e=>null==e?void 0:e.abort()),this.inFlightDependencies=[];let f=Promise.resolve({});if(Object.keys(p).length){const e=new AbortController;this.inFlightDependencies.push(e),f=s.sendAsync({type:"GG",data:{stacks:p,source:this.source,tileID:this.tileID,type:"glyphs"}},e)}const m=Object.keys(h.iconDependencies);let g=Promise.resolve({});if(m.length){const e=new AbortController;this.inFlightDependencies.push(e),g=s.sendAsync({type:"GI",data:{icons:m,source:this.source,tileID:this.tileID,type:"icons"}},e)}const _=Object.keys(h.patternDependencies);let A=Promise.resolve({});if(_.length){const e=new AbortController;this.inFlightDependencies.push(e),A=s.sendAsync({type:"GI",data:{icons:_,source:this.source,tileID:this.tileID,type:"patterns"}},e)}const y=h.dashDependencies;let v=Promise.resolve({});if(Object.keys(y).length){const e=new AbortController;this.inFlightDependencies.push(e),v=s.sendAsync({type:"GDA",data:{dashes:y}},e)}const[x,b,w,T]=yield Promise.all([f,g,A,v]),E=new i(x),C=new e.cP(b,w);for(const t in u){const i=u[t];i instanceof e.ai?(n(i.layers,this.zoom,o),e.cQ({bucket:i,glyphMap:x,glyphPositions:E.positions,imageMap:b,imagePositions:C.iconPositions,showCollisionBoxes:this.showCollisionBoxes,canonical:this.tileID.canonical,subdivisionGranularity:h.subdivisionGranularity})):i.hasDependencies&&(i instanceof e.cR||i instanceof e.cS||i instanceof e.cT)&&(n(i.layers,this.zoom,o),i.addFeatures(h,this.tileID.canonical,C.patternPositions,T))}return this.status="done",{buckets:Object.values(u).filter(e=>!e.isEmpty()),featureIndex:c,collisionBoxArray:this.collisionBoxArray,glyphAtlasImage:E.image,imageAtlas:C,dashPositions:T,glyphMap:this.returnDependencies?x:null,iconMap:this.returnDependencies?b:null,glyphPositions:this.returnDependencies?E.positions:null}})}}function n(t,i,r){const n=new e.H(i);for(const e of t)e.recalculate(n,r)}class o extends e.cW{constructor(t,i){super(new e.cV,0,i,[],[]),this.feature=t,this.type=t.type,this.properties=t.tags?t.tags:{},"id"in t&&("string"==typeof t.id?this.id=parseInt(t.id,10):"number"!=typeof t.id||isNaN(t.id)||(this.id=t.id))}loadGeometry(){const t=[],i=1===this.feature.type?[this.feature.geometry]:this.feature.geometry;for(const r of i){const i=[];for(const t of r)i.push(new e.P(t[0],t[1]));t.push(i)}return t}}class s extends e.cU{constructor(t,i){super(new e.cV),this.layers={_geojsonTileLayer:this},this.name="_geojsonTileLayer",this.version=i?i.version:1,this.extent=i?i.extent:4096,this.length=t.length,this.features=t}feature(e){return new o(this.features[e],this.extent)}}function a(e,t){t.writeVarintField(15,e.version||1),t.writeStringField(1,e.name||""),t.writeVarintField(5,e.extent||4096);const i={keys:[],values:[],keycache:{},valuecache:{}};for(let r=0;r>31}function d(e,t){const i=e.loadGeometry(),r=e.type;let n=0,o=0;for(const s of i){let i=1;1===r&&(i=s.length),t.writeVarint(u(1,i));const a=3===r?s.length-1:s.length;for(let e=0;et.map(t=>new e.P(t.x,t.y)))}}class m extends e.cU{constructor(t,i,r){super(new e.cV),this.version=2,this._myFeatures=t,this.name=i,this.length=t.length,this.extent=r}feature(e){return this._myFeatures[e]}}class g{constructor(){this.layers={}}addLayer(e){this.layers[e.name]=e}}function _(t){let i=function(t){const i=new e.cV;return function(e,t){for(const i in e.layers)t.writeMessage(3,a,e.layers[i])}(t,i),i.finish()}(t);return 0===i.byteOffset&&i.byteLength===i.buffer.byteLength||(i=new Uint8Array(i)),{vectorTile:t,rawData:i.buffer}}function A(t,i,r){const{extent:n}=t,o=Math.pow(2,r.z-i.z),s=(r.x-i.x*o)*n,a=(r.y-i.y*o)*n,l=[];for(let i=0;i0&&l.addLayer(n)}const u=_(l);return this.overzoomedTileResultCache.set(s,u),u}reloadTile(t){return e._(this,void 0,void 0,function*(){const i=t.uid;if(!this.loaded||!this.loaded[i])throw new Error("Should not be trying to reload a tile that was never loaded or has been removed");const r=this.loaded[i];if(r.showCollisionBoxes=t.showCollisionBoxes,"parsing"===r.status){const n=yield r.parse(r.vectorTile,this.layerIndex,this.availableImages,this.actor,t.subdivisionGranularity);let o;if(this.fetching[i]){const{rawTileData:r,cacheControl:s,resourceTiming:a}=this.fetching[i];delete this.fetching[i],o=e.e({rawTileData:r.slice(0),encoding:t.encoding},n,s,a)}else o=n;return o}if("done"===r.status&&r.vectorTile)return r.parse(r.vectorTile,this.layerIndex,this.availableImages,this.actor,t.subdivisionGranularity)})}abortTile(t){return e._(this,void 0,void 0,function*(){const e=this.loading,i=t.uid;e&&e[i]&&e[i].abort&&(e[i].abort.abort(),delete e[i])})}removeTile(t){return e._(this,void 0,void 0,function*(){this.loaded&&this.loaded[t.uid]&&delete this.loaded[t.uid]})}}class v{constructor(){this.loaded={}}loadTile(t){return e._(this,void 0,void 0,function*(){const{uid:i,encoding:r,rawImageData:n,redFactor:o,greenFactor:s,blueFactor:a,baseShift:l}=t,c=n.width+2,u=n.height+2,h=e.b(n)?new e.R({width:c,height:u},yield e.d0(n,-1,-1,c,u)):n,d=new e.d1(i,h,r,o,s,a,l);return this.loaded=this.loaded||{},this.loaded[i]=d,d})}removeTile(e){const t=this.loaded,i=e.uid;t&&t[i]&&delete t[i]}}var x,b,w=function(){if(b)return x;function e(e,i){if(0!==e.length){t(e[0],i);for(var r=1;r=Math.abs(a)?i-l+a:a-l+i,i=l}i+r>=0!=!!t&&e.reverse()}return b=1,x=function t(i,r){var n,o=i&&i.type;if("FeatureCollection"===o)for(n=0;ne},C=Math.fround||(B=new Float32Array(1),e=>(B[0]=+e,B[0]));var B;class S{constructor(e){this.options=Object.assign(Object.create(E),e),this.trees=new Array(this.options.maxZoom+1),this.stride=this.options.reduce?7:6,this.clusterProps=[]}load(e){const{log:t,minZoom:i,maxZoom:r}=this.options;t&&console.time("total time");const n=`prepare ${e.length} points`;t&&console.time(n),this.points=e;const o=[];for(let t=0;t=i;e--){const i=+Date.now();s=this.trees[e]=this._createTree(this._cluster(s,e)),t&&console.log("z%d: %d clusters in %dms",e,s.numItems,+Date.now()-i)}return t&&console.timeEnd("total time"),this}getClusters(e,t){let i=((e[0]+180)%360+360)%360-180;const r=Math.max(-90,Math.min(90,e[1]));let n=180===e[2]?180:((e[2]+180)%360+360)%360-180;const o=Math.max(-90,Math.min(90,e[3]));if(e[2]-e[0]>=360)i=-180,n=180;else if(i>n){const e=this.getClusters([i,r,180,o],t),s=this.getClusters([-180,r,n,o],t);return e.concat(s)}const s=this.trees[this._limitZoom(t)],a=s.range(P(i),R(o),P(n),R(r)),l=s.data,c=[];for(const e of a){const t=this.stride*e;c.push(l[t+5]>1?I(l,t,this.clusterProps):this.points[l[t+3]])}return c}getChildren(e){const t=this._getOriginId(e),i=this._getOriginZoom(e),r="No cluster with the specified id.",n=this.trees[i];if(!n)throw new Error(r);const o=n.data;if(t*this.stride>=o.length)throw new Error(r);const s=this.options.radius/(this.options.extent*Math.pow(2,i-1)),a=n.within(o[t*this.stride],o[t*this.stride+1],s),l=[];for(const t of a){const i=t*this.stride;o[i+4]===e&&l.push(o[i+5]>1?I(o,i,this.clusterProps):this.points[o[i+3]])}if(0===l.length)throw new Error(r);return l}getLeaves(e,t,i){const r=[];return this._appendLeaves(r,e,t=t||10,i=i||0,0),r}getTile(e,t,i){const r=this.trees[this._limitZoom(e)],n=Math.pow(2,e),{extent:o,radius:s}=this.options,a=s/o,l=(i-a)/n,c=(i+1+a)/n,u={features:[]};return this._addTileFeatures(r.range((t-a)/n,l,(t+1+a)/n,c),r.data,t,i,n,u),0===t&&this._addTileFeatures(r.range(1-a/n,l,1,c),r.data,n,i,n,u),t===n-1&&this._addTileFeatures(r.range(0,l,a/n,c),r.data,-1,i,n,u),u.features.length?u:null}getClusterExpansionZoom(e){let t=this._getOriginZoom(e)-1;for(;t<=this.options.maxZoom;){const i=this.getChildren(e);if(t++,1!==i.length)break;e=i[0].properties.cluster_id}return t}_appendLeaves(e,t,i,r,n){const o=this.getChildren(t);for(const t of o){const o=t.properties;if(o&&o.cluster?n+o.point_count<=r?n+=o.point_count:n=this._appendLeaves(e,o.cluster_id,i,r,n):n1;let l,c,u;if(a)l=M(t,e,this.clusterProps),c=t[e],u=t[e+1];else{const i=this.points[t[e+3]];l=i.properties;const[r,n]=i.geometry.coordinates;c=P(r),u=R(n)}const h={type:1,geometry:[[Math.round(this.options.extent*(c*n-i)),Math.round(this.options.extent*(u*n-r))]],tags:l};let d;d=a||this.options.generateId?t[e+3]:this.points[t[e+3]].id,void 0!==d&&(h.id=d),o.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:i,extent:r,reduce:n,minPoints:o}=this.options,s=i/(r*Math.pow(2,t)),a=e.data,l=[],c=this.stride;for(let i=0;it&&(p+=a[i+5])}if(p>d&&p>=o){let e,o=r*d,s=u*d,f=-1;const m=(i/c<<5)+(t+1)+this.points.length;for(const r of h){const l=r*c;if(a[l+2]<=t)continue;a[l+2]=t;const u=a[l+5];o+=a[l]*u,s+=a[l+1]*u,a[l+4]=m,n&&(e||(e=this._map(a,i,!0),f=this.clusterProps.length,this.clusterProps.push(e)),n(e,this._map(a,l)))}a[i+4]=m,l.push(o/p,s/p,1/0,m,-1,p),n&&l.push(f)}else{for(let e=0;e1)for(const e of h){const i=e*c;if(!(a[i+2]<=t)){a[i+2]=t;for(let e=0;e>5}_getOriginZoom(e){return(e-this.points.length)%32}_map(e,t,i){if(e[t+5]>1){const r=this.clusterProps[e[t+6]];return i?Object.assign({},r):r}const r=this.points[e[t+3]].properties,n=this.options.map(r);return i&&n===r?Object.assign({},n):n}}function I(e,t,i){return{type:"Feature",id:e[t+3],properties:M(e,t,i),geometry:{type:"Point",coordinates:[(r=e[t],360*(r-.5)),L(e[t+1])]}};var r}function M(e,t,i){const r=e[t+5],n=r>=1e4?`${Math.round(r/1e3)}k`:r>=1e3?Math.round(r/100)/10+"k":r,o=e[t+6],s=-1===o?{}:Object.assign({},i[o]);return Object.assign(s,{cluster:!0,cluster_id:e[t+3],point_count:r,point_count_abbreviated:n})}function P(e){return e/360+.5}function R(e){const t=Math.sin(e*Math.PI/180),i=.5-.25*Math.log((1+t)/(1-t))/Math.PI;return i<0?0:i>1?1:i}function L(e){const t=(180-360*e)*Math.PI/180;return 360*Math.atan(Math.exp(t))/Math.PI-90}function F(e,t,i,r){let n=r;const o=t+(i-t>>1);let s,a=i-t;const l=e[t],c=e[t+1],u=e[i],h=e[i+1];for(let r=t+3;rn)s=r,n=t;else if(t===n){const e=Math.abs(r-o);er&&(s-t>3&&F(e,t,s,r),e[s+2]=n,i-s>3&&F(e,s,i,r))}function k(e,t,i,r,n,o){let s=n-i,a=o-r;if(0!==s||0!==a){const l=((e-i)*s+(t-r)*a)/(s*s+a*a);l>1?(i=n,r=o):l>0&&(i+=s*l,r+=a*l)}return s=e-i,a=t-r,s*s+a*a}function D(e,t,i,r){const n={id:null==e?null:e,type:t,geometry:i,tags:r,minX:1/0,minY:1/0,maxX:-1/0,maxY:-1/0};if("Point"===t||"MultiPoint"===t||"LineString"===t)O(n,i);else if("Polygon"===t)O(n,i[0]);else if("MultiLineString"===t)for(const e of i)O(n,e);else if("MultiPolygon"===t)for(const e of i)O(n,e[0]);return n}function O(e,t){for(let i=0;i0&&(s+=r?(n*l-a*o)/2:Math.sqrt(Math.pow(a-n,2)+Math.pow(l-o,2))),n=a,o=l}const a=t.length-3;t[2]=1,F(t,0,a,i),t[a+2]=1,t.size=Math.abs(s),t.start=0,t.end=t.size}function V(e,t,i,r){for(let n=0;n1?1:i}function H(e,t,i,r,n,o,s,a){if(r/=t,o>=(i/=t)&&s=r)return null;const l=[];for(const t of e){const e=t.geometry;let o=t.type;const s=0===n?t.minX:t.minY,c=0===n?t.maxX:t.maxY;if(s>=i&&c=r)continue;let u=[];if("Point"===o||"MultiPoint"===o)Q(e,u,i,r,n);else if("LineString"===o)$(e,u,i,r,n,!1,a.lineMetrics);else if("MultiLineString"===o)W(e,u,i,r,n,!1);else if("Polygon"===o)W(e,u,i,r,n,!0);else if("MultiPolygon"===o)for(const t of e){const e=[];W(t,e,i,r,n,!0),e.length&&u.push(e)}if(u.length){if(a.lineMetrics&&"LineString"===o){for(const e of u)l.push(D(t.id,o,e,t.tags));continue}"LineString"!==o&&"MultiLineString"!==o||(1===u.length?(o="LineString",u=u[0]):o="MultiLineString"),"Point"!==o&&"MultiPoint"!==o||(o=3===u.length?"Point":"MultiPoint"),l.push(D(t.id,o,u,t.tags))}}return l.length?l:null}function Q(e,t,i,r,n){for(let o=0;o=i&&s<=r&&q(t,e[o],e[o+1],e[o+2])}}function $(e,t,i,r,n,o,s){let a=Z(e);const l=0===n?K:X;let c,u,h=e.start;for(let d=0;di&&(u=l(a,p,f,g,_,i),s&&(a.start=h+c*u)):A>r?y=i&&(u=l(a,p,f,g,_,i),v=!0),y>r&&A<=r&&(u=l(a,p,f,g,_,r),v=!0),!o&&v&&(s&&(a.end=h+c*u),t.push(a),a=Z(e)),s&&(h+=c)}let d=e.length-3;const p=e[d],f=e[d+1],m=0===n?p:f;m>=i&&m<=r&&q(a,p,f,e[d+2]),d=a.length-3,o&&d>=3&&(a[d]!==a[0]||a[d+1]!==a[1])&&q(a,a[0],a[1],a[2]),a.length&&t.push(a)}function Z(e){const t=[];return t.size=e.size,t.start=e.start,t.end=e.end,t}function W(e,t,i,r,n,o){for(const s of e)$(s,t,i,r,n,o,!1)}function q(e,t,i,r){e.push(t,i,r)}function K(e,t,i,r,n,o){const s=(o-t)/(r-t);return q(e,o,i+(n-i)*s,1),s}function X(e,t,i,r,n,o){const s=(o-i)/(n-i);return q(e,t+(r-t)*s,o,1),s}function J(e,t){const i=[];for(let r=0;r0&&t.size<(n?s:r))return void(i.numPoints+=t.length/3);const a=[];for(let e=0;es)&&(i.numSimplified++,a.push(t[e],t[e+1])),i.numPoints++;n&&function(e,t){let i=0;for(let t=0,r=e.length,n=r-2;t0===t)for(let t=0,i=e.length;t24)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 r=function(e,t){const i=[];if("FeatureCollection"===e.type)for(let r=0;r1&&console.time("creation"),d=this.tiles[h]=ie(e,t,i,r,l),this.tileCoords.push({z:t,x:i,y:r}),c)){c>1&&(console.log("tile z%d-%d-%d (features: %d, points: %d, simplified: %d)",t,i,r,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(i!==o>>e||r!==s>>e)continue}}if(d.source=null,0===e.length)continue;c>1&&console.time("clipping");const p=.5*l.buffer/l.extent,f=.5-p,m=.5+p,g=1+p;let _=null,A=null,y=null,v=null,x=H(e,u,i-p,i+m,0,d.minX,d.maxX,l),b=H(e,u,i+f,i+g,0,d.minX,d.maxX,l);e=null,x&&(_=H(x,u,r-p,r+m,1,d.minY,d.maxY,l),A=H(x,u,r+f,r+g,1,d.minY,d.maxY,l),x=null),b&&(y=H(b,u,r-p,r+m,1,d.minY,d.maxY,l),v=H(b,u,r+f,r+g,1,d.minY,d.maxY,l),b=null),c>1&&console.timeEnd("clipping"),a.push(_||[],t+1,2*i,2*r),a.push(A||[],t+1,2*i,2*r+1),a.push(y||[],t+1,2*i+1,2*r),a.push(v||[],t+1,2*i+1,2*r+1)}}getTile(e,t,i){e=+e,t=+t,i=+i;const r=this.options,{extent:n,debug:o}=r;if(e<0||e>24)return null;const s=1<1&&console.log("drilling down to z%d-%d-%d",e,t,i);let l,c=e,u=t,h=i;for(;!l&&c>0;)c--,u>>=1,h>>=1,l=this.tiles[ae(c,u,h)];return l&&l.source?(o>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,i),o>1&&console.timeEnd("drilling down"),this.tiles[a]?ee(this.tiles[a],n):null):null}}function ae(e,t,i){return 32*((1<`${e.key}: ${e.message}`).join(", "));const n=t.features.filter(e=>r.value.evaluate({zoom:0},e));return this._toFeatureCollection(n)}_toFeatureCollection(e){return{type:"FeatureCollection",features:e}}removeSource(t){return e._(this,void 0,void 0,function*(){this._pendingRequest&&this._pendingRequest.abort()})}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)}}function ce(t,i){return i.cluster?new S(function({superclusterOptions:t,clusterProperties:i}){if(!i||!t)return t;const r={},n={},o={accumulated:null,zoom:0},s={properties:null},a=Object.keys(i);for(const t of a){const[o,s]=i[t],a=e.d3(s),l=e.d3("string"==typeof o?[o,["accumulated"],["get",t]]:o);r[t]=a.value,n[t]=l.value}return t.map=e=>{s.properties=e;const t={};for(const e of a)t[e]=r[e].evaluate(o,s);return t},t.reduce=(e,t)=>{s.properties=t;for(const t of a)o.accumulated=e[t],e[t]=n[t].evaluate(o,s)},t}(i)).load(t.features):function(e,t){return new se(e,t)}(t,i.geojsonVtOptions)}class ue{constructor(t){this.self=t,this.actor=new e.L(t),this.layerIndexes={},this.availableImages={},this.workerSources={},this.demWorkerSources={},this.externalWorkerSourceTypes={},this.globalStates=new Map,this.self.registerWorkerSource=(e,t)=>{if(this.externalWorkerSourceTypes[e])throw new Error(`Worker source with name "${e}" already registered.`);this.externalWorkerSourceTypes[e]=t},this.self.addProtocol=e.cJ,this.self.removeProtocol=e.cK,this.self.registerRTLTextPlugin=t=>{e.d4.setMethods(t)},this.actor.registerMessageHandler("LDT",(e,t)=>this._getDEMWorkerSource(e,t.source).loadTile(t)),this.actor.registerMessageHandler("RDT",(t,i)=>e._(this,void 0,void 0,function*(){this._getDEMWorkerSource(t,i.source).removeTile(i)})),this.actor.registerMessageHandler("GCEZ",(t,i)=>e._(this,void 0,void 0,function*(){return this._getWorkerSource(t,i.type,i.source).getClusterExpansionZoom(i)})),this.actor.registerMessageHandler("GCC",(t,i)=>e._(this,void 0,void 0,function*(){return this._getWorkerSource(t,i.type,i.source).getClusterChildren(i)})),this.actor.registerMessageHandler("GCL",(t,i)=>e._(this,void 0,void 0,function*(){return this._getWorkerSource(t,i.type,i.source).getClusterLeaves(i)})),this.actor.registerMessageHandler("LD",(e,t)=>this._getWorkerSource(e,t.type,t.source).loadData(t)),this.actor.registerMessageHandler("GD",(e,t)=>this._getWorkerSource(e,t.type,t.source).getData()),this.actor.registerMessageHandler("LT",(e,t)=>this._getWorkerSource(e,t.type,t.source).loadTile(t)),this.actor.registerMessageHandler("RT",(e,t)=>this._getWorkerSource(e,t.type,t.source).reloadTile(t)),this.actor.registerMessageHandler("AT",(e,t)=>this._getWorkerSource(e,t.type,t.source).abortTile(t)),this.actor.registerMessageHandler("RMT",(e,t)=>this._getWorkerSource(e,t.type,t.source).removeTile(t)),this.actor.registerMessageHandler("RS",(t,i)=>e._(this,void 0,void 0,function*(){if(!this.workerSources[t]||!this.workerSources[t][i.type]||!this.workerSources[t][i.type][i.source])return;const e=this.workerSources[t][i.type][i.source];delete this.workerSources[t][i.type][i.source],void 0!==e.removeSource&&e.removeSource(i)})),this.actor.registerMessageHandler("RM",t=>e._(this,void 0,void 0,function*(){delete this.layerIndexes[t],delete this.availableImages[t],delete this.workerSources[t],delete this.demWorkerSources[t],this.globalStates.delete(t)})),this.actor.registerMessageHandler("SR",(t,i)=>e._(this,void 0,void 0,function*(){this.referrer=i})),this.actor.registerMessageHandler("SRPS",(e,t)=>this._syncRTLPluginState(e,t)),this.actor.registerMessageHandler("IS",(t,i)=>e._(this,void 0,void 0,function*(){this.self.importScripts(i)})),this.actor.registerMessageHandler("SI",(e,t)=>this._setImages(e,t)),this.actor.registerMessageHandler("UL",(t,i)=>e._(this,void 0,void 0,function*(){this._getLayerIndex(t).update(i.layers,i.removedIds,this._getGlobalState(t))})),this.actor.registerMessageHandler("UGS",(t,i)=>e._(this,void 0,void 0,function*(){const e=this._getGlobalState(t);for(const t in i)e[t]=i[t]})),this.actor.registerMessageHandler("SL",(t,i)=>e._(this,void 0,void 0,function*(){this._getLayerIndex(t).replace(i,this._getGlobalState(t))}))}_getGlobalState(e){let t=this.globalStates.get(e);return t||(t={},this.globalStates.set(e,t)),t}_setImages(t,i){return e._(this,void 0,void 0,function*(){this.availableImages[t]=i;for(const e in this.workerSources[t]){const r=this.workerSources[t][e];for(const e in r)r[e].availableImages=i}})}_syncRTLPluginState(t,i){return e._(this,void 0,void 0,function*(){return yield e.d4.syncState(i,this.self.importScripts)})}_getAvailableImages(e){let t=this.availableImages[e];return t||(t=[]),t}_getLayerIndex(e){let i=this.layerIndexes[e];return i||(i=this.layerIndexes[e]=new t),i}_getWorkerSource(e,t,i){if(this.workerSources[e]||(this.workerSources[e]={}),this.workerSources[e][t]||(this.workerSources[e][t]={}),!this.workerSources[e][t][i]){const r={sendAsync:(t,i)=>(t.targetMapId=e,this.actor.sendAsync(t,i))};switch(t){case"vector":this.workerSources[e][t][i]=new y(r,this._getLayerIndex(e),this._getAvailableImages(e));break;case"geojson":this.workerSources[e][t][i]=new le(r,this._getLayerIndex(e),this._getAvailableImages(e));break;default:this.workerSources[e][t][i]=new this.externalWorkerSourceTypes[t](r,this._getLayerIndex(e),this._getAvailableImages(e))}}return this.workerSources[e][t][i]}_getDEMWorkerSource(e,t){return this.demWorkerSources[e]||(this.demWorkerSources[e]={}),this.demWorkerSources[e][t]||(this.demWorkerSources[e][t]=new v),this.demWorkerSources[e][t]}}return e.i(self)&&(self.worker=new ue(self)),ue}),i("index",["exports","./shared"],function(e,t){var i="5.13.0";function r(){var e=new t.A(4);return t.A!=Float32Array&&(e[1]=0,e[2]=0),e[0]=1,e[3]=1,e}let n,o,s;const a={frame(e,i,r){const n=requestAnimationFrame(e=>{o(),i(e)}),{unsubscribe:o}=t.s(e.signal,"abort",()=>{o(),cancelAnimationFrame(n),r(t.c())},!1)},frameAsync(e){return new Promise((t,i)=>{this.frame(e,t,i)})},getImageData(e,t=0){return this.getImageCanvasContext(e).getImageData(-t,-t,e.width+2*t,e.height+2*t)},getImageCanvasContext(e){const t=window.document.createElement("canvas"),i=t.getContext("2d",{willReadFrequently:!0});if(!i)throw new Error("failed to create canvas 2d context");return t.width=e.width,t.height=e.height,i.drawImage(e,0,0,e.width,e.height),i},resolveURL:e=>(n||(n=document.createElement("a")),n.href=e,n.href),hardwareConcurrency:"undefined"!=typeof navigator&&navigator.hardwareConcurrency||4,get prefersReducedMotion(){return void 0!==s?s:!!matchMedia&&(null==o&&(o=matchMedia("(prefers-reduced-motion: reduce)")),o.matches)},set prefersReducedMotion(e){s=e}},l=new class{constructor(){this._realTime="undefined"!=typeof performance&&performance&&performance.now?performance.now.bind(performance):Date.now.bind(Date),this._frozenAt=null}getCurrentTime(){return null!==this._frozenAt?this._frozenAt:this._realTime()}setNow(e){this._frozenAt=e}restoreNow(){this._frozenAt=null}isFrozen(){return null!==this._frozenAt}};function c(){return l.getCurrentTime()}class u{static testProp(e){if(!u.docStyle)return e[0];for(let t=0;t{window.removeEventListener("click",u.suppressClickInternal,!0)},0)}static getScale(e){const t=e.getBoundingClientRect();return{x:t.width/e.offsetWidth||1,y:t.height/e.offsetHeight||1,boundingClientRect:t}}static getPoint(e,i,r){const n=i.boundingClientRect;return new t.P((r.clientX-n.left)/i.x-e.clientLeft,(r.clientY-n.top)/i.y-e.clientTop)}static mousePos(e,t){const i=u.getScale(e);return u.getPoint(e,i,t)}static touchPos(e,t){const i=[],r=u.getScale(e);for(let n=0;n{d&&g(d),d=null,m=!0},p.onerror=()=>{f=!0,d=null},p.src="data:image/webp;base64,UklGRh4AAABXRUJQVlA4TBEAAAAvAQAAAAfQ//73v/+BiOh/AAA="),function(e){let i,r,n,o;e.resetRequestQueue=()=>{i=[],r=0,n=0,o={}},e.addThrottleControl=e=>{const t=n++;return o[t]=e,t},e.removeThrottleControl=e=>{delete o[e],a()},e.getImage=(e,r,n=!0)=>new Promise((o,s)=>{h.supported&&(e.headers||(e.headers={}),e.headers.accept="image/webp,*/*"),t.e(e,{type:"image"}),i.push({abortController:r,requestParameters:e,supportImageRefresh:n,state:"queued",onError:e=>{s(e)},onSuccess:e=>{o(e)}}),a()});const s=e=>t._(this,void 0,void 0,function*(){e.state="running";const{requestParameters:i,supportImageRefresh:n,onError:o,onSuccess:s,abortController:c}=e,u=!1===n&&!t.i(self)&&!t.g(i.url)&&(!i.headers||Object.keys(i.headers).reduce((e,t)=>e&&"accept"===t,!0));r++;const h=u?l(i,c):t.m(i,c);try{const i=yield h;delete e.abortController,e.state="completed",i.data instanceof HTMLImageElement||t.b(i.data)?s(i):i.data&&s({data:yield(d=i.data,"function"==typeof createImageBitmap?t.f(d):t.h(d)),cacheControl:i.cacheControl,expires:i.expires})}catch(t){delete e.abortController,o(t)}finally{r--,a()}var d}),a=()=>{const e=(()=>{for(const e of Object.keys(o))if(o[e]())return!0;return!1})()?t.a.MAX_PARALLEL_IMAGE_REQUESTS_PER_FRAME:t.a.MAX_PARALLEL_IMAGE_REQUESTS;for(let t=r;t0;t++){const e=i.shift();e.abortController.signal.aborted?t--:s(e)}},l=(e,i)=>new Promise((r,n)=>{const o=new Image,s=e.url,a=e.credentials;a&&"include"===a?o.crossOrigin="use-credentials":(a&&"same-origin"===a||!t.d(s))&&(o.crossOrigin="anonymous"),i.signal.addEventListener("abort",()=>{o.src="",n(t.c())}),o.fetchPriority="high",o.onload=()=>{o.onerror=o.onload=null,r({data:o})},o.onerror=()=>{o.onerror=o.onload=null,i.signal.aborted||n(new Error("Could not load image. Please make sure to use a supported image type such as PNG or JPEG. Note that SVGs are not supported."))},o.src=s})}(_||(_={})),_.resetRequestQueue();class A{constructor(e){this._transformRequestFn=null!=e?e:null}transformRequest(e,t){return this._transformRequestFn&&this._transformRequestFn(e,t)||{url:e}}setTransformRequest(e){this._transformRequestFn=e}}function y(e){const t=[];if("string"==typeof e)t.push({id:"default",url:e});else if(e&&e.length>0){const i=[];for(const{id:r,url:n}of e){const e=`${r}${n}`;-1===i.indexOf(e)&&(i.push(e),t.push({id:r,url:n}))}}return t}function v(e,t,i){try{const r=new URL(e);return r.pathname+=`${t}${i}`,r.toString()}catch(t){throw new Error(`Invalid sprite URL "${e}", must be absolute. Modify style specification directly or use TransformStyleFunction to correct the issue dynamically`)}}function x(e){const{userImage:t}=e;return!!(t&&t.render&&t.render())&&(e.data.replace(new Uint8Array(t.data.buffer)),!0)}class b extends t.E{constructor(){super(),this.images={},this.updatedImages={},this.callbackDispatchedThisFrame={},this.loaded=!1,this.requestors=[],this.patterns={},this.atlasImage=new t.R({width:1,height:1}),this.dirty=!0}destroy(){this.atlasTexture&&(this.atlasTexture.destroy(),this.atlasTexture=null);for(const e of Object.keys(this.images))this.removeImage(e);this.patterns={},this.atlasImage=new t.R({width:1,height:1}),this.dirty=!0}isLoaded(){return this.loaded}setLoaded(e){if(this.loaded!==e&&(this.loaded=e,e)){for(const{ids:e,promiseResolve:t}of this.requestors)t(this._getImagesForIds(e));this.requestors=[]}}getImage(e){const i=this.images[e];if(i&&!i.data&&i.spriteData){const e=i.spriteData;i.data=new t.R({width:e.width,height:e.height},e.context.getImageData(e.x,e.y,e.width,e.height).data),i.spriteData=null}return i}addImage(e,t){if(this.images[e])throw new Error(`Image id ${e} already exist, use updateImage instead`);this._validate(e,t)&&(this.images[e]=t)}_validate(e,i){let r=!0;const n=i.data||i.spriteData;return this._validateStretch(i.stretchX,n&&n.width)||(this.fire(new t.k(new Error(`Image "${e}" has invalid "stretchX" value`))),r=!1),this._validateStretch(i.stretchY,n&&n.height)||(this.fire(new t.k(new Error(`Image "${e}" has invalid "stretchY" value`))),r=!1),this._validateContent(i.content,i)||(this.fire(new t.k(new Error(`Image "${e}" has invalid "content" value`))),r=!1),r}_validateStretch(e,t){if(!e)return!0;let i=0;for(const r of e){if(r[0]{let r=!0;if(!this.isLoaded())for(const t of e)this.images[t]||(r=!1);this.isLoaded()||r?t(this._getImagesForIds(e)):this.requestors.push({ids:e,promiseResolve:t})})}_getImagesForIds(e){const i={};for(const r of e){let e=this.getImage(r);e||(this.fire(new t.l("styleimagemissing",{id:r})),e=this.getImage(r)),e?i[r]={data:e.data.clone(),pixelRatio:e.pixelRatio,sdf:e.sdf,version:e.version,stretchX:e.stretchX,stretchY:e.stretchY,content:e.content,textFitWidth:e.textFitWidth,textFitHeight:e.textFitHeight,hasRenderCallback:Boolean(e.userImage&&e.userImage.render)}:t.w(`Image "${r}" could not be loaded. Please make sure you have added the image with map.addImage() or a "sprite" property in your style. You can provide missing images by listening for the "styleimagemissing" map event.`)}return i}getPixelSize(){const{width:e,height:t}=this.atlasImage;return{width:e,height:t}}getPattern(e){const i=this.patterns[e],r=this.getImage(e);if(!r)return null;if(i&&i.position.version===r.version)return i.position;if(i)i.position.version=r.version;else{const i={w:r.data.width+2,h:r.data.height+2,x:0,y:0},n=new t.I(i,r);this.patterns[e]={bin:i,position:n}}return this._updatePatternAtlas(),this.patterns[e].position}bind(e){const i=e.gl;this.atlasTexture?this.dirty&&(this.atlasTexture.update(this.atlasImage),this.dirty=!1):this.atlasTexture=new t.T(e,this.atlasImage,i.RGBA),this.atlasTexture.bind(i.LINEAR,i.CLAMP_TO_EDGE)}_updatePatternAtlas(){const e=[];for(const t in this.patterns)e.push(this.patterns[t].bin);const{w:i,h:r}=t.p(e),n=this.atlasImage;n.resize({width:i||1,height:r||1});for(const e in this.patterns){const{bin:i}=this.patterns[e],r=i.x+1,o=i.y+1,s=this.getImage(e).data,a=s.width,l=s.height;t.R.copy(s,n,{x:0,y:0},{x:r,y:o},{width:a,height:l}),t.R.copy(s,n,{x:0,y:l-1},{x:r,y:o-1},{width:a,height:1}),t.R.copy(s,n,{x:0,y:0},{x:r,y:o+l},{width:a,height:1}),t.R.copy(s,n,{x:a-1,y:0},{x:r-1,y:o},{width:1,height:l}),t.R.copy(s,n,{x:0,y:0},{x:r+a,y:o},{width:1,height:l})}this.dirty=!0}beginFrame(){this.callbackDispatchedThisFrame={}}dispatchRenderCallbacks(e){for(const i of e){if(this.callbackDispatchedThisFrame[i])continue;this.callbackDispatchedThisFrame[i]=!0;const e=this.getImage(i);e||t.w(`Image with ID: "${i}" was not found`),x(e)&&this.updateImage(i,e)}}cloneImages(){const e={};for(const t in this.images){const i=this.images[t];e[t]=Object.assign(Object.assign({},i),{data:i.data?i.data.clone():null})}return e}}const w=1e20;function T(e,t,i,r,n,o,s,a,l){for(let c=t;c-1);l++,o[l]=a,s[l]=c,s[l+1]=w}for(let a=0,l=0;a/[-\w]+/.test(e)?e:`'${CSS.escape(e)}'`).join(",");return new B.TinySDF({fontSize:48,buffer:6,radius:16,cutoff:.25,fontFamily:i,fontWeight:this._fontWeight(t[0]),fontStyle:this._fontStyle(t[0]),lang:this.lang})}_fontStyle(e){return/italic/i.test(e)?"italic":/oblique/i.test(e)?"oblique":"normal"}_fontWeight(e){const t={thin:100,hairline:100,"extra light":200,"ultra light":200,light:300,normal:400,regular:400,medium:500,semibold:600,demibold:600,bold:700,"extra bold":800,"ultra bold":800,black:900,heavy:900,"extra black":950,"ultra black":950};let i;for(const[r,n]of Object.entries(t))new RegExp(`\\b${r}\\b`,"i").test(e)&&(i=`${n}`);return i}destroy(){for(const e in this.entries){const t=this.entries[e];t.tinySDF&&(t.tinySDF=null),t.ideographTinySDF&&(t.ideographTinySDF=null),t.glyphs={},t.requests={},t.ranges={}}this.entries={}}}B.loadGlyphRange=function(e,i,r,n){return t._(this,void 0,void 0,function*(){const o=256*i,s=o+255,a=n.transformRequest(r.replace("{fontstack}",e).replace("{range}",`${o}-${s}`),"Glyphs"),l=yield t.n(a,new AbortController);if(!l||!l.data)throw new Error(`Could not load glyph range. range: ${i}, ${o}-${s}`);const c={};for(const e of t.o(l.data))c[e.id]=e;return c})},B.TinySDF=class{constructor({fontSize:e=24,buffer:t=3,radius:i=8,cutoff:r=.25,fontFamily:n="sans-serif",fontWeight:o="normal",fontStyle:s="normal",lang:a=null}={}){this.buffer=t,this.cutoff=r,this.radius=i,this.lang=a;const l=this.size=e+4*t,c=this._createCanvas(l),u=this.ctx=c.getContext("2d",{willReadFrequently:!0});u.font=`${s} ${o} ${e}px ${n}`,u.textBaseline="alphabetic",u.textAlign="left",u.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){const t=document.createElement("canvas");return t.width=t.height=e,t}draw(e){const{width:t,actualBoundingBoxAscent:i,actualBoundingBoxDescent:r,actualBoundingBoxLeft:n,actualBoundingBoxRight:o}=this.ctx.measureText(e),s=Math.ceil(i),a=Math.max(0,Math.min(this.size-this.buffer,Math.ceil(o-n))),l=Math.min(this.size-this.buffer,s+Math.ceil(r)),c=a+2*this.buffer,u=l+2*this.buffer,h=Math.max(c*u,0),d=new Uint8ClampedArray(h),p={data:d,width:c,height:u,glyphWidth:a,glyphHeight:l,glyphTop:s,glyphLeft:0,glyphAdvance:t};if(0===a||0===l)return p;const{ctx:f,buffer:m,gridInner:g,gridOuter:_}=this;this.lang&&(f.lang=this.lang),f.clearRect(m,m,a,l),f.fillText(e,m,m+s);const A=f.getImageData(m,m,a,l);_.fill(w,0,h),g.fill(0,0,h);for(let e=0;e0?e*e:0,g[r]=e<0?e*e:0}}T(_,0,0,c,u,c,this.f,this.v,this.z),T(g,m,m,a,l,c,this.f,this.v,this.z);for(let e=0;e1&&(s=e[++o]);const l=Math.abs(a-s.left),c=Math.abs(a-s.right),u=Math.min(l,c);let h;const d=t/i*(r+1);if(s.isDash){const e=r-Math.abs(d);h=Math.sqrt(u*u+e*e)}else h=r-Math.sqrt(u*u+d*d);this.data[n+a]=Math.max(0,Math.min(255,h+128))}}}addRegularDash(e){for(let t=e.length-1;t>=0;--t){const i=e[t],r=e[t+1];i.zeroLength?e.splice(t,1):r&&r.isDash===i.isDash&&(r.left=i.left,e.splice(t,1))}const t=e[0],i=e[e.length-1];t.isDash===i.isDash&&(t.left=i.left-this.width,i.right=t.right+this.width);const r=this.width*this.nextRow;let n=0,o=e[n];for(let t=0;t1&&(o=e[++n]);const i=Math.abs(t-o.left),s=Math.abs(t-o.right),a=Math.min(i,s);this.data[r+t]=Math.max(0,Math.min(255,(o.isDash?a:-a)+128))}}addDash(e,i){const r=i?7:0,n=2*r+1;if(this.nextRow+n>this.height)return t.w("LineAtlas out of space"),null;let o=0;for(let t=0;t{e.terminate()}),this.workers=null)}isPreloaded(){return!!this.active[F]}numActive(){return Object.keys(this.active).length}}const D=Math.floor(a.hardwareConcurrency/2);let O,z;function U(){return O||(O=new k),O}k.workerCount=t.K(globalThis)?Math.max(Math.min(D,3),1):1;class N{constructor(e,i){this.workerPool=e,this.actors=[],this.currentActor=0,this.id=i;const r=this.workerPool.acquire(i);for(let e=0;e{e.remove()}),this.actors=[],e&&this.workerPool.release(this.id)}registerMessageHandler(e,t){for(const i of this.actors)i.registerMessageHandler(e,t)}unregisterMessageHandler(e){for(const t of this.actors)t.unregisterMessageHandler(e)}}function V(){return z||(z=new N(U(),t.M),z.registerMessageHandler("GR",(e,i,r)=>t.m(i,r))),z}function j(e,i){const r=t.N();return t.O(r,r,[1,1,0]),t.Q(r,r,[.5*e.width,.5*e.height,1]),e.calculatePosMatrix?t.S(r,r,e.calculatePosMatrix(i.toUnwrapped())):r}function G(e,t,i,r,n,o,s){var a;const l=function(e,t,i){if(e)for(const r of e){const e=t[r];if(e&&e.source===i&&"fill-extrusion"===e.type)return!0}else for(const e in t){const r=t[e];if(r.source===i&&"fill-extrusion"===r.type)return!0}return!1}(null!==(a=null==n?void 0:n.layers)&&void 0!==a?a:null,t,e.id),c=o.maxPitchScaleFactor(),u=e.tilesIn(r,c,l);u.sort(H);const h=[];for(const r of u)h.push({wrappedTileID:r.tileID.wrapped().key,queryResults:r.tile.queryRenderedFeatures(t,i,e.getState(),r.queryGeometry,r.cameraQueryGeometry,r.scale,n,o,c,j(o,r.tileID),s?(e,t)=>s(r.tileID,e,t):void 0)});return function(e,t){for(const i in e)for(const r of e[i])Q(r,t);return e}(function(e){const t={},i={};for(const r of e){const e=r.queryResults,n=r.wrappedTileID,o=i[n]=i[n]||{};for(const i in e){const r=e[i],n=o[i]=o[i]||{},s=t[i]=t[i]||[];for(const e of r)n[e.featureIndex]||(n[e.featureIndex]=!0,s.push(e))}}return t}(h),e)}function H(e,t){const i=e.tileID,r=t.tileID;return i.overscaledZ-r.overscaledZ||i.canonical.y-r.canonical.y||i.wrap-r.wrap||i.canonical.x-r.canonical.x}function Q(e,t){const i=e.feature,r=t.getFeatureState(i.layer["source-layer"],i.id);i.source=i.layer.source,i.layer["source-layer"]&&(i.sourceLayer=i.layer["source-layer"]),i.state=r}function $(e,i,r){return t._(this,void 0,void 0,function*(){let n=e;if(e.url?n=(yield t.j(i.transformRequest(e.url,"Source"),r)).data:yield a.frameAsync(r),!n)return null;const o=t.U(t.e(n,e),["tiles","minzoom","maxzoom","attribution","bounds","scheme","tileSize","encoding"]);return"vector_layers"in n&&n.vector_layers&&(o.vectorLayerIds=n.vector_layers.map(e=>e.id)),o})}class Z{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 t.V?new t.V(e.lng,e.lat):t.V.convert(e),this}setSouthWest(e){return this._sw=e instanceof t.V?new t.V(e.lng,e.lat):t.V.convert(e),this}extend(e){const i=this._sw,r=this._ne;let n,o;if(e instanceof t.V)n=e,o=e;else{if(!(e instanceof Z))return Array.isArray(e)?4===e.length||e.every(Array.isArray)?this.extend(Z.convert(e)):this.extend(t.V.convert(e)):e&&("lng"in e||"lon"in e)&&"lat"in e?this.extend(t.V.convert(e)):this;if(n=e._sw,o=e._ne,!n||!o)return this}return i||r?(i.lng=Math.min(n.lng,i.lng),i.lat=Math.min(n.lat,i.lat),r.lng=Math.max(o.lng,r.lng),r.lat=Math.max(o.lat,r.lat)):(this._sw=new t.V(n.lng,n.lat),this._ne=new t.V(o.lng,o.lat)),this}getCenter(){return new t.V((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 t.V(this.getWest(),this.getNorth())}getSouthEast(){return new t.V(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:i,lat:r}=t.V.convert(e);let n=this._sw.lng<=i&&i<=this._ne.lng;return this._sw.lng>this._ne.lng&&(n=this._sw.lng>=i&&i>=this._ne.lng),this._sw.lat<=r&&r<=this._ne.lat&&n}intersects(e){if((e=Z.convert(e)).getNorth()this.getNorth())return!1;const i=t.W(this.getWest(),-180,180),r=t.W(this.getEast(),-180,180),n=t.W(e.getWest(),-180,180),o=t.W(e.getEast(),-180,180),s=i>r,a=n>o;return!(!s||!a)||(s?o>=i||n<=r:a?r>=n||i<=o:!(n>r||oi.lng?new t.V(i.lng+360,i.lat):i)}}class W{constructor(e,t,i){this.bounds=Z.convert(this.validateBounds(e)),this.minzoom=t||0,this.maxzoom=i||24}validateBounds(e){return Array.isArray(e)&&4===e.length?[Math.max(-180,e[0]),Math.max(-90,e[1]),Math.min(180,e[2]),Math.min(90,e[3])]:[-180,-90,180,90]}contains(e){const i=Math.pow(2,e.z),r=Math.floor(t.Y(this.bounds.getWest())*i),n=Math.floor(t.X(this.bounds.getNorth())*i),o=Math.ceil(t.Y(this.bounds.getEast())*i),s=Math.ceil(t.X(this.bounds.getSouth())*i);return e.x>=r&&e.x=n&&e.y{this._options.tiles=e}),this}setUrl(e){return this.setSourceProperty(()=>{this.url=e,this._options.url=e}),this}onRemove(){this._tileJSONRequest&&(this._tileJSONRequest.abort(),this._tileJSONRequest=null)}serialize(){return t.e({},this._options)}loadTile(e){return t._(this,void 0,void 0,function*(){const t=e.tileID.canonical.url(this.tiles,this.map.getPixelRatio(),this.scheme),i={request:this.map._requestManager.transformRequest(t,"Tile"),uid:e.uid,tileID:e.tileID,zoom:e.tileID.overscaledZ,tileSize:this.tileSize*e.tileID.overscaleFactor(),type:this.type,source:this.id,pixelRatio:this.map.getPixelRatio(),showCollisionBoxes:this.map.showCollisionBoxes,promoteId:this.promoteId,subdivisionGranularity:this.map.style.projection.subdivisionGranularity,encoding:this.encoding,overzoomParameters:this._getOverzoomParameters(e)};i.request.collectResourceTiming=this._collectResourceTiming;let r="RT";if(e.actor&&"expired"!==e.state){if("loading"===e.state)return new Promise((t,i)=>{e.reloadPromise={resolve:t,reject:i}})}else e.actor=this.dispatcher.getActor(),r="LT";e.abortController=new AbortController;try{const t=yield e.actor.sendAsync({type:r,data:i},e.abortController);if(delete e.abortController,e.aborted)return;this._afterTileLoadWorkerResponse(e,t)}catch(t){if(delete e.abortController,e.aborted)return;if(t&&404!==t.status)throw t;this._afterTileLoadWorkerResponse(e,null)}})}_getOverzoomParameters(e){if(e.tileID.canonical.z<=this.maxzoom)return;if(void 0===this.map._zoomLevelsToOverscale)return;const t=e.tileID.scaledTo(this.maxzoom).canonical,i=t.url(this.tiles,this.map.getPixelRatio(),this.scheme);return{maxZoomTileID:t,overzoomRequest:this.map._requestManager.transformRequest(i,"Tile")}}_afterTileLoadWorkerResponse(e,t){if(t&&t.resourceTiming&&(e.resourceTiming=t.resourceTiming),t&&this.map._refreshExpiredTiles&&e.setExpiryData(t),e.loadVectorData(t,this.map.painter),e.reloadPromise){const t=e.reloadPromise;e.reloadPromise=null,this.loadTile(e).then(t.resolve).catch(t.reject)}}abortTile(e){return t._(this,void 0,void 0,function*(){e.abortController&&(e.abortController.abort(),delete e.abortController),e.actor&&(yield e.actor.sendAsync({type:"AT",data:{uid:e.uid,type:this.type,source:this.id}}))})}unloadTile(e){return t._(this,void 0,void 0,function*(){e.unloadVectorData(),e.actor&&(yield e.actor.sendAsync({type:"RMT",data:{uid:e.uid,type:this.type,source:this.id}}))})}hasTransition(){return!1}}class K extends t.E{constructor(e,i,r,n){super(),this.id=e,this.dispatcher=r,this.setEventedParent(n),this.type="raster",this.minzoom=0,this.maxzoom=22,this.roundZoom=!0,this.scheme="xyz",this.tileSize=512,this._loaded=!1,this._options=t.e({type:"raster"},i),t.e(this,t.U(i,["url","scheme","tileSize"]))}load(){return t._(this,arguments,void 0,function*(e=!1){this._loaded=!1,this.fire(new t.l("dataloading",{dataType:"source"})),this._tileJSONRequest=new AbortController;try{const i=yield $(this._options,this.map._requestManager,this._tileJSONRequest);this._tileJSONRequest=null,this._loaded=!0,i&&(t.e(this,i),i.bounds&&(this.tileBounds=new W(i.bounds,this.minzoom,this.maxzoom)),this.fire(new t.l("data",{dataType:"source",sourceDataType:"metadata"})),this.fire(new t.l("data",{dataType:"source",sourceDataType:"content",sourceDataChanged:e})))}catch(e){this._tileJSONRequest=null,this._loaded=!0,this.fire(new t.k(e))}})}loaded(){return this._loaded}onAdd(e){this.map=e,this.load()}onRemove(){this._tileJSONRequest&&(this._tileJSONRequest.abort(),this._tileJSONRequest=null)}setSourceProperty(e){this._tileJSONRequest&&(this._tileJSONRequest.abort(),this._tileJSONRequest=null),e(),this.load(!0)}setTiles(e){return this.setSourceProperty(()=>{this._options.tiles=e}),this}setUrl(e){return this.setSourceProperty(()=>{this.url=e,this._options.url=e}),this}serialize(){return t.e({},this._options)}hasTile(e){return!this.tileBounds||this.tileBounds.contains(e.canonical)}loadTile(e){return t._(this,void 0,void 0,function*(){const i=e.tileID.canonical.url(this.tiles,this.map.getPixelRatio(),this.scheme);e.abortController=new AbortController;try{const r=yield _.getImage(this.map._requestManager.transformRequest(i,"Tile"),e.abortController,this.map._refreshExpiredTiles);if(delete e.abortController,e.aborted)return void(e.state="unloaded");if(r&&r.data){this.map._refreshExpiredTiles&&(r.cacheControl||r.expires)&&e.setExpiryData({cacheControl:r.cacheControl,expires:r.expires});const i=this.map.painter.context,n=i.gl,o=r.data;e.texture=this.map.painter.getTileTexture(o.width),e.texture?e.texture.update(o,{useMipmap:!0}):(e.texture=new t.T(i,o,n.RGBA,{useMipmap:!0}),e.texture.bind(n.LINEAR,n.CLAMP_TO_EDGE,n.LINEAR_MIPMAP_NEAREST)),e.state="loaded"}}catch(t){if(delete e.abortController,e.aborted)e.state="unloaded";else if(t)throw e.state="errored",t}})}abortTile(e){return t._(this,void 0,void 0,function*(){e.abortController&&(e.abortController.abort(),delete e.abortController)})}unloadTile(e){return t._(this,void 0,void 0,function*(){e.texture&&this.map.painter.saveTileTexture(e.texture)})}hasTransition(){return!1}}class X extends K{constructor(e,i,r,n){super(e,i,r,n),this.type="raster-dem",this.maxzoom=22,this._options=t.e({type:"raster-dem"},i),this.encoding=i.encoding||"mapbox",this.redFactor=i.redFactor,this.greenFactor=i.greenFactor,this.blueFactor=i.blueFactor,this.baseShift=i.baseShift}loadTile(e){return t._(this,void 0,void 0,function*(){const i=e.tileID.canonical.url(this.tiles,this.map.getPixelRatio(),this.scheme),r=this.map._requestManager.transformRequest(i,"Tile");e.neighboringTiles=this._getNeighboringTiles(e.tileID),e.abortController=new AbortController;try{const i=yield _.getImage(r,e.abortController,this.map._refreshExpiredTiles);if(delete e.abortController,e.aborted)return void(e.state="unloaded");if(i&&i.data){const r=i.data;this.map._refreshExpiredTiles&&(i.cacheControl||i.expires)&&e.setExpiryData({cacheControl:i.cacheControl,expires:i.expires});const n=t.b(r)&&t.Z()?r:yield this.readImageNow(r),o={type:this.type,uid:e.uid,source:this.id,rawImageData:n,encoding:this.encoding,redFactor:this.redFactor,greenFactor:this.greenFactor,blueFactor:this.blueFactor,baseShift:this.baseShift};if(!e.actor||"expired"===e.state){e.actor=this.dispatcher.getActor();const t=yield e.actor.sendAsync({type:"LDT",data:o});e.dem=t,e.needsHillshadePrepare=!0,e.needsTerrainPrepare=!0,e.state="loaded"}}}catch(t){if(delete e.abortController,e.aborted)e.state="unloaded";else if(t)throw e.state="errored",t}})}readImageNow(e){return t._(this,void 0,void 0,function*(){if("undefined"!=typeof VideoFrame&&t.$()){const i=e.width+2,r=e.height+2;try{return new t.R({width:i,height:r},yield t.a0(e,-1,-1,i,r))}catch(e){}}return a.getImageData(e,1)})}_getNeighboringTiles(e){const i=e.canonical,r=Math.pow(2,i.z),n=(i.x-1+r)%r,o=0===i.x?e.wrap-1:e.wrap,s=(i.x+1+r)%r,a=i.x+1===r?e.wrap+1:e.wrap,l={};return l[new t.a1(e.overscaledZ,o,i.z,n,i.y).key]={backfilled:!1},l[new t.a1(e.overscaledZ,a,i.z,s,i.y).key]={backfilled:!1},i.y>0&&(l[new t.a1(e.overscaledZ,o,i.z,n,i.y-1).key]={backfilled:!1},l[new t.a1(e.overscaledZ,e.wrap,i.z,i.x,i.y-1).key]={backfilled:!1},l[new t.a1(e.overscaledZ,a,i.z,s,i.y-1).key]={backfilled:!1}),i.y+1e.coordinates).flat(1/0):e.coordinates.flat(1/0)}function Y(e){const t=new Z;let i;switch(e.type){case"FeatureCollection":i=e.features.map(e=>J(e.geometry)).flat(1/0);break;case"Feature":i=J(e.geometry);break;default:i=J(e)}if(0==i.length)return t;for(let e=0;e0&&t.e(o,{resourceTiming:n}),this.fire(new t.l("data",Object.assign(Object.assign({},o),{sourceDataType:"metadata"}))),this.fire(new t.l("data",Object.assign(Object.assign({},o),{sourceDataType:"content",shouldReloadTileOptions:this._getShouldReloadTileOptions(i)})))}catch(e){if(this._isUpdatingWorker=!1,this._removed)return void this.fire(new t.l("dataabort",{dataType:"source"}));this.fire(new t.k(e))}finally{this._hasPendingWorkerUpdate()&&this._updateWorkerData()}})}_applyDiff(e){const i="string"==typeof this.promoteId?this.promoteId:void 0;this._data.url||this._data.updateable||!t.a6(this._data.geojson,i)||(this._data={updateable:t.a7(this._data.geojson,i)}),e&&this._data.updateable?t.a8(this._data.updateable,e,i):t.w("Cannot apply GeoJSONSource#updateData due to internal error")}_getShouldReloadTileOptions(e){if(this._options.cluster||!e||e.removeAll)return;const{add:i=[],update:r=[],remove:n=[]}=e||{},o=new Set([...r.map(e=>e.id),...n]);for(const e of o.values())if("number"!=typeof e&&null==this.promoteId)return void t.w(`GeoJSONSource "${this.id}": updateData is slower when using string GeoJSON feature IDs (e.g. "${e}"). Consider using promoteId or numeric IDs for better performance.`);return{nextBounds:[...r.map(e=>e.newGeometry),...i.map(e=>e.geometry)].filter(Boolean).map(e=>Y(e)),prevIds:o}}shouldReloadTile(e,{nextBounds:i,prevIds:r}){if(!e.latestFeatureIndex)return"unloaded"!==e.state;const n=e.latestFeatureIndex.loadVTLayers();for(let i=0;i{this.texture=null}),this):this}_finishLoading(){this.map&&(this.setCoordinates(this.coordinates),this.fire(new t.l("data",{dataType:"source",sourceDataType:"metadata"})))}onAdd(e){this.map=e,this.load()}onRemove(){this._request&&(this._request.abort(),this._request=null)}setCoordinates(e){this.coordinates=e;const i=e.map(t.aa.fromLngLat);var r;return this.tileID=function(e){const i=t.ab.fromPoints(e),r=i.width(),n=i.height(),o=Math.max(r,n),s=Math.max(0,Math.floor(-Math.log(o)/Math.LN2)),a=Math.pow(2,s);return new t.ad(s,Math.floor((i.minX+i.maxX)/2*a),Math.floor((i.minY+i.maxY)/2*a))}(i),this.terrainTileRanges=this._getOverlappingTileRanges(i),this.minzoom=this.maxzoom=this.tileID.z,this.tileCoords=i.map(e=>this.tileID.getTilePoint(e)._round()),this.flippedWindingOrder=((r=this.tileCoords)[1].x-r[0].x)*(r[2].y-r[0].y)-(r[1].y-r[0].y)*(r[2].x-r[0].x)<0,this.fire(new t.l("data",{dataType:"source",sourceDataType:"content"})),this}prepare(){if(0===Object.keys(this.tiles).length||!this.image)return;const e=this.map.painter.context,i=e.gl;this.texture||(this.texture=new t.T(e,this.image,i.RGBA),this.texture.bind(i.LINEAR,i.CLAMP_TO_EDGE));let r=!1;for(const e in this.tiles){const t=this.tiles[e];"loaded"!==t.state&&(t.state="loaded",t.texture=this.texture,r=!0)}r&&this.fire(new t.l("data",{dataType:"source",sourceDataType:"idle",sourceId:this.id}))}loadTile(e){return t._(this,void 0,void 0,function*(){this.tileID&&this.tileID.equals(e.tileID.canonical)?(this.tiles[String(e.tileID.wrap)]=e,e.buckets={}):e.state="errored"})}serialize(){return{type:"image",url:this.options.url,coordinates:this.coordinates}}hasTransition(){return!1}_getOverlappingTileRanges(e){const{minX:i,minY:r,maxX:n,maxY:o}=t.ab.fromPoints(e),s={};for(let e=0;e<=t.ac;e++){const t=Math.pow(2,e),a=Math.floor(i*t),l=Math.floor(r*t),c=Math.floor(n*t),u=Math.floor(o*t);s[e]={minTileX:a,minTileY:l,maxTileX:c,maxTileY:u}}return s}}class ie extends te{constructor(e,t,i,r){super(e,t,i,r),this.roundZoom=!0,this.type="video",this.options=t}load(){return t._(this,void 0,void 0,function*(){this._loaded=!1;const e=this.options;this.urls=[];for(const t of e.urls)this.urls.push(this.map._requestManager.transformRequest(t,"Source").url);try{const e=yield t.ae(this.urls);if(this._loaded=!0,!e)return;this.video=e,this.video.loop=!0,this.video.addEventListener("playing",()=>{this.map.triggerRepaint()}),this.map&&this.video.play(),this._finishLoading()}catch(e){this.fire(new t.k(e))}})}pause(){this.video&&this.video.pause()}play(){this.video&&this.video.play()}seek(e){if(this.video){const i=this.video.seekable;ei.end(0)?this.fire(new t.k(new t.af(`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=e}}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 e=this.map.painter.context,i=e.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 t.T(e,this.video,i.RGBA),this.texture.bind(i.LINEAR,i.CLAMP_TO_EDGE));let r=!1;for(const e in this.tiles){const t=this.tiles[e];"loaded"!==t.state&&(t.state="loaded",t.texture=this.texture,r=!0)}r&&this.fire(new t.l("data",{dataType:"source",sourceDataType:"idle",sourceId:this.id}))}serialize(){return{type:"video",urls:this.urls,coordinates:this.coordinates}}hasTransition(){return this.video&&!this.video.paused}}class re extends te{constructor(e,i,r,n){super(e,i,r,n),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 t.k(new t.af(`sources.${e}`,null,'"coordinates" property must be an array of 4 longitude/latitude array pairs'))):this.fire(new t.k(new t.af(`sources.${e}`,null,'missing required property "coordinates"'))),i.animate&&"boolean"!=typeof i.animate&&this.fire(new t.k(new t.af(`sources.${e}`,null,'optional "animate" property must be a boolean value'))),i.canvas?"string"==typeof i.canvas||i.canvas instanceof HTMLCanvasElement||this.fire(new t.k(new t.af(`sources.${e}`,null,'"canvas" must be either a string representing the ID of the canvas element from which to read, or an HTMLCanvasElement instance'))):this.fire(new t.k(new t.af(`sources.${e}`,null,'missing required property "canvas"'))),this.options=i,this.animate=void 0===i.animate||i.animate}load(){return t._(this,void 0,void 0,function*(){this._loaded=!0,this.canvas||(this.canvas=this.options.canvas instanceof HTMLCanvasElement?this.options.canvas:document.getElementById(this.options.canvas)),this.width=this.canvas.width,this.height=this.canvas.height,this._hasInvalidDimensions()?this.fire(new t.k(new Error("Canvas dimensions cannot be less than or equal to zero."))):(this.play=function(){this._playing=!0,this.map.triggerRepaint()},this.pause=function(){this._playing&&(this.prepare(),this._playing=!1)},this._finishLoading())})}getCanvas(){return this.canvas}onAdd(e){this.map=e,this.load(),this.canvas&&this.animate&&this.play()}onRemove(){this.pause()}prepare(){let e=!1;if(this.canvas.width!==this.width&&(this.width=this.canvas.width,e=!0),this.canvas.height!==this.height&&(this.height=this.canvas.height,e=!0),this._hasInvalidDimensions())return;if(0===Object.keys(this.tiles).length)return;const i=this.map.painter.context,r=i.gl;this.texture?(e||this._playing)&&this.texture.update(this.canvas,{premultiply:!0}):this.texture=new t.T(i,this.canvas,r.RGBA,{premultiply:!0});let n=!1;for(const e in this.tiles){const t=this.tiles[e];"loaded"!==t.state&&(t.state="loaded",t.texture=this.texture,n=!0)}n&&this.fire(new t.l("data",{dataType:"source",sourceDataType:"idle",sourceId:this.id}))}serialize(){return{type:"canvas",animate:this.animate,canvas:this.options.canvas,coordinates:this.coordinates}}hasTransition(){return this._playing}_hasInvalidDimensions(){for(const e of[this.canvas.width,this.canvas.height])if(isNaN(e)||e<=0)return!0;return!1}}const ne={},oe=e=>{switch(e){case"geojson":return ee;case"image":return te;case"raster":return K;case"raster-dem":return X;case"vector":return q;case"video":return ie;case"canvas":return re}return ne[e]},se="RTLPluginLoaded";class ae extends t.E{constructor(){super(...arguments),this.status="unavailable",this.url=null,this.dispatcher=V()}_syncState(e){return this.status=e,this.dispatcher.broadcast("SRPS",{pluginStatus:e,pluginURL:this.url}).catch(e=>{throw this.status="error",e})}getRTLTextPluginStatus(){return this.status}clearRTLTextPlugin(){this.status="unavailable",this.url=null}setRTLTextPlugin(e){return t._(this,arguments,void 0,function*(e,t=!1){if(this.url)throw new Error("setRTLTextPlugin cannot be called multiple times.");if(this.url=a.resolveURL(e),!this.url)throw new Error(`requested url ${e} is invalid`);if("unavailable"===this.status){if(!t)return this._requestImport();this.status="deferred",this._syncState(this.status)}else if("requested"===this.status)return this._requestImport()})}_requestImport(){return t._(this,void 0,void 0,function*(){yield this._syncState("loading"),this.status="loaded",this.fire(new t.l(se))})}lazyLoad(){"unavailable"===this.status?this.status="requested":"deferred"===this.status&&this._requestImport()}}let le=null;function ce(){return le||(le=new ae),le}var ue,he;!function(e){e[e.Base=0]="Base",e[e.Parent=1]="Parent"}(ue||(ue={})),function(e){e[e.Departing=0]="Departing",e[e.Incoming=1]="Incoming"}(he||(he={}));class de{constructor(e,i){this.timeAdded=0,this.fadeEndTime=0,this.fadeOpacity=1,this.tileID=e,this.uid=t.ag(),this.uses=0,this.tileSize=i,this.buckets={},this.expirationTime=null,this.queryPadding=0,this.hasSymbolBuckets=!1,this.hasRTLText=!1,this.dependencies={},this.rtt=[],this.rttCoords={},this.expiredRequestCount=0,this.state="loading"}isRenderable(e){return this.hasData()&&(!this.fadeEndTime||this.fadeOpacity>0)&&(e||!this.holdingForSymbolFade())}setCrossFadeLogic({fadingRole:e,fadingDirection:t,fadingParentID:i,fadeEndTime:r}){this.resetFadeLogic(),this.fadingRole=e,this.fadingDirection=t,this.fadingParentID=i,this.fadeEndTime=r}setSelfFadeLogic(e){this.resetFadeLogic(),this.selfFading=!0,this.fadeEndTime=e}resetFadeLogic(){this.fadingRole=null,this.fadingDirection=null,this.fadingParentID=null,this.selfFading=!1,this.timeAdded=c(),this.fadeEndTime=0,this.fadeOpacity=1}wasRequested(){return"errored"===this.state||"loaded"===this.state||"reloading"===this.state}clearTextures(e){this.demTexture&&e.saveTileTexture(this.demTexture),this.demTexture=null}loadVectorData(e,i,r){if(this.hasData()&&this.unloadVectorData(),this.state="loaded",e){e.featureIndex&&(this.latestFeatureIndex=e.featureIndex,e.rawTileData?(this.latestRawTileData=e.rawTileData,this.latestFeatureIndex.rawTileData=e.rawTileData,this.latestFeatureIndex.encoding=e.encoding):this.latestRawTileData&&(this.latestFeatureIndex.rawTileData=this.latestRawTileData,this.latestFeatureIndex.encoding=this.latestEncoding)),this.collisionBoxArray=e.collisionBoxArray,this.buckets=function(e,t){const i={};if(!t)return i;for(const r of e){const e=r.layerIds.map(e=>t.getLayer(e)).filter(Boolean);if(0!==e.length){r.layers=e,r.stateDependentLayerIds&&(r.stateDependentLayers=r.stateDependentLayerIds.map(t=>e.filter(e=>e.id===t)[0]));for(const t of e)i[t.id]=r}}return i}(e.buckets,null==i?void 0:i.style),this.hasSymbolBuckets=!1;for(const e in this.buckets){const i=this.buckets[e];if(i instanceof t.ai){if(this.hasSymbolBuckets=!0,!r)break;i.justReloaded=!0}}if(this.hasRTLText=!1,this.hasSymbolBuckets)for(const e in this.buckets){const i=this.buckets[e];if(i instanceof t.ai&&i.hasRTLText){this.hasRTLText=!0,ce().lazyLoad();break}}this.queryPadding=0;for(const e in this.buckets){const t=this.buckets[e];this.queryPadding=Math.max(this.queryPadding,i.style.getLayer(e).queryRadius(t))}e.imageAtlas&&(this.imageAtlas=e.imageAtlas),e.glyphAtlasImage&&(this.glyphAtlasImage=e.glyphAtlasImage),this.dashPositions=e.dashPositions}else this.collisionBoxArray=new t.ah}unloadVectorData(){for(const e in this.buckets)this.buckets[e].destroy();this.buckets={},this.imageAtlasTexture&&this.imageAtlasTexture.destroy(),this.imageAtlas&&(this.imageAtlas=null),this.glyphAtlasTexture&&this.glyphAtlasTexture.destroy(),this.dashPositions&&(this.dashPositions=null),this.latestFeatureIndex=null,this.state="unloaded"}getBucket(e){return this.buckets[e.id]}upload(e){for(const t in this.buckets){const i=this.buckets[t];i.uploadPending()&&i.upload(e)}const i=e.gl;this.imageAtlas&&!this.imageAtlas.uploaded&&(this.imageAtlasTexture=new t.T(e,this.imageAtlas.image,i.RGBA),this.imageAtlas.uploaded=!0),this.glyphAtlasImage&&(this.glyphAtlasTexture=new t.T(e,this.glyphAtlasImage,i.ALPHA),this.glyphAtlasImage=null)}prepare(e){this.imageAtlas&&this.imageAtlas.patchUpdatedImages(e,this.imageAtlasTexture)}queryRenderedFeatures(e,t,i,r,n,o,s,a,l,c,u){return this.latestFeatureIndex&&this.latestFeatureIndex.rawTileData?this.latestFeatureIndex.query({queryGeometry:r,cameraQueryGeometry:n,scale:o,tileSize:this.tileSize,pixelPosMatrix:c,transform:a,params:s,queryPadding:this.queryPadding*l,getElevation:u},e,t,i):{}}querySourceFeatures(e,i){const r=this.latestFeatureIndex;if(!r||!r.rawTileData)return;const n=r.loadVTLayers(),o=i&&i.sourceLayer?i.sourceLayer:"",s=n[t.a9]||n[o];if(!s)return;const a=t.aj(null==i?void 0:i.filter,null==i?void 0:i.globalState),{z:l,x:c,y:u}=this.tileID.canonical,h={z:l,x:c,y:u};for(let i=0;ie)t=!1;else if(i)if(this.expirationTime({zoom:0,x:0,y:0,wrap:e,fullyVisible:!1}),v=[],x=[];if(e.renderWorldCopies&&a.allowWorldCopies())for(let e=1;e<=3;e++)v.push(y(-e)),v.push(y(e));for(v.push(y(0));v.length>0;){const p=v.pop(),g=p.x,y=p.y;let b=p.fullyVisible;const w={x:g,y:y,z:p.zoom},T=a.getTileBoundingVolume(w,p.wrap,e.elevation,i);if(!b){const e=ve(r,T,n);if(0===e)continue;b=2===e}const E=a.distanceToTile2d(o.x,o.y,w,T);let C=c;l&&(C=(i.calculateTileZoom||we)(e.zoom+t.at(e.tileSize/i.tileSize),E,_,A,e.fov)),C=(i.roundZoom?Math.round:Math.floor)(C),C=Math.max(0,C);const B=Math.min(C,h);if(p.wrap=a.getWrap(s,w,p.wrap),p.zoom>=B){if(p.zoom>1),wrap:p.wrap,fullyVisible:b})}return x.sort((e,t)=>e.distanceSq-t.distanceSq).map(e=>e.tileID)}const Ce=t.ab.fromPoints([new t.P(0,0),new t.P(t.a4,t.a4)]);class Be extends t.E{constructor(e,i,r){super(),this.id=e,this.dispatcher=r,this.on("data",e=>this._dataHandler(e)),this.on("dataloading",()=>{this._sourceErrored=!1}),this.on("error",()=>{this._sourceErrored=this._source.loaded()}),this._source=((e,t,i,r)=>{const n=new(oe(t.type))(e,t,i,r);if(n.id!==e)throw new Error(`Expected Source id to be ${e} instead of ${n.id}`);return n})(e,i,r,this),this._tiles={},this._cache=new t.av(0,e=>this._unloadTile(e)),this._timers={},this._maxTileCacheSize=null,this._maxTileCacheZoomLevels=null,this._rasterFadeDuration=0,this._maxFadingAncestorLevels=5,this._state=new pe,this._didEmitContent=!1,this._updated=!1}onAdd(e){this.map=e,this._maxTileCacheSize=e?e._maxTileCacheSize:null,this._maxTileCacheZoomLevels=e?e._maxTileCacheZoomLevels:null,this._source&&this._source.onAdd&&this._source.onAdd(e)}onRemove(e){this.clearTiles(),this._source&&this._source.onRemove&&this._source.onRemove(e)}loaded(){if(this._sourceErrored)return!0;if(!this._sourceLoaded)return!1;if(!this._source.loaded())return!1;if(!(void 0===this.used&&void 0===this.usedForTerrain||this.used||this.usedForTerrain))return!0;if(!this._updated)return!1;for(const e in this._tiles){const t=this._tiles[e];if("loaded"!==t.state&&"errored"!==t.state)return!1}return!0}getSource(){return this._source}getState(){return this._state}pause(){this._paused=!0}resume(){if(!this._paused)return;const e=this._shouldReloadOnResume;this._paused=!1,this._shouldReloadOnResume=!1,e&&this.reload(),this.transform&&this.update(this.transform,this.terrain)}_loadTile(e,i,r){return t._(this,void 0,void 0,function*(){try{yield this._source.loadTile(e),this._tileLoaded(e,i,r)}catch(i){e.state="errored",404!==i.status?this._source.fire(new t.k(i,{tile:e})):this.update(this.transform,this.terrain)}})}_unloadTile(e){this._source.unloadTile&&this._source.unloadTile(e)}_abortTile(e){this._source.abortTile&&this._source.abortTile(e),this._source.fire(new t.l("dataabort",{tile:e,coord:e.tileID,dataType:"source"}))}serialize(){return this._source.serialize()}prepare(e){this._source.prepare&&this._source.prepare(),this._state.coalesceChanges(this._tiles,this.map?this.map.painter:null);for(const t in this._tiles){const i=this._tiles[t];i.upload(e),i.prepare(this.map.style.imageManager)}}getIds(){return Object.values(this._tiles).map(e=>e.tileID).sort(Se).map(e=>e.key)}getRenderableIds(e){const i=[];for(const t in this._tiles)this._isIdRenderable(t,e)&&i.push(this._tiles[t]);return e?i.sort((e,i)=>{const r=e.tileID,n=i.tileID,o=new t.P(r.canonical.x,r.canonical.y)._rotate(-this.transform.bearingInRadians),s=new t.P(n.canonical.x,n.canonical.y)._rotate(-this.transform.bearingInRadians);return r.overscaledZ-n.overscaledZ||s.y-o.y||s.x-o.x}).map(e=>e.tileID.key):i.map(e=>e.tileID).sort(Se).map(e=>e.key)}hasRenderableParent(e){const t=e.overscaledZ-1;if(t>=this._source.minzoom){const i=this.getLoadedTile(e.scaledTo(t));if(i)return this._isIdRenderable(i.tileID.key)}return!1}_isIdRenderable(e,t=!1){var i;return null===(i=this._tiles[e])||void 0===i?void 0:i.isRenderable(t)}reload(e,t=void 0){if(this._paused)this._shouldReloadOnResume=!0;else{this._cache.reset();for(const i in this._tiles)t&&this._source.shouldReloadTile&&!this._source.shouldReloadTile(this._tiles[i],t)||(e?this._reloadTile(i,"expired"):"errored"!==this._tiles[i].state&&this._reloadTile(i,"reloading"))}}_reloadTile(e,i){return t._(this,void 0,void 0,function*(){const t=this._tiles[e];t&&("loading"!==t.state&&(t.state=i),yield this._loadTile(t,e,i))})}_tileLoaded(e,i,r){e.timeAdded=c(),e.selfFading&&(e.fadeEndTime=e.timeAdded+this._rasterFadeDuration),"expired"===r&&(e.refreshedUponExpiration=!0),this._setTileReloadTimer(i,e),"raster-dem"===this.getSource().type&&e.dem&&this._backfillDEM(e),this._state.initializeTileState(e,this.map?this.map.painter:null),e.aborted||this._source.fire(new t.l("data",{dataType:"source",tile:e,coord:e.tileID}))}_backfillDEM(e){const t=this.getRenderableIds();for(let r=0;r1||(Math.abs(i)>1&&(1===Math.abs(i+n)?i+=n:1===Math.abs(i-n)&&(i-=n)),t.dem&&e.dem&&(e.dem.backfillBorder(t.dem,i,r),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){const i=this._getLoadedDescendents(t),r=new Set;for(const n of t){const t=i[n.key];if(!(null==t?void 0:t.length)){r.add(n);continue}const o=n.overscaledZ+Be.maxOverzooming,s=t.filter(e=>e.tileID.overscaledZ<=o);if(!s.length){r.add(n);continue}const a=Math.min(...s.map(e=>e.tileID.overscaledZ)),l=s.filter(e=>e.tileID.overscaledZ===a).map(e=>e.tileID);for(const t of l)e[t.key]=t;this._areDescendentsComplete(l,a,n.overscaledZ)||r.add(n)}return r}_getLoadedDescendents(e){var t;const i={};for(const r in this._tiles){const n=this._tiles[r];if(n.hasData())for(const r of e)n.tileID.isChildOf(r)&&(i[t=r.key]||(i[t]=[])).push(n)}return i}_areDescendentsComplete(e,t,i){return 1===e.length&&e[0].isOverscaled()?e[0].overscaledZ===t:Math.pow(4,t-i)===e.length}getLoadedTile(e){const t=this._tiles[e.key];return(null==t?void 0:t.hasData())?t:null}updateCacheSize(e){const i=Math.ceil(e.width/this._source.tileSize)+1,r=Math.ceil(e.height/this._source.tileSize)+1,n=Math.floor(i*r*(null===this._maxTileCacheZoomLevels?t.a.MAX_TILE_CACHE_ZOOM_LEVELS:this._maxTileCacheZoomLevels)),o="number"==typeof this._maxTileCacheSize?Math.min(this._maxTileCacheSize,n):n;this._cache.setMaxSize(o)}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 r=this._tiles[i];r.tileID=r.tileID.unwrapTo(r.tileID.wrap+t),e[r.tileID.key]=r}this._tiles=e,this._resetTileReloadTimers()}}update(e,i){if(!this._sourceLoaded||this._paused)return;let r;this.transform=e,this.terrain=i,this.updateCacheSize(e),this.handleWrapJump(this.transform.center.lng),this.used||this.usedForTerrain?this._source.tileID?r=e.getVisibleUnwrappedCoordinates(this._source.tileID).map(e=>new t.a1(e.canonical.z,e.wrap,e.canonical.z,e.canonical.x,e.canonical.y)):(r=Ee(e,{tileSize:this.usedForTerrain?this.tileSize:this._source.tileSize,minzoom:this._source.minzoom,maxzoom:"vector"===this._source.type&&void 0!==this.map._zoomLevelsToOverscale?e.maxZoom-this.map._zoomLevelsToOverscale:this._source.maxzoom,roundZoom:!this.usedForTerrain&&this._source.roundZoom,reparseOverscaled:this._source.reparseOverscaled,terrain:i,calculateTileZoom:this._source.calculateTileZoom}),this._source.hasTile&&(r=r.filter(e=>this._source.hasTile(e)))):r=[],this.usedForTerrain&&(r=this._addTerrainIdealTiles(r));const n=0===r.length&&!this._updated&&this._didEmitContent;this._updated=!0,n&&this.fire(new t.l("data",{sourceDataType:"idle",dataType:"source",sourceId:this.id}));const o=Te(e,this._source),s=this._updateRetainedTiles(r,o),a=Ie(this._source.type);a&&this._rasterFadeDuration>0&&!i&&this._updateFadingTiles(r,s),a?this._cleanUpRasterTiles(s):this._cleanUpVectorTiles(s)}_cleanUpRasterTiles(e){for(const t in this._tiles)e[t]||this._removeTile(t)}_cleanUpVectorTiles(e){for(const t in this._tiles){const i=this._tiles[t];e[t]?i.clearSymbolFadeHold():i.hasSymbolBuckets?i.holdingForSymbolFade()?i.symbolFadeFinished()&&this._removeTile(t):i.setSymbolHoldDuration(this.map._fadeDuration):this._removeTile(t)}}_addTerrainIdealTiles(e){const t=[];for(const i of e)if(i.canonical.z>this._source.minzoom){const e=i.scaledTo(i.canonical.z-1);t.push(e);const r=i.scaledTo(Math.max(this._source.minzoom,Math.min(i.canonical.z,5)));t.push(r)}return e.concat(t)}releaseSymbolFadeTiles(){for(const e in this._tiles)this._tiles[e].holdingForSymbolFade()&&this._removeTile(e)}_updateRetainedTiles(e,t){var i;const r=new Set;for(const t of e)this._addTile(t).hasData()||r.add(t);const n=e.reduce((e,t)=>(e[t.key]=t,e),{}),o=this._retainLoadedChildren(n,r),s={},a=Math.max(t-Be.maxUnderzooming,this._source.minzoom);for(const e of o){let t=this._tiles[e.key],r=null==t?void 0:t.wasRequested();for(let o=e.overscaledZ-1;o>=a;--o){const a=e.scaledTo(o);if(s[a.key])break;if(s[a.key]=!0,t=this.getTile(a),!t&&r&&(t=this._addTile(a)),t){const e=t.hasData();if((e||!(null===(i=this.map)||void 0===i?void 0:i.cancelPendingTileRequestsWhileZooming)||r)&&(n[a.key]=a),r=t.wasRequested(),e)break}}}return n}_updateFadingTiles(e,i){const r=c(),n=t.aw(e);for(const t of e){const e=this._tiles[t.key];e.fadingDirection!==he.Departing&&0!==e.fadeOpacity||e.resetFadeLogic(),this._updateFadingAncestor(e,i,r)||this._updateFadingDescendents(e,i,r)||this._updateFadingEdge(e,n,r)||e.resetFadeLogic()}}_updateFadingAncestor(e,t,i){if(!e.hasData())return!1;const{tileID:r,fadingRole:n,fadingDirection:o,fadingParentID:s}=e;if(n===ue.Base&&o===he.Incoming&&s)return t[s.key]=s,!0;const a=Math.max(r.overscaledZ-this._maxFadingAncestorLevels,this._source.minzoom);for(let n=r.overscaledZ-1;n>=a;n--){const o=r.scaledTo(n),s=this.getLoadedTile(o);if(s)return e.setCrossFadeLogic({fadingRole:ue.Base,fadingDirection:he.Incoming,fadingParentID:s.tileID,fadeEndTime:i+this._rasterFadeDuration}),s.setCrossFadeLogic({fadingRole:ue.Parent,fadingDirection:he.Departing,fadeEndTime:i+this._rasterFadeDuration}),t[o.key]=o,!0}return!1}_updateFadingDescendents(e,t,i){if(!e.hasData())return!1;const r=e.tileID.children(this._source.maxzoom);let n=this._updateFadingChildren(e,r,t,i);if(n)return!0;for(const o of r){const r=o.children(this._source.maxzoom);this._updateFadingChildren(e,r,t,i)&&(n=!0)}return n}_updateFadingChildren(e,t,i,r){if(t[0].overscaledZ>=this._source.maxzoom)return!1;let n=!1;for(const o of t){const t=this.getLoadedTile(o);if(!t)continue;const{fadingRole:s,fadingDirection:a,fadingParentID:l}=t;s===ue.Base&&a===he.Departing&&l||(t.setCrossFadeLogic({fadingRole:ue.Base,fadingDirection:he.Departing,fadingParentID:e.tileID,fadeEndTime:r+this._rasterFadeDuration}),e.setCrossFadeLogic({fadingRole:ue.Parent,fadingDirection:he.Incoming,fadeEndTime:r+this._rasterFadeDuration})),i[o.key]=o,n=!0}return n}_updateFadingEdge(e,t,i){const r=e.tileID;return!!e.selfFading||!e.hasData()&&!!t.has(r)&&(e.setSelfFadeLogic(i+this._rasterFadeDuration),!0)}_addTile(e){let i=this._tiles[e.key];if(i)return i;i=this._cache.getAndRemove(e),i&&(i.resetFadeLogic(),this._setTileReloadTimer(e.key,i),i.tileID=e,this._state.initializeTileState(i,this.map?this.map.painter:null));const r=i;return i||(i=new de(e,this._source.tileSize*e.overscaleFactor()),this._loadTile(i,e.key,i.state)),i.uses++,this._tiles[e.key]=i,r||this._source.fire(new t.l("dataloading",{tile:i,coord:i.tileID,dataType:"source"})),i}_setTileReloadTimer(e,t){this._clearTileReloadTimer(e);const i=t.getExpiryTimeout();i&&(this._timers[e]=setTimeout(()=>{this._reloadTile(e,"expired"),delete this._timers[e]},i))}_clearTileReloadTimer(e){const t=this._timers[e];t&&(clearTimeout(t),delete this._timers[e])}_resetTileReloadTimers(){for(const e in this._timers)clearTimeout(this._timers[e]),delete this._timers[e];for(const e in this._tiles)this._setTileReloadTimer(e,this._tiles[e])}refreshTiles(e){for(const t in this._tiles)(this._isIdRenderable(t)||"errored"==this._tiles[t].state)&&e.some(e=>e.equals(this._tiles[t].tileID.canonical))&&this._reloadTile(t,"expired")}_removeTile(e){const t=this._tiles[e];t&&(t.uses--,delete this._tiles[e],this._clearTileReloadTimer(e),t.uses>0||(t.hasData()&&"reloading"!==t.state?this._cache.add(t.tileID,t,t.getExpiryTimeout()):(t.aborted=!0,this._abortTile(t),this._unloadTile(t))))}_dataHandler(e){"source"===e.dataType&&("metadata"!==e.sourceDataType?"content"===e.sourceDataType&&this._sourceLoaded&&!this._paused&&(this.reload(e.sourceDataChanged,e.shouldReloadTileOptions),this.transform&&this.update(this.transform,this.terrain),this._didEmitContent=!0):this._sourceLoaded=!0)}clearTiles(){this._shouldReloadOnResume=!1,this._paused=!1;for(const e in this._tiles)this._removeTile(e);this._cache.reset()}tilesIn(e,i,r){const n=[],o=this.transform;if(!o)return n;const s=o.getCoveringTilesDetailsProvider().allowWorldCopies(),a=r?o.getCameraQueryGeometry(e):e,l=e=>o.screenPointToMercatorCoordinate(e,this.terrain),c=this.transformBbox(e,l,!s),u=this.transformBbox(a,l,!s),h=this.getIds(),d=t.ab.fromPoints(u);for(let e=0;ee.getTilePoint(new t.aa(i.x,i.y)));if(i.expandBy(p),i.intersects(Ce)){const t=c.map(t=>e.getTilePoint(t)),i=u.map(t=>e.getTilePoint(t));n.push({tile:r,tileID:s?e:e.unwrapTo(0),queryGeometry:t,cameraQueryGeometry:i,scale:l})}}}return n}transformBbox(e,i,r){let n=e.map(i);if(r){const r=t.ab.fromPoints(e);r.shrinkBy(.001*Math.min(r.width(),r.height()));const o=r.map(i);t.ab.fromPoints(n).covers(o)||(n=n.map(e=>e.x>.5?new t.aa(e.x-1,e.y,e.z):e))}return n}getVisibleCoordinates(e){const t=this.getRenderableIds(e).map(e=>this._tiles[e].tileID);return this.transform&&this.transform.populateCache(t),t}hasTransition(){if(this._source.hasTransition())return!0;if(Ie(this._source.type)&&this._rasterFadeDuration>0){const e=c();for(const t in this._tiles)if(this._tiles[t].fadeEndTime>=e)return!0}return!1}setRasterFadeDuration(e){this._rasterFadeDuration=e}setFeatureState(e,i,r){this._state.updateState(e=e||t.a9,i,r)}removeFeatureState(e,i,r){this._state.removeFeatureState(e=e||t.a9,i,r)}getFeatureState(e,i){return this._state.getState(e=e||t.a9,i)}setDependencies(e,t,i){const r=this._tiles[e];r&&r.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))}}function Se(e,t){const i=Math.abs(2*e.wrap)-+(e.wrap<0),r=Math.abs(2*t.wrap)-+(t.wrap<0);return e.overscaledZ-t.overscaledZ||r-i||t.canonical.y-e.canonical.y||t.canonical.x-e.canonical.x}function Ie(e){return"raster"===e||"image"===e||"video"===e}Be.maxUnderzooming=10,Be.maxOverzooming=3;class Me{constructor(e,t){this.reset(e,t)}reset(e,t){this.points=e||[],this._distances=[0];for(let e=1;e0?(n-s)/a:0;return this.points[o].mult(1-l).add(this.points[i].mult(l))}}function Pe(e,t){let i=!0;return"always"===e||"never"!==e&&"never"!==t||(i=!1),i}class Re{constructor(e,t,i){const r=this.boxCells=[],n=this.circleCells=[];this.xCellCount=Math.ceil(e/i),this.yCellCount=Math.ceil(t/i);for(let e=0;ethis.width||r<0||t>this.height)return[];const a=[];if(e<=0&&t<=0&&this.width<=i&&this.height<=r){if(n)return[{key:null,x1:e,y1:t,x2:i,y2:r}];for(let e=0;e0}hitTestCircle(e,t,i,r,n){const o=e-i,s=e+i,a=t-i,l=t+i;if(s<0||o>this.width||l<0||a>this.height)return!1;const c=[];return this._forEachCell(o,a,s,l,this._queryCellCircle,c,{hitTest:!0,overlapMode:r,circle:{x:e,y:t,radius:i},seenUids:{box:{},circle:{}}},n),c.length>0}_queryCell(e,t,i,r,n,o,s,a){const{seenUids:l,hitTest:c,overlapMode:u}=s,h=this.boxCells[n];if(null!==h){const n=this.bboxes;for(const s of h)if(!l.box[s]){l.box[s]=!0;const h=4*s,d=this.boxKeys[s];if(e<=n[h+2]&&t<=n[h+3]&&i>=n[h+0]&&r>=n[h+1]&&(!a||a(d))&&(!c||!Pe(u,d.overlapMode))&&(o.push({key:d,x1:n[h],y1:n[h+1],x2:n[h+2],y2:n[h+3]}),c))return!0}}const d=this.circleCells[n];if(null!==d){const n=this.circles;for(const s of d)if(!l.circle[s]){l.circle[s]=!0;const h=3*s,d=this.circleKeys[s];if(this._circleAndRectCollide(n[h],n[h+1],n[h+2],e,t,i,r)&&(!a||a(d))&&(!c||!Pe(u,d.overlapMode))){const e=n[h],t=n[h+1],i=n[h+2];if(o.push({key:d,x1:e-i,y1:t-i,x2:e+i,y2:t+i}),c)return!0}}}return!1}_queryCellCircle(e,t,i,r,n,o,s,a){const{circle:l,seenUids:c,overlapMode:u}=s,h=this.boxCells[n];if(null!==h){const e=this.bboxes;for(const t of h)if(!c.box[t]){c.box[t]=!0;const i=4*t,r=this.boxKeys[t];if(this._circleAndRectCollide(l.x,l.y,l.radius,e[i+0],e[i+1],e[i+2],e[i+3])&&(!a||a(r))&&!Pe(u,r.overlapMode))return o.push(!0),!0}}const d=this.circleCells[n];if(null!==d){const e=this.circles;for(const t of d)if(!c.circle[t]){c.circle[t]=!0;const i=3*t,r=this.circleKeys[t];if(this._circlesCollide(e[i],e[i+1],e[i+2],l.x,l.y,l.radius)&&(!a||a(r))&&!Pe(u,r.overlapMode))return o.push(!0),!0}}}_forEachCell(e,t,i,r,n,o,s,a){const l=this._convertToXCellCoord(e),c=this._convertToYCellCoord(t),u=this._convertToXCellCoord(i),h=this._convertToYCellCoord(r);for(let d=l;d<=u;d++)for(let l=c;l<=h;l++)if(n.call(this,e,t,i,r,this.xCellCount*l+d,o,s,a))return}_convertToXCellCoord(e){return Math.max(0,Math.min(this.xCellCount-1,Math.floor(e*this.xScale)))}_convertToYCellCoord(e){return Math.max(0,Math.min(this.yCellCount-1,Math.floor(e*this.yScale)))}_circlesCollide(e,t,i,r,n,o){const s=r-e,a=n-t,l=i+o;return l*l>s*s+a*a}_circleAndRectCollide(e,t,i,r,n,o,s){const a=(o-r)/2,l=Math.abs(e-(r+a));if(l>a+i)return!1;const c=(s-n)/2,u=Math.abs(t-(n+c));if(u>c+i)return!1;if(l<=a||u<=c)return!0;const h=l-a,d=u-c;return h*h+d*d<=i*i}}function Le(e,i,n){const o=t.N();if(!e){const{vecSouth:e,vecEast:t}=ke(i),n=r();n[0]=t[0],n[1]=t[1],n[2]=e[0],n[3]=e[1],s=n,(d=(l=(a=n)[0])*(h=a[3])-(u=a[2])*(c=a[1]))&&(s[0]=h*(d=1/d),s[1]=-c*d,s[2]=-u*d,s[3]=l*d),o[0]=n[0],o[1]=n[1],o[4]=n[2],o[5]=n[3]}var s,a,l,c,u,h,d;return t.Q(o,o,[1/n,1/n,1]),o}function Fe(e,i,r,n){if(e){const e=t.N();if(!i){const{vecSouth:t,vecEast:i}=ke(r);e[0]=i[0],e[1]=i[1],e[4]=t[0],e[5]=t[1]}return t.Q(e,e,[n,n,1]),e}return r.pixelsToClipSpaceMatrix}function ke(e){const i=Math.cos(e.rollInRadians),r=Math.sin(e.rollInRadians),n=Math.cos(e.pitchInRadians),o=Math.cos(e.bearingInRadians),s=Math.sin(e.bearingInRadians),a=t.aB();a[0]=-o*n*r-s*i,a[1]=-s*n*r+o*i;const l=t.aC(a);l<1e-9?t.aD(a):t.aE(a,a,1/l);const c=t.aB();c[0]=o*n*i-s*r,c[1]=s*n*i+o*r;const u=t.aC(c);return u<1e-9?t.aD(c):t.aE(c,c,1/u),{vecEast:c,vecSouth:a}}function De(e,i,r,n){let o;n?(o=[e,i,n(e,i),1],t.aG(o,o,r)):(o=[e,i,0,1],Ye(o,o,r));const s=o[3];return{point:new t.P(o[0]/s,o[1]/s),signedDistanceFromCamera:s,isOccluded:!1}}function Oe(e,t){return.5+e/t*.5}function ze(e,t){return e.x>=-t[0]&&e.x<=t[0]&&e.y>=-t[1]&&e.y<=t[1]}function Ue(e,i,r,n,o,s,a,l,c,u,h,d,p){const f=r?e.textSizeData:e.iconSizeData,m=t.ax(f,i.transform.zoom),g=[256/i.width*2+1,256/i.height*2+1],_=r?e.text.dynamicLayoutVertexArray:e.icon.dynamicLayoutVertexArray;_.clear();const A=e.lineVertexArray,y=r?e.text.placedSymbolArray:e.icon.placedSymbolArray,v=i.transform.width/i.transform.height;let x=!1;for(let r=0;rMath.abs(r.x-i.x)*n?{useVertical:!0}:(e===t.ay.vertical?i.yr.x)?{needsFlipping:!0}:null}function je(e){const{projectionContext:i,pitchedLabelPlaneMatrixInverse:r,symbol:n,fontSize:o,flip:s,keepUpright:a,glyphOffsetArray:l,dynamicLayoutVertexArray:c,aspectRatio:u,rotateToLine:h}=e,d=o/24,p=n.lineOffsetX*d,f=n.lineOffsetY*d;let m;if(n.numGlyphs>1){const e=n.glyphStartIndex+n.numGlyphs,t=n.lineStartIndex,o=n.lineStartIndex+n.lineLength,c=Ne(d,l,p,f,s,n,h,i);if(!c)return{notEnoughRoom:!0};const g=$e(c.first.point.x,c.first.point.y,i,r),_=$e(c.last.point.x,c.last.point.y,i,r);if(a&&!s){const e=Ve(n.writingMode,g,_,u);if(e)return e}m=[c.first];for(let r=n.glyphStartIndex+1;r0?a.point:Ge(i.tileAnchorPoint,s,e,1,i),c=$e(e.x,e.y,i,r),h=$e(l.x,l.y,i,r),d=Ve(n.writingMode,c,h,u);if(d)return d}const e=Ke(d*l.getoffsetX(n.glyphStartIndex),p,f,s,n.segment,n.lineStartIndex,n.lineStartIndex+n.lineLength,i,h);if(!e||i.projectionCache.anyProjectionOccluded)return{notEnoughRoom:!0};m=[e]}for(const e of m)t.aF(c,e.point,e.angle);return{}}function Ge(e,t,i,r,n){const o=e.add(e.sub(t)._unit()),s=Qe(o.x,o.y,n).point,a=i.sub(s);return i.add(a._mult(r/a.mag()))}function He(e,i,r){const n=i.projectionCache;if(n.projections[e])return n.projections[e];const o=new t.P(i.lineVertexArray.getx(e),i.lineVertexArray.gety(e)),s=Qe(o.x,o.y,i);if(s.signedDistanceFromCamera>0)return n.projections[e]=s.point,n.anyProjectionOccluded=n.anyProjectionOccluded||s.isOccluded,s.point;const a=e-r.direction;return Ge(0===r.distanceFromAnchor?i.tileAnchorPoint:new t.P(i.lineVertexArray.getx(a),i.lineVertexArray.gety(a)),o,r.previousVertex,r.absOffsetX-r.distanceFromAnchor+1,i)}function Qe(e,t,i){const r=e+i.translation[0],n=t+i.translation[1];let o;return i.pitchWithMap?(o=De(r,n,i.pitchedLabelPlaneMatrix,i.getElevation),o.isOccluded=!1):(o=i.transform.projectTileCoordinates(r,n,i.unwrappedTileID,i.getElevation),o.point.x=(.5*o.point.x+.5)*i.width,o.point.y=(.5*-o.point.y+.5)*i.height),o}function $e(e,i,r,n){if(r.pitchWithMap){const o=[e,i,0,1];return t.aG(o,o,n),r.transform.projectTileCoordinates(o[0]/o[3],o[1]/o[3],r.unwrappedTileID,r.getElevation).point}return{x:e/r.width*2-1,y:1-i/r.height*2}}function Ze(e,t,i){return i.transform.projectTileCoordinates(e,t,i.unwrappedTileID,i.getElevation)}function We(e,t,i){return e._unit()._perp()._mult(t*i)}function qe(e,i,r,n,o,s,a,l,c){if(l.projectionCache.offsets[e])return l.projectionCache.offsets[e];const u=r.add(i);if(e+c.direction=o)return l.projectionCache.offsets[e]=u,u;const h=He(e+c.direction,l,c),d=We(h.sub(r),a,c.direction),p=r.add(d),f=h.add(d);return l.projectionCache.offsets[e]=t.aH(s,u,p,f)||u,l.projectionCache.offsets[e]}function Ke(e,t,i,r,n,o,s,a,l){const c=r?e-t:e+t;let u=c>0?1:-1,h=0;r&&(u*=-1,h=Math.PI),u<0&&(h+=Math.PI);let d,p=u>0?o+n:o+n+1;a.projectionCache.cachedAnchorPoint?d=a.projectionCache.cachedAnchorPoint:(d=Qe(a.tileAnchorPoint.x,a.tileAnchorPoint.y,a).point,a.projectionCache.cachedAnchorPoint=d);let f,m,g=d,_=d,A=0,y=0;const v=Math.abs(c),x=[];let b;for(;A+y<=v;){if(p+=u,p=s)return null;A+=y,_=g,m=f;const e={absOffsetX:v,direction:u,distanceFromAnchor:A,previousVertex:_};if(g=He(p,a,e),0===i)x.push(_),b=g.sub(_);else{let t;const r=g.sub(_);t=0===r.mag()?We(He(p+u,a,e).sub(g),i,u):We(r,i,u),m||(m=_.add(t)),f=qe(p,t,g,o,s,m,i,a,e),x.push(m),b=f.sub(m)}y=b.mag()}const w=b._mult((v-A)/y)._add(m||_),T=h+Math.atan2(g.y-_.y,g.x-_.x);return x.push(w),{point:w,angle:l?T:0,path:x}}const Xe=new Float32Array([-1/0,-1/0,0,-1/0,-1/0,0,-1/0,-1/0,0,-1/0,-1/0,0]);function Je(e,t){for(let i=0;i=1;e--)p.push(s.path[e]);for(let e=1;ee.signedDistanceFromCamera<=0)?[]:e.map(e=>e.point)}let g=[];if(p.length>0){const e=p[0].clone(),i=p[0].clone();for(let t=1;t=r.x&&i.x<=n.x&&e.y>=r.y&&i.y<=n.y?[p]:i.xn.x||i.yn.y?[]:t.aI([p],r.x,r.y,n.x,n.y)}for(const t of g){o.reset(t,.25*i);let r=0;r=o.length<=.5*i?1:Math.ceil(o.paddedLength/f)+1;for(let t=0;t{const t=De(e.x,e.y,r,i.getElevation),n=i.transform.projectTileCoordinates(t.point.x,t.point.y,i.unwrappedTileID,i.getElevation);return n.point.x=(.5*n.point.x+.5)*i.width,n.point.y=(.5*-n.point.y+.5)*i.height,n})}(e,i);return function(e){let t=0,i=0,r=0,n=0;for(let o=0;oi&&(i=n,t=r));return e.slice(t,t+i)}(r)}queryRenderedSymbols(e){if(0===e.length||0===this.grid.keysLength()&&0===this.ignoredGrid.keysLength())return{};const i=[],r=new t.ab;for(const n of e){const e=new t.P(n.x+et,n.y+et);r.extend(e),i.push(e)}const{minX:n,minY:o,maxX:s,maxY:a}=r,l=this.grid.query(n,o,s,a).concat(this.ignoredGrid.query(n,o,s,a)),c={},u={};for(const e of l){const r=e.key;if(void 0===c[r.bucketInstanceId]&&(c[r.bucketInstanceId]={}),c[r.bucketInstanceId][r.featureIndex])continue;const n=[new t.P(e.x1,e.y1),new t.P(e.x2,e.y1),new t.P(e.x2,e.y2),new t.P(e.x1,e.y2)];t.aJ(i,n)&&(c[r.bucketInstanceId][r.featureIndex]=!0,void 0===u[r.bucketInstanceId]&&(u[r.bucketInstanceId]=[]),u[r.bucketInstanceId].push(r.featureIndex))}return u}insertCollisionBox(e,t,i,r,n,o){(i?this.ignoredGrid:this.grid).insert({bucketInstanceId:r,featureIndex:n,collisionGroupID:o,overlapMode:t},e[0],e[1],e[2],e[3])}insertCollisionCircles(e,t,i,r,n,o){const s=i?this.ignoredGrid:this.grid,a={bucketInstanceId:r,featureIndex:n,collisionGroupID:o,overlapMode:t};for(let t=0;t=this.screenRightBoundary||rthis.screenBottomBoundary}isInsideGrid(e,t,i,r){return i>=0&&e=0&&tthis.projectAndGetPerspectiveRatio(e.x,e.y,n,c,h));I=e.some(e=>!e.isOccluded),S=e.map(e=>new t.P(e.x,e.y))}else I=!0;return{box:t.aK(S),allPointsOccluded:!I}}}class it{constructor(e,t,i,r){this.opacity=e?Math.max(0,Math.min(1,e.opacity+(e.placed?t:-t))):r&&i?1:0,this.placed=i}isHidden(){return 0===this.opacity&&!this.placed}}class rt{constructor(e,t,i,r,n){this.text=new it(e?e.text:null,t,i,n),this.icon=new it(e?e.icon:null,t,r,n)}isHidden(){return this.text.isHidden()&&this.icon.isHidden()}}class nt{constructor(e,t,i){this.text=e,this.icon=t,this.skipFade=i}}class ot{constructor(e,t,i,r,n){this.bucketInstanceId=e,this.featureIndex=t,this.sourceLayerIndex=i,this.bucketIndex=r,this.tileID=n}}class st{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 at(e,i,r,n,o){const{horizontalAlign:s,verticalAlign:a}=t.aR(e);return new t.P(-(s-.5)*i+n[0]*o,-(a-.5)*r+n[1]*o)}class lt{constructor(e,t,i,r,n){this.transform=e.clone(),this.terrain=t,this.collisionIndex=new tt(this.transform),this.placements={},this.opacities={},this.variableOffsets={},this.stale=!1,this.commitTime=0,this.fadeDuration=i,this.retainedQueryData={},this.collisionGroups=new st(r),this.collisionCircleArrays={},this.collisionBoxArrays=new Map,this.prevPlacement=n,n&&(n.prevPlacement=void 0),this.placedOrientations={}}_getTerrainElevationFunc(e){const t=this.terrain;return t?(i,r)=>t.getElevation(e,i,r):null}getBucketParts(e,i,r,n){const o=r.getBucket(i),s=r.latestFeatureIndex;if(!o||!s||i.id!==o.layerIds[0])return;const a=r.collisionBoxArray,l=o.layers[0].layout,c=o.layers[0].paint,u=Math.pow(2,this.transform.zoom-r.tileID.overscaledZ),h=r.tileSize/t.a4,d=r.tileID.toUnwrapped(),p="map"===l.get("text-rotation-alignment"),f=t.aM(r,1,this.transform.zoom),m=t.aN(this.collisionIndex.transform,r,c.get("text-translate"),c.get("text-translate-anchor")),g=t.aN(this.collisionIndex.transform,r,c.get("icon-translate"),c.get("icon-translate-anchor")),_=Le(p,this.transform,f);this.retainedQueryData[o.bucketInstanceId]=new ot(o.bucketInstanceId,s,o.sourceLayerIndex,o.index,r.tileID);const A={bucket:o,layout:l,translationText:m,translationIcon:g,unwrappedTileID:d,pitchedLabelPlaneMatrix:_,scale:u,textPixelRatio:h,holdingForFade:r.holdingForSymbolFade(),collisionBoxArray:a,partiallyEvaluatedTextSize:t.ax(o.textSizeData,this.transform.zoom),collisionGroup:this.collisionGroups.get(o.sourceID)};if(n)for(const t of o.sortKeyRanges){const{sortKey:i,symbolInstanceStart:r,symbolInstanceEnd:n}=t;e.push({sortKey:i,symbolInstanceStart:r,symbolInstanceEnd:n,parameters:A})}else e.push({symbolInstanceStart:0,symbolInstanceEnd:o.symbolInstances.length,parameters:A})}attemptAnchorPlacement(e,i,r,n,o,s,a,l,c,u,h,d,p,f,m,g,_,A,y,v){const x=t.aO[e.textAnchor],b=[e.textOffset0,e.textOffset1],w=at(x,r,n,b,o),T=this.collisionIndex.placeCollisionBox(i,d,l,c,u,a,s,g,h.predicate,y,w,v);if((!A||this.collisionIndex.placeCollisionBox(A,d,l,c,u,a,s,_,h.predicate,y,w,v).placeable)&&T.placeable){let e;if(this.prevPlacement&&this.prevPlacement.variableOffsets[p.crossTileID]&&this.prevPlacement.placements[p.crossTileID]&&this.prevPlacement.placements[p.crossTileID].text&&(e=this.prevPlacement.variableOffsets[p.crossTileID].anchor),0===p.crossTileID)throw new Error("symbolInstance.crossTileID can't be 0");return this.variableOffsets[p.crossTileID]={textOffset:b,width:r,height:n,anchor:x,textBoxScale:o,prevAnchor:e},this.markUsedJustification(f,x,p,m),f.allowVerticalPlacement&&(this.markUsedOrientation(f,m,p),this.placedOrientations[p.crossTileID]=m),{shift:w,placedGlyphBoxes:T}}}placeLayerBucketPart(e,i,r){const{bucket:n,layout:o,translationText:s,translationIcon:a,unwrappedTileID:l,pitchedLabelPlaneMatrix:c,textPixelRatio:u,holdingForFade:h,collisionBoxArray:d,partiallyEvaluatedTextSize:p,collisionGroup:f}=e.parameters,m=o.get("text-optional"),g=o.get("icon-optional"),_=t.aP(o,"text-overlap","text-allow-overlap"),A="always"===_,y=t.aP(o,"icon-overlap","icon-allow-overlap"),v="always"===y,x="map"===o.get("text-rotation-alignment"),b="map"===o.get("text-pitch-alignment"),w="none"!==o.get("icon-text-fit"),T="viewport-y"===o.get("symbol-z-order"),E=A&&(v||!n.hasIconData()||g),C=v&&(A||!n.hasTextData()||m);!n.collisionArrays&&d&&n.deserializeCollisionBoxes(d);const B=this.retainedQueryData[n.bucketInstanceId].tileID,S=this._getTerrainElevationFunc(B),I=this.transform.getFastPathSimpleProjectionMatrix(B),M=(e,d,v)=>{var T,M;if(i[e.crossTileID])return;if(h)return void(this.placements[e.crossTileID]=new nt(!1,!1,!1));let P=!1,R=!1,L=!0,F=null,k={box:null,placeable:!1,offscreen:null,occluded:!1},D={placeable:!1},O=null,z=null,U=null,N=0,V=0,j=0;d.textFeatureIndex?N=d.textFeatureIndex:e.useRuntimeCollisionCircles&&(N=e.featureIndex),d.verticalTextFeatureIndex&&(V=d.verticalTextFeatureIndex);const G=d.textBox;if(G){const i=i=>{let r=t.ay.horizontal;if(n.allowVerticalPlacement&&!i&&this.prevPlacement){const t=this.prevPlacement.placedOrientations[e.crossTileID];t&&(this.placedOrientations[e.crossTileID]=t,r=t,this.markUsedOrientation(n,r,e))}return r},o=(i,r)=>{if(n.allowVerticalPlacement&&e.numVerticalGlyphVertices>0&&d.verticalTextBox){for(const e of n.writingModes)if(e===t.ay.vertical?(k=r(),D=k):k=i(),k&&k.placeable)break}else k=i()},c=e.textAnchorOffsetStartIndex,h=e.textAnchorOffsetEndIndex;if(h===c){const r=(t,i)=>{const r=this.collisionIndex.placeCollisionBox(t,_,u,B,l,b,x,s,f.predicate,S,void 0,I);return r&&r.placeable&&(this.markUsedOrientation(n,i,e),this.placedOrientations[e.crossTileID]=i),r};o(()=>r(G,t.ay.horizontal),()=>{const i=d.verticalTextBox;return n.allowVerticalPlacement&&e.numVerticalGlyphVertices>0&&i?r(i,t.ay.vertical):{box:null,offscreen:null}}),i(k&&k.placeable)}else{let p=t.aO[null===(M=null===(T=this.prevPlacement)||void 0===T?void 0:T.variableOffsets[e.crossTileID])||void 0===M?void 0:M.anchor];const m=(t,i,o)=>{const d=t.x2-t.x1,m=t.y2-t.y1,g=e.textBoxScale,A=w&&"never"===y?i:null;let v=null,T="never"===_?1:2,E="never";p&&T++;for(let i=0;im(G,d.iconBox,t.ay.horizontal),()=>{const i=d.verticalTextBox;return n.allowVerticalPlacement&&(!k||!k.placeable)&&e.numVerticalGlyphVertices>0&&i?m(i,d.verticalIconBox,t.ay.vertical):{box:null,occluded:!0,offscreen:null}}),k&&(P=k.placeable,L=k.offscreen);const g=i(k&&k.placeable);if(!P&&this.prevPlacement){const t=this.prevPlacement.variableOffsets[e.crossTileID];t&&(this.variableOffsets[e.crossTileID]=t,this.markUsedJustification(n,t.anchor,e,g))}}}if(O=k,P=O&&O.placeable,L=O&&O.offscreen,e.useRuntimeCollisionCircles&&e.centerJustifiedTextSymbolIndex>=0){const i=n.text.placedSymbolArray.get(e.centerJustifiedTextSymbolIndex),a=t.az(n.textSizeData,p,i),u=o.get("text-padding");z=this.collisionIndex.placeCollisionCircles(_,i,n.lineVertexArray,n.glyphOffsetArray,a,l,c,r,b,f.predicate,e.collisionCircleDiameter,u,s,S),z.circles.length&&z.collisionDetected&&!r&&t.w("Collisions detected, but collision boxes are not shown"),P=A||z.circles.length>0&&!z.collisionDetected,L=L&&z.offscreen}if(d.iconFeatureIndex&&(j=d.iconFeatureIndex),d.iconBox){const e=e=>this.collisionIndex.placeCollisionBox(e,y,u,B,l,b,x,a,f.predicate,S,w&&F?F:void 0,I);D&&D.placeable&&d.verticalIconBox?(U=e(d.verticalIconBox),R=U.placeable):(U=e(d.iconBox),R=U.placeable),L=L&&U.offscreen}const H=m||0===e.numHorizontalGlyphVertices&&0===e.numVerticalGlyphVertices,Q=g||0===e.numIconVertices;H||Q?Q?H||(R=R&&P):P=R&&P:R=P=R&&P;const $=R&&U.placeable;if(P&&O.placeable&&this.collisionIndex.insertCollisionBox(O.box,_,o.get("text-ignore-placement"),n.bucketInstanceId,D&&D.placeable&&V?V:N,f.ID),$&&this.collisionIndex.insertCollisionBox(U.box,y,o.get("icon-ignore-placement"),n.bucketInstanceId,j,f.ID),z&&P&&this.collisionIndex.insertCollisionCircles(z.circles,_,o.get("text-ignore-placement"),n.bucketInstanceId,N,f.ID),r&&this.storeCollisionData(n.bucketInstanceId,v,d,O,U,z),0===e.crossTileID)throw new Error("symbolInstance.crossTileID can't be 0");if(0===n.bucketInstanceId)throw new Error("bucket.bucketInstanceId can't be 0");this.placements[e.crossTileID]=new nt((P||E)&&!(null==O?void 0:O.occluded),(R||C)&&!(null==U?void 0:U.occluded),L||n.justReloaded),i[e.crossTileID]=!0};if(T){if(0!==e.symbolInstanceStart)throw new Error("bucket.bucketInstanceId should be 0");const t=n.getSortedSymbolIndexes(-this.transform.bearingInRadians);for(let e=t.length-1;e>=0;--e){const i=t[e];M(n.symbolInstances.get(i),n.collisionArrays[i],i)}}else for(let t=e.symbolInstanceStart;t=0&&(e.text.placedSymbolArray.get(t).crossTileID=o>=0&&t!==o?0:r.crossTileID)}markUsedOrientation(e,i,r){const n=i===t.ay.horizontal||i===t.ay.horizontalOnly?i:0,o=i===t.ay.vertical?i:0,s=[r.leftJustifiedTextSymbolIndex,r.centerJustifiedTextSymbolIndex,r.rightJustifiedTextSymbolIndex];for(const t of s)e.text.placedSymbolArray.get(t).placedOrientation=n;r.verticalPlacedTextSymbolIndex&&(e.text.placedSymbolArray.get(r.verticalPlacedTextSymbolIndex).placedOrientation=o)}commit(e){this.commitTime=e,this.zoomAtLastRecencyCheck=this.transform.zoom;const t=this.prevPlacement;let i=!1;this.prevZoomAdjustment=t?t.zoomAdjustment(this.transform.zoom):0;const r=t?t.symbolFadeChange(e):1,n=t?t.opacities:{},o=t?t.variableOffsets:{},s=t?t.placedOrientations:{};for(const e in this.placements){const t=this.placements[e],o=n[e];o?(this.opacities[e]=new rt(o,r,t.text,t.icon),i=i||t.text!==o.text.placed||t.icon!==o.icon.placed):(this.opacities[e]=new rt(null,r,t.text,t.icon,t.skipFade),i=i||t.text||t.icon)}for(const e in n){const t=n[e];if(!this.opacities[e]){const n=new rt(t,r,!1,!1);n.isHidden()||(this.opacities[e]=n,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 s)this.placedOrientations[e]||!this.opacities[e]||this.opacities[e].isHidden()||(this.placedOrientations[e]=s[e]);if(t&&void 0===t.lastPlacementChangeTime)throw new Error("Last placement time for previous placement is not defined");i?this.lastPlacementChangeTime=e:"number"!=typeof this.lastPlacementChangeTime&&(this.lastPlacementChangeTime=t?t.lastPlacementChangeTime:e)}updateLayerOpacities(e,t){const i={};for(const r of t){const t=r.getBucket(e);t&&r.latestFeatureIndex&&e.id===t.layerIds[0]&&this.updateBucketOpacities(t,r.tileID,i,r.collisionBoxArray)}}updateBucketOpacities(e,i,r,n){e.hasTextData()&&(e.text.opacityVertexArray.clear(),e.text.hasVisibleVertices=!1),e.hasIconData()&&(e.icon.opacityVertexArray.clear(),e.icon.hasVisibleVertices=!1),e.hasIconCollisionBoxData()&&e.iconCollisionBox.collisionVertexArray.clear(),e.hasTextCollisionBoxData()&&e.textCollisionBox.collisionVertexArray.clear();const o=e.layers[0],s=o.layout,a=new rt(null,0,!1,!1,!0),l=s.get("text-allow-overlap"),c=s.get("icon-allow-overlap"),u=o._unevaluatedLayout.hasValue("text-variable-anchor")||o._unevaluatedLayout.hasValue("text-variable-anchor-offset"),h="map"===s.get("text-rotation-alignment"),d="map"===s.get("text-pitch-alignment"),p="none"!==s.get("icon-text-fit"),f=new rt(null,0,l&&(c||!e.hasIconData()||s.get("icon-optional")),c&&(l||!e.hasTextData()||s.get("text-optional")),!0);!e.collisionArrays&&n&&(e.hasIconCollisionBoxData()||e.hasTextCollisionBoxData())&&e.deserializeCollisionBoxes(n);const m=(e,t,i)=>{for(let r=0;r0,A=this.placedOrientations[n.crossTileID],y=A===t.ay.vertical,v=A===t.ay.horizontal||A===t.ay.horizontalOnly;if(o>0||s>0){const t=_t(c.text);m(e.text,o,y?At:t),m(e.text,s,v?At:t);const i=c.text.isHidden();[n.rightJustifiedTextSymbolIndex,n.centerJustifiedTextSymbolIndex,n.leftJustifiedTextSymbolIndex].forEach(t=>{t>=0&&(e.text.placedSymbolArray.get(t).hidden=i||y?1:0)}),n.verticalPlacedTextSymbolIndex>=0&&(e.text.placedSymbolArray.get(n.verticalPlacedTextSymbolIndex).hidden=i||v?1:0);const r=this.variableOffsets[n.crossTileID];r&&this.markUsedJustification(e,r.anchor,n,A);const a=this.placedOrientations[n.crossTileID];a&&(this.markUsedJustification(e,"left",n,a),this.markUsedOrientation(e,a,n))}if(_){const t=_t(c.icon),i=!(p&&n.verticalPlacedIconSymbolIndex&&y);n.placedIconSymbolIndex>=0&&(m(e.icon,n.numIconVertices,i?t:At),e.icon.placedSymbolArray.get(n.placedIconSymbolIndex).hidden=c.icon.isHidden()),n.verticalPlacedIconSymbolIndex>=0&&(m(e.icon,n.numVerticalIconVertices,i?At:t),e.icon.placedSymbolArray.get(n.verticalPlacedIconSymbolIndex).hidden=c.icon.isHidden())}const x=g&&g.has(i)?g.get(i):{text:null,icon:null};if(e.hasIconCollisionBoxData()||e.hasTextCollisionBoxData()){const r=e.collisionArrays[i];if(r){let i=new t.P(0,0);if(r.textBox||r.verticalTextBox){let t=!0;if(u){const e=this.variableOffsets[l];e?(i=at(e.anchor,e.width,e.height,e.textOffset,e.textBoxScale),h&&i._rotate(d?-this.transform.bearingInRadians:this.transform.bearingInRadians)):t=!1}if(r.textBox||r.verticalTextBox){let n;r.textBox&&(n=y),r.verticalTextBox&&(n=v),ct(e.textCollisionBox.collisionVertexArray,c.text.placed,!t||n,x.text,i.x,i.y)}}if(r.iconBox||r.verticalIconBox){const t=Boolean(!v&&r.verticalIconBox);let n;r.iconBox&&(n=t),r.verticalIconBox&&(n=!t),ct(e.iconCollisionBox.collisionVertexArray,c.icon.placed,n,x.icon,p?i.x:0,p?i.y:0)}}}}if(e.sortFeatures(-this.transform.bearingInRadians),this.retainedQueryData[e.bucketInstanceId]&&(this.retainedQueryData[e.bucketInstanceId].featureSortOrder=e.featureSortOrder),e.hasTextData()&&e.text.opacityVertexBuffer&&e.text.opacityVertexBuffer.updateData(e.text.opacityVertexArray),e.hasIconData()&&e.icon.opacityVertexBuffer&&e.icon.opacityVertexBuffer.updateData(e.icon.opacityVertexArray),e.hasIconCollisionBoxData()&&e.iconCollisionBox.collisionVertexBuffer&&e.iconCollisionBox.collisionVertexBuffer.updateData(e.iconCollisionBox.collisionVertexArray),e.hasTextCollisionBoxData()&&e.textCollisionBox.collisionVertexBuffer&&e.textCollisionBox.collisionVertexBuffer.updateData(e.textCollisionBox.collisionVertexArray),e.text.opacityVertexArray.length!==e.text.layoutVertexArray.length/4)throw new Error(`bucket.text.opacityVertexArray.length (= ${e.text.opacityVertexArray.length}) !== bucket.text.layoutVertexArray.length (= ${e.text.layoutVertexArray.length}) / 4`);if(e.icon.opacityVertexArray.length!==e.icon.layoutVertexArray.length/4)throw new Error(`bucket.icon.opacityVertexArray.length (= ${e.icon.opacityVertexArray.length}) !== bucket.icon.layoutVertexArray.length (= ${e.icon.layoutVertexArray.length}) / 4`);e.bucketInstanceId in this.collisionCircleArrays&&(e.collisionCircleArray=this.collisionCircleArrays[e.bucketInstanceId],delete this.collisionCircleArrays[e.bucketInstanceId])}symbolFadeChange(e){return 0===this.fadeDuration?1:(e-this.commitTime)/this.fadeDuration+this.prevZoomAdjustment}zoomAdjustment(e){return Math.max(0,(this.transform.zoom-e)/1.5)}hasTransitions(e){return this.stale||e-this.lastPlacementChangeTimee}setStale(){this.stale=!0}}function ct(e,t,i,r,n,o){r&&0!==r.length||(r=[0,0,0,0]);const s=r[0]-et,a=r[1]-et,l=r[2]-et,c=r[3]-et;e.emplaceBack(t?1:0,i?1:0,n||0,o||0,s,a),e.emplaceBack(t?1:0,i?1:0,n||0,o||0,l,a),e.emplaceBack(t?1:0,i?1:0,n||0,o||0,l,c),e.emplaceBack(t?1:0,i?1:0,n||0,o||0,s,c)}const ut=Math.pow(2,25),ht=Math.pow(2,24),dt=Math.pow(2,17),pt=Math.pow(2,16),ft=Math.pow(2,9),mt=Math.pow(2,8),gt=Math.pow(2,1);function _t(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*ut+t*ht+i*dt+t*pt+i*ft+t*mt+i*gt+t}const At=0;class yt{constructor(e){this._sortAcrossTiles="viewport-y"!==e.layout.get("symbol-z-order")&&!e.layout.get("symbol-sort-key").isConstant(),this._currentTileIndex=0,this._currentPartIndex=0,this._seenCrossTileIDs={},this._bucketParts=[]}continuePlacement(e,t,i,r,n){const o=this._bucketParts;for(;this._currentTileIndexe.sortKey-t.sortKey));this._currentPartIndex!this._forceFullPlacement&&c()-r>2;for(;this._currentPlacementIndex>=0;){const r=t[e[this._currentPlacementIndex]],o=this.placement.collisionIndex.transform.zoom;if("symbol"===r.type&&(!r.minzoom||r.minzoom<=o)&&(!r.maxzoom||r.maxzoom>o)){if(this._inProgressLayer||(this._inProgressLayer=new yt(r)),this._inProgressLayer.continuePlacement(i[r.source],this.placement,this._showCollisionBoxes,r,n))return;delete this._inProgressLayer}this._currentPlacementIndex--}this._done=!0}commit(e){return this.placement.commit(e),this.placement}}const xt=512/t.a4/2;class bt{constructor(e,i,r){this.tileID=e,this.bucketInstanceId=r,this._symbolsByKey={};const n=new Map;for(let e=0;e({x:Math.floor(e.anchorX*xt),y:Math.floor(e.anchorY*xt)})),crossTileIDs:i.map(e=>e.crossTileID)};if(r.positions.length>128){const e=new t.aS(r.positions.length,16,Uint16Array);for(const{x:t,y:i}of r.positions)e.add(t,i);e.finish(),delete r.positions,r.index=e}this._symbolsByKey[e]=r}}getScaledCoordinates(e,i){const{x:r,y:n,z:o}=this.tileID.canonical,{x:s,y:a,z:l}=i.canonical,c=xt/Math.pow(2,l-o),u=(a*t.a4+e.anchorY)*c,h=n*t.a4*xt;return{x:Math.floor((s*t.a4+e.anchorX)*c-r*t.a4*xt),y:Math.floor(u-h)}}findMatches(e,t,i){const r=this.tileID.canonical.ze)}}class wt{constructor(){this.maxCrossTileID=0}generate(){return++this.maxCrossTileID}}class Tt{constructor(){this.indexes={},this.usedCrossTileIDs={},this.lng=0}handleWrapJump(e){const t=Math.round((e-this.lng)/360);if(0!==t)for(const e in this.indexes){const i=this.indexes[e],r={};for(const e in i){const n=i[e];n.tileID=n.tileID.unwrapTo(n.tileID.wrap+t),r[n.tileID.key]=n}this.indexes[e]=r}this.lng=e}addBucket(e,t,i){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;ee.overscaledZ)for(const i in n){const o=n[i];o.tileID.isChildOf(e)&&o.findMatches(t.symbolInstances,e,r)}else{const o=n[e.scaledTo(Number(i)).key];o&&o.findMatches(t.symbolInstances,e,r)}}for(let e=0;e{t[e]=!0});for(const e in this.layerIndexes)t[e]||delete this.layerIndexes[e]}}var Ct="void main() {fragColor=vec4(1.0);}";const Bt={prelude:St("#ifdef GL_ES\nprecision mediump float;\n#else\n#if !defined(lowp)\n#define lowp\n#endif\n#if !defined(mediump)\n#define mediump\n#endif\n#if !defined(highp)\n#define highp\n#endif\n#endif\nout highp vec4 fragColor;","#ifdef GL_ES\nprecision highp float;\n#else\n#if !defined(lowp)\n#define lowp\n#endif\n#if !defined(mediump)\n#define mediump\n#endif\n#if !defined(highp)\n#define highp\n#endif\n#endif\nvec2 unpack_float(const float packedValue) {int packedIntValue=int(packedValue);int v0=packedIntValue/256;return vec2(v0,packedIntValue-v0*256);}vec2 unpack_opacity(const float packedOpacity) {int intOpacity=int(packedOpacity)/2;return vec2(float(intOpacity)/127.0,mod(packedOpacity,2.0));}vec4 decode_color(const vec2 encodedColor) {return vec4(unpack_float(encodedColor[0])/255.0,unpack_float(encodedColor[1])/255.0\n);}float unpack_mix_vec2(const vec2 packedValue,const float t) {return mix(packedValue[0],packedValue[1],t);}vec4 unpack_mix_color(const vec4 packedColors,const float t) {vec4 minColor=decode_color(vec2(packedColors[0],packedColors[1]));vec4 maxColor=decode_color(vec2(packedColors[2],packedColors[3]));return mix(minColor,maxColor,t);}vec2 get_pattern_pos(const vec2 pixel_coord_upper,const vec2 pixel_coord_lower,const vec2 pattern_size,const float tile_units_to_pixels,const vec2 pos) {vec2 offset=mod(mod(mod(pixel_coord_upper,pattern_size)*256.0,pattern_size)*256.0+pixel_coord_lower,pattern_size);return (tile_units_to_pixels*pos+offset)/pattern_size;}mat3 rotationMatrixFromAxisAngle(vec3 u,float angle) {float c=cos(angle);float s=sin(angle);float c2=1.0-c;return mat3(u.x*u.x*c2+ c,u.x*u.y*c2-u.z*s,u.x*u.z*c2+u.y*s,u.y*u.x*c2+u.z*s,u.y*u.y*c2+ c,u.y*u.z*c2-u.x*s,u.z*u.x*c2-u.y*s,u.z*u.y*c2+u.x*s,u.z*u.z*c2+ c\n);}\n#ifdef TERRAIN3D\nuniform sampler2D u_terrain;uniform float u_terrain_dim;uniform mat4 u_terrain_matrix;uniform vec4 u_terrain_unpack;uniform float u_terrain_exaggeration;uniform highp sampler2D u_depth;\n#endif\nconst highp vec4 bitSh=vec4(256.*256.*256.,256.*256.,256.,1.);const highp vec4 bitShifts=vec4(1.)/bitSh;highp float unpack(highp vec4 color) {return dot(color,bitShifts);}highp float depthOpacity(vec3 frag) {\n#ifdef TERRAIN3D\nhighp float d=unpack(texture(u_depth,frag.xy*0.5+0.5))+0.0001-frag.z;return 1.0-max(0.0,min(1.0,-d*500.0));\n#else\nreturn 1.0;\n#endif\n}float calculate_visibility(vec4 pos) {\n#ifdef TERRAIN3D\nvec3 frag=pos.xyz/pos.w;highp float d=depthOpacity(frag);if (d > 0.95) return 1.0;return (d+depthOpacity(frag+vec3(0.0,0.01,0.0)))/2.0;\n#else\nreturn 1.0;\n#endif\n}float ele(vec2 pos) {\n#ifdef TERRAIN3D\nvec4 rgb=(texture(u_terrain,pos)*255.0)*u_terrain_unpack;return rgb.r+rgb.g+rgb.b-u_terrain_unpack.a;\n#else\nreturn 0.0;\n#endif\n}float get_elevation(vec2 pos) {\n#ifdef TERRAIN3D\n#ifdef GLOBE\nif ((pos.y <-32767.5) || (pos.y > 32766.5)) {return 0.0;}\n#endif\nvec2 coord=(u_terrain_matrix*vec4(pos,0.0,1.0)).xy*u_terrain_dim+1.0;vec2 f=fract(coord);vec2 c=(floor(coord)+0.5)/(u_terrain_dim+2.0);float d=1.0/(u_terrain_dim+2.0);float tl=ele(c);float tr=ele(c+vec2(d,0.0));float bl=ele(c+vec2(0.0,d));float br=ele(c+vec2(d,d));float elevation=mix(mix(tl,tr,f.x),mix(bl,br,f.x),f.y);return elevation*u_terrain_exaggeration;\n#else\nreturn 0.0;\n#endif\n}const float PI=3.141592653589793;uniform mat4 u_projection_matrix;"),projectionMercator:St("","float projectLineThickness(float tileY) {return 1.0;}float projectCircleRadius(float tileY) {return 1.0;}vec4 projectTile(vec2 p) {vec4 result=u_projection_matrix*vec4(p,0.0,1.0);return result;}vec4 projectTile(vec2 p,vec2 rawPos) {vec4 result=u_projection_matrix*vec4(p,0.0,1.0);if (rawPos.y <-32767.5 || rawPos.y > 32766.5) {result.z=-10000000.0;}return result;}vec4 projectTileWithElevation(vec2 posInTile,float elevation) {return u_projection_matrix*vec4(posInTile,elevation,1.0);}vec4 projectTileFor3D(vec2 posInTile,float elevation) {return projectTileWithElevation(posInTile,elevation);}"),projectionGlobe:St("","#define GLOBE_RADIUS 6371008.8\nuniform highp vec4 u_projection_tile_mercator_coords;uniform highp vec4 u_projection_clipping_plane;uniform highp float u_projection_transition;uniform mat4 u_projection_fallback_matrix;vec3 globeRotateVector(vec3 vec,vec2 angles) {vec3 axisRight=vec3(vec.z,0.0,-vec.x);vec3 axisUp=cross(axisRight,vec);axisRight=normalize(axisRight);axisUp=normalize(axisUp);vec2 t=tan(angles);return normalize(vec+axisRight*t.x+axisUp*t.y);}mat3 globeGetRotationMatrix(vec3 spherePos) {vec3 axisRight=vec3(spherePos.z,0.0,-spherePos.x);vec3 axisDown=cross(axisRight,spherePos);axisRight=normalize(axisRight);axisDown=normalize(axisDown);return mat3(axisRight,axisDown,spherePos\n);}float circumferenceRatioAtTileY(float tileY) {float mercator_pos_y=u_projection_tile_mercator_coords.y+u_projection_tile_mercator_coords.w*tileY;float spherical_y=2.0*atan(exp(PI-(mercator_pos_y*PI*2.0)))-PI*0.5;return cos(spherical_y);}float projectLineThickness(float tileY) {float thickness=1.0/circumferenceRatioAtTileY(tileY); \nif (u_projection_transition < 0.999) {return mix(1.0,thickness,u_projection_transition);} else {return thickness;}}vec3 projectToSphere(vec2 translatedPos,vec2 rawPos) {vec2 mercator_pos=u_projection_tile_mercator_coords.xy+u_projection_tile_mercator_coords.zw*translatedPos;vec2 spherical;spherical.x=mercator_pos.x*PI*2.0+PI;spherical.y=2.0*atan(exp(PI-(mercator_pos.y*PI*2.0)))-PI*0.5;float len=cos(spherical.y);vec3 pos=vec3(sin(spherical.x)*len,sin(spherical.y),cos(spherical.x)*len\n);if (rawPos.y <-32767.5) {pos=vec3(0.0,1.0,0.0);}if (rawPos.y > 32766.5) {pos=vec3(0.0,-1.0,0.0);}return pos;}vec3 projectToSphere(vec2 posInTile) {return projectToSphere(posInTile,vec2(0.0,0.0));}float globeComputeClippingZ(vec3 spherePos) {return (1.0-(dot(spherePos,u_projection_clipping_plane.xyz)+u_projection_clipping_plane.w));}vec4 interpolateProjection(vec2 posInTile,vec3 spherePos,float elevation) {vec3 elevatedPos=spherePos*(1.0+elevation/GLOBE_RADIUS);vec4 globePosition=u_projection_matrix*vec4(elevatedPos,1.0);globePosition.z=globeComputeClippingZ(elevatedPos)*globePosition.w;if (u_projection_transition > 0.999) {return globePosition;}vec4 flatPosition=u_projection_fallback_matrix*vec4(posInTile,elevation,1.0);const float z_globeness_threshold=0.2;vec4 result=globePosition;result.z=mix(0.0,globePosition.z,clamp((u_projection_transition-z_globeness_threshold)/(1.0-z_globeness_threshold),0.0,1.0));result.xyw=mix(flatPosition.xyw,globePosition.xyw,u_projection_transition);if ((posInTile.y <-32767.5) || (posInTile.y > 32766.5)) {result=globePosition;const float poles_hidden_anim_percentage=0.02;result.z=mix(globePosition.z,100.0,pow(max((1.0-u_projection_transition)/poles_hidden_anim_percentage,0.0),8.0));}return result;}vec4 interpolateProjectionFor3D(vec2 posInTile,vec3 spherePos,float elevation) {vec3 elevatedPos=spherePos*(1.0+elevation/GLOBE_RADIUS);vec4 globePosition=u_projection_matrix*vec4(elevatedPos,1.0);if (u_projection_transition > 0.999) {return globePosition;}vec4 fallbackPosition=u_projection_fallback_matrix*vec4(posInTile,elevation,1.0);return mix(fallbackPosition,globePosition,u_projection_transition);}vec4 projectTile(vec2 posInTile) {return interpolateProjection(posInTile,projectToSphere(posInTile),0.0);}vec4 projectTile(vec2 posInTile,vec2 rawPos) {return interpolateProjection(posInTile,projectToSphere(posInTile,rawPos),0.0);}vec4 projectTileWithElevation(vec2 posInTile,float elevation) {return interpolateProjection(posInTile,projectToSphere(posInTile),elevation);}vec4 projectTileFor3D(vec2 posInTile,float elevation) {vec3 spherePos=projectToSphere(posInTile,posInTile);return interpolateProjectionFor3D(posInTile,spherePos,elevation);}"),background:St("uniform vec4 u_color;uniform float u_opacity;void main() {fragColor=u_color*u_opacity;\n#ifdef OVERDRAW_INSPECTOR\nfragColor=vec4(1.0);\n#endif\n}","in vec2 a_pos;void main() {gl_Position=projectTile(a_pos);}"),backgroundPattern:St("uniform vec2 u_pattern_tl_a;uniform vec2 u_pattern_br_a;uniform vec2 u_pattern_tl_b;uniform vec2 u_pattern_br_b;uniform vec2 u_texsize;uniform float u_mix;uniform float u_opacity;uniform sampler2D u_image;in vec2 v_pos_a;in vec2 v_pos_b;void main() {vec2 imagecoord=mod(v_pos_a,1.0);vec2 pos=mix(u_pattern_tl_a/u_texsize,u_pattern_br_a/u_texsize,imagecoord);vec4 color1=texture(u_image,pos);vec2 imagecoord_b=mod(v_pos_b,1.0);vec2 pos2=mix(u_pattern_tl_b/u_texsize,u_pattern_br_b/u_texsize,imagecoord_b);vec4 color2=texture(u_image,pos2);fragColor=mix(color1,color2,u_mix)*u_opacity;\n#ifdef OVERDRAW_INSPECTOR\nfragColor=vec4(1.0);\n#endif\n}","uniform vec2 u_pattern_size_a;uniform vec2 u_pattern_size_b;uniform vec2 u_pixel_coord_upper;uniform vec2 u_pixel_coord_lower;uniform float u_scale_a;uniform float u_scale_b;uniform float u_tile_units_to_pixels;in vec2 a_pos;out vec2 v_pos_a;out vec2 v_pos_b;void main() {gl_Position=projectTile(a_pos);v_pos_a=get_pattern_pos(u_pixel_coord_upper,u_pixel_coord_lower,u_scale_a*u_pattern_size_a,u_tile_units_to_pixels,a_pos);v_pos_b=get_pattern_pos(u_pixel_coord_upper,u_pixel_coord_lower,u_scale_b*u_pattern_size_b,u_tile_units_to_pixels,a_pos);}"),circle:St("in vec3 v_data;in float v_visibility;\n#pragma mapbox: define highp vec4 color\n#pragma mapbox: define mediump float radius\n#pragma mapbox: define lowp float blur\n#pragma mapbox: define lowp float opacity\n#pragma mapbox: define highp vec4 stroke_color\n#pragma mapbox: define mediump float stroke_width\n#pragma mapbox: define lowp float stroke_opacity\nvoid main() {\n#pragma mapbox: initialize highp vec4 color\n#pragma mapbox: initialize mediump float radius\n#pragma mapbox: initialize lowp float blur\n#pragma mapbox: initialize lowp float opacity\n#pragma mapbox: initialize highp vec4 stroke_color\n#pragma mapbox: initialize mediump float stroke_width\n#pragma mapbox: initialize lowp float stroke_opacity\nvec2 extrude=v_data.xy;float extrude_length=length(extrude);float antialiased_blur=v_data.z;float opacity_t=smoothstep(0.0,antialiased_blur,extrude_length-1.0);float color_t=stroke_width < 0.01 ? 0.0 : smoothstep(antialiased_blur,0.0,extrude_length-radius/(radius+stroke_width));fragColor=v_visibility*opacity_t*mix(color*opacity,stroke_color*stroke_opacity,color_t);const float epsilon=0.5/255.0;if (fragColor.r < epsilon && fragColor.g < epsilon && fragColor.b < epsilon && fragColor.a < epsilon) {discard;}\n#ifdef OVERDRAW_INSPECTOR\nfragColor=vec4(1.0);\n#endif\n}","uniform bool u_scale_with_map;uniform bool u_pitch_with_map;uniform vec2 u_extrude_scale;uniform highp float u_globe_extrude_scale;uniform lowp float u_device_pixel_ratio;uniform highp float u_camera_to_center_distance;uniform vec2 u_translate;in vec2 a_pos;out vec3 v_data;out float v_visibility;\n#pragma mapbox: define highp vec4 color\n#pragma mapbox: define mediump float radius\n#pragma mapbox: define lowp float blur\n#pragma mapbox: define lowp float opacity\n#pragma mapbox: define highp vec4 stroke_color\n#pragma mapbox: define mediump float stroke_width\n#pragma mapbox: define lowp float stroke_opacity\nvoid main(void) {\n#pragma mapbox: initialize highp vec4 color\n#pragma mapbox: initialize mediump float radius\n#pragma mapbox: initialize lowp float blur\n#pragma mapbox: initialize lowp float opacity\n#pragma mapbox: initialize highp vec4 stroke_color\n#pragma mapbox: initialize mediump float stroke_width\n#pragma mapbox: initialize lowp float stroke_opacity\nvec2 pos_raw=a_pos+32768.0;vec2 extrude=vec2(mod(pos_raw,8.0)/7.0*2.0-1.0);vec2 circle_center=floor(pos_raw/8.0)+u_translate;float ele=get_elevation(circle_center);v_visibility=calculate_visibility(projectTileWithElevation(circle_center,ele));if (u_pitch_with_map) {\n#ifdef GLOBE\nvec3 center_vector=projectToSphere(circle_center);\n#endif\nfloat angle_scale=u_globe_extrude_scale;vec2 corner_position=circle_center;if (u_scale_with_map) {angle_scale*=(radius+stroke_width);corner_position+=extrude*u_extrude_scale*(radius+stroke_width);} else {\n#ifdef GLOBE\nvec4 projected_center=interpolateProjection(circle_center,center_vector,ele);\n#else\nvec4 projected_center=projectTileWithElevation(circle_center,ele);\n#endif\ncorner_position+=extrude*u_extrude_scale*(radius+stroke_width)*(projected_center.w/u_camera_to_center_distance);angle_scale*=(radius+stroke_width)*(projected_center.w/u_camera_to_center_distance);}\n#ifdef GLOBE\nvec2 angles=extrude*angle_scale;vec3 corner_vector=globeRotateVector(center_vector,angles);gl_Position=interpolateProjection(corner_position,corner_vector,ele);\n#else\ngl_Position=projectTileWithElevation(corner_position,ele);\n#endif\n} else {gl_Position=projectTileWithElevation(circle_center,ele);if (gl_Position.z/gl_Position.w > 1.0) {gl_Position.xy=vec2(10000.0);}if (u_scale_with_map) {gl_Position.xy+=extrude*(radius+stroke_width)*u_extrude_scale*u_camera_to_center_distance;} else {gl_Position.xy+=extrude*(radius+stroke_width)*u_extrude_scale*gl_Position.w;}}float antialiasblur=-max(1.0/u_device_pixel_ratio/(radius+stroke_width),blur);v_data=vec3(extrude.x,extrude.y,antialiasblur);}"),clippingMask:St(Ct,"in vec2 a_pos;void main() {gl_Position=projectTile(a_pos);}"),heatmap:St("uniform highp float u_intensity;in vec2 v_extrude;\n#pragma mapbox: define highp float weight\n#define GAUSS_COEF 0.3989422804014327\nvoid main() {\n#pragma mapbox: initialize highp float weight\nfloat d=-0.5*3.0*3.0*dot(v_extrude,v_extrude);float val=weight*u_intensity*GAUSS_COEF*exp(d);fragColor=vec4(val,1.0,1.0,1.0);\n#ifdef OVERDRAW_INSPECTOR\nfragColor=vec4(1.0);\n#endif\n}","uniform float u_extrude_scale;uniform float u_opacity;uniform float u_intensity;uniform highp float u_globe_extrude_scale;in vec2 a_pos;out vec2 v_extrude;\n#pragma mapbox: define highp float weight\n#pragma mapbox: define mediump float radius\nconst highp float ZERO=1.0/255.0/16.0;\n#define GAUSS_COEF 0.3989422804014327\nvoid main(void) {\n#pragma mapbox: initialize highp float weight\n#pragma mapbox: initialize mediump float radius\nvec2 pos_raw=a_pos+32768.0;vec2 unscaled_extrude=vec2(mod(pos_raw,8.0)/7.0*2.0-1.0);float S=sqrt(-2.0*log(ZERO/weight/u_intensity/GAUSS_COEF))/3.0;v_extrude=S*unscaled_extrude;vec2 extrude=v_extrude*radius*u_extrude_scale;vec2 circle_center=floor(pos_raw/8.0);\n#ifdef GLOBE\nvec2 angles=v_extrude*radius*u_globe_extrude_scale;vec3 center_vector=projectToSphere(circle_center);vec3 corner_vector=globeRotateVector(center_vector,angles);gl_Position=interpolateProjection(circle_center+extrude,corner_vector,0.0);\n#else\ngl_Position=projectTileFor3D(circle_center+extrude,get_elevation(circle_center));\n#endif\n}"),heatmapTexture:St("uniform sampler2D u_image;uniform sampler2D u_color_ramp;uniform float u_opacity;in vec2 v_pos;void main() {float t=texture(u_image,v_pos).r;vec4 color=texture(u_color_ramp,vec2(t,0.5));fragColor=color*u_opacity;\n#ifdef OVERDRAW_INSPECTOR\nfragColor=vec4(0.0);\n#endif\n}","uniform mat4 u_matrix;uniform vec2 u_world;in vec2 a_pos;out vec2 v_pos;void main() {gl_Position=u_matrix*vec4(a_pos*u_world,0,1);v_pos.x=a_pos.x;v_pos.y=1.0-a_pos.y;}"),collisionBox:St("in float v_placed;in float v_notUsed;void main() {float alpha=0.5;fragColor=vec4(1.0,0.0,0.0,1.0)*alpha;if (v_placed > 0.5) {fragColor=vec4(0.0,0.0,1.0,0.5)*alpha;}if (v_notUsed > 0.5) {fragColor*=.1;}}","in vec2 a_anchor_pos;in vec2 a_placed;in vec2 a_box_real;uniform vec2 u_pixel_extrude_scale;out float v_placed;out float v_notUsed;void main() {gl_Position=projectTileWithElevation(a_anchor_pos,get_elevation(a_anchor_pos));gl_Position.xy=((a_box_real+0.5)*u_pixel_extrude_scale*2.0-1.0)*vec2(1.0,-1.0)*gl_Position.w;if (gl_Position.z/gl_Position.w < 1.1) {gl_Position.z=0.5;}v_placed=a_placed.x;v_notUsed=a_placed.y;}"),collisionCircle:St("in float v_radius;in vec2 v_extrude;in float v_collision;void main() {float alpha=0.5;float stroke_radius=0.9;float distance_to_center=length(v_extrude);float distance_to_edge=abs(distance_to_center-v_radius);float opacity_t=smoothstep(-stroke_radius,0.0,-distance_to_edge);vec4 color=mix(vec4(0.0,0.0,1.0,0.5),vec4(1.0,0.0,0.0,1.0),v_collision);fragColor=color*alpha*opacity_t;}","in vec2 a_pos;in float a_radius;in vec2 a_flags;uniform vec2 u_viewport_size;out float v_radius;out vec2 v_extrude;out float v_collision;void main() {float radius=a_radius;float collision=a_flags.x;float vertexIdx=a_flags.y;vec2 quadVertexOffset=vec2(mix(-1.0,1.0,float(vertexIdx >=2.0)),mix(-1.0,1.0,float(vertexIdx >=1.0 && vertexIdx <=2.0)));vec2 quadVertexExtent=quadVertexOffset*radius;float padding_factor=1.2;v_radius=radius;v_extrude=quadVertexExtent*padding_factor;v_collision=collision;gl_Position=vec4((a_pos/u_viewport_size*2.0-1.0)*vec2(1.0,-1.0),0.0,1.0)+vec4(quadVertexExtent*padding_factor/u_viewport_size*2.0,0.0,0.0);}"),colorRelief:St("#ifdef GL_ES\nprecision highp float;\n#endif\nuniform sampler2D u_image;uniform vec4 u_unpack;uniform sampler2D u_elevation_stops;uniform sampler2D u_color_stops;uniform int u_color_ramp_size;uniform float u_opacity;in vec2 v_pos;float getElevation(vec2 coord) {vec4 data=texture(u_image,coord)*255.0;data.a=-1.0;return dot(data,u_unpack);}float getElevationStop(int stop) {float x=(float(stop)+0.5)/float(u_color_ramp_size);vec4 data=texture(u_elevation_stops,vec2(x,0))*255.0;data.a=-1.0;return dot(data,u_unpack);}void main() {float el=getElevation(v_pos);int r=(u_color_ramp_size-1);int l=0;float el_l=getElevationStop(l);float el_r=getElevationStop(r);while(r-l > 1){int m=(r+l)/2;float el_m=getElevationStop(m);if(el < el_m){r=m;el_r=el_m;}else\n{l=m;el_l=el_m;}}float x=(float(l)+(el-el_l)/(el_r-el_l)+0.5)/float(u_color_ramp_size);fragColor=u_opacity*texture(u_color_stops,vec2(x,0));\n#ifdef OVERDRAW_INSPECTOR\nfragColor=vec4(1.0);\n#endif\n}","uniform vec2 u_dimension;in vec2 a_pos;out vec2 v_pos;void main() {gl_Position=projectTile(a_pos,a_pos);highp vec2 epsilon=1.0/u_dimension;float scale=(u_dimension.x-2.0)/u_dimension.x;v_pos=(a_pos/8192.0)*scale+epsilon;if (a_pos.y <-32767.5) {v_pos.y=0.0;}if (a_pos.y > 32766.5) {v_pos.y=1.0;}}"),debug:St("uniform highp vec4 u_color;uniform sampler2D u_overlay;in vec2 v_uv;void main() {vec4 overlay_color=texture(u_overlay,v_uv);fragColor=mix(u_color,overlay_color,overlay_color.a);}","in vec2 a_pos;out vec2 v_uv;uniform float u_overlay_scale;void main() {v_uv=a_pos/8192.0;gl_Position=projectTileWithElevation(a_pos*u_overlay_scale,get_elevation(a_pos));}"),depth:St(Ct,"in vec2 a_pos;void main() {\n#ifdef GLOBE\ngl_Position=projectTileFor3D(a_pos,0.0);\n#else\ngl_Position=u_projection_matrix*vec4(a_pos,0.0,1.0);\n#endif\n}"),fill:St("#pragma mapbox: define highp vec4 color\n#pragma mapbox: define lowp float opacity\nvoid main() {\n#pragma mapbox: initialize highp vec4 color\n#pragma mapbox: initialize lowp float opacity\nfragColor=color*opacity;\n#ifdef OVERDRAW_INSPECTOR\nfragColor=vec4(1.0);\n#endif\n}","uniform vec2 u_fill_translate;in vec2 a_pos;\n#pragma mapbox: define highp vec4 color\n#pragma mapbox: define lowp float opacity\nvoid main() {\n#pragma mapbox: initialize highp vec4 color\n#pragma mapbox: initialize lowp float opacity\ngl_Position=projectTile(a_pos+u_fill_translate,a_pos);}"),fillOutline:St("in vec2 v_pos;\n#ifdef GLOBE\nin float v_depth;\n#endif\n#pragma mapbox: define highp vec4 outline_color\n#pragma mapbox: define lowp float opacity\nvoid main() {\n#pragma mapbox: initialize highp vec4 outline_color\n#pragma mapbox: initialize lowp float opacity\nfloat dist=length(v_pos-gl_FragCoord.xy);float alpha=1.0-smoothstep(0.0,1.0,dist);fragColor=outline_color*(alpha*opacity);\n#ifdef GLOBE\nif (v_depth > 1.0) {discard;}\n#endif\n#ifdef OVERDRAW_INSPECTOR\nfragColor=vec4(1.0);\n#endif\n}","uniform vec2 u_world;uniform vec2 u_fill_translate;in vec2 a_pos;out vec2 v_pos;\n#ifdef GLOBE\nout float v_depth;\n#endif\n#pragma mapbox: define highp vec4 outline_color\n#pragma mapbox: define lowp float opacity\nvoid main() {\n#pragma mapbox: initialize highp vec4 outline_color\n#pragma mapbox: initialize lowp float opacity\ngl_Position=projectTile(a_pos+u_fill_translate,a_pos);v_pos=(gl_Position.xy/gl_Position.w+1.0)/2.0*u_world;\n#ifdef GLOBE\nv_depth=gl_Position.z/gl_Position.w;\n#endif\n}"),fillOutlinePattern:St("uniform vec2 u_texsize;uniform sampler2D u_image;uniform float u_fade;in vec2 v_pos_a;in vec2 v_pos_b;in vec2 v_pos;\n#ifdef GLOBE\nin float v_depth;\n#endif\n#pragma mapbox: define lowp float opacity\n#pragma mapbox: define lowp vec4 pattern_from\n#pragma mapbox: define lowp vec4 pattern_to\nvoid main() {\n#pragma mapbox: initialize lowp float opacity\n#pragma mapbox: initialize mediump vec4 pattern_from\n#pragma mapbox: initialize mediump vec4 pattern_to\nvec2 pattern_tl_a=pattern_from.xy;vec2 pattern_br_a=pattern_from.zw;vec2 pattern_tl_b=pattern_to.xy;vec2 pattern_br_b=pattern_to.zw;vec2 imagecoord=mod(v_pos_a,1.0);vec2 pos=mix(pattern_tl_a/u_texsize,pattern_br_a/u_texsize,imagecoord);vec4 color1=texture(u_image,pos);vec2 imagecoord_b=mod(v_pos_b,1.0);vec2 pos2=mix(pattern_tl_b/u_texsize,pattern_br_b/u_texsize,imagecoord_b);vec4 color2=texture(u_image,pos2);float dist=length(v_pos-gl_FragCoord.xy);float alpha=1.0-smoothstep(0.0,1.0,dist);fragColor=mix(color1,color2,u_fade)*alpha*opacity;\n#ifdef GLOBE\nif (v_depth > 1.0) {discard;}\n#endif\n#ifdef OVERDRAW_INSPECTOR\nfragColor=vec4(1.0);\n#endif\n}","uniform vec2 u_world;uniform vec2 u_pixel_coord_upper;uniform vec2 u_pixel_coord_lower;uniform vec3 u_scale;uniform vec2 u_fill_translate;in vec2 a_pos;out vec2 v_pos_a;out vec2 v_pos_b;out vec2 v_pos;\n#ifdef GLOBE\nout float v_depth;\n#endif\n#pragma mapbox: define lowp float opacity\n#pragma mapbox: define lowp vec4 pattern_from\n#pragma mapbox: define lowp vec4 pattern_to\n#pragma mapbox: define lowp float pixel_ratio_from\n#pragma mapbox: define lowp float pixel_ratio_to\nvoid main() {\n#pragma mapbox: initialize lowp float opacity\n#pragma mapbox: initialize mediump vec4 pattern_from\n#pragma mapbox: initialize mediump vec4 pattern_to\n#pragma mapbox: initialize lowp float pixel_ratio_from\n#pragma mapbox: initialize lowp float pixel_ratio_to\nvec2 pattern_tl_a=pattern_from.xy;vec2 pattern_br_a=pattern_from.zw;vec2 pattern_tl_b=pattern_to.xy;vec2 pattern_br_b=pattern_to.zw;float tileRatio=u_scale.x;float fromScale=u_scale.y;float toScale=u_scale.z;gl_Position=projectTile(a_pos+u_fill_translate,a_pos);vec2 display_size_a=(pattern_br_a-pattern_tl_a)/pixel_ratio_from;vec2 display_size_b=(pattern_br_b-pattern_tl_b)/pixel_ratio_to;v_pos_a=get_pattern_pos(u_pixel_coord_upper,u_pixel_coord_lower,fromScale*display_size_a,tileRatio,a_pos);v_pos_b=get_pattern_pos(u_pixel_coord_upper,u_pixel_coord_lower,toScale*display_size_b,tileRatio,a_pos);v_pos=(gl_Position.xy/gl_Position.w+1.0)/2.0*u_world;\n#ifdef GLOBE\nv_depth=gl_Position.z/gl_Position.w;\n#endif\n}"),fillPattern:St("#ifdef GL_ES\nprecision highp float;\n#endif\nuniform vec2 u_texsize;uniform float u_fade;uniform sampler2D u_image;in vec2 v_pos_a;in vec2 v_pos_b;\n#pragma mapbox: define lowp float opacity\n#pragma mapbox: define lowp vec4 pattern_from\n#pragma mapbox: define lowp vec4 pattern_to\nvoid main() {\n#pragma mapbox: initialize lowp float opacity\n#pragma mapbox: initialize mediump vec4 pattern_from\n#pragma mapbox: initialize mediump vec4 pattern_to\nvec2 pattern_tl_a=pattern_from.xy;vec2 pattern_br_a=pattern_from.zw;vec2 pattern_tl_b=pattern_to.xy;vec2 pattern_br_b=pattern_to.zw;vec2 imagecoord=mod(v_pos_a,1.0);vec2 pos=mix(pattern_tl_a/u_texsize,pattern_br_a/u_texsize,imagecoord);vec4 color1=texture(u_image,pos);vec2 imagecoord_b=mod(v_pos_b,1.0);vec2 pos2=mix(pattern_tl_b/u_texsize,pattern_br_b/u_texsize,imagecoord_b);vec4 color2=texture(u_image,pos2);fragColor=mix(color1,color2,u_fade)*opacity;\n#ifdef OVERDRAW_INSPECTOR\nfragColor=vec4(1.0);\n#endif\n}","uniform vec2 u_pixel_coord_upper;uniform vec2 u_pixel_coord_lower;uniform vec3 u_scale;uniform vec2 u_fill_translate;in vec2 a_pos;out vec2 v_pos_a;out vec2 v_pos_b;\n#pragma mapbox: define lowp float opacity\n#pragma mapbox: define lowp vec4 pattern_from\n#pragma mapbox: define lowp vec4 pattern_to\n#pragma mapbox: define lowp float pixel_ratio_from\n#pragma mapbox: define lowp float pixel_ratio_to\nvoid main() {\n#pragma mapbox: initialize lowp float opacity\n#pragma mapbox: initialize mediump vec4 pattern_from\n#pragma mapbox: initialize mediump vec4 pattern_to\n#pragma mapbox: initialize lowp float pixel_ratio_from\n#pragma mapbox: initialize lowp float pixel_ratio_to\nvec2 pattern_tl_a=pattern_from.xy;vec2 pattern_br_a=pattern_from.zw;vec2 pattern_tl_b=pattern_to.xy;vec2 pattern_br_b=pattern_to.zw;float tileZoomRatio=u_scale.x;float fromScale=u_scale.y;float toScale=u_scale.z;vec2 display_size_a=(pattern_br_a-pattern_tl_a)/pixel_ratio_from;vec2 display_size_b=(pattern_br_b-pattern_tl_b)/pixel_ratio_to;gl_Position=projectTile(a_pos+u_fill_translate,a_pos);v_pos_a=get_pattern_pos(u_pixel_coord_upper,u_pixel_coord_lower,fromScale*display_size_a,tileZoomRatio,a_pos);v_pos_b=get_pattern_pos(u_pixel_coord_upper,u_pixel_coord_lower,toScale*display_size_b,tileZoomRatio,a_pos);}"),fillExtrusion:St("in vec4 v_color;void main() {fragColor=v_color;\n#ifdef OVERDRAW_INSPECTOR\nfragColor=vec4(1.0);\n#endif\n}","uniform vec3 u_lightcolor;uniform lowp vec3 u_lightpos;uniform lowp vec3 u_lightpos_globe;uniform lowp float u_lightintensity;uniform float u_vertical_gradient;uniform lowp float u_opacity;uniform vec2 u_fill_translate;in vec2 a_pos;in vec4 a_normal_ed;\n#ifdef TERRAIN3D\nin vec2 a_centroid;\n#endif\nout vec4 v_color;\n#pragma mapbox: define highp float base\n#pragma mapbox: define highp float height\n#pragma mapbox: define highp vec4 color\nvoid main() {\n#pragma mapbox: initialize highp float base\n#pragma mapbox: initialize highp float height\n#pragma mapbox: initialize highp vec4 color\nvec3 normal=a_normal_ed.xyz;\n#ifdef TERRAIN3D\nfloat height_terrain3d_offset=get_elevation(a_centroid);float base_terrain3d_offset=height_terrain3d_offset-(base > 0.0 ? 0.0 : 10.0);\n#else\nfloat height_terrain3d_offset=0.0;float base_terrain3d_offset=0.0;\n#endif\nbase=max(0.0,base)+base_terrain3d_offset;height=max(0.0,height)+height_terrain3d_offset;float t=mod(normal.x,2.0);float elevation=t > 0.0 ? height : base;vec2 posInTile=a_pos+u_fill_translate;\n#ifdef GLOBE\nvec3 spherePos=projectToSphere(posInTile,a_pos);gl_Position=interpolateProjectionFor3D(posInTile,spherePos,elevation);\n#else\ngl_Position=u_projection_matrix*vec4(posInTile,elevation,1.0);\n#endif\nfloat colorvalue=color.r*0.2126+color.g*0.7152+color.b*0.0722;v_color=vec4(0.0,0.0,0.0,1.0);vec4 ambientlight=vec4(0.03,0.03,0.03,1.0);color+=ambientlight;vec3 normalForLighting=normal/16384.0;float directional=clamp(dot(normalForLighting,u_lightpos),0.0,1.0);\n#ifdef GLOBE\nmat3 rotMatrix=globeGetRotationMatrix(spherePos);normalForLighting=rotMatrix*normalForLighting;directional=mix(directional,clamp(dot(normalForLighting,u_lightpos_globe),0.0,1.0),u_projection_transition);\n#endif\ndirectional=mix((1.0-u_lightintensity),max((1.0-colorvalue+u_lightintensity),1.0),directional);if (normal.y !=0.0) {directional*=((1.0-u_vertical_gradient)+(u_vertical_gradient*clamp((t+base)*pow(height/150.0,0.5),mix(0.7,0.98,1.0-u_lightintensity),1.0)));}v_color.r+=clamp(color.r*directional*u_lightcolor.r,mix(0.0,0.3,1.0-u_lightcolor.r),1.0);v_color.g+=clamp(color.g*directional*u_lightcolor.g,mix(0.0,0.3,1.0-u_lightcolor.g),1.0);v_color.b+=clamp(color.b*directional*u_lightcolor.b,mix(0.0,0.3,1.0-u_lightcolor.b),1.0);v_color*=u_opacity;}"),fillExtrusionPattern:St("uniform vec2 u_texsize;uniform float u_fade;uniform sampler2D u_image;in vec2 v_pos_a;in vec2 v_pos_b;in vec4 v_lighting;\n#pragma mapbox: define lowp float base\n#pragma mapbox: define lowp float height\n#pragma mapbox: define lowp vec4 pattern_from\n#pragma mapbox: define lowp vec4 pattern_to\n#pragma mapbox: define lowp float pixel_ratio_from\n#pragma mapbox: define lowp float pixel_ratio_to\nvoid main() {\n#pragma mapbox: initialize lowp float base\n#pragma mapbox: initialize lowp float height\n#pragma mapbox: initialize mediump vec4 pattern_from\n#pragma mapbox: initialize mediump vec4 pattern_to\n#pragma mapbox: initialize lowp float pixel_ratio_from\n#pragma mapbox: initialize lowp float pixel_ratio_to\nvec2 pattern_tl_a=pattern_from.xy;vec2 pattern_br_a=pattern_from.zw;vec2 pattern_tl_b=pattern_to.xy;vec2 pattern_br_b=pattern_to.zw;vec2 imagecoord=mod(v_pos_a,1.0);vec2 pos=mix(pattern_tl_a/u_texsize,pattern_br_a/u_texsize,imagecoord);vec4 color1=texture(u_image,pos);vec2 imagecoord_b=mod(v_pos_b,1.0);vec2 pos2=mix(pattern_tl_b/u_texsize,pattern_br_b/u_texsize,imagecoord_b);vec4 color2=texture(u_image,pos2);vec4 mixedColor=mix(color1,color2,u_fade);fragColor=mixedColor*v_lighting;\n#ifdef OVERDRAW_INSPECTOR\nfragColor=vec4(1.0);\n#endif\n}","uniform vec2 u_pixel_coord_upper;uniform vec2 u_pixel_coord_lower;uniform float u_height_factor;uniform vec3 u_scale;uniform float u_vertical_gradient;uniform lowp float u_opacity;uniform vec2 u_fill_translate;uniform vec3 u_lightcolor;uniform lowp vec3 u_lightpos;uniform lowp vec3 u_lightpos_globe;uniform lowp float u_lightintensity;in vec2 a_pos;in vec4 a_normal_ed;\n#ifdef TERRAIN3D\nin vec2 a_centroid;\n#endif\n#ifdef GLOBE\nout vec3 v_sphere_pos;\n#endif\nout vec2 v_pos_a;out vec2 v_pos_b;out vec4 v_lighting;\n#pragma mapbox: define lowp float base\n#pragma mapbox: define lowp float height\n#pragma mapbox: define lowp vec4 pattern_from\n#pragma mapbox: define lowp vec4 pattern_to\n#pragma mapbox: define lowp float pixel_ratio_from\n#pragma mapbox: define lowp float pixel_ratio_to\nvoid main() {\n#pragma mapbox: initialize lowp float base\n#pragma mapbox: initialize lowp float height\n#pragma mapbox: initialize mediump vec4 pattern_from\n#pragma mapbox: initialize mediump vec4 pattern_to\n#pragma mapbox: initialize lowp float pixel_ratio_from\n#pragma mapbox: initialize lowp float pixel_ratio_to\nvec2 pattern_tl_a=pattern_from.xy;vec2 pattern_br_a=pattern_from.zw;vec2 pattern_tl_b=pattern_to.xy;vec2 pattern_br_b=pattern_to.zw;float tileRatio=u_scale.x;float fromScale=u_scale.y;float toScale=u_scale.z;vec3 normal=a_normal_ed.xyz;float edgedistance=a_normal_ed.w;vec2 display_size_a=(pattern_br_a-pattern_tl_a)/pixel_ratio_from;vec2 display_size_b=(pattern_br_b-pattern_tl_b)/pixel_ratio_to;\n#ifdef TERRAIN3D\nfloat height_terrain3d_offset=get_elevation(a_centroid);float base_terrain3d_offset=height_terrain3d_offset-(base > 0.0 ? 0.0 : 10.0);\n#else\nfloat height_terrain3d_offset=0.0;float base_terrain3d_offset=0.0;\n#endif\nbase=max(0.0,base)+base_terrain3d_offset;height=max(0.0,height)+height_terrain3d_offset;float t=mod(normal.x,2.0);float elevation=t > 0.0 ? height : base;vec2 posInTile=a_pos+u_fill_translate;\n#ifdef GLOBE\nvec3 spherePos=projectToSphere(posInTile,a_pos);vec3 elevatedPos=spherePos*(1.0+elevation/GLOBE_RADIUS);v_sphere_pos=elevatedPos;gl_Position=interpolateProjectionFor3D(posInTile,spherePos,elevation);\n#else\ngl_Position=u_projection_matrix*vec4(posInTile,elevation,1.0);\n#endif\nvec2 pos=normal.x==1.0 && normal.y==0.0 && normal.z==16384.0\n? a_pos\n: vec2(edgedistance,elevation*u_height_factor);v_pos_a=get_pattern_pos(u_pixel_coord_upper,u_pixel_coord_lower,fromScale*display_size_a,tileRatio,pos);v_pos_b=get_pattern_pos(u_pixel_coord_upper,u_pixel_coord_lower,toScale*display_size_b,tileRatio,pos);v_lighting=vec4(0.0,0.0,0.0,1.0);float directional=clamp(dot(normal/16383.0,u_lightpos),0.0,1.0);directional=mix((1.0-u_lightintensity),max((0.5+u_lightintensity),1.0),directional);if (normal.y !=0.0) {directional*=((1.0-u_vertical_gradient)+(u_vertical_gradient*clamp((t+base)*pow(height/150.0,0.5),mix(0.7,0.98,1.0-u_lightintensity),1.0)));}v_lighting.rgb+=clamp(directional*u_lightcolor,mix(vec3(0.0),vec3(0.3),1.0-u_lightcolor),vec3(1.0));v_lighting*=u_opacity;}"),hillshadePrepare:St("#ifdef GL_ES\nprecision highp float;\n#endif\nuniform sampler2D u_image;in vec2 v_pos;uniform vec2 u_dimension;uniform float u_zoom;uniform vec4 u_unpack;float getElevation(vec2 coord,float bias) {vec4 data=texture(u_image,coord)*255.0;data.a=-1.0;return dot(data,u_unpack);}void main() {vec2 epsilon=1.0/u_dimension;float tileSize=u_dimension.x-2.0;float a=getElevation(v_pos+vec2(-epsilon.x,-epsilon.y),0.0);float b=getElevation(v_pos+vec2(0,-epsilon.y),0.0);float c=getElevation(v_pos+vec2(epsilon.x,-epsilon.y),0.0);float d=getElevation(v_pos+vec2(-epsilon.x,0),0.0);float e=getElevation(v_pos,0.0);float f=getElevation(v_pos+vec2(epsilon.x,0),0.0);float g=getElevation(v_pos+vec2(-epsilon.x,epsilon.y),0.0);float h=getElevation(v_pos+vec2(0,epsilon.y),0.0);float i=getElevation(v_pos+vec2(epsilon.x,epsilon.y),0.0);float exaggerationFactor=u_zoom < 2.0 ? 0.4 : u_zoom < 4.5 ? 0.35 : 0.3;float exaggeration=u_zoom < 15.0 ? (u_zoom-15.0)*exaggerationFactor : 0.0;vec2 deriv=vec2((c+f+f+i)-(a+d+d+g),(g+h+h+i)-(a+b+b+c))*tileSize/pow(2.0,exaggeration+(28.2562-u_zoom));fragColor=clamp(vec4(deriv.x/8.0+0.5,deriv.y/8.0+0.5,1.0,1.0),0.0,1.0);\n#ifdef OVERDRAW_INSPECTOR\nfragColor=vec4(1.0);\n#endif\n}","uniform mat4 u_matrix;uniform vec2 u_dimension;in vec2 a_pos;in vec2 a_texture_pos;out vec2 v_pos;void main() {gl_Position=u_matrix*vec4(a_pos,0,1);highp vec2 epsilon=1.0/u_dimension;float scale=(u_dimension.x-2.0)/u_dimension.x;v_pos=(a_texture_pos/8192.0)*scale+epsilon;}"),hillshade:St("uniform sampler2D u_image;in vec2 v_pos;uniform vec2 u_latrange;uniform float u_exaggeration;uniform vec4 u_accent;uniform int u_method;uniform float u_altitudes[NUM_ILLUMINATION_SOURCES];uniform float u_azimuths[NUM_ILLUMINATION_SOURCES];uniform vec4 u_shadows[NUM_ILLUMINATION_SOURCES];uniform vec4 u_highlights[NUM_ILLUMINATION_SOURCES];\n#define PI 3.141592653589793\n#define STANDARD 0\n#define COMBINED 1\n#define IGOR 2\n#define MULTIDIRECTIONAL 3\n#define BASIC 4\nfloat get_aspect(vec2 deriv){return deriv.x !=0.0 ? atan(deriv.y,-deriv.x) : PI/2.0*(deriv.y > 0.0 ? 1.0 :-1.0);}void igor_hillshade(vec2 deriv){deriv=deriv*u_exaggeration*2.0;float aspect=get_aspect(deriv);float azimuth=u_azimuths[0]+PI;float slope_stength=atan(length(deriv))*2.0/PI;float aspect_strength=1.0-abs(mod((aspect+azimuth)/PI+0.5,2.0)-1.0);float shadow_strength=slope_stength*aspect_strength;float highlight_strength=slope_stength*(1.0-aspect_strength);fragColor=u_shadows[0]*shadow_strength+u_highlights[0]*highlight_strength;}void standard_hillshade(vec2 deriv){float azimuth=u_azimuths[0]+PI;float slope=atan(0.625*length(deriv));float aspect=get_aspect(deriv);float intensity=u_exaggeration;float base=1.875-intensity*1.75;float maxValue=0.5*PI;float scaledSlope=intensity !=0.5 ? ((pow(base,slope)-1.0)/(pow(base,maxValue)-1.0))*maxValue : slope;float accent=cos(scaledSlope);vec4 accent_color=(1.0-accent)*u_accent*clamp(intensity*2.0,0.0,1.0);float shade=abs(mod((aspect+azimuth)/PI+0.5,2.0)-1.0);vec4 shade_color=mix(u_shadows[0],u_highlights[0],shade)*sin(scaledSlope)*clamp(intensity*2.0,0.0,1.0);fragColor=accent_color*(1.0-shade_color.a)+shade_color;}void basic_hillshade(vec2 deriv){deriv=deriv*u_exaggeration*2.0;float azimuth=u_azimuths[0]+PI;float cos_az=cos(azimuth);float sin_az=sin(azimuth);float cos_alt=cos(u_altitudes[0]);float sin_alt=sin(u_altitudes[0]);float cang=(sin_alt-(deriv.y*cos_az*cos_alt-deriv.x*sin_az*cos_alt))/sqrt(1.0+dot(deriv,deriv));float shade=clamp(cang,0.0,1.0);if(shade > 0.5){fragColor=u_highlights[0]*(2.0*shade-1.0);}else\n{fragColor=u_shadows[0]*(1.0-2.0*shade);}}void multidirectional_hillshade(vec2 deriv){deriv=deriv*u_exaggeration*2.0;fragColor=vec4(0,0,0,0);for(int i=0; i < NUM_ILLUMINATION_SOURCES; i++){float cos_alt=cos(u_altitudes[i]);float sin_alt=sin(u_altitudes[i]);float cos_az=-cos(u_azimuths[i]);float sin_az=-sin(u_azimuths[i]);float cang=(sin_alt-(deriv.y*cos_az*cos_alt-deriv.x*sin_az*cos_alt))/sqrt(1.0+dot(deriv,deriv));float shade=clamp(cang,0.0,1.0);if(shade > 0.5){fragColor+=u_highlights[i]*(2.0*shade-1.0)/float(NUM_ILLUMINATION_SOURCES);}else\n{fragColor+=u_shadows[i]*(1.0-2.0*shade)/float(NUM_ILLUMINATION_SOURCES);}}}void combined_hillshade(vec2 deriv){deriv=deriv*u_exaggeration*2.0;float azimuth=u_azimuths[0]+PI;float cos_az=cos(azimuth);float sin_az=sin(azimuth);float cos_alt=cos(u_altitudes[0]);float sin_alt=sin(u_altitudes[0]);float cang=acos((sin_alt-(deriv.y*cos_az*cos_alt-deriv.x*sin_az*cos_alt))/sqrt(1.0+dot(deriv,deriv)));cang=clamp(cang,0.0,PI/2.0);float shade=cang*atan(length(deriv))*4.0/PI/PI;float highlight=(PI/2.0-cang)*atan(length(deriv))*4.0/PI/PI;fragColor=u_shadows[0]*shade+u_highlights[0]*highlight;}void main() {vec4 pixel=texture(u_image,v_pos);float scaleFactor=cos(radians((u_latrange[0]-u_latrange[1])*(1.0-v_pos.y)+u_latrange[1]));vec2 deriv=((pixel.rg*8.0)-4.0)/scaleFactor;if (u_method==BASIC) {basic_hillshade(deriv);} else if (u_method==COMBINED) {combined_hillshade(deriv);} else if (u_method==IGOR) {igor_hillshade(deriv);} else if (u_method==MULTIDIRECTIONAL) {multidirectional_hillshade(deriv);} else if (u_method==STANDARD) {standard_hillshade(deriv);} else {standard_hillshade(deriv);}\n#ifdef OVERDRAW_INSPECTOR\nfragColor=vec4(1.0);\n#endif\n}","uniform mat4 u_matrix;in vec2 a_pos;out vec2 v_pos;void main() {gl_Position=projectTile(a_pos,a_pos);v_pos=a_pos/8192.0;if (a_pos.y <-32767.5) {v_pos.y=0.0;}if (a_pos.y > 32766.5) {v_pos.y=1.0;}}"),line:St("uniform lowp float u_device_pixel_ratio;in vec2 v_width2;in vec2 v_normal;in float v_gamma_scale;\n#ifdef GLOBE\nin float v_depth;\n#endif\n#pragma mapbox: define highp vec4 color\n#pragma mapbox: define lowp float blur\n#pragma mapbox: define lowp float opacity\nvoid main() {\n#pragma mapbox: initialize highp vec4 color\n#pragma mapbox: initialize lowp float blur\n#pragma mapbox: initialize lowp float opacity\nfloat dist=length(v_normal)*v_width2.s;float blur2=(blur+1.0/u_device_pixel_ratio)*v_gamma_scale;float alpha=clamp(min(dist-(v_width2.t-blur2),v_width2.s-dist)/blur2,0.0,1.0);fragColor=color*(alpha*opacity);\n#ifdef GLOBE\nif (v_depth > 1.0) {discard;}\n#endif\n#ifdef OVERDRAW_INSPECTOR\nfragColor=vec4(1.0);\n#endif\n}","\n#define scale 0.015873016\nin vec2 a_pos_normal;in vec4 a_data;uniform vec2 u_translation;uniform mediump float u_ratio;uniform vec2 u_units_to_pixels;uniform lowp float u_device_pixel_ratio;out vec2 v_normal;out vec2 v_width2;out float v_gamma_scale;out highp float v_linesofar;\n#ifdef GLOBE\nout float v_depth;\n#endif\n#pragma mapbox: define highp vec4 color\n#pragma mapbox: define lowp float blur\n#pragma mapbox: define lowp float opacity\n#pragma mapbox: define mediump float gapwidth\n#pragma mapbox: define lowp float offset\n#pragma mapbox: define mediump float width\nvoid main() {\n#pragma mapbox: initialize highp vec4 color\n#pragma mapbox: initialize lowp float blur\n#pragma mapbox: initialize lowp float opacity\n#pragma mapbox: initialize mediump float gapwidth\n#pragma mapbox: initialize lowp float offset\n#pragma mapbox: initialize mediump float width\nfloat ANTIALIASING=1.0/u_device_pixel_ratio/2.0;vec2 a_extrude=a_data.xy-128.0;float a_direction=mod(a_data.z,4.0)-1.0;v_linesofar=(floor(a_data.z/4.0)+a_data.w*64.0)*2.0;vec2 pos=floor(a_pos_normal*0.5);mediump vec2 normal=a_pos_normal-2.0*pos;normal.y=normal.y*2.0-1.0;v_normal=normal;gapwidth=gapwidth/2.0;float halfwidth=width/2.0;offset=-1.0*offset;float inset=gapwidth+(gapwidth > 0.0 ? ANTIALIASING : 0.0);float outset=gapwidth+halfwidth*(gapwidth > 0.0 ? 2.0 : 1.0)+(halfwidth==0.0 ? 0.0 : ANTIALIASING);mediump vec2 dist=outset*a_extrude*scale;mediump float u=0.5*a_direction;mediump float t=1.0-abs(u);mediump vec2 offset2=offset*a_extrude*scale*normal.y*mat2(t,-u,u,t);float adjustedThickness=projectLineThickness(pos.y);vec4 projected_no_extrude=projectTile(pos+offset2/u_ratio*adjustedThickness+u_translation);vec4 projected_with_extrude=projectTile(pos+offset2/u_ratio*adjustedThickness+u_translation+dist/u_ratio*adjustedThickness);gl_Position=projected_with_extrude;\n#ifdef GLOBE\nv_depth=gl_Position.z/gl_Position.w;\n#endif\n#ifdef TERRAIN3D\nv_gamma_scale=1.0;\n#else\nfloat extrude_length_without_perspective=length(dist);float extrude_length_with_perspective=length((projected_with_extrude.xy-projected_no_extrude.xy)/projected_with_extrude.w*u_units_to_pixels);v_gamma_scale=extrude_length_without_perspective/extrude_length_with_perspective;\n#endif\nv_width2=vec2(outset,inset);}"),lineGradient:St("uniform lowp float u_device_pixel_ratio;uniform sampler2D u_image;in vec2 v_width2;in vec2 v_normal;in float v_gamma_scale;in highp vec2 v_uv;\n#ifdef GLOBE\nin float v_depth;\n#endif\n#pragma mapbox: define lowp float blur\n#pragma mapbox: define lowp float opacity\nvoid main() {\n#pragma mapbox: initialize lowp float blur\n#pragma mapbox: initialize lowp float opacity\nfloat dist=length(v_normal)*v_width2.s;float blur2=(blur+1.0/u_device_pixel_ratio)*v_gamma_scale;float alpha=clamp(min(dist-(v_width2.t-blur2),v_width2.s-dist)/blur2,0.0,1.0);vec4 color=texture(u_image,v_uv);fragColor=color*(alpha*opacity);\n#ifdef GLOBE\nif (v_depth > 1.0) {discard;}\n#endif\n#ifdef OVERDRAW_INSPECTOR\nfragColor=vec4(1.0);\n#endif\n}","\n#define scale 0.015873016\nin vec2 a_pos_normal;in vec4 a_data;in float a_uv_x;in float a_split_index;uniform vec2 u_translation;uniform mediump float u_ratio;uniform lowp float u_device_pixel_ratio;uniform vec2 u_units_to_pixels;uniform float u_image_height;out vec2 v_normal;out vec2 v_width2;out float v_gamma_scale;out highp vec2 v_uv;\n#ifdef GLOBE\nout float v_depth;\n#endif\n#pragma mapbox: define lowp float blur\n#pragma mapbox: define lowp float opacity\n#pragma mapbox: define mediump float gapwidth\n#pragma mapbox: define lowp float offset\n#pragma mapbox: define mediump float width\nvoid main() {\n#pragma mapbox: initialize lowp float blur\n#pragma mapbox: initialize lowp float opacity\n#pragma mapbox: initialize mediump float gapwidth\n#pragma mapbox: initialize lowp float offset\n#pragma mapbox: initialize mediump float width\nfloat ANTIALIASING=1.0/u_device_pixel_ratio/2.0;vec2 a_extrude=a_data.xy-128.0;float a_direction=mod(a_data.z,4.0)-1.0;highp float texel_height=1.0/u_image_height;highp float half_texel_height=0.5*texel_height;v_uv=vec2(a_uv_x,a_split_index*texel_height-half_texel_height);vec2 pos=floor(a_pos_normal*0.5);mediump vec2 normal=a_pos_normal-2.0*pos;normal.y=normal.y*2.0-1.0;v_normal=normal;gapwidth=gapwidth/2.0;float halfwidth=width/2.0;offset=-1.0*offset;float inset=gapwidth+(gapwidth > 0.0 ? ANTIALIASING : 0.0);float outset=gapwidth+halfwidth*(gapwidth > 0.0 ? 2.0 : 1.0)+(halfwidth==0.0 ? 0.0 : ANTIALIASING);mediump vec2 dist=outset*a_extrude*scale;mediump float u=0.5*a_direction;mediump float t=1.0-abs(u);mediump vec2 offset2=offset*a_extrude*scale*normal.y*mat2(t,-u,u,t);float adjustedThickness=projectLineThickness(pos.y);vec4 projected_no_extrude=projectTile(pos+offset2/u_ratio*adjustedThickness+u_translation);vec4 projected_with_extrude=projectTile(pos+offset2/u_ratio*adjustedThickness+u_translation+dist/u_ratio*adjustedThickness);gl_Position=projected_with_extrude;\n#ifdef GLOBE\nv_depth=gl_Position.z/gl_Position.w;\n#endif\n#ifdef TERRAIN3D\nv_gamma_scale=1.0;\n#else\nfloat extrude_length_without_perspective=length(dist);float extrude_length_with_perspective=length((projected_with_extrude.xy-projected_no_extrude.xy)/projected_with_extrude.w*u_units_to_pixels);v_gamma_scale=extrude_length_without_perspective/extrude_length_with_perspective;\n#endif\nv_width2=vec2(outset,inset);}"),linePattern:St("#ifdef GL_ES\nprecision highp float;\n#endif\nuniform lowp float u_device_pixel_ratio;uniform vec2 u_texsize;uniform float u_fade;uniform mediump vec3 u_scale;uniform sampler2D u_image;in vec2 v_normal;in vec2 v_width2;in float v_linesofar;in float v_gamma_scale;in float v_width;\n#ifdef GLOBE\nin float v_depth;\n#endif\n#pragma mapbox: define lowp vec4 pattern_from\n#pragma mapbox: define lowp vec4 pattern_to\n#pragma mapbox: define lowp float pixel_ratio_from\n#pragma mapbox: define lowp float pixel_ratio_to\n#pragma mapbox: define lowp float blur\n#pragma mapbox: define lowp float opacity\nvoid main() {\n#pragma mapbox: initialize mediump vec4 pattern_from\n#pragma mapbox: initialize mediump vec4 pattern_to\n#pragma mapbox: initialize lowp float pixel_ratio_from\n#pragma mapbox: initialize lowp float pixel_ratio_to\n#pragma mapbox: initialize lowp float blur\n#pragma mapbox: initialize lowp float opacity\nvec2 pattern_tl_a=pattern_from.xy;vec2 pattern_br_a=pattern_from.zw;vec2 pattern_tl_b=pattern_to.xy;vec2 pattern_br_b=pattern_to.zw;float tileZoomRatio=u_scale.x;float fromScale=u_scale.y;float toScale=u_scale.z;vec2 display_size_a=(pattern_br_a-pattern_tl_a)/pixel_ratio_from;vec2 display_size_b=(pattern_br_b-pattern_tl_b)/pixel_ratio_to;vec2 pattern_size_a=vec2(display_size_a.x*fromScale/tileZoomRatio,display_size_a.y);vec2 pattern_size_b=vec2(display_size_b.x*toScale/tileZoomRatio,display_size_b.y);float aspect_a=display_size_a.y/v_width;float aspect_b=display_size_b.y/v_width;float dist=length(v_normal)*v_width2.s;float blur2=(blur+1.0/u_device_pixel_ratio)*v_gamma_scale;float alpha=clamp(min(dist-(v_width2.t-blur2),v_width2.s-dist)/blur2,0.0,1.0);float x_a=mod(v_linesofar/pattern_size_a.x*aspect_a,1.0);float x_b=mod(v_linesofar/pattern_size_b.x*aspect_b,1.0);float y=0.5*v_normal.y+0.5;vec2 texel_size=1.0/u_texsize;vec2 pos_a=mix(pattern_tl_a*texel_size-texel_size,pattern_br_a*texel_size+texel_size,vec2(x_a,y));vec2 pos_b=mix(pattern_tl_b*texel_size-texel_size,pattern_br_b*texel_size+texel_size,vec2(x_b,y));vec4 color=mix(texture(u_image,pos_a),texture(u_image,pos_b),u_fade);fragColor=color*alpha*opacity;\n#ifdef GLOBE\nif (v_depth > 1.0) {discard;}\n#endif\n#ifdef OVERDRAW_INSPECTOR\nfragColor=vec4(1.0);\n#endif\n}","\n#define scale 0.015873016\n#define LINE_DISTANCE_SCALE 2.0\nin vec2 a_pos_normal;in vec4 a_data;uniform vec2 u_translation;uniform vec2 u_units_to_pixels;uniform mediump float u_ratio;uniform lowp float u_device_pixel_ratio;out vec2 v_normal;out vec2 v_width2;out float v_linesofar;out float v_gamma_scale;out float v_width;\n#ifdef GLOBE\nout float v_depth;\n#endif\n#pragma mapbox: define lowp float blur\n#pragma mapbox: define lowp float opacity\n#pragma mapbox: define lowp float offset\n#pragma mapbox: define mediump float gapwidth\n#pragma mapbox: define mediump float width\n#pragma mapbox: define lowp float floorwidth\n#pragma mapbox: define lowp vec4 pattern_from\n#pragma mapbox: define lowp vec4 pattern_to\n#pragma mapbox: define lowp float pixel_ratio_from\n#pragma mapbox: define lowp float pixel_ratio_to\nvoid main() {\n#pragma mapbox: initialize lowp float blur\n#pragma mapbox: initialize lowp float opacity\n#pragma mapbox: initialize lowp float offset\n#pragma mapbox: initialize mediump float gapwidth\n#pragma mapbox: initialize mediump float width\n#pragma mapbox: initialize lowp float floorwidth\n#pragma mapbox: initialize mediump vec4 pattern_from\n#pragma mapbox: initialize mediump vec4 pattern_to\n#pragma mapbox: initialize lowp float pixel_ratio_from\n#pragma mapbox: initialize lowp float pixel_ratio_to\nfloat ANTIALIASING=1.0/u_device_pixel_ratio/2.0;vec2 a_extrude=a_data.xy-128.0;float a_direction=mod(a_data.z,4.0)-1.0;float a_linesofar=(floor(a_data.z/4.0)+a_data.w*64.0)*LINE_DISTANCE_SCALE;vec2 pos=floor(a_pos_normal*0.5);mediump vec2 normal=a_pos_normal-2.0*pos;normal.y=normal.y*2.0-1.0;v_normal=normal;gapwidth=gapwidth/2.0;float halfwidth=width/2.0;offset=-1.0*offset;float inset=gapwidth+(gapwidth > 0.0 ? ANTIALIASING : 0.0);float outset=gapwidth+halfwidth*(gapwidth > 0.0 ? 2.0 : 1.0)+(halfwidth==0.0 ? 0.0 : ANTIALIASING);mediump vec2 dist=outset*a_extrude*scale;mediump float u=0.5*a_direction;mediump float t=1.0-abs(u);mediump vec2 offset2=offset*a_extrude*scale*normal.y*mat2(t,-u,u,t);float adjustedThickness=projectLineThickness(pos.y);vec4 projected_no_extrude=projectTile(pos+offset2/u_ratio*adjustedThickness+u_translation);vec4 projected_with_extrude=projectTile(pos+offset2/u_ratio*adjustedThickness+u_translation+dist/u_ratio*adjustedThickness);gl_Position=projected_with_extrude;\n#ifdef GLOBE\nv_depth=gl_Position.z/gl_Position.w;\n#endif\n#ifdef TERRAIN3D\nv_gamma_scale=1.0;\n#else\nfloat extrude_length_without_perspective=length(dist);float extrude_length_with_perspective=length((projected_with_extrude.xy-projected_no_extrude.xy)/projected_with_extrude.w*u_units_to_pixels);v_gamma_scale=extrude_length_without_perspective/extrude_length_with_perspective;\n#endif\nv_linesofar=a_linesofar;v_width2=vec2(outset,inset);v_width=floorwidth;}"),lineSDF:St("uniform lowp float u_device_pixel_ratio;uniform lowp float u_lineatlas_width;uniform sampler2D u_image;uniform float u_mix;in vec2 v_normal;in vec2 v_width2;in vec2 v_tex_a;in vec2 v_tex_b;in float v_gamma_scale;\n#ifdef GLOBE\nin float v_depth;\n#endif\n#pragma mapbox: define highp vec4 color\n#pragma mapbox: define lowp float blur\n#pragma mapbox: define lowp float opacity\n#pragma mapbox: define mediump float width\n#pragma mapbox: define lowp float floorwidth\n#pragma mapbox: define mediump vec4 dasharray_from\n#pragma mapbox: define mediump vec4 dasharray_to\nvoid main() {\n#pragma mapbox: initialize highp vec4 color\n#pragma mapbox: initialize lowp float blur\n#pragma mapbox: initialize lowp float opacity\n#pragma mapbox: initialize mediump float width\n#pragma mapbox: initialize lowp float floorwidth\n#pragma mapbox: initialize mediump vec4 dasharray_from\n#pragma mapbox: initialize mediump vec4 dasharray_to\nfloat dist=length(v_normal)*v_width2.s;float blur2=(blur+1.0/u_device_pixel_ratio)*v_gamma_scale;float alpha=clamp(min(dist-(v_width2.t-blur2),v_width2.s-dist)/blur2,0.0,1.0);float sdfdist_a=texture(u_image,v_tex_a).a;float sdfdist_b=texture(u_image,v_tex_b).a;float sdfdist=mix(sdfdist_a,sdfdist_b,u_mix);float sdfgamma=(u_lineatlas_width/256.0/u_device_pixel_ratio)/min(dasharray_from.w,dasharray_to.w);alpha*=smoothstep(0.5-sdfgamma/floorwidth,0.5+sdfgamma/floorwidth,sdfdist);fragColor=color*(alpha*opacity);\n#ifdef GLOBE\nif (v_depth > 1.0) {discard;}\n#endif\n#ifdef OVERDRAW_INSPECTOR\nfragColor=vec4(1.0);\n#endif\n}","\n#define scale 0.015873016\n#define LINE_DISTANCE_SCALE 2.0\nin vec2 a_pos_normal;in vec4 a_data;uniform vec2 u_translation;uniform mediump float u_ratio;uniform lowp float u_device_pixel_ratio;uniform vec2 u_units_to_pixels;uniform float u_tileratio;uniform float u_crossfade_from;uniform float u_crossfade_to;uniform float u_lineatlas_height;out vec2 v_normal;out vec2 v_width2;out vec2 v_tex_a;out vec2 v_tex_b;out float v_gamma_scale;\n#ifdef GLOBE\nout float v_depth;\n#endif\n#pragma mapbox: define highp vec4 color\n#pragma mapbox: define lowp float blur\n#pragma mapbox: define lowp float opacity\n#pragma mapbox: define mediump float gapwidth\n#pragma mapbox: define lowp float offset\n#pragma mapbox: define mediump float width\n#pragma mapbox: define lowp float floorwidth\n#pragma mapbox: define mediump vec4 dasharray_from\n#pragma mapbox: define mediump vec4 dasharray_to\nvoid main() {\n#pragma mapbox: initialize highp vec4 color\n#pragma mapbox: initialize lowp float blur\n#pragma mapbox: initialize lowp float opacity\n#pragma mapbox: initialize mediump float gapwidth\n#pragma mapbox: initialize lowp float offset\n#pragma mapbox: initialize mediump float width\n#pragma mapbox: initialize lowp float floorwidth\n#pragma mapbox: initialize mediump vec4 dasharray_from\n#pragma mapbox: initialize mediump vec4 dasharray_to\nfloat ANTIALIASING=1.0/u_device_pixel_ratio/2.0;vec2 a_extrude=a_data.xy-128.0;float a_direction=mod(a_data.z,4.0)-1.0;float a_linesofar=(floor(a_data.z/4.0)+a_data.w*64.0)*LINE_DISTANCE_SCALE;vec2 pos=floor(a_pos_normal*0.5);mediump vec2 normal=a_pos_normal-2.0*pos;normal.y=normal.y*2.0-1.0;v_normal=normal;gapwidth=gapwidth/2.0;float halfwidth=width/2.0;offset=-1.0*offset;float inset=gapwidth+(gapwidth > 0.0 ? ANTIALIASING : 0.0);float outset=gapwidth+halfwidth*(gapwidth > 0.0 ? 2.0 : 1.0)+(halfwidth==0.0 ? 0.0 : ANTIALIASING);mediump vec2 dist=outset*a_extrude*scale;mediump float u=0.5*a_direction;mediump float t=1.0-abs(u);mediump vec2 offset2=offset*a_extrude*scale*normal.y*mat2(t,-u,u,t);float adjustedThickness=projectLineThickness(pos.y);vec4 projected_no_extrude=projectTile(pos+offset2/u_ratio*adjustedThickness+u_translation);vec4 projected_with_extrude=projectTile(pos+offset2/u_ratio*adjustedThickness+u_translation+dist/u_ratio*adjustedThickness);gl_Position=projected_with_extrude;\n#ifdef GLOBE\nv_depth=gl_Position.z/gl_Position.w;\n#endif\n#ifdef TERRAIN3D\nv_gamma_scale=1.0;\n#else\nfloat extrude_length_without_perspective=length(dist);float extrude_length_with_perspective=length((projected_with_extrude.xy-projected_no_extrude.xy)/projected_with_extrude.w*u_units_to_pixels);v_gamma_scale=extrude_length_without_perspective/extrude_length_with_perspective;\n#endif\nfloat u_patternscale_a_x=u_tileratio/dasharray_from.w/u_crossfade_from;float u_patternscale_a_y=-dasharray_from.z/2.0/u_lineatlas_height;float u_patternscale_b_x=u_tileratio/dasharray_to.w/u_crossfade_to;float u_patternscale_b_y=-dasharray_to.z/2.0/u_lineatlas_height;v_tex_a=vec2(a_linesofar*u_patternscale_a_x/floorwidth,normal.y*u_patternscale_a_y+(float(dasharray_from.y)+0.5)/u_lineatlas_height);v_tex_b=vec2(a_linesofar*u_patternscale_b_x/floorwidth,normal.y*u_patternscale_b_y+(float(dasharray_to.y)+0.5)/u_lineatlas_height);v_width2=vec2(outset,inset);}"),lineGradientSDF:St("uniform lowp float u_device_pixel_ratio;uniform sampler2D u_image;uniform sampler2D u_image_dash;uniform float u_mix;uniform lowp float u_lineatlas_width;in vec2 v_normal;in vec2 v_width2;in vec2 v_tex_a;in vec2 v_tex_b;in float v_gamma_scale;in highp vec2 v_uv;\n#ifdef GLOBE\nin float v_depth;\n#endif\n#pragma mapbox: define lowp float blur\n#pragma mapbox: define lowp float opacity\n#pragma mapbox: define mediump float width\n#pragma mapbox: define lowp float floorwidth\n#pragma mapbox: define mediump vec4 dasharray_from\n#pragma mapbox: define mediump vec4 dasharray_to\nvoid main() {\n#pragma mapbox: initialize lowp float blur\n#pragma mapbox: initialize lowp float opacity\n#pragma mapbox: initialize mediump float width\n#pragma mapbox: initialize lowp float floorwidth\n#pragma mapbox: initialize mediump vec4 dasharray_from\n#pragma mapbox: initialize mediump vec4 dasharray_to\nfloat dist=length(v_normal)*v_width2.s;float blur2=(blur+1.0/u_device_pixel_ratio)*v_gamma_scale;float alpha=clamp(min(dist-(v_width2.t-blur2),v_width2.s-dist)/blur2,0.0,1.0);vec4 color=texture(u_image,v_uv);float sdfdist_a=texture(u_image_dash,v_tex_a).a;float sdfdist_b=texture(u_image_dash,v_tex_b).a;float sdfdist=mix(sdfdist_a,sdfdist_b,u_mix);float sdfgamma=(u_lineatlas_width/256.0)/min(dasharray_from.w,dasharray_to.w);float dash_alpha=smoothstep(0.5-sdfgamma/floorwidth,0.5+sdfgamma/floorwidth,sdfdist);fragColor=color*(alpha*dash_alpha*opacity);\n#ifdef GLOBE\nif (v_depth > 1.0) {discard;}\n#endif\n#ifdef OVERDRAW_INSPECTOR\nfragColor=vec4(1.0);\n#endif\n}","\n#define scale 0.015873016\n#define LINE_DISTANCE_SCALE 2.0\nin vec2 a_pos_normal;in vec4 a_data;in float a_uv_x;in float a_split_index;uniform vec2 u_translation;uniform mediump float u_ratio;uniform lowp float u_device_pixel_ratio;uniform vec2 u_units_to_pixels;uniform float u_image_height;uniform float u_tileratio;uniform float u_crossfade_from;uniform float u_crossfade_to;uniform float u_lineatlas_height;out vec2 v_normal;out vec2 v_width2;out float v_gamma_scale;out highp vec2 v_uv;out vec2 v_tex_a;out vec2 v_tex_b;\n#ifdef GLOBE\nout float v_depth;\n#endif\n#pragma mapbox: define lowp float blur\n#pragma mapbox: define lowp float opacity\n#pragma mapbox: define mediump float gapwidth\n#pragma mapbox: define lowp float offset\n#pragma mapbox: define mediump float width\n#pragma mapbox: define lowp float floorwidth\n#pragma mapbox: define mediump vec4 dasharray_from\n#pragma mapbox: define mediump vec4 dasharray_to\nvoid main() {\n#pragma mapbox: initialize lowp float blur\n#pragma mapbox: initialize lowp float opacity\n#pragma mapbox: initialize mediump float gapwidth\n#pragma mapbox: initialize lowp float offset\n#pragma mapbox: initialize mediump float width\n#pragma mapbox: initialize lowp float floorwidth\n#pragma mapbox: initialize mediump vec4 dasharray_from\n#pragma mapbox: initialize mediump vec4 dasharray_to\nfloat ANTIALIASING=1.0/u_device_pixel_ratio/2.0;vec2 a_extrude=a_data.xy-128.0;float a_direction=mod(a_data.z,4.0)-1.0;float a_linesofar=(floor(a_data.z/4.0)+a_data.w*64.0)*LINE_DISTANCE_SCALE;float texel_height=1.0/u_image_height;float half_texel_height=0.5*texel_height;v_uv=vec2(a_uv_x,a_split_index*texel_height-half_texel_height);vec2 pos=floor(a_pos_normal*0.5);mediump vec2 normal=a_pos_normal-2.0*pos;normal.y=normal.y*2.0-1.0;v_normal=normal;gapwidth=gapwidth/2.0;float halfwidth=width/2.0;offset=-1.0*offset;float inset=gapwidth+(gapwidth > 0.0 ? ANTIALIASING : 0.0);float outset=gapwidth+halfwidth*(gapwidth > 0.0 ? 2.0 : 1.0)+(halfwidth==0.0 ? 0.0 : ANTIALIASING);mediump vec2 dist=outset*a_extrude*scale;mediump float u=0.5*a_direction;mediump float t=1.0-abs(u);mediump vec2 offset2=offset*a_extrude*scale*normal.y*mat2(t,-u,u,t);float adjustedThickness=projectLineThickness(pos.y);vec4 projected_no_extrude=projectTile(pos+offset2/u_ratio*adjustedThickness+u_translation);vec4 projected_with_extrude=projectTile(pos+offset2/u_ratio*adjustedThickness+u_translation+dist/u_ratio*adjustedThickness);gl_Position=projected_with_extrude;\n#ifdef GLOBE\nv_depth=gl_Position.z/gl_Position.w;\n#endif\n#ifdef TERRAIN3D\nv_gamma_scale=1.0;\n#else\nfloat extrude_length_without_perspective=length(dist);float extrude_length_with_perspective=length((projected_with_extrude.xy-projected_no_extrude.xy)/projected_with_extrude.w*u_units_to_pixels);v_gamma_scale=extrude_length_without_perspective/extrude_length_with_perspective;\n#endif\nfloat u_patternscale_a_x=u_tileratio/dasharray_from.w/u_crossfade_from;float u_patternscale_a_y=-dasharray_from.z/2.0/u_lineatlas_height;float u_patternscale_b_x=u_tileratio/dasharray_to.w/u_crossfade_to;float u_patternscale_b_y=-dasharray_to.z/2.0/u_lineatlas_height;v_tex_a=vec2(a_linesofar*u_patternscale_a_x/floorwidth,normal.y*u_patternscale_a_y+(float(dasharray_from.y)+0.5)/u_lineatlas_height);v_tex_b=vec2(a_linesofar*u_patternscale_b_x/floorwidth,normal.y*u_patternscale_b_y+(float(dasharray_to.y)+0.5)/u_lineatlas_height);v_width2=vec2(outset,inset);}"),raster:St("uniform float u_fade_t;uniform float u_opacity;uniform sampler2D u_image0;uniform sampler2D u_image1;in vec2 v_pos0;in vec2 v_pos1;uniform float u_brightness_low;uniform float u_brightness_high;uniform float u_saturation_factor;uniform float u_contrast_factor;uniform vec3 u_spin_weights;void main() {vec4 color0=texture(u_image0,v_pos0);vec4 color1=texture(u_image1,v_pos1);if (color0.a > 0.0) {color0.rgb=color0.rgb/color0.a;}if (color1.a > 0.0) {color1.rgb=color1.rgb/color1.a;}vec4 color=mix(color0,color1,u_fade_t);color.a*=u_opacity;vec3 rgb=color.rgb;rgb=vec3(dot(rgb,u_spin_weights.xyz),dot(rgb,u_spin_weights.zxy),dot(rgb,u_spin_weights.yzx));float average=(color.r+color.g+color.b)/3.0;rgb+=(average-rgb)*u_saturation_factor;rgb=(rgb-0.5)*u_contrast_factor+0.5;vec3 u_high_vec=vec3(u_brightness_low,u_brightness_low,u_brightness_low);vec3 u_low_vec=vec3(u_brightness_high,u_brightness_high,u_brightness_high);fragColor=vec4(mix(u_high_vec,u_low_vec,rgb)*color.a,color.a);\n#ifdef OVERDRAW_INSPECTOR\nfragColor=vec4(1.0);\n#endif\n}","uniform vec2 u_tl_parent;uniform float u_scale_parent;uniform float u_buffer_scale;uniform vec4 u_coords_top;uniform vec4 u_coords_bottom;in vec2 a_pos;out vec2 v_pos0;out vec2 v_pos1;void main() {vec2 fractionalPos=a_pos/8192.0;vec2 position=mix(mix(u_coords_top.xy,u_coords_top.zw,fractionalPos.x),mix(u_coords_bottom.xy,u_coords_bottom.zw,fractionalPos.x),fractionalPos.y);gl_Position=projectTile(position,position);v_pos0=((fractionalPos-0.5)/u_buffer_scale)+0.5;\n#ifdef GLOBE\nif (a_pos.y <-32767.5) {v_pos0.y=0.0;}if (a_pos.y > 32766.5) {v_pos0.y=1.0;}\n#endif\nv_pos1=(v_pos0*u_scale_parent)+u_tl_parent;}"),symbolIcon:St("uniform sampler2D u_texture;in vec2 v_tex;in float v_fade_opacity;\n#pragma mapbox: define lowp float opacity\nvoid main() {\n#pragma mapbox: initialize lowp float opacity\nlowp float alpha=opacity*v_fade_opacity;fragColor=texture(u_texture,v_tex)*alpha;\n#ifdef OVERDRAW_INSPECTOR\nfragColor=vec4(1.0);\n#endif\n}","in vec4 a_pos_offset;in vec4 a_data;in vec4 a_pixeloffset;in vec3 a_projected_pos;in float a_fade_opacity;uniform bool u_is_size_zoom_constant;uniform bool u_is_size_feature_constant;uniform highp float u_size_t;uniform highp float u_size;uniform highp float u_camera_to_center_distance;uniform highp float u_pitch;uniform bool u_rotate_symbol;uniform highp float u_aspect_ratio;uniform float u_fade_change;uniform mat4 u_label_plane_matrix;uniform mat4 u_coord_matrix;uniform bool u_is_text;uniform bool u_pitch_with_map;uniform vec2 u_texsize;uniform bool u_is_along_line;uniform bool u_is_variable_anchor;uniform vec2 u_translation;uniform float u_pitched_scale;out vec2 v_tex;out float v_fade_opacity;\n#pragma mapbox: define lowp float opacity\nvoid main() {\n#pragma mapbox: initialize lowp float opacity\nvec2 a_pos=a_pos_offset.xy;vec2 a_offset=a_pos_offset.zw;vec2 a_tex=a_data.xy;vec2 a_size=a_data.zw;float a_size_min=floor(a_size[0]*0.5);vec2 a_pxoffset=a_pixeloffset.xy;vec2 a_minFontScale=a_pixeloffset.zw/256.0;float ele=get_elevation(a_pos);highp float segment_angle=-a_projected_pos[2];float size;if (!u_is_size_zoom_constant && !u_is_size_feature_constant) {size=mix(a_size_min,a_size[1],u_size_t)/128.0;} else if (u_is_size_zoom_constant && !u_is_size_feature_constant) {size=a_size_min/128.0;} else {size=u_size;}vec2 translated_a_pos=a_pos+u_translation;vec4 projectedPoint=projectTileWithElevation(translated_a_pos,ele);highp float camera_to_anchor_distance=projectedPoint.w;highp float distance_ratio=u_pitch_with_map ?\ncamera_to_anchor_distance/u_camera_to_center_distance :\nu_camera_to_center_distance/camera_to_anchor_distance;highp float perspective_ratio=clamp(0.5+0.5*distance_ratio,0.0,4.0);size*=perspective_ratio;float fontScale=u_is_text ? size/24.0 : size;highp float symbol_rotation=0.0;if (u_rotate_symbol) {vec4 offsetProjectedPoint=projectTileWithElevation(translated_a_pos+vec2(1,0),ele);vec2 a=projectedPoint.xy/projectedPoint.w;vec2 b=offsetProjectedPoint.xy/offsetProjectedPoint.w;symbol_rotation=atan((b.y-a.y)/u_aspect_ratio,b.x-a.x);}highp float angle_sin=sin(segment_angle+symbol_rotation);highp float angle_cos=cos(segment_angle+symbol_rotation);mat2 rotation_matrix=mat2(angle_cos,-1.0*angle_sin,angle_sin,angle_cos);vec4 projected_pos;if (u_is_along_line || u_is_variable_anchor) {projected_pos=vec4(a_projected_pos.xy,ele,1.0);} else if (u_pitch_with_map) {projected_pos=u_label_plane_matrix*vec4(a_projected_pos.xy+u_translation,ele,1.0);} else {projected_pos=u_label_plane_matrix*projectTileWithElevation(a_projected_pos.xy+u_translation,ele);}float z=float(u_pitch_with_map)*projected_pos.z/projected_pos.w;float projectionScaling=1.0;\n#ifdef GLOBE\nif(u_pitch_with_map) {float anchor_pos_tile_y=(u_coord_matrix*vec4(projected_pos.xy/projected_pos.w,z,1.0)).y;projectionScaling=mix(projectionScaling,1.0/circumferenceRatioAtTileY(anchor_pos_tile_y)*u_pitched_scale,u_projection_transition);}\n#endif\nvec4 finalPos=u_coord_matrix*vec4(projected_pos.xy/projected_pos.w+rotation_matrix*(a_offset/32.0*max(a_minFontScale,fontScale)+a_pxoffset/16.0)*projectionScaling,z,1.0);if(u_pitch_with_map) {finalPos=projectTileWithElevation(finalPos.xy,finalPos.z);}gl_Position=finalPos;v_tex=a_tex/u_texsize;vec2 fade_opacity=unpack_opacity(a_fade_opacity);float fade_change=fade_opacity[1] > 0.5 ? u_fade_change :-u_fade_change;float visibility=calculate_visibility(projectedPoint);v_fade_opacity=max(0.0,min(visibility,fade_opacity[0]+fade_change));}"),symbolSDF:St("#define SDF_PX 8.0\nuniform bool u_is_halo;uniform sampler2D u_texture;uniform highp float u_gamma_scale;uniform lowp float u_device_pixel_ratio;uniform bool u_is_text;in vec2 v_data0;in vec3 v_data1;\n#pragma mapbox: define highp vec4 fill_color\n#pragma mapbox: define highp vec4 halo_color\n#pragma mapbox: define lowp float opacity\n#pragma mapbox: define lowp float halo_width\n#pragma mapbox: define lowp float halo_blur\nvoid main() {\n#pragma mapbox: initialize highp vec4 fill_color\n#pragma mapbox: initialize highp vec4 halo_color\n#pragma mapbox: initialize lowp float opacity\n#pragma mapbox: initialize lowp float halo_width\n#pragma mapbox: initialize lowp float halo_blur\nfloat EDGE_GAMMA=0.105/u_device_pixel_ratio;vec2 tex=v_data0.xy;float gamma_scale=v_data1.x;float size=v_data1.y;float fade_opacity=v_data1[2];float fontScale=u_is_text ? size/24.0 : size;lowp vec4 color=fill_color;highp float gamma=EDGE_GAMMA/(fontScale*u_gamma_scale);lowp float inner_edge=(256.0-64.0)/256.0;if (u_is_halo) {color=halo_color;gamma=(halo_blur*1.19/SDF_PX+EDGE_GAMMA)/(fontScale*u_gamma_scale);inner_edge=inner_edge+gamma*gamma_scale;}lowp float dist=texture(u_texture,tex).a;highp float gamma_scaled=gamma*gamma_scale;highp float alpha=smoothstep(inner_edge-gamma_scaled,inner_edge+gamma_scaled,dist);if (u_is_halo) {lowp float halo_edge=(6.0-halo_width/fontScale)/SDF_PX;alpha=min(smoothstep(halo_edge-gamma_scaled,halo_edge+gamma_scaled,dist),1.0-alpha);}fragColor=color*(alpha*opacity*fade_opacity);\n#ifdef OVERDRAW_INSPECTOR\nfragColor=vec4(1.0);\n#endif\n}","in vec4 a_pos_offset;in vec4 a_data;in vec4 a_pixeloffset;in vec3 a_projected_pos;in float a_fade_opacity;uniform bool u_is_size_zoom_constant;uniform bool u_is_size_feature_constant;uniform highp float u_size_t;uniform highp float u_size;uniform mat4 u_label_plane_matrix;uniform mat4 u_coord_matrix;uniform bool u_is_text;uniform bool u_pitch_with_map;uniform bool u_is_along_line;uniform bool u_is_variable_anchor;uniform highp float u_pitch;uniform bool u_rotate_symbol;uniform highp float u_aspect_ratio;uniform highp float u_camera_to_center_distance;uniform float u_fade_change;uniform vec2 u_texsize;uniform vec2 u_translation;uniform float u_pitched_scale;out vec2 v_data0;out vec3 v_data1;\n#pragma mapbox: define highp vec4 fill_color\n#pragma mapbox: define highp vec4 halo_color\n#pragma mapbox: define lowp float opacity\n#pragma mapbox: define lowp float halo_width\n#pragma mapbox: define lowp float halo_blur\nvoid main() {\n#pragma mapbox: initialize highp vec4 fill_color\n#pragma mapbox: initialize highp vec4 halo_color\n#pragma mapbox: initialize lowp float opacity\n#pragma mapbox: initialize lowp float halo_width\n#pragma mapbox: initialize lowp float halo_blur\nvec2 a_pos=a_pos_offset.xy;vec2 a_offset=a_pos_offset.zw;vec2 a_tex=a_data.xy;vec2 a_size=a_data.zw;float a_size_min=floor(a_size[0]*0.5);vec2 a_pxoffset=a_pixeloffset.xy;float ele=get_elevation(a_pos);highp float segment_angle=-a_projected_pos[2];float size;if (!u_is_size_zoom_constant && !u_is_size_feature_constant) {size=mix(a_size_min,a_size[1],u_size_t)/128.0;} else if (u_is_size_zoom_constant && !u_is_size_feature_constant) {size=a_size_min/128.0;} else {size=u_size;}vec2 translated_a_pos=a_pos+u_translation;vec4 projectedPoint=projectTileWithElevation(translated_a_pos,ele);highp float camera_to_anchor_distance=projectedPoint.w;highp float distance_ratio=u_pitch_with_map ?\ncamera_to_anchor_distance/u_camera_to_center_distance :\nu_camera_to_center_distance/camera_to_anchor_distance;highp float perspective_ratio=clamp(0.5+0.5*distance_ratio,0.0,4.0);size*=perspective_ratio;float fontScale=u_is_text ? size/24.0 : size;highp float symbol_rotation=0.0;if (u_rotate_symbol) {vec4 offsetProjectedPoint=projectTileWithElevation(translated_a_pos+vec2(1,0),ele);vec2 a=projectedPoint.xy/projectedPoint.w;vec2 b=offsetProjectedPoint.xy/offsetProjectedPoint.w;symbol_rotation=atan((b.y-a.y)/u_aspect_ratio,b.x-a.x);}highp float angle_sin=sin(segment_angle+symbol_rotation);highp float angle_cos=cos(segment_angle+symbol_rotation);mat2 rotation_matrix=mat2(angle_cos,-1.0*angle_sin,angle_sin,angle_cos);vec4 projected_pos;if (u_is_along_line || u_is_variable_anchor) {projected_pos=vec4(a_projected_pos.xy,ele,1.0);} else if (u_pitch_with_map) {projected_pos=u_label_plane_matrix*vec4(a_projected_pos.xy+u_translation,ele,1.0);} else {projected_pos=u_label_plane_matrix*projectTileWithElevation(a_projected_pos.xy+u_translation,ele);}float z=float(u_pitch_with_map)*projected_pos.z/projected_pos.w;float projectionScaling=1.0;\n#ifdef GLOBE\nif(u_pitch_with_map) {float anchor_pos_tile_y=(u_coord_matrix*vec4(projected_pos.xy/projected_pos.w,z,1.0)).y;projectionScaling=mix(projectionScaling,1.0/circumferenceRatioAtTileY(anchor_pos_tile_y)*u_pitched_scale,u_projection_transition);}\n#endif\nvec4 finalPos=u_coord_matrix*vec4(projected_pos.xy/projected_pos.w+rotation_matrix*(a_offset/32.0*fontScale+a_pxoffset)*projectionScaling,z,1.0);if(u_pitch_with_map) {finalPos=projectTileWithElevation(finalPos.xy,finalPos.z);}float gamma_scale=finalPos.w;gl_Position=finalPos;vec2 fade_opacity=unpack_opacity(a_fade_opacity);float visibility=calculate_visibility(projectedPoint);float fade_change=fade_opacity[1] > 0.5 ? u_fade_change :-u_fade_change;float interpolated_fade_opacity=max(0.0,min(visibility,fade_opacity[0]+fade_change));v_data0=a_tex/u_texsize;v_data1=vec3(gamma_scale,size,interpolated_fade_opacity);}"),symbolTextAndIcon:St("#define SDF_PX 8.0\n#define SDF 1.0\n#define ICON 0.0\nuniform bool u_is_halo;uniform sampler2D u_texture;uniform sampler2D u_texture_icon;uniform highp float u_gamma_scale;uniform lowp float u_device_pixel_ratio;in vec4 v_data0;in vec4 v_data1;\n#pragma mapbox: define highp vec4 fill_color\n#pragma mapbox: define highp vec4 halo_color\n#pragma mapbox: define lowp float opacity\n#pragma mapbox: define lowp float halo_width\n#pragma mapbox: define lowp float halo_blur\nvoid main() {\n#pragma mapbox: initialize highp vec4 fill_color\n#pragma mapbox: initialize highp vec4 halo_color\n#pragma mapbox: initialize lowp float opacity\n#pragma mapbox: initialize lowp float halo_width\n#pragma mapbox: initialize lowp float halo_blur\nfloat fade_opacity=v_data1[2];if (v_data1.w==ICON) {vec2 tex_icon=v_data0.zw;lowp float alpha=opacity*fade_opacity;fragColor=texture(u_texture_icon,tex_icon)*alpha;\n#ifdef OVERDRAW_INSPECTOR\nfragColor=vec4(1.0);\n#endif\nreturn;}vec2 tex=v_data0.xy;float EDGE_GAMMA=0.105/u_device_pixel_ratio;float gamma_scale=v_data1.x;float size=v_data1.y;float fontScale=size/24.0;lowp vec4 color=fill_color;highp float gamma=EDGE_GAMMA/(fontScale*u_gamma_scale);lowp float buff=(256.0-64.0)/256.0;if (u_is_halo) {color=halo_color;gamma=(halo_blur*1.19/SDF_PX+EDGE_GAMMA)/(fontScale*u_gamma_scale);buff=(6.0-halo_width/fontScale)/SDF_PX;}lowp float dist=texture(u_texture,tex).a;highp float gamma_scaled=gamma*gamma_scale;highp float alpha=smoothstep(buff-gamma_scaled,buff+gamma_scaled,dist);fragColor=color*(alpha*opacity*fade_opacity);\n#ifdef OVERDRAW_INSPECTOR\nfragColor=vec4(1.0);\n#endif\n}","in vec4 a_pos_offset;in vec4 a_data;in vec3 a_projected_pos;in float a_fade_opacity;uniform bool u_is_size_zoom_constant;uniform bool u_is_size_feature_constant;uniform highp float u_size_t;uniform highp float u_size;uniform mat4 u_label_plane_matrix;uniform mat4 u_coord_matrix;uniform bool u_is_text;uniform bool u_pitch_with_map;uniform highp float u_pitch;uniform bool u_rotate_symbol;uniform highp float u_aspect_ratio;uniform highp float u_camera_to_center_distance;uniform float u_fade_change;uniform vec2 u_texsize;uniform vec2 u_texsize_icon;uniform bool u_is_along_line;uniform bool u_is_variable_anchor;uniform vec2 u_translation;uniform float u_pitched_scale;out vec4 v_data0;out vec4 v_data1;\n#pragma mapbox: define highp vec4 fill_color\n#pragma mapbox: define highp vec4 halo_color\n#pragma mapbox: define lowp float opacity\n#pragma mapbox: define lowp float halo_width\n#pragma mapbox: define lowp float halo_blur\nvoid main() {\n#pragma mapbox: initialize highp vec4 fill_color\n#pragma mapbox: initialize highp vec4 halo_color\n#pragma mapbox: initialize lowp float opacity\n#pragma mapbox: initialize lowp float halo_width\n#pragma mapbox: initialize lowp float halo_blur\nvec2 a_pos=a_pos_offset.xy;vec2 a_offset=a_pos_offset.zw;vec2 a_tex=a_data.xy;vec2 a_size=a_data.zw;float a_size_min=floor(a_size[0]*0.5);float is_sdf=a_size[0]-2.0*a_size_min;float ele=get_elevation(a_pos);highp float segment_angle=-a_projected_pos[2];float size;if (!u_is_size_zoom_constant && !u_is_size_feature_constant) {size=mix(a_size_min,a_size[1],u_size_t)/128.0;} else if (u_is_size_zoom_constant && !u_is_size_feature_constant) {size=a_size_min/128.0;} else {size=u_size;}vec2 translated_a_pos=a_pos+u_translation;vec4 projectedPoint=projectTileWithElevation(translated_a_pos,ele);highp float camera_to_anchor_distance=projectedPoint.w;highp float distance_ratio=u_pitch_with_map ?\ncamera_to_anchor_distance/u_camera_to_center_distance :\nu_camera_to_center_distance/camera_to_anchor_distance;highp float perspective_ratio=clamp(0.5+0.5*distance_ratio,0.0,4.0);size*=perspective_ratio;float fontScale=size/24.0;highp float symbol_rotation=0.0;if (u_rotate_symbol) {vec4 offsetProjectedPoint=projectTileWithElevation(translated_a_pos+vec2(1,0),ele);vec2 a=projectedPoint.xy/projectedPoint.w;vec2 b=offsetProjectedPoint.xy/offsetProjectedPoint.w;symbol_rotation=atan((b.y-a.y)/u_aspect_ratio,b.x-a.x);}highp float angle_sin=sin(segment_angle+symbol_rotation);highp float angle_cos=cos(segment_angle+symbol_rotation);mat2 rotation_matrix=mat2(angle_cos,-1.0*angle_sin,angle_sin,angle_cos);vec4 projected_pos;if (u_is_along_line || u_is_variable_anchor) {projected_pos=vec4(a_projected_pos.xy,ele,1.0);} else if (u_pitch_with_map) {projected_pos=u_label_plane_matrix*vec4(a_projected_pos.xy+u_translation,ele,1.0);} else {projected_pos=u_label_plane_matrix*projectTileWithElevation(a_projected_pos.xy+u_translation,ele);}float z=float(u_pitch_with_map)*projected_pos.z/projected_pos.w;float projectionScaling=1.0;\n#ifdef GLOBE\nif(u_pitch_with_map && !u_is_along_line) {float anchor_pos_tile_y=(u_coord_matrix*vec4(projected_pos.xy/projected_pos.w,z,1.0)).y;projectionScaling=mix(projectionScaling,1.0/circumferenceRatioAtTileY(anchor_pos_tile_y)*u_pitched_scale,u_projection_transition);}\n#endif\nvec4 finalPos=u_coord_matrix*vec4(projected_pos.xy/projected_pos.w+rotation_matrix*(a_offset/32.0*fontScale)*projectionScaling,z,1.0);if(u_pitch_with_map) {finalPos=projectTileWithElevation(finalPos.xy,finalPos.z);}float gamma_scale=finalPos.w;gl_Position=finalPos;vec2 fade_opacity=unpack_opacity(a_fade_opacity);float visibility=calculate_visibility(projectedPoint);float fade_change=fade_opacity[1] > 0.5 ? u_fade_change :-u_fade_change;float interpolated_fade_opacity=max(0.0,min(visibility,fade_opacity[0]+fade_change));v_data0.xy=a_tex/u_texsize;v_data0.zw=a_tex/u_texsize_icon;v_data1=vec4(gamma_scale,size,interpolated_fade_opacity,is_sdf);}"),terrain:St("uniform sampler2D u_texture;uniform vec4 u_fog_color;uniform vec4 u_horizon_color;uniform float u_fog_ground_blend;uniform float u_fog_ground_blend_opacity;uniform float u_horizon_fog_blend;uniform bool u_is_globe_mode;in vec2 v_texture_pos;in float v_fog_depth;const float gamma=2.2;vec4 gammaToLinear(vec4 color) {return pow(color,vec4(gamma));}vec4 linearToGamma(vec4 color) {return pow(color,vec4(1.0/gamma));}void main() {vec4 surface_color=texture(u_texture,vec2(v_texture_pos.x,1.0-v_texture_pos.y));if (!u_is_globe_mode && v_fog_depth > u_fog_ground_blend) {vec4 surface_color_linear=gammaToLinear(surface_color);float blend_color=smoothstep(0.0,1.0,max((v_fog_depth-u_horizon_fog_blend)/(1.0-u_horizon_fog_blend),0.0));vec4 fog_horizon_color_linear=mix(gammaToLinear(u_fog_color),gammaToLinear(u_horizon_color),blend_color);float factor_fog=max(v_fog_depth-u_fog_ground_blend,0.0)/(1.0-u_fog_ground_blend);fragColor=linearToGamma(mix(surface_color_linear,fog_horizon_color_linear,pow(factor_fog,2.0)*u_fog_ground_blend_opacity));} else {fragColor=surface_color;}}","in vec3 a_pos3d;uniform mat4 u_fog_matrix;uniform float u_ele_delta;out vec2 v_texture_pos;out float v_fog_depth;void main() {float ele=get_elevation(a_pos3d.xy);float ele_delta=a_pos3d.z==1.0 ? u_ele_delta : 0.0;v_texture_pos=a_pos3d.xy/8192.0;gl_Position=projectTileFor3D(a_pos3d.xy,get_elevation(a_pos3d.xy)-ele_delta);vec4 pos=u_fog_matrix*vec4(a_pos3d.xy,ele,1.0);v_fog_depth=pos.z/pos.w*0.5+0.5;}"),terrainDepth:St("in float v_depth;const highp vec4 bitSh=vec4(256.*256.*256.,256.*256.,256.,1.);const highp vec4 bitMsk=vec4(0.,vec3(1./256.0));highp vec4 pack(highp float value) {highp vec4 comp=fract(value*bitSh);comp-=comp.xxyz*bitMsk;return comp;}void main() {fragColor=pack(v_depth);}","in vec3 a_pos3d;uniform float u_ele_delta;out float v_depth;void main() {float ele=get_elevation(a_pos3d.xy);float ele_delta=a_pos3d.z==1.0 ? u_ele_delta : 0.0;gl_Position=projectTileFor3D(a_pos3d.xy,ele-ele_delta);v_depth=gl_Position.z/gl_Position.w;}"),terrainCoords:St("precision mediump float;uniform sampler2D u_texture;uniform float u_terrain_coords_id;in vec2 v_texture_pos;void main() {vec4 rgba=texture(u_texture,v_texture_pos);fragColor=vec4(rgba.r,rgba.g,rgba.b,u_terrain_coords_id);}","in vec3 a_pos3d;uniform float u_ele_delta;out vec2 v_texture_pos;void main() {float ele=get_elevation(a_pos3d.xy);float ele_delta=a_pos3d.z==1.0 ? u_ele_delta : 0.0;v_texture_pos=a_pos3d.xy/8192.0;gl_Position=projectTileFor3D(a_pos3d.xy,ele-ele_delta);}"),projectionErrorMeasurement:St("in vec4 v_output_error_encoded;void main() {fragColor=v_output_error_encoded;}","in vec2 a_pos;uniform highp float u_input;uniform highp float u_output_expected;out vec4 v_output_error_encoded;void main() {float real_output=2.0*atan(exp(PI-(u_input*PI*2.0)))-PI*0.5;float error=real_output-u_output_expected;float abs_error=abs(error)*128.0;v_output_error_encoded.x=min(floor(abs_error*256.0),255.0)/255.0;abs_error-=v_output_error_encoded.x;v_output_error_encoded.y=min(floor(abs_error*65536.0),255.0)/255.0;abs_error-=v_output_error_encoded.x/255.0;v_output_error_encoded.z=min(floor(abs_error*16777216.0),255.0)/255.0;v_output_error_encoded.w=error >=0.0 ? 1.0 : 0.0;gl_Position=vec4(a_pos,0.0,1.0);}"),atmosphere:St("in vec3 view_direction;uniform vec3 u_sun_pos;uniform vec3 u_globe_position;uniform float u_globe_radius;uniform float u_atmosphere_blend;/**Shader use from https:*Made some change to adapt to MapLibre Globe geometry*/const float PI=3.141592653589793;const int iSteps=5;const int jSteps=3;/*radius of the planet*/const float EARTH_RADIUS=6371e3;/*radius of the atmosphere*/const float ATMOS_RADIUS=6471e3;vec2 rsi(vec3 r0,vec3 rd,float sr) {float a=dot(rd,rd);float b=2.0*dot(rd,r0);float c=dot(r0,r0)-(sr*sr);float d=(b*b)-4.0*a*c;if (d < 0.0) return vec2(1e5,-1e5);return vec2((-b-sqrt(d))/(2.0*a),(-b+sqrt(d))/(2.0*a));}vec4 atmosphere(vec3 r,vec3 r0,vec3 pSun,float iSun,float rPlanet,float rAtmos,vec3 kRlh,float kMie,float shRlh,float shMie,float g) {pSun=normalize(pSun);r=normalize(r);vec2 p=rsi(r0,r,rAtmos);if (p.x > p.y) {return vec4(0.0,0.0,0.0,1.0);}if (p.x < 0.0) {p.x=0.0;}vec3 pos=r0+r*p.x;vec2 p2=rsi(r0,r,rPlanet);if (p2.x <=p2.y && p2.x > 0.0) {p.y=min(p.y,p2.x);}float iStepSize=(p.y-p.x)/float(iSteps);float iTime=p.x+iStepSize*0.5;vec3 totalRlh=vec3(0,0,0);vec3 totalMie=vec3(0,0,0);float iOdRlh=0.0;float iOdMie=0.0;float mu=dot(r,pSun);float mumu=mu*mu;float gg=g*g;float pRlh=3.0/(16.0*PI)*(1.0+mumu);float pMie=3.0/(8.0*PI)*((1.0-gg)*(mumu+1.0))/(pow(1.0+gg-2.0*mu*g,1.5)*(2.0+gg));for (int i=0; i < iSteps; i++) {vec3 iPos=r0+r*iTime;float iHeight=length(iPos)-rPlanet;float odStepRlh=exp(-iHeight/shRlh)*iStepSize;float odStepMie=exp(-iHeight/shMie)*iStepSize;iOdRlh+=odStepRlh;iOdMie+=odStepMie;float jStepSize=rsi(iPos,pSun,rAtmos).y/float(jSteps);float jTime=jStepSize*0.5;float jOdRlh=0.0;float jOdMie=0.0;for (int j=0; j < jSteps; j++) {vec3 jPos=iPos+pSun*jTime;float jHeight=length(jPos)-rPlanet;jOdRlh+=exp(-jHeight/shRlh)*jStepSize;jOdMie+=exp(-jHeight/shMie)*jStepSize;jTime+=jStepSize;}vec3 attn=exp(-(kMie*(iOdMie+jOdMie)+kRlh*(iOdRlh+jOdRlh)));totalRlh+=odStepRlh*attn;totalMie+=odStepMie*attn;iTime+=iStepSize;}float opacity=exp(-(length(kRlh)*length(totalRlh)+kMie*length(totalMie)));vec3 color=iSun*(pRlh*kRlh*totalRlh+pMie*kMie*totalMie);return vec4(color,opacity);}void main() {vec3 scale_camera_pos=-u_globe_position*EARTH_RADIUS/u_globe_radius;vec4 color=atmosphere(normalize(view_direction),scale_camera_pos,u_sun_pos,22.0,EARTH_RADIUS,ATMOS_RADIUS,vec3(5.5e-6,13.0e-6,22.4e-6),21e-6,8e3,1.2e3,0.758\n);color.rgb=1.0-exp(-1.0*color.rgb);color=pow(color,vec4(1.0/2.2));fragColor=vec4(color.rgb,1.0-color.a)*u_atmosphere_blend;}","in vec2 a_pos;uniform mat4 u_inv_proj_matrix;out vec3 view_direction;void main() {view_direction=(u_inv_proj_matrix*vec4(a_pos,0.0,1.0)).xyz;gl_Position=vec4(a_pos,0.0,1.0);}"),sky:St("uniform vec4 u_sky_color;uniform vec4 u_horizon_color;uniform vec2 u_horizon;uniform vec2 u_horizon_normal;uniform float u_sky_horizon_blend;uniform float u_sky_blend;void main() {float x=gl_FragCoord.x;float y=gl_FragCoord.y;float blend=(y-u_horizon.y)*u_horizon_normal.y+(x-u_horizon.x)*u_horizon_normal.x;if (blend > 0.0) {if (blend < u_sky_horizon_blend) {fragColor=mix(u_sky_color,u_horizon_color,pow(1.0-blend/u_sky_horizon_blend,2.0));} else {fragColor=u_sky_color;}}fragColor=mix(fragColor,vec4(vec3(0.0),0.0),u_sky_blend);}","in vec2 a_pos;void main() {gl_Position=vec4(a_pos,1.0,1.0);}")};function St(e,t){const i=/#pragma mapbox: ([\w]+) ([\w]+) ([\w]+) ([\w]+)/g,r=t.match(/in ([\w]+) ([\w]+)/g),n=e.match(/uniform ([\w]+) ([\w]+)([\s]*)([\w]*)/g),o=t.match(/uniform ([\w]+) ([\w]+)([\s]*)([\w]*)/g),s=o?o.concat(n):n,a={};return{fragmentSource:e=e.replace(i,(e,t,i,r,n)=>(a[n]=!0,"define"===t?`\n#ifndef HAS_UNIFORM_u_${n}\nin ${i} ${r} ${n};\n#else\nuniform ${i} ${r} u_${n};\n#endif\n`:`\n#ifdef HAS_UNIFORM_u_${n}\n ${i} ${r} ${n} = u_${n};\n#endif\n`)),vertexSource:t=t.replace(i,(e,t,i,r,n)=>{const o="float"===r?"vec2":"vec4",s=n.match(/color/)?"color":o;return a[n]?"define"===t?`\n#ifndef HAS_UNIFORM_u_${n}\nuniform lowp float u_${n}_t;\nin ${i} ${o} a_${n};\nout ${i} ${r} ${n};\n#else\nuniform ${i} ${r} u_${n};\n#endif\n`:"vec4"===s?`\n#ifndef HAS_UNIFORM_u_${n}\n ${n} = a_${n};\n#else\n ${i} ${r} ${n} = u_${n};\n#endif\n`:`\n#ifndef HAS_UNIFORM_u_${n}\n ${n} = unpack_mix_${s}(a_${n}, u_${n}_t);\n#else\n ${i} ${r} ${n} = u_${n};\n#endif\n`:"define"===t?`\n#ifndef HAS_UNIFORM_u_${n}\nuniform lowp float u_${n}_t;\nin ${i} ${o} a_${n};\n#else\nuniform ${i} ${r} u_${n};\n#endif\n`:"vec4"===s?`\n#ifndef HAS_UNIFORM_u_${n}\n ${i} ${r} ${n} = a_${n};\n#else\n ${i} ${r} ${n} = u_${n};\n#endif\n`:`\n#ifndef HAS_UNIFORM_u_${n}\n ${i} ${r} ${n} = unpack_mix_${s}(a_${n}, u_${n}_t);\n#else\n ${i} ${r} ${n} = u_${n};\n#endif\n`}),staticAttributes:r,staticUniforms:s}}class It{constructor(e,t,i){this.vertexBuffer=e,this.indexBuffer=t,this.segments=i}destroy(){this.vertexBuffer.destroy(),this.indexBuffer.destroy(),this.segments.destroy(),this.vertexBuffer=null,this.indexBuffer=null,this.segments=null}}var Mt=t.aT([{name:"a_pos",type:"Int16",components:2}]);const Pt="#define PROJECTION_MERCATOR",Rt="mercator";class Lt{constructor(){this._cachedMesh=null}get name(){return"mercator"}get useSubdivision(){return!1}get shaderVariantName(){return Rt}get shaderDefine(){return Pt}get shaderPreludeCode(){return Bt.projectionMercator}get vertexShaderPreludeCode(){return Bt.projectionMercator.vertexSource}get subdivisionGranularity(){return t.aU.noSubdivision}get useGlobeControls(){return!1}get transitionState(){return 0}get latitudeErrorCorrectionRadians(){return 0}destroy(){}updateGPUdependent(e){}getMeshFromTileID(e,i,r,n,o){if(this._cachedMesh)return this._cachedMesh;const s=new t.aV;s.emplaceBack(0,0),s.emplaceBack(t.a4,0),s.emplaceBack(0,t.a4),s.emplaceBack(t.a4,t.a4);const a=e.createVertexBuffer(s,Mt.members),l=t.aW.simpleSegment(0,0,4,2),c=new t.aX;c.emplaceBack(1,0,2),c.emplaceBack(1,2,3);const u=e.createIndexBuffer(c);return this._cachedMesh=new It(a,u,l),this._cachedMesh}recalculate(){}hasTransition(){return!1}setErrorQueryLatitudeDegrees(e){}}class Ft{constructor(e=0,t=0,i=0,r=0){if(isNaN(e)||e<0||isNaN(t)||t<0||isNaN(i)||i<0||isNaN(r)||r<0)throw new Error("Invalid value for edge-insets, top, bottom, left and right must all be numbers");this.top=e,this.bottom=t,this.left=i,this.right=r}interpolate(e,i,r){return null!=i.top&&null!=e.top&&(this.top=t.G.number(e.top,i.top,r)),null!=i.bottom&&null!=e.bottom&&(this.bottom=t.G.number(e.bottom,i.bottom,r)),null!=i.left&&null!=e.left&&(this.left=t.G.number(e.left,i.left,r)),null!=i.right&&null!=e.right&&(this.right=t.G.number(e.right,i.right,r)),this}getCenter(e,i){const r=t.an((this.left+e-this.right)/2,0,e),n=t.an((this.top+i-this.bottom)/2,0,i);return new t.P(r,n)}equals(e){return this.top===e.top&&this.bottom===e.bottom&&this.left===e.left&&this.right===e.right}clone(){return new Ft(this.top,this.bottom,this.left,this.right)}toJSON(){return{top:this.top,bottom:this.bottom,left:this.left,right:this.right}}}function kt(e,t){if(!e.renderWorldCopies||e.lngRange)return;const i=t.lng-e.center.lng;t.lng+=i>180?-360:i<-180?360:0}function Dt(e){return Math.max(0,Math.floor(e))}class Ot{constructor(e,i){var r;this.applyConstrain=(e,t)=>null!==this._constrainOverride?this._constrainOverride(e,t):this._callbacks.defaultConstrain(e,t),this._callbacks=e,this._tileSize=512,this._renderWorldCopies=void 0===(null==i?void 0:i.renderWorldCopies)||!!(null==i?void 0:i.renderWorldCopies),this._minZoom=(null==i?void 0:i.minZoom)||0,this._maxZoom=(null==i?void 0:i.maxZoom)||22,this._minPitch=null==(null==i?void 0:i.minPitch)?0:null==i?void 0:i.minPitch,this._maxPitch=null==(null==i?void 0:i.maxPitch)?60:null==i?void 0:i.maxPitch,this._constrainOverride=null!==(r=null==i?void 0:i.constrainOverride)&&void 0!==r?r:null,this.setMaxBounds(),this._width=0,this._height=0,this._center=new t.V(0,0),this._elevation=0,this._zoom=0,this._tileZoom=Dt(this._zoom),this._scale=t.aq(this._zoom),this._bearingInRadians=0,this._fovInRadians=.6435011087932844,this._pitchInRadians=0,this._rollInRadians=0,this._unmodified=!0,this._edgeInsets=new Ft,this._minElevationForCurrentTile=0,this._autoCalculateNearFarZ=!0}apply(e,i,r){this._constrainOverride=e.constrainOverride,this._latRange=e.latRange,this._lngRange=e.lngRange,this._width=e.width,this._height=e.height,this._center=e.center,this._elevation=e.elevation,this._minElevationForCurrentTile=e.minElevationForCurrentTile,this._zoom=e.zoom,this._tileZoom=Dt(this._zoom),this._scale=t.aq(this._zoom),this._bearingInRadians=e.bearingInRadians,this._fovInRadians=e.fovInRadians,this._pitchInRadians=e.pitchInRadians,this._rollInRadians=e.rollInRadians,this._unmodified=e.unmodified,this._edgeInsets=new Ft(e.padding.top,e.padding.bottom,e.padding.left,e.padding.right),this._minZoom=e.minZoom,this._maxZoom=e.maxZoom,this._minPitch=e.minPitch,this._maxPitch=e.maxPitch,this._renderWorldCopies=e.renderWorldCopies,this._cameraToCenterDistance=e.cameraToCenterDistance,this._nearZ=e.nearZ,this._farZ=e.farZ,this._autoCalculateNearFarZ=!r&&e.autoCalculateNearFarZ,i&&this.constrainInternal(),this._calcMatrices()}get pixelsToClipSpaceMatrix(){return this._pixelsToClipSpaceMatrix}get clipSpaceToPixelsMatrix(){return this._clipSpaceToPixelsMatrix}get minElevationForCurrentTile(){return this._minElevationForCurrentTile}setMinElevationForCurrentTile(e){this._minElevationForCurrentTile=e}get tileSize(){return this._tileSize}get tileZoom(){return this._tileZoom}get scale(){return this._scale}get width(){return this._width}get height(){return this._height}get bearingInRadians(){return this._bearingInRadians}get lngRange(){return this._lngRange}get latRange(){return this._latRange}get pixelsToGLUnits(){return this._pixelsToGLUnits}get minZoom(){return this._minZoom}setMinZoom(e){this._minZoom!==e&&(this._minZoom=e,this.setZoom(this.applyConstrain(this._center,this.zoom).zoom))}get maxZoom(){return this._maxZoom}setMaxZoom(e){this._maxZoom!==e&&(this._maxZoom=e,this.setZoom(this.applyConstrain(this._center,this.zoom).zoom))}get minPitch(){return this._minPitch}setMinPitch(e){this._minPitch!==e&&(this._minPitch=e,this.setPitch(Math.max(this.pitch,e)))}get maxPitch(){return this._maxPitch}setMaxPitch(e){this._maxPitch!==e&&(this._maxPitch=e,this.setPitch(Math.min(this.pitch,e)))}get renderWorldCopies(){return this._renderWorldCopies}setRenderWorldCopies(e){void 0===e?e=!0:null===e&&(e=!1),this._renderWorldCopies=e}get constrainOverride(){return this._constrainOverride}setConstrainOverride(e){void 0===e&&(e=null),this._constrainOverride!==e&&(this._constrainOverride=e,this.constrainInternal(),this._calcMatrices())}get worldSize(){return this._tileSize*this._scale}get centerOffset(){return this.centerPoint._sub(this.size._div(2))}get size(){return new t.P(this._width,this._height)}get bearing(){return this._bearingInRadians/Math.PI*180}setBearing(e){const i=t.W(e,-180,180)*Math.PI/180;var n,o,s,a,l,c,u,h,d;this._bearingInRadians!==i&&(this._unmodified=!1,this._bearingInRadians=i,this._calcMatrices(),this._rotationMatrix=r(),n=this._rotationMatrix,s=-this._bearingInRadians,a=(o=this._rotationMatrix)[0],l=o[1],c=o[2],u=o[3],h=Math.sin(s),d=Math.cos(s),n[0]=a*d+c*h,n[1]=l*d+u*h,n[2]=a*-h+c*d,n[3]=l*-h+u*d)}get rotationMatrix(){return this._rotationMatrix}get pitchInRadians(){return this._pitchInRadians}get pitch(){return this._pitchInRadians/Math.PI*180}setPitch(e){const i=t.an(e,this.minPitch,this.maxPitch)/180*Math.PI;this._pitchInRadians!==i&&(this._unmodified=!1,this._pitchInRadians=i,this._calcMatrices())}get rollInRadians(){return this._rollInRadians}get roll(){return this._rollInRadians/Math.PI*180}setRoll(e){const t=e/180*Math.PI;this._rollInRadians!==t&&(this._unmodified=!1,this._rollInRadians=t,this._calcMatrices())}get fovInRadians(){return this._fovInRadians}get fov(){return t.aY(this._fovInRadians)}setFov(e){e=t.an(e,.1,150),this.fov!==e&&(this._unmodified=!1,this._fovInRadians=t.ap(e),this._calcMatrices())}get zoom(){return this._zoom}setZoom(e){const i=this.applyConstrain(this._center,e).zoom;this._zoom!==i&&(this._unmodified=!1,this._zoom=i,this._tileZoom=Math.max(0,Math.floor(i)),this._scale=t.aq(i),this.constrainInternal(),this._calcMatrices())}get center(){return this._center}setCenter(e){e.lat===this._center.lat&&e.lng===this._center.lng||(this._unmodified=!1,this._center=e,this.constrainInternal(),this._calcMatrices())}get elevation(){return this._elevation}setElevation(e){e!==this._elevation&&(this._elevation=e,this.constrainInternal(),this._calcMatrices())}get padding(){return this._edgeInsets.toJSON()}setPadding(e){this._edgeInsets.equals(e)||(this._unmodified=!1,this._edgeInsets.interpolate(this._edgeInsets,e,1),this._calcMatrices())}get centerPoint(){return this._edgeInsets.getCenter(this._width,this._height)}get pixelsPerMeter(){return this._pixelPerMeter}get unmodified(){return this._unmodified}get cameraToCenterDistance(){return this._cameraToCenterDistance}get nearZ(){return this._nearZ}get farZ(){return this._farZ}get autoCalculateNearFarZ(){return this._autoCalculateNearFarZ}overrideNearFarZ(e,t){this._autoCalculateNearFarZ=!1,this._nearZ=e,this._farZ=t,this._calcMatrices()}clearNearFarZOverride(){this._autoCalculateNearFarZ=!0,this._calcMatrices()}isPaddingEqual(e){return this._edgeInsets.equals(e)}interpolatePadding(e,t,i){this._unmodified=!1,this._edgeInsets.interpolate(e,t,i),this.constrainInternal(),this._calcMatrices()}resize(e,t,i=!0){this._width=e,this._height=t,i&&this.constrainInternal(),this._calcMatrices()}getMaxBounds(){return this._latRange&&2===this._latRange.length&&this._lngRange&&2===this._lngRange.length?new Z([this._lngRange[0],this._latRange[0]],[this._lngRange[1],this._latRange[1]]):null}setMaxBounds(e){e?(this._lngRange=[e.getWest(),e.getEast()],this._latRange=[e.getSouth(),e.getNorth()],this.constrainInternal()):(this._lngRange=null,this._latRange=[-t.ao,t.ao])}getCameraQueryGeometry(e,i){if(1===i.length)return[i[0],e];{const{minX:r,minY:n,maxX:o,maxY:s}=t.ab.fromPoints(i).extend(e);return[new t.P(r,n),new t.P(o,n),new t.P(o,s),new t.P(r,s),new t.P(r,n)]}}constrainInternal(){if(!this.center||!this._width||!this._height||this._constraining)return;this._constraining=!0;const e=this._unmodified,{center:t,zoom:i}=this.applyConstrain(this.center,this.zoom);this.setCenter(t),this.setZoom(i),this._unmodified=e,this._constraining=!1}_calcMatrices(){if(this._width&&this._height){this._pixelsToGLUnits=[2/this._width,-2/this._height];let e=t.ar(new Float64Array(16));t.Q(e,e,[this._width/2,-this._height/2,1]),t.O(e,e,[1,-1,0]),this._clipSpaceToPixelsMatrix=e,e=t.ar(new Float64Array(16)),t.Q(e,e,[1,-1,1]),t.O(e,e,[-1,-1,0]),t.Q(e,e,[2/this._width,2/this._height,1]),this._pixelsToClipSpaceMatrix=e,this._cameraToCenterDistance=.5/Math.tan(this.fovInRadians/2)*this._height}this._callbacks.calcMatrices()}calculateCenterFromCameraLngLatAlt(e,i,r,n){const o=void 0!==r?r:this.bearing,s=n=void 0!==n?n:this.pitch,a=t.aa.fromLngLat(e,i),l=-Math.cos(t.ap(s)),c=Math.sin(t.ap(s)),u=c*Math.sin(t.ap(o)),h=-c*Math.cos(t.ap(o));let d=this.elevation;const p=i-d;let f;l*p>=0||Math.abs(l)<.1?(f=1e4,d=i+f*l):f=-p/l;let m,g,_=t.aZ(1,a.y),A=0;do{if(A+=1,A>10)break;g=f/_,m=new t.aa(a.x+u*g,a.y+h*g),_=1/m.meterInMercatorCoordinateUnits()}while(Math.abs(f-g*_)>1e-12);return{center:m.toLngLat(),elevation:d,zoom:t.at(this.height/2/Math.tan(this.fovInRadians/2)/g/this.tileSize)}}recalculateZoomAndCenter(e){if(this.elevation-e==0)return;const i=t.as(1,this.center.lat)*this.worldSize,r=this.cameraToCenterDistance/i,n=t.aa.fromLngLat(this.center,this.elevation),o=ye(this.center,this.elevation,this.pitch,this.bearing,r);this._elevation=e;const s=this.calculateCenterFromCameraLngLatAlt(o.toLngLat(),t.aZ(o.z,n.y),this.bearing,this.pitch);this._elevation=s.elevation,this._center=s.center,this.setZoom(s.zoom)}getCameraPoint(){const e=Math.tan(this.pitchInRadians)*(this.cameraToCenterDistance||1);return this.centerPoint.add(new t.P(e*Math.sin(this.rollInRadians),e*Math.cos(this.rollInRadians)))}getCameraAltitude(){return Math.cos(this.pitchInRadians)*this._cameraToCenterDistance/this._pixelPerMeter+this.elevation}getCameraLngLat(){const e=t.as(1,this.center.lat)*this.worldSize;return ye(this.center,this.elevation,this.pitch,this.bearing,this.cameraToCenterDistance/e).toLngLat()}getMercatorTileCoordinates(e){if(!e)return[0,0,1,1];const i=e.canonical.z>=0?1<this.max[0]||e.aabb.min[1]>this.max[1]||e.aabb.min[2]>this.max[2]||e.aabb.max[0]0?(t+=e[r]*this.min[r],i+=e[r]*this.max[r]):(i+=e[r]*this.min[r],t+=e[r]*this.max[r]);return t>=0?2:i<0?0:1}}class Ut{distanceToTile2d(e,t,i,r){const n=r.distanceX([e,t]),o=r.distanceY([e,t]);return Math.hypot(n,o)}getWrap(e,t,i){return i}getTileBoundingVolume(e,i,r,n){var o,s;let a=0,l=0;if(null==n?void 0:n.terrain){const c=new t.a1(e.z,i,e.z,e.x,e.y),u=n.terrain.getMinMaxElevation(c);a=null!==(o=u.minElevation)&&void 0!==o?o:Math.min(0,r),l=null!==(s=u.maxElevation)&&void 0!==s?s:Math.max(0,r)}const c=1<n}allowWorldCopies(){return!0}prepareNextFrame(){}}class Nt{constructor(e,t,i){this.points=e,this.planes=t,this.aabb=i}static fromInvProjectionMatrix(e,i=1,r=0,n,o){const s=o?[[6,5,4],[0,1,2],[0,3,7],[2,1,5],[3,2,6],[0,4,5]]:[[0,1,2],[6,5,4],[0,3,7],[2,1,5],[3,2,6],[0,4,5]],a=Math.pow(2,r),l=[[-1,1,-1,1],[1,1,-1,1],[1,-1,-1,1],[-1,-1,-1,1],[-1,1,1,1],[1,1,1,1],[1,-1,1,1],[-1,-1,1,1]].map(r=>function(e,i,r,n){const o=t.aG([],e,i),s=1/o[3]/r*n;return t.b5(o,o,[s,s,1/o[3],s])}(r,e,i,a));n&&function(e,i,r,n){const o=n?4:0,s=n?0:4;let a=0;const l=[],c=[];for(let i=0;i<4;i++){const r=t.b1([],e[i+s],e[i+o]),n=t.b6(r);t.a_(r,r,1/n),l.push(n),c.push(r)}for(let i=0;i<4;i++){const n=t.b7(e[i+o],c[i],r);a=null!==n&&n>=0?Math.max(a,n):Math.max(a,l[i])}const u=function(e,i){const r=t.b1([],e[i[0]],e[i[1]]),n=t.b1([],e[i[2]],e[i[1]]),o=[0,0,0,0];return t.b2(o,t.b3([],r,n)),o[3]=-t.b4(o,e[i[0]]),o}(e,i),h=function(e,i){const r=t.b8(e),n=t.b9([],e,1/r),o=t.b1([],i,t.a_([],n,t.b4(i,n))),s=t.b8(o);if(s>0){const e=Math.sqrt(1-n[3]*n[3]),r=t.a_([],n,-n[3]),a=t.a$([],r,t.a_([],o,e/s));return t.ba(i,a)}return null}(r,u);if(null!==h){const e=h/t.b4(c[0],u);a=Math.min(a,e)}for(let t=0;t<4;t++){const i=Math.min(a,l[t]);e[t+s]=[e[t+o][0]+c[t][0]*i,e[t+o][1]+c[t][1]*i,e[t+o][2]+c[t][2]*i,1]}}(l,s[0],n,o);const c=s.map(e=>{const i=t.b1([],l[e[0]],l[e[1]]),r=t.b1([],l[e[2]],l[e[1]]),n=t.b2([],t.b3([],i,r)),o=-t.b4(n,l[e[1]]);return n.concat(o)}),u=[Number.POSITIVE_INFINITY,Number.POSITIVE_INFINITY,Number.POSITIVE_INFINITY],h=[Number.NEGATIVE_INFINITY,Number.NEGATIVE_INFINITY,Number.NEGATIVE_INFINITY];for(const e of l)for(let t=0;t<3;t++)u[t]=Math.min(u[t],e[t]),h[t]=Math.max(h[t],e[t]);return new Nt(l,c,new zt(u,h))}}class Vt{get pixelsToClipSpaceMatrix(){return this._helper.pixelsToClipSpaceMatrix}get clipSpaceToPixelsMatrix(){return this._helper.clipSpaceToPixelsMatrix}get pixelsToGLUnits(){return this._helper.pixelsToGLUnits}get centerOffset(){return this._helper.centerOffset}get size(){return this._helper.size}get rotationMatrix(){return this._helper.rotationMatrix}get centerPoint(){return this._helper.centerPoint}get pixelsPerMeter(){return this._helper.pixelsPerMeter}setMinZoom(e){this._helper.setMinZoom(e)}setMaxZoom(e){this._helper.setMaxZoom(e)}setMinPitch(e){this._helper.setMinPitch(e)}setMaxPitch(e){this._helper.setMaxPitch(e)}setRenderWorldCopies(e){this._helper.setRenderWorldCopies(e)}setBearing(e){this._helper.setBearing(e)}setPitch(e){this._helper.setPitch(e)}setRoll(e){this._helper.setRoll(e)}setFov(e){this._helper.setFov(e)}setZoom(e){this._helper.setZoom(e)}setCenter(e){this._helper.setCenter(e)}setElevation(e){this._helper.setElevation(e)}setMinElevationForCurrentTile(e){this._helper.setMinElevationForCurrentTile(e)}setPadding(e){this._helper.setPadding(e)}interpolatePadding(e,t,i){return this._helper.interpolatePadding(e,t,i)}isPaddingEqual(e){return this._helper.isPaddingEqual(e)}resize(e,t,i=!0){this._helper.resize(e,t,i)}getMaxBounds(){return this._helper.getMaxBounds()}setMaxBounds(e){this._helper.setMaxBounds(e)}setConstrainOverride(e){this._helper.setConstrainOverride(e)}overrideNearFarZ(e,t){this._helper.overrideNearFarZ(e,t)}clearNearFarZOverride(){this._helper.clearNearFarZOverride()}getCameraQueryGeometry(e){return this._helper.getCameraQueryGeometry(this.getCameraPoint(),e)}get tileSize(){return this._helper.tileSize}get tileZoom(){return this._helper.tileZoom}get scale(){return this._helper.scale}get worldSize(){return this._helper.worldSize}get width(){return this._helper.width}get height(){return this._helper.height}get lngRange(){return this._helper.lngRange}get latRange(){return this._helper.latRange}get minZoom(){return this._helper.minZoom}get maxZoom(){return this._helper.maxZoom}get zoom(){return this._helper.zoom}get center(){return this._helper.center}get minPitch(){return this._helper.minPitch}get maxPitch(){return this._helper.maxPitch}get pitch(){return this._helper.pitch}get pitchInRadians(){return this._helper.pitchInRadians}get roll(){return this._helper.roll}get rollInRadians(){return this._helper.rollInRadians}get bearing(){return this._helper.bearing}get bearingInRadians(){return this._helper.bearingInRadians}get fov(){return this._helper.fov}get fovInRadians(){return this._helper.fovInRadians}get elevation(){return this._helper.elevation}get minElevationForCurrentTile(){return this._helper.minElevationForCurrentTile}get padding(){return this._helper.padding}get unmodified(){return this._helper.unmodified}get renderWorldCopies(){return this._helper.renderWorldCopies}get cameraToCenterDistance(){return this._helper.cameraToCenterDistance}get constrainOverride(){return this._helper.constrainOverride}get nearZ(){return this._helper.nearZ}get farZ(){return this._helper.farZ}get autoCalculateNearFarZ(){return this._helper.autoCalculateNearFarZ}setTransitionState(e,t){}constructor(e){this._posMatrixCache=new Map,this._alignedPosMatrixCache=new Map,this._fogMatrixCacheF32=new Map,this.defaultConstrain=(e,i)=>{i=t.an(+i,this.minZoom,this.maxZoom);const r={center:new t.V(e.lng,e.lat),zoom:i};let n=this._helper._lngRange;if(!this._helper._renderWorldCopies&&null===n){const e=180-1e-10;n=[-e,e]}const o=this.tileSize*t.aq(r.zoom);let s=0,a=o,l=0,c=o,u=0,h=0;const{x:d,y:p}=this.size;if(this._helper._latRange){const e=this._helper._latRange;s=t.X(e[1])*o,a=t.X(e[0])*o,a-sa&&(_=a-e)}if(n){const e=(l+c)/2;let i=f;this._helper._renderWorldCopies&&(i=t.W(f,e-o/2,e+o/2));const r=d/2;i-rc&&(g=c-r)}if(void 0!==g||void 0!==_){const e=new t.P(null!=g?g:f,null!=_?_:m);r.center=ge(o,e).wrap()}return r},this.applyConstrain=(e,t)=>this._helper.applyConstrain(e,t),this._helper=new Ot({calcMatrices:()=>{this._calcMatrices()},defaultConstrain:(e,t)=>this.defaultConstrain(e,t)},e),this._coveringTilesDetailsProvider=new Ut}clone(){const e=new Vt;return e.apply(this),e}apply(e,t,i){this._helper.apply(e,t,i)}get cameraPosition(){return this._cameraPosition}get projectionMatrix(){return this._projectionMatrix}get modelViewProjectionMatrix(){return this._viewProjMatrix}get inverseProjectionMatrix(){return this._invProjMatrix}get mercatorMatrix(){return this._mercatorMatrix}getVisibleUnwrappedCoordinates(e){const i=[new t.bb(0,e)];if(this._helper._renderWorldCopies){const r=this.screenPointToMercatorCoordinate(new t.P(0,0)),n=this.screenPointToMercatorCoordinate(new t.P(this._helper._width,0)),o=this.screenPointToMercatorCoordinate(new t.P(this._helper._width,this._helper._height)),s=this.screenPointToMercatorCoordinate(new t.P(0,this._helper._height)),a=Math.floor(Math.min(r.x,n.x,o.x,s.x)),l=Math.floor(Math.max(r.x,n.x,o.x,s.x)),c=1;for(let r=a-c;r<=l+c;r++)0!==r&&i.push(new t.bb(r,e))}return i}getCameraFrustum(){return Nt.fromInvProjectionMatrix(this._invViewProjMatrix,this.worldSize)}getClippingPlane(){return null}getCoveringTilesDetailsProvider(){return this._coveringTilesDetailsProvider}recalculateZoomAndCenter(e){const t=this.screenPointToLocation(this.centerPoint,e),i=e?e.getElevationForLngLatZoom(t,this._helper._tileZoom):0;this._helper.recalculateZoomAndCenter(i)}setLocationAtPoint(e,i){const r=t.as(this.elevation,this.center.lat),n=this.screenPointToMercatorCoordinateAtZ(i,r),o=this.screenPointToMercatorCoordinateAtZ(this.centerPoint,r),s=t.aa.fromLngLat(e),a=new t.aa(s.x-(n.x-o.x),s.y-(n.y-o.y));this.setCenter(null==a?void 0:a.toLngLat()),this._helper._renderWorldCopies&&this.setCenter(this.center.wrap())}locationToScreenPoint(e,i){return i?this.coordinatePoint(t.aa.fromLngLat(e),i.getElevationForLngLatZoom(e,this._helper._tileZoom),this._pixelMatrix3D):this.coordinatePoint(t.aa.fromLngLat(e))}screenPointToLocation(e,t){var i;return null===(i=this.screenPointToMercatorCoordinate(e,t))||void 0===i?void 0:i.toLngLat()}screenPointToMercatorCoordinate(e,t){if(t){const i=t.pointCoordinate(e);if(null!=i)return i}return this.screenPointToMercatorCoordinateAtZ(e)}screenPointToMercatorCoordinateAtZ(e,i){const r=i||0,n=[e.x,e.y,0,1],o=[e.x,e.y,1,1];t.aG(n,n,this._pixelMatrixInverse),t.aG(o,o,this._pixelMatrixInverse);const s=n[3],a=o[3],l=n[1]/s,c=o[1]/a,u=n[2]/s,h=o[2]/a,d=u===h?0:(r-u)/(h-u);return new t.aa(t.G.number(n[0]/s,o[0]/a,d)/this.worldSize,t.G.number(l,c,d)/this.worldSize,r)}coordinatePoint(e,i=0,r=this._pixelMatrix){const n=[e.x*this.worldSize,e.y*this.worldSize,i,1];return t.aG(n,n,r),new t.P(n[0]/n[3],n[1]/n[3])}getBounds(){const e=Math.max(0,this._helper._height/2-_e(this));return(new Z).extend(this.screenPointToLocation(new t.P(0,e))).extend(this.screenPointToLocation(new t.P(this._helper._width,e))).extend(this.screenPointToLocation(new t.P(this._helper._width,this._helper._height))).extend(this.screenPointToLocation(new t.P(0,this._helper._height)))}isPointOnMapSurface(e,t){return t?null!=t.pointCoordinate(e):e.y>this.height/2-_e(this)}calculatePosMatrix(e,i=!1,r){var n;const o=null!==(n=e.key)&&void 0!==n?n:t.bc(e.wrap,e.canonical.z,e.canonical.z,e.canonical.x,e.canonical.y),s=i?this._alignedPosMatrixCache:this._posMatrixCache;if(s.has(o)){const e=s.get(o);return r?e.f32:e.f64}const a=Ae(e,this.worldSize);t.S(a,i?this._alignedProjMatrix:this._viewProjMatrix,a);const l={f64:a,f32:new Float32Array(a)};return s.set(o,l),r?l.f32:l.f64}calculateFogMatrix(e){const i=e.key,r=this._fogMatrixCacheF32;if(r.has(i))return r.get(i);const n=Ae(e,this.worldSize);return t.S(n,this._fogMatrix,n),r.set(i,new Float32Array(n)),r.get(i)}calculateCenterFromCameraLngLatAlt(e,t,i,r){return this._helper.calculateCenterFromCameraLngLatAlt(e,t,i,r)}_calculateNearFarZIfNeeded(e,i,r){if(!this._helper.autoCalculateNearFarZ)return;const n=Math.min(this.elevation,this.minElevationForCurrentTile,this.getCameraAltitude()-100),o=e-n*this._helper._pixelPerMeter/Math.cos(i),s=n<0?o:e,a=Math.PI/2+this.pitchInRadians,l=t.ap(this.fov)*(Math.abs(Math.cos(t.ap(this.roll)))*this.height+Math.abs(Math.sin(t.ap(this.roll)))*this.width)/this.height*(.5+r.y/this.height),c=Math.sin(l)*s/Math.sin(t.an(Math.PI-a-l,.01,Math.PI-.01)),u=_e(this),h=Math.atan(u/this._helper.cameraToCenterDistance),d=t.ap(.75),p=h>d?2*h*(.5+r.y/(2*u)):d,f=Math.sin(p)*s/Math.sin(t.an(Math.PI-a-p,.01,Math.PI-.01)),m=Math.min(c,f);this._helper._farZ=1.01*(Math.cos(Math.PI/2-i)*m+s),this._helper._nearZ=this._helper._height/50}_calcMatrices(){if(!this._helper._height)return;const e=this.centerOffset,i=me(this.worldSize,this.center),r=i.x,n=i.y;this._helper._pixelPerMeter=t.as(1,this.center.lat)*this.worldSize;const o=t.ap(Math.min(this.pitch,fe)),s=Math.max(this._helper.cameraToCenterDistance/2,this._helper.cameraToCenterDistance+this._helper._elevation*this._helper._pixelPerMeter/Math.cos(o));let a;this._calculateNearFarZIfNeeded(s,o,e),a=new Float64Array(16),t.bd(a,this.fovInRadians,this._helper._width/this._helper._height,this._helper._nearZ,this._helper._farZ),this._invProjMatrix=new Float64Array(16),t.aA(this._invProjMatrix,a),a[8]=2*-e.x/this._helper._width,a[9]=2*e.y/this._helper._height,this._projectionMatrix=t.be(a),t.Q(a,a,[1,-1,1]),t.O(a,a,[0,0,-this._helper.cameraToCenterDistance]),t.bf(a,a,-this.rollInRadians),t.bg(a,a,this.pitchInRadians),t.bf(a,a,-this.bearingInRadians),t.O(a,a,[-r,-n,0]),this._mercatorMatrix=t.Q([],a,[this.worldSize,this.worldSize,this.worldSize]),t.Q(a,a,[1,1,this._helper._pixelPerMeter]),this._pixelMatrix=t.S(new Float64Array(16),this.clipSpaceToPixelsMatrix,a),t.O(a,a,[0,0,-this.elevation]),this._viewProjMatrix=a,this._invViewProjMatrix=t.aA([],a);const l=[0,0,-1,1];t.aG(l,l,this._invViewProjMatrix),this._cameraPosition=[l[0]/l[3],l[1]/l[3],l[2]/l[3]],this._fogMatrix=new Float64Array(16),t.bd(this._fogMatrix,this.fovInRadians,this.width/this.height,s,this._helper._farZ),this._fogMatrix[8]=2*-e.x/this.width,this._fogMatrix[9]=2*e.y/this.height,t.Q(this._fogMatrix,this._fogMatrix,[1,-1,1]),t.O(this._fogMatrix,this._fogMatrix,[0,0,-this.cameraToCenterDistance]),t.bf(this._fogMatrix,this._fogMatrix,-this.rollInRadians),t.bg(this._fogMatrix,this._fogMatrix,this.pitchInRadians),t.bf(this._fogMatrix,this._fogMatrix,-this.bearingInRadians),t.O(this._fogMatrix,this._fogMatrix,[-r,-n,0]),t.Q(this._fogMatrix,this._fogMatrix,[1,1,this._helper._pixelPerMeter]),t.O(this._fogMatrix,this._fogMatrix,[0,0,-this.elevation]),this._pixelMatrix3D=t.S(new Float64Array(16),this.clipSpaceToPixelsMatrix,a);const c=this._helper._width%2/2,u=this._helper._height%2/2,h=Math.cos(this.bearingInRadians),d=Math.sin(-this.bearingInRadians),p=r-Math.round(r)+h*c+d*u,f=n-Math.round(n)+h*u+d*c,m=new Float64Array(a);if(t.O(m,m,[p>.5?p-1:p,f>.5?f-1:f,0]),this._alignedProjMatrix=m,a=t.aA(new Float64Array(16),this._pixelMatrix),!a)throw new Error("failed to invert matrix");this._pixelMatrixInverse=a,this._clearMatrixCaches()}_clearMatrixCaches(){this._posMatrixCache.clear(),this._alignedPosMatrixCache.clear(),this._fogMatrixCacheF32.clear()}maxPitchScaleFactor(){if(!this._pixelMatrixInverse)return 1;const e=this.screenPointToMercatorCoordinate(new t.P(0,0)),i=[e.x*this.worldSize,e.y*this.worldSize,0,1];return t.aG(i,i,this._pixelMatrix)[3]/this._helper.cameraToCenterDistance}getCameraPoint(){return this._helper.getCameraPoint()}getCameraAltitude(){return this._helper.getCameraAltitude()}getCameraLngLat(){const e=t.as(1,this.center.lat)*this.worldSize;return ye(this.center,this.elevation,this.pitch,this.bearing,this._helper.cameraToCenterDistance/e).toLngLat()}lngLatToCameraDepth(e,i){const r=t.aa.fromLngLat(e),n=[r.x*this.worldSize,r.y*this.worldSize,i,1];return t.aG(n,n,this._viewProjMatrix),n[2]/n[3]}getProjectionData(e){const{overscaledTileID:i,aligned:r,applyTerrainMatrix:n}=e,o=this._helper.getMercatorTileCoordinates(i),s=i?this.calculatePosMatrix(i,r,!0):null;let a;return a=i&&i.terrainRttPosMatrix32f&&n?i.terrainRttPosMatrix32f:s||t.bh(),{mainMatrix:a,tileMercatorCoords:o,clippingPlane:[0,0,0,0],projectionTransition:0,fallbackMatrix:a}}isLocationOccluded(e){return!1}getPixelScale(){return 1}getCircleRadiusCorrection(){return 1}getPitchedTextCorrection(e,t,i){return 1}transformLightDirection(e){return t.b0(e)}getRayDirectionFromPixel(e){throw new Error("Not implemented.")}projectTileCoordinates(e,i,r,n){const o=this.calculatePosMatrix(r);let s;n?(s=[e,i,n(e,i),1],t.aG(s,s,o)):(s=[e,i,0,1],Ye(s,s,o));const a=s[3];return{point:new t.P(s[0]/a,s[1]/a),signedDistanceFromCamera:a,isOccluded:!1}}populateCache(e){for(const t of e)this.calculatePosMatrix(t)}getMatrixForModel(e,i){const r=t.aa.fromLngLat(e,i),n=r.meterInMercatorCoordinateUnits(),o=t.bi();return t.O(o,o,[r.x,r.y,r.z]),t.bf(o,o,Math.PI),t.bg(o,o,Math.PI/2),t.Q(o,o,[-n,n,n]),o}getProjectionDataForCustomLayer(e=!0){const i=new t.a1(0,0,0,0,0),r=this.getProjectionData({overscaledTileID:i,applyGlobeMatrix:e}),n=Ae(i,this.worldSize);t.S(n,this._viewProjMatrix,n),r.tileMercatorCoords=[0,0,1,1];const o=[t.a4,t.a4,this.worldSize/this._helper.pixelsPerMeter],s=t.bj();return t.Q(s,n,o),r.fallbackMatrix=s,r.mainMatrix=s,r}getFastPathSimpleProjectionMatrix(e){return this.calculatePosMatrix(e)}}function jt(){t.w("Map cannot fit within canvas with the given bounds, padding, and/or offset.")}function Gt(e){if(e.useSlerp)if(e.k<1){const i=t.bk(e.startEulerAngles.roll,e.startEulerAngles.pitch,e.startEulerAngles.bearing),r=t.bk(e.endEulerAngles.roll,e.endEulerAngles.pitch,e.endEulerAngles.bearing),n=new Float64Array(4);t.bl(n,i,r,e.k);const o=t.bm(n);e.tr.setRoll(o.roll),e.tr.setPitch(o.pitch),e.tr.setBearing(o.bearing)}else e.tr.setRoll(e.endEulerAngles.roll),e.tr.setPitch(e.endEulerAngles.pitch),e.tr.setBearing(e.endEulerAngles.bearing);else e.tr.setRoll(t.G.number(e.startEulerAngles.roll,e.endEulerAngles.roll,e.k)),e.tr.setPitch(t.G.number(e.startEulerAngles.pitch,e.endEulerAngles.pitch,e.k)),e.tr.setBearing(t.G.number(e.startEulerAngles.bearing,e.endEulerAngles.bearing,e.k))}function Ht(e,i,r,n,o){const s=o.padding,a=me(o.worldSize,r.getNorthWest()),l=me(o.worldSize,r.getNorthEast()),c=me(o.worldSize,r.getSouthEast()),u=me(o.worldSize,r.getSouthWest()),h=t.ap(-n),d=a.rotate(h),p=l.rotate(h),f=c.rotate(h),m=u.rotate(h),g=new t.P(Math.max(d.x,p.x,m.x,f.x),Math.max(d.y,p.y,m.y,f.y)),_=new t.P(Math.min(d.x,p.x,m.x,f.x),Math.min(d.y,p.y,m.y,f.y)),A=g.sub(_),y=(o.width-(s.left+s.right+i.left+i.right))/A.x,v=(o.height-(s.top+s.bottom+i.top+i.bottom))/A.y;if(v<0||y<0)return void jt();const x=Math.min(t.at(o.scale*Math.min(y,v)),e.maxZoom),b=t.P.convert(e.offset),w=new t.P((i.left-i.right)/2,(i.top-i.bottom)/2).rotate(t.ap(n)),T=b.add(w).mult(o.scale/t.aq(x));return{center:ge(o.worldSize,a.add(c).div(2).sub(T)),zoom:x,bearing:n}}class Qt{get useGlobeControls(){return!1}handlePanInertia(e,t){const i=e.mag(),r=Math.abs(_e(t));return{easingOffset:e.mult(Math.min(.75*r/i,1)),easingCenter:t.center}}handleMapControlsRollPitchBearingZoom(e,t){e.bearingDelta&&t.setBearing(t.bearing+e.bearingDelta),e.pitchDelta&&t.setPitch(t.pitch+e.pitchDelta),e.rollDelta&&t.setRoll(t.roll+e.rollDelta),e.zoomDelta&&t.setZoom(t.zoom+e.zoomDelta)}handleMapControlsPan(e,t,i){e.around.distSqr(t.centerPoint)<.01||t.setLocationAtPoint(i,e.around)}cameraForBoxAndBearing(e,t,i,r,n){return Ht(e,t,i,r,n)}handleJumpToCenterZoom(e,i){e.zoom!==(void 0!==i.zoom?+i.zoom:e.zoom)&&e.setZoom(+i.zoom),void 0!==i.center&&e.setCenter(t.V.convert(i.center))}handleEaseTo(e,i){const r=e.zoom,n=e.padding,o={roll:e.roll,pitch:e.pitch,bearing:e.bearing},s={roll:void 0===i.roll?e.roll:i.roll,pitch:void 0===i.pitch?e.pitch:i.pitch,bearing:void 0===i.bearing?e.bearing:i.bearing},a=void 0!==i.zoom,l=!e.isPaddingEqual(i.padding);let c=!1;const u=a?+i.zoom:e.zoom;let h=e.centerPoint.add(i.offsetAsPoint);const d=e.screenPointToLocation(h),{center:p,zoom:f}=e.applyConstrain(t.V.convert(i.center||d),null!=u?u:r);kt(e,p);const m=me(e.worldSize,d),g=me(e.worldSize,p).sub(m),_=t.aq(f-r);return c=f!==r,{easeFunc:a=>{if(c&&e.setZoom(t.G.number(r,f,a)),t.bn(o,s)||Gt({startEulerAngles:o,endEulerAngles:s,tr:e,k:a,useSlerp:o.roll!=s.roll}),l&&(e.interpolatePadding(n,i.padding,a),h=e.centerPoint.add(i.offsetAsPoint)),i.around)e.setLocationAtPoint(i.around,i.aroundPoint);else{const i=t.aq(e.zoom-r),n=f>r?Math.min(2,_):Math.max(.5,_),o=Math.pow(n,1-a),s=ge(e.worldSize,m.add(g.mult(a*o)).mult(i));e.setLocationAtPoint(e.renderWorldCopies?s.wrap():s,h)}},isZooming:c,elevationCenter:p}}handleFlyTo(e,i){const r=void 0!==i.zoom,n=e.zoom,o=e.applyConstrain(t.V.convert(i.center||i.locationAtOffset),r?+i.zoom:n),s=o.center,a=o.zoom;kt(e,s);const l=me(e.worldSize,i.locationAtOffset),c=me(e.worldSize,s).sub(l),u=c.mag(),h=t.aq(a-n);let d;if(void 0!==i.minZoom){const r=Math.min(+i.minZoom,n,a),o=e.applyConstrain(s,r).zoom;d=t.aq(o-n)}return{easeFunc:(i,r,o,u)=>{e.setZoom(1===i?a:n+t.at(r));const h=1===i?s:ge(e.worldSize,l.add(c.mult(o)).mult(r));e.setLocationAtPoint(e.renderWorldCopies?h.wrap():h,u)},scaleOfZoom:h,targetCenter:s,scaleOfMinZoom:d,pixelPathLength:u}}}class $t{constructor(e,t,i){this.blendFunction=e,this.blendColor=t,this.mask=i}}$t.Replace=[1,0],$t.disabled=new $t($t.Replace,t.bo.transparent,[!1,!1,!1,!1]),$t.unblended=new $t($t.Replace,t.bo.transparent,[!0,!0,!0,!0]),$t.alphaBlended=new $t([1,771],t.bo.transparent,[!0,!0,!0,!0]);const Zt=2305;class Wt{constructor(e,t,i){this.enable=e,this.mode=t,this.frontFace=i}}Wt.disabled=new Wt(!1,1029,Zt),Wt.backCCW=new Wt(!0,1029,Zt),Wt.frontCCW=new Wt(!0,1028,Zt);class qt{constructor(e,t,i){this.func=e,this.mask=t,this.range=i}}qt.ReadOnly=!1,qt.ReadWrite=!0,qt.disabled=new qt(519,qt.ReadOnly,[0,1]);const Kt=7680;class Xt{constructor(e,t,i,r,n,o){this.test=e,this.ref=t,this.mask=i,this.fail=r,this.depthFail=n,this.pass=o}}Xt.disabled=new Xt({func:519,mask:0},0,0,Kt,Kt,Kt);const Jt=new WeakMap;function Yt(e){var t;if(Jt.has(e))return Jt.get(e);{const i=null===(t=e.getParameter(e.VERSION))||void 0===t?void 0:t.startsWith("WebGL 2.0");return Jt.set(e,i),i}}class ei{get awaitingQuery(){return!!this._readbackQueue}constructor(e){this._readbackWaitFrames=4,this._measureWaitFrames=6,this._texWidth=1,this._texHeight=1,this._measuredError=0,this._updateCount=0,this._lastReadbackFrame=-1e3,this._readbackQueue=null,this._cachedRenderContext=e;const i=e.context,r=i.gl;this._texFormat=r.RGBA,this._texType=r.UNSIGNED_BYTE;const n=new t.aV;n.emplaceBack(-1,-1),n.emplaceBack(2,-1),n.emplaceBack(-1,2);const o=new t.aX;o.emplaceBack(0,1,2),this._fullscreenTriangle=new It(i.createVertexBuffer(n,Mt.members),i.createIndexBuffer(o),t.aW.simpleSegment(0,0,n.length,o.length)),this._resultBuffer=new Uint8Array(4),i.activeTexture.set(r.TEXTURE1);const s=r.createTexture();r.bindTexture(r.TEXTURE_2D,s),r.texParameteri(r.TEXTURE_2D,r.TEXTURE_WRAP_S,r.CLAMP_TO_EDGE),r.texParameteri(r.TEXTURE_2D,r.TEXTURE_WRAP_T,r.CLAMP_TO_EDGE),r.texParameteri(r.TEXTURE_2D,r.TEXTURE_MIN_FILTER,r.NEAREST),r.texParameteri(r.TEXTURE_2D,r.TEXTURE_MAG_FILTER,r.NEAREST),r.texImage2D(r.TEXTURE_2D,0,this._texFormat,this._texWidth,this._texHeight,0,this._texFormat,this._texType,null),this._fbo=i.createFramebuffer(this._texWidth,this._texHeight,!1,!1),this._fbo.colorAttachment.set(s),Yt(r)&&(this._pbo=r.createBuffer(),r.bindBuffer(r.PIXEL_PACK_BUFFER,this._pbo),r.bufferData(r.PIXEL_PACK_BUFFER,4,r.STREAM_READ),r.bindBuffer(r.PIXEL_PACK_BUFFER,null))}destroy(){const e=this._cachedRenderContext.context.gl;this._fullscreenTriangle.destroy(),this._fbo.destroy(),e.deleteBuffer(this._pbo),this._fullscreenTriangle=null,this._fbo=null,this._pbo=null,this._resultBuffer=null}updateErrorLoop(e,t){const i=this._updateCount;return this._readbackQueue?i>=this._readbackQueue.frameNumberIssued+this._readbackWaitFrames&&this._tryReadback():i>=this._lastReadbackFrame+this._measureWaitFrames&&this._renderErrorTexture(e,t),this._updateCount++,this._measuredError}_bindFramebuffer(){const e=this._cachedRenderContext.context,t=e.gl;e.activeTexture.set(t.TEXTURE1),t.bindTexture(t.TEXTURE_2D,this._fbo.colorAttachment.get()),e.bindFramebuffer.set(this._fbo.framebuffer)}_renderErrorTexture(e,i){const r=this._cachedRenderContext.context,n=r.gl;if(this._bindFramebuffer(),r.viewport.set([0,0,this._texWidth,this._texHeight]),r.clear({color:t.bo.transparent}),this._cachedRenderContext.useProgram("projectionErrorMeasurement").draw(r,n.TRIANGLES,qt.disabled,Xt.disabled,$t.unblended,Wt.disabled,((e,t)=>({u_input:e,u_output_expected:t}))(e,i),null,null,"$clipping",this._fullscreenTriangle.vertexBuffer,this._fullscreenTriangle.indexBuffer,this._fullscreenTriangle.segments),this._pbo&&Yt(n)){n.bindBuffer(n.PIXEL_PACK_BUFFER,this._pbo),n.readBuffer(n.COLOR_ATTACHMENT0),n.readPixels(0,0,this._texWidth,this._texHeight,this._texFormat,this._texType,0),n.bindBuffer(n.PIXEL_PACK_BUFFER,null);const e=n.fenceSync(n.SYNC_GPU_COMMANDS_COMPLETE,0);n.flush(),this._readbackQueue={frameNumberIssued:this._updateCount,sync:e}}else this._readbackQueue={frameNumberIssued:this._updateCount,sync:null}}_tryReadback(){const e=this._cachedRenderContext.context.gl;if(this._pbo&&this._readbackQueue&&Yt(e)){const i=e.clientWaitSync(this._readbackQueue.sync,0,0);if(i===e.WAIT_FAILED)return t.w("WebGL2 clientWaitSync failed."),this._readbackQueue=null,void(this._lastReadbackFrame=this._updateCount);if(i===e.TIMEOUT_EXPIRED)return;e.bindBuffer(e.PIXEL_PACK_BUFFER,this._pbo),e.getBufferSubData(e.PIXEL_PACK_BUFFER,0,this._resultBuffer,0,4),e.bindBuffer(e.PIXEL_PACK_BUFFER,null)}else this._bindFramebuffer(),e.readPixels(0,0,this._texWidth,this._texHeight,this._texFormat,this._texType,this._resultBuffer);this._readbackQueue=null,this._measuredError=ei._parseRGBA8float(this._resultBuffer),this._lastReadbackFrame=this._updateCount}static _parseRGBA8float(e){let t=0;return t+=e[0]/256,t+=e[1]/65536,t+=e[2]/16777216,e[3]<127&&(t=-t),t/128}}const ti=t.a4/128;function ii(e,i){const r=void 0!==e.granularity?Math.max(e.granularity,1):1,n=r+(e.generateBorders?2:0),o=r+(e.extendToNorthPole||e.generateBorders?1:0)+(e.extendToSouthPole||e.generateBorders?1:0),s=n+1,a=o+1,l=e.generateBorders?-1:0,c=e.generateBorders||e.extendToNorthPole?-1:0,u=r+(e.generateBorders?1:0),h=r+(e.generateBorders||e.extendToSouthPole?1:0),d=s*a,p=n*o*6,f=s*a>65536;if(f&&"16bit"===i)throw new Error("Granularity is too large and meshes would not fit inside 16 bit vertex indices.");const m=f||"32bit"===i,g=new Int16Array(2*d);let _=0;for(let i=c;i<=h;i++)for(let n=l;n<=u;n++){let o=n/r*t.a4;-1===n&&(o=-ti),n===r+1&&(o=t.a4+ti);let s=i/r*t.a4;-1===i&&(s=e.extendToNorthPole?t.bq:-ti),i===r+1&&(s=e.extendToSouthPole?t.br:t.a4+ti),g[_++]=o,g[_++]=s}const A=m?new Uint32Array(p):new Uint16Array(p);let y=0;for(let e=0;e0}get latitudeErrorCorrectionRadians(){return this._verticalPerspectiveProjection.latitudeErrorCorrectionRadians}get currentProjection(){return this.useGlobeRendering?this._verticalPerspectiveProjection:this._mercatorProjection}get name(){return"globe"}get useSubdivision(){return this.currentProjection.useSubdivision}get shaderVariantName(){return this.currentProjection.shaderVariantName}get shaderDefine(){return this.currentProjection.shaderDefine}get shaderPreludeCode(){return this.currentProjection.shaderPreludeCode}get vertexShaderPreludeCode(){return this.currentProjection.vertexShaderPreludeCode}get subdivisionGranularity(){return this.currentProjection.subdivisionGranularity}get useGlobeControls(){return this.transitionState>0}destroy(){this._mercatorProjection.destroy(),this._verticalPerspectiveProjection.destroy()}updateGPUdependent(e){this._mercatorProjection.updateGPUdependent(e),this._verticalPerspectiveProjection.updateGPUdependent(e)}getMeshFromTileID(e,t,i,r,n){return this.currentProjection.getMeshFromTileID(e,t,i,r,n)}setProjection(e){this._transitionable.setValue("type",(null==e?void 0:e.type)||"mercator")}updateTransitions(e){this._transitioning=this._transitionable.transitioned(e,this._transitioning)}hasTransition(){return this._transitioning.hasTransition()||this.currentProjection.hasTransition()}recalculate(e){this.properties=this._transitioning.possiblyEvaluate(e)}setErrorQueryLatitudeDegrees(e){this._verticalPerspectiveProjection.setErrorQueryLatitudeDegrees(e),this._mercatorProjection.setErrorQueryLatitudeDegrees(e)}}function ai(e){const t=ui(e.worldSize,e.center.lat);return 2*Math.PI*t}function li(e,i,r,n,o){const s=1/(1<1e-6){const n=e[0]/r,o=Math.acos(e[2]/r),s=(n>0?o:-o)/Math.PI*180;return new t.V(t.W(s,-180,180),i)}return new t.V(0,i)}function di(e){return Math.cos(e*Math.PI/180)}function pi(e,i){const r=di(e),n=di(i);return t.at(n/r)}function fi(e,i){const r=e.rotate(i.bearingInRadians),n=i.zoom+pi(i.center.lat,0),o=t.bt(1/di(i.center.lat),1/di(Math.min(Math.abs(i.center.lat),60)),t.bw(n,7,3,0,1)),s=360/ai({worldSize:i.worldSize,center:{lat:i.center.lat}});return new t.V(i.center.lng-r.x*s*o,t.an(i.center.lat+r.y*s,-t.ao,t.ao))}function mi(e){const t=.5*e,i=Math.sin(t),r=Math.cos(t);return Math.log(i+r)-Math.log(r-i)}function gi(e,i,r,n){const o=e.lat+r*n;if(Math.abs(r)>1){const s=(Math.sign(e.lat+r)!==Math.sign(e.lat)?-Math.abs(e.lat):Math.abs(e.lat))*Math.PI/180,a=Math.abs(e.lat+r)*Math.PI/180,l=mi(s+n*(a-s)),c=mi(s),u=mi(a);return new t.V(e.lng+i*((l-c)/(u-c)),o)}return new t.V(e.lng+i*n,o)}class _i{constructor(e){this._cachePrevious=new Map,this._cache=new Map,this._hadAnyChanges=!1,this._boundingVolumeFactory=e}swapBuffers(){if(!this._hadAnyChanges)return;const e=this._cachePrevious;this._cachePrevious=this._cache,this._cache=e,this._cache.clear(),this._hadAnyChanges=!1}getTileBoundingVolume(e,t,i,r){const n=`${e.z}_${e.x}_${e.y}_${(null==r?void 0:r.terrain)?"t":""}`,o=this._cache.get(n);if(o)return o;const s=this._cachePrevious.get(n);if(s)return this._cache.set(n,s),s;const a=this._boundingVolumeFactory(e,t,i,r);return this._cache.set(n,a),this._hadAnyChanges=!0,a}}class Ai{constructor(e,t,i,r){this.min=i,this.max=r,this.points=e,this.planes=t}static fromAabb(e,t){const i=[];for(let r=0;r<8;r++)i.push([1&~r?e[0]:t[0],1==(r>>1&1)?t[1]:e[1],1==(r>>2&1)?t[2]:e[2]]);return new Ai(i,[[-1,0,0,t[0]],[1,0,0,-e[0]],[0,-1,0,t[1]],[0,1,0,-e[1]],[0,0,-1,t[2]],[0,0,1,-e[2]]],e,t)}static fromCenterSizeAngles(e,i,r){const n=t.bA([],r[0],r[1],r[2]),o=t.bB([],[i[0],0,0],n),s=t.bB([],[0,i[1],0],n),a=t.bB([],[0,0,i[2]],n),l=[...e],c=[...e];for(let t=0;t<8;t++)for(let i=0;i<3;i++){const r=e[i]+o[i]*(1&~t?-1:1)+s[i]*(1==(t>>1&1)?1:-1)+a[i]*(1==(t>>2&1)?1:-1);l[i]=Math.min(l[i],r),c[i]=Math.max(c[i],r)}const u=[];for(let i=0;i<8;i++){const r=[...e];t.a$(r,r,t.a_([],o,1&~i?-1:1)),t.a$(r,r,t.a_([],s,1==(i>>1&1)?1:-1)),t.a$(r,r,t.a_([],a,1==(i>>2&1)?1:-1)),u.push(r)}return new Ai(u,[[...o,-t.b4(o,u[0])],[...s,-t.b4(s,u[0])],[...a,-t.b4(a,u[0])],[-o[0],-o[1],-o[2],-t.b4(o,u[7])],[-s[0],-s[1],-s[2],-t.b4(s,u[7])],[-a[0],-a[1],-a[2],-t.b4(a,u[7])]],l,c)}intersectsFrustum(e){let t=!0;const i=this.points.length,r=this.planes.length,n=e.planes.length,o=e.points.length;for(let r=0;r=0&&o++}if(0===o)return 0;o=0&&r++}if(0===r)return 0}return 1}intersectsPlane(e){const t=this.points.length;let i=0;for(let r=0;r=0&&i++}return i===t?2:0===i?0:1}}function yi(e,t,i){const r=e-t;return r<0?-r:Math.max(0,r-i)}function vi(e,t,i,r,n){const o=e-i;let s;return s=o<0?Math.min(-o,1+o-n):o>1?Math.min(Math.max(o-n,0),1-o):0,Math.max(s,yi(t,r,n))}class xi{constructor(){this._boundingVolumeCache=new _i(this._computeTileBoundingVolume)}prepareNextFrame(){this._boundingVolumeCache.swapBuffers()}distanceToTile2d(e,t,i,r){const n=1<4}allowWorldCopies(){return!1}getTileBoundingVolume(e,t,i,r){return this._boundingVolumeCache.getTileBoundingVolume(e,t,i,r)}_computeTileBoundingVolume(e,i,r,n){var o,s;let a=0,l=0;if(null==n?void 0:n.terrain){const c=new t.a1(e.z,i,e.z,e.x,e.y),u=n.terrain.getMinMaxElevation(c);a=null!==(o=u.minElevation)&&void 0!==o?o:Math.min(0,r),l=null!==(s=u.maxElevation)&&void 0!==s?s:Math.max(0,r)}if(a/=t.bD,l/=t.bD,a+=1,l+=1,e.z<=0)return Ai.fromAabb([-l,-l,-l],[l,l,l]);if(1===e.z)return Ai.fromAabb([0===e.x?-l:0,0===e.y?0:-l,-l],[0===e.x?0:l,0===e.y?l:0,l]);{const i=[li(0,0,e.x,e.y,e.z),li(t.a4,0,e.x,e.y,e.z),li(t.a4,t.a4,e.x,e.y,e.z),li(0,t.a4,e.x,e.y,e.z)],r=[];for(const e of i)r.push(t.a_([],e,l));if(l!==a)for(const e of i)r.push(t.a_([],e,a));0===e.y&&r.push([0,1,0]),e.y===(1<=(1<{const r=t.an(e.lat,-t.ao,t.ao),n=t.an(+i,this.minZoom+pi(0,r),this.maxZoom);return{center:new t.V(e.lng,r),zoom:n}},this.applyConstrain=(e,t)=>this._helper.applyConstrain(e,t),this._helper=new Ot({calcMatrices:()=>{this._calcMatrices()},defaultConstrain:(e,t)=>this.defaultConstrain(e,t)},e),this._coveringTilesDetailsProvider=new xi}clone(){const e=new wi;return e.apply(this),e}apply(e,t){this._globeLatitudeErrorCorrectionRadians=t||0,this._helper.apply(e)}get projectionMatrix(){return this._projectionMatrix}get modelViewProjectionMatrix(){return this._globeViewProjMatrixNoCorrection}get inverseProjectionMatrix(){return this._globeProjMatrixInverted}get cameraPosition(){const e=t.by();return e[0]=this._cameraPosition[0],e[1]=this._cameraPosition[1],e[2]=this._cameraPosition[2],e}get cameraToCenterDistance(){return this._helper.cameraToCenterDistance}getProjectionData(e){const{overscaledTileID:t,applyGlobeMatrix:i}=e,r=this._helper.getMercatorTileCoordinates(t);return{mainMatrix:this._globeViewProjMatrix32f,tileMercatorCoords:r,clippingPlane:this._cachedClippingPlane,projectionTransition:i?1:0,fallbackMatrix:this._globeViewProjMatrix32f}}_computeClippingPlane(e){const i=this.pitchInRadians,r=this.cameraToCenterDistance/e,n=Math.sin(i)*r,o=Math.cos(i)*r+1,s=1/Math.sqrt(n*n+o*o)*1;let a=-n,l=o;const c=Math.sqrt(a*a+l*l);a/=c,l/=c;const u=[0,a,l];t.bF(u,u,[0,0,0],-this.bearingInRadians),t.bG(u,u,[0,0,0],-1*this.center.lat*Math.PI/180),t.bH(u,u,[0,0,0],this.center.lng*Math.PI/180);const h=1/t.b6(u);return t.a_(u,u,h),[...u,-s*h]}isLocationOccluded(e){return!this.isSurfacePointVisible(ci(e))}transformLightDirection(e){const i=this._helper._center.lng*Math.PI/180,r=this._helper._center.lat*Math.PI/180,n=Math.cos(r),o=[Math.sin(i)*n,Math.sin(r),Math.cos(i)*n],s=[o[2],0,-o[0]],a=[0,0,0];t.b3(a,s,o),t.b2(s,s),t.b2(a,a);const l=[0,0,0];return t.b2(l,[s[0]*e[0]+a[0]*e[1]+o[0]*e[2],s[1]*e[0]+a[1]*e[1]+o[1]*e[2],s[2]*e[0]+a[2]*e[1]+o[2]*e[2]]),l}getPixelScale(){return 1/Math.cos(this._helper._center.lat*Math.PI/180)}getCircleRadiusCorrection(){return Math.cos(this._helper._center.lat*Math.PI/180)}getPitchedTextCorrection(e,i,r){const n=function(e,i,r){const n=1/(1<o&&(o=i),ra&&(a=r)}const u=[c.lng+s,c.lat+l,c.lng+o,c.lat+a];return this.isSurfacePointOnScreen([0,1,0])&&(u[3]=90,u[0]=-180,u[2]=180),this.isSurfacePointOnScreen([0,-1,0])&&(u[1]=-90,u[0]=-180,u[2]=180),new Z(u)}calculateCenterFromCameraLngLatAlt(e,t,i,r){return this._helper.calculateCenterFromCameraLngLatAlt(e,t,i,r)}setLocationAtPoint(e,i){const r=ci(this.unprojectScreenPoint(i)),n=ci(e),o=t.by();t.bK(o);const s=t.by();t.bH(s,r,o,-this.center.lng*Math.PI/180),t.bG(s,s,o,this.center.lat*Math.PI/180);const a=n[0]*n[0]+n[2]*n[2],l=s[0]*s[0];if(a=-_&&f<=_,y=g>=-_&&g<=_;let v,x;if(A&&y){const e=this.center.lng*Math.PI/180,i=this.center.lat*Math.PI/180;t.bM(h,e)+t.bM(f,i)=0}isSurfacePointOnScreen(e){if(!this.isSurfacePointVisible(e))return!1;const i=t.bE();return t.aG(i,[...e,1],this._globeViewProjMatrixNoCorrection),i[0]/=i[3],i[1]/=i[3],i[2]/=i[3],i[0]>-1&&i[0]<1&&i[1]>-1&&i[1]<1&&i[2]>-1&&i[2]<1}rayPlanetIntersection(e,i){const r=t.b4(e,i),n=t.by(),o=t.by();t.a_(o,i,r),t.b1(n,e,o);const s=1-t.b4(n,n);if(s<0)return null;const a=t.b4(e,e)-1,l=-r+(r<0?1:-1)*Math.sqrt(s),c=a/l,u=l;return{tMin:Math.min(c,u),tMax:Math.max(c,u)}}unprojectScreenPoint(e){const i=this._cameraPosition,r=this.getRayDirectionFromPixel(e),n=this.rayPlanetIntersection(i,r);if(n){const e=t.by();t.a$(e,i,[r[0]*n.tMin,r[1]*n.tMin,r[2]*n.tMin]);const o=t.by();return t.b2(o,e),hi(o)}const o=this._cachedClippingPlane,s=o[0]*r[0]+o[1]*r[1]+o[2]*r[2],a=-t.ba(o,i)/s,l=t.by();if(a>0)t.a$(l,i,[r[0]*a,r[1]*a,r[2]*a]);else{const e=t.by();t.a$(e,i,[2*r[0],2*r[1],2*r[2]]);const n=t.ba(this._cachedClippingPlane,e);t.b1(l,e,[this._cachedClippingPlane[0]*n,this._cachedClippingPlane[1]*n,this._cachedClippingPlane[2]*n])}const c=function(e){const i=t.by();return i[0]=e[0]*-e[3],i[1]=e[1]*-e[3],i[2]=e[2]*-e[3],{center:i,radius:Math.sqrt(1-e[3]*e[3])}}(o);return hi(function(e,i,r){const n=t.by();t.b1(n,r,e);const o=t.by();return t.bz(o,e,n,i/t.b8(n)),o}(c.center,c.radius,l))}getMatrixForModel(e,i){const r=t.V.convert(e),n=1/t.bD,o=t.bi();return t.bI(o,o,r.lng/180*Math.PI),t.bg(o,o,-r.lat/180*Math.PI),t.O(o,o,[0,0,1+i/t.bD]),t.bg(o,o,.5*Math.PI),t.Q(o,o,[n,n,n]),o}getProjectionDataForCustomLayer(e=!0){const i=this.getProjectionData({overscaledTileID:new t.a1(0,0,0,0,0),applyGlobeMatrix:e});return i.tileMercatorCoords=[0,0,1,1],i}getFastPathSimpleProjectionMatrix(e){}}class Ti{get pixelsToClipSpaceMatrix(){return this._helper.pixelsToClipSpaceMatrix}get clipSpaceToPixelsMatrix(){return this._helper.clipSpaceToPixelsMatrix}get pixelsToGLUnits(){return this._helper.pixelsToGLUnits}get centerOffset(){return this._helper.centerOffset}get size(){return this._helper.size}get rotationMatrix(){return this._helper.rotationMatrix}get centerPoint(){return this._helper.centerPoint}get pixelsPerMeter(){return this._helper.pixelsPerMeter}setMinZoom(e){this._helper.setMinZoom(e)}setMaxZoom(e){this._helper.setMaxZoom(e)}setMinPitch(e){this._helper.setMinPitch(e)}setMaxPitch(e){this._helper.setMaxPitch(e)}setRenderWorldCopies(e){this._helper.setRenderWorldCopies(e)}setBearing(e){this._helper.setBearing(e)}setPitch(e){this._helper.setPitch(e)}setRoll(e){this._helper.setRoll(e)}setFov(e){this._helper.setFov(e)}setZoom(e){this._helper.setZoom(e)}setCenter(e){this._helper.setCenter(e)}setElevation(e){this._helper.setElevation(e)}setMinElevationForCurrentTile(e){this._helper.setMinElevationForCurrentTile(e)}setPadding(e){this._helper.setPadding(e)}interpolatePadding(e,t,i){return this._helper.interpolatePadding(e,t,i)}isPaddingEqual(e){return this._helper.isPaddingEqual(e)}resize(e,t,i=!0){this._helper.resize(e,t,i)}getMaxBounds(){return this._helper.getMaxBounds()}setMaxBounds(e){this._helper.setMaxBounds(e)}setConstrainOverride(e){this._helper.setConstrainOverride(e)}overrideNearFarZ(e,t){this._helper.overrideNearFarZ(e,t)}clearNearFarZOverride(){this._helper.clearNearFarZOverride()}getCameraQueryGeometry(e){return this._helper.getCameraQueryGeometry(this.getCameraPoint(),e)}get tileSize(){return this._helper.tileSize}get tileZoom(){return this._helper.tileZoom}get scale(){return this._helper.scale}get worldSize(){return this._helper.worldSize}get width(){return this._helper.width}get height(){return this._helper.height}get lngRange(){return this._helper.lngRange}get latRange(){return this._helper.latRange}get minZoom(){return this._helper.minZoom}get maxZoom(){return this._helper.maxZoom}get zoom(){return this._helper.zoom}get center(){return this._helper.center}get minPitch(){return this._helper.minPitch}get maxPitch(){return this._helper.maxPitch}get pitch(){return this._helper.pitch}get pitchInRadians(){return this._helper.pitchInRadians}get roll(){return this._helper.roll}get rollInRadians(){return this._helper.rollInRadians}get bearing(){return this._helper.bearing}get bearingInRadians(){return this._helper.bearingInRadians}get fov(){return this._helper.fov}get fovInRadians(){return this._helper.fovInRadians}get elevation(){return this._helper.elevation}get minElevationForCurrentTile(){return this._helper.minElevationForCurrentTile}get padding(){return this._helper.padding}get unmodified(){return this._helper.unmodified}get renderWorldCopies(){return this._helper.renderWorldCopies}get cameraToCenterDistance(){return this._helper.cameraToCenterDistance}get constrainOverride(){return this._helper.constrainOverride}get nearZ(){return this._helper.nearZ}get farZ(){return this._helper.farZ}get autoCalculateNearFarZ(){return this._helper.autoCalculateNearFarZ}get isGlobeRendering(){return this._globeness>0}setTransitionState(e,t){this._globeness=e,this._globeLatitudeErrorCorrectionRadians=t,this._calcMatrices(),this._verticalPerspectiveTransform.getCoveringTilesDetailsProvider().prepareNextFrame(),this._mercatorTransform.getCoveringTilesDetailsProvider().prepareNextFrame()}get currentTransform(){return this.isGlobeRendering?this._verticalPerspectiveTransform:this._mercatorTransform}constructor(e){this._globeLatitudeErrorCorrectionRadians=0,this._globeness=1,this.defaultConstrain=(e,t)=>this.currentTransform.defaultConstrain(e,t),this.applyConstrain=(e,t)=>this._helper.applyConstrain(e,t),this._helper=new Ot({calcMatrices:()=>{this._calcMatrices()},defaultConstrain:(e,t)=>this.defaultConstrain(e,t)},e),this._globeness=1,this._mercatorTransform=new Vt,this._verticalPerspectiveTransform=new wi}clone(){const e=new Ti;return e._globeness=this._globeness,e._globeLatitudeErrorCorrectionRadians=this._globeLatitudeErrorCorrectionRadians,e.apply(this),e}apply(e){this._helper.apply(e),this._mercatorTransform.apply(this),this._verticalPerspectiveTransform.apply(this,this._globeLatitudeErrorCorrectionRadians)}get projectionMatrix(){return this.currentTransform.projectionMatrix}get modelViewProjectionMatrix(){return this.currentTransform.modelViewProjectionMatrix}get inverseProjectionMatrix(){return this.currentTransform.inverseProjectionMatrix}get cameraPosition(){return this.currentTransform.cameraPosition}getProjectionData(e){const t=this._mercatorTransform.getProjectionData(e),i=this._verticalPerspectiveTransform.getProjectionData(e);return{mainMatrix:this.isGlobeRendering?i.mainMatrix:t.mainMatrix,clippingPlane:i.clippingPlane,tileMercatorCoords:i.tileMercatorCoords,projectionTransition:e.applyGlobeMatrix?this._globeness:0,fallbackMatrix:t.fallbackMatrix}}isLocationOccluded(e){return this.currentTransform.isLocationOccluded(e)}transformLightDirection(e){return this.currentTransform.transformLightDirection(e)}getPixelScale(){return t.bt(this._mercatorTransform.getPixelScale(),this._verticalPerspectiveTransform.getPixelScale(),this._globeness)}getCircleRadiusCorrection(){return t.bt(this._mercatorTransform.getCircleRadiusCorrection(),this._verticalPerspectiveTransform.getCircleRadiusCorrection(),this._globeness)}getPitchedTextCorrection(e,i,r){const n=this._mercatorTransform.getPitchedTextCorrection(e,i,r),o=this._verticalPerspectiveTransform.getPitchedTextCorrection(e,i,r);return t.bt(n,o,this._globeness)}projectTileCoordinates(e,t,i,r){return this.currentTransform.projectTileCoordinates(e,t,i,r)}_calcMatrices(){this._helper._width&&this._helper._height&&(this._verticalPerspectiveTransform.apply(this,this._globeLatitudeErrorCorrectionRadians),this._helper._nearZ=this._verticalPerspectiveTransform.nearZ,this._helper._farZ=this._verticalPerspectiveTransform.farZ,this._mercatorTransform.apply(this,!0,this.isGlobeRendering),this._helper._nearZ=this._mercatorTransform.nearZ,this._helper._farZ=this._mercatorTransform.farZ)}calculateFogMatrix(e){return this.currentTransform.calculateFogMatrix(e)}getVisibleUnwrappedCoordinates(e){return this.currentTransform.getVisibleUnwrappedCoordinates(e)}getCameraFrustum(){return this.currentTransform.getCameraFrustum()}getClippingPlane(){return this.currentTransform.getClippingPlane()}getCoveringTilesDetailsProvider(){return this.currentTransform.getCoveringTilesDetailsProvider()}recalculateZoomAndCenter(e){this._mercatorTransform.recalculateZoomAndCenter(e),this._verticalPerspectiveTransform.recalculateZoomAndCenter(e)}maxPitchScaleFactor(){return this._mercatorTransform.maxPitchScaleFactor()}getCameraPoint(){return this._helper.getCameraPoint()}getCameraAltitude(){return this._helper.getCameraAltitude()}getCameraLngLat(){return this._helper.getCameraLngLat()}lngLatToCameraDepth(e,t){return this.currentTransform.lngLatToCameraDepth(e,t)}populateCache(e){this._mercatorTransform.populateCache(e),this._verticalPerspectiveTransform.populateCache(e)}getBounds(){return this.currentTransform.getBounds()}calculateCenterFromCameraLngLatAlt(e,t,i,r){return this._helper.calculateCenterFromCameraLngLatAlt(e,t,i,r)}setLocationAtPoint(e,t){if(!this.isGlobeRendering)return this._mercatorTransform.setLocationAtPoint(e,t),void this.apply(this._mercatorTransform);this._verticalPerspectiveTransform.setLocationAtPoint(e,t),this.apply(this._verticalPerspectiveTransform)}locationToScreenPoint(e,t){return this.currentTransform.locationToScreenPoint(e,t)}screenPointToMercatorCoordinate(e,t){return this.currentTransform.screenPointToMercatorCoordinate(e,t)}screenPointToLocation(e,t){return this.currentTransform.screenPointToLocation(e,t)}isPointOnMapSurface(e,t){return this.currentTransform.isPointOnMapSurface(e,t)}getRayDirectionFromPixel(e){return this._verticalPerspectiveTransform.getRayDirectionFromPixel(e)}getMatrixForModel(e,t){return this.currentTransform.getMatrixForModel(e,t)}getProjectionDataForCustomLayer(e=!0){const t=this._mercatorTransform.getProjectionDataForCustomLayer(e);if(!this.isGlobeRendering)return t;const i=this._verticalPerspectiveTransform.getProjectionDataForCustomLayer(e);return i.fallbackMatrix=t.mainMatrix,i}getFastPathSimpleProjectionMatrix(e){return this.currentTransform.getFastPathSimpleProjectionMatrix(e)}}class Ei{get useGlobeControls(){return!0}handlePanInertia(e,i){const r=fi(e,i);return Math.abs(r.lng-i.center.lng)>180&&(r.lng=i.center.lng+179.5*Math.sign(r.lng-i.center.lng)),{easingCenter:r,easingOffset:new t.P(0,0)}}handleMapControlsRollPitchBearingZoom(e,i){const r=e.around,n=i.screenPointToLocation(r);e.bearingDelta&&i.setBearing(i.bearing+e.bearingDelta),e.pitchDelta&&i.setPitch(i.pitch+e.pitchDelta),e.rollDelta&&i.setRoll(i.roll+e.rollDelta);const o=i.zoom;e.zoomDelta&&i.setZoom(i.zoom+e.zoomDelta);const s=i.zoom-o;if(0===s)return;const a=t.bJ(i.center.lng,n.lng),l=a/(Math.abs(a/180)+1),c=t.bJ(i.center.lat,n.lat),u=i.getRayDirectionFromPixel(r),h=i.cameraPosition,d=-1*t.b4(h,u),p=t.by();t.a$(p,h,[u[0]*d,u[1]*d,u[2]*d]);const f=t.b6(p)-1,m=Math.exp(.5*-Math.max(f-.3,0)),g=ui(i.worldSize,i.center.lat)/Math.min(i.width,i.height),_=t.bw(g,.9,.5,1,.25),A=(1-t.aq(-s))*Math.min(m,_),y=i.center.lat,v=i.zoom,x=new t.V(i.center.lng+l*A,t.an(i.center.lat+c*A,-t.ao,t.ao));i.setLocationAtPoint(n,r);const b=i.center,w=t.bw(Math.abs(a),45,85,0,1),T=t.bw(g,.75,.35,0,1),E=Math.pow(Math.max(w,T),.25),C=t.bJ(b.lng,x.lng),B=t.bJ(b.lat,x.lat);i.setCenter(new t.V(b.lng+C*E,b.lat+B*E).wrap()),i.setZoom(v+pi(y,i.center.lat))}handleMapControlsPan(e,t,i){if(!e.panDelta)return;const r=t.center.lat,n=t.zoom;t.setCenter(fi(e.panDelta,t).wrap()),t.setZoom(n+pi(r,t.center.lat))}cameraForBoxAndBearing(e,i,r,n,o){const s=Ht(e,i,r,n,o),a=i.left/o.width*2-1,l=(o.width-i.right)/o.width*2-1,c=i.top/o.height*-2+1,u=(o.height-i.bottom)/o.height*-2+1,h=t.bJ(r.getWest(),r.getEast())<0,d=h?r.getEast():r.getWest(),p=h?r.getWest():r.getEast(),f=Math.max(r.getNorth(),r.getSouth()),m=Math.min(r.getNorth(),r.getSouth()),g=d+.5*t.bJ(d,p),_=f+.5*t.bJ(f,m),A=o.clone();A.setCenter(s.center),A.setBearing(s.bearing),A.setPitch(0),A.setRoll(0),A.setZoom(s.zoom);const y=A.modelViewProjectionMatrix,v=[ci(r.getNorthWest()),ci(r.getNorthEast()),ci(r.getSouthWest()),ci(r.getSouthEast()),ci(new t.V(p,_)),ci(new t.V(d,_)),ci(new t.V(g,f)),ci(new t.V(g,m))],x=ci(s.center);let b=Number.POSITIVE_INFINITY;for(const e of v)a<0&&(b=Ei.getLesserNonNegativeNonNull(b,Ei.solveVectorScale(e,x,y,"x",a))),l>0&&(b=Ei.getLesserNonNegativeNonNull(b,Ei.solveVectorScale(e,x,y,"x",l))),c>0&&(b=Ei.getLesserNonNegativeNonNull(b,Ei.solveVectorScale(e,x,y,"y",c))),u<0&&(b=Ei.getLesserNonNegativeNonNull(b,Ei.solveVectorScale(e,x,y,"y",u)));if(Number.isFinite(b)&&0!==b)return s.zoom=A.zoom+t.at(b),s;jt()}handleJumpToCenterZoom(e,i){const r=e.center.lat,n=e.applyConstrain(i.center?t.V.convert(i.center):e.center,e.zoom).center;e.setCenter(n.wrap());const o=void 0!==i.zoom?+i.zoom:e.zoom+pi(r,n.lat);e.zoom!==o&&e.setZoom(o)}handleEaseTo(e,i){const r=e.zoom,n=e.center,o=e.padding,s={roll:e.roll,pitch:e.pitch,bearing:e.bearing},a={roll:void 0===i.roll?e.roll:i.roll,pitch:void 0===i.pitch?e.pitch:i.pitch,bearing:void 0===i.bearing?e.bearing:i.bearing},l=void 0!==i.zoom,c=!e.isPaddingEqual(i.padding);let u=!1;const h=i.center?t.V.convert(i.center):n,d=e.applyConstrain(h,r).center;kt(e,d);const p=e.clone();p.setCenter(d),p.setZoom(l?+i.zoom:r+pi(n.lat,h.lat)),p.setBearing(i.bearing);const f=new t.P(t.an(e.centerPoint.x+i.offsetAsPoint.x,0,e.width),t.an(e.centerPoint.y+i.offsetAsPoint.y,0,e.height));p.setLocationAtPoint(d,f);const m=(i.offset&&i.offsetAsPoint.mag())>0?p.center:d,g=l?+i.zoom:r+pi(n.lat,m.lat),_=r+pi(n.lat,0),A=g+pi(m.lat,0),y=t.bJ(n.lng,m.lng),v=t.bJ(n.lat,m.lat),x=t.aq(A-_);return u=g!==r,{easeFunc:r=>{if(t.bn(s,a)||Gt({startEulerAngles:s,endEulerAngles:a,tr:e,k:r,useSlerp:s.roll!=a.roll}),c&&e.interpolatePadding(o,i.padding,r),i.around)t.w("Easing around a point is not supported under globe projection."),e.setLocationAtPoint(i.around,i.aroundPoint);else{const t=A>_?Math.min(2,x):Math.max(.5,x),i=Math.pow(t,1-r),o=gi(n,y,v,r*i);e.setCenter(o.wrap())}if(u){const i=t.G.number(_,A,r)+pi(0,e.center.lat);e.setZoom(i)}},isZooming:u,elevationCenter:m}}handleFlyTo(e,i){const r=void 0!==i.zoom,n=e.center,o=e.zoom,s=e.padding,a=!e.isPaddingEqual(i.padding),l=e.applyConstrain(t.V.convert(i.center||i.locationAtOffset),o).center,c=r?+i.zoom:e.zoom+pi(e.center.lat,l.lat),u=e.clone();u.setCenter(l),u.setZoom(c),u.setBearing(i.bearing);const h=new t.P(t.an(e.centerPoint.x+i.offsetAsPoint.x,0,e.width),t.an(e.centerPoint.y+i.offsetAsPoint.y,0,e.height));u.setLocationAtPoint(l,h);const d=u.center;kt(e,d);const p=function(e,i,r){const n=ci(i),o=ci(r),s=t.b4(n,o),a=Math.acos(s),l=ai(e);return a/(2*Math.PI)*l}(e,n,d),f=o+pi(n.lat,0),m=c+pi(d.lat,0),g=t.aq(m-f);let _;if("number"==typeof i.minZoom){const r=+i.minZoom+pi(d.lat,0),n=Math.min(r,f,m)+pi(0,d.lat),o=e.applyConstrain(d,n).zoom+pi(d.lat,0);_=t.aq(o-f)}const A=t.bJ(n.lng,d.lng),y=t.bJ(n.lat,d.lat);return{easeFunc:(r,o,l,u)=>{const h=gi(n,A,y,l);a&&e.interpolatePadding(s,i.padding,r);const p=1===r?d:h;e.setCenter(p.wrap());const m=f+t.at(o);e.setZoom(1===r?c:m+pi(0,p.lat))},scaleOfZoom:g,targetCenter:d,scaleOfMinZoom:_,pixelPathLength:p}}static solveVectorScale(e,t,i,r,n){const o="x"===r?[i[0],i[4],i[8],i[12]]:[i[1],i[5],i[9],i[13]],s=[i[3],i[7],i[11],i[15]],a=e[0]*o[0]+e[1]*o[1]+e[2]*o[2],l=e[0]*s[0]+e[1]*s[1]+e[2]*s[2],c=t[0]*o[0]+t[1]*o[1]+t[2]*o[2],u=t[0]*s[0]+t[1]*s[1]+t[2]*s[2];return c+n*l===a+n*u||s[3]*(a-c)+o[3]*(u-l)+a*u==c*l?null:(c+o[3]-n*u-n*s[3])/(c-a-n*u+n*l)}static getLesserNonNegativeNonNull(e,t){return null!==t&&t>=0&&tt.B(e,i&&i.filter(e=>"source.canvas"!==e.identifier)),Si=t.bN();class Ii extends t.E{constructor(e,i={}){var r,n;super(),this._rtlPluginLoaded=()=>{for(const e in this.tileManagers){const t=this.tileManagers[e].getSource().type;"vector"!==t&&"geojson"!==t||this.tileManagers[e].reload()}},this.map=e,this.dispatcher=new N(U(),e._getMapId()),this.dispatcher.registerMessageHandler("GG",(e,t)=>this.getGlyphs(e,t)),this.dispatcher.registerMessageHandler("GI",(e,t)=>this.getImages(e,t)),this.dispatcher.registerMessageHandler("GDA",(e,t)=>this.getDashes(e,t)),this.imageManager=new b,this.imageManager.setEventedParent(this);const o=(null===(r=e._container)||void 0===r?void 0:r.lang)||"undefined"!=typeof document&&(null===(n=document.documentElement)||void 0===n?void 0:n.lang)||void 0;this.glyphManager=new B(e._requestManager,i.localIdeographFontFamily,o),this.lineAtlas=new L(256,512),this.crossTileSymbolIndex=new Et,this._setInitialValues(),this._resetUpdates(),this.dispatcher.broadcast("SR",t.bO()),ce().on(se,this._rtlPluginLoaded),this.on("data",e=>{if("source"!==e.dataType||"metadata"!==e.sourceDataType)return;const t=this.tileManagers[e.sourceId];if(!t)return;const i=t.getSource();if(i&&i.vectorLayerIds)for(const e in this._layers){const t=this._layers[e];t.source===i.id&&this._validateLayer(t)}})}_setInitialValues(){var e;this._spritesImagesIds={},this._layers={},this._order=[],this.tileManagers={},this.zoomHistory=new t.bP,this._availableImages=[],this._globalState={},this._serializedLayers={},this.stylesheet=null,this.light=null,this.sky=null,this.projection&&(this.projection.destroy(),delete this.projection),this._loaded=!1,this._changed=!1,this._updatedLayers={},this._updatedSources={},this._changedImages={},this._glyphsDidChange=!1,this._updatedPaintProps={},this._layerOrderChanged=!1,this.crossTileSymbolIndex=new((null===(e=this.crossTileSymbolIndex)||void 0===e?void 0:e.constructor)||Object),this.pauseablePlacement=void 0,this.placement=void 0,this.z=0}setGlobalStateProperty(e,i){var r,n,o;this._checkLoaded();const s=null===i?null!==(o=null===(n=null===(r=this.stylesheet.state)||void 0===r?void 0:r[e])||void 0===n?void 0:n.default)&&void 0!==o?o:null:i;if(t.bQ(s,this._globalState[e]))return this;this._globalState[e]=s,this._applyGlobalStateChanges([e])}getGlobalState(){return this._globalState}setGlobalState(e){this._checkLoaded();const i=[];for(const r in e)!t.bQ(this._globalState[r],e[r].default)&&(i.push(r),this._globalState[r]=e[r].default);this._applyGlobalStateChanges(i)}_applyGlobalStateChanges(e){if(0===e.length)return;const t=new Set,i={};for(const r of e){i[r]=this._globalState[r];for(const e in this._layers){const i=this._layers[e],n=i.getLayoutAffectingGlobalStateRefs(),o=i.getPaintAffectingGlobalStateRefs();if(n.has(r)&&t.add(i.source),o.has(r))for(const{name:e,value:t}of o.get(r))this._updatePaintProperty(i,e,t)}}this.dispatcher.broadcast("UGS",i);for(const e in this.tileManagers)t.has(e)&&(this._reloadSource(e),this._changed=!0)}loadURL(e,i={},r){this.fire(new t.l("dataloading",{dataType:"style"})),i.validate="boolean"!=typeof i.validate||i.validate;const n=this.map._requestManager.transformRequest(e,"Style");this._loadStyleRequest=new AbortController;const o=this._loadStyleRequest;t.j(n,this._loadStyleRequest).then(e=>{this._loadStyleRequest=null,this._load(e.data,i,r)}).catch(e=>{this._loadStyleRequest=null,e&&!o.signal.aborted&&this.fire(new t.k(e))})}loadJSON(e,i={},r){this.fire(new t.l("dataloading",{dataType:"style"})),this._frameRequest=new AbortController,a.frameAsync(this._frameRequest).then(()=>{this._frameRequest=null,i.validate=!1!==i.validate,this._load(e,i,r)}).catch(()=>{})}loadEmpty(){this.fire(new t.l("dataloading",{dataType:"style"})),this._load(Si,{validate:!1})}_load(e,i,r){var n,o;let s=i.transformStyle?i.transformStyle(r,e):e;if(!i.validate||!Bi(this,t.C(s))){s=Object.assign({},s),this._loaded=!0,this.stylesheet=s;for(const e in s.sources)this.addSource(e,s.sources[e],{validate:!1});s.sprite?this._loadSprite(s.sprite):this.imageManager.setLoaded(!0),this.glyphManager.setURL(s.glyphs),this._createLayers(),this.light=new M(this.stylesheet.light),this._setProjectionInternal((null===(n=this.stylesheet.projection)||void 0===n?void 0:n.type)||"mercator"),this.sky=new R(this.stylesheet.sky),this.map.setTerrain(null!==(o=this.stylesheet.terrain)&&void 0!==o?o:null),this.fire(new t.l("data",{dataType:"style"})),this.fire(new t.l("style.load"))}}_createLayers(){var e,i,r;const n=t.bR(this.stylesheet.layers);this.setGlobalState(null!==(e=this.stylesheet.state)&&void 0!==e?e:null),this.dispatcher.broadcast("SL",n),this._order=n.map(e=>e.id),this._layers={},this._serializedLayers=null;for(const e of n){const n=t.bS(e,this._globalState);if(n.setEventedParent(this,{layer:{id:e.id}}),this._layers[e.id]=n,t.bT(n)&&this.tileManagers[n.source]){const t=null!==(r=null===(i=e.paint)||void 0===i?void 0:i["raster-fade-duration"])&&void 0!==r?r:n.paint.get("raster-fade-duration");this.tileManagers[n.source].setRasterFadeDuration(t)}}}_loadSprite(e,i=!1,r=void 0){let n;this.imageManager.setLoaded(!1),this._spriteRequest=new AbortController,function(e,i,r,n){return t._(this,void 0,void 0,function*(){const o=y(e),s=r>1?"@2x":"",l={},c={};for(const{id:e,url:r}of o){const o=i.transformRequest(v(r,s,".json"),"SpriteJSON");l[e]=t.j(o,n);const a=i.transformRequest(v(r,s,".png"),"SpriteImage");c[e]=_.getImage(a,n)}return yield Promise.all([...Object.values(l),...Object.values(c)]),function(e,i){return t._(this,void 0,void 0,function*(){const t={};for(const r in e){t[r]={};const n=a.getImageCanvasContext((yield i[r]).data),o=(yield e[r]).data;for(const e in o){const{width:i,height:s,x:a,y:l,sdf:c,pixelRatio:u,stretchX:h,stretchY:d,content:p,textFitWidth:f,textFitHeight:m}=o[e];t[r][e]={data:null,pixelRatio:u,sdf:c,stretchX:h,stretchY:d,content:p,textFitWidth:f,textFitHeight:m,spriteData:{width:i,height:s,x:a,y:l,context:n}}}}return t})}(l,c)})}(e,this.map._requestManager,this.map.getPixelRatio(),this._spriteRequest).then(e=>{if(this._spriteRequest=null,e)for(const t in e){this._spritesImagesIds[t]=[];const r=this._spritesImagesIds[t]?this._spritesImagesIds[t].filter(t=>!(t in e)):[];for(const e of r)this.imageManager.removeImage(e),this._changedImages[e]=!0;for(const r in e[t]){const n="default"===t?r:`${t}:${r}`;this._spritesImagesIds[t].push(n),n in this.imageManager.images?this.imageManager.updateImage(n,e[t][r],!1):this.imageManager.addImage(n,e[t][r]),i&&(this._changedImages[n]=!0)}}}).catch(e=>{this._spriteRequest=null,n=e,this.fire(new t.k(n))}).finally(()=>{this.imageManager.setLoaded(!0),this._availableImages=this.imageManager.listImages(),i&&(this._changed=!0),this.dispatcher.broadcast("SI",this._availableImages),this.fire(new t.l("data",{dataType:"style"})),r&&r(n)})}_unloadSprite(){for(const e of Object.values(this._spritesImagesIds).flat())this.imageManager.removeImage(e),this._changedImages[e]=!0;this._spritesImagesIds={},this._availableImages=this.imageManager.listImages(),this._changed=!0,this.dispatcher.broadcast("SI",this._availableImages),this.fire(new t.l("data",{dataType:"style"}))}_validateLayer(e){const i=this.tileManagers[e.source];if(!i)return;const r=e.sourceLayer;if(!r)return;const n=i.getSource();("geojson"===n.type||n.vectorLayerIds&&-1===n.vectorLayerIds.indexOf(r))&&this.fire(new t.k(new Error(`Source layer "${r}" does not exist on source "${n.id}" as specified by style layer "${e.id}".`)))}loaded(){if(!this._loaded)return!1;if(Object.keys(this._updatedSources).length)return!1;for(const e in this.tileManagers)if(!this.tileManagers[e].loaded())return!1;return!!this.imageManager.isLoaded()}_serializeByIds(e,i=!1){const r=this._serializedAllLayers();if(!e||0===e.length)return Object.values(i?t.bU(r):r);const n=[];for(const o of e)if(r[o]){const e=i?t.bU(r[o]):r[o];n.push(e)}return n}_serializedAllLayers(){let e=this._serializedLayers;if(e)return e;e=this._serializedLayers={};const t=Object.keys(this._layers);for(const i of t){const t=this._layers[i];"custom"!==t.type&&(e[i]=t.serialize())}return e}hasTransitions(){var e,t,i;if(null===(e=this.light)||void 0===e?void 0:e.hasTransition())return!0;if(null===(t=this.sky)||void 0===t?void 0:t.hasTransition())return!0;if(null===(i=this.projection)||void 0===i?void 0:i.hasTransition())return!0;for(const e in this.tileManagers)if(this.tileManagers[e].hasTransition())return!0;for(const e in this._layers)if(this._layers[e].hasTransition())return!0;return!1}_checkLoaded(){if(!this._loaded)throw new Error("Style is not done loading.")}update(e){if(!this._loaded)return;const i=this._changed;if(i){const t=Object.keys(this._updatedLayers),i=Object.keys(this._removedLayers);(t.length||i.length)&&this._updateWorkerLayers(t,i);for(const e in this._updatedSources){const t=this._updatedSources[e];if("reload"===t)this._reloadSource(e);else{if("clear"!==t)throw new Error(`Invalid action ${t}`);this._clearSource(e)}}this._updateTilesForChangedImages(),this._updateTilesForChangedGlyphs();for(const t in this._updatedPaintProps)this._layers[t].updateTransitions(e);this.light.updateTransitions(e),this.sky.updateTransitions(e),this._resetUpdates()}const r={};for(const e in this.tileManagers){const t=this.tileManagers[e];r[e]=t.used,t.used=!1}for(const t of this._order){const i=this._layers[t];i.recalculate(e,this._availableImages),!i.isHidden(e.zoom)&&i.source&&(this.tileManagers[i.source].used=!0)}for(const e in r){const i=this.tileManagers[e];!!r[e]!=!!i.used&&i.fire(new t.l("data",{sourceDataType:"visibility",dataType:"source",sourceId:e}))}this.light.recalculate(e),this.sky.recalculate(e),this.projection.recalculate(e),this.z=e.zoom,i&&this.fire(new t.l("data",{dataType:"style"}))}_updateTilesForChangedImages(){const e=Object.keys(this._changedImages);if(e.length){for(const t in this.tileManagers)this.tileManagers[t].reloadTilesForDependencies(["icons","patterns"],e);this._changedImages={}}}_updateTilesForChangedGlyphs(){if(this._glyphsDidChange){for(const e in this.tileManagers)this.tileManagers[e].reloadTilesForDependencies(["glyphs"],[""]);this._glyphsDidChange=!1}}_updateWorkerLayers(e,t){this.dispatcher.broadcast("UL",{layers:this._serializeByIds(e,!1),removedIds:t})}_resetUpdates(){this._changed=!1,this._updatedLayers={},this._removedLayers={},this._updatedSources={},this._updatedPaintProps={},this._changedImages={},this._glyphsDidChange=!1}setState(e,i={}){var r;this._checkLoaded();const n=this.serialize();if(e=i.transformStyle?i.transformStyle(n,e):e,(null===(r=i.validate)||void 0===r||r)&&Bi(this,t.C(e)))return!1;(e=t.bU(e)).layers=t.bR(e.layers);const o=t.bV(n,e),s=this._getOperationsToPerform(o);if(s.unimplemented.length>0)throw new Error(`Unimplemented: ${s.unimplemented.join(", ")}.`);if(0===s.operations.length)return!1;for(const e of s.operations)e();return this.stylesheet=e,this._serializedLayers=null,!0}_getOperationsToPerform(e){const t=[],i=[];for(const r of e)switch(r.command){case"setCenter":case"setZoom":case"setBearing":case"setPitch":case"setRoll":continue;case"addLayer":t.push(()=>this.addLayer.apply(this,r.args));break;case"removeLayer":t.push(()=>this.removeLayer.apply(this,r.args));break;case"setPaintProperty":t.push(()=>this.setPaintProperty.apply(this,r.args));break;case"setLayoutProperty":t.push(()=>this.setLayoutProperty.apply(this,r.args));break;case"setFilter":t.push(()=>this.setFilter.apply(this,r.args));break;case"addSource":t.push(()=>this.addSource.apply(this,r.args));break;case"removeSource":t.push(()=>this.removeSource.apply(this,r.args));break;case"setLayerZoomRange":t.push(()=>this.setLayerZoomRange.apply(this,r.args));break;case"setLight":t.push(()=>this.setLight.apply(this,r.args));break;case"setGeoJSONSourceData":t.push(()=>this.setGeoJSONSourceData.apply(this,r.args));break;case"setGlyphs":t.push(()=>this.setGlyphs.apply(this,r.args));break;case"setSprite":t.push(()=>this.setSprite.apply(this,r.args));break;case"setTerrain":t.push(()=>this.map.setTerrain.apply(this,r.args));break;case"setSky":t.push(()=>this.setSky.apply(this,r.args));break;case"setProjection":this.setProjection.apply(this,r.args);break;case"setGlobalState":t.push(()=>this.setGlobalState.apply(this,r.args));break;case"setTransition":t.push(()=>{});break;default:i.push(r.command)}return{operations:t,unimplemented:i}}addImage(e,i){if(this.getImage(e))return this.fire(new t.k(new Error(`An image named "${e}" already exists.`)));this.imageManager.addImage(e,i),this._afterImageUpdated(e)}updateImage(e,t){this.imageManager.updateImage(e,t)}getImage(e){return this.imageManager.getImage(e)}removeImage(e){if(!this.getImage(e))return this.fire(new t.k(new Error(`An image named "${e}" does not exist.`)));this.imageManager.removeImage(e),this._afterImageUpdated(e)}_afterImageUpdated(e){this._availableImages=this.imageManager.listImages(),this._changedImages[e]=!0,this._changed=!0,this.dispatcher.broadcast("SI",this._availableImages),this.fire(new t.l("data",{dataType:"style"}))}listImages(){return this._checkLoaded(),this.imageManager.listImages()}addSource(e,i,r={}){if(this._checkLoaded(),void 0!==this.tileManagers[e])throw new Error(`Source "${e}" already exists.`);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"].indexOf(i.type)>=0&&this._validate(t.C.source,`sources.${e}`,i,null,r))return;this.map&&this.map._collectResourceTiming&&(i.collectResourceTiming=!0);const n=this.tileManagers[e]=new Be(e,i,this.dispatcher);n.style=this,n.setEventedParent(this,()=>({isSourceLoaded:n.loaded(),source:n.serialize(),sourceId:e})),n.onAdd(this.map),this._changed=!0}removeSource(e){if(this._checkLoaded(),void 0===this.tileManagers[e])throw new Error("There is no source with this ID");for(const i in this._layers)if(this._layers[i].source===e)return this.fire(new t.k(new Error(`Source "${e}" cannot be removed while layer "${i}" is using it.`)));const i=this.tileManagers[e];delete this.tileManagers[e],delete this._updatedSources[e],i.fire(new t.l("data",{sourceDataType:"metadata",dataType:"source",sourceId:e})),i.setEventedParent(null),i.onRemove(this.map),this._changed=!0}setGeoJSONSourceData(e,t){if(this._checkLoaded(),void 0===this.tileManagers[e])throw new Error(`There is no source with this ID=${e}`);const i=this.tileManagers[e].getSource();if("geojson"!==i.type)throw new Error(`geojsonSource.type is ${i.type}, which is !== 'geojson`);i.setData(t),this._changed=!0}getSource(e){return this.tileManagers[e]&&this.tileManagers[e].getSource()}addLayer(e,i,r={}){this._checkLoaded();const n=e.id;if(this.getLayer(n))return void this.fire(new t.k(new Error(`Layer "${n}" already exists on this map.`)));let o;if("custom"===e.type){if(Bi(this,t.bW(e)))return;o=t.bS(e,this._globalState)}else{if("source"in e&&"object"==typeof e.source&&(this.addSource(n,e.source),e=t.bU(e),e=t.e(e,{source:n})),this._validate(t.C.layer,`layers.${n}`,e,{arrayIndex:-1},r))return;o=t.bS(e,this._globalState),this._validateLayer(o),o.setEventedParent(this,{layer:{id:n}})}const s=i?this._order.indexOf(i):this._order.length;if(i&&-1===s)this.fire(new t.k(new Error(`Cannot add layer "${n}" before non-existing layer "${i}".`)));else{if(this._order.splice(s,0,n),this._layerOrderChanged=!0,this._layers[n]=o,this._removedLayers[n]&&o.source&&"custom"!==o.type){const e=this._removedLayers[n];delete this._removedLayers[n],e.type!==o.type?this._updatedSources[o.source]="clear":(this._updatedSources[o.source]="reload",this.tileManagers[o.source].pause())}this._updateLayer(o),o.onAdd&&o.onAdd(this.map)}}moveLayer(e,i){if(this._checkLoaded(),this._changed=!0,!this._layers[e])return void this.fire(new t.k(new Error(`The layer '${e}' does not exist in the map's style and cannot be moved.`)));if(e===i)return;const r=this._order.indexOf(e);this._order.splice(r,1);const n=i?this._order.indexOf(i):this._order.length;i&&-1===n?this.fire(new t.k(new Error(`Cannot move layer "${e}" before non-existing layer "${i}".`))):(this._order.splice(n,0,e),this._layerOrderChanged=!0)}removeLayer(e){this._checkLoaded();const i=this._layers[e];if(!i)return void this.fire(new t.k(new Error(`Cannot remove non-existing layer "${e}".`)));i.setEventedParent(null);const r=this._order.indexOf(e);this._order.splice(r,1),this._layerOrderChanged=!0,this._changed=!0,this._removedLayers[e]=i,delete this._layers[e],this._serializedLayers&&delete this._serializedLayers[e],delete this._updatedLayers[e],delete this._updatedPaintProps[e],i.onRemove&&i.onRemove(this.map)}getLayer(e){return this._layers[e]}getLayersOrder(){return[...this._order]}hasLayer(e){return e in this._layers}setLayerZoomRange(e,i,r){this._checkLoaded();const n=this.getLayer(e);n?n.minzoom===i&&n.maxzoom===r||(null!=i&&(n.minzoom=i),null!=r&&(n.maxzoom=r),this._updateLayer(n)):this.fire(new t.k(new Error(`Cannot set the zoom range of non-existing layer "${e}".`)))}setFilter(e,i,r={}){this._checkLoaded();const n=this.getLayer(e);if(n){if(!t.bQ(n.filter,i))return null==i?(n.setFilter(void 0),void this._updateLayer(n)):void(this._validate(t.C.filter,`layers.${n.id}.filter`,i,null,r)||(n.setFilter(t.bU(i)),this._updateLayer(n)))}else this.fire(new t.k(new Error(`Cannot filter non-existing layer "${e}".`)))}getFilter(e){return t.bU(this.getLayer(e).filter)}setLayoutProperty(e,i,r,n={}){this._checkLoaded();const o=this.getLayer(e);o?t.bQ(o.getLayoutProperty(i),r)||(o.setLayoutProperty(i,r,n),this._updateLayer(o)):this.fire(new t.k(new Error(`Cannot style non-existing layer "${e}".`)))}getLayoutProperty(e,i){const r=this.getLayer(e);if(r)return r.getLayoutProperty(i);this.fire(new t.k(new Error(`Cannot get style of non-existing layer "${e}".`)))}setPaintProperty(e,i,r,n={}){this._checkLoaded();const o=this.getLayer(e);o?t.bQ(o.getPaintProperty(i),r)||this._updatePaintProperty(o,i,r,n):this.fire(new t.k(new Error(`Cannot style non-existing layer "${e}".`)))}_updatePaintProperty(e,i,r,n={}){e.setPaintProperty(i,r,n)&&this._updateLayer(e),t.bT(e)&&"raster-fade-duration"===i&&this.tileManagers[e.source].setRasterFadeDuration(r),this._changed=!0,this._updatedPaintProps[e.id]=!0,this._serializedLayers=null}getPaintProperty(e,t){return this.getLayer(e).getPaintProperty(t)}setFeatureState(e,i){this._checkLoaded();const r=e.source,n=e.sourceLayer,o=this.tileManagers[r];if(void 0===o)return void this.fire(new t.k(new Error(`The source '${r}' does not exist in the map's style.`)));const s=o.getSource().type;"geojson"===s&&n?this.fire(new t.k(new Error("GeoJSON sources cannot have a sourceLayer parameter."))):"vector"!==s||n?(void 0===e.id&&this.fire(new t.k(new Error("The feature id parameter must be provided."))),o.setFeatureState(n,e.id,i)):this.fire(new t.k(new Error("The sourceLayer parameter must be provided for vector source types.")))}removeFeatureState(e,i){this._checkLoaded();const r=e.source,n=this.tileManagers[r];if(void 0===n)return void this.fire(new t.k(new Error(`The source '${r}' does not exist in the map's style.`)));const o=n.getSource().type,s="vector"===o?e.sourceLayer:void 0;"vector"!==o||s?i&&"string"!=typeof e.id&&"number"!=typeof e.id?this.fire(new t.k(new Error("A feature id is required to remove its specific state property."))):n.removeFeatureState(s,e.id,i):this.fire(new t.k(new Error("The sourceLayer parameter must be provided for vector source types.")))}getFeatureState(e){this._checkLoaded();const i=e.source,r=e.sourceLayer,n=this.tileManagers[i];if(void 0!==n)return"vector"!==n.getSource().type||r?(void 0===e.id&&this.fire(new t.k(new Error("The feature id parameter must be provided."))),n.getFeatureState(r,e.id)):void this.fire(new t.k(new Error("The sourceLayer parameter must be provided for vector source types.")));this.fire(new t.k(new Error(`The source '${i}' does not exist in the map's style.`)))}getTransition(){return t.e({duration:300,delay:0},this.stylesheet&&this.stylesheet.transition)}serialize(){if(!this._loaded)return;const e=t.bX(this.tileManagers,e=>e.serialize()),i=this._serializeByIds(this._order,!0),r=this.map.getTerrain()||void 0,n=this.stylesheet;return t.bY({version:n.version,name:n.name,metadata:n.metadata,light:n.light,sky:n.sky,center:n.center,zoom:n.zoom,bearing:n.bearing,pitch:n.pitch,sprite:n.sprite,glyphs:n.glyphs,transition:n.transition,projection:n.projection,sources:e,layers:i,terrain:r},e=>void 0!==e)}_updateLayer(e){this._updatedLayers[e.id]=!0,e.source&&!this._updatedSources[e.source]&&"raster"!==this.tileManagers[e.source].getSource().type&&(this._updatedSources[e.source]="reload",this.tileManagers[e.source].pause()),this._serializedLayers=null,this._changed=!0}_flattenAndSortRenderedFeatures(e){const t=e=>"fill-extrusion"===this._layers[e].type,i={},r=[];for(let n=this._order.length-1;n>=0;n--){const o=this._order[n];if(t(o)){i[o]=n;for(const t of e){const e=t[o];if(e)for(const t of e)r.push(t)}}}r.sort((e,t)=>t.intersectionZ-e.intersectionZ);const n=[];for(let o=this._order.length-1;o>=0;o--){const s=this._order[o];if(t(s))for(let e=r.length-1;e>=0;e--){const t=r[e].feature;if(i[t.layer.id]this.map.terrain.getElevation(e,t,i):void 0));return this.placement&&o.push(function(e,t,i,r,n,o,s){const a={},l=o.queryRenderedSymbols(r),c=[];for(const e of Object.keys(l).map(Number))c.push(s[e]);c.sort(H);for(const i of c){const r=i.featureIndex.lookupSymbolFeatures(l[i.bucketInstanceId],t,i.bucketIndex,i.sourceLayerIndex,{filterSpec:n.filter,globalState:n.globalState},n.layers,n.availableImages,e);for(const e in r){const t=a[e]=a[e]||[],n=r[e];n.sort((e,t)=>{const r=i.featureSortOrder;if(r){const i=r.indexOf(e.featureIndex);return r.indexOf(t.featureIndex)-i}return t.featureIndex-e.featureIndex});for(const e of n)t.push(e)}}return function(e,t,i){for(const r in e)for(const n of e[r])Q(n,i[t[r].source]);return e}(a,e,i)}(this._layers,s,this.tileManagers,e,l,this.placement.collisionIndex,this.placement.retainedQueryData)),this._flattenAndSortRenderedFeatures(o)}querySourceFeatures(e,i){(null==i?void 0:i.filter)&&this._validate(t.C.filter,"querySourceFeatures.filter",i.filter,null,i);const r=this.tileManagers[e];return r?function(e,t){const i=e.getRenderableIds().map(t=>e.getTileByID(t)),r=[],n={};for(let e=0;ee.getTileByID(t)).sort((e,t)=>t.tileID.overscaledZ-e.tileID.overscaledZ||(e.tileID.isLessThan(t.tileID)?-1:1))}const r=this.crossTileSymbolIndex.addLayer(i,a[i.source],e.center.lng);o=o||r}if(this.crossTileSymbolIndex.pruneUnusedLayers(this._order),((n=n||this._layerOrderChanged||0===i)||!this.pauseablePlacement||this.pauseablePlacement.isDone()&&!this.placement.stillRecent(c(),e.zoom))&&(this.pauseablePlacement=new vt(e,this.map.terrain,this._order,n,t,i,r,this.placement),this._layerOrderChanged=!1),this.pauseablePlacement.isDone()?this.placement.setStale():(this.pauseablePlacement.continuePlacement(this._order,this._layers,a),this.pauseablePlacement.isDone()&&(this.placement=this.pauseablePlacement.commit(c()),s=!0),o&&this.pauseablePlacement.placement.setStale()),s||o)for(const e of this._order){const t=this._layers[e];"symbol"===t.type&&this.placement.updateLayerOpacities(t,a[t.source])}return!this.pauseablePlacement.isDone()||this.placement.hasTransitions(c())}_releaseSymbolFadeTiles(){for(const e in this.tileManagers)this.tileManagers[e].releaseSymbolFadeTiles()}getImages(e,i){return t._(this,void 0,void 0,function*(){const e=yield this.imageManager.getImages(i.icons);this._updateTilesForChangedImages();const t=this.tileManagers[i.source];return t&&t.setDependencies(i.tileID.key,i.type,i.icons),e})}getGlyphs(e,i){return t._(this,void 0,void 0,function*(){const e=yield this.glyphManager.getGlyphs(i.stacks),t=this.tileManagers[i.source];return t&&t.setDependencies(i.tileID.key,i.type,[""]),e})}getGlyphsUrl(){return this.stylesheet.glyphs||null}setGlyphs(e,i={}){this._checkLoaded(),e&&this._validate(t.C.glyphs,"glyphs",e,null,i)||(this._glyphsDidChange=!0,this.stylesheet.glyphs=e,this.glyphManager.entries={},this.glyphManager.setURL(e))}getDashes(e,i){return t._(this,void 0,void 0,function*(){const e={};for(const[t,r]of Object.entries(i.dashes))e[t]=this.lineAtlas.getDash(r.dasharray,r.round);return e})}addSprite(e,i,r={},n){this._checkLoaded();const o=[{id:e,url:i}],s=[...y(this.stylesheet.sprite),...o];this._validate(t.C.sprite,"sprite",s,null,r)||(this.stylesheet.sprite=s,this._loadSprite(o,!0,n))}removeSprite(e){this._checkLoaded();const i=y(this.stylesheet.sprite);if(i.find(t=>t.id===e)){if(this._spritesImagesIds[e])for(const t of this._spritesImagesIds[e])this.imageManager.removeImage(t),this._changedImages[t]=!0;i.splice(i.findIndex(t=>t.id===e),1),this.stylesheet.sprite=i.length>0?i:void 0,delete this._spritesImagesIds[e],this._availableImages=this.imageManager.listImages(),this._changed=!0,this.dispatcher.broadcast("SI",this._availableImages),this.fire(new t.l("data",{dataType:"style"}))}else this.fire(new t.k(new Error(`Sprite "${e}" doesn't exists on this map.`)))}getSprite(){return y(this.stylesheet.sprite)}setSprite(e,i={},r){this._checkLoaded(),e&&this._validate(t.C.sprite,"sprite",e,null,i)||(this.stylesheet.sprite=e,e?this._loadSprite(e,!0,r):(this._unloadSprite(),r&&r(null)))}destroy(){this._frameRequest&&(this._frameRequest.abort(),this._frameRequest=null),this._loadStyleRequest&&(this._loadStyleRequest.abort(),this._loadStyleRequest=null),this._spriteRequest&&(this._spriteRequest.abort(),this._spriteRequest=null);for(const e in this.tileManagers){const t=this.tileManagers[e];if(t.setEventedParent(null),t._tiles){for(const e in t._tiles)t._tiles[e].unloadVectorData();t._tiles={}}t._cache.reset(),t.onRemove(this.map)}this.tileManagers={},this.imageManager&&(this.imageManager.setEventedParent(null),this.imageManager.destroy(),this._availableImages=[],this._spritesImagesIds={}),this.glyphManager&&this.glyphManager.destroy();for(const e in this._layers){const t=this._layers[e];t.setEventedParent(null),t.onRemove&&t.onRemove(this.map)}this._setInitialValues(),this.setEventedParent(null),this.dispatcher.unregisterMessageHandler("GG"),this.dispatcher.unregisterMessageHandler("GI"),this.dispatcher.unregisterMessageHandler("GDA"),this.dispatcher.remove(!0),this._listeners={},this._oneTimeListeners={}}}var Mi=t.aT([{name:"a_pos",type:"Int16",components:2},{name:"a_texture_pos",type:"Int16",components:2}]);class Pi{constructor(){this.boundProgram=null,this.boundLayoutVertexBuffer=null,this.boundPaintVertexBuffers=[],this.boundIndexBuffer=null,this.boundVertexOffset=null,this.boundDynamicVertexBuffer=null,this.vao=null}bind(e,t,i,r,n,o,s,a,l){this.context=e;let c=this.boundPaintVertexBuffers.length!==r.length;for(let e=0;!c&&e({u_texture:0,u_ele_delta:e,u_fog_matrix:i,u_fog_color:r?r.properties.get("fog-color"):t.bo.white,u_fog_ground_blend:r?r.properties.get("fog-ground-blend"):1,u_fog_ground_blend_opacity:o?0:r?r.calculateFogBlendOpacity(n):0,u_horizon_color:r?r.properties.get("horizon-color"):t.bo.white,u_horizon_fog_blend:r?r.properties.get("horizon-fog-blend"):1,u_is_globe_mode:o?1:0}),Li={mainMatrix:"u_projection_matrix",tileMercatorCoords:"u_projection_tile_mercator_coords",clippingPlane:"u_projection_clipping_plane",projectionTransition:"u_projection_transition",fallbackMatrix:"u_projection_fallback_matrix"};function Fi(e){const t=[];for(let i=0;i({u_depth:new t.bZ(e,i.u_depth),u_terrain:new t.bZ(e,i.u_terrain),u_terrain_dim:new t.bp(e,i.u_terrain_dim),u_terrain_matrix:new t.b$(e,i.u_terrain_matrix),u_terrain_unpack:new t.c0(e,i.u_terrain_unpack),u_terrain_exaggeration:new t.bp(e,i.u_terrain_exaggeration)}))(e,E),this.projectionUniforms=((e,i)=>({u_projection_matrix:new t.b$(e,i.u_projection_matrix),u_projection_tile_mercator_coords:new t.c0(e,i.u_projection_tile_mercator_coords),u_projection_clipping_plane:new t.c0(e,i.u_projection_clipping_plane),u_projection_transition:new t.bp(e,i.u_projection_transition),u_projection_fallback_matrix:new t.b$(e,i.u_projection_fallback_matrix)}))(e,E),this.binderUniforms=r?r.getUniforms(e,E):[]}draw(e,t,i,r,n,o,s,a,l,c,u,h,d,p,f,m,g,_,A){const y=e.gl;if(this.failedToCreate)return;if(e.program.set(this.program),e.setDepthMode(i),e.setStencilMode(r),e.setColorMode(n),e.setCullFace(o),a){e.activeTexture.set(y.TEXTURE2),y.bindTexture(y.TEXTURE_2D,a.depthTexture),e.activeTexture.set(y.TEXTURE3),y.bindTexture(y.TEXTURE_2D,a.texture);for(const e in this.terrainUniforms)this.terrainUniforms[e].set(a[e])}if(l)for(const e in l)this.projectionUniforms[Li[e]].set(l[e]);if(s)for(const e in this.fixedUniforms)this.fixedUniforms[e].set(s[e]);m&&m.setUniforms(e,this.binderUniforms,p,{zoom:f});let v=0;switch(t){case y.LINES:v=2;break;case y.TRIANGLES:v=3;break;case y.LINE_STRIP:v=1}for(const i of d.get()){const r=i.vaos||(i.vaos={});(r[c]||(r[c]=new Pi)).bind(e,this,u,m?m.getPaintVertexBuffers():[],h,i.vertexOffset,g,_,A),y.drawElements(t,i.primitiveLength*v,y.UNSIGNED_SHORT,i.primitiveOffset*v*2)}}}function Di(e,i,r){const n=1/t.aM(r,1,i.transform.tileZoom),o=Math.pow(2,r.tileID.overscaledZ),s=r.tileSize*Math.pow(2,i.transform.tileZoom)/o,a=s*(r.tileID.canonical.x+r.tileID.wrap*o),l=s*r.tileID.canonical.y;return{u_image:0,u_texsize:r.imageAtlasTexture.size,u_scale:[n,e.fromScale,e.toScale],u_fade:e.t,u_pixel_coord_upper:[a>>16,l>>16],u_pixel_coord_lower:[65535&a,65535&l]}}const Oi=(e,i,r,n)=>{const o=e.style.light,s=o.properties.get("position"),a=[s.x,s.y,s.z],l=t.c3();"viewport"===o.properties.get("anchor")&&t.c4(l,e.transform.bearingInRadians),t.c5(a,a,l);const c=e.transform.transformLightDirection(a),u=o.properties.get("color");return{u_lightpos:a,u_lightpos_globe:c,u_lightintensity:o.properties.get("intensity"),u_lightcolor:[u.r,u.g,u.b],u_vertical_gradient:+i,u_opacity:r,u_fill_translate:n}},zi=(e,i,r,n,o,s,a)=>t.e(Oi(e,i,r,n),Di(s,e,a),{u_height_factor:-Math.pow(2,o.overscaledZ)/a.tileSize/8}),Ui=(e,i,r,n)=>t.e(Di(i,e,r),{u_fill_translate:n}),Ni=(e,t)=>({u_world:e,u_fill_translate:t}),Vi=(e,i,r,n,o)=>t.e(Ui(e,i,r,o),{u_world:n}),ji=(e,i,r,n,o)=>{const s=e.transform;let a,l,c=0;if("map"===r.paint.get("circle-pitch-alignment")){const e=t.aM(i,1,s.zoom);a=!0,l=[e,e],c=e/(t.a4*Math.pow(2,i.tileID.overscaledZ))*2*Math.PI*o}else a=!1,l=s.pixelsToGLUnits;return{u_camera_to_center_distance:s.cameraToCenterDistance,u_scale_with_map:+("map"===r.paint.get("circle-pitch-scale")),u_pitch_with_map:+a,u_device_pixel_ratio:e.pixelRatio,u_extrude_scale:l,u_globe_extrude_scale:c,u_translate:n}},Gi=e=>({u_pixel_extrude_scale:[1/e.width,1/e.height]}),Hi=e=>({u_viewport_size:[e.width,e.height]}),Qi=(e,t=1)=>({u_color:e,u_overlay:0,u_overlay_scale:t}),$i=(e,i,r,n)=>{const o=t.aM(e,1,i)/(t.a4*Math.pow(2,e.tileID.overscaledZ))*2*Math.PI*n;return{u_extrude_scale:t.aM(e,1,i),u_intensity:r,u_globe_extrude_scale:o}},Zi=(e,i,r,n)=>{const o=t.N();t.c6(o,0,e.width,e.height,0,0,1);const s=e.context.gl;return{u_matrix:o,u_world:[s.drawingBufferWidth,s.drawingBufferHeight],u_image:r,u_color_ramp:n,u_opacity:i.paint.get("heatmap-opacity")}},Wi=(e,t,i)=>{const r=i.paint.get("hillshade-accent-color");let n;switch(i.paint.get("hillshade-method")){case"basic":n=4;break;case"combined":n=1;break;case"igor":n=2;break;case"multidirectional":n=3;break;default:n=0}const o=i.getIlluminationProperties();for(let t=0;t{const r=i.stride,n=t.N();return t.c6(n,0,t.a4,-t.a4,0,0,1),t.O(n,n,[0,-t.a4,0]),{u_matrix:n,u_image:1,u_dimension:[r,r],u_zoom:e.overscaledZ,u_unpack:i.getUnpackVector()}};function Ki(e,i){const r=Math.pow(2,i.canonical.z),n=i.canonical.y;return[new t.aa(0,n/r).toLngLat().lat,new t.aa(0,(n+1)/r).toLngLat().lat]}const Xi=(e,t,i=0)=>({u_image:0,u_unpack:t.getUnpackVector(),u_dimension:[t.stride,t.stride],u_elevation_stops:1,u_color_stops:4,u_color_ramp_size:i,u_opacity:e.paint.get("color-relief-opacity")}),Ji=(e,i,r,n)=>{const o=e.transform;return{u_translation:nr(e,i,r),u_ratio:n/t.aM(i,1,o.zoom),u_device_pixel_ratio:e.pixelRatio,u_units_to_pixels:[1/o.pixelsToGLUnits[0],1/o.pixelsToGLUnits[1]]}},Yi=(e,i,r,n,o)=>t.e(Ji(e,i,r,n),{u_image:0,u_image_height:o}),er=(e,i,r,n,o)=>{const s=e.transform,a=rr(i,s);return{u_translation:nr(e,i,r),u_texsize:i.imageAtlasTexture.size,u_ratio:n/t.aM(i,1,s.zoom),u_device_pixel_ratio:e.pixelRatio,u_image:0,u_scale:[a,o.fromScale,o.toScale],u_fade:o.t,u_units_to_pixels:[1/s.pixelsToGLUnits[0],1/s.pixelsToGLUnits[1]]}},tr=(e,i,r,n,o)=>{const s=rr(i,e.transform);return t.e(Ji(e,i,r,n),{u_tileratio:s,u_crossfade_from:o.fromScale,u_crossfade_to:o.toScale,u_image:0,u_mix:o.t,u_lineatlas_width:e.lineAtlas.width,u_lineatlas_height:e.lineAtlas.height})},ir=(e,i,r,n,o,s)=>{const a=rr(i,e.transform);return t.e(Ji(e,i,r,n),{u_image:0,u_image_height:s,u_tileratio:a,u_crossfade_from:o.fromScale,u_crossfade_to:o.toScale,u_image_dash:1,u_mix:o.t,u_lineatlas_width:e.lineAtlas.width,u_lineatlas_height:e.lineAtlas.height})};function rr(e,i){return 1/t.aM(e,1,i.tileZoom)}function nr(e,i,r){return t.aN(e.transform,i,r.paint.get("line-translate"),r.paint.get("line-translate-anchor"))}const or=(e,t,i,r,n)=>{return{u_tl_parent:e,u_scale_parent:t,u_buffer_scale:1,u_fade_t:i.mix,u_opacity:i.opacity*r.paint.get("raster-opacity"),u_image0:0,u_image1:1,u_brightness_low:r.paint.get("raster-brightness-min"),u_brightness_high:r.paint.get("raster-brightness-max"),u_saturation_factor:(s=r.paint.get("raster-saturation"),s>0?1-1/(1.001-s):-s),u_contrast_factor:(o=r.paint.get("raster-contrast"),o>0?1/(1-o):1+o),u_spin_weights:sr(r.paint.get("raster-hue-rotate")),u_coords_top:[n[0].x,n[0].y,n[1].x,n[1].y],u_coords_bottom:[n[3].x,n[3].y,n[2].x,n[2].y]};var o,s};function sr(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 ar=(e,t,i,r,n,o,s,a,l,c,u,h,d)=>{const p=s.transform;return{u_is_size_zoom_constant:+("constant"===e||"source"===e),u_is_size_feature_constant:+("constant"===e||"camera"===e),u_size_t:t?t.uSizeT:0,u_size:t?t.uSize:0,u_camera_to_center_distance:p.cameraToCenterDistance,u_pitch:p.pitch/360*2*Math.PI,u_rotate_symbol:+i,u_aspect_ratio:p.width/p.height,u_fade_change:s.options.fadeDuration?s.symbolFadeChange:1,u_label_plane_matrix:a,u_coord_matrix:l,u_is_text:+u,u_pitch_with_map:+r,u_is_along_line:n,u_is_variable_anchor:o,u_texsize:h,u_texture:0,u_translation:c,u_pitched_scale:d}},lr=(e,i,r,n,o,s,a,l,c,u,h,d,p,f)=>{const m=a.transform;return t.e(ar(e,i,r,n,o,s,a,l,c,u,h,d,f),{u_gamma_scale:n?Math.cos(m.pitch*Math.PI/180)*m.cameraToCenterDistance:1,u_device_pixel_ratio:a.pixelRatio,u_is_halo:1})},cr=(e,i,r,n,o,s,a,l,c,u,h,d,p)=>t.e(lr(e,i,r,n,o,s,a,l,c,u,!0,h,0,p),{u_texsize_icon:d,u_texture_icon:1}),ur=(e,t)=>({u_opacity:e,u_color:t}),hr=(e,i,r,n,o)=>t.e(function(e,i,r,n){const o=r.imageManager.getPattern(e.from.toString()),s=r.imageManager.getPattern(e.to.toString()),{width:a,height:l}=r.imageManager.getPixelSize(),c=Math.pow(2,n.tileID.overscaledZ),u=n.tileSize*Math.pow(2,r.transform.tileZoom)/c,h=u*(n.tileID.canonical.x+n.tileID.wrap*c),d=u*n.tileID.canonical.y;return{u_image:0,u_pattern_tl_a:o.tl,u_pattern_br_a:o.br,u_pattern_tl_b:s.tl,u_pattern_br_b:s.br,u_texsize:[a,l],u_mix:i.t,u_pattern_size_a:o.displaySize,u_pattern_size_b:s.displaySize,u_scale_a:i.fromScale,u_scale_b:i.toScale,u_tile_units_to_pixels:1/t.aM(n,1,r.transform.tileZoom),u_pixel_coord_upper:[h>>16,d>>16],u_pixel_coord_lower:[65535&h,65535&d]}}(r,o,i,n),{u_opacity:e}),dr=(e,t)=>{},pr={fillExtrusion:(e,i)=>({u_lightpos:new t.c1(e,i.u_lightpos),u_lightpos_globe:new t.c1(e,i.u_lightpos_globe),u_lightintensity:new t.bp(e,i.u_lightintensity),u_lightcolor:new t.c1(e,i.u_lightcolor),u_vertical_gradient:new t.bp(e,i.u_vertical_gradient),u_opacity:new t.bp(e,i.u_opacity),u_fill_translate:new t.c2(e,i.u_fill_translate)}),fillExtrusionPattern:(e,i)=>({u_lightpos:new t.c1(e,i.u_lightpos),u_lightpos_globe:new t.c1(e,i.u_lightpos_globe),u_lightintensity:new t.bp(e,i.u_lightintensity),u_lightcolor:new t.c1(e,i.u_lightcolor),u_vertical_gradient:new t.bp(e,i.u_vertical_gradient),u_height_factor:new t.bp(e,i.u_height_factor),u_opacity:new t.bp(e,i.u_opacity),u_fill_translate:new t.c2(e,i.u_fill_translate),u_image:new t.bZ(e,i.u_image),u_texsize:new t.c2(e,i.u_texsize),u_pixel_coord_upper:new t.c2(e,i.u_pixel_coord_upper),u_pixel_coord_lower:new t.c2(e,i.u_pixel_coord_lower),u_scale:new t.c1(e,i.u_scale),u_fade:new t.bp(e,i.u_fade)}),fill:(e,i)=>({u_fill_translate:new t.c2(e,i.u_fill_translate)}),fillPattern:(e,i)=>({u_image:new t.bZ(e,i.u_image),u_texsize:new t.c2(e,i.u_texsize),u_pixel_coord_upper:new t.c2(e,i.u_pixel_coord_upper),u_pixel_coord_lower:new t.c2(e,i.u_pixel_coord_lower),u_scale:new t.c1(e,i.u_scale),u_fade:new t.bp(e,i.u_fade),u_fill_translate:new t.c2(e,i.u_fill_translate)}),fillOutline:(e,i)=>({u_world:new t.c2(e,i.u_world),u_fill_translate:new t.c2(e,i.u_fill_translate)}),fillOutlinePattern:(e,i)=>({u_world:new t.c2(e,i.u_world),u_image:new t.bZ(e,i.u_image),u_texsize:new t.c2(e,i.u_texsize),u_pixel_coord_upper:new t.c2(e,i.u_pixel_coord_upper),u_pixel_coord_lower:new t.c2(e,i.u_pixel_coord_lower),u_scale:new t.c1(e,i.u_scale),u_fade:new t.bp(e,i.u_fade),u_fill_translate:new t.c2(e,i.u_fill_translate)}),circle:(e,i)=>({u_camera_to_center_distance:new t.bp(e,i.u_camera_to_center_distance),u_scale_with_map:new t.bZ(e,i.u_scale_with_map),u_pitch_with_map:new t.bZ(e,i.u_pitch_with_map),u_extrude_scale:new t.c2(e,i.u_extrude_scale),u_device_pixel_ratio:new t.bp(e,i.u_device_pixel_ratio),u_globe_extrude_scale:new t.bp(e,i.u_globe_extrude_scale),u_translate:new t.c2(e,i.u_translate)}),collisionBox:(e,i)=>({u_pixel_extrude_scale:new t.c2(e,i.u_pixel_extrude_scale)}),collisionCircle:(e,i)=>({u_viewport_size:new t.c2(e,i.u_viewport_size)}),debug:(e,i)=>({u_color:new t.b_(e,i.u_color),u_overlay:new t.bZ(e,i.u_overlay),u_overlay_scale:new t.bp(e,i.u_overlay_scale)}),depth:dr,clippingMask:dr,heatmap:(e,i)=>({u_extrude_scale:new t.bp(e,i.u_extrude_scale),u_intensity:new t.bp(e,i.u_intensity),u_globe_extrude_scale:new t.bp(e,i.u_globe_extrude_scale)}),heatmapTexture:(e,i)=>({u_matrix:new t.b$(e,i.u_matrix),u_world:new t.c2(e,i.u_world),u_image:new t.bZ(e,i.u_image),u_color_ramp:new t.bZ(e,i.u_color_ramp),u_opacity:new t.bp(e,i.u_opacity)}),hillshade:(e,i)=>({u_image:new t.bZ(e,i.u_image),u_latrange:new t.c2(e,i.u_latrange),u_exaggeration:new t.bp(e,i.u_exaggeration),u_altitudes:new t.c8(e,i.u_altitudes),u_azimuths:new t.c8(e,i.u_azimuths),u_accent:new t.b_(e,i.u_accent),u_method:new t.bZ(e,i.u_method),u_shadows:new t.c7(e,i.u_shadows),u_highlights:new t.c7(e,i.u_highlights)}),hillshadePrepare:(e,i)=>({u_matrix:new t.b$(e,i.u_matrix),u_image:new t.bZ(e,i.u_image),u_dimension:new t.c2(e,i.u_dimension),u_zoom:new t.bp(e,i.u_zoom),u_unpack:new t.c0(e,i.u_unpack)}),colorRelief:(e,i)=>({u_image:new t.bZ(e,i.u_image),u_unpack:new t.c0(e,i.u_unpack),u_dimension:new t.c2(e,i.u_dimension),u_elevation_stops:new t.bZ(e,i.u_elevation_stops),u_color_stops:new t.bZ(e,i.u_color_stops),u_color_ramp_size:new t.bZ(e,i.u_color_ramp_size),u_opacity:new t.bp(e,i.u_opacity)}),line:(e,i)=>({u_translation:new t.c2(e,i.u_translation),u_ratio:new t.bp(e,i.u_ratio),u_device_pixel_ratio:new t.bp(e,i.u_device_pixel_ratio),u_units_to_pixels:new t.c2(e,i.u_units_to_pixels)}),lineGradient:(e,i)=>({u_translation:new t.c2(e,i.u_translation),u_ratio:new t.bp(e,i.u_ratio),u_device_pixel_ratio:new t.bp(e,i.u_device_pixel_ratio),u_units_to_pixels:new t.c2(e,i.u_units_to_pixels),u_image:new t.bZ(e,i.u_image),u_image_height:new t.bp(e,i.u_image_height)}),linePattern:(e,i)=>({u_translation:new t.c2(e,i.u_translation),u_texsize:new t.c2(e,i.u_texsize),u_ratio:new t.bp(e,i.u_ratio),u_device_pixel_ratio:new t.bp(e,i.u_device_pixel_ratio),u_image:new t.bZ(e,i.u_image),u_units_to_pixels:new t.c2(e,i.u_units_to_pixels),u_scale:new t.c1(e,i.u_scale),u_fade:new t.bp(e,i.u_fade)}),lineSDF:(e,i)=>({u_translation:new t.c2(e,i.u_translation),u_ratio:new t.bp(e,i.u_ratio),u_device_pixel_ratio:new t.bp(e,i.u_device_pixel_ratio),u_units_to_pixels:new t.c2(e,i.u_units_to_pixels),u_image:new t.bZ(e,i.u_image),u_mix:new t.bp(e,i.u_mix),u_tileratio:new t.bp(e,i.u_tileratio),u_crossfade_from:new t.bp(e,i.u_crossfade_from),u_crossfade_to:new t.bp(e,i.u_crossfade_to),u_lineatlas_width:new t.bp(e,i.u_lineatlas_width),u_lineatlas_height:new t.bp(e,i.u_lineatlas_height)}),lineGradientSDF:(e,i)=>({u_translation:new t.c2(e,i.u_translation),u_ratio:new t.bp(e,i.u_ratio),u_device_pixel_ratio:new t.bp(e,i.u_device_pixel_ratio),u_units_to_pixels:new t.c2(e,i.u_units_to_pixels),u_image:new t.bZ(e,i.u_image),u_image_height:new t.bp(e,i.u_image_height),u_tileratio:new t.bp(e,i.u_tileratio),u_crossfade_from:new t.bp(e,i.u_crossfade_from),u_crossfade_to:new t.bp(e,i.u_crossfade_to),u_image_dash:new t.bZ(e,i.u_image_dash),u_mix:new t.bp(e,i.u_mix),u_lineatlas_width:new t.bp(e,i.u_lineatlas_width),u_lineatlas_height:new t.bp(e,i.u_lineatlas_height)}),raster:(e,i)=>({u_tl_parent:new t.c2(e,i.u_tl_parent),u_scale_parent:new t.bp(e,i.u_scale_parent),u_buffer_scale:new t.bp(e,i.u_buffer_scale),u_fade_t:new t.bp(e,i.u_fade_t),u_opacity:new t.bp(e,i.u_opacity),u_image0:new t.bZ(e,i.u_image0),u_image1:new t.bZ(e,i.u_image1),u_brightness_low:new t.bp(e,i.u_brightness_low),u_brightness_high:new t.bp(e,i.u_brightness_high),u_saturation_factor:new t.bp(e,i.u_saturation_factor),u_contrast_factor:new t.bp(e,i.u_contrast_factor),u_spin_weights:new t.c1(e,i.u_spin_weights),u_coords_top:new t.c0(e,i.u_coords_top),u_coords_bottom:new t.c0(e,i.u_coords_bottom)}),symbolIcon:(e,i)=>({u_is_size_zoom_constant:new t.bZ(e,i.u_is_size_zoom_constant),u_is_size_feature_constant:new t.bZ(e,i.u_is_size_feature_constant),u_size_t:new t.bp(e,i.u_size_t),u_size:new t.bp(e,i.u_size),u_camera_to_center_distance:new t.bp(e,i.u_camera_to_center_distance),u_pitch:new t.bp(e,i.u_pitch),u_rotate_symbol:new t.bZ(e,i.u_rotate_symbol),u_aspect_ratio:new t.bp(e,i.u_aspect_ratio),u_fade_change:new t.bp(e,i.u_fade_change),u_label_plane_matrix:new t.b$(e,i.u_label_plane_matrix),u_coord_matrix:new t.b$(e,i.u_coord_matrix),u_is_text:new t.bZ(e,i.u_is_text),u_pitch_with_map:new t.bZ(e,i.u_pitch_with_map),u_is_along_line:new t.bZ(e,i.u_is_along_line),u_is_variable_anchor:new t.bZ(e,i.u_is_variable_anchor),u_texsize:new t.c2(e,i.u_texsize),u_texture:new t.bZ(e,i.u_texture),u_translation:new t.c2(e,i.u_translation),u_pitched_scale:new t.bp(e,i.u_pitched_scale)}),symbolSDF:(e,i)=>({u_is_size_zoom_constant:new t.bZ(e,i.u_is_size_zoom_constant),u_is_size_feature_constant:new t.bZ(e,i.u_is_size_feature_constant),u_size_t:new t.bp(e,i.u_size_t),u_size:new t.bp(e,i.u_size),u_camera_to_center_distance:new t.bp(e,i.u_camera_to_center_distance),u_pitch:new t.bp(e,i.u_pitch),u_rotate_symbol:new t.bZ(e,i.u_rotate_symbol),u_aspect_ratio:new t.bp(e,i.u_aspect_ratio),u_fade_change:new t.bp(e,i.u_fade_change),u_label_plane_matrix:new t.b$(e,i.u_label_plane_matrix),u_coord_matrix:new t.b$(e,i.u_coord_matrix),u_is_text:new t.bZ(e,i.u_is_text),u_pitch_with_map:new t.bZ(e,i.u_pitch_with_map),u_is_along_line:new t.bZ(e,i.u_is_along_line),u_is_variable_anchor:new t.bZ(e,i.u_is_variable_anchor),u_texsize:new t.c2(e,i.u_texsize),u_texture:new t.bZ(e,i.u_texture),u_gamma_scale:new t.bp(e,i.u_gamma_scale),u_device_pixel_ratio:new t.bp(e,i.u_device_pixel_ratio),u_is_halo:new t.bZ(e,i.u_is_halo),u_translation:new t.c2(e,i.u_translation),u_pitched_scale:new t.bp(e,i.u_pitched_scale)}),symbolTextAndIcon:(e,i)=>({u_is_size_zoom_constant:new t.bZ(e,i.u_is_size_zoom_constant),u_is_size_feature_constant:new t.bZ(e,i.u_is_size_feature_constant),u_size_t:new t.bp(e,i.u_size_t),u_size:new t.bp(e,i.u_size),u_camera_to_center_distance:new t.bp(e,i.u_camera_to_center_distance),u_pitch:new t.bp(e,i.u_pitch),u_rotate_symbol:new t.bZ(e,i.u_rotate_symbol),u_aspect_ratio:new t.bp(e,i.u_aspect_ratio),u_fade_change:new t.bp(e,i.u_fade_change),u_label_plane_matrix:new t.b$(e,i.u_label_plane_matrix),u_coord_matrix:new t.b$(e,i.u_coord_matrix),u_is_text:new t.bZ(e,i.u_is_text),u_pitch_with_map:new t.bZ(e,i.u_pitch_with_map),u_is_along_line:new t.bZ(e,i.u_is_along_line),u_is_variable_anchor:new t.bZ(e,i.u_is_variable_anchor),u_texsize:new t.c2(e,i.u_texsize),u_texsize_icon:new t.c2(e,i.u_texsize_icon),u_texture:new t.bZ(e,i.u_texture),u_texture_icon:new t.bZ(e,i.u_texture_icon),u_gamma_scale:new t.bp(e,i.u_gamma_scale),u_device_pixel_ratio:new t.bp(e,i.u_device_pixel_ratio),u_is_halo:new t.bZ(e,i.u_is_halo),u_translation:new t.c2(e,i.u_translation),u_pitched_scale:new t.bp(e,i.u_pitched_scale)}),background:(e,i)=>({u_opacity:new t.bp(e,i.u_opacity),u_color:new t.b_(e,i.u_color)}),backgroundPattern:(e,i)=>({u_opacity:new t.bp(e,i.u_opacity),u_image:new t.bZ(e,i.u_image),u_pattern_tl_a:new t.c2(e,i.u_pattern_tl_a),u_pattern_br_a:new t.c2(e,i.u_pattern_br_a),u_pattern_tl_b:new t.c2(e,i.u_pattern_tl_b),u_pattern_br_b:new t.c2(e,i.u_pattern_br_b),u_texsize:new t.c2(e,i.u_texsize),u_mix:new t.bp(e,i.u_mix),u_pattern_size_a:new t.c2(e,i.u_pattern_size_a),u_pattern_size_b:new t.c2(e,i.u_pattern_size_b),u_scale_a:new t.bp(e,i.u_scale_a),u_scale_b:new t.bp(e,i.u_scale_b),u_pixel_coord_upper:new t.c2(e,i.u_pixel_coord_upper),u_pixel_coord_lower:new t.c2(e,i.u_pixel_coord_lower),u_tile_units_to_pixels:new t.bp(e,i.u_tile_units_to_pixels)}),terrain:(e,i)=>({u_texture:new t.bZ(e,i.u_texture),u_ele_delta:new t.bp(e,i.u_ele_delta),u_fog_matrix:new t.b$(e,i.u_fog_matrix),u_fog_color:new t.b_(e,i.u_fog_color),u_fog_ground_blend:new t.bp(e,i.u_fog_ground_blend),u_fog_ground_blend_opacity:new t.bp(e,i.u_fog_ground_blend_opacity),u_horizon_color:new t.b_(e,i.u_horizon_color),u_horizon_fog_blend:new t.bp(e,i.u_horizon_fog_blend),u_is_globe_mode:new t.bp(e,i.u_is_globe_mode)}),terrainDepth:(e,i)=>({u_ele_delta:new t.bp(e,i.u_ele_delta)}),terrainCoords:(e,i)=>({u_texture:new t.bZ(e,i.u_texture),u_terrain_coords_id:new t.bp(e,i.u_terrain_coords_id),u_ele_delta:new t.bp(e,i.u_ele_delta)}),projectionErrorMeasurement:(e,i)=>({u_input:new t.bp(e,i.u_input),u_output_expected:new t.bp(e,i.u_output_expected)}),atmosphere:(e,i)=>({u_sun_pos:new t.c1(e,i.u_sun_pos),u_atmosphere_blend:new t.bp(e,i.u_atmosphere_blend),u_globe_position:new t.c1(e,i.u_globe_position),u_globe_radius:new t.bp(e,i.u_globe_radius),u_inv_proj_matrix:new t.b$(e,i.u_inv_proj_matrix)}),sky:(e,i)=>({u_sky_color:new t.b_(e,i.u_sky_color),u_horizon_color:new t.b_(e,i.u_horizon_color),u_horizon:new t.c2(e,i.u_horizon),u_horizon_normal:new t.c2(e,i.u_horizon_normal),u_sky_horizon_blend:new t.bp(e,i.u_sky_horizon_blend),u_sky_blend:new t.bp(e,i.u_sky_blend)})};class fr{constructor(e,t,i){this.context=e;const r=e.gl;this.buffer=r.createBuffer(),this.dynamicDraw=Boolean(i),this.context.unbindVAO(),e.bindElementBuffer.set(this.buffer),r.bufferData(r.ELEMENT_ARRAY_BUFFER,t.arrayBuffer,this.dynamicDraw?r.DYNAMIC_DRAW:r.STATIC_DRAW),this.dynamicDraw||delete t.arrayBuffer}bind(){this.context.bindElementBuffer.set(this.buffer)}updateData(e){const t=this.context.gl;if(!this.dynamicDraw)throw new Error("Attempted to update data while not in dynamic mode.");this.context.unbindVAO(),this.bind(),t.bufferSubData(t.ELEMENT_ARRAY_BUFFER,0,e.arrayBuffer)}destroy(){this.buffer&&(this.context.gl.deleteBuffer(this.buffer),delete this.buffer)}}const mr={Int8:"BYTE",Uint8:"UNSIGNED_BYTE",Int16:"SHORT",Uint16:"UNSIGNED_SHORT",Int32:"INT",Uint32:"UNSIGNED_INT",Float32:"FLOAT"};class gr{constructor(e,t,i,r){this.length=t.length,this.attributes=i,this.itemSize=t.bytesPerElement,this.dynamicDraw=r,this.context=e;const n=e.gl;this.buffer=n.createBuffer(),e.bindVertexBuffer.set(this.buffer),n.bufferData(n.ARRAY_BUFFER,t.arrayBuffer,this.dynamicDraw?n.DYNAMIC_DRAW:n.STATIC_DRAW),this.dynamicDraw||delete t.arrayBuffer}bind(){this.context.bindVertexBuffer.set(this.buffer)}updateData(e){if(e.length!==this.length)throw new Error(`Length of new data is ${e.length}, which doesn't match current length of ${this.length}`);const t=this.context.gl;this.bind(),t.bufferSubData(t.ARRAY_BUFFER,0,e.arrayBuffer)}enableAttributes(e,t){for(let i=0;i0&&(u.push({circleArray:g,circleOffset:d,coord:p}),h+=g.length/4,d=h),m&&c.draw(s,l.LINES,qt.disabled,Xt.disabled,e.colorModeForRenderPass(),Wt.disabled,Gi(e.transform),e.style.map.terrain&&e.style.map.terrain.getTerrainData(p),a.getProjectionData({overscaledTileID:p,applyGlobeMatrix:!0,applyTerrainMatrix:!0}),r.id,m.layoutVertexBuffer,m.indexBuffer,m.segments,null,e.transform.zoom,null,null,m.collisionVertexBuffer)}if(!o||!u.length)return;const p=e.useProgram("collisionCircle"),f=new t.c9;f.resize(4*h),f._trim();let m=0;for(const e of u)for(let t=0;t=0&&(g[_.associatedIconIndex]={shiftedAnchor:S,angle:I})}else Je(_.numGlyphs,f)}if(c){m.clear();const i=e.icon.placedSymbolArray;for(let e=0;ee.style.map.terrain.getElevation(l,t,i):null,i="map"===r.layout.get("text-rotation-alignment");Ue(c,e,o,z,U,A,u,i,l.toUnwrapped(),g.width,g.height,V,t)}const Q=o&&T||H,$=y||Q?on:A?z:e.transform.clipSpaceToPixelsMatrix,Z=f&&0!==r.paint.get(o?"text-halo-width":"icon-halo-width").constantOr(1);let W;W=f?c.iconsInText?cr(w.kind,I,v,A,y,Q,e,$,N,V,P,k,C):lr(w.kind,I,v,A,y,Q,e,$,N,V,o,P,0,C):ar(w.kind,I,v,A,y,Q,e,$,N,V,o,P,C);const q={program:S,buffers:h,uniformValues:W,projectionData:j,atlasTexture:R,atlasTextureIcon:D,atlasInterpolation:L,atlasInterpolationIcon:F,isSDF:f,hasHalo:Z};if(x&&c.canOverlap){b=!0;const e=h.segments.get();for(const i of e)E.push({segments:new t.aW([i]),sortKey:i.sortKey,state:q,terrainData:M})}else E.push({segments:h.segments,sortKey:0,state:q,terrainData:M})}b&&E.sort((e,t)=>e.sortKey-t.sortKey);for(const t of E){const i=t.state;if(f.activeTexture.set(m.TEXTURE0),i.atlasTexture.bind(i.atlasInterpolation,m.CLAMP_TO_EDGE),i.atlasTextureIcon&&(f.activeTexture.set(m.TEXTURE1),i.atlasTextureIcon&&i.atlasTextureIcon.bind(i.atlasInterpolationIcon,m.CLAMP_TO_EDGE)),i.isSDF){const n=i.uniformValues;i.hasHalo&&(n.u_is_halo=1,hn(i.buffers,t.segments,r,e,i.program,w,h,d,n,i.projectionData,t.terrainData)),n.u_is_halo=0}hn(i.buffers,t.segments,r,e,i.program,w,h,d,i.uniformValues,i.projectionData,t.terrainData)}}function hn(e,t,i,r,n,o,s,a,l,c,u){const h=r.context;n.draw(h,h.gl.TRIANGLES,o,s,a,Wt.backCCW,l,u,c,i.id,e.layoutVertexBuffer,e.indexBuffer,t,i.paint,r.transform.zoom,e.programConfigurations.get(i.id),e.dynamicLayoutVertexBuffer,e.opacityVertexBuffer)}function dn(e,i,r,n,o){const s=e.context,a=s.gl,l=Xt.disabled,c=new $t([a.ONE,a.ONE],t.bo.transparent,[!0,!0,!0,!0]),u=i.getBucket(r);if(!u)return;const h=n.key;let d=r.heatmapFbos.get(h);d||(d=fn(s,i.tileSize,i.tileSize),r.heatmapFbos.set(h,d)),s.bindFramebuffer.set(d.framebuffer),s.viewport.set([0,0,i.tileSize,i.tileSize]),s.clear({color:t.bo.transparent});const p=u.programConfigurations.get(r.id),f=e.useProgram("heatmap",p,!o),m=e.transform.getProjectionData({overscaledTileID:i.tileID,applyGlobeMatrix:!0,applyTerrainMatrix:!0}),g=e.style.map.terrain.getTerrainData(n);f.draw(s,a.TRIANGLES,qt.disabled,l,c,Wt.disabled,$i(i,e.transform.zoom,r.paint.get("heatmap-intensity"),1),g,m,r.id,u.layoutVertexBuffer,u.indexBuffer,u.segments,r.paint,e.transform.zoom,p)}function pn(e,t,i,r,n){const o=e.context,s=o.gl,a=e.transform;o.setColorMode(e.colorModeForRenderPass());const l=mn(o,t),c=i.key,u=t.heatmapFbos.get(c);if(!u)return;o.activeTexture.set(s.TEXTURE0),s.bindTexture(s.TEXTURE_2D,u.colorAttachment.get()),o.activeTexture.set(s.TEXTURE1),l.bind(s.LINEAR,s.CLAMP_TO_EDGE);const h=a.getProjectionData({overscaledTileID:i,applyTerrainMatrix:n,applyGlobeMatrix:!r});e.useProgram("heatmapTexture").draw(o,s.TRIANGLES,qt.disabled,Xt.disabled,e.colorModeForRenderPass(),Wt.disabled,Zi(e,t,0,1),null,h,t.id,e.rasterBoundsBuffer,e.quadTriangleIndexBuffer,e.rasterBoundsSegments,t.paint,a.zoom),u.destroy(),t.heatmapFbos.delete(c)}function fn(e,t,i){var r,n;const o=e.gl,s=o.createTexture();o.bindTexture(o.TEXTURE_2D,s),o.texParameteri(o.TEXTURE_2D,o.TEXTURE_WRAP_S,o.CLAMP_TO_EDGE),o.texParameteri(o.TEXTURE_2D,o.TEXTURE_WRAP_T,o.CLAMP_TO_EDGE),o.texParameteri(o.TEXTURE_2D,o.TEXTURE_MIN_FILTER,o.LINEAR),o.texParameteri(o.TEXTURE_2D,o.TEXTURE_MAG_FILTER,o.LINEAR);const a=null!==(r=e.HALF_FLOAT)&&void 0!==r?r:o.UNSIGNED_BYTE,l=null!==(n=e.RGBA16F)&&void 0!==n?n:o.RGBA;o.texImage2D(o.TEXTURE_2D,0,l,t,i,0,o.RGBA,a,null);const c=e.createFramebuffer(t,i,!1,!1);return c.colorAttachment.set(s),c}function mn(e,i){return i.colorRampTexture||(i.colorRampTexture=new t.T(e,i.colorRamp,e.gl.RGBA)),i.colorRampTexture}function gn(e,i,r,n,o,s,a,l){let c=256;if(o.stepInterpolant){const n=i.getSource().maxzoom,o=a.canonical.z===n?Math.ceil(1<20&&d.texParameterf(d.TEXTURE_2D,h.extTextureFilterAnisotropic.TEXTURE_MAX_ANISOTROPY_EXT,h.extTextureFilterAnisotropicMax);const I=e.style.map.terrain&&e.style.map.terrain.getTerrainData(b),M=f.getProjectionData({overscaledTileID:b,aligned:_,applyGlobeMatrix:!c,applyTerrainMatrix:!0}),P=or(B,C,S.fadeMix,i,a),R=m.getMeshFromTileID(h,b.canonical,o,s,"raster");p.draw(h,d.TRIANGLES,r,n?n[b.overscaledZ]:Xt.disabled,g,l?Wt.frontCCW:Wt.backCCW,P,I,M,i.id,R.vertexBuffer,R.indexBuffer,R.segments)}}function Sn(e,i,r,n){const o={parentTile:null,parentScaleBy:1,parentTopLeft:[0,0],fadeValues:{tileOpacity:1,parentTileOpacity:1,fadeMix:{opacity:1,mix:0}}};if(0===r||n)return o;if(e.fadingParentID){const n=i.getLoadedTile(e.fadingParentID);if(!n)return o;const s=Math.pow(2,n.tileID.overscaledZ-e.tileID.overscaledZ),a=[e.tileID.canonical.x*s%1,e.tileID.canonical.y*s%1],l=function(e,i,r){const n=c(),o=(n-i.timeAdded)/r,s=e.fadingDirection===he.Incoming,a=t.an((n-e.timeAdded)/r,0,1),l=t.an(1-o,0,1),u=s?a:l;return{tileOpacity:u,parentTileOpacity:s?l:a,fadeMix:{opacity:1,mix:1-u}}}(e,n,r);return{parentTile:n,parentScaleBy:s,parentTopLeft:a,fadeValues:l}}if(e.selfFading){const i=function(e,i){const r=(c()-e.timeAdded)/i,n=t.an(r,0,1);return{tileOpacity:n,fadeMix:{opacity:n,mix:0}}}(e,r);return{parentTile:null,parentScaleBy:1,parentTopLeft:[0,0],fadeValues:i}}return o}const In=new t.bo(1,0,0,1),Mn=new t.bo(0,1,0,1),Pn=new t.bo(0,0,1,1),Rn=new t.bo(1,0,1,1),Ln=new t.bo(0,1,1,1);function Fn(e,t,i,r){Dn(e,0,t+i/2,e.transform.width,i,r)}function kn(e,t,i,r){Dn(e,t-i/2,0,i,e.transform.height,r)}function Dn(e,t,i,r,n,o){const s=e.context,a=s.gl;a.enable(a.SCISSOR_TEST),a.scissor(t*e.pixelRatio,i*e.pixelRatio,r*e.pixelRatio,n*e.pixelRatio),s.clear({color:o}),a.disable(a.SCISSOR_TEST)}function On(e,i,r){const n=e.context,o=n.gl,s=e.useProgram("debug"),a=qt.disabled,l=Xt.disabled,c=e.colorModeForRenderPass(),u="$debug",h=e.style.map.terrain&&e.style.map.terrain.getTerrainData(r);n.activeTexture.set(o.TEXTURE0);const d=i.getTileByID(r.key).latestRawTileData,p=Math.floor((d&&d.byteLength||0)/1024),f=i.getTile(r).tileSize,m=512/Math.min(f,512)*(r.overscaledZ/e.transform.zoom)*.5;let g=r.canonical.toString();r.overscaledZ!==r.canonical.z&&(g+=` => ${r.overscaledZ}`),function(e,t){e.initDebugOverlayCanvas();const i=e.debugOverlayCanvas,r=e.context.gl,n=e.debugOverlayCanvas.getContext("2d");n.clearRect(0,0,i.width,i.height),n.shadowColor="white",n.shadowBlur=2,n.lineWidth=1.5,n.strokeStyle="white",n.textBaseline="top",n.font="bold 36px Open Sans, sans-serif",n.fillText(t,5,5),n.strokeText(t,5,5),e.debugOverlayTexture.update(i),e.debugOverlayTexture.bind(r.LINEAR,r.CLAMP_TO_EDGE)}(e,`${g} ${p}kB`);const _=e.transform.getProjectionData({overscaledTileID:r,applyGlobeMatrix:!0,applyTerrainMatrix:!0});s.draw(n,o.TRIANGLES,a,l,$t.alphaBlended,Wt.disabled,Qi(t.bo.transparent,m),null,_,u,e.debugBuffer,e.quadTriangleIndexBuffer,e.debugSegments),s.draw(n,o.LINE_STRIP,a,l,c,Wt.disabled,Qi(t.bo.red),h,_,u,e.debugBuffer,e.tileBorderIndexBuffer,e.debugSegments)}function zn(e,t,i,r){const{isRenderingGlobe:n}=r,o=e.context,s=o.gl,a=e.transform,l=e.colorModeForRenderPass(),c=e.getDepthModeFor3D(),u=e.useProgram("terrain");o.bindFramebuffer.set(null),o.viewport.set([0,0,e.width,e.height]);for(const r of i){const i=t.getTerrainMesh(r.tileID),h=e.renderToTexture.getTexture(r),d=t.getTerrainData(r.tileID);o.activeTexture.set(s.TEXTURE0),s.bindTexture(s.TEXTURE_2D,h.texture);const p=t.getMeshFrameDelta(a.zoom),f=a.calculateFogMatrix(r.tileID.toUnwrapped()),m=Ri(p,f,e.style.sky,a.pitch,n),g=a.getProjectionData({overscaledTileID:r.tileID,applyTerrainMatrix:!1,applyGlobeMatrix:!0});u.draw(o,s.TRIANGLES,c,Xt.disabled,l,Wt.backCCW,m,d,g,"terrain",i.vertexBuffer,i.indexBuffer,i.segments)}}function Un(e,i){if(!i.mesh){const r=new t.aV;r.emplaceBack(-1,-1),r.emplaceBack(1,-1),r.emplaceBack(1,1),r.emplaceBack(-1,1);const n=new t.aX;n.emplaceBack(0,1,2),n.emplaceBack(0,2,3),i.mesh=new It(e.createVertexBuffer(r,Mt.members),e.createIndexBuffer(n),t.aW.simpleSegment(0,0,r.length,n.length))}return i.mesh}class Nn{constructor(e,i){this.context=new tn(e),this.transform=i,this._tileTextures={},this.terrainFacilitator={dirty:!0,matrix:t.ar(new Float64Array(16)),renderTime:0},this.setup(),this.numSublayers=Be.maxOverzooming+Be.maxUnderzooming+1,this.depthEpsilon=1/Math.pow(2,16),this.crossTileSymbolIndex=new Et}resize(e,t,i){if(this.width=Math.floor(e*i),this.height=Math.floor(t*i),this.pixelRatio=i,this.context.viewport.set([0,0,this.width,this.height]),this.style)for(const e of this.style._order)this.style._layers[e].resize()}setup(){const e=this.context,i=new t.aV;i.emplaceBack(0,0),i.emplaceBack(t.a4,0),i.emplaceBack(0,t.a4),i.emplaceBack(t.a4,t.a4),this.tileExtentBuffer=e.createVertexBuffer(i,Mt.members),this.tileExtentSegments=t.aW.simpleSegment(0,0,4,2);const r=new t.aV;r.emplaceBack(0,0),r.emplaceBack(t.a4,0),r.emplaceBack(0,t.a4),r.emplaceBack(t.a4,t.a4),this.debugBuffer=e.createVertexBuffer(r,Mt.members),this.debugSegments=t.aW.simpleSegment(0,0,4,5);const n=new t.cg;n.emplaceBack(0,0,0,0),n.emplaceBack(t.a4,0,t.a4,0),n.emplaceBack(0,t.a4,0,t.a4),n.emplaceBack(t.a4,t.a4,t.a4,t.a4),this.rasterBoundsBuffer=e.createVertexBuffer(n,Mi.members),this.rasterBoundsSegments=t.aW.simpleSegment(0,0,4,2);const o=new t.aV;o.emplaceBack(0,0),o.emplaceBack(t.a4,0),o.emplaceBack(0,t.a4),o.emplaceBack(t.a4,t.a4),this.rasterBoundsBufferPosOnly=e.createVertexBuffer(o,Mt.members),this.rasterBoundsSegmentsPosOnly=t.aW.simpleSegment(0,0,4,5);const s=new t.aV;s.emplaceBack(0,0),s.emplaceBack(1,0),s.emplaceBack(0,1),s.emplaceBack(1,1),this.viewportBuffer=e.createVertexBuffer(s,Mt.members),this.viewportSegments=t.aW.simpleSegment(0,0,4,2);const a=new t.ch;a.emplaceBack(0),a.emplaceBack(1),a.emplaceBack(3),a.emplaceBack(2),a.emplaceBack(0),this.tileBorderIndexBuffer=e.createIndexBuffer(a);const l=new t.aX;l.emplaceBack(1,0,2),l.emplaceBack(1,2,3),this.quadTriangleIndexBuffer=e.createIndexBuffer(l);const c=this.context.gl;this.stencilClearMode=new Xt({func:c.ALWAYS,mask:0},0,255,c.ZERO,c.ZERO,c.ZERO),this.tileExtentMesh=new It(this.tileExtentBuffer,this.quadTriangleIndexBuffer,this.tileExtentSegments)}clearStencil(){const e=this.context,i=e.gl;this.nextStencilID=1,this.currentStencilSource=void 0;const r=t.N();t.c6(r,0,this.width,this.height,0,0,1),t.Q(r,r,[i.drawingBufferWidth,i.drawingBufferHeight,0]);const n={mainMatrix:r,tileMercatorCoords:[0,0,1,1],clippingPlane:[0,0,0,0],projectionTransition:0,fallbackMatrix:r};this.useProgram("clippingMask",null,!0).draw(e,i.TRIANGLES,qt.disabled,this.stencilClearMode,$t.disabled,Wt.disabled,null,null,n,"$clipping",this.viewportBuffer,this.quadTriangleIndexBuffer,this.viewportSegments)}_renderTileClippingMasks(e,t,i){if(this.currentStencilSource===e.source||!e.isTileClipped()||!t||!t.length)return;this.currentStencilSource=e.source,this.nextStencilID+t.length>256&&this.clearStencil();const r=this.context;r.setColorMode($t.disabled),r.setDepthMode(qt.disabled);const n={};for(const e of t)n[e.key]=this.nextStencilID++;this._renderTileMasks(n,t,i,!0),this._renderTileMasks(n,t,i,!1),this._tileClippingMaskIDs=n}_renderTileMasks(e,t,i,r){const n=this.context,o=n.gl,s=this.style.projection,a=this.transform,l=this.useProgram("clippingMask");for(const c of t){const t=e[c.key],u=this.style.map.terrain&&this.style.map.terrain.getTerrainData(c),h=s.getMeshFromTileID(this.context,c.canonical,r,!0,"stencil"),d=a.getProjectionData({overscaledTileID:c,applyGlobeMatrix:!i,applyTerrainMatrix:!0});l.draw(n,o.TRIANGLES,qt.disabled,new Xt({func:o.ALWAYS,mask:0},t,255,o.KEEP,o.KEEP,o.REPLACE),$t.disabled,i?Wt.disabled:Wt.backCCW,null,u,d,"$clipping",h.vertexBuffer,h.indexBuffer,h.segments)}}_renderTilesDepthBuffer(){const e=this.context,t=e.gl,i=this.style.projection,r=this.transform,n=this.useProgram("depth"),o=this.getDepthModeFor3D(),s=Ee(r,{tileSize:r.tileSize});for(const a of s){const s=this.style.map.terrain&&this.style.map.terrain.getTerrainData(a),l=i.getMeshFromTileID(this.context,a.canonical,!0,!0,"raster"),c=r.getProjectionData({overscaledTileID:a,applyGlobeMatrix:!0,applyTerrainMatrix:!0});n.draw(e,t.TRIANGLES,o,Xt.disabled,$t.disabled,Wt.backCCW,null,s,c,"$clipping",l.vertexBuffer,l.indexBuffer,l.segments)}}stencilModeFor3D(){this.currentStencilSource=void 0,this.nextStencilID+1>256&&this.clearStencil();const e=this.nextStencilID++,t=this.context.gl;return new Xt({func:t.NOTEQUAL,mask:255},e,255,t.KEEP,t.KEEP,t.REPLACE)}stencilModeForClipping(e){const t=this.context.gl;return new Xt({func:t.EQUAL,mask:255},this._tileClippingMaskIDs[e.key],0,t.KEEP,t.KEEP,t.REPLACE)}getStencilConfigForOverlapAndUpdateStencilID(e){const t=this.context.gl,i=e.sort((e,t)=>t.overscaledZ-e.overscaledZ),r=i[i.length-1].overscaledZ,n=i[0].overscaledZ-r+1;if(n>1){this.currentStencilSource=void 0,this.nextStencilID+n>256&&this.clearStencil();const e={};for(let i=0;it.overscaledZ-e.overscaledZ),r=i[i.length-1].overscaledZ,n=i[0].overscaledZ-r+1;if(this.clearStencil(),n>1){const e={},o={};for(let i=0;i0};for(const e in s){const t=s[e];t.used&&t.prepare(this.context),a[e]=t.getVisibleCoordinates(!1),l[e]=a[e].slice().reverse(),u[e]=t.getVisibleCoordinates(!0).reverse()}this.opaquePassCutoff=1/0;for(let e=0;ethis.useProgram(e)}),this.context.viewport.set([0,0,this.width,this.height]),this.context.bindFramebuffer.set(null),this.context.clear({color:i.showOverdrawInspector?t.bo.black:t.bo.transparent,depth:1}),this.clearStencil(),this.style.sky&&function(e,t){const i=e.context,r=i.gl,n=((e,t,i)=>{const r=Math.cos(t.rollInRadians),n=Math.sin(t.rollInRadians),o=_e(t),s=t.getProjectionData({overscaledTileID:null,applyGlobeMatrix:!0,applyTerrainMatrix:!0}).projectionTransition;return{u_sky_color:e.properties.get("sky-color"),u_horizon_color:e.properties.get("horizon-color"),u_horizon:[(t.width/2-o*n)*i,(t.height/2+o*r)*i],u_horizon_normal:[-n,r],u_sky_horizon_blend:e.properties.get("sky-horizon-blend")*t.height/2*i,u_sky_blend:s}})(t,e.style.map.transform,e.pixelRatio),o=new qt(r.LEQUAL,qt.ReadWrite,[0,1]),s=Xt.disabled,a=e.colorModeForRenderPass(),l=e.useProgram("sky"),c=Un(i,t);l.draw(i,r.TRIANGLES,o,s,a,Wt.disabled,n,null,void 0,"sky",c.vertexBuffer,c.indexBuffer,c.segments)}(this,this.style.sky),this._showOverdrawInspector=i.showOverdrawInspector,this.depthRangeFor3D=[0,1-(e._order.length+2)*this.numSublayers*this.depthEpsilon],!this.renderToTexture)for(this.renderPass="opaque",this.currentLayer=o.length-1;this.currentLayer>=0;this.currentLayer--){const e=this.style._layers[o[this.currentLayer]],t=s[e.source],i=a[e.source];this._renderTileClippingMasks(e,i,!1),this.renderLayer(this,t,e,i,h)}this.renderPass="translucent";let d=!1;for(this.currentLayer=0;this.currentLayer({u_sun_pos:e,u_atmosphere_blend:t,u_globe_position:i,u_globe_radius:r,u_inv_proj_matrix:n}))(c,h,[f[0],f[1],f[2]],d,p),g=Un(n,i);s.draw(n,o.TRIANGLES,a,Xt.disabled,$t.alphaBlended,Wt.disabled,m,null,null,"atmosphere",g.vertexBuffer,g.indexBuffer,g.segments)}(this,this.style.sky,this.style.light),this.options.showTileBoundaries){const e=function(e,t){let i=null;const r=Object.values(e._layers).flatMap(i=>i.source&&!i.isHidden(t)?[e.tileManagers[i.source]]:[]),n=r.filter(e=>"vector"===e.getSource().type),o=r.filter(e=>"vector"!==e.getSource().type),s=e=>{(!i||i.getSource().maxzooms(e)),i||o.forEach(e=>s(e)),i}(this.style,this.transform.zoom);e&&function(e,t,i){for(let r=0;rh.getElevation(o,e,t):null;ln(s,d,p,c,u,g,i,f,_,t.aN(u,e,a,l),o.toUnwrapped(),r)}}}(n,e,r,i,r.layout.get("text-rotation-alignment"),r.layout.get("text-pitch-alignment"),r.paint.get("text-translate"),r.paint.get("text-translate-anchor"),o),0!==r.paint.get("icon-opacity").constantOr(1)&&un(e,i,r,n,!1,r.paint.get("icon-translate"),r.paint.get("icon-translate-anchor"),r.layout.get("icon-rotation-alignment"),r.layout.get("icon-pitch-alignment"),r.layout.get("icon-keep-upright"),l,c,a),0!==r.paint.get("text-opacity").constantOr(1)&&un(e,i,r,n,!0,r.paint.get("text-translate"),r.paint.get("text-translate-anchor"),r.layout.get("text-rotation-alignment"),r.layout.get("text-pitch-alignment"),r.layout.get("text-keep-upright"),l,c,a),i.map.showCollisionBoxes&&(nn(e,i,r,n,!0),nn(e,i,r,n,!1))}(e,i,r,n,this.style.placement.variableOffsets,o):t.cm(r)?function(e,i,r,n,o){if("translucent"!==e.renderPass)return;const{isRenderingToTexture:s}=o,a=r.paint.get("circle-opacity"),l=r.paint.get("circle-stroke-width"),c=r.paint.get("circle-stroke-opacity"),u=!r.layout.get("circle-sort-key").isConstant();if(0===a.constantOr(1)&&(0===l.constantOr(1)||0===c.constantOr(1)))return;const h=e.context,d=h.gl,p=e.transform,f=e.getDepthModeForSublayer(0,qt.ReadOnly),m=Xt.disabled,g=e.colorModeForRenderPass(),_=[],A=p.getCircleRadiusCorrection();for(let o=0;oe.sortKey-t.sortKey);for(const t of _){const{programConfiguration:i,program:n,layoutVertexBuffer:o,indexBuffer:s,uniformValues:a,terrainData:l,projectionData:c}=t.state;n.draw(h,d.TRIANGLES,f,m,g,Wt.backCCW,a,l,c,r.id,o,s,t.segments,r.paint,e.transform.zoom,i)}}(e,i,r,n,o):t.cn(r)?function(e,i,r,n,o){if(0===r.paint.get("heatmap-opacity"))return;const s=e.context,{isRenderingToTexture:a,isRenderingGlobe:l}=o;if(e.style.map.terrain){for(const t of n){const n=i.getTile(t);i.hasRenderableParent(t)||("offscreen"===e.renderPass?dn(e,n,r,t,l):"translucent"===e.renderPass&&pn(e,r,t,a,l))}s.viewport.set([0,0,e.width,e.height])}else"offscreen"===e.renderPass?function(e,i,r,n){const o=e.context,s=o.gl,a=e.transform,l=Xt.disabled,c=new $t([s.ONE,s.ONE],t.bo.transparent,[!0,!0,!0,!0]);(function(e,i,r){const n=e.gl;e.activeTexture.set(n.TEXTURE1),e.viewport.set([0,0,i.width/4,i.height/4]);let o=r.heatmapFbos.get(t.cc);o?(n.bindTexture(n.TEXTURE_2D,o.colorAttachment.get()),e.bindFramebuffer.set(o.framebuffer)):(o=fn(e,i.width/4,i.height/4),r.heatmapFbos.set(t.cc,o))})(o,e,r),o.clear({color:t.bo.transparent});for(let t=0;t0?t.pop():null}isPatternMissing(e){if(!e)return!1;if(!e.from||!e.to)return!0;const t=this.imageManager.getPattern(e.from.toString()),i=this.imageManager.getPattern(e.to.toString());return!t||!i}useProgram(e,t,i=!1,r=[]){this.cache=this.cache||{};const n=!!this.style.map.terrain,o=this.style.projection,s=i?Bt.projectionMercator:o.shaderPreludeCode,a=i?Pt:o.shaderDefine,l=e+(t?t.cacheKey:"")+`/${i?Rt:o.shaderVariantName}`+(this._showOverdrawInspector?"/overdraw":"")+(n?"/terrain":"")+(r?`/${r.join("/")}`:"");return this.cache[l]||(this.cache[l]=new ki(this.context,Bt[e],t,pr[e],this._showOverdrawInspector,n,s,a,r)),this.cache[l]}setCustomLayerDefaults(){this.context.unbindVAO(),this.context.cullFace.setDefault(),this.context.activeTexture.setDefault(),this.context.pixelStoreUnpack.setDefault(),this.context.pixelStoreUnpackPremultiplyAlpha.setDefault(),this.context.pixelStoreUnpackFlipY.setDefault()}setBaseState(){const e=this.context.gl;this.context.cullFace.set(!1),this.context.viewport.set([0,0,this.width,this.height]),this.context.blendEquation.set(e.FUNC_ADD)}initDebugOverlayCanvas(){null==this.debugOverlayCanvas&&(this.debugOverlayCanvas=document.createElement("canvas"),this.debugOverlayCanvas.width=512,this.debugOverlayCanvas.height=512,this.debugOverlayTexture=new t.T(this.context,this.debugOverlayCanvas,this.context.gl.RGBA))}destroy(){var e,t;if(this._tileTextures){for(const e in this._tileTextures){const t=this._tileTextures[e];if(t)for(const e of t)e.destroy()}this._tileTextures={}}if(this.tileExtentBuffer&&this.tileExtentBuffer.destroy(),this.debugBuffer&&this.debugBuffer.destroy(),this.rasterBoundsBuffer&&this.rasterBoundsBuffer.destroy(),this.rasterBoundsBufferPosOnly&&this.rasterBoundsBufferPosOnly.destroy(),this.viewportBuffer&&this.viewportBuffer.destroy(),this.tileBorderIndexBuffer&&this.tileBorderIndexBuffer.destroy(),this.quadTriangleIndexBuffer&&this.quadTriangleIndexBuffer.destroy(),this.tileExtentMesh&&(null===(e=this.tileExtentMesh.vertexBuffer)||void 0===e||e.destroy()),this.tileExtentMesh&&(null===(t=this.tileExtentMesh.indexBuffer)||void 0===t||t.destroy()),this.debugOverlayTexture&&this.debugOverlayTexture.destroy(),this.cache){for(const e in this.cache){const t=this.cache[e];t&&t.program&&this.context.gl.deleteProgram(t.program)}this.cache={}}this.context&&this.context.setDefault()}overLimit(){const{drawingBufferWidth:e,drawingBufferHeight:t}=this.context.gl;return this.width!==e||this.height!==t}}function Vn(e,t){let i,r=!1,n=null,o=null;const s=()=>{n=null,r&&(e.apply(o,i),n=setTimeout(s,t),r=!1)};return(...e)=>(r=!0,o=this,i=e,n||s(),n)}class jn{constructor(e){this._getCurrentHash=()=>{const e=window.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("/")},this._onHashChange=()=>{const e=this._getCurrentHash();if(!this._isValidHash(e))return!1;const t=this._map.dragRotate.isEnabled()&&this._map.touchZoomRotate.isEnabled()?+(e[3]||0):this._map.getBearing();return this._map.jumpTo({center:[+e[2],+e[1]],zoom:+e[0],bearing:t,pitch:+(e[4]||0)}),!0},this._updateHashUnthrottled=()=>{const e=window.location.href.replace(/(#.*)?$/,this.getHashString());window.history.replaceState(window.history.state,null,e)},this._removeHash=()=>{const e=this._getCurrentHash();if(0===e.length)return;const t=e.join("/");let i=t;i.split("&").length>0&&(i=i.split("&")[0]),this._hashName&&(i=`${this._hashName}=${t}`);let r=window.location.hash.replace(i,"");r.startsWith("#&")?r=r.slice(0,1)+r.slice(2):"#"===r&&(r="");let n=window.location.href.replace(/(#.+)?$/,r);n=n.replace("&&","&"),window.history.replaceState(window.history.state,null,n)},this._updateHash=Vn(this._updateHashUnthrottled,300),this._hashName=e&&encodeURIComponent(e)}addTo(e){return this._map=e,addEventListener("hashchange",this._onHashChange,!1),this._map.on("moveend",this._updateHash),this}remove(){return removeEventListener("hashchange",this._onHashChange,!1),this._map.off("moveend",this._updateHash),clearTimeout(this._updateHash()),this._removeHash(),delete this._map,this}getHashString(e){const t=this._map.getCenter(),i=Math.round(100*this._map.getZoom())/100,r=Math.ceil((i*Math.LN2+Math.log(512/360/.5))/Math.LN10),n=Math.pow(10,r),o=Math.round(t.lng*n)/n,s=Math.round(t.lat*n)/n,a=this._map.getBearing(),l=this._map.getPitch();let c="";if(c+=e?`/${o}/${s}/${i}`:`${i}/${s}/${o}`,(a||l)&&(c+="/"+Math.round(10*a)/10),l&&(c+=`/${Math.round(l)}`),this._hashName){const e=this._hashName;let t=!1;const i=window.location.hash.slice(1).split("&").map(i=>{const r=i.split("=")[0];return r===e?(t=!0,`${r}=${c}`):i}).filter(e=>e);return t||i.push(`${e}=${c}`),`#${i.join("&")}`}return`#${c}`}_isValidHash(e){if(e.length<3||e.some(isNaN))return!1;try{new t.V(+e[2],+e[1])}catch(e){return!1}const i=+e[0],r=+(e[3]||0),n=+(e[4]||0);return i>=this._map.getMinZoom()&&i<=this._map.getMaxZoom()&&r>=-180&&r<=180&&n>=this._map.getMinPitch()&&n<=this._map.getMaxPitch()}}const Gn={linearity:.3,easing:t.cv(0,0,.3,1)},Hn=t.e({deceleration:2500,maxSpeed:1400},Gn),Qn=t.e({deceleration:20,maxSpeed:1400},Gn),$n=t.e({deceleration:1e3,maxSpeed:360},Gn),Zn=t.e({deceleration:1e3,maxSpeed:90},Gn),Wn=t.e({deceleration:1e3,maxSpeed:360},Gn);class qn{constructor(e){this._map=e,this.clear()}clear(){this._inertiaBuffer=[]}record(e){this._drainInertiaBuffer(),this._inertiaBuffer.push({time:c(),settings:e})}_drainInertiaBuffer(){const e=this._inertiaBuffer,t=c();for(;e.length>0&&t-e[0].time>160;)e.shift()}_onMoveEnd(e){if(this._drainInertiaBuffer(),this._inertiaBuffer.length<2)return;const i={zoom:0,bearing:0,pitch:0,roll:0,pan:new t.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,i.roll+=e.rollDelta||0,e.panDelta&&i.pan._add(e.panDelta),e.around&&(i.around=e.around),e.pinchAround&&(i.pinchAround=e.pinchAround);const r=this._inertiaBuffer[this._inertiaBuffer.length-1].time-this._inertiaBuffer[0].time,n={};if(i.pan.mag()){const o=Xn(i.pan.mag(),r,t.e({},Hn,e||{})),s=i.pan.mult(o.amount/i.pan.mag()),a=this._map.cameraHelper.handlePanInertia(s,this._map.transform);n.center=a.easingCenter,n.offset=a.easingOffset,Kn(n,o)}if(i.zoom){const e=Xn(i.zoom,r,Qn);n.zoom=this._map.transform.zoom+e.amount,Kn(n,e)}if(i.bearing){const e=Xn(i.bearing,r,$n);n.bearing=this._map.transform.bearing+t.an(e.amount,-179,179),Kn(n,e)}if(i.pitch){const e=Xn(i.pitch,r,Zn);n.pitch=this._map.transform.pitch+e.amount,Kn(n,e)}if(i.roll){const e=Xn(i.roll,r,Wn);n.roll=this._map.transform.roll+t.an(e.amount,-179,179),Kn(n,e)}if(n.zoom||n.bearing){const e=void 0===i.pinchAround?i.around:i.pinchAround;n.around=e?this._map.unproject(e):this._map.getCenter()}return this.clear(),t.e(n,{noMoveStart:!0})}}function Kn(e,t){(!e.duration||e.durationi.unproject(e)),a=o.reduce((e,t,i,r)=>e.add(t.div(r.length)),new t.P(0,0));super(e,{points:o,point:a,lngLats:s,lngLat:i.unproject(a),originalEvent:r}),this._defaultPrevented=!1}}class eo extends t.l{preventDefault(){this._defaultPrevented=!0}get defaultPrevented(){return this._defaultPrevented}constructor(e,t,i){super(e,{originalEvent:i}),this._defaultPrevented=!1}}class to{constructor(e,t){this._map=e,this._clickTolerance=t.clickTolerance}reset(){delete this._mousedownPos}wheel(e){return this._firePreventable(new eo(e.type,this._map,e))}mousedown(e,t){return this._mousedownPos=t,this._firePreventable(new Jn(e.type,this._map,e))}mouseup(e){this._map.fire(new Jn(e.type,this._map,e))}click(e,t){this._mousedownPos&&this._mousedownPos.dist(t)>=this._clickTolerance||this._map.fire(new Jn(e.type,this._map,e))}dblclick(e){return this._firePreventable(new Jn(e.type,this._map,e))}mouseover(e){this._map.fire(new Jn(e.type,this._map,e))}mouseout(e){this._map.fire(new Jn(e.type,this._map,e))}touchstart(e){return this._firePreventable(new Yn(e.type,this._map,e))}touchmove(e){this._map.fire(new Yn(e.type,this._map,e))}touchend(e){this._map.fire(new Yn(e.type,this._map,e))}touchcancel(e){this._map.fire(new Yn(e.type,this._map,e))}_firePreventable(e){if(this._map.fire(e),e.defaultPrevented)return{}}isEnabled(){return!0}isActive(){return!1}enable(){}disable(){}}class io{constructor(e){this._map=e}reset(){this._delayContextMenu=!1,this._ignoreContextMenu=!0,delete this._contextMenuEvent}mousemove(e){this._map.fire(new Jn(e.type,this._map,e))}mousedown(){this._delayContextMenu=!0,this._ignoreContextMenu=!1}mouseup(){this._delayContextMenu=!1,this._contextMenuEvent&&(this._map.fire(new Jn("contextmenu",this._map,this._contextMenuEvent)),delete this._contextMenuEvent)}contextmenu(e){this._delayContextMenu?this._contextMenuEvent=e:this._ignoreContextMenu||this._map.fire(new Jn(e.type,this._map,e)),this._map.listens("contextmenu")&&e.preventDefault()}isEnabled(){return!0}isActive(){return!1}enable(){}disable(){}}class ro{constructor(e){this._map=e}get transform(){return this._map._requestedCameraState||this._map.transform}get center(){return{lng:this.transform.center.lng,lat:this.transform.center.lat}}get zoom(){return this.transform.zoom}get pitch(){return this.transform.pitch}get bearing(){return this.transform.bearing}unproject(e){return this.transform.screenPointToLocation(t.P.convert(e),this._map.terrain)}}class no{constructor(e,t){this._map=e,this._tr=new ro(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.disableDrag(),this._startPos=this._lastPos=t,this._active=!0)}mousemoveWindow(e,t){if(!this._active)return;const i=t;if(this._lastPos.equals(i)||!this._box&&i.dist(this._startPos)e.fitScreenCoordinates(r,n,this._tr.bearing,{linear:!0})};this._fireEvent("boxzoomcancel",e)}keydown(e){this._active&&27===e.keyCode&&(this.reset(),this._fireEvent("boxzoomcancel",e))}reset(){this._active=!1,this._container.classList.remove("maplibregl-crosshair"),this._box&&(u.remove(this._box),this._box=null),u.enableDrag(),delete this._startPos,delete this._lastPos}_fireEvent(e,i){return this._map.fire(new t.l(e,{originalEvent:i}))}}function oo(e,t){if(e.length!==t.length)throw new Error(`The number of touches and points are not equal - touches ${e.length}, points ${t.length}`);const i={};for(let r=0;rthis.numTouches)&&(this.aborted=!0),this.aborted||(void 0===this.startTime&&(this.startTime=e.timeStamp),r.length===this.numTouches&&(this.centroid=function(e){const i=new t.P(0,0);for(const t of e)i._add(t);return i.div(e.length)}(i),this.touches=oo(r,i)))}touchmove(e,t,i){if(this.aborted||!this.centroid)return;const r=oo(i,t);for(const e in this.touches){const t=r[e];(!t||t.dist(this.touches[e])>30)&&(this.aborted=!0)}}touchend(e,t,i){if((!this.centroid||e.timeStamp-this.startTime>500)&&(this.aborted=!0),0===i.length){const e=!this.aborted&&this.centroid;if(this.reset(),e)return e}}}class ao{constructor(e){this.singleTap=new so(e),this.numTaps=e.numTaps,this.reset()}reset(){this.lastTime=1/0,delete this.lastTap,this.count=0,this.singleTap.reset()}touchstart(e,t,i){this.singleTap.touchstart(e,t,i)}touchmove(e,t,i){this.singleTap.touchmove(e,t,i)}touchend(e,t,i){const r=this.singleTap.touchend(e,t,i);if(r){const t=e.timeStamp-this.lastTime<500,i=!this.lastTap||this.lastTap.dist(r)<30;if(t&&i||this.reset(),this.count++,this.lastTime=e.timeStamp,this.lastTap=r,this.count===this.numTaps)return this.reset(),r}}}class lo{constructor(e){this._tr=new ro(e),this._zoomIn=new ao({numTouches:1,numTaps:2}),this._zoomOut=new ao({numTouches:2,numTaps:1}),this.reset()}reset(){this._active=!1,this._zoomIn.reset(),this._zoomOut.reset()}touchstart(e,t,i){this._zoomIn.touchstart(e,t,i),this._zoomOut.touchstart(e,t,i)}touchmove(e,t,i){this._zoomIn.touchmove(e,t,i),this._zoomOut.touchmove(e,t,i)}touchend(e,t,i){const r=this._zoomIn.touchend(e,t,i),n=this._zoomOut.touchend(e,t,i),o=this._tr;return r?(this._active=!0,e.preventDefault(),setTimeout(()=>this.reset(),0),{cameraAnimation:t=>t.easeTo({duration:300,zoom:o.zoom+1,around:o.unproject(r)},{originalEvent:e})}):n?(this._active=!0,e.preventDefault(),setTimeout(()=>this.reset(),0),{cameraAnimation:t=>t.easeTo({duration:300,zoom:o.zoom-1,around:o.unproject(n)},{originalEvent:e})}):void 0}touchcancel(){this.reset()}enable(){this._enabled=!0}disable(){this._enabled=!1,this.reset()}isEnabled(){return this._enabled}isActive(){return this._active}}class co{constructor(e){this._enabled=!!e.enable,this._moveStateManager=e.moveStateManager,this._clickTolerance=e.clickTolerance||1,this._moveFunction=e.move,this._activateOnStart=!!e.activateOnStart,e.assignEvents(this),this.reset()}reset(e){this._active=!1,this._moved=!1,delete this._lastPoint,this._moveStateManager.endMove(e)}_move(...e){const t=this._moveFunction(...e);if(t.bearingDelta||t.pitchDelta||t.rollDelta||t.around||t.panDelta)return this._active=!0,t}dragStart(e,t){this.isEnabled()&&!this._lastPoint&&this._moveStateManager.isValidStartEvent(e)&&(this._moveStateManager.startMove(e),this._lastPoint=Array.isArray(t)?t[0]:t,this._activateOnStart&&this._lastPoint&&(this._active=!0))}dragMove(e,t){if(!this.isEnabled())return;const i=this._lastPoint;if(!i)return;if(e.preventDefault(),!this._moveStateManager.isValidMoveEvent(e))return void this.reset(e);const r=Array.isArray(t)?t[0]:t;return!this._moved&&r.dist(i)!0}),t=new mo){this.mouseMoveStateManager=e,this.oneFingerTouchMoveStateManager=t}_executeRelevantHandler(e,t,i){return e instanceof MouseEvent?t(e):"undefined"!=typeof TouchEvent&&e instanceof TouchEvent?i(e):void 0}startMove(e){this._executeRelevantHandler(e,e=>this.mouseMoveStateManager.startMove(e),e=>this.oneFingerTouchMoveStateManager.startMove(e))}endMove(e){this._executeRelevantHandler(e,e=>this.mouseMoveStateManager.endMove(e),e=>this.oneFingerTouchMoveStateManager.endMove(e))}isValidStartEvent(e){return this._executeRelevantHandler(e,e=>this.mouseMoveStateManager.isValidStartEvent(e),e=>this.oneFingerTouchMoveStateManager.isValidStartEvent(e))}isValidMoveEvent(e){return this._executeRelevantHandler(e,e=>this.mouseMoveStateManager.isValidMoveEvent(e),e=>this.oneFingerTouchMoveStateManager.isValidMoveEvent(e))}isValidEndEvent(e){return this._executeRelevantHandler(e,e=>this.mouseMoveStateManager.isValidEndEvent(e),e=>this.oneFingerTouchMoveStateManager.isValidEndEvent(e))}}const _o=e=>{e.mousedown=e.dragStart,e.mousemoveWindow=e.dragMove,e.mouseup=e.dragEnd,e.contextmenu=e=>{e.preventDefault()}};class Ao{constructor(e,t){this._clickTolerance=e.clickTolerance||1,this._map=t,this.reset()}reset(){this._active=!1,this._touches={},this._sum=new t.P(0,0)}_shouldBePrevented(e){return e<(this._map.cooperativeGestures.isEnabled()?2:1)}touchstart(e,t,i){return this._calculateTransform(e,t,i)}touchmove(e,t,i){if(this._active){if(!this._shouldBePrevented(i.length))return e.preventDefault(),this._calculateTransform(e,t,i);this._map.cooperativeGestures.notifyGestureBlocked("touch_pan",e)}}touchend(e,t,i){this._calculateTransform(e,t,i),this._active&&this._shouldBePrevented(i.length)&&this.reset()}touchcancel(){this.reset()}_calculateTransform(e,i,r){r.length>0&&(this._active=!0);const n=oo(r,i),o=new t.P(0,0),s=new t.P(0,0);let a=0;for(const e in n){const t=n[e],i=this._touches[e];i&&(o._add(t),s._add(t.sub(i)),a++,n[e]=t)}if(this._touches=n,this._shouldBePrevented(a)||!s.mag())return;const l=s.div(a);return this._sum._add(l),this._sum.mag()Math.abs(e.x)}class Co extends yo{constructor(e){super(),this._currentTouchCount=0,this._map=e}reset(){super.reset(),this._valid=void 0,delete this._firstMove,delete this._lastPoints}touchstart(e,t,i){super.touchstart(e,t,i),this._currentTouchCount=i.length}_start(e){this._lastPoints=e,Eo(e[0].sub(e[1]))&&(this._valid=!1)}_move(e,t,i){if(this._map.cooperativeGestures.isEnabled()&&this._currentTouchCount<3)return;const r=e[0].sub(this._lastPoints[0]),n=e[1].sub(this._lastPoints[1]);return this._valid=this.gestureBeginsVertically(r,n,i.timeStamp),this._valid?(this._lastPoints=e,this._active=!0,{pitchDelta:(r.y+n.y)/2*-.5}):void 0}gestureBeginsVertically(e,t,i){if(void 0!==this._valid)return this._valid;const r=e.mag()>=2,n=t.mag()>=2;if(!r&&!n)return;if(!r||!n)return void 0===this._firstMove&&(this._firstMove=i),i-this._firstMove<100&&void 0;const o=e.y>0==t.y>0;return Eo(e)&&Eo(t)&&o}}const Bo={panStep:100,bearingStep:15,pitchStep:10};class So{constructor(e){this._tr=new ro(e);const t=Bo;this._panStep=t.panStep,this._bearingStep=t.bearingStep,this._pitchStep=t.pitchStep,this._rotationDisabled=!1}reset(){this._active=!1}keydown(e){if(e.altKey||e.ctrlKey||e.metaKey)return;let t=0,i=0,r=0,n=0,o=0;switch(e.keyCode){case 61:case 107:case 171:case 187:t=1;break;case 189:case 109:case 173:t=-1;break;case 37:e.shiftKey?i=-1:(e.preventDefault(),n=-1);break;case 39:e.shiftKey?i=1:(e.preventDefault(),n=1);break;case 38:e.shiftKey?r=1:(e.preventDefault(),o=-1);break;case 40:e.shiftKey?r=-1:(e.preventDefault(),o=1);break;default:return}return this._rotationDisabled&&(i=0,r=0),{cameraAnimation:s=>{const a=this._tr;s.easeTo({duration:300,easeId:"keyboardHandler",easing:Io,zoom:t?Math.round(a.zoom)+t*(e.shiftKey?2:1):a.zoom,bearing:a.bearing+i*this._bearingStep,pitch:a.pitch+r*this._pitchStep,offset:[-n*this._panStep,-o*this._panStep],center:a.center},{originalEvent:e})}}}enable(){this._enabled=!0}disable(){this._enabled=!1,this.reset()}isEnabled(){return this._enabled}isActive(){return this._active}disableRotation(){this._rotationDisabled=!0}enableRotation(){this._rotationDisabled=!1}}function Io(e){return e*(2-e)}const Mo=4.000244140625,Po=1/450;class Ro{constructor(e,t){this._onTimeout=e=>{this._type="wheel",this._delta-=this._lastValue,this._active||this._start(e)},this._map=e,this._tr=new ro(e),this._triggerRenderFrame=t,this._delta=0,this._defaultZoomRate=.01,this._wheelZoomRate=Po}setZoomRate(e){this._defaultZoomRate=e}setWheelZoomRate(e){this._wheelZoomRate=e}isEnabled(){return!!this._enabled}isActive(){return!!this._active||void 0!==this._finishTimeout}isZooming(){return!!this._zooming}enable(e){this.isEnabled()||(this._enabled=!0,this._aroundCenter=!!e&&"center"===e.around)}disable(){this.isEnabled()&&(this._enabled=!1)}_shouldBePrevented(e){return!!this._map.cooperativeGestures.isEnabled()&&!(e.ctrlKey||this._map.cooperativeGestures.isBypassed(e))}wheel(e){if(!this.isEnabled())return;if(this._shouldBePrevented(e))return void this._map.cooperativeGestures.notifyGestureBlocked("wheel_zoom",e);let t=e.deltaMode===WheelEvent.DOM_DELTA_LINE?40*e.deltaY:e.deltaY;const i=c(),r=i-(this._lastWheelEventTime||0);this._lastWheelEventTime=i,0!==t&&t%Mo==0?this._type="wheel":0!==t&&Math.abs(t)<4?this._type="trackpad":r>400?(this._type=null,this._lastValue=t,this._timeout=setTimeout(this._onTimeout,40,e)):this._type||(this._type=Math.abs(r*t)<200?"trackpad":"wheel",this._timeout&&(clearTimeout(this._timeout),this._timeout=null,t+=this._lastValue)),e.shiftKey&&t&&(t/=4),this._type&&(this._lastWheelEvent=e,this._delta-=t,this._active||this._start(e)),e.preventDefault()}_start(e){if(!this._delta)return;this._frameId&&(this._frameId=null),this._active=!0,this.isZooming()||(this._zooming=!0),this._finishTimeout&&(clearTimeout(this._finishTimeout),delete this._finishTimeout);const i=u.mousePos(this._map.getCanvas(),e),r=this._tr;this._aroundPoint=this._aroundCenter?r.transform.locationToScreenPoint(t.V.convert(r.center)):i,this._frameId||(this._frameId=!0,this._triggerRenderFrame())}renderFrame(){if(!this._frameId)return;if(this._frameId=null,!this.isActive())return;const e=this._tr.transform;if("number"==typeof this._lastExpectedZoom){const t=e.zoom-this._lastExpectedZoom;"number"==typeof this._startZoom&&(this._startZoom+=t),"number"==typeof this._targetZoom&&(this._targetZoom+=t)}if(0!==this._delta){const i="wheel"===this._type&&Math.abs(this._delta)>Mo?this._wheelZoomRate:this._defaultZoomRate;let r=2/(1+Math.exp(-Math.abs(this._delta*i)));this._delta<0&&0!==r&&(r=1/r);const n="number"!=typeof this._targetZoom?e.scale:t.aq(this._targetZoom);this._targetZoom=e.applyConstrain(e.getCameraLngLat(),t.at(n*r)).zoom,"wheel"===this._type&&(this._startZoom=e.zoom,this._easing=this._smoothOutEasing(200)),this._delta=0}const i="number"!=typeof this._targetZoom?e.zoom:this._targetZoom,r=this._startZoom,n=this._easing;let o,s=!1;if("wheel"===this._type&&r&&n){const e=c()-this._lastWheelEventTime,a=Math.min((e+5)/200,1),l=n(a);o=t.G.number(r,i,l),a<1?this._frameId||(this._frameId=!0):s=!0}else o=i,s=!0;return this._active=!0,s&&(this._active=!1,this._finishTimeout=setTimeout(()=>{this._zooming=!1,this._triggerRenderFrame(),delete this._targetZoom,delete this._lastExpectedZoom,delete this._finishTimeout},200)),this._lastExpectedZoom=o,{noInertia:!0,needsRenderFrame:!s,zoomDelta:o-e.zoom,around:this._aroundPoint,originalEvent:this._lastWheelEvent}}_smoothOutEasing(e){let i=t.cx;if(this._prevEase){const e=this._prevEase,r=(c()-e.start)/e.duration,n=e.easing(r+.01)-e.easing(r),o=.27/Math.sqrt(n*n+1e-4)*.01,s=Math.sqrt(.0729-o*o);i=t.cv(o,s,.25,1)}return this._prevEase={start:c(),duration:e,easing:i},i}reset(){this._active=!1,this._zooming=!1,delete this._targetZoom,delete this._lastExpectedZoom,this._finishTimeout&&(clearTimeout(this._finishTimeout),delete this._finishTimeout)}}class Lo{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 Fo{constructor(e){this._tr=new ro(e),this.reset()}reset(){this._active=!1}dblclick(e,t){return e.preventDefault(),{cameraAnimation:i=>{i.easeTo({duration:300,zoom:this._tr.zoom+(e.shiftKey?-1:1),around:this._tr.unproject(t)},{originalEvent:e})}}}enable(){this._enabled=!0}disable(){this._enabled=!1,this.reset()}isEnabled(){return this._enabled}isActive(){return this._active}}class ko{constructor(){this._tap=new ao({numTouches:1,numTaps:1}),this.reset()}reset(){this._active=!1,delete this._swipePoint,delete this._swipeTouch,delete this._tapTime,delete this._tapPoint,this._tap.reset()}touchstart(e,t,i){if(!this._swipePoint)if(this._tapTime){const r=t[0],n=e.timeStamp-this._tapTime<500,o=this._tapPoint.dist(r)<30;n&&o?i.length>0&&(this._swipePoint=r,this._swipeTouch=i[0].identifier):this.reset()}else this._tap.touchstart(e,t,i)}touchmove(e,t,i){if(this._tapTime){if(this._swipePoint){if(i[0].identifier!==this._swipeTouch)return;const r=t[0],n=r.y-this._swipePoint.y;return this._swipePoint=r,e.preventDefault(),this._active=!0,{zoomDelta:n/128}}}else this._tap.touchmove(e,t,i)}touchend(e,t,i){if(this._tapTime)this._swipePoint&&0===i.length&&this.reset();else{const r=this._tap.touchend(e,t,i);r&&(this._tapTime=e.timeStamp,this._tapPoint=r)}}touchcancel(){this.reset()}enable(){this._enabled=!0}disable(){this._enabled=!1,this.reset()}isEnabled(){return this._enabled}isActive(){return this._active}}class Do{constructor(e,t,i){this._el=e,this._mousePan=t,this._touchPan=i}enable(e){this._inertiaOptions=e||{},this._mousePan.enable(),this._touchPan.enable(),this._el.classList.add("maplibregl-touch-drag-pan")}disable(){this._mousePan.disable(),this._touchPan.disable(),this._el.classList.remove("maplibregl-touch-drag-pan")}isEnabled(){return this._mousePan.isEnabled()&&this._touchPan.isEnabled()}isActive(){return this._mousePan.isActive()||this._touchPan.isActive()}}class Oo{constructor(e,t,i,r){this._pitchWithRotate=e.pitchWithRotate,this._rollEnabled=e.rollEnabled,this._mouseRotate=t,this._mousePitch=i,this._mouseRoll=r}enable(){this._mouseRotate.enable(),this._pitchWithRotate&&this._mousePitch.enable(),this._rollEnabled&&this._mouseRoll.enable()}disable(){this._mouseRotate.disable(),this._mousePitch.disable(),this._mouseRoll.disable()}isEnabled(){return this._mouseRotate.isEnabled()&&(!this._pitchWithRotate||this._mousePitch.isEnabled())&&(!this._rollEnabled||this._mouseRoll.isEnabled())}isActive(){return this._mouseRotate.isActive()||this._mousePitch.isActive()||this._mouseRoll.isActive()}}class zo{constructor(e,t,i,r){this._el=e,this._touchZoom=t,this._touchRotate=i,this._tapDragZoom=r,this._rotationDisabled=!1,this._enabled=!0}enable(e){this._touchZoom.enable(e),this._rotationDisabled||this._touchRotate.enable(e),this._tapDragZoom.enable(),this._el.classList.add("maplibregl-touch-zoom-rotate")}disable(){this._touchZoom.disable(),this._touchRotate.disable(),this._tapDragZoom.disable(),this._el.classList.remove("maplibregl-touch-zoom-rotate")}isEnabled(){return this._touchZoom.isEnabled()&&(this._rotationDisabled||this._touchRotate.isEnabled())&&this._tapDragZoom.isEnabled()}isActive(){return this._touchZoom.isActive()||this._touchRotate.isActive()||this._tapDragZoom.isActive()}disableRotation(){this._rotationDisabled=!0,this._touchRotate.disable()}enableRotation(){this._rotationDisabled=!1,this._touchZoom.isEnabled()&&this._touchRotate.enable()}}class Uo{constructor(e,t){this._bypassKey=-1!==navigator.userAgent.indexOf("Mac")?"metaKey":"ctrlKey",this._map=e,this._options=t,this._enabled=!1}isActive(){return!1}reset(){}_setupUI(){if(this._container)return;const e=this._map.getCanvasContainer();e.classList.add("maplibregl-cooperative-gestures"),this._container=u.create("div","maplibregl-cooperative-gesture-screen",e);let t=this._map._getUIString("CooperativeGesturesHandler.WindowsHelpText");"metaKey"===this._bypassKey&&(t=this._map._getUIString("CooperativeGesturesHandler.MacHelpText"));const i=this._map._getUIString("CooperativeGesturesHandler.MobileHelpText"),r=document.createElement("div");r.className="maplibregl-desktop-message",r.textContent=t,this._container.appendChild(r);const n=document.createElement("div");n.className="maplibregl-mobile-message",n.textContent=i,this._container.appendChild(n),this._container.setAttribute("aria-hidden","true")}_destroyUI(){this._container&&(u.remove(this._container),this._map.getCanvasContainer().classList.remove("maplibregl-cooperative-gestures")),delete this._container}enable(){this._setupUI(),this._enabled=!0}disable(){this._enabled=!1,this._destroyUI()}isEnabled(){return this._enabled}isBypassed(e){return e[this._bypassKey]}notifyGestureBlocked(e,i){this._enabled&&(this._map.fire(new t.l("cooperativegestureprevented",{gestureType:e,originalEvent:i})),this._container.classList.add("maplibregl-show"),setTimeout(()=>{this._container.classList.remove("maplibregl-show")},100))}}const No=e=>e.zoom||e.drag||e.roll||e.pitch||e.rotate;class Vo extends t.l{}function jo(e){return e.panDelta&&e.panDelta.mag()||e.zoomDelta||e.bearingDelta||e.pitchDelta||e.rollDelta}class Go{constructor(e,i){this.handleWindowEvent=e=>{this.handleEvent(e,`${e.type}Window`)},this.handleEvent=(e,i)=>{if("blur"===e.type)return void this.stop(!0);this._updatingCamera=!0;const r="renderFrame"===e.type?void 0:e,n={needsRenderFrame:!1},o={},s={};for(const{handlerName:a,handler:l,allowed:c}of this._handlers){if(!l.isEnabled())continue;let h;if(this._blockedByActive(s,c,a))l.reset();else if(l[i||e.type]){if(t.cy(e,i||e.type)){const t=u.mousePos(this._map.getCanvas(),e);h=l[i||e.type](e,t)}else if(t.cz(e,i||e.type)){const t=this._getMapTouches(e.touches),r=u.touchPos(this._map.getCanvas(),t);h=l[i||e.type](e,r,t)}else t.cA(i||e.type)||(h=l[i||e.type](e));this.mergeHandlerResult(n,o,h,a,r),h&&h.needsRenderFrame&&this._triggerRenderFrame()}(h||l.isActive())&&(s[a]=l)}const a={};for(const e in this._previousActiveHandlers)s[e]||(a[e]=r);this._previousActiveHandlers=s,(Object.keys(a).length||jo(n))&&(this._changes.push([n,o,a]),this._triggerRenderFrame()),(Object.keys(s).length||jo(n))&&this._map._stop(!0),this._updatingCamera=!1;const{cameraAnimation:l}=n;l&&(this._inertia.clear(),this._fireEvents({},{},!0),this._changes=[],l(this._map))},this._map=e,this._el=this._map.getCanvasContainer(),this._handlers=[],this._handlersById={},this._changes=[],this._inertia=new qn(e),this._bearingSnap=i.bearingSnap,this._previousActiveHandlers={},this._eventsInProgress={},this._addDefaultHandlers(i);const r=this._el;this._listeners=[[r,"touchstart",{passive:!0}],[r,"touchmove",{passive:!1}],[r,"touchend",void 0],[r,"touchcancel",void 0],[r,"mousedown",void 0],[r,"mousemove",void 0],[r,"mouseup",void 0],[document,"mousemove",{capture:!0}],[document,"mouseup",void 0],[r,"mouseover",void 0],[r,"mouseout",void 0],[r,"dblclick",void 0],[r,"click",void 0],[r,"keydown",{capture:!1}],[r,"keyup",void 0],[r,"wheel",{passive:!1}],[r,"contextmenu",void 0],[window,"blur",void 0]];for(const[e,t,i]of this._listeners)u.addEventListener(e,t,e===document?this.handleWindowEvent:this.handleEvent,i)}destroy(){for(const[e,t,i]of this._listeners)u.removeEventListener(e,t,e===document?this.handleWindowEvent:this.handleEvent,i)}_addDefaultHandlers(e){const i=this._map,r=i.getCanvasContainer();this._add("mapEvent",new to(i,e));const n=i.boxZoom=new no(i,e);this._add("boxZoom",n),e.interactive&&e.boxZoom&&n.enable();const o=i.cooperativeGestures=new Uo(i,e.cooperativeGestures);this._add("cooperativeGestures",o),e.cooperativeGestures&&o.enable();const s=new lo(i),a=new Fo(i);i.doubleClickZoom=new Lo(a,s),this._add("tapZoom",s),this._add("clickZoom",a),e.interactive&&e.doubleClickZoom&&i.doubleClickZoom.enable();const l=new ko;this._add("tapDragZoom",l);const c=i.touchPitch=new Co(i);this._add("touchPitch",c),e.interactive&&e.touchPitch&&i.touchPitch.enable(e.touchPitch);const h=()=>i.project(i.getCenter()),d=function({enable:e,clickTolerance:i,aroundCenter:r=!0,minPixelCenterThreshold:n=100,rotateDegreesPerPixelMoved:o=.8},s){const a=new fo({checkCorrectEvent:e=>0===u.mouseButton(e)&&e.ctrlKey||2===u.mouseButton(e)&&!e.ctrlKey});return new co({clickTolerance:i,move:(e,i)=>{const a=s();if(r&&Math.abs(a.y-e.y)>n)return{bearingDelta:t.cw(new t.P(e.x,i.y),i,a)};let l=(i.x-e.x)*o;return r&&i.y0===u.mouseButton(e)&&e.ctrlKey||2===u.mouseButton(e)});return new co({clickTolerance:t,move:(e,t)=>({pitchDelta:(t.y-e.y)*i}),moveStateManager:r,enable:e,assignEvents:_o})}(e),f=function({enable:e,clickTolerance:t,rollDegreesPerPixelMoved:i=.3},r){const n=new fo({checkCorrectEvent:e=>2===u.mouseButton(e)&&e.ctrlKey});return new co({clickTolerance:t,move:(e,t)=>{const n=r();let o=(t.x-e.x)*i;return t.y0===u.mouseButton(e)&&!e.ctrlKey});return new co({clickTolerance:t,move:(e,t)=>({around:t,panDelta:t.sub(e)}),activateOnStart:!0,moveStateManager:i,enable:e,assignEvents:_o})}(e),g=new Ao(e,i);i.dragPan=new Do(r,m,g),this._add("mousePan",m),this._add("touchPan",g,["touchZoom","touchRotate"]),e.interactive&&e.dragPan&&i.dragPan.enable(e.dragPan);const _=new To,A=new bo;i.touchZoomRotate=new zo(r,A,_,l),this._add("touchRotate",_,["touchPan","touchZoom"]),this._add("touchZoom",A,["touchPan","touchRotate"]),e.interactive&&e.touchZoomRotate&&i.touchZoomRotate.enable(e.touchZoomRotate),this._add("blockableMapEvent",new io(i));const y=i.scrollZoom=new Ro(i,()=>this._triggerRenderFrame());this._add("scrollZoom",y,["mousePan"]),e.interactive&&e.scrollZoom&&i.scrollZoom.enable(e.scrollZoom);const v=i.keyboard=new So(i);this._add("keyboard",v),e.interactive&&e.keyboard&&i.keyboard.enable()}_add(e,t,i){this._handlers.push({handlerName:e,handler:t,allowed:i}),this._handlersById[e]=t}stop(e){if(!this._updatingCamera){for(const{handler:e}of this._handlers)e.reset();this._inertia.clear(),this._fireEvents({},{},e),this._changes=[]}}isActive(){for(const{handler:e}of this._handlers)if(e.isActive())return!0;return!1}isZooming(){return!!this._eventsInProgress.zoom||this._map.scrollZoom.isZooming()}isRotating(){return!!this._eventsInProgress.rotate}isMoving(){return Boolean(No(this._eventsInProgress))||this.isZooming()}_blockedByActive(e,t,i){for(const r in e)if(r!==i&&(!t||t.indexOf(r)<0))return!0;return!1}_getMapTouches(e){const t=[];for(const i of e)this._el.contains(i.target)&&t.push(i);return t}mergeHandlerResult(e,i,r,n,o){if(!r)return;t.e(e,r);const s={handlerName:n,originalEvent:r.originalEvent||o};void 0!==r.zoomDelta&&(i.zoom=s),void 0!==r.panDelta&&(i.drag=s),void 0!==r.rollDelta&&(i.roll=s),void 0!==r.pitchDelta&&(i.pitch=s),void 0!==r.bearingDelta&&(i.rotate=s)}_applyChanges(){const e={},i={},r={};for(const[n,o,s]of this._changes)n.panDelta&&(e.panDelta=(e.panDelta||new t.P(0,0))._add(n.panDelta)),n.zoomDelta&&(e.zoomDelta=(e.zoomDelta||0)+n.zoomDelta),n.bearingDelta&&(e.bearingDelta=(e.bearingDelta||0)+n.bearingDelta),n.pitchDelta&&(e.pitchDelta=(e.pitchDelta||0)+n.pitchDelta),n.rollDelta&&(e.rollDelta=(e.rollDelta||0)+n.rollDelta),void 0!==n.around&&(e.around=n.around),void 0!==n.pinchAround&&(e.pinchAround=n.pinchAround),n.noInertia&&(e.noInertia=n.noInertia),t.e(i,o),t.e(r,s);this._updateMapTransform(e,i,r),this._changes=[]}_updateMapTransform(e,t,i){const r=this._map,n=r._getTransformForUpdate(),o=r.terrain;if(!(jo(e)||o&&this._terrainMovement))return this._fireEvents(t,i,!0);r._stop(!0);let{panDelta:s,zoomDelta:a,bearingDelta:l,pitchDelta:c,rollDelta:u,around:h,pinchAround:d}=e;void 0!==d&&(h=d),h=h||r.transform.centerPoint,o&&!n.isPointOnMapSurface(h)&&(h=n.centerPoint);const p={panDelta:s,zoomDelta:a,rollDelta:u,pitchDelta:c,bearingDelta:l,around:h};this._map.cameraHelper.useGlobeControls&&!n.isPointOnMapSurface(h)&&(h=n.centerPoint);const f=h.distSqr(n.centerPoint)<.01?n.center:n.screenPointToLocation(s?h.sub(s):h);this._handleMapControls({terrain:o,tr:n,deltasForHelper:p,preZoomAroundLoc:f,combinedEventsInProgress:t,panDelta:s}),r._applyUpdatedTransform(n),this._map._update(),e.noInertia||this._inertia.record(e),this._fireEvents(t,i,!0)}_handleMapControls({terrain:e,tr:t,deltasForHelper:i,preZoomAroundLoc:r,combinedEventsInProgress:n,panDelta:o}){const s=this._map.cameraHelper;if(s.handleMapControlsRollPitchBearingZoom(i,t),e)return s.useGlobeControls?(this._terrainMovement||!n.drag&&!n.zoom||(this._terrainMovement=!0,this._map._elevationFreeze=!0),void s.handleMapControlsPan(i,t,r)):this._terrainMovement||!n.drag&&!n.zoom?void(n.drag&&this._terrainMovement&&o?t.setCenter(t.screenPointToLocation(t.centerPoint.sub(o))):s.handleMapControlsPan(i,t,r)):(this._terrainMovement=!0,this._map._elevationFreeze=!0,void s.handleMapControlsPan(i,t,r));s.handleMapControlsPan(i,t,r)}_fireEvents(e,i,r){const n=No(this._eventsInProgress),o=No(e),s={};for(const t in e){const{originalEvent:i}=e[t];this._eventsInProgress[t]||(s[`${t}start`]=i),this._eventsInProgress[t]=e[t]}!n&&o&&this._fireEvent("movestart",o.originalEvent);for(const e in s)this._fireEvent(e,s[e]);o&&this._fireEvent("move",o.originalEvent);for(const t in e){const{originalEvent:i}=e[t];this._fireEvent(t,i)}const l={};let c;for(const e in this._eventsInProgress){const{handlerName:t,originalEvent:r}=this._eventsInProgress[e];this._handlersById[t].isActive()||(delete this._eventsInProgress[e],c=i[t]||r,l[`${e}end`]=c)}for(const e in l)this._fireEvent(e,l[e]);const u=No(this._eventsInProgress),h=(n||o)&&!u;if(h&&this._terrainMovement){this._map._elevationFreeze=!1,this._terrainMovement=!1;const e=this._map._getTransformForUpdate();this._map.getCenterClampedToGround()&&e.recalculateZoomAndCenter(this._map.terrain),this._map._applyUpdatedTransform(e)}if(r&&h){this._updatingCamera=!0;const e=this._inertia._onMoveEnd(this._map.dragPan._inertiaOptions),i=e=>0!==e&&-this._bearingSnap{delete this._frameId,this.handleEvent(new Vo("renderFrame",{timeStamp:e})),this._applyChanges()})}_triggerRenderFrame(){void 0===this._frameId&&(this._frameId=this._requestFrame())}}class Ho extends t.E{constructor(e,t,i){super(),this._renderFrameCallback=()=>{const e=Math.min((c()-this._easeStart)/this._easeOptions.duration,1);this._onEaseFrame(this._easeOptions.easing(e)),e<1&&this._easeFrameId?this._easeFrameId=this._requestRenderFrame(this._renderFrameCallback):this.stop()},this._moving=!1,this._zooming=!1,this.transform=e,this._bearingSnap=i.bearingSnap,this.cameraHelper=t,this.on("moveend",()=>{delete this._requestedCameraState})}migrateProjection(e,t){e.apply(this.transform),this.transform=e,this.cameraHelper=t}getCenter(){return new t.V(this.transform.center.lng,this.transform.center.lat)}setCenter(e,t){return this.jumpTo({center:e},t)}getCenterElevation(){return this.transform.elevation}setCenterElevation(e,t){return this.jumpTo({elevation:e},t),this}getCenterClampedToGround(){return this._centerClampedToGround}setCenterClampedToGround(e){this._centerClampedToGround=e}panBy(e,i,r){return e=t.P.convert(e).mult(-1),this.panTo(this.transform.center,t.e({offset:e},i),r)}panTo(e,i,r){return this.easeTo(t.e({center:e},i),r)}getZoom(){return this.transform.zoom}setZoom(e,t){return this.jumpTo({zoom:e},t),this}zoomTo(e,i,r){return this.easeTo(t.e({zoom:e},i),r)}zoomIn(e,t){return this.zoomTo(this.getZoom()+1,e,t),this}zoomOut(e,t){return this.zoomTo(this.getZoom()-1,e,t),this}getVerticalFieldOfView(){return this.transform.fov}setVerticalFieldOfView(e,i){return e!=this.transform.fov&&(this.transform.setFov(e),this.fire(new t.l("movestart",i)).fire(new t.l("move",i)).fire(new t.l("moveend",i))),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,i,r){return this.easeTo(t.e({bearing:e},i),r)}resetNorth(e,i){return this.rotateTo(0,t.e({duration:1e3},e),i),this}resetNorthPitch(e,i){return this.easeTo(t.e({bearing:0,pitch:0,roll:0,duration:1e3},e),i),this}snapToNorth(e,t){return Math.abs(this.getBearing()){g.easeFunc(t),this.terrain&&!e.freezeElevation&&this._updateElevation(t),this._applyUpdatedTransform(r),this._fireMoveEvents(i)},t=>{this.terrain&&e.freezeElevation&&this._finalizeElevation(),this._afterEase(i,t)},e),this}_prepareEase(e,i,r={}){this._moving=!0,i||r.moving||this.fire(new t.l("movestart",e)),this._zooming&&!r.zooming&&this.fire(new t.l("zoomstart",e)),this._rotating&&!r.rotating&&this.fire(new t.l("rotatestart",e)),this._pitching&&!r.pitching&&this.fire(new t.l("pitchstart",e)),this._rolling&&!r.rolling&&this.fire(new t.l("rollstart",e))}_prepareElevation(e){this._elevationCenter=e,this._elevationStart=this.transform.elevation,this._elevationTarget=this.terrain.getElevationForLngLatZoom(e,this.transform.tileZoom),this._elevationFreeze=!0}_updateElevation(e){void 0!==this._elevationStart&&void 0!==this._elevationCenter||this._prepareElevation(this.transform.center),this.transform.setMinElevationForCurrentTile(this.terrain.getMinTileElevationForLngLatZoom(this._elevationCenter,this.transform.tileZoom));const i=this.terrain.getElevationForLngLatZoom(this._elevationCenter,this.transform.tileZoom);if(e<1&&i!==this._elevationTarget){const t=this._elevationTarget-this._elevationStart;this._elevationStart+=e*(t-(i-(t*e+this._elevationStart))/(1-e)),this._elevationTarget=i}this.transform.setElevation(t.G.number(this._elevationStart,this._elevationTarget,e))}_finalizeElevation(){this._elevationFreeze=!1,this.getCenterClampedToGround()&&this.transform.recalculateZoomAndCenter(this.terrain)}_getTransformForUpdate(){return this.transformCameraUpdate||this.terrain?(this._requestedCameraState||(this._requestedCameraState=this.transform.clone()),this._requestedCameraState):this.transform}_elevateCameraIfInsideTerrain(e){if(!this.terrain&&e.elevation>=0&&e.pitch<=90)return{};const t=e.getCameraLngLat(),i=e.getCameraAltitude(),r=this.terrain?this.terrain.getElevationForLngLatZoom(t,e.zoom):0;if(ithis._elevateCameraIfInsideTerrain(e)),this.transformCameraUpdate&&t.push(e=>this.transformCameraUpdate(e)),!t.length)return;const i=e.clone();for(const e of t){const t=i.clone(),{center:r,zoom:n,roll:o,pitch:s,bearing:a,elevation:l}=e(t);r&&t.setCenter(r),void 0!==l&&t.setElevation(l),void 0!==n&&t.setZoom(n),void 0!==o&&t.setRoll(o),void 0!==s&&t.setPitch(s),void 0!==a&&t.setBearing(a),i.apply(t)}this.transform.apply(i)}_fireMoveEvents(e){this.fire(new t.l("move",e)),this._zooming&&this.fire(new t.l("zoom",e)),this._rotating&&this.fire(new t.l("rotate",e)),this._pitching&&this.fire(new t.l("pitch",e)),this._rolling&&this.fire(new t.l("roll",e))}_afterEase(e,i){if(this._easeId&&i&&this._easeId===i)return;delete this._easeId;const r=this._zooming,n=this._rotating,o=this._pitching,s=this._rolling;this._moving=!1,this._zooming=!1,this._rotating=!1,this._pitching=!1,this._rolling=!1,this._padding=!1,r&&this.fire(new t.l("zoomend",e)),n&&this.fire(new t.l("rotateend",e)),o&&this.fire(new t.l("pitchend",e)),s&&this.fire(new t.l("rollend",e)),this.fire(new t.l("moveend",e))}flyTo(e,i){if(!e.essential&&a.prefersReducedMotion){const r=t.U(e,["center","zoom","bearing","pitch","roll","elevation","padding"]);return this.jumpTo(r,i)}this.stop(),e=t.e({offset:[0,0],speed:1.2,curve:1.42,easing:t.cx},e);const r=this._getTransformForUpdate(),n=r.bearing,o=r.pitch,s=r.roll,l=r.padding,c="bearing"in e?this._normalizeBearing(e.bearing,n):n,u="pitch"in e?+e.pitch:o,h="roll"in e?this._normalizeBearing(e.roll,s):s,d="padding"in e?e.padding:r.padding,p=t.P.convert(e.offset);let f=r.centerPoint.add(p);const m=r.screenPointToLocation(f),g=this.cameraHelper.handleFlyTo(r,{bearing:c,pitch:u,roll:h,padding:d,locationAtOffset:m,offsetAsPoint:p,center:e.center,minZoom:e.minZoom,zoom:e.zoom});let _=e.curve;const A=Math.max(r.width,r.height),y=A/g.scaleOfZoom,v=g.pixelPathLength;"number"==typeof g.scaleOfMinZoom&&(_=Math.sqrt(A/g.scaleOfMinZoom/v*2));const x=_*_;function b(e){const t=(y*y-A*A+(e?-1:1)*x*x*v*v)/(2*(e?y:A)*x*v);return Math.log(Math.sqrt(t*t+1)-t)}function w(e){return(Math.exp(e)-Math.exp(-e))/2}function T(e){return(Math.exp(e)+Math.exp(-e))/2}const E=b(!1);let C=function(e){return T(E)/T(E+_*e)},B=function(e){return A*((T(E)*(w(t=E+_*e)/T(t))-w(E))/x)/v;var t},S=(b(!0)-E)/_;if(Math.abs(v)<2e-6||!isFinite(S)){if(Math.abs(A-y)<1e-6)return this.easeTo(e,i);const t=y0,C=e=>Math.exp(t*_*e)}return e.duration="duration"in e?+e.duration:1e3*S/("screenSpeed"in e?+e.screenSpeed/_:+e.speed),e.maxDuration&&e.duration>e.maxDuration&&(e.duration=0),this._zooming=!0,this._rotating=n!==c,this._pitching=u!==o,this._rolling=h!==s,this._padding=!r.isPaddingEqual(d),this._prepareEase(i,!1),this.terrain&&this._prepareElevation(g.targetCenter),this._ease(a=>{const m=a*S,_=1/C(m),A=B(m);this._rotating&&r.setBearing(t.G.number(n,c,a)),this._pitching&&r.setPitch(t.G.number(o,u,a)),this._rolling&&r.setRoll(t.G.number(s,h,a)),this._padding&&(r.interpolatePadding(l,d,a),f=r.centerPoint.add(p)),g.easeFunc(a,_,A,f),this.terrain&&!e.freezeElevation&&this._updateElevation(a),this._applyUpdatedTransform(r),this._fireMoveEvents(i)},()=>{this.terrain&&e.freezeElevation&&this._finalizeElevation(),this._afterEase(i)},e),this}isEasing(){return!!this._easeFrameId}stop(){return this._stop()}_stop(e,t){var i;if(this._easeFrameId&&(this._cancelRenderFrame(this._easeFrameId),delete this._easeFrameId,delete this._onEaseFrame),this._onEaseEnd){const e=this._onEaseEnd;delete this._onEaseEnd,e.call(this,t)}return e||null===(i=this.handlers)||void 0===i||i.stop(!1),this}_ease(e,t,i){!1===i.animate||0===i.duration?(e(1),t()):(this._easeStart=c(),this._easeOptions=i,this._onEaseFrame=e,this._onEaseEnd=t,this._easeFrameId=this._requestRenderFrame(this._renderFrameCallback))}_normalizeBearing(e,i){e=t.W(e,-180,180);const r=Math.abs(e-i);return Math.abs(e-360-i)MapLibre'};class $o{constructor(e=Qo){this._toggleAttribution=()=>{this._container.classList.contains("maplibregl-compact")&&(this._container.classList.contains("maplibregl-compact-show")?(this._container.setAttribute("open",""),this._container.classList.remove("maplibregl-compact-show")):(this._container.classList.add("maplibregl-compact-show"),this._container.removeAttribute("open")))},this._updateData=e=>{!e||"metadata"!==e.sourceDataType&&"visibility"!==e.sourceDataType&&"style"!==e.dataType&&"terrain"!==e.type||this._updateAttributions()},this._updateCompact=()=>{this._map.getCanvasContainer().offsetWidth<=640||this._compact?!1===this._compact?this._container.setAttribute("open",""):this._container.classList.contains("maplibregl-compact")||this._container.classList.contains("maplibregl-attrib-empty")||(this._container.setAttribute("open",""),this._container.classList.add("maplibregl-compact","maplibregl-compact-show")):(this._container.setAttribute("open",""),this._container.classList.contains("maplibregl-compact")&&this._container.classList.remove("maplibregl-compact","maplibregl-compact-show"))},this._updateCompactMinimize=()=>{this._container.classList.contains("maplibregl-compact")&&this._container.classList.contains("maplibregl-compact-show")&&this._container.classList.remove("maplibregl-compact-show")},this.options=e}getDefaultPosition(){return"bottom-right"}onAdd(e){return this._map=e,this._compact=this.options.compact,this._container=u.create("details","maplibregl-ctrl maplibregl-ctrl-attrib"),this._compactButton=u.create("summary","maplibregl-ctrl-attrib-button",this._container),this._compactButton.addEventListener("click",this._toggleAttribution),this._setElementTitle(this._compactButton,"ToggleAttribution"),this._innerContainer=u.create("div","maplibregl-ctrl-attrib-inner",this._container),this._updateAttributions(),this._updateCompact(),this._map.on("styledata",this._updateData),this._map.on("sourcedata",this._updateData),this._map.on("terrain",this._updateData),this._map.on("resize",this._updateCompact),this._map.on("drag",this._updateCompactMinimize),this._container}onRemove(){u.remove(this._container),this._map.off("styledata",this._updateData),this._map.off("sourcedata",this._updateData),this._map.off("terrain",this._updateData),this._map.off("resize",this._updateCompact),this._map.off("drag",this._updateCompactMinimize),this._map=void 0,this._compact=void 0,this._attribHTML=void 0}_setElementTitle(e,t){const i=this._map._getUIString(`AttributionControl.${t}`);e.title=i,e.setAttribute("aria-label",i)}_updateAttributions(){if(!this._map.style)return;let e=[];if(this.options.customAttribution&&(Array.isArray(this.options.customAttribution)?e=e.concat(this.options.customAttribution.map(e=>"string"!=typeof e?"":e)):"string"==typeof this.options.customAttribution&&e.push(this.options.customAttribution)),this._map.style.stylesheet){const e=this._map.style.stylesheet;this.styleOwner=e.owner,this.styleId=e.id}const t=this._map.style.tileManagers;for(const i in t){const r=t[i];if(r.used||r.usedForTerrain){const t=r.getSource();t.attribution&&e.indexOf(t.attribution)<0&&e.push(t.attribution)}}e=e.filter(e=>String(e).trim()),e.sort((e,t)=>e.length-t.length),e=e.filter((t,i)=>{for(let r=i+1;r=0)return!1;return!0});const i=e.join(" | ");i!==this._attribHTML&&(this._attribHTML=i,e.length?(this._innerContainer.innerHTML=u.sanitize(i),this._container.classList.remove("maplibregl-attrib-empty")):this._container.classList.add("maplibregl-attrib-empty"),this._updateCompact(),this._editLink=null)}}class Zo{constructor(e={}){this._updateCompact=()=>{const e=this._container.children;if(e.length){const t=e[0];this._map.getCanvasContainer().offsetWidth<=640||this._compact?!1!==this._compact&&t.classList.add("maplibregl-compact"):t.classList.remove("maplibregl-compact")}},this.options=e}getDefaultPosition(){return"bottom-left"}onAdd(e){this._map=e,this._compact=this.options&&this.options.compact,this._container=u.create("div","maplibregl-ctrl");const t=u.create("a","maplibregl-ctrl-logo");return t.target="_blank",t.rel="noopener nofollow",t.href="https://maplibre.org/",t.setAttribute("aria-label",this._map._getUIString("LogoControl.Title")),t.setAttribute("rel","noopener nofollow"),this._container.appendChild(t),this._container.style.display="block",this._map.on("resize",this._updateCompact),this._updateCompact(),this._container}onRemove(){u.remove(this._container),this._map.off("resize",this._updateCompact),this._map=void 0,this._compact=void 0}}class Wo{constructor(){this._queue=[],this._id=0,this._cleared=!1,this._currentlyRunning=!1}add(e){const t=++this._id;return this._queue.push({callback:e,id:t,cancelled:!1}),t}remove(e){const t=this._currentlyRunning,i=t?this._queue.concat(t):this._queue;for(const t of i)if(t.id===e)return void(t.cancelled=!0)}run(e=0){if(this._currentlyRunning)throw new Error("Attempting to run(), but is already running.");const t=this._currentlyRunning=this._queue;this._queue=[];for(const i of t)if(!i.cancelled&&(i.callback(e),this._cleared))break;this._cleared=!1,this._currentlyRunning=!1}clear(){this._currentlyRunning&&(this._cleared=!0),this._queue=[]}}var qo=t.aT([{name:"a_pos3d",type:"Int16",components:3}]);class Ko extends t.E{constructor(e){super(),this._lastTilesetChange=c(),this.tileManager=e,this._tiles={},this._renderableTilesKeys=[],this._sourceTileCache={},this.minzoom=0,this.maxzoom=22,this.deltaZoom=1,this.tileSize=e._source.tileSize*2**this.deltaZoom,e.usedForTerrain=!0,e.tileSize=this.tileSize}destruct(){this.tileManager.usedForTerrain=!1,this.tileManager.tileSize=null}getSource(){return this.tileManager._source}update(e,i){this.tileManager.update(e,i),this._renderableTilesKeys=[];const r={};for(const n of Ee(e,{tileSize:this.tileSize,minzoom:this.minzoom,maxzoom:this.maxzoom,reparseOverscaled:!1,terrain:i,calculateTileZoom:this.tileManager._source.calculateTileZoom}))r[n.key]=!0,this._renderableTilesKeys.push(n.key),this._tiles[n.key]||(n.terrainRttPosMatrix32f=new Float64Array(16),t.c6(n.terrainRttPosMatrix32f,0,t.a4,t.a4,0,0,1),this._tiles[n.key]=new de(n,this.tileSize),this._lastTilesetChange=c());for(const e in this._tiles)r[e]||delete this._tiles[e]}freeRtt(e){for(const t in this._tiles){const i=this._tiles[t];(!e||i.tileID.equals(e)||i.tileID.isChildOf(e)||e.isChildOf(i.tileID))&&(i.rtt=[])}}getRenderableTiles(){return this._renderableTilesKeys.map(e=>this.getTileByID(e))}getTileByID(e){return this._tiles[e]}getTerrainCoords(e,t){return t?this._getTerrainCoordsForTileRanges(e,t):this._getTerrainCoordsForRegularTile(e)}_getTerrainCoordsForRegularTile(e){const i={};for(const r of this._renderableTilesKeys){const n=this._tiles[r].tileID,o=e.clone(),s=t.bj();if(n.canonical.equals(e.canonical))t.c6(s,0,t.a4,t.a4,0,0,1);else if(n.canonical.isChildOf(e.canonical)){const i=n.canonical.z-e.canonical.z,r=n.canonical.x-(n.canonical.x>>i<>i<>i;t.c6(s,0,a,a,0,0,1),t.O(s,s,[-r*a,-o*a,0])}else{if(!e.canonical.isChildOf(n.canonical))continue;{const i=e.canonical.z-n.canonical.z,r=e.canonical.x-(e.canonical.x>>i<>i<>i;t.c6(s,0,t.a4,t.a4,0,0,1),t.O(s,s,[r*a,o*a,0]),t.Q(s,s,[1/2**i,1/2**i,0])}}o.terrainRttPosMatrix32f=new Float32Array(s),i[r]=o}return i}_getTerrainCoordsForTileRanges(e,i){const r={};for(const n of this._renderableTilesKeys){const o=this._tiles[n].tileID;if(!this._isWithinTileRanges(o,i))continue;const s=e.clone(),a=t.bj();if(o.canonical.z===e.canonical.z){const i=e.canonical.x-o.canonical.x,r=e.canonical.y-o.canonical.y;t.c6(a,0,t.a4,t.a4,0,0,1),t.O(a,a,[i*t.a4,r*t.a4,0])}else if(o.canonical.z>e.canonical.z){const i=o.canonical.z-e.canonical.z,r=o.canonical.x-(o.canonical.x>>i<>i<>i),l=e.canonical.y-(o.canonical.y>>i),c=t.a4>>i;t.c6(a,0,c,c,0,0,1),t.O(a,a,[-r*c+s*t.a4,-n*c+l*t.a4,0])}else{const i=e.canonical.z-o.canonical.z,r=e.canonical.x-(e.canonical.x>>i<>i<>i)-o.canonical.x,l=(e.canonical.y>>i)-o.canonical.y,c=t.a4<i.maxzoom&&(r=i.maxzoom),r=i.minzoom&&(!n||!n.dem);)n=this.tileManager.getTileByID(e.scaledTo(r--).key);return n}anyTilesAfterTime(e=Date.now()){return this._lastTilesetChange>=e}_isWithinTileRanges(e,t){return t[e.canonical.z]&&e.canonical.x>=t[e.canonical.z].minTileX&&e.canonical.x<=t[e.canonical.z].maxTileX&&e.canonical.y>=t[e.canonical.z].minTileY&&e.canonical.y<=t[e.canonical.z].maxTileY}}class Xo{constructor(e,t,i){this._meshCache={},this.painter=e,this.tileManager=new Ko(t),this.options=i,this.exaggeration="number"==typeof i.exaggeration?i.exaggeration:1,this.qualityFactor=2,this.meshSize=128,this._demMatrixCache={},this.coordsIndex=[],this._coordsTextureSize=1024}getDEMElevation(e,i,r,n=t.a4){var o;if(!(i>=0&&i=0&&re.canonical.z&&(e.canonical.z>=r?n=e.canonical.z-r:t.w("cannot calculate elevation if elevation maxzoom > source.maxzoom"));const o=e.canonical.x-(e.canonical.x>>n<>n<>8<<4|e>>8,i[t+3]=0;const r=new t.R({width:this._coordsTextureSize,height:this._coordsTextureSize},new Uint8Array(i.buffer)),n=new t.T(e,r,e.gl.RGBA,{premultiply:!1});return n.bind(e.gl.NEAREST,e.gl.CLAMP_TO_EDGE),this._coordsTexture=n,n}pointCoordinate(e){this.painter.maybeDrawDepthAndCoords(!0);const i=new Uint8Array(4),r=this.painter.context,n=r.gl,o=Math.round(e.x*this.painter.pixelRatio/devicePixelRatio),s=Math.round(e.y*this.painter.pixelRatio/devicePixelRatio),a=Math.round(this.painter.height/devicePixelRatio);r.bindFramebuffer.set(this.getFramebuffer("coords").framebuffer),n.readPixels(o,a-s-1,1,1,n.RGBA,n.UNSIGNED_BYTE,i),r.bindFramebuffer.set(null);const l=i[0]+(i[2]>>4<<8),c=i[1]+((15&i[2])<<8),u=this.coordsIndex[255-i[3]],h=u&&this.tileManager.getTileByID(u);if(!h)return null;const d=this._coordsTextureSize,p=(1<0,n=r&&0===e.canonical.y,o=r&&e.canonical.y===(1<e.id!==t),this._recentlyUsed.push(e.id)}stampObject(e){e.stamp=++this._stamp}getOrCreateFreeObject(){for(const e of this._recentlyUsed)if(!this._objects[e].inUse)return this._objects[e];if(this._objects.length>=this._size)throw new Error("No free RenderPool available, call freeAllObjects() required!");const e=this._createObject(this._objects.length);return this._objects.push(e),e}freeObject(e){e.inUse=!1}freeAllObjects(){for(const e of this._objects)this.freeObject(e)}isFull(){return!(this._objects.length!e.inUse)}}const Yo={background:!0,fill:!0,line:!0,raster:!0,hillshade:!0,"color-relief":!0};class es{constructor(e,t){this.painter=e,this.terrain=t,this.pool=new Jo(e.context,30,t.tileManager.tileSize*t.qualityFactor)}destruct(){this.pool.destruct()}getTexture(e){return this.pool.getObjectForId(e.rtt[this._stacks.length-1].id).texture}prepareForRender(e,t){this._stacks=[],this._prevType=null,this._rttTiles=[],this._renderableTiles=this.terrain.tileManager.getRenderableTiles(),this._renderableLayerIds=e._order.filter(i=>!e._layers[i].isHidden(t)),this._coordsAscending={};for(const t in e.tileManagers){this._coordsAscending[t]={};const i=e.tileManagers[t].getVisibleCoordinates(),r=e.tileManagers[t].getSource(),n=r instanceof te?r.terrainTileRanges:null;for(const e of i){const i=this.terrain.tileManager.getTerrainCoords(e,n);for(const e in i)this._coordsAscending[t][e]||(this._coordsAscending[t][e]=[]),this._coordsAscending[t][e].push(i[e])}}this._coordsAscendingStr={};for(const t of e._order){const i=e._layers[t],r=i.source;if(Yo[i.type]&&!this._coordsAscendingStr[r]){this._coordsAscendingStr[r]={};for(const e in this._coordsAscending[r])this._coordsAscendingStr[r][e]=this._coordsAscending[r][e].map(e=>e.key).sort().join()}}for(const e of this._renderableTiles)for(const t in this._coordsAscendingStr){const i=this._coordsAscendingStr[t][e.tileID.key];i&&i!==e.rttCoords[t]&&(e.rtt=[])}}renderLayer(e,i){if(e.isHidden(this.painter.transform.zoom))return!1;const r=Object.assign(Object.assign({},i),{isRenderingToTexture:!0}),n=e.type,o=this.painter,s=this._renderableLayerIds[this._renderableLayerIds.length-1]===e.id;if(Yo[n]&&(this._prevType&&Yo[this._prevType]||this._stacks.push([]),this._prevType=n,this._stacks[this._stacks.length-1].push(e.id),!s))return!0;if(Yo[this._prevType]||Yo[n]&&s){this._prevType=n;const e=this._stacks.length-1,i=this._stacks[e]||[];for(const n of this._renderableTiles){if(this.pool.isFull()&&(zn(this.painter,this.terrain,this._rttTiles,r),this._rttTiles=[],this.pool.freeAllObjects()),this._rttTiles.push(n),n.rtt[e]){const t=this.pool.getObjectForId(n.rtt[e].id);if(t.stamp===n.rtt[e].stamp){this.pool.useObject(t);continue}}const s=this.pool.getOrCreateFreeObject();this.pool.useObject(s),this.pool.stampObject(s),n.rtt[e]={id:s.id,stamp:s.stamp},o.context.bindFramebuffer.set(s.fbo.framebuffer),o.context.clear({color:t.bo.transparent,stencil:0}),o.currentStencilSource=void 0;for(let e=0;e{this.startMove(e,u.mousePos(this.element,e)),u.addEventListener(window,"mousemove",this.mousemove),u.addEventListener(window,"mouseup",this.mouseup)},this.mousemove=e=>{this.move(e,u.mousePos(this.element,e))},this.mouseup=e=>{this._rotatePitchHandler.dragEnd(e),this.offTemp()},this.touchstart=e=>{1!==e.targetTouches.length?this.reset():(this._startPos=this._lastPos=u.touchPos(this.element,e.targetTouches)[0],this.startMove(e,this._startPos),u.addEventListener(window,"touchmove",this.touchmove,{passive:!1}),u.addEventListener(window,"touchend",this.touchend))},this.touchmove=e=>{1!==e.targetTouches.length?this.reset():(this._lastPos=u.touchPos(this.element,e.targetTouches)[0],this.move(e,this._lastPos))},this.touchend=e=>{0===e.targetTouches.length&&this._startPos&&this._lastPos&&this._startPos.dist(this._lastPos){this._rotatePitchHandler.reset(),delete this._startPos,delete this._lastPos,this.offTemp()},this._clickTolerance=10,this.element=i;const n=new go;this._rotatePitchHandler=new co({clickTolerance:3,move:(e,n)=>{const o=i.getBoundingClientRect(),s=new t.P((o.bottom-o.top)/2,(o.right-o.left)/2);return{bearingDelta:t.cw(new t.P(e.x,n.y),n,s),pitchDelta:r?-.5*(n.y-e.y):void 0}},moveStateManager:n,enable:!0,assignEvents:()=>{}}),this.map=e,u.addEventListener(i,"mousedown",this.mousedown),u.addEventListener(i,"touchstart",this.touchstart,{passive:!1}),u.addEventListener(i,"touchcancel",this.reset)}startMove(e,t){this._rotatePitchHandler.dragStart(e,t),u.disableDrag()}move(e,t){const i=this.map,{bearingDelta:r,pitchDelta:n}=this._rotatePitchHandler.dragMove(e,t)||{};r&&i.setBearing(i.getBearing()+r),n&&i.setPitch(i.getPitch()+n)}off(){const e=this.element;u.removeEventListener(e,"mousedown",this.mousedown),u.removeEventListener(e,"touchstart",this.touchstart,{passive:!1}),u.removeEventListener(window,"touchmove",this.touchmove,{passive:!1}),u.removeEventListener(window,"touchend",this.touchend),u.removeEventListener(e,"touchcancel",this.reset),this.offTemp()}offTemp(){u.enableDrag(),u.removeEventListener(window,"mousemove",this.mousemove),u.removeEventListener(window,"mouseup",this.mouseup),u.removeEventListener(window,"touchmove",this.touchmove,{passive:!1}),u.removeEventListener(window,"touchend",this.touchend)}}let ss;function as(e,i,r,n=!1){if(n||!r.getCoveringTilesDetailsProvider().allowWorldCopies())return null==e?void 0:e.wrap();const o=new t.V(e.lng,e.lat);if(e=new t.V(e.lng,e.lat),i){const n=new t.V(e.lng-360,e.lat),o=new t.V(e.lng+360,e.lat),s=r.locationToScreenPoint(e).distSqr(i);r.locationToScreenPoint(n).distSqr(i)180;){const t=r.locationToScreenPoint(e);if(t.x>=0&&t.y>=0&&t.x<=r.width&&t.y<=r.height)break;e.lng>r.center.lng?e.lng-=360:e.lng+=360}return e.lng!==o.lng&&r.isPointOnMapSurface(r.locationToScreenPoint(e))?e:o}const ls={center:"translate(-50%,-50%)",top:"translate(-50%,0)","top-left":"translate(0,0)","top-right":"translate(-100%,0)",bottom:"translate(-50%,-100%)","bottom-left":"translate(0,-100%)","bottom-right":"translate(-100%,-100%)",left:"translate(0,-50%)",right:"translate(-100%,-50%)"};function cs(e,t,i){const r=e.classList;for(const e in ls)r.remove(`maplibregl-${i}-anchor-${e}`);r.add(`maplibregl-${i}-anchor-${t}`)}class us extends t.E{constructor(e){if(super(),this._onKeyPress=e=>{const t=e.code,i=e.charCode||e.keyCode;"Space"!==t&&"Enter"!==t&&32!==i&&13!==i||this.togglePopup()},this._onMapClick=e=>{const t=e.originalEvent.target,i=this._element;this._popup&&(t===i||i.contains(t))&&this.togglePopup()},this._update=e=>{if(!this._map)return;const t=this._map.loaded()&&!this._map.isMoving();("terrain"===(null==e?void 0:e.type)||"render"===(null==e?void 0:e.type)&&!t)&&this._map.once("render",this._update),this._lngLat=as(this._lngLat,this._flatPos,this._map.transform),this._flatPos=this._pos=this._map.project(this._lngLat)._add(this._offset),this._map.terrain&&(this._flatPos=this._map.transform.locationToScreenPoint(this._lngLat)._add(this._offset));let i="";"viewport"===this._rotationAlignment||"auto"===this._rotationAlignment?i=`rotateZ(${this._rotation}deg)`:"map"===this._rotationAlignment&&(i=`rotateZ(${this._rotation-this._map.getBearing()}deg)`);let r="";"viewport"===this._pitchAlignment||"auto"===this._pitchAlignment?r="rotateX(0deg)":"map"===this._pitchAlignment&&(r=`rotateX(${this._map.getPitch()}deg)`),this._subpixelPositioning||e&&"moveend"!==e.type||(this._pos=this._pos.round()),u.setTransform(this._element,`${ls[this._anchor]} translate(${this._pos.x}px, ${this._pos.y}px) ${r} ${i}`),a.frameAsync(new AbortController).then(()=>{this._updateOpacity(e&&"moveend"===e.type)}).catch(()=>{})},this._onMove=e=>{if(!this._isDragging){const t=this._clickTolerance||this._map._clickTolerance;this._isDragging=e.point.dist(this._pointerdownPos)>=t}this._isDragging&&(this._pos=e.point.sub(this._positionDelta),this._lngLat=this._map.unproject(this._pos),this.setLngLat(this._lngLat),this._element.style.pointerEvents="none","pending"===this._state&&(this._state="active",this.fire(new t.l("dragstart"))),this.fire(new t.l("drag")))},this._onUp=()=>{this._element.style.pointerEvents="auto",this._positionDelta=null,this._pointerdownPos=null,this._isDragging=!1,this._map.off("mousemove",this._onMove),this._map.off("touchmove",this._onMove),"active"===this._state&&this.fire(new t.l("dragend")),this._state="inactive"},this._addDragHandler=e=>{this._element.contains(e.originalEvent.target)&&(e.preventDefault(),this._positionDelta=e.point.sub(this._pos).add(this._offset),this._pointerdownPos=e.point,this._state="pending",this._map.on("mousemove",this._onMove),this._map.on("touchmove",this._onMove),this._map.once("mouseup",this._onUp),this._map.once("touchend",this._onUp))},this._anchor=e&&e.anchor||"center",this._color=e&&e.color||"#3FB1CE",this._scale=e&&e.scale||1,this._draggable=e&&e.draggable||!1,this._clickTolerance=e&&e.clickTolerance||0,this._subpixelPositioning=e&&e.subpixelPositioning||!1,this._isDragging=!1,this._state="inactive",this._rotation=e&&e.rotation||0,this._rotationAlignment=e&&e.rotationAlignment||"auto",this._pitchAlignment=e&&e.pitchAlignment&&"auto"!==e.pitchAlignment?e.pitchAlignment:this._rotationAlignment,this.setOpacity(null==e?void 0:e.opacity,null==e?void 0:e.opacityWhenCovered),e&&e.element)this._element=e.element,this._offset=t.P.convert(e&&e.offset||[0,0]);else{this._defaultMarker=!0,this._element=u.create("div");const i=u.createNS("http://www.w3.org/2000/svg","svg"),r=41,n=27;i.setAttributeNS(null,"display","block"),i.setAttributeNS(null,"height",`${r}px`),i.setAttributeNS(null,"width",`${n}px`),i.setAttributeNS(null,"viewBox",`0 0 ${n} ${r}`);const o=u.createNS("http://www.w3.org/2000/svg","g");o.setAttributeNS(null,"stroke","none"),o.setAttributeNS(null,"stroke-width","1"),o.setAttributeNS(null,"fill","none"),o.setAttributeNS(null,"fill-rule","evenodd");const s=u.createNS("http://www.w3.org/2000/svg","g");s.setAttributeNS(null,"fill-rule","nonzero");const a=u.createNS("http://www.w3.org/2000/svg","g");a.setAttributeNS(null,"transform","translate(3.0, 29.0)"),a.setAttributeNS(null,"fill","#000000");const l=[{rx:"10.5",ry:"5.25002273"},{rx:"10.5",ry:"5.25002273"},{rx:"9.5",ry:"4.77275007"},{rx:"8.5",ry:"4.29549936"},{rx:"7.5",ry:"3.81822308"},{rx:"6.5",ry:"3.34094679"},{rx:"5.5",ry:"2.86367051"},{rx:"4.5",ry:"2.38636864"}];for(const e of l){const t=u.createNS("http://www.w3.org/2000/svg","ellipse");t.setAttributeNS(null,"opacity","0.04"),t.setAttributeNS(null,"cx","10.5"),t.setAttributeNS(null,"cy","5.80029008"),t.setAttributeNS(null,"rx",e.rx),t.setAttributeNS(null,"ry",e.ry),a.appendChild(t)}const c=u.createNS("http://www.w3.org/2000/svg","g");c.setAttributeNS(null,"fill",this._color);const h=u.createNS("http://www.w3.org/2000/svg","path");h.setAttributeNS(null,"d","M27,13.5 C27,19.074644 20.250001,27.000002 14.75,34.500002 C14.016665,35.500004 12.983335,35.500004 12.25,34.500002 C6.7499993,27.000002 0,19.222562 0,13.5 C0,6.0441559 6.0441559,0 13.5,0 C20.955844,0 27,6.0441559 27,13.5 Z"),c.appendChild(h);const d=u.createNS("http://www.w3.org/2000/svg","g");d.setAttributeNS(null,"opacity","0.25"),d.setAttributeNS(null,"fill","#000000");const p=u.createNS("http://www.w3.org/2000/svg","path");p.setAttributeNS(null,"d","M13.5,0 C6.0441559,0 0,6.0441559 0,13.5 C0,19.222562 6.7499993,27 12.25,34.5 C13,35.522727 14.016664,35.500004 14.75,34.5 C20.250001,27 27,19.074644 27,13.5 C27,6.0441559 20.955844,0 13.5,0 Z M13.5,1 C20.415404,1 26,6.584596 26,13.5 C26,15.898657 24.495584,19.181431 22.220703,22.738281 C19.945823,26.295132 16.705119,30.142167 13.943359,33.908203 C13.743445,34.180814 13.612715,34.322738 13.5,34.441406 C13.387285,34.322738 13.256555,34.180814 13.056641,33.908203 C10.284481,30.127985 7.4148684,26.314159 5.015625,22.773438 C2.6163816,19.232715 1,15.953538 1,13.5 C1,6.584596 6.584596,1 13.5,1 Z"),d.appendChild(p);const f=u.createNS("http://www.w3.org/2000/svg","g");f.setAttributeNS(null,"transform","translate(6.0, 7.0)"),f.setAttributeNS(null,"fill","#FFFFFF");const m=u.createNS("http://www.w3.org/2000/svg","g");m.setAttributeNS(null,"transform","translate(8.0, 8.0)");const g=u.createNS("http://www.w3.org/2000/svg","circle");g.setAttributeNS(null,"fill","#000000"),g.setAttributeNS(null,"opacity","0.25"),g.setAttributeNS(null,"cx","5.5"),g.setAttributeNS(null,"cy","5.5"),g.setAttributeNS(null,"r","5.4999962");const _=u.createNS("http://www.w3.org/2000/svg","circle");_.setAttributeNS(null,"fill","#FFFFFF"),_.setAttributeNS(null,"cx","5.5"),_.setAttributeNS(null,"cy","5.5"),_.setAttributeNS(null,"r","5.4999962"),m.appendChild(g),m.appendChild(_),s.appendChild(a),s.appendChild(c),s.appendChild(d),s.appendChild(f),s.appendChild(m),i.appendChild(s),i.setAttributeNS(null,"height",r*this._scale+"px"),i.setAttributeNS(null,"width",n*this._scale+"px"),this._element.appendChild(i),this._offset=t.P.convert(e&&e.offset||[0,-14])}if(this._element.classList.add("maplibregl-marker"),this._element.addEventListener("dragstart",e=>{e.preventDefault()}),this._element.addEventListener("mousedown",e=>{e.preventDefault()}),cs(this._element,this._anchor,"marker"),e&&e.className)for(const t of e.className.split(" "))this._element.classList.add(t);this._popup=null}addTo(e){return this.remove(),this._map=e,this._element.hasAttribute("aria-label")||this._element.setAttribute("aria-label",e._getUIString("Marker.Title")),this._element.hasAttribute("role")||this._element.setAttribute("role","button"),e.getCanvasContainer().appendChild(this._element),e.on("move",this._update),e.on("moveend",this._update),e.on("terrain",this._update),e.on("projectiontransition",this._update),this.setDraggable(this._draggable),this._update(),this._map.on("click",this._onMapClick),this}remove(){return this._opacityTimeout&&(clearTimeout(this._opacityTimeout),delete this._opacityTimeout),this._map&&(this._map.off("click",this._onMapClick),this._map.off("move",this._update),this._map.off("moveend",this._update),this._map.off("terrain",this._update),this._map.off("projectiontransition",this._update),this._map.off("mousedown",this._addDragHandler),this._map.off("touchstart",this._addDragHandler),this._map.off("mouseup",this._onUp),this._map.off("touchend",this._onUp),this._map.off("mousemove",this._onMove),this._map.off("touchmove",this._onMove),delete this._map),u.remove(this._element),this._popup&&this._popup.remove(),this}getLngLat(){return this._lngLat}setLngLat(e){return this._lngLat=t.V.convert(e),this._pos=null,this._popup&&this._popup.setLngLat(this._lngLat),this._update(),this}getElement(){return this._element}setPopup(e){if(this._popup&&(this._popup.remove(),this._popup=null,this._element.removeEventListener("keypress",this._onKeyPress),this._originalTabIndex||this._element.removeAttribute("tabindex")),e){if(!("offset"in e.options)){const t=38.1,i=13.5,r=Math.abs(i)/Math.SQRT2;e.options.offset=this._defaultMarker?{top:[0,0],"top-left":[0,0],"top-right":[0,0],bottom:[0,-t],"bottom-left":[r,-1*(t-i+r)],"bottom-right":[-r,-1*(t-i+r)],left:[i,-1*(t-i)],right:[-i,-1*(t-i)]}:this._offset}this._popup=e,this._originalTabIndex=this._element.getAttribute("tabindex"),this._originalTabIndex||this._element.setAttribute("tabindex","0"),this._element.addEventListener("keypress",this._onKeyPress)}return this}setSubpixelPositioning(e){return this._subpixelPositioning=e,this}getPopup(){return this._popup}togglePopup(){const e=this._popup;return this._element.style.opacity===this._opacityWhenCovered?this:e?(e.isOpen()?e.remove():(e.setLngLat(this._lngLat),e.addTo(this._map)),this):this}_updateOpacity(e=!1){var i,r;const n=null===(i=this._map)||void 0===i?void 0:i.terrain,o=this._map.transform.isLocationOccluded(this._lngLat);if(!n||o){const e=o?this._opacityWhenCovered:this._opacity;return void(this._element.style.opacity!==e&&(this._element.style.opacity=e))}if(e)this._opacityTimeout=null;else{if(this._opacityTimeout)return;this._opacityTimeout=setTimeout(()=>{this._opacityTimeout=null},100)}const s=this._map,a=s.terrain.depthAtPoint(this._pos),l=s.terrain.getElevationForLngLatZoom(this._lngLat,s.transform.tileZoom);if(s.transform.lngLatToCameraDepth(this._lngLat,l)-a<.006)return void(this._element.style.opacity=this._opacity);const c=-this._offset.y/s.transform.pixelsPerMeter,u=Math.sin(s.getPitch()*Math.PI/180)*c,h=s.terrain.depthAtPoint(new t.P(this._pos.x,this._pos.y-this._offset.y)),d=s.transform.lngLatToCameraDepth(this._lngLat,l+u)-h>.006;(null===(r=this._popup)||void 0===r?void 0:r.isOpen())&&d&&this._popup.remove(),this._element.style.opacity=d?this._opacityWhenCovered:this._opacity}getOffset(){return this._offset}setOffset(e){return this._offset=t.P.convert(e),this._update(),this}addClassName(e){this._element.classList.add(e)}removeClassName(e){this._element.classList.remove(e)}toggleClassName(e){return this._element.classList.toggle(e)}setDraggable(e){return this._draggable=!!e,this._map&&(e?(this._map.on("mousedown",this._addDragHandler),this._map.on("touchstart",this._addDragHandler)):(this._map.off("mousedown",this._addDragHandler),this._map.off("touchstart",this._addDragHandler))),this}isDraggable(){return this._draggable}setRotation(e){return this._rotation=e||0,this._update(),this}getRotation(){return this._rotation}setRotationAlignment(e){return this._rotationAlignment=e||"auto",this._update(),this}getRotationAlignment(){return this._rotationAlignment}setPitchAlignment(e){return this._pitchAlignment=e&&"auto"!==e?e:this._rotationAlignment,this._update(),this}getPitchAlignment(){return this._pitchAlignment}setOpacity(e,t){return(void 0===this._opacity||void 0===e&&void 0===t)&&(this._opacity="1",this._opacityWhenCovered="0.2"),void 0!==e&&(this._opacity=e),void 0!==t&&(this._opacityWhenCovered=t),this._map&&this._updateOpacity(!0),this}}const hs={positionOptions:{enableHighAccuracy:!1,maximumAge:0,timeout:6e3},fitBoundsOptions:{maxZoom:15},trackUserLocation:!1,showAccuracyCircle:!0,showUserLocation:!0};let ds=0,ps=!1;const fs={maxWidth:100,unit:"metric"};function ms(e,t,i){const r=i&&i.maxWidth||100,n=e._container.clientHeight/2,o=e._container.clientWidth/2,s=e.unproject([o-r/2,n]),a=e.unproject([o+r/2,n]),l=Math.round(e.project(a).x-e.project(s).x),c=Math.min(r,l,e._container.clientWidth),u=s.distanceTo(a);if(i&&"imperial"===i.unit){const i=3.2808*u;i>5280?gs(t,c,i/5280,e._getUIString("ScaleControl.Miles")):gs(t,c,i,e._getUIString("ScaleControl.Feet"))}else i&&"nautical"===i.unit?gs(t,c,u/1852,e._getUIString("ScaleControl.NauticalMiles")):u>=1e3?gs(t,c,u/1e3,e._getUIString("ScaleControl.Kilometers")):gs(t,c,u,e._getUIString("ScaleControl.Meters"))}function gs(e,t,i,r){const n=function(e){const t=Math.pow(10,`${Math.floor(e)}`.length-1);let i=e/t;return i=i>=10?10:i>=5?5:i>=3?3:i>=2?2:i>=1?1:function(e){const t=Math.pow(10,Math.ceil(-Math.log(e)/Math.LN10));return Math.round(e*t)/t}(i),t*i}(i);e.style.width=t*(n/i)+"px",e.innerHTML=`${n} ${r}`}const _s={closeButton:!0,closeOnClick:!0,focusAfterOpen:!0,className:"",maxWidth:"240px",subpixelPositioning:!1,locationOccludedOpacity:void 0},As=["a[href]","[tabindex]:not([tabindex='-1'])","[contenteditable]:not([contenteditable='false'])","button:not([disabled])","input:not([disabled])","select:not([disabled])","textarea:not([disabled])"].join(", ");function ys(e){if(e){if("number"==typeof e){const i=Math.round(Math.abs(e)/Math.SQRT2);return{center:new t.P(0,0),top:new t.P(0,e),"top-left":new t.P(i,i),"top-right":new t.P(-i,i),bottom:new t.P(0,-e),"bottom-left":new t.P(i,-i),"bottom-right":new t.P(-i,-i),left:new t.P(e,0),right:new t.P(-e,0)}}if(e instanceof t.P||Array.isArray(e)){const i=t.P.convert(e);return{center:i,top:i,"top-left":i,"top-right":i,bottom:i,"bottom-left":i,"bottom-right":i,left:i,right:i}}return{center:t.P.convert(e.center||[0,0]),top:t.P.convert(e.top||[0,0]),"top-left":t.P.convert(e["top-left"]||[0,0]),"top-right":t.P.convert(e["top-right"]||[0,0]),bottom:t.P.convert(e.bottom||[0,0]),"bottom-left":t.P.convert(e["bottom-left"]||[0,0]),"bottom-right":t.P.convert(e["bottom-right"]||[0,0]),left:t.P.convert(e.left||[0,0]),right:t.P.convert(e.right||[0,0])}}return ys(new t.P(0,0))}const vs=i;e.AJAXError=t.cI,e.Event=t.l,e.Evented=t.E,e.LngLat=t.V,e.MercatorCoordinate=t.aa,e.Point=t.P,e.addProtocol=t.cJ,e.config=t.a,e.removeProtocol=t.cK,e.AttributionControl=$o,e.BoxZoomHandler=no,e.CanvasSource=re,e.CooperativeGesturesHandler=Uo,e.DoubleClickZoomHandler=Lo,e.DragPanHandler=Do,e.DragRotateHandler=Oo,e.EdgeInsets=Ft,e.FullscreenControl=class extends t.E{constructor(e={}){super(),this._onFullscreenChange=()=>{var e;let t=window.document.fullscreenElement||window.document.mozFullScreenElement||window.document.webkitFullscreenElement||window.document.msFullscreenElement;for(;null===(e=null==t?void 0:t.shadowRoot)||void 0===e?void 0:e.fullscreenElement;)t=t.shadowRoot.fullscreenElement;t===this._container!==this._fullscreen&&this._handleFullscreenChange()},this._onClickFullscreen=()=>{this._isFullscreen()?this._exitFullscreen():this._requestFullscreen()},this._fullscreen=!1,e&&e.container&&(e.container instanceof HTMLElement?this._container=e.container:t.w("Full screen control 'container' must be a DOM element.")),"onfullscreenchange"in document?this._fullscreenchange="fullscreenchange":"onmozfullscreenchange"in document?this._fullscreenchange="mozfullscreenchange":"onwebkitfullscreenchange"in document?this._fullscreenchange="webkitfullscreenchange":"onmsfullscreenchange"in document&&(this._fullscreenchange="MSFullscreenChange")}onAdd(e){return this._map=e,this._container||(this._container=this._map.getContainer()),this._controlContainer=u.create("div","maplibregl-ctrl maplibregl-ctrl-group"),this._setupUI(),this._controlContainer}onRemove(){u.remove(this._controlContainer),this._map=null,window.document.removeEventListener(this._fullscreenchange,this._onFullscreenChange)}_setupUI(){const e=this._fullscreenButton=u.create("button","maplibregl-ctrl-fullscreen",this._controlContainer);u.create("span","maplibregl-ctrl-icon",e).setAttribute("aria-hidden","true"),e.type="button",this._updateTitle(),this._fullscreenButton.addEventListener("click",this._onClickFullscreen),window.document.addEventListener(this._fullscreenchange,this._onFullscreenChange)}_updateTitle(){const e=this._getTitle();this._fullscreenButton.setAttribute("aria-label",e),this._fullscreenButton.title=e}_getTitle(){return this._map._getUIString(this._isFullscreen()?"FullscreenControl.Exit":"FullscreenControl.Enter")}_isFullscreen(){return this._fullscreen}_handleFullscreenChange(){this._fullscreen=!this._fullscreen,this._fullscreenButton.classList.toggle("maplibregl-ctrl-shrink"),this._fullscreenButton.classList.toggle("maplibregl-ctrl-fullscreen"),this._updateTitle(),this._fullscreen?(this.fire(new t.l("fullscreenstart")),this._prevCooperativeGesturesEnabled=this._map.cooperativeGestures.isEnabled(),this._map.cooperativeGestures.disable()):(this.fire(new t.l("fullscreenend")),this._prevCooperativeGesturesEnabled&&this._map.cooperativeGestures.enable())}_exitFullscreen(){window.document.exitFullscreen?window.document.exitFullscreen():window.document.mozCancelFullScreen?window.document.mozCancelFullScreen():window.document.msExitFullscreen?window.document.msExitFullscreen():window.document.webkitCancelFullScreen?window.document.webkitCancelFullScreen():this._togglePseudoFullScreen()}_requestFullscreen(){this._container.requestFullscreen?this._container.requestFullscreen():this._container.mozRequestFullScreen?this._container.mozRequestFullScreen():this._container.msRequestFullscreen?this._container.msRequestFullscreen():this._container.webkitRequestFullscreen?this._container.webkitRequestFullscreen():this._togglePseudoFullScreen()}_togglePseudoFullScreen(){this._container.classList.toggle("maplibregl-pseudo-fullscreen"),this._handleFullscreenChange(),this._map.resize()}},e.GeoJSONSource=ee,e.GeolocateControl=class extends t.E{constructor(e){super(),this._onSuccess=e=>{if(this._map){if(this._isOutOfMapMaxBounds(e))return this._setErrorState(),this.fire(new t.l("outofmaxbounds",e)),this._updateMarker(),void this._finish();if(this.options.trackUserLocation)switch(this._lastKnownPosition=e,this._watchState){case"WAITING_ACTIVE":case"ACTIVE_LOCK":case"ACTIVE_ERROR":this._watchState="ACTIVE_LOCK",this._geolocateButton.classList.remove("maplibregl-ctrl-geolocate-waiting"),this._geolocateButton.classList.remove("maplibregl-ctrl-geolocate-active-error"),this._geolocateButton.classList.add("maplibregl-ctrl-geolocate-active");break;case"BACKGROUND":case"BACKGROUND_ERROR":this._watchState="BACKGROUND",this._geolocateButton.classList.remove("maplibregl-ctrl-geolocate-waiting"),this._geolocateButton.classList.remove("maplibregl-ctrl-geolocate-background-error"),this._geolocateButton.classList.add("maplibregl-ctrl-geolocate-background");break;default:throw new Error(`Unexpected watchState ${this._watchState}`)}this.options.showUserLocation&&"OFF"!==this._watchState&&this._updateMarker(e),this.options.trackUserLocation&&"ACTIVE_LOCK"!==this._watchState||this._updateCamera(e),this.options.showUserLocation&&this._dotElement.classList.remove("maplibregl-user-location-dot-stale"),this.fire(new t.l("geolocate",e)),this._finish()}},this._updateCamera=e=>{const i=new t.V(e.coords.longitude,e.coords.latitude),r=e.coords.accuracy,n=this._map.getBearing(),o=t.e({bearing:n},this.options.fitBoundsOptions),s=Z.fromLngLat(i,r);this._map.fitBounds(s,o,{geolocateSource:!0})},this._updateMarker=e=>{if(e){const i=new t.V(e.coords.longitude,e.coords.latitude);this._accuracyCircleMarker.setLngLat(i).addTo(this._map),this._userLocationDotMarker.setLngLat(i).addTo(this._map),this._accuracy=e.coords.accuracy,this._updateCircleRadiusIfNeeded()}else this._userLocationDotMarker.remove(),this._accuracyCircleMarker.remove()},this._onUpdate=()=>{this._updateCircleRadiusIfNeeded()},this._onError=e=>{if(this._map){if(1===e.code){this._watchState="OFF",this._geolocateButton.classList.remove("maplibregl-ctrl-geolocate-waiting"),this._geolocateButton.classList.remove("maplibregl-ctrl-geolocate-active"),this._geolocateButton.classList.remove("maplibregl-ctrl-geolocate-active-error"),this._geolocateButton.classList.remove("maplibregl-ctrl-geolocate-background"),this._geolocateButton.classList.remove("maplibregl-ctrl-geolocate-background-error"),this._geolocateButton.disabled=!0;const e=this._map._getUIString("GeolocateControl.LocationNotAvailable");this._geolocateButton.title=e,this._geolocateButton.setAttribute("aria-label",e),void 0!==this._geolocationWatchID&&this._clearWatch()}else{if(3===e.code&&ps)return;this._setErrorState()}"OFF"!==this._watchState&&this.options.showUserLocation&&this._dotElement.classList.add("maplibregl-user-location-dot-stale"),this.fire(new t.l("error",e)),this._finish()}},this._finish=()=>{this._timeoutId&&clearTimeout(this._timeoutId),this._timeoutId=void 0},this._setupUI=()=>{this._map&&(this._container.addEventListener("contextmenu",e=>e.preventDefault()),this._geolocateButton=u.create("button","maplibregl-ctrl-geolocate",this._container),u.create("span","maplibregl-ctrl-icon",this._geolocateButton).setAttribute("aria-hidden","true"),this._geolocateButton.type="button",this._geolocateButton.disabled=!0)},this._finishSetupUI=e=>{if(this._map){if(!1===e){t.w("Geolocation support is not available so the GeolocateControl will be disabled.");const e=this._map._getUIString("GeolocateControl.LocationNotAvailable");this._geolocateButton.disabled=!0,this._geolocateButton.title=e,this._geolocateButton.setAttribute("aria-label",e)}else{const e=this._map._getUIString("GeolocateControl.FindMyLocation");this._geolocateButton.disabled=!1,this._geolocateButton.title=e,this._geolocateButton.setAttribute("aria-label",e)}this.options.trackUserLocation&&(this._geolocateButton.setAttribute("aria-pressed","false"),this._watchState="OFF"),this.options.showUserLocation&&(this._dotElement=u.create("div","maplibregl-user-location-dot"),this._userLocationDotMarker=new us({element:this._dotElement}),this._circleElement=u.create("div","maplibregl-user-location-accuracy-circle"),this._accuracyCircleMarker=new us({element:this._circleElement,pitchAlignment:"map"}),this.options.trackUserLocation&&(this._watchState="OFF"),this._map.on("zoom",this._onUpdate),this._map.on("move",this._onUpdate),this._map.on("rotate",this._onUpdate),this._map.on("pitch",this._onUpdate)),this._geolocateButton.addEventListener("click",()=>this.trigger()),this._setup=!0,this.options.trackUserLocation&&this._map.on("movestart",e=>{const i=(null==e?void 0:e[0])instanceof ResizeObserverEntry;e.geolocateSource||"ACTIVE_LOCK"!==this._watchState||i||this._map.isZooming()||(this._watchState="BACKGROUND",this._geolocateButton.classList.add("maplibregl-ctrl-geolocate-background"),this._geolocateButton.classList.remove("maplibregl-ctrl-geolocate-active"),this.fire(new t.l("trackuserlocationend")),this.fire(new t.l("userlocationlostfocus")))})}},this.options=t.e({},hs,e)}onAdd(e){return this._map=e,this._container=u.create("div","maplibregl-ctrl maplibregl-ctrl-group"),this._setupUI(),function(){return t._(this,arguments,void 0,function*(e=!1){if(void 0!==ss&&!e)return ss;if(void 0===window.navigator.permissions)return ss=!!window.navigator.geolocation,ss;try{const e=yield window.navigator.permissions.query({name:"geolocation"});ss="denied"!==e.state}catch(e){ss=!!window.navigator.geolocation}return ss})}().then(e=>this._finishSetupUI(e)),this._container}onRemove(){void 0!==this._geolocationWatchID&&(window.navigator.geolocation.clearWatch(this._geolocationWatchID),this._geolocationWatchID=void 0),this.options.showUserLocation&&this._userLocationDotMarker&&this._userLocationDotMarker.remove(),this.options.showAccuracyCircle&&this._accuracyCircleMarker&&this._accuracyCircleMarker.remove(),u.remove(this._container),this._map.off("zoom",this._onUpdate),this._map.off("move",this._onUpdate),this._map.off("rotate",this._onUpdate),this._map.off("pitch",this._onUpdate),this._map=void 0,ds=0,ps=!1}_isOutOfMapMaxBounds(e){const t=this._map.getMaxBounds(),i=e.coords;return t&&(i.longitudet.getEast()||i.latitudet.getNorth())}_setErrorState(){switch(this._watchState){case"WAITING_ACTIVE":this._watchState="ACTIVE_ERROR",this._geolocateButton.classList.remove("maplibregl-ctrl-geolocate-active"),this._geolocateButton.classList.add("maplibregl-ctrl-geolocate-active-error");break;case"ACTIVE_LOCK":this._watchState="ACTIVE_ERROR",this._geolocateButton.classList.remove("maplibregl-ctrl-geolocate-active"),this._geolocateButton.classList.add("maplibregl-ctrl-geolocate-active-error"),this._geolocateButton.classList.add("maplibregl-ctrl-geolocate-waiting");break;case"BACKGROUND":this._watchState="BACKGROUND_ERROR",this._geolocateButton.classList.remove("maplibregl-ctrl-geolocate-background"),this._geolocateButton.classList.add("maplibregl-ctrl-geolocate-background-error"),this._geolocateButton.classList.add("maplibregl-ctrl-geolocate-waiting");break;case"ACTIVE_ERROR":case"BACKGROUND_ERROR":case"OFF":case void 0:break;default:throw new Error(`Unexpected watchState ${this._watchState}`)}}_updateCircleRadiusIfNeeded(){const e=this._userLocationDotMarker.getLngLat();if(!(this.options.showUserLocation&&this.options.showAccuracyCircle&&this._accuracy&&e))return;const t=this._map.project(e),i=this._map.unproject([t.x+100,t.y]),r=e.distanceTo(i)/100,n=2*this._accuracy/r;this._circleElement.style.width=`${n.toFixed(2)}px`,this._circleElement.style.height=`${n.toFixed(2)}px`}trigger(){if(!this._setup)return t.w("Geolocate control triggered before added to a map"),!1;if(this.options.trackUserLocation){switch(this._watchState){case"OFF":this._watchState="WAITING_ACTIVE",this.fire(new t.l("trackuserlocationstart"));break;case"WAITING_ACTIVE":case"ACTIVE_LOCK":case"ACTIVE_ERROR":case"BACKGROUND_ERROR":ds--,ps=!1,this._watchState="OFF",this._geolocateButton.classList.remove("maplibregl-ctrl-geolocate-waiting"),this._geolocateButton.classList.remove("maplibregl-ctrl-geolocate-active"),this._geolocateButton.classList.remove("maplibregl-ctrl-geolocate-active-error"),this._geolocateButton.classList.remove("maplibregl-ctrl-geolocate-background"),this._geolocateButton.classList.remove("maplibregl-ctrl-geolocate-background-error"),this.fire(new t.l("trackuserlocationend"));break;case"BACKGROUND":this._watchState="ACTIVE_LOCK",this._geolocateButton.classList.remove("maplibregl-ctrl-geolocate-background"),this._lastKnownPosition&&this._updateCamera(this._lastKnownPosition),this.fire(new t.l("trackuserlocationstart")),this.fire(new t.l("userlocationfocus"));break;default:throw new Error(`Unexpected watchState ${this._watchState}`)}switch(this._watchState){case"WAITING_ACTIVE":this._geolocateButton.classList.add("maplibregl-ctrl-geolocate-waiting"),this._geolocateButton.classList.add("maplibregl-ctrl-geolocate-active");break;case"ACTIVE_LOCK":this._geolocateButton.classList.add("maplibregl-ctrl-geolocate-active");break;case"OFF":break;default:throw new Error(`Unexpected watchState ${this._watchState}`)}if("OFF"===this._watchState&&void 0!==this._geolocationWatchID)this._clearWatch();else if(void 0===this._geolocationWatchID){let e;this._geolocateButton.classList.add("maplibregl-ctrl-geolocate-waiting"),this._geolocateButton.setAttribute("aria-pressed","true"),ds++,ds>1?(e={maximumAge:6e5,timeout:0},ps=!0):(e=this.options.positionOptions,ps=!1),this._geolocationWatchID=window.navigator.geolocation.watchPosition(this._onSuccess,this._onError,e)}}else window.navigator.geolocation.getCurrentPosition(this._onSuccess,this._onError,this.options.positionOptions),this._timeoutId=setTimeout(this._finish,1e4);return!0}_clearWatch(){window.navigator.geolocation.clearWatch(this._geolocationWatchID),this._geolocationWatchID=void 0,this._geolocateButton.classList.remove("maplibregl-ctrl-geolocate-waiting"),this._geolocateButton.setAttribute("aria-pressed","false"),this.options.showUserLocation&&this._updateMarker(null)}},e.GlobeControl=class{constructor(){this._toggleProjection=()=>{var e;const t=null===(e=this._map.getProjection())||void 0===e?void 0:e.type;this._map.setProjection("mercator"!==t&&t?{type:"mercator"}:{type:"globe"}),this._updateGlobeIcon()},this._updateGlobeIcon=()=>{var e;this._globeButton.classList.remove("maplibregl-ctrl-globe"),this._globeButton.classList.remove("maplibregl-ctrl-globe-enabled"),"globe"===(null===(e=this._map.getProjection())||void 0===e?void 0:e.type)?(this._globeButton.classList.add("maplibregl-ctrl-globe-enabled"),this._globeButton.title=this._map._getUIString("GlobeControl.Disable")):(this._globeButton.classList.add("maplibregl-ctrl-globe"),this._globeButton.title=this._map._getUIString("GlobeControl.Enable"))}}onAdd(e){return this._map=e,this._container=u.create("div","maplibregl-ctrl maplibregl-ctrl-group"),this._globeButton=u.create("button","maplibregl-ctrl-globe",this._container),u.create("span","maplibregl-ctrl-icon",this._globeButton).setAttribute("aria-hidden","true"),this._globeButton.type="button",this._globeButton.addEventListener("click",this._toggleProjection),this._updateGlobeIcon(),this._map.on("styledata",this._updateGlobeIcon),this._container}onRemove(){u.remove(this._container),this._map.off("styledata",this._updateGlobeIcon),this._globeButton.removeEventListener("click",this._toggleProjection),this._map=void 0}},e.Hash=jn,e.ImageSource=te,e.KeyboardHandler=So,e.LngLatBounds=Z,e.LogoControl=Zo,e.Map=class extends Ho{constructor(e){var i,r;t.cF.mark(t.cG.create);const n=Object.assign(Object.assign(Object.assign({},rs),e),{canvasContextAttributes:Object.assign(Object.assign({},rs.canvasContextAttributes),e.canvasContextAttributes)});if(null!=n.minZoom&&null!=n.maxZoom&&n.minZoom>n.maxZoom)throw new Error("maxZoom must be greater than or equal to minZoom");if(null!=n.minPitch&&null!=n.maxPitch&&n.minPitch>n.maxPitch)throw new Error("maxPitch must be greater than or equal to minPitch");if(null!=n.minPitch&&n.minPitch<0)throw new Error("minPitch must be greater than or equal to 0");if(null!=n.maxPitch&&n.maxPitch>180)throw new Error("maxPitch must be less than or equal to 180");const o=new Vt,s=new Qt;if(void 0!==n.minZoom&&o.setMinZoom(n.minZoom),void 0!==n.maxZoom&&o.setMaxZoom(n.maxZoom),void 0!==n.minPitch&&o.setMinPitch(n.minPitch),void 0!==n.maxPitch&&o.setMaxPitch(n.maxPitch),void 0!==n.renderWorldCopies&&o.setRenderWorldCopies(n.renderWorldCopies),null!==n.transformConstrain&&o.setConstrainOverride(n.transformConstrain),super(o,s,{bearingSnap:n.bearingSnap}),this._idleTriggered=!1,this._crossFadingFactor=1,this._renderTaskQueue=new Wo,this._controls=[],this._mapId=t.ag(),this._lostContextStyle={style:null,images:null},this._contextLost=e=>{e.preventDefault(),this._frameRequest&&(this._frameRequest.abort(),this._frameRequest=null),this.painter.destroy();for(const e of Object.values(this.style._layers))if("custom"===e.type&&console.warn(`Custom layer with id '${e.id}' cannot be restored after WebGL context loss. You will need to re-add it manually after context restoration.`),e._listeners)for(const[t]of Object.entries(e._listeners))console.warn(`Custom layer with id '${e.id}' had event listeners for event '${t}' which cannot be restored after WebGL context loss. You will need to re-add them manually after context restoration.`);this._lostContextStyle=this._getStyleAndImages(),this.style.destroy(),this.style=null,this.fire(new t.l("webglcontextlost",{originalEvent:e}))},this._contextRestored=e=>{this._lostContextStyle.style&&this.setStyle(this._lostContextStyle.style,{diff:!1}),this._lostContextStyle.images&&(this.style.imageManager.images=this._lostContextStyle.images),this._setupPainter(),this.resize(),this._update(),this.fire(new t.l("webglcontextrestored",{originalEvent:e}))},this._onMapScroll=e=>{if(e.target===this._container)return this._container.scrollTop=0,this._container.scrollLeft=0,!1},this._onWindowOnline=()=>{this._update()},this._interactive=n.interactive,this._maxTileCacheSize=n.maxTileCacheSize,this._maxTileCacheZoomLevels=n.maxTileCacheZoomLevels,this._canvasContextAttributes=Object.assign({},n.canvasContextAttributes),this._trackResize=!0===n.trackResize,this._bearingSnap=n.bearingSnap,this._centerClampedToGround=n.centerClampedToGround,this._refreshExpiredTiles=!0===n.refreshExpiredTiles,this._fadeDuration=n.fadeDuration,this._crossSourceCollisions=!0===n.crossSourceCollisions,this._collectResourceTiming=!0===n.collectResourceTiming,this._locale=Object.assign(Object.assign({},ts),n.locale),this._clickTolerance=n.clickTolerance,this._overridePixelRatio=n.pixelRatio,this._maxCanvasSize=n.maxCanvasSize,this._zoomLevelsToOverscale=n.experimentalZoomLevelsToOverscale,this.transformCameraUpdate=n.transformCameraUpdate,this.transformConstrain=n.transformConstrain,this.cancelPendingTileRequestsWhileZooming=!0===n.cancelPendingTileRequestsWhileZooming,void 0!==n.reduceMotion&&(a.prefersReducedMotion=n.reduceMotion),this._imageQueueHandle=_.addThrottleControl(()=>this.isMoving()),this._requestManager=new A(n.transformRequest),"string"==typeof n.container){if(this._container=document.getElementById(n.container),!this._container)throw new Error(`Container '${n.container}' not found.`)}else{if(!(n.container instanceof HTMLElement))throw new Error("Invalid type: 'container' must be a String or HTMLElement.");this._container=n.container}if(n.maxBounds&&this.setMaxBounds(n.maxBounds),this._setupContainer(),this._setupPainter(),this.on("move",()=>this._update(!1)),this.on("moveend",()=>this._update(!1)),this.on("zoom",()=>this._update(!0)),this.on("terrain",()=>{this.painter.terrainFacilitator.dirty=!0,this._update(!0)}),this.once("idle",()=>{this._idleTriggered=!0}),"undefined"!=typeof window){addEventListener("online",this._onWindowOnline,!1);let e=!1;const t=Vn(e=>{this._trackResize&&!this._removed&&(this.resize(e),this.redraw())},50);this._resizeObserver=new ResizeObserver(i=>{e?t(i):e=!0}),this._resizeObserver.observe(this._container)}this.handlers=new Go(this,n),this._hash=n.hash&&new jn("string"==typeof n.hash&&n.hash||void 0).addTo(this),this._hash&&this._hash._onHashChange()||(this.jumpTo({center:n.center,elevation:n.elevation,zoom:n.zoom,bearing:n.bearing,pitch:n.pitch,roll:n.roll}),n.bounds&&(this.resize(),this.fitBounds(n.bounds,t.e({},n.fitBoundsOptions,{duration:0}))));const l="string"==typeof n.style||!("globe"===(null===(r=null===(i=n.style)||void 0===i?void 0:i.projection)||void 0===r?void 0:r.type));this.resize(null,l),this._localIdeographFontFamily=n.localIdeographFontFamily,this._validateStyle=n.validateStyle,n.style&&this.setStyle(n.style,{localIdeographFontFamily:n.localIdeographFontFamily}),n.attributionControl&&this.addControl(new $o("boolean"==typeof n.attributionControl?void 0:n.attributionControl)),n.maplibreLogo&&this.addControl(new Zo,n.logoPosition),this.on("style.load",()=>{if(l||this._resizeTransform(),this.transform.unmodified){const e=t.U(this.style.stylesheet,["center","zoom","bearing","pitch","roll"]);this.jumpTo(e)}}),this.on("data",e=>{this._update("style"===e.dataType),this.fire(new t.l(`${e.dataType}data`,e))}),this.on("dataloading",e=>{this.fire(new t.l(`${e.dataType}dataloading`,e))}),this.on("dataabort",e=>{this.fire(new t.l("sourcedataabort",e))})}_getMapId(){return this._mapId}setGlobalStateProperty(e,t){return this.style.setGlobalStateProperty(e,t),this._update(!0)}getGlobalState(){return this.style.getGlobalState()}addControl(e,i){if(void 0===i&&(i=e.getDefaultPosition?e.getDefaultPosition():"top-right"),!e||!e.onAdd)return this.fire(new t.k(new Error("Invalid argument to map.addControl(). Argument must be a control with onAdd and onRemove methods.")));const r=e.onAdd(this);this._controls.push(e);const n=this._controlPositions[i];return-1!==i.indexOf("bottom")?n.insertBefore(r,n.firstChild):n.appendChild(r),this}removeControl(e){if(!e||!e.onRemove)return this.fire(new t.k(new Error("Invalid argument to map.removeControl(). Argument must be a control with onAdd and onRemove methods.")));const i=this._controls.indexOf(e);return i>-1&&this._controls.splice(i,1),e.onRemove(this),this}hasControl(e){return this._controls.indexOf(e)>-1}coveringTiles(e){return Ee(this.transform,e)}calculateCameraOptionsFromTo(e,t,i,r){return null==r&&this.terrain&&(r=this.terrain.getElevationForLngLatZoom(i,this.transform.tileZoom)),super.calculateCameraOptionsFromTo(e,t,i,r)}resize(e,i=!0){const[r,n]=this._containerDimensions(),o=this._getClampedPixelRatio(r,n);if(this._resizeCanvas(r,n,o),this.painter.resize(r,n,o),this.painter.overLimit()){const e=this.painter.context.gl;this._maxCanvasSize=[e.drawingBufferWidth,e.drawingBufferHeight];const t=this._getClampedPixelRatio(r,n);this._resizeCanvas(r,n,t),this.painter.resize(r,n,t)}this._resizeTransform(i);const s=!this._moving;return s&&(this.stop(),this.fire(new t.l("movestart",e)).fire(new t.l("move",e))),this.fire(new t.l("resize",e)),s&&this.fire(new t.l("moveend",e)),this}_resizeTransform(e=!0){var t;const[i,r]=this._containerDimensions();this.transform.resize(i,r,e),null===(t=this._requestedCameraState)||void 0===t||t.resize(i,r,e)}_getClampedPixelRatio(e,t){const{0:i,1:r}=this._maxCanvasSize,n=this.getPixelRatio(),o=e*n,s=t*n;return Math.min(o>i?i/o:1,s>r?r/s:1)*n}getPixelRatio(){var e;return null!==(e=this._overridePixelRatio)&&void 0!==e?e:devicePixelRatio}setPixelRatio(e){this._overridePixelRatio=e,this.resize()}getBounds(){return this.transform.getBounds()}getMaxBounds(){return this.transform.getMaxBounds()}setMaxBounds(e){return this.transform.setMaxBounds(Z.convert(e)),this._update()}setMinZoom(e){if((e=null==e?-2:e)>=-2&&e<=this.transform.maxZoom)return this.transform.setMinZoom(e),this._update(),this.getZoom()=this.transform.minZoom)return this.transform.setMaxZoom(e),this._update(),this.getZoom()>e&&this.setZoom(e),this;throw new Error("maxZoom must be greater than the current minZoom")}getMaxZoom(){return this.transform.maxZoom}setMinPitch(e){if((e=null==e?0:e)<0)throw new Error("minPitch must be greater than or equal to 0");if(e>=0&&e<=this.transform.maxPitch)return this.transform.setMinPitch(e),this._update(),this.getPitch()180)throw new Error("maxPitch must be less than or equal to 180");if(e>=this.transform.minPitch)return this.transform.setMaxPitch(e),this._update(),this.getPitch()>e&&this.setPitch(e),this;throw new Error("maxPitch must be greater than the current minPitch")}getMaxPitch(){return this.transform.maxPitch}getRenderWorldCopies(){return this.transform.renderWorldCopies}setRenderWorldCopies(e){return this.transform.setRenderWorldCopies(e),this._update()}setTransformConstrain(e){return this.transform.setConstrainOverride(e),this._update()}project(e){return this.transform.locationToScreenPoint(t.V.convert(e),this.style&&this.terrain)}unproject(e){return this.transform.screenPointToLocation(t.P.convert(e),this.terrain)}isMoving(){var e;return this._moving||(null===(e=this.handlers)||void 0===e?void 0:e.isMoving())}isZooming(){var e;return this._zooming||(null===(e=this.handlers)||void 0===e?void 0:e.isZooming())}isRotating(){var e;return this._rotating||(null===(e=this.handlers)||void 0===e?void 0:e.isRotating())}_createDelegatedListener(e,t,i){if("mouseenter"===e||"mouseover"===e){let r=!1;const n=n=>{const o=t.filter(e=>this.getLayer(e)),s=0!==o.length?this.queryRenderedFeatures(n.point,{layers:o}):[];s.length?r||(r=!0,i.call(this,new Jn(e,this,n.originalEvent,{features:s}))):r=!1};return{layers:t,listener:i,delegates:{mousemove:n,mouseout:()=>{r=!1}}}}if("mouseleave"===e||"mouseout"===e){let r=!1;const n=n=>{const o=t.filter(e=>this.getLayer(e));(0!==o.length?this.queryRenderedFeatures(n.point,{layers:o}):[]).length?r=!0:r&&(r=!1,i.call(this,new Jn(e,this,n.originalEvent)))},o=t=>{r&&(r=!1,i.call(this,new Jn(e,this,t.originalEvent)))};return{layers:t,listener:i,delegates:{mousemove:n,mouseout:o}}}{const r=e=>{const r=t.filter(e=>this.getLayer(e)),n=0!==r.length?this.queryRenderedFeatures(e.point,{layers:r}):[];n.length&&(e.features=n,i.call(this,e),delete e.features)};return{layers:t,listener:i,delegates:{[e]:r}}}}_saveDelegatedListener(e,t){this._delegatedListeners=this._delegatedListeners||{},this._delegatedListeners[e]=this._delegatedListeners[e]||[],this._delegatedListeners[e].push(t)}_removeDelegatedListener(e,t,i){if(!this._delegatedListeners||!this._delegatedListeners[e])return;const r=this._delegatedListeners[e];for(let e=0;et.includes(e))){for(const e in n.delegates)this.off(e,n.delegates[e]);return void r.splice(e,1)}}}on(e,t,i){if(void 0===i)return super.on(e,t);const r="string"==typeof t?[t]:t,n=this._createDelegatedListener(e,r,i);this._saveDelegatedListener(e,n);for(const e in n.delegates)this.on(e,n.delegates[e]);return{unsubscribe:()=>{this._removeDelegatedListener(e,r,i)}}}once(e,t,i){if(void 0===i)return super.once(e,t);const r="string"==typeof t?[t]:t,n=this._createDelegatedListener(e,r,i);for(const t in n.delegates){const o=n.delegates[t];n.delegates[t]=(...t)=>{this._removeDelegatedListener(e,r,i),o(...t)}}this._saveDelegatedListener(e,n);for(const e in n.delegates)this.once(e,n.delegates[e]);return this}off(e,t,i){return void 0===i?super.off(e,t):(this._removeDelegatedListener(e,"string"==typeof t?[t]:t,i),this)}queryRenderedFeatures(e,i){if(!this.style)return[];let r;const n=e instanceof t.P||Array.isArray(e),o=n?e:[[0,0],[this.transform.width,this.transform.height]];if(i=i||(n?{}:e)||{},o instanceof t.P||"number"==typeof o[0])r=[t.P.convert(o)];else{const e=t.P.convert(o[0]),i=t.P.convert(o[1]);r=[e,new t.P(i.x,e.y),i,new t.P(e.x,i.y),e]}return this.style.queryRenderedFeatures(r,i,this.transform)}querySourceFeatures(e,t){return this.style.querySourceFeatures(e,t)}setStyle(e,i){return!1!==(i=t.e({},{localIdeographFontFamily:this._localIdeographFontFamily,validate:this._validateStyle},i)).diff&&i.localIdeographFontFamily===this._localIdeographFontFamily&&this.style&&e?(this._diffStyle(e,i),this):(this._localIdeographFontFamily=i.localIdeographFontFamily,this._updateStyle(e,i))}setTransformRequest(e){return this._requestManager.setTransformRequest(e),this}_getUIString(e){const t=this._locale[e];if(null==t)throw new Error(`Missing UI string '${e}'`);return t}_updateStyle(e,t){var i,r;if(t.transformStyle&&this.style&&!this.style._loaded)return void this.style.once("style.load",()=>this._updateStyle(e,t));const n=this.style&&t.transformStyle?this.style.serialize():void 0;return this.style&&(this.style.setEventedParent(null),this.style._remove(!e)),e?(this.style=new Ii(this,t||{}),this.style.setEventedParent(this,{style:this.style}),"string"==typeof e?this.style.loadURL(e,t,n):this.style.loadJSON(e,t,n),this):(null===(r=null===(i=this.style)||void 0===i?void 0:i.projection)||void 0===r||r.destroy(),delete this.style,this)}_lazyInitEmptyStyle(){this.style||(this.style=new Ii(this,{}),this.style.setEventedParent(this,{style:this.style}),this.style.loadEmpty())}_diffStyle(e,i){if("string"==typeof e){const r=this._requestManager.transformRequest(e,"Style");t.j(r,new AbortController).then(e=>{this._updateDiff(e.data,i)}).catch(e=>{e&&this.fire(new t.k(e))})}else"object"==typeof e&&this._updateDiff(e,i)}_updateDiff(e,i){try{this.style.setState(e,i)&&this._update(!0)}catch(r){t.w(`Unable to perform style diff: ${r.message||r.error||r}. Rebuilding the style from scratch.`),this._updateStyle(e,i)}}getStyle(){if(this.style)return this.style.serialize()}_getStyleAndImages(){return this.style?{style:this.style.serialize(),images:this.style.imageManager.cloneImages()}:{style:null,images:{}}}isStyleLoaded(){return this.style?this.style.loaded():t.w("There is no style added to the map.")}addSource(e,t){return this._lazyInitEmptyStyle(),this.style.addSource(e,t),this._update(!0)}isSourceLoaded(e){const i=this.style&&this.style.tileManagers[e];if(void 0!==i)return i.loaded();this.fire(new t.k(new Error(`There is no tile manager with ID '${e}'`)))}setTerrain(e){if(this.style._checkLoaded(),this._terrainDataCallback&&this.style.off("data",this._terrainDataCallback),e){const i=this.style.tileManagers[e.source];if(!i)throw new Error(`cannot load terrain, because there exists no source with ID: ${e.source}`);null===this.terrain&&i.reload();for(const i in this.style._layers){const r=this.style._layers[i];"hillshade"===r.type&&r.source===e.source&&t.w("You are using the same source for a hillshade layer and for 3D terrain. Please consider using two separate sources to improve rendering quality."),"color-relief"===r.type&&r.source===e.source&&t.w("You are using the same source for a color-relief layer and for 3D terrain. Please consider using two separate sources to improve rendering quality.")}this.terrain=new Xo(this.painter,i,e),this.painter.renderToTexture=new es(this.painter,this.terrain),this.transform.setMinElevationForCurrentTile(this.terrain.getMinTileElevationForLngLatZoom(this.transform.center,this.transform.tileZoom)),this.transform.setElevation(this.terrain.getElevationForLngLatZoom(this.transform.center,this.transform.tileZoom)),this._terrainDataCallback=t=>{var i;"style"===t.dataType?this.terrain.tileManager.freeRtt():"source"===t.dataType&&t.tile&&(t.sourceId!==e.source||this._elevationFreeze||(this.transform.setMinElevationForCurrentTile(this.terrain.getMinTileElevationForLngLatZoom(this.transform.center,this.transform.tileZoom)),this._centerClampedToGround&&this.transform.setElevation(this.terrain.getElevationForLngLatZoom(this.transform.center,this.transform.tileZoom))),"image"===(null===(i=t.source)||void 0===i?void 0:i.type)?this.terrain.tileManager.freeRtt():this.terrain.tileManager.freeRtt(t.tile.tileID))},this.style.on("data",this._terrainDataCallback)}else this.terrain&&this.terrain.tileManager.destruct(),this.terrain=null,this.painter.renderToTexture&&this.painter.renderToTexture.destruct(),this.painter.renderToTexture=null,this.transform.setMinElevationForCurrentTile(0),this._centerClampedToGround&&this.transform.setElevation(0);return this.fire(new t.l("terrain",{terrain:e})),this}getTerrain(){var e,t;return null!==(t=null===(e=this.terrain)||void 0===e?void 0:e.options)&&void 0!==t?t:null}areTilesLoaded(){const e=this.style&&this.style.tileManagers;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}removeSource(e){return this.style.removeSource(e),this._update(!0)}getSource(e){return this.style.getSource(e)}setSourceTileLodParams(e,t,i){if(i){const r=this.getSource(i);if(!r)throw new Error(`There is no source with ID "${i}", cannot set LOD parameters`);r.calculateTileZoom=be(Math.max(1,e),Math.max(1,t))}else for(const i in this.style.tileManagers)this.style.tileManagers[i].getSource().calculateTileZoom=be(Math.max(1,e),Math.max(1,t));return this._update(!0),this}refreshTiles(e,i){const r=this.style.tileManagers[e];if(!r)throw new Error(`There is no tile manager with ID "${e}", cannot refresh tile`);void 0===i?r.reload(!0):r.refreshTiles(i.map(e=>new t.ad(e.z,e.x,e.y)))}addImage(e,i,r={}){const{pixelRatio:n=1,sdf:o=!1,stretchX:s,stretchY:l,content:c,textFitWidth:u,textFitHeight:h}=r;if(this._lazyInitEmptyStyle(),!(i instanceof HTMLImageElement||t.b(i))){if(void 0===i.width||void 0===i.height)return this.fire(new t.k(new Error("Invalid arguments to map.addImage(). The second argument must be an `HTMLImageElement`, `ImageData`, `ImageBitmap`, or object with `width`, `height`, and `data` properties with the same format as `ImageData`")));{const{width:r,height:a,data:d}=i,p=i;return this.style.addImage(e,{data:new t.R({width:r,height:a},new Uint8Array(d)),pixelRatio:n,stretchX:s,stretchY:l,content:c,textFitWidth:u,textFitHeight:h,sdf:o,version:0,userImage:p}),p.onAdd&&p.onAdd(this,e),this}}{const{width:r,height:d,data:p}=a.getImageData(i);this.style.addImage(e,{data:new t.R({width:r,height:d},p),pixelRatio:n,stretchX:s,stretchY:l,content:c,textFitWidth:u,textFitHeight:h,sdf:o,version:0})}}updateImage(e,i){const r=this.style.getImage(e);if(!r)return this.fire(new t.k(new Error("The map has no image with that id. If you are adding a new image use `map.addImage(...)` instead.")));const n=i instanceof HTMLImageElement||t.b(i)?a.getImageData(i):i,{width:o,height:s,data:l}=n;if(void 0===o||void 0===s)return this.fire(new t.k(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(o!==r.data.width||s!==r.data.height)return this.fire(new t.k(new Error("The width and height of the updated image must be that same as the previous version of the image")));const c=!(i instanceof HTMLImageElement||t.b(i));return r.data.replace(l,c),this.style.updateImage(e,r),this}getImage(e){return this.style.getImage(e)}hasImage(e){return e?!!this.style.getImage(e):(this.fire(new t.k(new Error("Missing required image id"))),!1)}removeImage(e){this.style.removeImage(e)}loadImage(e){return _.getImage(this._requestManager.transformRequest(e,"Image"),new AbortController)}listImages(){return this.style.listImages()}addLayer(e,t){return this._lazyInitEmptyStyle(),this.style.addLayer(e,t),this._update(!0)}moveLayer(e,t){return this.style.moveLayer(e,t),this._update(!0)}removeLayer(e){return this.style.removeLayer(e),this._update(!0)}getLayer(e){return this.style.getLayer(e)}getLayersOrder(){return this.style.getLayersOrder()}setLayerZoomRange(e,t,i){return this.style.setLayerZoomRange(e,t,i),this._update(!0)}setFilter(e,t,i={}){return this.style.setFilter(e,t,i),this._update(!0)}getFilter(e){return this.style.getFilter(e)}setPaintProperty(e,t,i,r={}){return this.style.setPaintProperty(e,t,i,r),this._update(!0)}getPaintProperty(e,t){return this.style.getPaintProperty(e,t)}setLayoutProperty(e,t,i,r={}){return this.style.setLayoutProperty(e,t,i,r),this._update(!0)}getLayoutProperty(e,t){return this.style.getLayoutProperty(e,t)}setGlyphs(e,t={}){return this._lazyInitEmptyStyle(),this.style.setGlyphs(e,t),this._update(!0)}getGlyphs(){return this.style.getGlyphsUrl()}addSprite(e,t,i={}){return this._lazyInitEmptyStyle(),this.style.addSprite(e,t,i,e=>{e||this._update(!0)}),this}removeSprite(e){return this._lazyInitEmptyStyle(),this.style.removeSprite(e),this._update(!0)}getSprite(){return this.style.getSprite()}setSprite(e,t={}){return this._lazyInitEmptyStyle(),this.style.setSprite(e,t,e=>{e||this._update(!0)}),this}setLight(e,t={}){return this._lazyInitEmptyStyle(),this.style.setLight(e,t),this._update(!0)}getLight(){return this.style.getLight()}setSky(e,t={}){return this._lazyInitEmptyStyle(),this.style.setSky(e,t),this._update(!0)}getSky(){return this.style.getSky()}setFeatureState(e,t){return this.style.setFeatureState(e,t),this._update()}removeFeatureState(e,t){return this.style.removeFeatureState(e,t),this._update()}getFeatureState(e){return this.style.getFeatureState(e)}getContainer(){return this._container}getCanvasContainer(){return this._canvasContainer}getCanvas(){return this._canvas}_containerDimensions(){let e=0,t=0;return this._container&&(e=this._container.clientWidth||400,t=this._container.clientHeight||300),[e,t]}_setupContainer(){const e=this._container;e.classList.add("maplibregl-map");const t=this._canvasContainer=u.create("div","maplibregl-canvas-container",e);this._interactive&&t.classList.add("maplibregl-interactive"),this._canvas=u.create("canvas","maplibregl-canvas",t),this._canvas.addEventListener("webglcontextlost",this._contextLost,!1),this._canvas.addEventListener("webglcontextrestored",this._contextRestored,!1),this._canvas.setAttribute("tabindex",this._interactive?"0":"-1"),this._canvas.setAttribute("aria-label",this._getUIString("Map.Title")),this._canvas.setAttribute("role","region");const i=this._containerDimensions(),r=this._getClampedPixelRatio(i[0],i[1]);this._resizeCanvas(i[0],i[1],r);const n=this._controlContainer=u.create("div","maplibregl-control-container",e),o=this._controlPositions={};["top-left","top-right","bottom-left","bottom-right"].forEach(e=>{o[e]=u.create("div",`maplibregl-ctrl-${e} `,n)}),this._container.addEventListener("scroll",this._onMapScroll,!1)}_resizeCanvas(e,t,i){this._canvas.width=Math.floor(i*e),this._canvas.height=Math.floor(i*t),this._canvas.style.width=`${e}px`,this._canvas.style.height=`${t}px`}_setupPainter(){const e=Object.assign(Object.assign({},this._canvasContextAttributes),{alpha:!0,depth:!0,stencil:!0,premultipliedAlpha:!0});let t=null;this._canvas.addEventListener("webglcontextcreationerror",i=>{t={requestedAttributes:e},i&&(t.statusMessage=i.statusMessage,t.type=i.type)},{once:!0});let i=null;if(i=this._canvasContextAttributes.contextType?this._canvas.getContext(this._canvasContextAttributes.contextType,e):this._canvas.getContext("webgl2",e)||this._canvas.getContext("webgl",e),!i){const e="Failed to initialize WebGL";throw t?(t.message=e,new Error(JSON.stringify(t))):new Error(e)}this.painter=new Nn(i,this.transform),h.testSupport(i)}migrateProjection(e,i){super.migrateProjection(e,i),this.painter.transform=e,this.fire(new t.l("projectiontransition",{newProjection:this.style.projection.name}))}loaded(){return!this._styleDirty&&!this._sourcesDirty&&!!this.style&&this.style.loaded()}_update(e){return this.style&&this.style._loaded?(this._styleDirty=this._styleDirty||e,this._sourcesDirty=!0,this.triggerRepaint(),this):this}_requestRenderFrame(e){return this._update(),this._renderTaskQueue.add(e)}_cancelRenderFrame(e){this._renderTaskQueue.remove(e)}_render(e){var i,r,n,o,s;const a=this._idleTriggered?this._fadeDuration:0,l=(null===(i=this.style.projection)||void 0===i?void 0:i.transitionState)>0;if(this.painter.context.setDirty(),this.painter.setBaseState(),this._renderTaskQueue.run(e),this._removed)return;let u=!1;if(this.style&&this._styleDirty){this._styleDirty=!1;const e=this.transform.zoom,i=c();this.style.zoomHistory.update(e,i);const r=new t.H(e,{now:i,fadeDuration:a,zoomHistory:this.style.zoomHistory,transition:this.style.getTransition()}),n=r.crossFadingFactor();1===n&&n===this._crossFadingFactor||(u=!0,this._crossFadingFactor=n),this.style.update(r)}const h=(null===(r=this.style.projection)||void 0===r?void 0:r.transitionState)>0!==l;null===(n=this.style.projection)||void 0===n||n.setErrorQueryLatitudeDegrees(this.transform.center.lat),this.transform.setTransitionState(null===(o=this.style.projection)||void 0===o?void 0:o.transitionState,null===(s=this.style.projection)||void 0===s?void 0:s.latitudeErrorCorrectionRadians),this.style&&(this._sourcesDirty||h)&&(this._sourcesDirty=!1,this.style._updateSources(this.transform)),this.terrain?(this.terrain.tileManager.update(this.transform,this.terrain),this.transform.setMinElevationForCurrentTile(this.terrain.getMinTileElevationForLngLatZoom(this.transform.center,this.transform.tileZoom)),!this._elevationFreeze&&this._centerClampedToGround&&this.transform.setElevation(this.terrain.getElevationForLngLatZoom(this.transform.center,this.transform.tileZoom))):(this.transform.setMinElevationForCurrentTile(0),this._centerClampedToGround&&this.transform.setElevation(0)),this._placementDirty=this.style&&this.style._updatePlacement(this.transform,this.showCollisionBoxes,a,this._crossSourceCollisions,h),this.painter.render(this.style,{showTileBoundaries:this.showTileBoundaries,showOverdrawInspector:this._showOverdrawInspector,rotating:this.isRotating(),zooming:this.isZooming(),moving:this.isMoving(),fadeDuration:a,showPadding:this.showPadding}),this.fire(new t.l("render")),this.loaded()&&!this._loaded&&(this._loaded=!0,t.cF.mark(t.cG.load),this.fire(new t.l("load"))),this.style&&(this.style.hasTransitions()||u)&&(this._styleDirty=!0),this.style&&!this._placementDirty&&this.style._releaseSymbolFadeTiles();const d=this._sourcesDirty||this._styleDirty||this._placementDirty;return d||this._repaint?this.triggerRepaint():!this.isMoving()&&this.loaded()&&this.fire(new t.l("idle")),!this._loaded||this._fullyLoaded||d||(this._fullyLoaded=!0,t.cF.mark(t.cG.fullLoad)),this}redraw(){return this.style&&(this._frameRequest&&(this._frameRequest.abort(),this._frameRequest=null),this._render(0)),this}remove(){var e;this._hash&&this._hash.remove();for(const e of this._controls)e.onRemove(this);this._controls=[],this._frameRequest&&(this._frameRequest.abort(),this._frameRequest=null),this._renderTaskQueue.clear(),this.painter.destroy(),this.handlers.destroy(),delete this.handlers,this.setStyle(null),"undefined"!=typeof window&&removeEventListener("online",this._onWindowOnline,!1),_.removeThrottleControl(this._imageQueueHandle),null===(e=this._resizeObserver)||void 0===e||e.disconnect();const i=this.painter.context.gl.getExtension("WEBGL_lose_context");(null==i?void 0:i.loseContext)&&i.loseContext(),this._canvas.removeEventListener("webglcontextrestored",this._contextRestored,!1),this._canvas.removeEventListener("webglcontextlost",this._contextLost,!1),u.remove(this._canvasContainer),u.remove(this._controlContainer),this._container.removeEventListener("scroll",this._onMapScroll,!1),this._container.classList.remove("maplibregl-map"),t.cF.clearMetrics(),this._removed=!0,this.fire(new t.l("remove"))}triggerRepaint(){this.style&&!this._frameRequest&&(this._frameRequest=new AbortController,a.frame(this._frameRequest,e=>{t.cF.frame(e),this._frameRequest=null;try{this._render(e)}catch(e){if(!t.cH(e)&&!function(e){return e.message===Yr}(e))throw e}},()=>{}))}get showTileBoundaries(){return!!this._showTileBoundaries}set showTileBoundaries(e){this._showTileBoundaries!==e&&(this._showTileBoundaries=e,this._update())}get showPadding(){return!!this._showPadding}set showPadding(e){this._showPadding!==e&&(this._showPadding=e,this._update())}get showCollisionBoxes(){return!!this._showCollisionBoxes}set showCollisionBoxes(e){this._showCollisionBoxes!==e&&(this._showCollisionBoxes=e,e?this.style._generateCollisionBoxes():this._update())}get showOverdrawInspector(){return!!this._showOverdrawInspector}set showOverdrawInspector(e){this._showOverdrawInspector!==e&&(this._showOverdrawInspector=e,this._update())}get repaint(){return!!this._repaint}set repaint(e){this._repaint!==e&&(this._repaint=e,this.triggerRepaint())}get vertices(){return!!this._vertices}set vertices(e){this._vertices=e,this._update()}get version(){return is}getCameraTargetElevation(){return this.transform.elevation}getProjection(){return this.style.getProjection()}setProjection(e){return this._lazyInitEmptyStyle(),this.style.setProjection(e),this._update(!0)}},e.MapMouseEvent=Jn,e.MapTouchEvent=Yn,e.MapWheelEvent=eo,e.Marker=us,e.NavigationControl=class{constructor(e){this._updateZoomButtons=()=>{const e=this._map.getZoom(),t=e===this._map.getMaxZoom(),i=e===this._map.getMinZoom();this._zoomInButton.disabled=t,this._zoomOutButton.disabled=i,this._zoomInButton.setAttribute("aria-disabled",t.toString()),this._zoomOutButton.setAttribute("aria-disabled",i.toString())},this._rotateCompassArrow=()=>{this._compassIcon.style.transform=this.options.visualizePitch&&this.options.visualizeRoll?`scale(${1/Math.pow(Math.cos(this._map.transform.pitchInRadians),.5)}) rotateZ(${-this._map.transform.roll}deg) rotateX(${this._map.transform.pitch}deg) rotateZ(${-this._map.transform.bearing}deg)`:this.options.visualizePitch?`scale(${1/Math.pow(Math.cos(this._map.transform.pitchInRadians),.5)}) rotateX(${this._map.transform.pitch}deg) rotateZ(${-this._map.transform.bearing}deg)`:this.options.visualizeRoll?`rotate(${-this._map.transform.bearing-this._map.transform.roll}deg)`:`rotate(${-this._map.transform.bearing}deg)`},this._setButtonTitle=(e,t)=>{const i=this._map._getUIString(`NavigationControl.${t}`);e.title=i,e.setAttribute("aria-label",i)},this.options=t.e({},ns,e),this._container=u.create("div","maplibregl-ctrl maplibregl-ctrl-group"),this._container.addEventListener("contextmenu",e=>e.preventDefault()),this.options.showZoom&&(this._zoomInButton=this._createButton("maplibregl-ctrl-zoom-in",e=>this._map.zoomIn({},{originalEvent:e})),u.create("span","maplibregl-ctrl-icon",this._zoomInButton).setAttribute("aria-hidden","true"),this._zoomOutButton=this._createButton("maplibregl-ctrl-zoom-out",e=>this._map.zoomOut({},{originalEvent:e})),u.create("span","maplibregl-ctrl-icon",this._zoomOutButton).setAttribute("aria-hidden","true")),this.options.showCompass&&(this._compass=this._createButton("maplibregl-ctrl-compass",e=>{this.options.visualizePitch?this._map.resetNorthPitch({},{originalEvent:e}):this._map.resetNorth({},{originalEvent:e})}),this._compassIcon=u.create("span","maplibregl-ctrl-icon",this._compass),this._compassIcon.setAttribute("aria-hidden","true"))}onAdd(e){return this._map=e,this.options.showZoom&&(this._setButtonTitle(this._zoomInButton,"ZoomIn"),this._setButtonTitle(this._zoomOutButton,"ZoomOut"),this._map.on("zoom",this._updateZoomButtons),this._updateZoomButtons()),this.options.showCompass&&(this._setButtonTitle(this._compass,"ResetBearing"),this.options.visualizePitch&&this._map.on("pitch",this._rotateCompassArrow),this.options.visualizeRoll&&this._map.on("roll",this._rotateCompassArrow),this._map.on("rotate",this._rotateCompassArrow),this._rotateCompassArrow(),this._handler=new os(this._map,this._compass,this.options.visualizePitch)),this._container}onRemove(){u.remove(this._container),this.options.showZoom&&this._map.off("zoom",this._updateZoomButtons),this.options.showCompass&&(this.options.visualizePitch&&this._map.off("pitch",this._rotateCompassArrow),this.options.visualizeRoll&&this._map.off("roll",this._rotateCompassArrow),this._map.off("rotate",this._rotateCompassArrow),this._handler.off(),delete this._handler),delete this._map}_createButton(e,t){const i=u.create("button",e,this._container);return i.type="button",i.addEventListener("click",t),i}},e.Popup=class extends t.E{constructor(e){super(),this._updateOpacity=()=>{void 0!==this.options.locationOccludedOpacity&&(this._container.style.opacity=this._map.transform.isLocationOccluded(this.getLngLat())?`${this.options.locationOccludedOpacity}`:"")},this.remove=()=>(this._content&&u.remove(this._content),this._container&&(u.remove(this._container),delete this._container),this._map&&(this._map.off("move",this._update),this._map.off("move",this._onClose),this._map.off("click",this._onClose),this._map.off("remove",this.remove),this._map.off("mousemove",this._onMouseMove),this._map.off("mouseup",this._onMouseUp),this._map.off("drag",this._onDrag),this._map._canvasContainer.classList.remove("maplibregl-track-pointer"),delete this._map,this.fire(new t.l("close"))),this),this._onMouseUp=e=>{this._update(e.point)},this._onMouseMove=e=>{this._update(e.point)},this._onDrag=e=>{this._update(e.point)},this._update=e=>{if(!this._map||!this._lngLat&&!this._trackPointer||!this._content)return;if(!this._container){if(this._container=u.create("div","maplibregl-popup",this._map.getContainer()),this._tip=u.create("div","maplibregl-popup-tip",this._container),this._container.appendChild(this._content),this.options.className)for(const e of this.options.className.split(" "))this._container.classList.add(e);this._closeButton&&this._closeButton.setAttribute("aria-label",this._map._getUIString("Popup.Close")),this._trackPointer&&this._container.classList.add("maplibregl-popup-track-pointer")}if(this.options.maxWidth&&this._container.style.maxWidth!==this.options.maxWidth&&(this._container.style.maxWidth=this.options.maxWidth),this._lngLat=as(this._lngLat,this._flatPos,this._map.transform,this._trackPointer),this._trackPointer&&!e)return;const t=this._flatPos=this._pos=this._trackPointer&&e?e:this._map.project(this._lngLat);this._map.terrain&&(this._flatPos=this._trackPointer&&e?e:this._map.transform.locationToScreenPoint(this._lngLat));let i=this.options.anchor;const r=ys(this.options.offset);if(!i){const e=this._container.offsetWidth,n=this._container.offsetHeight;let o;o=t.y+r.bottom.ythis._map.transform.height-n?["bottom"]:[],t.xthis._map.transform.width-e/2&&o.push("right"),i=0===o.length?"bottom":o.join("-")}let n=t.add(r[i]);this.options.subpixelPositioning||(n=n.round()),u.setTransform(this._container,`${ls[i]} translate(${n.x}px,${n.y}px)`),cs(this._container,i,"popup"),this._updateOpacity()},this._onClose=()=>{this.remove()},this.options=t.e(Object.create(_s),e)}addTo(e){return this._map&&this.remove(),this._map=e,this.options.closeOnClick&&this._map.on("click",this._onClose),this.options.closeOnMove&&this._map.on("move",this._onClose),this._map.on("remove",this.remove),this._update(),this._focusFirstElement(),this._trackPointer?(this._map.on("mousemove",this._onMouseMove),this._map.on("mouseup",this._onMouseUp),this._container&&this._container.classList.add("maplibregl-popup-track-pointer"),this._map._canvasContainer.classList.add("maplibregl-track-pointer")):this._map.on("move",this._update),this.fire(new t.l("open")),this}isOpen(){return!!this._map}getLngLat(){return this._lngLat}setLngLat(e){return this._lngLat=t.V.convert(e),this._pos=null,this._flatPos=null,this._trackPointer=!1,this._update(),this._map&&(this._map.on("move",this._update),this._map.off("mousemove",this._onMouseMove),this._container&&this._container.classList.remove("maplibregl-popup-track-pointer"),this._map._canvasContainer.classList.remove("maplibregl-track-pointer")),this}trackPointer(){return this._trackPointer=!0,this._pos=null,this._flatPos=null,this._update(),this._map&&(this._map.off("move",this._update),this._map.on("mousemove",this._onMouseMove),this._map.on("drag",this._onDrag),this._container&&this._container.classList.add("maplibregl-popup-track-pointer"),this._map._canvasContainer.classList.add("maplibregl-track-pointer")),this}getElement(){return this._container}setText(e){return this.setDOMContent(document.createTextNode(e))}setHTML(e){const t=document.createDocumentFragment(),i=document.createElement("body");let r;for(i.innerHTML=e;r=i.firstChild,r;)t.appendChild(r);return this.setDOMContent(t)}getMaxWidth(){var e;return null===(e=this._container)||void 0===e?void 0:e.style.maxWidth}setMaxWidth(e){return this.options.maxWidth=e,this._update(),this}setDOMContent(e){if(this._content)for(;this._content.hasChildNodes();)this._content.firstChild&&this._content.removeChild(this._content.firstChild);else this._content=u.create("div","maplibregl-popup-content",this._container);return this._content.appendChild(e),this._createCloseButton(),this._update(),this._focusFirstElement(),this}addClassName(e){return this._container&&this._container.classList.add(e),this}removeClassName(e){return this._container&&this._container.classList.remove(e),this}setOffset(e){return this.options.offset=e,this._update(),this}toggleClassName(e){if(this._container)return this._container.classList.toggle(e)}setSubpixelPositioning(e){this.options.subpixelPositioning=e}_createCloseButton(){this.options.closeButton&&(this._closeButton=u.create("button","maplibregl-popup-close-button",this._content),this._closeButton.type="button",this._closeButton.innerHTML="×",this._closeButton.addEventListener("click",this._onClose))}_focusFirstElement(){if(!this.options.focusAfterOpen||!this._container)return;const e=this._container.querySelector(As);e&&e.focus()}},e.RasterDEMTileSource=X,e.RasterTileSource=K,e.ScaleControl=class{constructor(e){this._onMove=()=>{ms(this._map,this._container,this.options)},this.setUnit=e=>{this.options.unit=e,ms(this._map,this._container,this.options)},this.options=Object.assign(Object.assign({},fs),e)}getDefaultPosition(){return"bottom-left"}onAdd(e){return this._map=e,this._container=u.create("div","maplibregl-ctrl maplibregl-ctrl-scale",e.getContainer()),this._map.on("move",this._onMove),this._onMove(),this._container}onRemove(){u.remove(this._container),this._map.off("move",this._onMove),this._map=void 0}},e.ScrollZoomHandler=Ro,e.Style=Ii,e.TerrainControl=class{constructor(e){this._toggleTerrain=()=>{this._map.getTerrain()?this._map.setTerrain(null):this._map.setTerrain(this.options),this._updateTerrainIcon()},this._updateTerrainIcon=()=>{this._terrainButton.classList.remove("maplibregl-ctrl-terrain"),this._terrainButton.classList.remove("maplibregl-ctrl-terrain-enabled"),this._map.terrain?(this._terrainButton.classList.add("maplibregl-ctrl-terrain-enabled"),this._terrainButton.title=this._map._getUIString("TerrainControl.Disable")):(this._terrainButton.classList.add("maplibregl-ctrl-terrain"),this._terrainButton.title=this._map._getUIString("TerrainControl.Enable"))},this.options=e}onAdd(e){return this._map=e,this._container=u.create("div","maplibregl-ctrl maplibregl-ctrl-group"),this._terrainButton=u.create("button","maplibregl-ctrl-terrain",this._container),u.create("span","maplibregl-ctrl-icon",this._terrainButton).setAttribute("aria-hidden","true"),this._terrainButton.type="button",this._terrainButton.addEventListener("click",this._toggleTerrain),this._updateTerrainIcon(),this._map.on("terrain",this._updateTerrainIcon),this._container}onRemove(){u.remove(this._container),this._map.off("terrain",this._updateTerrainIcon),this._map=void 0}},e.TwoFingersTouchPitchHandler=Co,e.TwoFingersTouchRotateHandler=To,e.TwoFingersTouchZoomHandler=bo,e.TwoFingersTouchZoomRotateHandler=zo,e.VectorTileSource=q,e.VideoSource=ie,e.addSourceType=(e,i)=>t._(void 0,void 0,void 0,function*(){if(oe(e))throw new Error(`A source type called "${e}" already exists.`);((e,t)=>{ne[e]=t})(e,i)}),e.clearPrewarmedResources=function(){const e=O;e&&(e.isPreloaded()&&1===e.numActive()?(e.release(F),O=null):console.warn("Could not clear WebWorkers since there are active Map instances that still reference it. The pre-warmed WebWorker pool can only be cleared when all map instances have been removed with map.remove()"))},e.createTileMesh=ii,e.getMaxParallelImageRequests=function(){return t.a.MAX_PARALLEL_IMAGE_REQUESTS},e.getRTLTextPluginStatus=function(){return ce().getRTLTextPluginStatus()},e.getVersion=function(){return vs},e.getWorkerCount=function(){return k.workerCount},e.getWorkerUrl=function(){return t.a.WORKER_URL},e.importScriptInWorkers=function(e){return V().broadcast("IS",e)},e.isTimeFrozen=function(){return l.isFrozen()},e.now=c,e.prewarm=function(){U().acquire(F)},e.restoreNow=function(){l.restoreNow()},e.setMaxParallelImageRequests=function(e){t.a.MAX_PARALLEL_IMAGE_REQUESTS=e},e.setNow=function(e){l.setNow(e)},e.setRTLTextPlugin=function(e,t){return ce().setRTLTextPlugin(e,t)},e.setWorkerCount=function(e){k.workerCount=e},e.setWorkerUrl=function(e){t.a.WORKER_URL=e}});var r=e;return r}();var Ke=He(qe.exports),Xe=e({__proto__:null,default:Ke},[qe.exports]);const Je=[];function Ye(e,i=t){let r;const n=new Set;function o(t){if(a(e,t)&&(e=t,r)){const t=!Je.length;for(const t of n)t[1](),Je.push(t,e);if(t){for(let e=0;e{n.delete(l),0===n.size&&r&&(r(),r=null)}}}}const et=Ye([]),tt=Ye([]),it=Ye([]),rt=Ye(!0),nt=Ye(!0),ot=Ye([]),st=Ye({}),at=e=>{if(!Array.isArray(e))return!1;const t=["id","name","type"],i=e=>{const i=Object.keys(e);return t.filter(e=>!i.includes(e)).length>0};return!(e.filter(e=>"sublist"===e.type?e.presets.every(i):i(e)).length>0)},lt=(e,t)=>Math.round(e*10**t)/10**t;var ct="Expected a function",ut=/^\s+|\s+$/g,ht=/^[-+]0x[0-9a-f]+$/i,dt=/^0b[01]+$/i,pt=/^0o[0-7]+$/i,ft=parseInt,mt="object"==typeof Ge&&Ge&&Ge.Object===Object&&Ge,gt="object"==typeof self&&self&&self.Object===Object&&self,_t=mt||gt||Function("return this")(),At=Object.prototype.toString,yt=Math.max,vt=Math.min,xt=function(){return _t.Date.now()};function bt(e,t,i){var r,n,o,s,a,l,c=0,u=!1,h=!1,d=!0;if("function"!=typeof e)throw new TypeError(ct);function p(t){var i=r,o=n;return r=n=void 0,c=t,s=e.apply(o,i)}function f(e){var i=e-l;return void 0===l||i>=t||i<0||h&&e-c>=o}function m(){var e=xt();if(f(e))return g(e);a=setTimeout(m,function(e){var i=t-(e-l);return h?vt(i,o-(e-c)):i}(e))}function g(e){return a=void 0,d&&r?p(e):(r=n=void 0,s)}function _(){var e=xt(),i=f(e);if(r=arguments,n=this,l=e,i){if(void 0===a)return function(e){return c=e,a=setTimeout(m,t),u?p(e):s}(l);if(h)return a=setTimeout(m,t),p(l)}return void 0===a&&(a=setTimeout(m,t)),s}return t=Tt(t)||0,wt(i)&&(u=!!i.leading,o=(h="maxWait"in i)?yt(Tt(i.maxWait)||0,t):o,d="trailing"in i?!!i.trailing:d),_.cancel=function(){void 0!==a&&clearTimeout(a),c=0,r=l=n=a=void 0},_.flush=function(){return void 0===a?s:g(xt())},_}function wt(e){var t=typeof e;return!!e&&("object"==t||"function"==t)}function Tt(e){if("number"==typeof e)return e;if(function(e){return"symbol"==typeof e||function(e){return!!e&&"object"==typeof e}(e)&&"[object Symbol]"==At.call(e)}(e))return NaN;if(wt(e)){var t="function"==typeof e.valueOf?e.valueOf():e;e=wt(t)?t+"":t}if("string"!=typeof e)return 0===e?e:+e;e=e.replace(ut,"");var i=dt.test(e);return i||pt.test(e)?ft(e.slice(2),i?2:8):ht.test(e)?NaN:+e}var Et,Ct=function(e,t,i){var r=!0,n=!0;if("function"!=typeof e)throw new TypeError(ct);return wt(i)&&(r="leading"in i?!!i.leading:r,n="trailing"in i?!!i.trailing:n),bt(e,t,{leading:r,maxWait:t,trailing:n})},Bt=Object.prototype.toString,St=function(e){var t=Bt.call(e),i="[object Arguments]"===t;return i||(i="[object Array]"!==t&&null!==e&&"object"==typeof e&&"number"==typeof e.length&&e.length>=0&&"[object Function]"===Bt.call(e.callee)),i};if(!Object.keys){var It=Object.prototype.hasOwnProperty,Mt=Object.prototype.toString,Pt=St,Rt=Object.prototype.propertyIsEnumerable,Lt=!Rt.call({toString:null},"toString"),Ft=Rt.call(function(){},"prototype"),kt=["toString","toLocaleString","valueOf","hasOwnProperty","isPrototypeOf","propertyIsEnumerable","constructor"],Dt=function(e){var t=e.constructor;return t&&t.prototype===e},Ot={$applicationCache:!0,$console:!0,$external:!0,$frame:!0,$frameElement:!0,$frames:!0,$innerHeight:!0,$innerWidth:!0,$onmozfullscreenchange:!0,$onmozfullscreenerror:!0,$outerHeight:!0,$outerWidth:!0,$pageXOffset:!0,$pageYOffset:!0,$parent:!0,$scrollLeft:!0,$scrollTop:!0,$scrollX:!0,$scrollY:!0,$self:!0,$webkitIndexedDB:!0,$webkitStorageInfo:!0,$window:!0},zt=function(){if("undefined"==typeof window)return!1;for(var e in window)try{if(!Ot["$"+e]&&It.call(window,e)&&null!==window[e]&&"object"==typeof window[e])try{Dt(window[e])}catch(e){return!0}}catch(e){return!0}return!1}();Et=function(e){var t=null!==e&&"object"==typeof e,i="[object Function]"===Mt.call(e),r=Pt(e),n=t&&"[object String]"===Mt.call(e),o=[];if(!t&&!i&&!r)throw new TypeError("Object.keys called on a non-object");var s=Ft&&i;if(n&&e.length>0&&!It.call(e,0))for(var a=0;a0)for(var l=0;l3&&"boolean"!=typeof arguments[3]&&null!==arguments[3])throw new ei("`nonEnumerable`, if provided, must be a boolean or null");if(arguments.length>4&&"boolean"!=typeof arguments[4]&&null!==arguments[4])throw new ei("`nonWritable`, if provided, must be a boolean or null");if(arguments.length>5&&"boolean"!=typeof arguments[5]&&null!==arguments[5])throw new ei("`nonConfigurable`, if provided, must be a boolean or null");if(arguments.length>6&&"boolean"!=typeof arguments[6])throw new ei("`loose`, if provided, must be a boolean");var r=arguments.length>3?arguments[3]:null,n=arguments.length>4?arguments[4]:null,o=arguments.length>5?arguments[5]:null,s=arguments.length>6&&arguments[6],a=!!ti&&ti(e,t);if(Jt)Jt(e,t,{configurable:null===o&&a?a.configurable:!o,enumerable:null===r&&a?a.enumerable:!r,value:i,writable:null===n&&a?a.writable:!n});else{if(!s&&(r||n||o))throw new Yt("This environment does not support defining a property as non-configurable, non-writable, or non-enumerable.");e[t]=i}},ri=Zt,ni=function(){return!!ri};ni.hasArrayLengthDefineBug=function(){if(!ri)return null;try{return 1!==ri([],"length",{value:1}).length}catch(e){return!0}};var oi=ni,si=Qt,ai="function"==typeof Symbol&&"symbol"==typeof Symbol("foo"),li=Object.prototype.toString,ci=Array.prototype.concat,ui=ii,hi=oi(),di=function(e,t,i,r){if(t in e)if(!0===r){if(e[t]===i)return}else if(!function(e){return"function"==typeof e&&"[object Function]"===li.call(e)}(r)||!r())return;hi?ui(e,t,i,!0):ui(e,t,i)},pi=function(e,t){var i=arguments.length>2?arguments[2]:{},r=si(t);ai&&(r=ci.call(r,Object.getOwnPropertySymbols(t)));for(var n=0;n1&&"boolean"!=typeof t)throw new Ar('"allowMissing" argument must be a boolean');if(null===Xr(/^%?[^%]*%?$/,e))throw new _r("`%` may not be present anywhere but at the beginning and end of the intrinsic name");var i=function(e){var t=Kr(e,0,1),i=Kr(e,-1);if("%"===t&&"%"!==i)throw new _r("invalid intrinsic syntax, expected closing `%`");if("%"===i&&"%"!==t)throw new _r("invalid intrinsic syntax, expected opening `%`");var r=[];return qr(e,Jr,function(e,t,i,n){r[r.length]=i?qr(n,Yr,"$1"):t||e}),r}(e),r=i.length>0?i[0]:"",n=en("%"+r+"%",t),o=n.name,s=n.value,a=!1,l=n.alias;l&&(r=l[0],Wr(i,Zr([0,1],l)));for(var c=1,u=!0;c=i.length){var f=Ir(s,h);s=(u=!!f)&&"get"in f&&!("originalValue"in f.get)?f.get:s[h]}else u=$r(s,h),s=s[h];u&&!a&&(Vr[o]=s)}}return s},rn=tn,nn=ii,on=oi(),sn=Xt,an=qt,ln=rn("%Math.floor%"),cn=function(e,t){if("function"!=typeof e)throw new an("`fn` is not a function");if("number"!=typeof t||t<0||t>4294967295||ln(t)!==t)throw new an("`length` must be a positive 32-bit integer");var i=arguments.length>2&&!!arguments[2],r=!0,n=!0;if("length"in e&&sn){var o=sn(e,"length");o&&!o.configurable&&(r=!1),o&&!o.writable&&(n=!1)}return(r||n||!i)&&(on?nn(e,"length",t,!0,!0):nn(e,"length",t)),e},un=Vi,hn=Gi,dn=$i,pn=function(){return dn(un,hn,arguments)};!function(e){var t=cn,i=Zt,r=Xi,n=pn;e.exports=function(e){var i=r(arguments),n=e.length-(arguments.length-1);return t(i,1+(n>0?n:0),!0)},i?i(e.exports,"apply",{value:n}):e.exports.apply=n}(gi);var fn=tn,mn=Xi,gn=mn([fn("%String.prototype.indexOf%")]),_n=function(e,t){var i=fn(e,!!t);return"function"==typeof i&&gn(e,".prototype.")>-1?mn([i]):i},An=Qt,yn=Pi(),vn=_n,xn=_i,bn=vn("Array.prototype.push"),wn=vn("Object.prototype.propertyIsEnumerable"),Tn=yn?xn.getOwnPropertySymbols:null,En=function(e,t){if(null==e)throw new TypeError("target must be an object");var i=xn(e);if(1===arguments.length)return i;for(var r=1;r2&&!!arguments[2]&&!$n||(Qn?Hn(e,"name",t,!0,!0):Hn(e,"name",t)),e},qn=qt,Kn=Object,Xn=Wn(function(){if(null==this||this!==Kn(this))throw new qn("RegExp.prototype.flags getter called on non-object");var e="";return this.hasIndices&&(e+="d"),this.global&&(e+="g"),this.ignoreCase&&(e+="i"),this.multiline&&(e+="m"),this.dotAll&&(e+="s"),this.unicode&&(e+="u"),this.unicodeSets&&(e+="v"),this.sticky&&(e+="y"),e},"get flags",!0),Jn=Xn,Yn=mi.supportsDescriptors,eo=Object.getOwnPropertyDescriptor,to=function(){if(Yn&&"gim"===/a/gim.flags){var e=eo(RegExp.prototype,"flags");if(e&&"function"==typeof e.get&&"dotAll"in RegExp.prototype&&"hasIndices"in RegExp.prototype){var t="",i={};if(Object.defineProperty(i,"hasIndices",{get:function(){t+="d"}}),Object.defineProperty(i,"sticky",{get:function(){t+="y"}}),e.get.call(i),"dy"===t)return e.get}}return Jn},io=mi.supportsDescriptors,ro=to,no=Xt,oo=Object.defineProperty,so=Ai,ao=lr,lo=/a/,co=mi,uo=Xn,ho=to,po=function(){if(!io||!ao)throw new so("RegExp.prototype.flags requires a true ES5 environment that supports property descriptors");var e=ro(),t=ao(lo),i=no(t,"flags");return i&&i.get===e||oo(t,"flags",{configurable:!0,enumerable:!1,get:e}),e},fo=(0,gi.exports)(ho());co(fo,{getPolyfill:ho,implementation:uo,shim:po});var mo=fo,go=Symbol.iterator,_o=Qe(Object.freeze({__proto__:null,default:{}})),Ao="function"==typeof Map&&Map.prototype,yo=Object.getOwnPropertyDescriptor&&Ao?Object.getOwnPropertyDescriptor(Map.prototype,"size"):null,vo=Ao&&yo&&"function"==typeof yo.get?yo.get:null,xo=Ao&&Map.prototype.forEach,bo="function"==typeof Set&&Set.prototype,wo=Object.getOwnPropertyDescriptor&&bo?Object.getOwnPropertyDescriptor(Set.prototype,"size"):null,To=bo&&wo&&"function"==typeof wo.get?wo.get:null,Eo=bo&&Set.prototype.forEach,Co="function"==typeof WeakMap&&WeakMap.prototype?WeakMap.prototype.has:null,Bo="function"==typeof WeakSet&&WeakSet.prototype?WeakSet.prototype.has:null,So="function"==typeof WeakRef&&WeakRef.prototype?WeakRef.prototype.deref:null,Io=Boolean.prototype.valueOf,Mo=Object.prototype.toString,Po=Function.prototype.toString,Ro=String.prototype.match,Lo=String.prototype.slice,Fo=String.prototype.replace,ko=String.prototype.toUpperCase,Do=String.prototype.toLowerCase,Oo=RegExp.prototype.test,zo=Array.prototype.concat,Uo=Array.prototype.join,No=Array.prototype.slice,Vo=Math.floor,jo="function"==typeof BigInt?BigInt.prototype.valueOf:null,Go=Object.getOwnPropertySymbols,Ho="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?Symbol.prototype.toString:null,Qo="function"==typeof Symbol&&"object"==typeof Symbol.iterator,$o="function"==typeof Symbol&&Symbol.toStringTag&&(typeof Symbol.toStringTag===Qo||"symbol")?Symbol.toStringTag:null,Zo=Object.prototype.propertyIsEnumerable,Wo=("function"==typeof Reflect?Reflect.getPrototypeOf:Object.getPrototypeOf)||([].__proto__===Array.prototype?function(e){return e.__proto__}:null);function qo(e,t){if(e===1/0||e===-1/0||e!=e||e&&e>-1e3&&e<1e3||Oo.call(/e/,t))return t;var i=/[0-9](?=(?:[0-9]{3})+(?![0-9]))/g;if("number"==typeof e){var r=e<0?-Vo(-e):Vo(e);if(r!==e){var n=String(r),o=Lo.call(t,n.length+1);return Fo.call(n,i,"$&_")+"."+Fo.call(Fo.call(o,/([0-9]{3})/g,"$&_"),/_$/,"")}}return Fo.call(t,i,"$&_")}var Ko=_o,Xo=Ko.custom,Jo=as(Xo)?Xo:null,Yo={__proto__:null,double:'"',single:"'"},es={__proto__:null,double:/(["\\])/g,single:/(['\\])/g},ts=function e(t,i,r,n){var o=i||{};if(cs(o,"quoteStyle")&&!cs(Yo,o.quoteStyle))throw new TypeError('option "quoteStyle" must be "single" or "double"');if(cs(o,"maxStringLength")&&("number"==typeof o.maxStringLength?o.maxStringLength<0&&o.maxStringLength!==1/0:null!==o.maxStringLength))throw new TypeError('option "maxStringLength", if provided, must be a positive integer, Infinity, or `null`');var s=!cs(o,"customInspect")||o.customInspect;if("boolean"!=typeof s&&"symbol"!==s)throw new TypeError("option \"customInspect\", if provided, must be `true`, `false`, or `'symbol'`");if(cs(o,"indent")&&null!==o.indent&&"\t"!==o.indent&&!(parseInt(o.indent,10)===o.indent&&o.indent>0))throw new TypeError('option "indent" must be "\\t", an integer > 0, or `null`');if(cs(o,"numericSeparator")&&"boolean"!=typeof o.numericSeparator)throw new TypeError('option "numericSeparator", if provided, must be `true` or `false`');var a=o.numericSeparator;if(void 0===t)return"undefined";if(null===t)return"null";if("boolean"==typeof t)return t?"true":"false";if("string"==typeof t)return ds(t,o);if("number"==typeof t){if(0===t)return 1/0/t>0?"0":"-0";var l=String(t);return a?qo(t,l):l}if("bigint"==typeof t){var c=String(t)+"n";return a?qo(t,c):c}var u=void 0===o.depth?5:o.depth;if(void 0===r&&(r=0),r>=u&&u>0&&"object"==typeof t)return os(t)?"[Array]":"[Object]";var h=function(e,t){var i;if("\t"===e.indent)i="\t";else{if(!("number"==typeof e.indent&&e.indent>0))return null;i=Uo.call(Array(e.indent+1)," ")}return{base:i,prev:Uo.call(Array(t+1),i)}}(o,r);if(void 0===n)n=[];else if(hs(n,t)>=0)return"[Circular]";function d(t,i,s){if(i&&(n=No.call(n)).push(i),s){var a={depth:o.depth};return cs(o,"quoteStyle")&&(a.quoteStyle=o.quoteStyle),e(t,a,r+1,n)}return e(t,o,r+1,n)}if("function"==typeof t&&!ss(t)){var p=function(e){if(e.name)return e.name;var t=Ro.call(Po.call(e),/^function\s*([\w$]+)/);if(t)return t[1];return null}(t),f=As(t,d);return"[Function"+(p?": "+p:" (anonymous)")+"]"+(f.length>0?" { "+Uo.call(f,", ")+" }":"")}if(as(t)){var m=Qo?Fo.call(String(t),/^(Symbol\(.*\))_[^)]*$/,"$1"):Ho.call(t);return"object"!=typeof t||Qo?m:fs(m)}if(function(e){if(!e||"object"!=typeof e)return!1;if("undefined"!=typeof HTMLElement&&e instanceof HTMLElement)return!0;return"string"==typeof e.nodeName&&"function"==typeof e.getAttribute}(t)){for(var g="<"+Do.call(String(t.nodeName)),_=t.attributes||[],A=0;A<_.length;A++)g+=" "+_[A].name+"="+is(rs(_[A].value),"double",o);return g+=">",t.childNodes&&t.childNodes.length&&(g+="..."),g+=""}if(os(t)){if(0===t.length)return"[]";var y=As(t,d);return h&&!function(e){for(var t=0;t=0)return!1;return!0}(y)?"["+_s(y,h)+"]":"[ "+Uo.call(y,", ")+" ]"}if(function(e){return"[object Error]"===us(e)&&ns(e)}(t)){var v=As(t,d);return"cause"in Error.prototype||!("cause"in t)||Zo.call(t,"cause")?0===v.length?"["+String(t)+"]":"{ ["+String(t)+"] "+Uo.call(v,", ")+" }":"{ ["+String(t)+"] "+Uo.call(zo.call("[cause]: "+d(t.cause),v),", ")+" }"}if("object"==typeof t&&s){if(Jo&&"function"==typeof t[Jo]&&Ko)return Ko(t,{depth:u-r});if("symbol"!==s&&"function"==typeof t.inspect)return t.inspect()}if(function(e){if(!vo||!e||"object"!=typeof e)return!1;try{vo.call(e);try{To.call(e)}catch(e){return!0}return e instanceof Map}catch(e){}return!1}(t)){var x=[];return xo&&xo.call(t,function(e,i){x.push(d(i,t,!0)+" => "+d(e,t))}),gs("Map",vo.call(t),x,h)}if(function(e){if(!To||!e||"object"!=typeof e)return!1;try{To.call(e);try{vo.call(e)}catch(e){return!0}return e instanceof Set}catch(e){}return!1}(t)){var b=[];return Eo&&Eo.call(t,function(e){b.push(d(e,t))}),gs("Set",To.call(t),b,h)}if(function(e){if(!Co||!e||"object"!=typeof e)return!1;try{Co.call(e,Co);try{Bo.call(e,Bo)}catch(e){return!0}return e instanceof WeakMap}catch(e){}return!1}(t))return ms("WeakMap");if(function(e){if(!Bo||!e||"object"!=typeof e)return!1;try{Bo.call(e,Bo);try{Co.call(e,Co)}catch(e){return!0}return e instanceof WeakSet}catch(e){}return!1}(t))return ms("WeakSet");if(function(e){if(!So||!e||"object"!=typeof e)return!1;try{return So.call(e),!0}catch(e){}return!1}(t))return ms("WeakRef");if(function(e){return"[object Number]"===us(e)&&ns(e)}(t))return fs(d(Number(t)));if(function(e){if(!e||"object"!=typeof e||!jo)return!1;try{return jo.call(e),!0}catch(e){}return!1}(t))return fs(d(jo.call(t)));if(function(e){return"[object Boolean]"===us(e)&&ns(e)}(t))return fs(Io.call(t));if(function(e){return"[object String]"===us(e)&&ns(e)}(t))return fs(d(String(t)));if("undefined"!=typeof window&&t===window)return"{ [object Window] }";if("undefined"!=typeof globalThis&&t===globalThis||void 0!==Ge&&t===Ge)return"{ [object globalThis] }";if(!function(e){return"[object Date]"===us(e)&&ns(e)}(t)&&!ss(t)){var w=As(t,d),T=Wo?Wo(t)===Object.prototype:t instanceof Object||t.constructor===Object,E=t instanceof Object?"":"null prototype",C=!T&&$o&&Object(t)===t&&$o in t?Lo.call(us(t),8,-1):E?"Object":"",B=(T||"function"!=typeof t.constructor?"":t.constructor.name?t.constructor.name+" ":"")+(C||E?"["+Uo.call(zo.call([],C||[],E||[]),": ")+"] ":"");return 0===w.length?B+"{}":h?B+"{"+_s(w,h)+"}":B+"{ "+Uo.call(w,", ")+" }"}return String(t)};function is(e,t,i){var r=i.quoteStyle||t,n=Yo[r];return n+e+n}function rs(e){return Fo.call(String(e),/"/g,""")}function ns(e){return!$o||!("object"==typeof e&&($o in e||void 0!==e[$o]))}function os(e){return"[object Array]"===us(e)&&ns(e)}function ss(e){return"[object RegExp]"===us(e)&&ns(e)}function as(e){if(Qo)return e&&"object"==typeof e&&e instanceof Symbol;if("symbol"==typeof e)return!0;if(!e||"object"!=typeof e||!Ho)return!1;try{return Ho.call(e),!0}catch(e){}return!1}var ls=Object.prototype.hasOwnProperty||function(e){return e in this};function cs(e,t){return ls.call(e,t)}function us(e){return Mo.call(e)}function hs(e,t){if(e.indexOf)return e.indexOf(t);for(var i=0,r=e.length;it.maxStringLength){var i=e.length-t.maxStringLength,r="... "+i+" more character"+(i>1?"s":"");return ds(Lo.call(e,0,t.maxStringLength),t)+r}var n=es[t.quoteStyle||"single"];return n.lastIndex=0,is(Fo.call(Fo.call(e,n,"\\$1"),/[\x00-\x1f]/g,ps),"single",t)}function ps(e){var t=e.charCodeAt(0),i={8:"b",9:"t",10:"n",12:"f",13:"r"}[t];return i?"\\"+i:"\\x"+(t<16?"0":"")+ko.call(t.toString(16))}function fs(e){return"Object("+e+")"}function ms(e){return e+" { ? }"}function gs(e,t,i,r){return e+" ("+t+") {"+(r?_s(i,r):Uo.call(i,", "))+"}"}function _s(e,t){if(0===e.length)return"";var i="\n"+t.prev+t.base;return i+Uo.call(e,","+i)+"\n"+t.prev}function As(e,t){var i=os(e),r=[];if(i){r.length=e.length;for(var n=0;n=0&&"[object Array]"!==sa(e)&&"callee"in e&&"[object Function]"===sa(e.callee)},ca=function(){return aa(arguments)}();aa.isLegacyArguments=la;var ua,ha=ca?aa:la,da={}.toString,pa=Array.isArray||function(e){return"[object Array]"==da.call(e)},fa=gi.exports,ma=_n,ga=tn("%ArrayBuffer%",!0),_a=ma("ArrayBuffer.prototype.byteLength",!0),Aa=ma("Object.prototype.toString"),ya=!!ga&&!_a&&new ga(0).slice,va=!!ya&&fa(ya),xa=_a||va?function(e){if(!e||"object"!=typeof e)return!1;try{return _a?_a(e):va(e,0),!0}catch(e){return!1}}:ga?function(e){return"[object ArrayBuffer]"===Aa(e)}:function(e){return!1},ba=_n,wa=ba("Date.prototype.getDay"),Ta=ba("Object.prototype.toString"),Ea=na(),Ca=_n,Ba=na(),Sa=hr,Ia=Xt;if(Ba){var Ma=Ca("RegExp.prototype.exec"),Pa={},Ra=function(){throw Pa},La={toString:Ra,valueOf:Ra};"symbol"==typeof Symbol.toPrimitive&&(La[Symbol.toPrimitive]=Ra),ua=function(e){if(!e||"object"!=typeof e)return!1;var t=Ia(e,"lastIndex");if(!(t&&Sa(t,"value")))return!1;try{Ma(e,La)}catch(e){return e===Pa}}}else{var Fa=Ca("Object.prototype.toString");ua=function(e){return!(!e||"object"!=typeof e&&"function"!=typeof e)&&"[object RegExp]"===Fa(e)}}var ka=ua,Da=_n("SharedArrayBuffer.prototype.byteLength",!0),Oa=Da?function(e){if(!e||"object"!=typeof e)return!1;try{return Da(e),!0}catch(e){return!1}}:function(e){return!1},za=_n,Ua=za("String.prototype.valueOf"),Na=za("Object.prototype.toString"),Va=na(),ja=_n,Ga=ja("Number.prototype.toString"),Ha=ja("Object.prototype.toString"),Qa=na(),$a=_n,Za=$a("Boolean.prototype.toString"),Wa=$a("Object.prototype.toString"),qa=na(),Ka={exports:{}},Xa=ka,Ja=_n("RegExp.prototype.exec"),Ya=qt,el=_n,tl=el("Object.prototype.toString"),il=function(e){if(!Xa(e))throw new Ya("`regex` must be a RegExp");return function(t){return null!==Ja(e,t)}};if(Fi()){var rl=el("Symbol.prototype.toString"),nl=il(/^Symbol\(.*\)$/);Ka.exports=function(e){if("symbol"==typeof e)return!0;if(!e||"object"!=typeof e||"[object Symbol]"!==tl(e))return!1;try{return function(e){return"symbol"==typeof e.valueOf()&&nl(rl(e))}(e)}catch(e){return!1}}}else Ka.exports=function(e){return!1};var ol={exports:{}},sl="undefined"!=typeof BigInt&&BigInt;if("function"==typeof sl&&"function"==typeof BigInt&&"bigint"==typeof sl(42)&&"bigint"==typeof BigInt(42)){var al=BigInt.prototype.valueOf;ol.exports=function(e){return null!=e&&"boolean"!=typeof e&&"string"!=typeof e&&"number"!=typeof e&&"symbol"!=typeof e&&"function"!=typeof e&&("bigint"==typeof e||function(e){try{return al.call(e),!0}catch(e){}return!1}(e))}}else ol.exports=function(e){return!1};var ll,cl=function(e){return"string"==typeof e||!(!e||"object"!=typeof e)&&(Va?function(e){try{return Ua(e),!0}catch(e){return!1}}(e):"[object String]"===Na(e))},ul=function(e){return"number"==typeof e||!(!e||"object"!=typeof e)&&(Qa?function(e){try{return Ga(e),!0}catch(e){return!1}}(e):"[object Number]"===Ha(e))},hl=function(e){return"boolean"==typeof e||null!==e&&"object"==typeof e&&(qa?function(e){try{return Za(e),!0}catch(e){return!1}}(e):"[object Boolean]"===Wa(e))},dl=Ka.exports,pl=ol.exports,fl="function"==typeof Map&&Map.prototype?Map:null,ml="function"==typeof Set&&Set.prototype?Set:null;fl||(ll=function(e){return!1});var gl=fl?Map.prototype.has:null,_l=ml?Set.prototype.has:null;ll||gl||(ll=function(e){return!1});var Al,yl=ll||function(e){if(!e||"object"!=typeof e)return!1;try{if(gl.call(e),_l)try{_l.call(e)}catch(e){return!0}return e instanceof fl}catch(e){}return!1},vl="function"==typeof Map&&Map.prototype?Map:null,xl="function"==typeof Set&&Set.prototype?Set:null;xl||(Al=function(e){return!1});var bl=vl?Map.prototype.has:null,wl=xl?Set.prototype.has:null;Al||wl||(Al=function(e){return!1});var Tl,El=Al||function(e){if(!e||"object"!=typeof e)return!1;try{if(wl.call(e),bl)try{bl.call(e)}catch(e){return!0}return e instanceof xl}catch(e){}return!1},Cl="function"==typeof WeakMap&&WeakMap.prototype?WeakMap:null,Bl="function"==typeof WeakSet&&WeakSet.prototype?WeakSet:null;Cl||(Tl=function(e){return!1});var Sl=Cl?Cl.prototype.has:null,Il=Bl?Bl.prototype.has:null;Tl||Sl||(Tl=function(e){return!1});var Ml=Tl||function(e){if(!e||"object"!=typeof e)return!1;try{if(Sl.call(e,Sl),Il)try{Il.call(e,Il)}catch(e){return!0}return e instanceof Cl}catch(e){}return!1},Pl={exports:{}},Rl=_n,Ll=tn("%WeakSet%",!0),Fl=Rl("WeakSet.prototype.has",!0);if(Fl){var kl=Rl("WeakMap.prototype.has",!0);Pl.exports=function(e){if(!e||"object"!=typeof e)return!1;try{if(Fl(e,Fl),kl)try{kl(e,kl)}catch(e){return!0}return e instanceof Ll}catch(e){}return!1}}else Pl.exports=function(e){return!1};var Dl,Ol,zl=yl,Ul=El,Nl=Ml,Vl=Pl.exports,jl=Function.prototype.toString,Gl="object"==typeof Reflect&&null!==Reflect&&Reflect.apply;if("function"==typeof Gl&&"function"==typeof Object.defineProperty)try{Dl=Object.defineProperty({},"length",{get:function(){throw Ol}}),Ol={},Gl(function(){throw 42},null,Dl)}catch(w3){w3!==Ol&&(Gl=null)}else Gl=null;var Hl=/^\s*class\b/,Ql=function(e){try{var t=jl.call(e);return Hl.test(t)}catch(e){return!1}},$l=function(e){try{return!Ql(e)&&(jl.call(e),!0)}catch(e){return!1}},Zl=Object.prototype.toString,Wl="function"==typeof Symbol&&!!Symbol.toStringTag,ql=!(0 in[,]),Kl=function(){return!1};if("object"==typeof document){var Xl=document.all;Zl.call(Xl)===Zl.call(document.all)&&(Kl=function(e){if((ql||!e)&&(void 0===e||"object"==typeof e))try{var t=Zl.call(e);return("[object HTMLAllCollection]"===t||"[object HTML document.all class]"===t||"[object HTMLCollection]"===t||"[object Object]"===t)&&null==e("")}catch(e){}return!1})}var Jl=Gl?function(e){if(Kl(e))return!0;if(!e)return!1;if("function"!=typeof e&&"object"!=typeof e)return!1;try{Gl(e,null,Dl)}catch(e){if(e!==Ol)return!1}return!Ql(e)&&$l(e)}:function(e){if(Kl(e))return!0;if(!e)return!1;if("function"!=typeof e&&"object"!=typeof e)return!1;if(Wl)return $l(e);if(Ql(e))return!1;var t=Zl.call(e);return!("[object Function]"!==t&&"[object GeneratorFunction]"!==t&&!/^\[object HTML/.test(t))&&$l(e)},Yl=Jl,ec=Object.prototype.toString,tc=Object.prototype.hasOwnProperty;var ic=["Float16Array","Float32Array","Float64Array","Int8Array","Int16Array","Int32Array","Uint8Array","Uint8ClampedArray","Uint16Array","Uint32Array","BigInt64Array","BigUint64Array"],rc="undefined"==typeof globalThis?Ge:globalThis,nc=function(e,t,i){if(!Yl(t))throw new TypeError("iterator must be a function");var r;arguments.length>=3&&(r=i),function(e){return"[object Array]"===ec.call(e)}(e)?function(e,t,i){for(var r=0,n=e.length;r-1?zn(i):i},xc=mo,bc=tn,wc=function(e){if(null!=e&&void 0!==e[go])return e[go]()},Tc=function(){var e,t={assert:function(e){if(!t.has(e))throw new Vs("Side channel does not contain "+js(e))},delete:function(t){return!!e&&e.delete(t)},get:function(t){return e&&e.get(t)},has:function(t){return!!e&&e.has(t)},set:function(t,i){e||(e=Hs()),e.set(t,i)}};return t},Ec=ia,Cc=ha,Bc=pa,Sc=xa,Ic=function(e){return"object"==typeof e&&null!==e&&(Ea?function(e){try{return wa(e),!0}catch(e){return!1}}(e):"[object Date]"===Ta(e))},Mc=ka,Pc=Oa,Rc=Qt,Lc=function(e){return null==e||"object"!=typeof e&&"function"!=typeof e?null:cl(e)?"String":ul(e)?"Number":hl(e)?"Boolean":dl(e)?"Symbol":pl(e)?"BigInt":void 0},Fc=function(e){if(e&&"object"==typeof e){if(zl(e))return"Map";if(Ul(e))return"Set";if(Nl(e))return"WeakMap";if(Vl(e))return"WeakSet"}return!1},kc=function(e){if(!e||"object"!=typeof e)return!1;if(!hc){var t=fc(uc(e),8,-1);return mc(pc,t)>-1?t:"Object"===t&&function(e){var t=!1;return nc(gc,function(i,r){if(!t)try{i(e),t=fc(r,1)}catch(e){}}),t}(e)}return lc?function(e){var t=!1;return nc(gc,function(i,r){if(!t)try{"$"+i(e)===r&&(t=fc(r,1))}catch(e){}}),t}(e):null},Dc=function(e){return Ac(e)?_c?_c(e):e.byteLength:NaN},Oc=vc("SharedArrayBuffer.prototype.byteLength",!0),zc=vc("Date.prototype.getTime"),Uc=Object.getPrototypeOf,Nc=vc("Object.prototype.toString"),Vc=bc("%Set%",!0),jc=vc("Map.prototype.has",!0),Gc=vc("Map.prototype.get",!0),Hc=vc("Map.prototype.size",!0),Qc=vc("Set.prototype.add",!0),$c=vc("Set.prototype.delete",!0),Zc=vc("Set.prototype.has",!0),Wc=vc("Set.prototype.size",!0);function qc(e,t,i,r){for(var n,o=wc(e);(n=o.next())&&!n.done;)if(eu(t,n.value,i,r))return $c(e,n.value),!0;return!1}function Kc(e){return void 0===e?null:"object"!=typeof e?"symbol"!=typeof e&&("string"!=typeof e&&"number"!=typeof e||+e==+e):void 0}function Xc(e,t,i,r,n,o){var s=Kc(i);if(null!=s)return s;var a=Gc(t,s),l=yc({},n,{strict:!1});return!(void 0===a&&!jc(t,s)||!eu(r,a,l,o))&&(!jc(e,s)&&eu(r,a,l,o))}function Jc(e,t,i){var r=Kc(i);return null!=r?r:Zc(t,r)&&!Zc(e,r)}function Yc(e,t,i,r,n,o){for(var s,a,l=wc(e);(s=l.next())&&!s.done;)if(eu(i,a=s.value,n,o)&&eu(r,Gc(t,a),n,o))return $c(e,a),!0;return!1}function eu(e,t,i,r){var n=i||{};if(n.strict?Ec(e,t):e===t)return!0;if(Lc(e)!==Lc(t))return!1;if(!e||!t||"object"!=typeof e&&"object"!=typeof t)return n.strict?Ec(e,t):e==t;var o,s=r.has(e),a=r.has(t);if(s&&a){if(r.get(e)===r.get(t))return!0}else o={};return s||r.set(e,o),a||r.set(t,o),function(e,t,i,r){var n,o;if(typeof e!=typeof t)return!1;if(null==e||null==t)return!1;if(Nc(e)!==Nc(t))return!1;if(Cc(e)!==Cc(t))return!1;var s=Bc(e),a=Bc(t);if(s!==a)return!1;var l=e instanceof Error,c=t instanceof Error;if(l!==c)return!1;if((l||c)&&(e.name!==t.name||e.message!==t.message))return!1;var u=Mc(e),h=Mc(t);if(u!==h)return!1;if((u||h)&&(e.source!==t.source||xc(e)!==xc(t)))return!1;var d=Ic(e),p=Ic(t);if(d!==p)return!1;if((d||p)&&zc(e)!==zc(t))return!1;if(i.strict&&Uc&&Uc(e)!==Uc(t))return!1;var f=kc(e),m=kc(t);if(f!==m)return!1;if(f||m){if(e.length!==t.length)return!1;for(n=0;n=0;n--)if(b[n]!=w[n])return!1;for(n=b.length-1;n>=0;n--)if(!eu(e[o=b[n]],t[o],i,r))return!1;var T=Fc(e),E=Fc(t);if(T!==E)return!1;if("Set"===T||"Set"===E)return function(e,t,i,r){if(Wc(e)!==Wc(t))return!1;var n,o,s,a=wc(e),l=wc(t);for(;(n=a.next())&&!n.done;)if(n.value&&"object"==typeof n.value)s||(s=new Vc),Qc(s,n.value);else if(!Zc(t,n.value)){if(i.strict)return!1;if(!Jc(e,t,n.value))return!1;s||(s=new Vc),Qc(s,n.value)}if(s){for(;(o=l.next())&&!o.done;)if(o.value&&"object"==typeof o.value){if(!qc(s,o.value,i.strict,r))return!1}else if(!i.strict&&!Zc(e,o.value)&&!qc(s,o.value,i.strict,r))return!1;return 0===Wc(s)}return!0}(e,t,i,r);if("Map"===T)return function(e,t,i,r){if(Hc(e)!==Hc(t))return!1;var n,o,s,a,l,c,u=wc(e),h=wc(t);for(;(n=u.next())&&!n.done;)if(a=n.value[0],l=n.value[1],a&&"object"==typeof a)s||(s=new Vc),Qc(s,a);else if(void 0===(c=Gc(t,a))&&!jc(t,a)||!eu(l,c,i,r)){if(i.strict)return!1;if(!Xc(e,t,a,l,i,r))return!1;s||(s=new Vc),Qc(s,a)}if(s){for(;(o=h.next())&&!o.done;)if(a=o.value[0],c=o.value[1],a&&"object"==typeof a){if(!Yc(s,e,a,c,i,r))return!1}else if(!(i.strict||e.has(a)&&eu(Gc(e,a),c,i,r)||Yc(s,e,a,c,yc({},i,{strict:!1}),r)))return!1;return 0===Wc(s)}return!0}(e,t,i,r);return!0}(e,t,n,r)}function tu(e){return!(!e||"object"!=typeof e||"number"!=typeof e.length)&&("function"==typeof e.copy&&"function"==typeof e.slice&&(!(e.length>0&&"number"!=typeof e[0])&&!!(e.constructor&&e.constructor.isBuffer&&e.constructor.isBuffer(e))))}var iu,ru,nu=function(e,t,i){return eu(e,t,i,Tc())};function ou(e,t,i,r){return new(i||(i=Promise))(function(n,o){function s(e){try{l(r.next(e))}catch(e){o(e)}}function a(e){try{l(r.throw(e))}catch(e){o(e)}}function l(e){var t;e.done?n(e.value):(t=e.value,t instanceof i?t:new i(function(e){e(t)})).then(s,a)}l((r=r.apply(e,t||[])).next())})}function su(e){return e&&e.__esModule&&Object.prototype.hasOwnProperty.call(e,"default")?e.default:e}"function"==typeof SuppressedError&&SuppressedError;var au=(ru||(ru=1,iu=function e(t,i){if(t===i)return!0;if(t&&i&&"object"==typeof t&&"object"==typeof i){if(t.constructor!==i.constructor)return!1;var r,n,o;if(Array.isArray(t)){if((r=t.length)!=i.length)return!1;for(n=r;0!==n--;)if(!e(t[n],i[n]))return!1;return!0}if(t.constructor===RegExp)return t.source===i.source&&t.flags===i.flags;if(t.valueOf!==Object.prototype.valueOf)return t.valueOf()===i.valueOf();if(t.toString!==Object.prototype.toString)return t.toString()===i.toString();if((r=(o=Object.keys(t)).length)!==Object.keys(i).length)return!1;for(n=r;0!==n--;)if(!Object.prototype.hasOwnProperty.call(i,o[n]))return!1;for(n=r;0!==n--;){var s=o[n];if(!e(t[s],i[s]))return!1}return!0}return t!=t&&i!=i}),iu),lu=su(au);const cu="__googleMapsScriptId";var uu;!function(e){e[e.INITIALIZED=0]="INITIALIZED",e[e.LOADING=1]="LOADING",e[e.SUCCESS=2]="SUCCESS",e[e.FAILURE=3]="FAILURE"}(uu||(uu={}));class hu{constructor({apiKey:e,authReferrerPolicy:t,channel:i,client:r,id:n=cu,language:o,libraries:s=[],mapIds:a,nonce:l,region:c,retries:u=3,url:h="https://maps.googleapis.com/maps/api/js",version:d}){if(this.callbacks=[],this.done=!1,this.loading=!1,this.errors=[],this.apiKey=e,this.authReferrerPolicy=t,this.channel=i,this.client=r,this.id=n||cu,this.language=o,this.libraries=s,this.mapIds=a,this.nonce=l,this.region=c,this.retries=u,this.url=h,this.version=d,hu.instance){if(!lu(this.options,hu.instance.options))throw new Error(`Loader must not be called again with different options. ${JSON.stringify(this.options)} !== ${JSON.stringify(hu.instance.options)}`);return hu.instance}hu.instance=this}get options(){return{version:this.version,apiKey:this.apiKey,channel:this.channel,client:this.client,id:this.id,libraries:this.libraries,language:this.language,region:this.region,mapIds:this.mapIds,nonce:this.nonce,url:this.url,authReferrerPolicy:this.authReferrerPolicy}}get status(){return this.errors.length?uu.FAILURE:this.done?uu.SUCCESS:this.loading?uu.LOADING:uu.INITIALIZED}get failed(){return this.done&&!this.loading&&this.errors.length>=this.retries+1}createUrl(){let e=this.url;return e+="?callback=__googleMapsCallback&loading=async",this.apiKey&&(e+=`&key=${this.apiKey}`),this.channel&&(e+=`&channel=${this.channel}`),this.client&&(e+=`&client=${this.client}`),this.libraries.length>0&&(e+=`&libraries=${this.libraries.join(",")}`),this.language&&(e+=`&language=${this.language}`),this.region&&(e+=`®ion=${this.region}`),this.version&&(e+=`&v=${this.version}`),this.mapIds&&(e+=`&map_ids=${this.mapIds.join(",")}`),this.authReferrerPolicy&&(e+=`&auth_referrer_policy=${this.authReferrerPolicy}`),e}deleteScript(){const e=document.getElementById(this.id);e&&e.remove()}load(){return this.loadPromise()}loadPromise(){return new Promise((e,t)=>{this.loadCallback(i=>{i?t(i.error):e(window.google)})})}importLibrary(e){return this.execute(),google.maps.importLibrary(e)}loadCallback(e){this.callbacks.push(e),this.execute()}setScript(){var e,t;if(document.getElementById(this.id))return void this.callback();const i={key:this.apiKey,channel:this.channel,client:this.client,libraries:this.libraries.length&&this.libraries,v:this.version,mapIds:this.mapIds,language:this.language,region:this.region,authReferrerPolicy:this.authReferrerPolicy};Object.keys(i).forEach(e=>!i[e]&&delete i[e]),(null===(t=null===(e=null===window||void 0===window?void 0:window.google)||void 0===e?void 0:e.maps)||void 0===t?void 0:t.importLibrary)||(e=>{let t,i,r,n="The Google Maps JavaScript API",o="google",s="importLibrary",a="__ib__",l=document,c=window;c=c[o]||(c[o]={});const u=c.maps||(c.maps={}),h=new Set,d=new URLSearchParams,p=()=>t||(t=new Promise((s,c)=>ou(this,void 0,void 0,function*(){var p;for(r in yield i=l.createElement("script"),i.id=this.id,d.set("libraries",[...h]+""),e)d.set(r.replace(/[A-Z]/g,e=>"_"+e[0].toLowerCase()),e[r]);d.set("callback",o+".maps."+a),i.src=this.url+"?"+d,u[a]=s,i.onerror=()=>t=c(Error(n+" could not load.")),i.nonce=this.nonce||(null===(p=l.querySelector("script[nonce]"))||void 0===p?void 0:p.nonce)||"",l.head.append(i)})));u[s]?console.warn(n+" only loads once. Ignoring:",e):u[s]=(e,...t)=>h.add(e)&&p().then(()=>u[s](e,...t))})(i);const r=this.libraries.map(e=>this.importLibrary(e));r.length||r.push(this.importLibrary("core")),Promise.all(r).then(()=>this.callback(),e=>{const t=new ErrorEvent("error",{error:e});this.loadErrorCallback(t)})}reset(){this.deleteScript(),this.done=!1,this.loading=!1,this.errors=[],this.onerrorEvent=null}resetIfRetryingFailed(){this.failed&&this.reset()}loadErrorCallback(e){if(this.errors.push(e),this.errors.length<=this.retries){const e=this.errors.length*Math.pow(2,this.errors.length);console.error(`Failed to load Google Maps script, retrying in ${e} ms.`),setTimeout(()=>{this.deleteScript(),this.setScript()},e)}else this.onerrorEvent=e,this.callback()}callback(){this.done=!0,this.loading=!1,this.callbacks.forEach(e=>{e(this.onerrorEvent)}),this.callbacks=[]}execute(){if(this.resetIfRetryingFailed(),!this.loading)if(this.done)this.callback();else{if(window.google&&window.google.maps&&window.google.maps.version)return console.warn("Google Maps already loaded outside @googlemaps/js-api-loader. This may result in undesirable behavior as options and script parameters may not match."),void this.callback();this.loading=!0,this.setScript()}}}function du(e){let i;return{c(){i=b("div"),S(i,"id",e[0]),S(i,"class","map svelte-16c2pp7")},m(e,t){y(e,i,t)},p(e,[t]){1&t&&S(i,"id",e[0])},i:t,o:t,d(e){e&&v(i)}}}function pu(e,t,i){let r,n,{id:o}=t,{bearing:s}=t,{center:a}=t,{pitch:l}=t,{zoom:c}=t,{mapStyle:u}=t,{numberOfMaps:h}=t,{onMapMount:d}=t;it.subscribe(e=>({googleMapsAPIKey:n}=e));const p=H();let f,m={};const g=new hu({apiKey:n,version:"beta"}),_=()=>({bearing:f.getHeading(),center:{lng:f.getCenter().lng(),lat:f.getCenter().lat()},pitch:f.getTilt(),zoom:f.getZoom()-1}),A=()=>{const e=y(_()),t=y(m);return!nu(e,t)},y=e=>({bearing:lt(e.bearing,1),pitch:lt(e.pitch,1),center:{lat:lt(e.center.lat,6),lng:lt(e.center.lng,6)},zoom:lt(e.zoom,2)});return j(()=>{g.load().then(()=>{var t;HTMLCanvasElement.prototype.getContext=(t=HTMLCanvasElement.prototype.getContext,function(e,i){return(i=i||{}).preserveDrawingBuffer=!0,t.call(this,e,i)}),i(8,f=new google.maps.Map(document.getElementById(o),{center:m.center,zoom:m.zoom,mapId:r,disableDefaultUI:!0,isFractionalZoomEnabled:!0,fullscreenControl:!1,zoomControl:!1})),d(f);const n=Ct(()=>{document.getElementById(o).querySelector('div[tabindex="0"]').focus()},250);document.getElementById(o).addEventListener("wheel",n,{passive:!0}),f.addListener("center_changed",e),f.addListener("heading_changed",e),f.addListener("tilt_changed",e),f.addListener("zoom_changed",e)});const e=()=>{document.getElementById(o).contains(document.activeElement)&&A()&&p("mapMove",{options:_()})}}),e.$$set=e=>{"id"in e&&i(0,o=e.id),"bearing"in e&&i(1,s=e.bearing),"center"in e&&i(2,a=e.center),"pitch"in e&&i(3,l=e.pitch),"zoom"in e&&i(4,c=e.zoom),"mapStyle"in e&&i(5,u=e.mapStyle),"numberOfMaps"in e&&i(6,h=e.numberOfMaps),"onMapMount"in e&&i(7,d=e.onMapMount)},e.$$.update=()=>{if(32&e.$$.dirty&&(r=u?.mapId),30&e.$$.dirty&&i(9,m={bearing:s,center:a,pitch:l,zoom:c}),768&e.$$.dirty&&(e=>{e&&A()&&e.moveCamera({center:{lat:a.lat,lng:a.lng},zoom:c+1,heading:s,tilt:l})})(f),321&e.$$.dirty&&f&&h){const e=document.getElementById(o);if(e){new ResizeObserver(()=>{google.maps.event.trigger(f,"resize")}).observe(e)}}},[o,s,a,l,c,u,h,d,f,m]}class fu extends ge{constructor(e){super(),me(this,e,pu,du,a,{id:0,bearing:1,center:2,pitch:3,zoom:4,mapStyle:5,numberOfMaps:6,onMapMount:7})}}const mu=e=>{if("string"!=typeof e)return!1;return e.startsWith("mapbox://")},gu=e=>{if(!e)return!1;let t;try{t=new URL(e)}catch(e){return!1}return"api.maptiler.com"===t.host&&!t.searchParams.has("key")},_u=(e,t)=>{const{mapboxKey:i,maptilerKey:r}=t;let n=e;return mu(e)&&i?n=((e,t)=>{if(!mu(e))return e;if(!t)return e;const[,,,i,r]=e.split("/");return`https://api.mapbox.com/styles/v1/${i}/${r}?title=true&access_token=${t}`})(n,i):gu(e)&&r&&(n=((e,t)=>{if(!t)return e;let i=new URL(e);return t&&gu(e)&&i.searchParams.append("key",t),i.toString()})(n,r)),n};let Au,yu;it.subscribe(e=>({mapboxGlAccessToken:Au,maptilerApiKey:yu}=e));const vu=async e=>{const t=mu(e);let i,r=e;try{r=new URL(e);const t={mapboxKey:Au,maptilerKey:yu};r=_u(r.toString(),t)}catch(e){}try{i=await fetch(r)}catch(e){throw{message:e.message}}if(!i.ok)throw{status:i.status,message:i.statusText};const n=await i.json();if(t&&n.message)throw{message:n.message};return n},xu=(e,t,i)=>e.replace("{branch}",t).replace("{style}",i),bu=["swipe","mirror","phone","responsive"];async function wu(e,t,i,r){return r._parse(e,t,i,r)}function Tu(e,t){if(!e)throw new Error(t||"loader assertion failed.")}const Eu=Boolean("object"!=typeof process||"[object process]"!==String(process)||process.browser),Cu="undefined"!=typeof process&&process.version&&/v([0-9]*)/.exec(process.version);Cu&&parseFloat(Cu[1]);const Bu=globalThis,Su=globalThis.process||{},Iu=globalThis.navigator||{};function Mu(e){if("undefined"!=typeof window&&"renderer"===window.process?.type)return!0;if("undefined"!=typeof process&&Boolean(process.versions?.electron))return!0;const t="undefined"!=typeof navigator&&navigator.userAgent,i=e||t;return Boolean(i&&i.indexOf("Electron")>=0)}function Pu(){return!("object"==typeof process&&"[object process]"===String(process)&&!process?.browser)||Mu()}const Ru="4.1.0";class Lu{constructor(e,t,i="sessionStorage"){this.storage=function(e){try{const t=window[e],i="__storage_test__";return t.setItem(i,i),t.removeItem(i),t}catch(e){return null}}(i),this.id=e,this.config=t,this._loadConfiguration()}getConfiguration(){return this.config}setConfiguration(e){if(Object.assign(this.config,e),this.storage){const e=JSON.stringify(this.config);this.storage.setItem(this.id,e)}}_loadConfiguration(){let e={};if(this.storage){const t=this.storage.getItem(this.id);e=t?JSON.parse(t):{}}return Object.assign(this.config,e),this}}var Fu;!function(e){e[e.BLACK=30]="BLACK",e[e.RED=31]="RED",e[e.GREEN=32]="GREEN",e[e.YELLOW=33]="YELLOW",e[e.BLUE=34]="BLUE",e[e.MAGENTA=35]="MAGENTA",e[e.CYAN=36]="CYAN",e[e.WHITE=37]="WHITE",e[e.BRIGHT_BLACK=90]="BRIGHT_BLACK",e[e.BRIGHT_RED=91]="BRIGHT_RED",e[e.BRIGHT_GREEN=92]="BRIGHT_GREEN",e[e.BRIGHT_YELLOW=93]="BRIGHT_YELLOW",e[e.BRIGHT_BLUE=94]="BRIGHT_BLUE",e[e.BRIGHT_MAGENTA=95]="BRIGHT_MAGENTA",e[e.BRIGHT_CYAN=96]="BRIGHT_CYAN",e[e.BRIGHT_WHITE=97]="BRIGHT_WHITE"}(Fu||(Fu={}));function ku(e){return"string"!=typeof e?e:(e=e.toUpperCase(),Fu[e]||Fu.WHITE)}function Du(e,t){if(!e)throw new Error(t||"Assertion failed")}function Ou(){let e;if(Pu()&&Bu.performance)e=Bu?.performance?.now?.();else if("hrtime"in Su){const t=Su?.hrtime?.();e=1e3*t[0]+t[1]/1e6}else e=Date.now();return e}const zu={debug:Pu()&&console.debug||console.log,log:console.log,info:console.info,warn:console.warn,error:console.error},Uu={enabled:!0,level:0};function Nu(){}const Vu={},ju={once:!0};class Gu{constructor({id:e}={id:""}){this.VERSION=Ru,this._startTs=Ou(),this._deltaTs=Ou(),this.userData={},this.LOG_THROTTLE_TIMEOUT=0,this.id=e,this.userData={},this._storage=new Lu(`__probe-${this.id}__`,Uu),this.timeStamp(`${this.id} started`),function(e,t=["constructor"]){const i=Object.getPrototypeOf(e),r=Object.getOwnPropertyNames(i),n=e;for(const i of r){const r=n[i];"function"==typeof r&&(t.find(e=>i===e)||(n[i]=r.bind(e)))}}(this),Object.seal(this)}set level(e){this.setLevel(e)}get level(){return this.getLevel()}isEnabled(){return this._storage.config.enabled}getLevel(){return this._storage.config.level}getTotal(){return Number((Ou()-this._startTs).toPrecision(10))}getDelta(){return Number((Ou()-this._deltaTs).toPrecision(10))}set priority(e){this.level=e}get priority(){return this.level}getPriority(){return this.level}enable(e=!0){return this._storage.setConfiguration({enabled:e}),this}setLevel(e){return this._storage.setConfiguration({level:e}),this}get(e){return this._storage.config[e]}set(e,t){this._storage.setConfiguration({[e]:t})}settings(){console.table?console.table(this._storage.config):console.log(this._storage.config)}assert(e,t){if(!e)throw new Error(t||"Assertion failed")}warn(e){return this._getLogFunction(0,e,zu.warn,arguments,ju)}error(e){return this._getLogFunction(0,e,zu.error,arguments)}deprecated(e,t){return this.warn(`\`${e}\` is deprecated and will be removed in a later version. Use \`${t}\` instead`)}removed(e,t){return this.error(`\`${e}\` has been removed. Use \`${t}\` instead`)}probe(e,t){return this._getLogFunction(e,t,zu.log,arguments,{time:!0,once:!0})}log(e,t){return this._getLogFunction(e,t,zu.debug,arguments)}info(e,t){return this._getLogFunction(e,t,console.info,arguments)}once(e,t){return this._getLogFunction(e,t,zu.debug||zu.info,arguments,ju)}table(e,t,i){return t?this._getLogFunction(e,t,console.table||Nu,i&&[i],{tag:$u(t)}):Nu}time(e,t){return this._getLogFunction(e,t,console.time?console.time:console.info)}timeEnd(e,t){return this._getLogFunction(e,t,console.timeEnd?console.timeEnd:console.info)}timeStamp(e,t){return this._getLogFunction(e,t,console.timeStamp||Nu)}group(e,t,i={collapsed:!1}){const r=Qu({logLevel:e,message:t,opts:i}),{collapsed:n}=i;return r.method=(n?console.groupCollapsed:console.group)||console.info,this._getLogFunction(r)}groupCollapsed(e,t,i={}){return this.group(e,t,Object.assign({},i,{collapsed:!0}))}groupEnd(e){return this._getLogFunction(e,"",console.groupEnd||Nu)}withGroup(e,t,i){this.group(e,t)();try{i()}finally{this.groupEnd(e)()}}trace(){console.trace&&console.trace()}_shouldLog(e){return this.isEnabled()&&this.getLevel()>=Hu(e)}_getLogFunction(e,t,i,r,n){if(this._shouldLog(e)){n=Qu({logLevel:e,message:t,args:r,opts:n}),Du(i=i||n.method),n.total=this.getTotal(),n.delta=this.getDelta(),this._deltaTs=Ou();const o=n.tag||n.message;if(n.once&&o){if(Vu[o])return Nu;Vu[o]=Ou()}return t=function(e,t,i){if("string"==typeof t){const r=i.time?function(e,t=8){const i=Math.max(t-e.length,0);return`${" ".repeat(i)}${e}`}(function(e){let t;return t=e<10?`${e.toFixed(2)}ms`:e<100?`${e.toFixed(1)}ms`:e<1e3?`${e.toFixed(0)}ms`:`${(e/1e3).toFixed(2)}s`,t}(i.total)):"";t=function(e,t,i){Pu||"string"!=typeof e||(t&&(e=`[${ku(t)}m${e}`),i&&(e=`[${ku(i)+10}m${e}`));return e}(t=i.time?`${e}: ${r} ${t}`:`${e}: ${t}`,i.color,i.background)}return t}(this.id,n.message,n),i.bind(console,t,...n.args)}return Nu}}function Hu(e){if(!e)return 0;let t;switch(typeof e){case"number":t=e;break;case"object":t=e.logLevel||e.priority||0;break;default:return 0}return Du(Number.isFinite(t)&&t>=0),t}function Qu(e){const{logLevel:t,message:i}=e;e.logLevel=Hu(t);const r=e.args?Array.from(e.args):[];for(;r.length&&r.shift()!==i;);switch(typeof t){case"string":case"function":void 0!==i&&r.unshift(i),e.message=t;break;case"object":Object.assign(e,t)}"function"==typeof e.message&&(e.message=e.message());const n=typeof e.message;return Du("string"===n||"object"===n),Object.assign(e,{args:r},e.opts)}function $u(e){for(const t in e)for(const i in e[t])return i||"untitled";return"empty"}Gu.VERSION=Ru,globalThis.probe={};var Zu=new Gu({id:"@probe.gl/log"});const Wu="4.3.3",qu=Wu[0]>="0"&&Wu[0]<="9"?`v${Wu}`:"";const Ku=function(){const e=new Gu({id:"loaders.gl"});return globalThis.loaders=globalThis.loaders||{},globalThis.loaders.log=e,globalThis.loaders.version=qu,globalThis.probe=globalThis.probe||{},globalThis.probe.loaders=e,e}();function Xu(e,t){return Ju(e||{},t)}function Ju(e,t,i=0){if(i>3)return t;const r={...e};for(const[e,n]of Object.entries(t))n&&"object"==typeof n&&!Array.isArray(n)?r[e]=Ju(r[e]||{},t[e],i+1):r[e]=t[e];return r}function Yu(e,t){if(!e)throw new Error(t||"loaders.gl assertion failed.")}globalThis._loadersgl_?.version||(globalThis._loadersgl_=globalThis._loadersgl_||{},globalThis._loadersgl_.version="4.3.3"),globalThis._loadersgl_.version;const eh="object"!=typeof process||"[object process]"!==String(process)||process.browser,th="undefined"!=typeof window&&void 0!==window.orientation,ih="undefined"!=typeof process&&process.version&&/v([0-9]*)/.exec(process.version);ih&&parseFloat(ih[1]);class rh{name;workerThread;isRunning=!0;result;_resolve=()=>{};_reject=()=>{};constructor(e,t){this.name=e,this.workerThread=t,this.result=new Promise((e,t)=>{this._resolve=e,this._reject=t})}postMessage(e,t){this.workerThread.postMessage({source:"loaders.gl",type:e,payload:t})}done(e){Yu(this.isRunning),this.isRunning=!1,this._resolve(e)}error(e){Yu(this.isRunning),this.isRunning=!1,this._reject(e)}}class nh{terminate(){}}const oh=new Map;function sh(e){Yu(e.source&&!e.url||!e.source&&e.url);let t=oh.get(e.source||e.url);return t||(e.url&&(t=function(e){if(!e.startsWith("http"))return e;return ah((t=e,`try {\n importScripts('${t}');\n} catch (error) {\n console.error(error);\n throw error;\n}`));var t}(e.url),oh.set(e.url,t)),e.source&&(t=ah(e.source),oh.set(e.source,t))),Yu(t),t}function ah(e){const t=new Blob([e],{type:"application/javascript"});return URL.createObjectURL(t)}function lh(e,t=!0,i){const r=i||new Set;if(e){if(ch(e))r.add(e);else if(ch(e.buffer))r.add(e.buffer);else if(ArrayBuffer.isView(e));else if(t&&"object"==typeof e)for(const i in e)lh(e[i],t,r)}else;return void 0===i?Array.from(r):[]}function ch(e){return!!e&&(e instanceof ArrayBuffer||("undefined"!=typeof MessagePort&&e instanceof MessagePort||("undefined"!=typeof ImageBitmap&&e instanceof ImageBitmap||"undefined"!=typeof OffscreenCanvas&&e instanceof OffscreenCanvas)))}const uh=()=>{};class hh{name;source;url;terminated=!1;worker;onMessage;onError;_loadableURL="";static isSupported(){return"undefined"!=typeof Worker&&eh||void 0!==nh&&!eh}constructor(e){const{name:t,source:i,url:r}=e;Yu(i||r),this.name=t,this.source=i,this.url=r,this.onMessage=uh,this.onError=e=>console.log(e),this.worker=eh?this._createBrowserWorker():this._createNodeWorker()}destroy(){this.onMessage=uh,this.onError=uh,this.worker.terminate(),this.terminated=!0}get isRunning(){return Boolean(this.onMessage)}postMessage(e,t){t=t||lh(e),this.worker.postMessage(e,t)}_getErrorFromErrorEvent(e){let t="Failed to load ";return t+=`worker ${this.name} from ${this.url}. `,e.message&&(t+=`${e.message} in `),e.lineno&&(t+=`:${e.lineno}:${e.colno}`),new Error(t)}_createBrowserWorker(){this._loadableURL=sh({source:this.source,url:this.url});const e=new Worker(this._loadableURL,{name:this.name});return e.onmessage=e=>{e.data?this.onMessage(e.data):this.onError(new Error("No data received"))},e.onerror=e=>{this.onError(this._getErrorFromErrorEvent(e)),this.terminated=!0},e.onmessageerror=e=>console.error(e),e}_createNodeWorker(){let e;if(this.url){const t=this.url.includes(":/")||this.url.startsWith("/")?this.url:`./${this.url}`;e=new nh(t,{eval:!1})}else{if(!this.source)throw new Error("no worker");e=new nh(this.source,{eval:!0})}return e.on("message",e=>{this.onMessage(e)}),e.on("error",e=>{this.onError(e)}),e.on("exit",e=>{}),e}}class dh{name="unnamed";source;url;maxConcurrency=1;maxMobileConcurrency=1;onDebug=()=>{};reuseWorkers=!0;props={};jobQueue=[];idleQueue=[];count=0;isDestroyed=!1;static isSupported(){return hh.isSupported()}constructor(e){this.source=e.source,this.url=e.url,this.setProps(e)}destroy(){this.idleQueue.forEach(e=>e.destroy()),this.isDestroyed=!0}setProps(e){this.props={...this.props,...e},void 0!==e.name&&(this.name=e.name),void 0!==e.maxConcurrency&&(this.maxConcurrency=e.maxConcurrency),void 0!==e.maxMobileConcurrency&&(this.maxMobileConcurrency=e.maxMobileConcurrency),void 0!==e.reuseWorkers&&(this.reuseWorkers=e.reuseWorkers),void 0!==e.onDebug&&(this.onDebug=e.onDebug)}async startJob(e,t=(e,t,i)=>e.done(i),i=(e,t)=>e.error(t)){const r=new Promise(r=>(this.jobQueue.push({name:e,onMessage:t,onError:i,onStart:r}),this));return this._startQueuedJob(),await r}async _startQueuedJob(){if(!this.jobQueue.length)return;const e=this._getAvailableWorker();if(!e)return;const t=this.jobQueue.shift();if(t){this.onDebug({message:"Starting job",name:t.name,workerThread:e,backlog:this.jobQueue.length});const i=new rh(t.name,e);e.onMessage=e=>t.onMessage(i,e.type,e.payload),e.onError=e=>t.onError(i,e),t.onStart(i);try{await i.result}catch(e){console.error(`Worker exception: ${e}`)}finally{this.returnWorkerToQueue(e)}}}returnWorkerToQueue(e){!eh||this.isDestroyed||!this.reuseWorkers||this.count>this._getMaxConcurrency()?(e.destroy(),this.count--):this.idleQueue.push(e),this.isDestroyed||this._startQueuedJob()}_getAvailableWorker(){if(this.idleQueue.length>0)return this.idleQueue.shift()||null;if(this.count{}};class fh{props;workerPools=new Map;static _workerFarm;static isSupported(){return hh.isSupported()}static getWorkerFarm(e={}){return fh._workerFarm=fh._workerFarm||new fh({}),fh._workerFarm.setProps(e),fh._workerFarm}constructor(e){this.props={...ph},this.setProps(e),this.workerPools=new Map}destroy(){for(const e of this.workerPools.values())e.destroy();this.workerPools=new Map}setProps(e){this.props={...this.props,...e};for(const e of this.workerPools.values())e.setProps(this._getWorkerPoolProps())}getWorkerPool(e){const{name:t,source:i,url:r}=e;let n=this.workerPools.get(t);return n||(n=new dh({name:t,source:i,url:r}),n.setProps(this._getWorkerPoolProps()),this.workerPools.set(t,n)),n}_getWorkerPoolProps(){return{maxConcurrency:this.props.maxConcurrency,maxMobileConcurrency:this.props.maxMobileConcurrency,reuseWorkers:this.props.reuseWorkers,onDebug:this.props.onDebug}}}async function mh(e,t,i,r,n){const o=e.id,s=function(e,t={}){const i=t[e.id]||{},r=eh?`${e.id}-worker.js`:`${e.id}-worker-node.js`;let n=i.workerUrl;if(n||"compression"!==e.id||(n=t.workerUrl),"test"===t._workerType&&(n=eh?`modules/${e.module}/dist/${r}`:`modules/${e.module}/src/workers/${e.id}-worker-node.ts`),!n){let t=e.version;"latest"===t&&(t="latest");const i=t?`@${t}`:"";n=`https://unpkg.com/@loaders.gl/${e.module}${i}/dist/${r}`}return Yu(n),n}(e,i),a=fh.getWorkerFarm(i).getWorkerPool({name:o,url:s});i=JSON.parse(JSON.stringify(i)),r=JSON.parse(JSON.stringify(r||{}));const l=await a.startJob("process-on-worker",gh.bind(null,n));l.postMessage("process",{input:t,options:i,context:r});const c=await l.result;return await c.result}async function gh(e,t,i,r){switch(i){case"done":t.done(r);break;case"error":t.error(new Error(r.error));break;case"process":const{id:n,input:o,options:s}=r;try{const i=await e(o,s);t.postMessage("done",{id:n,result:i})}catch(e){const i=e instanceof Error?e.message:"unknown error";t.postMessage("error",{id:n,error:i})}break;default:console.warn(`parse-with-worker unknown message ${i}`)}}function _h(e,t,i){if(e.byteLength<=t+i)return"";const r=new DataView(e);let n="";for(let e=0;ee instanceof ArrayBuffer?new Uint8Array(e):e),i=t.reduce((e,t)=>e+t.byteLength,0),r=new Uint8Array(i);let n=0;for(const e of t)r.set(e,n),n+=e.byteLength;return r.buffer}(e)}function vh(e,t,i){const r=void 0!==i?new Uint8Array(e).subarray(t,t+i):new Uint8Array(e).subarray(t);return new Uint8Array(r).buffer}function xh(e,t){return Tu(e>=0),Tu(t>0),e+(t-1)&~(t-1)}function bh(e,t,i){let r;if(e instanceof ArrayBuffer)r=new Uint8Array(e);else{const t=e.byteOffset,i=e.byteLength;r=new Uint8Array(e.buffer||e.arrayBuffer,t,i)}return t.set(r,i),i+xh(r.byteLength,4)}function wh(){let e;if("undefined"!=typeof window&&window.performance)e=window.performance.now();else if("undefined"!=typeof process&&process.hrtime){const t=process.hrtime();e=1e3*t[0]+t[1]/1e6}else e=Date.now();return e}class Th{constructor(e,t){this.sampleSize=1,this.time=0,this.count=0,this.samples=0,this.lastTiming=0,this.lastSampleTime=0,this.lastSampleCount=0,this._count=0,this._time=0,this._samples=0,this._startTime=0,this._timerPending=!1,this.name=e,this.type=t,this.reset()}reset(){return this.time=0,this.count=0,this.samples=0,this.lastTiming=0,this.lastSampleTime=0,this.lastSampleCount=0,this._count=0,this._time=0,this._samples=0,this._startTime=0,this._timerPending=!1,this}setSampleSize(e){return this.sampleSize=e,this}incrementCount(){return this.addCount(1),this}decrementCount(){return this.subtractCount(1),this}addCount(e){return this._count+=e,this._samples++,this._checkSampling(),this}subtractCount(e){return this._count-=e,this._samples++,this._checkSampling(),this}addTime(e){return this._time+=e,this.lastTiming=e,this._samples++,this._checkSampling(),this}timeStart(){return this._startTime=wh(),this._timerPending=!0,this}timeEnd(){return this._timerPending?(this.addTime(wh()-this._startTime),this._timerPending=!1,this._checkSampling(),this):this}getSampleAverageCount(){return this.sampleSize>0?this.lastSampleCount/this.sampleSize:0}getSampleAverageTime(){return this.sampleSize>0?this.lastSampleTime/this.sampleSize:0}getSampleHz(){return this.lastSampleTime>0?this.sampleSize/(this.lastSampleTime/1e3):0}getAverageCount(){return this.samples>0?this.count/this.samples:0}getAverageTime(){return this.samples>0?this.time/this.samples:0}getHz(){return this.time>0?this.samples/(this.time/1e3):0}_checkSampling(){this._samples===this.sampleSize&&(this.lastSampleTime=this._time,this.lastSampleCount=this._count,this.count+=this._count,this.time+=this._time,this.samples+=this._samples,this._time=0,this._count=0,this._samples=0)}}class Eh{constructor(e){this.stats={},this.id=e.id,this.stats={},this._initializeStats(e.stats),Object.seal(this)}get(e,t="count"){return this._getOrCreate({name:e,type:t})}get size(){return Object.keys(this.stats).length}reset(){for(const e of Object.values(this.stats))e.reset();return this}forEach(e){for(const t of Object.values(this.stats))e(t)}getTable(){const e={};return this.forEach(t=>{e[t.name]={time:t.time||0,count:t.count||0,average:t.getAverageTime()||0,hz:t.getHz()||0}}),e}_initializeStats(e=[]){e.forEach(e=>this._getOrCreate(e))}_getOrCreate(e){const{name:t,type:i}=e;let r=this.stats[t];return r||(r=e instanceof Th?e:new Th(t,i),this.stats[t]=r),r}}const Ch={id:"request-scheduler",throttleRequests:!0,maxRequests:6,debounceTime:0};class Bh{props;stats;activeRequestCount=0;requestQueue=[];requestMap=new Map;updateTimer=null;constructor(e={}){this.props={...Ch,...e},this.stats=new Eh({id:this.props.id}),this.stats.get("Queued Requests"),this.stats.get("Active Requests"),this.stats.get("Cancelled Requests"),this.stats.get("Queued Requests Ever"),this.stats.get("Active Requests Ever")}scheduleRequest(e,t=()=>0){if(!this.props.throttleRequests)return Promise.resolve({done:()=>{}});if(this.requestMap.has(e))return this.requestMap.get(e);const i={handle:e,priority:0,getPriority:t},r=new Promise(e=>(i.resolve=e,i));return this.requestQueue.push(i),this.requestMap.set(e,r),this._issueNewRequests(),r}_issueRequest(e){const{handle:t,resolve:i}=e;let r=!1;const n=()=>{r||(r=!0,this.requestMap.delete(t),this.activeRequestCount--,this._issueNewRequests())};return this.activeRequestCount++,i?i({done:n}):Promise.resolve({done:n})}_issueNewRequests(){null!==this.updateTimer&&clearTimeout(this.updateTimer),this.updateTimer=setTimeout(()=>this._issueNewRequestsAsync(),this.props.debounceTime)}_issueNewRequestsAsync(){null!==this.updateTimer&&clearTimeout(this.updateTimer),this.updateTimer=null;const e=Math.max(this.props.maxRequests-this.activeRequestCount,0);if(0!==e){this._updateAllRequests();for(let t=0;te.priority-t.priority)}_updateRequest(e){return e.priority=e.getPriority(e.handle),!(e.priority<0)||(e.resolve(null),!1)}}const Sh={};function Ih(e){if((t=e)&&"object"==typeof t&&t.isBuffer)return e;var t;if(e instanceof ArrayBuffer)return e;if(ArrayBuffer.isView(e))return 0===e.byteOffset&&e.byteLength===e.buffer.byteLength?e.buffer:e.buffer.slice(e.byteOffset,e.byteOffset+e.byteLength);if("string"==typeof e){const t=e;return(new TextEncoder).encode(t).buffer}if(e&&"object"==typeof e&&e._toArrayBuffer)return e._toArrayBuffer();throw new Error("toArrayBuffer")}function Mh(){if("undefined"!=typeof process&&void 0!==process.cwd)return process.cwd();const e=window.location?.pathname;return e?.slice(0,e.lastIndexOf("/")+1)||""}function Ph(e){const t=e?e.lastIndexOf("/"):-1;return t>=0?e.substr(t+1):""}function Rh(e){const t=e?e.lastIndexOf("/"):-1;return t>=0?e.substr(0,t):""}function Lh(...e){const t=[];for(let i=0;i=-1&&!n;e--){let o;e>=0?o=t[e]:(void 0===i&&(i=Mh()),o=i),0!==o.length&&(r=`${o}/${r}`,n=o.charCodeAt(0)===Fh)}return r=function(e,t){let i,r="",n=-1,o=0,s=!1;for(let a=0;a<=e.length;++a){if(a2){const e=r.length-1;let t=e;for(;t>=0&&r.charCodeAt(t)!==Fh;--t);if(t!==e){r=-1===t?"":r.slice(0,t),n=a,o=0,s=!1;continue}}else if(2===r.length||1===r.length){r="",n=a,o=0,s=!1;continue}t&&(r.length>0?r+="/..":r="..",s=!0)}else{const t=e.slice(n+1,a);r.length>0?r+=`/${t}`:r=t,s=!1}n=a,o=0}else i===kh&&-1!==o?++o:o=-1}return r}(r,!n),n?`/${r}`:r.length>0?r:"."}const Fh=47,kh=46;const Dh=e=>"function"==typeof e,Oh=e=>null!==e&&"object"==typeof e,zh=e=>Oh(e)&&e.constructor==={}.constructor,Uh=e=>"undefined"!=typeof Response&&e instanceof Response||e&&e.arrayBuffer&&e.text&&e.json,Nh=e=>"undefined"!=typeof Blob&&e instanceof Blob,Vh=e=>(e=>"undefined"!=typeof ReadableStream&&e instanceof ReadableStream||Oh(e)&&Dh(e.tee)&&Dh(e.cancel)&&Dh(e.getReader))(e)||(e=>Oh(e)&&Dh(e.read)&&Dh(e.pipe)&&(e=>"boolean"==typeof e)(e.readable))(e);class jh extends Error{constructor(e,t){super(e),this.reason=t.reason,this.url=t.url,this.response=t.response}reason;url;response}const Gh=/^data:([-\w.]+\/[-\w.+]+)(;|,)/,Hh=/^([-\w.]+\/[-\w.+]+)/;function Qh(e,t){return e.toLowerCase()===t.toLowerCase()}function $h(e){const t=Gh.exec(e);return t?t[1]:""}const Zh=/\?.*/;function Wh(e){return e.replace(Zh,"")}function qh(e){if(Uh(e)){return e.url}if(Nh(e)){return e.name||""}return"string"==typeof e?e:""}function Kh(e){if(Uh(e)){const t=e,i=t.headers.get("content-type")||"",r=Wh(t.url);return function(e){const t=Hh.exec(e);return t?t[1]:e}(i)||$h(r)}if(Nh(e)){return e.type||""}return"string"==typeof e?$h(e):""}async function Xh(e){if(Uh(e))return e;const t={},i=function(e){if(Uh(e))return e.headers["content-length"]||-1;if(Nh(e))return e.size;return"string"==typeof e?e.length:e instanceof ArrayBuffer||ArrayBuffer.isView(e)?e.byteLength:-1}(e);i>=0&&(t["content-length"]=String(i));const r=qh(e),n=Kh(e);n&&(t["content-type"]=n);const o=await async function(e){const t=5;if("string"==typeof e)return`data:,${e.slice(0,t)}`;if(e instanceof Blob){const t=e.slice(0,5);return await new Promise(e=>{const i=new FileReader;i.onload=t=>e(t?.target?.result),i.readAsDataURL(t)})}if(e instanceof ArrayBuffer){const i=function(e){let t="";const i=new Uint8Array(e);for(let e=0;e100?`${i.slice(0,100)}...`:i;const r={reason:e.statusText,url:e.url,response:e};try{const t=e.headers.get("Content-Type");r.reason=!e.bodyUsed&&t?.includes("application/json")?await e.json():await e.text()}catch(e){}return new jh(i,r)}(e);throw t}}async function Yh(e,t){if("string"==typeof e){const i=function(e){for(const t in Sh)if(e.startsWith(t)){const i=Sh[t];e=e.replace(t,i)}return e.startsWith("http://")||e.startsWith("https://")||(e=`${e}`),e}(e);return function(e){return!function(e){return e.startsWith("http:")||e.startsWith("https:")}(e)&&!function(e){return e.startsWith("data:")}(e)}(i)&&globalThis.loaders?.fetchNode?globalThis.loaders?.fetchNode(i,t):await fetch(i,t)}return await Xh(e)}const ed=new Gu({id:"loaders.gl"});class td{log(){return()=>{}}info(){return()=>{}}warn(){return()=>{}}error(){return()=>{}}}const id={fetch:null,mimeType:void 0,nothrow:!1,log:new class{console;constructor(){this.console=console}log(...e){return this.console.log.bind(this.console,...e)}info(...e){return this.console.info.bind(this.console,...e)}warn(...e){return this.console.warn.bind(this.console,...e)}error(...e){return this.console.error.bind(this.console,...e)}},useLocalLibraries:!1,CDN:"https://unpkg.com/@loaders.gl",worker:!0,maxConcurrency:3,maxMobileConcurrency:1,reuseWorkers:Eu,_nodeWorkers:!1,_workerType:"",limit:0,_limitMB:0,batchSize:"auto",batchDebounceMs:0,metadata:!1,transforms:[]},rd={throws:"nothrow",dataType:"(no longer used)",uri:"baseUri",method:"fetch.method",headers:"fetch.headers",body:"fetch.body",mode:"fetch.mode",credentials:"fetch.credentials",cache:"fetch.cache",redirect:"fetch.redirect",referrer:"fetch.referrer",referrerPolicy:"fetch.referrerPolicy",integrity:"fetch.integrity",keepalive:"fetch.keepalive",signal:"fetch.signal"};function nd(){globalThis.loaders=globalThis.loaders||{};const{loaders:e}=globalThis;return e._state||(e._state={}),e._state}function od(){const e=nd();return e.globalOptions=e.globalOptions||{...id},e.globalOptions}function sd(e,t,i,r){return i=i||[],function(e,t){ad(e,null,id,rd,t);for(const i of t){const r=e&&e[i.id]||{},n=i.options&&i.options[i.id]||{},o=i.deprecatedOptions&&i.deprecatedOptions[i.id]||{};ad(r,i.id,n,o,t)}}(e,i=Array.isArray(i)?i:[i]),function(e,t,i){const r=e.options||{},n={...r};(function(e,t){t&&!("baseUri"in e)&&(e.baseUri=t)})(n,i),null===n.log&&(n.log=new td);return cd(n,od()),cd(n,t),n}(t,e,r)}function ad(e,t,i,r,n){const o=t||"Top level",s=t?`${t}.`:"";for(const a in e){const l=!t&&Oh(e[a]);if(!(a in i)&&!("baseUri"===a&&!t)&&!("workerUrl"===a&&t))if(a in r)ed.warn(`${o} loader option '${s}${a}' no longer supported, use '${r[a]}'`)();else if(!l){const e=ld(a,n);ed.warn(`${o} loader option '${s}${a}' not recognized. ${e}`)()}}}function ld(e,t){const i=e.toLowerCase();let r="";for(const n of t)for(const t in n.options){if(e===t)return`Did you mean '${n.id}.${t}'?`;const o=t.toLowerCase();(i.startsWith(o)||o.startsWith(i))&&(r=r||`Did you mean '${n.id}.${t}'?`)}return r}function cd(e,t){for(const i in t)if(i in t){const r=t[i];zh(r)&&zh(e[i])?e[i]={...e[i],...t[i]}:e[i]=t[i]}}function ud(e){if(!e)return!1;Array.isArray(e)&&(e=e[0]);return Array.isArray(e?.extensions)}function hd(e){let t;return Tu(e,"null loader"),Tu(ud(e),"invalid loader"),Array.isArray(e)&&(t=e[1],e=e[0],e={...e,options:{...e.options,...t}}),(e?.parseTextSync||e?.parseText)&&(e.text=!0),e.text||(e.binary=!0),e}const dd=()=>{const e=nd();return e.loaderRegistry=e.loaderRegistry||[],e.loaderRegistry};const pd=/\.([^.]+)$/;function fd(e,t=[],i,r){if(!md(e))return null;if(t&&!Array.isArray(t))return hd(t);let n=[];t&&(n=n.concat(t)),i?.ignoreRegisteredLoaders||n.push(...dd()),function(e){for(const t of e)hd(t)}(n);const o=function(e,t,i,r){const n=qh(e),o=Kh(e),s=Wh(n)||r?.url;let a=null,l="";i?.mimeType&&(a=_d(t,i?.mimeType),l=`match forced by supplied MIME type ${i?.mimeType}`);a=a||function(e,t){const i=t&&pd.exec(t),r=i&&i[1];return r?function(e,t){t=t.toLowerCase();for(const i of e)for(const e of i.extensions)if(e.toLowerCase()===t)return i;return null}(e,r):null}(t,s),l=l||(a?`matched url ${s}`:""),a=a||_d(t,o),l=l||(a?`matched MIME type ${o}`:""),a=a||function(e,t){if(!t)return null;for(const i of e)if("string"==typeof t){if(Ad(t,i))return i}else if(ArrayBuffer.isView(t)){if(yd(t.buffer,t.byteOffset,i))return i}else if(t instanceof ArrayBuffer){if(yd(t,0,i))return i}return null}(t,e),l=l||(a?`matched initial data ${vd(e)}`:""),i?.fallbackMimeType&&(a=a||_d(t,i?.fallbackMimeType),l=l||(a?`matched fallback MIME type ${o}`:""));l&&Ku.log(1,`selectLoader selected ${a?.name}: ${l}.`);return a}(e,n,i,r);if(!o&&!i?.nothrow)throw new Error(gd(e));return o}function md(e){return!(e instanceof Response&&204===e.status)}function gd(e){const t=qh(e),i=Kh(e);let r="No valid loader found (";r+=t?`${Ph(t)}, `:"no url provided, ",r+=`MIME type: ${i?`"${i}"`:"not provided"}, `;const n=e?vd(e):"";return r+=n?` first bytes: "${n}"`:"first bytes: not available",r+=")",r}function _d(e,t){for(const i of e){if(i.mimeTypes?.some(e=>Qh(t,e)))return i;if(Qh(t,`application/x.${i.id}`))return i}return null}function Ad(e,t){if(t.testText)return t.testText(e);return(Array.isArray(t.tests)?t.tests:[t.tests]).some(t=>e.startsWith(t))}function yd(e,t,i){return(Array.isArray(i.tests)?i.tests:[i.tests]).some(i=>function(e,t,i,r){if(r instanceof ArrayBuffer)return function(e,t,i){if(i=i||e.byteLength,e.byteLengthe&&"object"==typeof e&&e.isBuffer)(e)&&(e=e.buffer),e instanceof ArrayBuffer){const i=e;return t.text&&!t.binary?new TextDecoder("utf8").decode(i):i}if(ArrayBuffer.isView(e)){if(t.text&&!t.binary)return new TextDecoder("utf8").decode(e);let i=e.buffer;const r=e.byteLength||e.length;return 0===e.byteOffset&&r===i.byteLength||(i=i.slice(e.byteOffset,e.byteOffset+r)),i}throw new Error(Cd)}(e,t);if(Nh(e)&&(e=await Xh(e)),Uh(e)){const i=e;return await Jh(i),t.binary?await i.arrayBuffer():await i.text()}if(Vh(e)&&(e=Ed(e,i)),(e=>Boolean(e)&&"function"==typeof e[Symbol.iterator])(e)||(e=>e&&"function"==typeof e[Symbol.asyncIterator])(e))return async function(e){const t=[];for await(const i of e)t.push(i);return yh(...t)}(e);throw new Error(Cd)}function Sd(e,t){const i=od(),r=e||i;return"function"==typeof r.fetch?r.fetch:Oh(r.fetch)?e=>Yh(e,r.fetch):t?.fetch?t?.fetch:Yh}function Id(e,t,i){if(i)return i;const r={fetch:Sd(t,e),...e};if(r.url){const e=Wh(r.url);r.baseUrl=e,r.queryString=function(e){const t=e.match(Zh);return t&&t[0]}(r.url),r.filename=Ph(e),r.baseUrl=Rh(e)}return Array.isArray(r.loaders)||(r.loaders=null),r}async function Md(e,t,i,r){!t||Array.isArray(t)||ud(t)||(r=void 0,i=t,t=void 0),i=i||{};const n=qh(e=await e),o=function(e,t){if(e&&!Array.isArray(e))return e;let i;if(e&&(i=Array.isArray(e)?e:[e]),t&&t.loaders){const e=Array.isArray(t.loaders)?t.loaders:[t.loaders];i=i?[...i,...e]:e}return i&&i.length?i:void 0}(t,r),s=await async function(e,t=[],i,r){if(!md(e))return null;let n=fd(e,t,{...i,nothrow:!0},r);if(n)return n;if(Nh(e)&&(n=fd(e=await e.slice(0,10).arrayBuffer(),t,i,r)),!n&&!i?.nothrow)throw new Error(gd(e));return n}(e,o,i);return s?(r=Id({url:n,_parse:Md,loaders:o},i=sd(i,s,o,n),r||null),await async function(e,t,i,r){if(function(e){bd(e,"no worker provided");const t=e.version}(e),i=Xu(e.options,i),Uh(t)){const e=t,{ok:i,redirected:n,status:o,statusText:s,type:a,url:l}=e,c=Object.fromEntries(e.headers.entries());r.response={headers:c,ok:i,redirected:n,status:o,statusText:s,type:a,url:l}}t=await Bd(t,e,i);const n=e;if(n.parseTextSync&&"string"==typeof t)return n.parseTextSync(t,i,r);if(function(e,t){return!!fh.isSupported()&&!(!eh&&!t?._nodeWorkers)&&e.worker&&t?.worker}(e,i))return await mh(e,t,i,r,Md);if(n.parseText&&"string"==typeof t)return await n.parseText(t,i,r);if(n.parse)return await n.parse(t,i,r);throw bd(!n.parseSync),new Error(`${e.id} loader - no parser found and worker is disabled`)}(s,e,i,r)):null}function Pd(e){let t=1/0,i=1/0,r=1/0,n=-1/0,o=-1/0,s=-1/0;const a=e.POSITION?e.POSITION.value:[],l=a&&a.length;for(let e=0;en?l:n,o=c>o?c:o,s=u>s?u:s}return[[t,i,r],[n,o,s]]}function Rd(e,t,i){const r=function(e){switch(e.constructor){case Int8Array:return"int8";case Uint8Array:case Uint8ClampedArray:return"uint8";case Int16Array:return"int16";case Uint16Array:return"uint16";case Int32Array:return"int32";case Uint32Array:return"uint32";case Float32Array:return"float32";case Float64Array:return"float64";default:return"null"}}(t.value),n=i||function(e){const t={};"byteOffset"in e&&(t.byteOffset=e.byteOffset.toString(10));"byteStride"in e&&(t.byteStride=e.byteStride.toString(10));"normalized"in e&&(t.normalized=e.normalized.toString());return t}(t);return{name:e,type:{type:"fixed-size-list",listSize:t.size,children:[{name:"value",type:r}]},nullable:!1,metadata:n}}async function Ld(e,t,i,r){let n,o;Array.isArray(t)||ud(t)?(n=t,o=i):(n=[],o=t);const s=Sd(o);let a=e;return"string"==typeof e&&(a=await s(e)),Nh(e)&&(a=await s(e)),Array.isArray(n),await Md(a,n,o)}const Fd=globalThis.loaders?.parseImageNode,kd="undefined"!=typeof Image,Dd="undefined"!=typeof ImageBitmap,Od=Boolean(Fd),zd=!!Eu||Od;function Ud(e){const t=function(e){if("undefined"!=typeof ImageBitmap&&e instanceof ImageBitmap)return"imagebitmap";if("undefined"!=typeof Image&&e instanceof Image)return"image";if(e&&"object"==typeof e&&e.data&&e.width&&e.height)return"data";return null}(e);if(!t)throw new Error("Not an image");return t}function Nd(e){switch(Ud(e)){case"data":return e;case"image":case"imagebitmap":const t=document.createElement("canvas"),i=t.getContext("2d");if(!i)throw new Error("getImageData");return t.width=e.width,t.height=e.height,i.drawImage(e,0,0),i.getImageData(0,0,e.width,e.height);default:throw new Error("getImageData")}}const Vd=/^data:image\/svg\+xml/,jd=/\.svg((\?|#).*)?$/;function Gd(e){return e&&(Vd.test(e)||jd.test(e))}function Hd(e,t){if(Gd(t))throw new Error("SVG cannot be parsed directly to imagebitmap");return new Blob([new Uint8Array(e)])}async function Qd(e,t,i){const r=function(e,t){if(Gd(t)){let t=(new TextDecoder).decode(e);try{"function"==typeof unescape&&"function"==typeof encodeURIComponent&&(t=unescape(encodeURIComponent(t)))}catch(e){throw new Error(e.message)}return`data:image/svg+xml;base64,${btoa(t)}`}return Hd(e,t)}(e,i),n=self.URL||self.webkitURL,o="string"!=typeof r&&n.createObjectURL(r);try{return await async function(e,t){const i=new Image;if(i.src=e,t.image&&t.image.decode&&i.decode)return await i.decode(),i;return await new Promise((e,t)=>{try{i.onload=()=>e(i),i.onerror=e=>{const i=e instanceof Error?e.message:"error";t(new Error(i))}}catch(e){t(e)}})}(o||r,t)}finally{o&&n.revokeObjectURL(o)}}const $d={};let Zd=!0;async function Wd(e,t,i){let r;if(Gd(i)){r=await Qd(e,t,i)}else r=Hd(e,i);const n=t&&t.imagebitmap;return await async function(e,t=null){!function(e){for(const t in e||$d)return!1;return!0}(t)&&Zd||(t=null);if(t)try{return await createImageBitmap(e,t)}catch(e){console.warn(e),Zd=!1}return await createImageBitmap(e)}(r,n)}function qd(e){return function(e,t,i=0){const r=(n=t,[...n].map(e=>e.charCodeAt(0)));var n;for(let t=0;t=24&&2303741511===t.getUint32(0,Kd);if(!i)return null;return{mimeType:"image/png",width:t.getUint32(16,Kd),height:t.getUint32(20,Kd)}}(t)||function(e){const t=Yd(e),i=t.byteLength>=3&&65496===t.getUint16(0,Kd)&&255===t.getUint8(2);if(!i)return null;const{tableMarkers:r,sofMarkers:n}=function(){const e=new Set([65499,65476,65484,65501,65534]);for(let t=65504;t<65520;++t)e.add(t);const t=new Set([65472,65473,65474,65475,65477,65478,65479,65481,65482,65483,65485,65486,65487,65502]);return{tableMarkers:e,sofMarkers:t}}();let o=2;for(;o+9=10&&1195984440===t.getUint32(0,Kd);if(!i)return null;return{mimeType:"image/gif",width:t.getUint16(6,Xd),height:t.getUint16(8,Xd)}}(t)||function(e){const t=Yd(e),i=t.byteLength>=14&&16973===t.getUint16(0,Kd)&&t.getUint32(2,Xd)===t.byteLength;if(!i)return null;return{mimeType:"image/bmp",width:t.getUint32(18,Xd),height:t.getUint32(22,Xd)}}(t)||function(e){const t=new Uint8Array(e instanceof DataView?e.buffer:e),i=qd(t);if(!i)return null;return{mimeType:i.mimeType,width:0,height:0}}(t)}function Yd(e){if(e instanceof DataView)return e;if(ArrayBuffer.isView(e))return new DataView(e.buffer);if(e instanceof ArrayBuffer)return new DataView(e);throw new Error("toDataView")}const ep={dataType:null,batchType:null,id:"image",module:"images",name:"Images",version:"4.3.3",mimeTypes:["image/png","image/jpeg","image/gif","image/webp","image/avif","image/bmp","image/vnd.microsoft.icon","image/svg+xml"],extensions:["png","jpg","jpeg","gif","webp","bmp","ico","svg","avif"],parse:async function(e,t,i){const r=((t=t||{}).image||{}).type||"auto",{url:n}=i||{},o=function(e){switch(e){case"auto":case"data":return function(){if(Dd)return"imagebitmap";if(kd)return"image";if(zd)return"data";throw new Error("Install '@loaders.gl/polyfills' to parse images under Node.js")}();default:return function(e){switch(e){case"auto":return Dd||kd||zd;case"imagebitmap":return Dd;case"image":return kd;case"data":return zd;default:throw new Error(`@loaders.gl/images: image ${e} not supported in this environment`)}}(e),e}}(r);let s;switch(o){case"imagebitmap":s=await Wd(e,t,n);break;case"image":s=await Qd(e,t,n);break;case"data":s=await async function(e){const{mimeType:t}=Jd(e)||{},i=globalThis.loaders?.parseImageNode;return Tu(i),await i(e,t)}(e);break;default:Tu(!1)}return"data"===r&&(s=Nd(s)),s},tests:[e=>Boolean(Jd(new DataView(e)))],options:{image:{type:"auto",decode:!0}}},tp={};function ip(e){if(void 0===tp[e]){const t=Eu?function(e){switch(e){case"image/avif":case"image/webp":return function(e){try{const t=document.createElement("canvas");return 0===t.toDataURL(e).indexOf(`data:${e}`)}catch{return!1}}(e);default:return!0}}(e):function(e){const t=["image/png","image/jpeg","image/gif"],i=globalThis.loaders?.imageFormatsNode||t,r=globalThis.loaders?.parseImageNode;return Boolean(r)&&i.includes(e)}(e);tp[e]=t}return tp[e]}var rp=new Gu({id:"deck"});const np={attributeUpdateStart:-1,attributeManagerUpdateStart:-1,attributeUpdateMessages:[]};let op={};function sp(e){op=e}function ap(e,t,i,r){rp.level>0&&op[e]&&op[e].call(null,t,i,r)}op=(e=>({"layer.changeFlag":(t,i,r)=>{e.log(3,`${t.id} ${i}: `,r[i])()},"layer.initialize":t=>{e.log(1,`Initializing ${t}`)()},"layer.update":(t,i)=>{if(i){const i=t.getChangeFlags();e.log(2,`Updating ${t} because: ${Object.keys(i).filter(e=>i[e]).join(", ")}`)()}else e.log(4,`${t} does not need update`)()},"layer.matched":(t,i)=>{i&&e.log(4,`Matched ${t}, state transfered`)()},"layer.finalize":t=>{e.log(1,`Finalizing ${t}`)()},"compositeLayer.renderLayers":(t,i,r)=>{i?e.log(2,`Composite layer rendered new subLayers ${t}`,r)():e.log(4,`Composite layer reused subLayers ${t}`,r)()},"layerManager.setLayers":(t,i,r)=>{i&&e.log(2,`Updating ${r.length} deck layers`)()},"layerManager.activateViewport":(t,i)=>{e.log(3,"Viewport changed",i)()},"attributeManager.invalidate":(t,i,r)=>{e.log(1,r?`invalidated attributes ${r} (${i}) for ${t.id}`:`invalidated all attributes for ${t.id}`)()},"attributeManager.updateStart":e=>{np.attributeUpdateMessages.length=0,np.attributeManagerUpdateStart=Date.now()},"attributeManager.updateEnd":(t,i)=>{const r=Math.round(Date.now()-np.attributeManagerUpdateStart);e.groupCollapsed(2,`Updated attributes for ${i} instances in ${t.id} in ${r}ms`)();for(const t of np.attributeUpdateMessages)e.log(3,t)();e.groupEnd(2)()},"attribute.updateStart":e=>{np.attributeUpdateStart=Date.now()},"attribute.allocate":(e,t)=>{const i=`${e.id} allocated ${t}`;np.attributeUpdateMessages.push(i)},"attribute.updateEnd":(e,t)=>{const i=Math.round(Date.now()-np.attributeUpdateStart),r=`${e.id} updated ${t} in ${i}ms`;np.attributeUpdateMessages.push(r)},"deckRenderer.renderLayers":(t,i,r)=>{const{pass:n,redrawReason:o,stats:s}=r;for(const r of i){const{totalCount:i,visibleCount:a,compositeCount:l,pickableCount:c}=r,u=i-l-a;e.log(2,`RENDER #${t.renderCount} ${a} (of ${i} layers) to ${n} because ${o} (${u} hidden, ${l} composite ${c} pickable)`)(),s&&s.get("Redraw Layers").add(a)}}}))(rp);var lp={dataType:null,batchType:null,id:"JSON",name:"JSON",module:"",version:"",options:{},extensions:["json","geojson"],mimeTypes:["application/json","application/geo+json"],testText:function(e){const t=e[0],i=e[e.length-1];return"{"===t&&"}"===i||"["===t&&"]"===i},parseTextSync:JSON.parse};const cp=function(){const e="9.0.41",t=globalThis.deck&&globalThis.deck.VERSION;if(t&&t!==e)throw new Error(`deck.gl - multiple versions detected: ${t} vs ${e}`);return t||(rp.log(1,`deck.gl ${e}`)(),globalThis.deck={...globalThis.deck,VERSION:e,version:e,log:rp,_registerLoggers:sp},function(e){const t=dd();e=Array.isArray(e)?e:[e];for(const i of e){const e=hd(i);t.find(t=>e===t)||t.unshift(e)}}([lp,[ep,{imagebitmap:{premultiplyAlpha:"none"}}]])),e}();function up(e,t){if(!e)throw new Error(t||"shadertools: assertion failed.")}const hp={number:{type:"number",validate:(e,t)=>Number.isFinite(e)&&"object"==typeof t&&(void 0===t.max||e<=t.max)&&(void 0===t.min||e>=t.min)},array:{type:"array",validate:(e,t)=>Array.isArray(e)||ArrayBuffer.isView(e)}};function dp(e){let t=pp(e);if("object"!==t)return{value:e,...hp[t],type:t};if("object"==typeof e)return e?void 0!==e.type?{...e,...hp[e.type],type:e.type}:void 0===e.value?{type:"object",value:e}:(t=pp(e.value),{...e,...hp[t],type:t}):{type:"object",value:null};throw new Error("props")}function pp(e){return Array.isArray(e)||ArrayBuffer.isView(e)?"array":typeof e}const fp={vertex:"#ifdef MODULE_LOGDEPTH\nlogdepth_adjustPosition(gl_Position);\n#endif\n",fragment:"#ifdef MODULE_MATERIAL\ngl_FragColor = material_filterColor(gl_FragColor);\n#endif\n#ifdef MODULE_LIGHTING\ngl_FragColor = lighting_filterColor(gl_FragColor);\n#endif\n#ifdef MODULE_FOG\ngl_FragColor = fog_filterColor(gl_FragColor);\n#endif\n#ifdef MODULE_PICKING\ngl_FragColor = picking_filterHighlightColor(gl_FragColor);\ngl_FragColor = picking_filterPickingColor(gl_FragColor);\n#endif\n#ifdef MODULE_LOGDEPTH\nlogdepth_setFragDepth();\n#endif\n"},mp=/void\s+main\s*\([^)]*\)\s*\{\n?/,gp=/}\n?[^{}]*$/,_p=[],Ap="__LUMA_INJECT_DECLARATIONS__";function yp(e){const t=e.slice(0,2);switch(t){case"vs":return"vertex";case"fs":return"fragment";default:throw new Error(t)}}function vp(e,t,i,r=!1){const n="vertex"===t;for(const t in i){const r=i[t];r.sort((e,t)=>e.order-t.order),_p.length=r.length;for(let e=0,t=r.length;ee+o));break;case"vs:#main-end":n&&(e=e.replace(gp,e=>o+e));break;case"fs:#decl":n||(e=e.replace(Ap,o));break;case"fs:#main-start":n||(e=e.replace(mp,e=>e+o));break;case"fs:#main-end":n||(e=e.replace(gp,e=>o+e));break;default:e=e.replace(t,e=>e+o)}}return e=e.replace(Ap,""),r&&(e=e.replace(/\}\s*$/,e=>e+fp[t])),e}let xp=1;class bp{name;vs;fs;getModuleUniforms;dependencies;deprecations;defines;injections;uniforms={};uniformTypes={};static instantiateModules(e){return e.map(e=>{if(e instanceof bp)return e;up("string"!=typeof e,`Shader module use by name is deprecated. Import shader module '${JSON.stringify(e)}' and use it directly.`),e.name||(console.warn("shader module has no name"),e.name="shader-module-"+xp++);const t=new bp(e);return t.dependencies=bp.instantiateModules(e.dependencies||[]),t})}constructor(e){const{name:t,vs:i,fs:r,dependencies:n=[],uniformTypes:o={},uniformPropTypes:s={},getUniforms:a,deprecations:l=[],defines:c={},inject:u={}}=e;up("string"==typeof t),this.name=t,this.vs=i,this.fs=r,this.getModuleUniforms=a,this.dependencies=bp.instantiateModules(n),this.deprecations=this._parseDeprecationDefinitions(l),this.defines=c,this.injections=function(e){const t={vertex:{},fragment:{}};for(const i in e){let r=e[i];"string"==typeof r&&(r={order:0,injection:r}),t[yp(i)][i]=r}return t}(u),this.uniformTypes=o,s&&(this.uniforms=function(e){const t={};for(const[i,r]of Object.entries(e))t[i]=dp(r);return t}(s))}getModuleSource(e){let t;switch(e){case"vertex":t=this.vs||"";break;case"fragment":t=this.fs||"";break;default:up(!1)}const i=this.name.toUpperCase().replace(/[^0-9a-z]/gi,"_");return`// ----- MODULE ${this.name} ---------------\n\n#define MODULE_${i}\n${t}\n\n`}getUniforms(e,t){return this.getModuleUniforms?this.getModuleUniforms(e,t):function(e,t,i){const r={};for(const[n,o]of Object.entries(t))e&&n in e&&!o.private?(o.validate&&up(o.validate(e[n],o),`${i}: invalid ${n}`),r[n]=e[n]):r[n]=o.value;return r}(e,this.uniforms,this.name)}getDefines(){return this.defines}checkDeprecations(e,t){this.deprecations.forEach(i=>{i.regex?.test(e)&&(i.deprecated?t.deprecated(i.old,i.new)():t.removed(i.old,i.new)())})}_parseDeprecationDefinitions(e){return e.forEach(e=>{if("function"===e.type)e.regex=new RegExp(`\\b${e.old}\\(`);else e.regex=new RegExp(`${e.type} ${e.old};`)}),e}_defaultGetUniforms(e={}){const t={},i=this.uniforms;for(const r in i){const n=i[r];r in e&&!n.private?(n.validate&&up(n.validate(e[r],n),`${this.name}: invalid ${r}`),t[r]=e[r]):t[r]=n.value}return t}}function wp(e){if(e.source&&"webgpu"===e.platformInfo.type){return{...e,vs:void 0,fs:void 0}}if(!e.vs)throw new Error("no vertex shader");const t=Tp(e.platformInfo,e.vs);let i;return e.fs&&(i=Tp(e.platformInfo,e.fs)),{...e,vs:t,fs:i}}function Tp(e,t){if("string"==typeof t)return t;if("webgpu"===e.type){if(t?.wgsl)return t.wgsl;throw new Error("WebGPU does not support GLSL shaders")}if(t?.glsl)return t.glsl;throw new Error("WebGL does not support WGSL shaders")}function Ep(e){return function(e){const t={},i={};return Cp({modules:e,level:0,moduleMap:t,moduleDepth:i}),Object.keys(i).sort((e,t)=>i[t]-i[e]).map(e=>t[e])}(bp.instantiateModules(e))}function Cp(e){const{modules:t,level:i,moduleMap:r,moduleDepth:n}=e;if(i>=5)throw new Error("Possible loop in shader dependency graph");for(const e of t)r[e.name]=e,(void 0===n[e.name]||n[e.name]e.order-t.order);for(const t of e)i+=` ${t.injection}\n`}n.footer&&(i+=` ${n.footer}`),i+="}\n"}return i}function Lp(e){const t={vertex:{},fragment:{}};for(const i of e){let e,r;"string"!=typeof i?(e=i,r=e.hook):(e={},r=i),r=r.trim();const[n,o]=r.split(":"),s=r.replace(/\(.+/,""),a=Object.assign(e,{signature:o});switch(n){case"vs":t.vertex[s]=a;break;case"fs":t.fragment[s]=a;break;default:throw new Error(n)}}return t}function Fp(e,t="unnamed"){const i=/#define[^\S\r\n]*SHADER_NAME[^\S\r\n]*([A-Za-z0-9_-]+)\s*/.exec(e);return i?i[1]:t}function kp(e){let t=100;const i=e.match(/[^\s]+/g);if(i&&i.length>=2&&"#version"===i[0]){const e=parseInt(i[1],10);Number.isFinite(e)&&(t=e)}if(100!==t&&300!==t)throw new Error(`Invalid GLSL version ${t}`);return t}const Dp=`\n\n${Ap}\n`;function Op(e,t){const{source:i,stage:r,modules:n,hookFunctions:o=[],inject:s={},log:a}=t;up("string"==typeof i,"shader source must be a string");const l=i;let c="";const u=Lp(o),h={},d={},p={};for(const e in s){const t="string"==typeof s[e]?{injection:s[e],order:0}:s[e],i=/^(v|f)s:(#)?([\w-]+)$/.exec(e);if(i){const r=i[2],n=i[3];r?"decl"===n?d[e]=[t]:p[e]=[t]:h[e]=[t]}else p[e]=[t]}const f="webgpu"!==e.type?n:[];for(const e of f){a&&e.checkDeprecations(l,a);c+=e.getModuleSource(r,"wgsl");const t=e.injections[r];for(const e in t){const i=/^(v|f)s:#([\w-]+)$/.exec(e);if(i){const r="decl"===i[2]?d:p;r[e]=r[e]||[],r[e].push(t[e])}else h[e]=h[e]||[],h[e].push(t[e])}}return c+=Dp,c=vp(c,r,d),c+=Rp(u[r],h),c+=l,c=vp(c,r,p),c}function zp(e,t){const{id:i,source:r,stage:n,language:o="glsl",modules:s,defines:a={},hookFunctions:l=[],inject:c={},prologue:u=!0,log:h}=t;up("string"==typeof r,"shader source must be a string");const d="glsl"===o?function(e,t){return{name:Fp(e,t),language:"glsl",version:kp(e)}}(r).version:-1,p=e.shaderLanguageVersion,f=100===d?"#version 100":"#version 300 es",m=r.split("\n").slice(1).join("\n"),g={};s.forEach(e=>{Object.assign(g,e.getDefines())}),Object.assign(g,a);let _="";switch(o){case"wgsl":break;case"glsl":_=u?`${f}\n\n// ----- PROLOGUE -------------------------\n${function(e){const{id:t,source:i,stage:r}=e,n=t&&-1===i.indexOf("SHADER_NAME");return n?`\n#define SHADER_NAME ${t}_${r}\n\n`:""}({id:i,source:r,stage:n})}\n#define SHADER_TYPE_${n.toUpperCase()}\n${function(e){switch(e?.gpu.toLowerCase()){case"apple":return"#define APPLE_GPU\n#define LUMA_FP64_CODE_ELIMINATION_WORKAROUND 1\n#define LUMA_FP32_TAN_PRECISION_WORKAROUND 1\n#define LUMA_FP64_HIGH_BITS_OVERFLOW_WORKAROUND 1\n";case"nvidia":return"#define NVIDIA_GPU\n#define LUMA_FP64_CODE_ELIMINATION_WORKAROUND 1\n";case"intel":return"#define INTEL_GPU\n#define LUMA_FP64_CODE_ELIMINATION_WORKAROUND 1\n#define LUMA_FP32_TAN_PRECISION_WORKAROUND 1\n#define LUMA_FP64_HIGH_BITS_OVERFLOW_WORKAROUND 1\n";case"amd":return"#define AMD_GPU\n";default:return"#define DEFAULT_GPU\n#define LUMA_FP64_CODE_ELIMINATION_WORKAROUND 1\n#define LUMA_FP32_TAN_PRECISION_WORKAROUND 1\n#define LUMA_FP64_HIGH_BITS_OVERFLOW_WORKAROUND 1\n"}}(e)}\n${"fragment"===n?"precision highp float;\n":""}\n\n// ----- APPLICATION DEFINES -------------------------\n\n${function(e={}){let t="";for(const i in e){const r=e[i];(r||Number.isFinite(r))&&(t+=`#define ${i.toUpperCase()} ${e[i]}\n`)}return t}(g)}\n\n`:`${f}\n`}const A=Lp(l),y={},v={},x={};for(const e in c){const t="string"==typeof c[e]?{injection:c[e],order:0}:c[e],i=/^(v|f)s:(#)?([\w-]+)$/.exec(e);if(i){const r=i[2],n=i[3];r?"decl"===n?v[e]=[t]:x[e]=[t]:y[e]=[t]}else x[e]=[t]}for(const e of s){h&&e.checkDeprecations(m,h);_+=e.getModuleSource(n);const t=e.injections[n];for(const e in t){const i=/^(v|f)s:#([\w-]+)$/.exec(e);if(i){const r="decl"===i[2]?v:x;r[e]=r[e]||[],r[e].push(t[e])}else y[e]=y[e]||[],y[e].push(t[e])}}return _+="// ----- MAIN SHADER SOURCE -------------------------",_+=Dp,_=vp(_,n,v),_+=Rp(A[n],y),_+=m,_=vp(_,n,x),"glsl"===o&&d!==p&&(_=function(e,t){if(300!==Number(e.match(/^#version[ \t]+(\d+)/m)?.[1]||100))throw new Error("luma.gl v9 only supports GLSL 3.00 shader sources");switch(t){case"vertex":return Mp(e,Sp);case"fragment":return Mp(e,Ip);default:throw new Error(t)}}(_,n)),_.trim()}function Up(e){return function(t){const i={};for(const r of e){const e=r.getUniforms(t,i);Object.assign(i,e)}return i}}class Np{static defaultShaderAssembler;_hookFunctions=[];_defaultModules=[];static getDefaultShaderAssembler(){return Np.defaultShaderAssembler=Np.defaultShaderAssembler||new Np,Np.defaultShaderAssembler}addDefaultModule(e){this._defaultModules.find(t=>t.name===("string"==typeof e?e:e.name))||this._defaultModules.push(e)}removeDefaultModule(e){const t="string"==typeof e?e:e.name;this._defaultModules=this._defaultModules.filter(e=>e.name!==t)}addShaderHook(e,t){t&&(e=Object.assign(t,{hook:e})),this._hookFunctions.push(e)}assembleShader(e){const t=this._getModuleList(e.modules),i=this._hookFunctions,r=wp(e),n=function(e){const t=Ep(e.modules||[]);return{source:Op(e.platformInfo,{...e,source:e.source,stage:"vertex",modules:t}),getUniforms:Up(t)}}({platformInfo:e.platformInfo,...r,modules:t,hookFunctions:i});return{...n,modules:t}}assembleShaderPair(e){const t=wp(e),i=this._getModuleList(e.modules),r=this._hookFunctions,{platformInfo:n}=e,o="wgsl"===e.platformInfo.shaderLanguage?function(e){const t=Ep(e.modules||[]);return{vs:Op(e.platformInfo,{...e,source:e.vs,stage:"vertex",modules:t}),fs:Op(e.platformInfo,{...e,source:e.fs,stage:"fragment",modules:t}),getUniforms:Up(t)}}({platformInfo:n,...t,modules:i,hookFunctions:r}):function(e){const{vs:t,fs:i}=e,r=Ep(e.modules||[]);return{vs:zp(e.platformInfo,{...e,source:t,stage:"vertex",modules:r}),fs:zp(e.platformInfo,{...e,source:i,stage:"fragment",modules:r}),getUniforms:Up(r)}}({platformInfo:n,...t,modules:i,hookFunctions:r});return{...o,modules:i}}_getModuleList(e=[]){const t=new Array(this._defaultModules.length+e.length),i={};let r=0;for(let e=0,n=this._defaultModules.length;ejp.error(e.message)};get[Symbol.toStringTag](){return"Device"}static VERSION=Hp;constructor(e){this.props={...af.defaultProps,...e},this.id=this.props.id||Zp(this[Symbol.toStringTag].toLowerCase())}id;props;userData={};statsManager=Gp;_lumaData={};isTextureFormatCompressed(e){return t=e,ef.some(e=>t.startsWith(e));var t}loseDevice(){return!1}getCanvasContext(){if(!this.canvasContext)throw new Error("Device has no CanvasContext");return this.canvasContext}createTexture(e){return(e instanceof Promise||"string"==typeof e)&&(e={data:e}),this._createTexture(e)}createCommandEncoder(e={}){throw new Error("not implemented")}readPixelsToArrayWebGL(e,t){throw new Error("not implemented")}readPixelsToBufferWebGL(e,t){throw new Error("not implemented")}setParametersWebGL(e){throw new Error("not implemented")}getParametersWebGL(e){throw new Error("not implemented")}withParametersWebGL(e,t){throw new Error("not implemented")}clearWebGL(e){throw new Error("not implemented")}resetWebGL(){throw new Error("not implemented")}timestamp=0;incrementTimestamp(){return this.timestamp++}onError(e){this.props.onError(e)}_getBufferProps(e){(e instanceof ArrayBuffer||ArrayBuffer.isView(e))&&(e={data:e});const t={...e};return(e.usage||0)&Kp.INDEX&&!e.indexType&&(e.data instanceof Uint32Array?t.indexType="uint32":e.data instanceof Uint16Array?t.indexType="uint16":jp.warn("indices buffer content must be of integer type")()),t}}function lf(e,t){if(!e)throw new Error(t||"luma.gl: assertion failed.")}const cf=new Map;class uf{static defaultProps={...af.defaultProps,type:"best-available",devices:void 0};static stats=Gp;static log=jp;static registerDevices(e){for(const t of e)lf(t.type&&t.isSupported&&t.create),cf.set(t.type,t)}static getAvailableDevices(){return Array.from(cf).map(e=>e.type)}static getSupportedDevices(){return Array.from(cf).filter(e=>e.isSupported()).map(e=>e.type)}static setDefaultDeviceProps(e){Object.assign(af.defaultProps,e)}static async attachDevice(e){const t=hf(e.devices)||cf;if(e.handle instanceof WebGL2RenderingContext){const i=t.get("webgl");if(i)return await i.attach(e.handle)}if(null===e.handle){const e=t.get("unknown");if(e)return await e.attach(null)}throw new Error("Failed to attach device. Ensure `@luma.gl/webgl` and/or `@luma.gl/webgpu` modules are imported.")}static async createDevice(e={}){(e={...uf.defaultProps,...e}).gl&&(e.type="webgl");const t=hf(e.devices)||cf;let i,r;switch(e.type){case"webgpu":if(i=t.get("webgpu"),i)return await i.create(e);break;case"webgl":if(r=t.get("webgl"),r)return await r.create(e);break;case"unknown":const n=t.get("unknown");if(n)return await n.create(e);break;case"best-available":if(i=t.get("webgpu"),i?.isSupported?.())return await i.create(e);if(r=t.get("webgl"),r?.isSupported?.())return await r.create(e)}throw new Error("No matching device found. Ensure `@luma.gl/webgl` and/or `@luma.gl/webgpu` modules are imported.")}static enforceWebGL2(e=!0){const t=HTMLCanvasElement.prototype;if(!e&&t.originalGetContext)return t.getContext=t.originalGetContext,void(t.originalGetContext=void 0);t.originalGetContext=t.getContext,t.getContext=function(e,t){return"webgl"===e||"experimental-webgl"===e?this.originalGetContext("webgl2",t):this.originalGetContext(e,t)}}}function hf(e){if(!e||0===e?.length)return null;const t=new Map;for(const i of e)t.set(i.type,i);return t}const df=Pu()&&"undefined"!=typeof document,pf=()=>df&&"complete"===document.readyState,ff={canvas:null,width:800,height:600,useDevicePixels:!0,autoResize:!0,container:null,visible:!0,colorSpace:"srgb",alphaMode:"opaque"};class mf{id;props;canvas;htmlCanvas;offscreenCanvas;type;width=1;height=1;resizeObserver;_canvasSizeInfo={clientWidth:0,clientHeight:0,devicePixelRatio:1};static get isPageLoaded(){return pf()}static pageLoaded=function(){if(pf()||"undefined"==typeof window)return Promise.resolve();return new Promise(e=>{window.addEventListener("load",()=>e())})}();constructor(e){if(this.props={...ff,...e},e=this.props,!Pu())return this.id="node-canvas-context",this.type="node",this.width=this.props.width,this.height=this.props.height,void(this.canvas=null);if(e.canvas)"string"==typeof e.canvas?this.canvas=function(e){const t=document.getElementById(e);if(!t&&!pf())throw new Error(`Accessing '${e}' before page was loaded`);if(!(t instanceof HTMLCanvasElement))throw new Error("Object is not a canvas element");return t}(e.canvas):this.canvas=e.canvas;else{const t=function(e){const{width:t,height:i}=e,r=document.createElement("canvas");return r.id="lumagl-auto-created-canvas",r.width=t||1,r.height=i||1,r.style.width=Number.isFinite(t)?`${t}px`:"100%",r.style.height=Number.isFinite(i)?`${i}px`:"100%",r}(e),i=function(e){if("string"==typeof e){const t=document.getElementById(e);if(!t&&!pf())throw new Error(`Accessing '${e}' before page was loaded`);if(!t)throw new Error(`${e} is not an HTML element`);return t}if(e)return e;return document.body}(e?.container||null);i.insertBefore(t,i.firstChild),this.canvas=t,e?.visible||(this.canvas.style.visibility="hidden")}this.canvas instanceof HTMLCanvasElement?(this.id=this.canvas.id,this.type="html-canvas",this.htmlCanvas=this.canvas):(this.id="offscreen-canvas",this.type="offscreen-canvas",this.offscreenCanvas=this.canvas),this.canvas instanceof HTMLCanvasElement&&e.autoResize&&(this.resizeObserver=new ResizeObserver(e=>{for(const t of e)t.target===this.canvas&&this.update()}),this.resizeObserver.observe(this.canvas))}getDevicePixelRatio(e){if("undefined"!=typeof OffscreenCanvas&&this.canvas instanceof OffscreenCanvas)return 1;if(!(e=void 0===e?this.props.useDevicePixels:e)||e<=0)return 1;if(!0===e){return"undefined"!=typeof window&&window.devicePixelRatio||1}return e}getPixelSize(){switch(this.type){case"node":return[this.width,this.height];case"offscreen-canvas":return[this.canvas.width,this.canvas.height];case"html-canvas":const e=this.getDevicePixelRatio(),t=this.canvas;return t.parentElement?[t.clientWidth*e,t.clientHeight*e]:[this.canvas.width,this.canvas.height];default:throw new Error(this.type)}}getAspect(){const[e,t]=this.getPixelSize();return e/t}cssToDeviceRatio(){try{const[e]=this.getDrawingBufferSize(),t=this._canvasSizeInfo.clientWidth||this.htmlCanvas?.clientWidth;return t?e/t:1}catch{return 1}}cssToDevicePixels(e,t=!0){const i=this.cssToDeviceRatio(),[r,n]=this.getDrawingBufferSize();return function(e,t,i,r,n){const o=e,s=gf(o[0],t,i);let a=_f(o[1],t,r,n),l=gf(o[0]+1,t,i);const c=l===i-1?l:l-1;let u;l=_f(o[1]+1,t,r,n),n?(l=0===l?l:l+1,u=a,a=l):u=l===r-1?l:l-1;return{x:s,y:a,width:Math.max(c-s+1,1),height:Math.max(u-a+1,1)}}(e,i,r,n,t)}setDevicePixelRatio(e,t={}){if(!this.htmlCanvas)return;let i="width"in t?t.width:this.htmlCanvas.clientWidth,r="height"in t?t.height:this.htmlCanvas.clientHeight;i&&r||(jp.log(1,"Canvas clientWidth/clientHeight is 0")(),e=1,i=this.htmlCanvas.width||1,r=this.htmlCanvas.height||1);const n=this._canvasSizeInfo;if(n.clientWidth!==i||n.clientHeight!==r||n.devicePixelRatio!==e){let t=e;const n=Math.floor(i*t),o=Math.floor(r*t);this.htmlCanvas.width=n,this.htmlCanvas.height=o;const[s,a]=this.getDrawingBufferSize();s===n&&a===o||(t=Math.min(s/i,a/r),this.htmlCanvas.width=Math.floor(i*t),this.htmlCanvas.height=Math.floor(r*t),jp.warn("Device pixel ratio clamped")()),this._canvasSizeInfo.clientWidth=i,this._canvasSizeInfo.clientHeight=r,this._canvasSizeInfo.devicePixelRatio=e}}getDrawingBufferSize(){const e=this.device.gl;if(!e)throw new Error("canvas size");return[e.drawingBufferWidth,e.drawingBufferHeight]}_setAutoCreatedCanvasId(e){"lumagl-auto-created-canvas"===this.htmlCanvas?.id&&(this.htmlCanvas.id=e)}}function gf(e,t,i){return Math.min(Math.round(e*t),i-1)}function _f(e,t,i,r){return r?Math.max(0,i-1-Math.round(e*t)):Math.min(Math.round(e*t),i-1)}class Af extends qp{static defaultProps={...qp.defaultProps,data:null,dimension:"2d",format:"rgba8unorm",width:void 0,height:void 0,depth:1,mipmaps:!0,compressed:!1,usage:0,mipLevels:void 0,samples:void 0,type:void 0,sampler:{},view:void 0};static COPY_SRC=1;static COPY_DST=2;static TEXTURE_BINDING=4;static STORAGE_BINDING=8;static RENDER_ATTACHMENT=16;get[Symbol.toStringTag](){return"Texture"}dimension;format;width;height;depth;updateTimestamp;constructor(e,t,i=Af.defaultProps){super(e,t,i),this.dimension=this.props.dimension,this.format=this.props.format,this.width=this.props.width,this.height=this.props.height,this.depth=this.props.depth,this.updateTimestamp=e.incrementTimestamp()}}class yf extends qp{static defaultProps={...qp.defaultProps,format:void 0,dimension:void 0,aspect:"all",baseMipLevel:0,mipLevelCount:void 0,baseArrayLayer:0,arrayLayerCount:void 0};get[Symbol.toStringTag](){return"TextureView"}constructor(e,t){super(e,t,yf.defaultProps)}}function vf(e,t,i,r){if(r?.inlineSource){const r=function(e,t,i){let r="";for(let n=t-2;n<=t;n++){const o=e[n-1];void 0!==o&&(r+=xf(o,t,i))}return r}(t,i);return`\n${r}${e.linePos>0?`${" ".repeat(e.linePos+5)}^^^\n`:""}${e.type.toUpperCase()}: ${e.message}\n\n`}return r?.html?`
${e.type.toUpperCase()}: ${e.message}
`:`${e.type.toUpperCase()}: ${e.message}`}function xf(e,t,i){const r=i?.html?e.replaceAll("&","&").replaceAll("<","<").replaceAll(">",">").replaceAll('"',""").replaceAll("'","'"):e;return`${function(e,t){let i="";for(let r=e.length;r":"\n"}`}function bf(e,t){return{name:wf(e,t),language:"glsl",version:Tf(e)}}function wf(e,t="unnamed"){const i=/#define[\s*]SHADER_NAME[\s*]([A-Za-z0-9_-]+)[\s*]/.exec(e);return i?i[1]:t}function Tf(e){let t=100;const i=e.match(/[^\s]+/g);if(i&&i.length>=2&&"#version"===i[0]){const e=parseInt(i[1],10);Number.isFinite(e)&&(t=e)}return t}class Ef extends qp{static defaultProps={...qp.defaultProps,language:"auto",stage:void 0,source:"",sourceMap:null,entryPoint:"main",debug:"errors"};get[Symbol.toStringTag](){return"Shader"}stage;source;compilationStatus="pending";constructor(e,t){super(e,{id:Cf(t),...t},Ef.defaultProps),this.stage=this.props.stage,this.source=this.props.source}getCompilationInfoSync(){return null}getTranslatedSource(){return null}async debugShader(e=this.props.debug){switch(e){case"never":return;case"errors":if("success"===this.compilationStatus)return}const t=await this.getCompilationInfo();"warnings"===this.props.debug&&0===t?.length||this._displayShaderLog(t)}_displayShaderLog(e){if("undefined"==typeof document||!document?.createElement)return;const t=bf(this.source).name,i=`${this.stage} ${t}`;let r=function(e,t,i){let r="";const n=t.split(/\r?\n/),o=e.slice().sort((e,t)=>e.lineNum-t.lineNum);switch(i?.showSourceCode||"no"){case"all":let t=0;for(let e=1;e<=n.length;e++)for(r+=xf(n[e-1],e,i);o.length>t&&o[t].lineNum===e;){const e=o[t++];r+=vf(e,n,e.lineNum,{...i,inlineSource:!1})}return r;case"issues":case"no":for(const t of e)r+=vf(t,n,t.lineNum,{inlineSource:"no"!==i?.showSourceCode});return r}}(e,this.source,{showSourceCode:"all",html:!0});const n=this.getTranslatedSource();n&&(r+=`

Translated Source



${n}
`);const o=document.createElement("Button");o.innerHTML=`\n

Shader Compilation Error in ${i}



\n
\n${r}\n
`,o.style.top="10px",o.style.left="10px",o.style.position="absolute",o.style.zIndex="9999",o.style.width="100%",o.style.textAlign="left",document.body.appendChild(o);const s=document.getElementsByClassName("luma-compiler-log-error");s[0]?.scrollIntoView&&s[0].scrollIntoView(),o.onclick=()=>{const e=`data:text/plain,${encodeURIComponent(this.source)}`;navigator.clipboard.writeText(e)}}}function Cf(e){return bf(e.source).name||e.id||Zp(`unnamed ${e.stage}-shader`)}class Bf extends qp{static defaultProps={...qp.defaultProps,type:"color-sampler",addressModeU:"clamp-to-edge",addressModeV:"clamp-to-edge",addressModeW:"clamp-to-edge",magFilter:"nearest",minFilter:"nearest",mipmapFilter:"nearest",lodMinClamp:0,lodMaxClamp:32,compare:"less-equal",maxAnisotropy:1};get[Symbol.toStringTag](){return"Sampler"}constructor(e,t){super(e,t,Bf.defaultProps)}}class Sf extends qp{static defaultProps={...qp.defaultProps,width:1,height:1,colorAttachments:[],depthStencilAttachment:null};get[Symbol.toStringTag](){return"Framebuffer"}width;height;colorAttachments=[];depthStencilAttachment=null;constructor(e,t={}){super(e,t,Sf.defaultProps),this.width=this.props.width,this.height=this.props.height}resize(e){let t=!e;if(e){const[i,r]=Array.isArray(e)?e:[e.width,e.height];t=t||r!==this.height||i!==this.width,this.width=i,this.height=r}t&&(jp.log(2,`Resizing framebuffer ${this.id} to ${this.width}x${this.height}`)(),this.resizeAttachments(this.width,this.height))}autoCreateAttachmentTextures(){if(0===this.props.colorAttachments.length&&!this.props.depthStencilAttachment)throw new Error("Framebuffer has noattachments");this.colorAttachments=this.props.colorAttachments.map(e=>{if("string"==typeof e){const t=this.createColorTexture(e);return this.attachResource(t),t.view}return e instanceof Af?e.view:e});const e=this.props.depthStencilAttachment;if(e)if("string"==typeof e){const t=this.createDepthStencilTexture(e);this.attachResource(t),this.depthStencilAttachment=t.view}else this.depthStencilAttachment=e instanceof Af?e.view:e}createColorTexture(e){return this.device.createTexture({id:"color-attachment",usage:Af.RENDER_ATTACHMENT,format:e,width:this.width,height:this.height})}createDepthStencilTexture(e){return this.device.createTexture({id:"depth-stencil-attachment",usage:Af.RENDER_ATTACHMENT,format:e,width:this.width,height:this.height})}resizeAttachments(e,t){for(let i=0;i":["f32",2],"vec3":["f32",3],"vec4":["f32",4],f16:["f16",1],"vec2":["f16",2],"vec3":["f16",3],"vec4":["f16",4],i32:["i32",1],"vec2":["i32",2],"vec3":["i32",3],"vec4":["i32",4],u32:["u32",1],"vec2":["u32",2],"vec3":["u32",3],"vec4":["u32",4]},kf={f32:4,f16:2,i32:4,u32:4};function Df(e){let t;e.endsWith("-webgl")&&(e.replace("-webgl",""),t=!0);const[i,r]=e.split("x"),n=i,o=r?parseInt(r):1,s=Xp(n),a={type:n,components:o,byteLength:s.byteLength*o,integer:s.integer,signed:s.signed,normalized:s.normalized};return t&&(a.webglOnly=!0),a}function Of(e,t){const i={};for(const r of e.attributes)i[r.name]=zf(e,t,r.name);return i}function zf(e,t,i){const r=function(e,t){const i=e.attributes.find(e=>e.name===t);i||jp.warn(`shader layout attribute "${t}" not present in shader`);return i||null}(e,i),n=function(e,t){Uf(e);let i=function(e,t){for(const i of e)if(i.format&&i.name===t)return{attributeName:i.name,bufferName:t,stepMode:i.stepMode,vertexFormat:i.format,byteOffset:0,byteStride:i.byteStride||0};return null}(e,t);if(i)return i;if(i=function(e,t){for(const i of e){let e=i.byteStride;if("number"!=typeof i.byteStride)for(const t of i.attributes||[]){e+=Df(t.format).byteLength}const r=i.attributes?.find(e=>e.attribute===t);if(r)return{attributeName:r.attribute,bufferName:i.name,stepMode:i.stepMode,vertexFormat:r.format,byteOffset:r.byteOffset,byteStride:e}}return null}(e,t),i)return i;return jp.warn(`layout for attribute "${t}" not present in buffer layout`),null}(t,i);if(!r)return null;const o=function(e){const[t,i]=Ff[e],r="i32"===t||"u32"===t,n="u32"!==t,o=kf[t]*i,s=function(e,t){let i;switch(e){case"f32":i="float32";break;case"i32":i="sint32";break;case"u32":i="uint32";break;case"f16":return t<=2?"float16x2":"float16x4"}return 1===t?i:`${i}x${t}`}(t,i);return{dataType:t,components:i,defaultVertexFormat:s,byteLength:o,integer:r,signed:n}}(r.type),s=n?.vertexFormat||o.defaultVertexFormat,a=Df(s);return{attributeName:n?.attributeName||r.name,bufferName:n?.bufferName||r.name,location:r.location,shaderType:r.type,shaderDataType:o.dataType,shaderComponents:o.components,vertexFormat:s,bufferDataType:a.type,bufferComponents:a.components,normalized:a.normalized,integer:o.integer,stepMode:n?.stepMode||r.stepMode,byteOffset:n?.byteOffset||0,byteStride:n?.byteStride||0}}function Uf(e){for(const t of e)(t.attributes&&t.format||!t.attributes&&!t.format)&&jp.warn(`BufferLayout ${name} must have either 'attributes' or 'format' field`)}class Nf extends qp{static defaultProps={...qp.defaultProps,renderPipeline:null};get[Symbol.toStringTag](){return"VertexArray"}maxVertexAttributes;attributeInfos;indexBuffer=null;attributes;constructor(e,t){super(e,t,Nf.defaultProps),this.maxVertexAttributes=e.limits.maxVertexAttributes,this.attributes=new Array(this.maxVertexAttributes).fill(null),this.attributeInfos=function(e,t,i=16){const r=Of(e,t),n=new Array(i).fill(null);for(const e of Object.values(r))n[e.location]=e;return n}(t.renderPipeline.shaderLayout,t.renderPipeline.bufferLayout,this.maxVertexAttributes)}setConstantWebGL(e,t){throw new Error("constant attributes not supported")}}class Vf extends qp{static defaultProps={...qp.defaultProps,layout:void 0,buffers:{}};get[Symbol.toStringTag](){return"TransformFeedback"}constructor(e,t){super(e,t,Vf.defaultProps)}}class jf extends qp{static defaultProps={...qp.defaultProps,type:void 0,count:void 0};get[Symbol.toStringTag](){return"QuerySet"}constructor(e,t){super(e,t,jf.defaultProps)}}const Gf={f32:{type:"f32",components:1},i32:{type:"i32",components:1},u32:{type:"u32",components:1},"vec2":{type:"f32",components:2},"vec3":{type:"f32",components:3},"vec4":{type:"f32",components:4},"vec2":{type:"i32",components:2},"vec3":{type:"i32",components:3},"vec4":{type:"i32",components:4},"vec2":{type:"u32",components:2},"vec3":{type:"u32",components:3},"vec4":{type:"u32",components:4},"mat2x2":{type:"f32",components:4},"mat2x3":{type:"f32",components:6},"mat2x4":{type:"f32",components:8},"mat3x2":{type:"f32",components:6},"mat3x3":{type:"f32",components:9},"mat3x4":{type:"f32",components:12},"mat4x2":{type:"f32",components:8},"mat4x3":{type:"f32",components:12},"mat4x4":{type:"f32",components:16}};function Hf(e){const t=Gf[e];return lf(e),t}function Qf(e,t){switch(t){case 1:return e;case 2:return e+e%2;default:return e+(4-e%4)%4}}let $f;function Zf(e){return(!$f||$f.byteLength"uniform"===t.type&&t.name===e?.name);if(!t)throw new Error(e?.name);const i=t;for(const e of i.uniforms||[])this.bindingLayout[e.name]=e}}setUniforms(e){for(const[t,i]of Object.entries(e))this._setUniform(t,i),this.needsRedraw||this.setNeedsRedraw(`${this.name}.${t}=${i}`)}setNeedsRedraw(e){this.needsRedraw=this.needsRedraw||e}getAllUniforms(){return this.modifiedUniforms={},this.needsRedraw=!1,this.uniforms||{}}_setUniform(e,t){(function(e,t){if(e!==t)return!1;const i=Qp(e);if(!i)return!1;const r=Qp(t);if(r&&i.length===r.length)for(let e=0;e4)throw new Error(`size ${t}`);const r=t;let n=Xf(e);if("uint8"===n&&i&&1===r)return"unorm8-webgl";if("uint8"===n&&i&&3===r)return"unorm8x3-webgl";if("uint8"===n||"sint8"===n){if(1===r||3===r)throw new Error(`size: ${t}`);return i&&(n=n.replace("int","norm")),`${n}x${r}`}if("uint16"===n||"sint16"===n){if(1===r||3===r)throw new Error(`size: ${t}`);return i&&(n=n.replace("int","norm")),`${n}x${r}`}return 1===r?n:`${n}x${r}`}function em(e){const t={bindings:{},uniforms:{}};return Object.keys(e).forEach(i=>{const r=e[i];var n;null!==Qp(n=r)||"number"==typeof n||"boolean"==typeof n?t.uniforms[i]=r:t.bindings[i]=r}),t}async function tm(e,t){return await new Promise((i,r)=>{try{const n=new Image;n.onload=()=>i(n),n.onerror=()=>r(new Error(`Could not load image ${e}.`)),n.crossOrigin=t?.crossOrigin||"anonymous",n.src=e.startsWith("http")?e:""+e}catch(e){r(e)}})}async function im(e,t){const i=document.getElementsByTagName("head")[0];if(!i)throw new Error("loadScript");const r=document.createElement("script");return r.setAttribute("type","text/javascript"),r.setAttribute("src",e),t&&(r.id=t),new Promise((t,n)=>{r.onload=t,r.onerror=t=>n(new Error(`Unable to load script '${e}': ${t}`)),i.appendChild(r)})}function rm(e,t,i){if(e===t)return!0;if(!i||!e||!t)return!1;if(Array.isArray(e)){if(!Array.isArray(t)||e.length!==t.length)return!1;for(let r=0;r`}}class lm extends nm{constructor(e,t,i){super(e,i),this.format=t}get isPointer(){return!0}getTypeName(){return`&${this.format.getTypeName()}`}}class cm extends nm{constructor(e,t,i,r){super(e,i),this.format=t,this.access=r}get isTemplate(){return!0}getTypeName(){let e=this.name;if(null!==this.format){if("vec2"===e||"vec3"===e||"vec4"===e||"mat2x2"===e||"mat2x3"===e||"mat2x4"===e||"mat3x2"===e||"mat3x3"===e||"mat3x4"===e||"mat4x2"===e||"mat4x3"===e||"mat4x4"===e){if("f32"===this.format.name)return e+="f",e;if("i32"===this.format.name)return e+="i",e;if("u32"===this.format.name)return e+="u",e;if("bool"===this.format.name)return e+="b",e;if("f16"===this.format.name)return e+="h",e}e+=`<${this.format.name}>`}else if("vec2"===e||"vec3"===e||"vec4"===e)return e;return e}}var um;(e=>{e[e.Uniform=0]="Uniform",e[e.Storage=1]="Storage",e[e.Texture=2]="Texture",e[e.Sampler=3]="Sampler",e[e.StorageTexture=4]="StorageTexture"})(um||(um={}));class hm{constructor(e,t,i,r,n,o,s){this.name=e,this.type=t,this.group=i,this.binding=r,this.attributes=n,this.resourceType=o,this.access=s}get isArray(){return this.type.isArray}get isStruct(){return this.type.isStruct}get isTemplate(){return this.type.isTemplate}get size(){return this.type.size}get align(){return this.type.isStruct?this.type.align:0}get members(){return this.type.isStruct?this.type.members:null}get format(){return this.type.isArray||this.type.isTemplate?this.type.format:null}get count(){return this.type.isArray?this.type.count:0}get stride(){return this.type.isArray?this.type.stride:this.size}}class dm{constructor(e,t){this.name=e,this.type=t}}class pm{constructor(e,t,i,r){this.name=e,this.type=t,this.locationType=i,this.location=r,this.interpolation=null}}class fm{constructor(e,t,i,r){this.name=e,this.type=t,this.locationType=i,this.location=r}}class mm{constructor(e,t,i,r){this.name=e,this.type=t,this.attributes=i,this.id=r}}class gm{constructor(e,t,i){this.name=e,this.type=t,this.attributes=i}}class _m{constructor(e,t=null,i){this.stage=null,this.inputs=[],this.outputs=[],this.arguments=[],this.returnType=null,this.resources=[],this.overrides=[],this.startLine=-1,this.endLine=-1,this.inUse=!1,this.calls=new Set,this.name=e,this.stage=t,this.attributes=i}}class Am{constructor(){this.vertex=[],this.fragment=[],this.compute=[]}}function ym(e){var t=(32768&e)>>15,i=(31744&e)>>10,r=1023&e;return 0==i?(t?-1:1)*Math.pow(2,-14)*(r/Math.pow(2,10)):31==i?r?NaN:1/0*(t?-1:1):(t?-1:1)*Math.pow(2,i-15)*(1+r/Math.pow(2,10))}const vm=new Float32Array(1),xm=new Int32Array(vm.buffer),bm=new Uint16Array(1);function wm(e){vm[0]=e;const t=xm[0],i=t>>31&1;let r=t>>23&255,n=8388607&t;if(255===r)return bm[0]=i<<15|31744|(0!==n?512:0),bm[0];if(0===r){if(0===n)return bm[0]=i<<15,bm[0];n|=8388608;let e=113;for(;!(8388608&n);)n<<=1,e--;return r=127-e,n&=8388607,r>0?(n=(n>>126-r)+(n>>127-r&1),bm[0]=i<<15|r<<10|n>>13,bm[0]):(bm[0]=i<<15,bm[0])}return r=r-127+15,r>=31?(bm[0]=i<<15|31744,bm[0]):r<=0?r<-10?(bm[0]=i<<15,bm[0]):(n=(8388608|n)>>1-r,bm[0]=i<<15|n>>13,bm[0]):(n>>=13,bm[0]=i<<15|r<<10|n,bm[0])}const Tm=new Uint32Array(1),Em=new Float32Array(Tm.buffer,0,1);function Cm(e){const t=112+(e>>6&31)<<23|(63&e)<<17;return Tm[0]=t,Em[0]}function Bm(e,t,i,r){const n=[0,0,0,0];for(let o=0;o{e.increment="++",e.decrement="--"})(Hm||(Hm={})),(e=>{e.parse=function(t){const i=t;if("parse"==i)throw new Error("Invalid value for IncrementOperator");return e[i]}})(Hm||(Hm={}));class Wm extends Fm{constructor(e,t){super(),this.operator=e,this.variable=t}get astNodeType(){return"increment"}search(e){this.variable.search(e)}}(e=>{e.assign="=",e.addAssign="+=",e.subtractAssin="-=",e.multiplyAssign="*=",e.divideAssign="/=",e.moduloAssign="%=",e.andAssign="&=",e.orAssign="|=",e.xorAssign="^=",e.shiftLeftAssign="<<=",e.shiftRightAssign=">>="})(Qm||(Qm={})),(Qm||(Qm={})).parse=function(e){const t=e;if("parse"==t)throw new Error("Invalid value for AssignOperator");return t};class qm extends Fm{constructor(e,t,i){super(),this.operator=e,this.variable=t,this.value=i}get astNodeType(){return"assign"}search(e){this.variable.search(e),this.value.search(e)}}class Km extends Fm{constructor(e,t){super(),this.name=e,this.args=t}get astNodeType(){return"call"}isBuiltin(){return Lm.has(this.name)}search(e){for(const t of this.args)t.search(e);e(this)}}class Xm extends Fm{constructor(e,t){super(),this.body=e,this.continuing=t}get astNodeType(){return"loop"}search(e){var t;this.searchBlock(this.body,e),null===(t=this.continuing)||void 0===t||t.search(e)}}class Jm extends Fm{constructor(e,t){super(),this.condition=e,this.cases=t}get astNodeType(){return"switch"}search(e){e(this);for(const t of this.cases)t.search(e)}}class Ym extends Fm{constructor(e,t,i,r){super(),this.condition=e,this.body=t,this.elseif=i,this.else=r}get astNodeType(){return"if"}search(e){this.condition.search(e),this.searchBlock(this.body,e),this.searchBlock(this.elseif,e),this.searchBlock(this.else,e)}}class eg extends Fm{constructor(e){super(),this.value=e}get astNodeType(){return"return"}search(e){var t;null===(t=this.value)||void 0===t||t.search(e)}}class tg extends Fm{constructor(e){super(),this.name=e}get astNodeType(){return"enable"}}class ig extends Fm{constructor(e){super(),this.extensions=e}get astNodeType(){return"requires"}}class rg extends Fm{constructor(e,t){super(),this.severity=e,this.rule=t}get astNodeType(){return"diagnostic"}}class ng extends Fm{constructor(e,t){super(),this.name=e,this.type=t}get astNodeType(){return"alias"}}class og extends Fm{constructor(){super()}get astNodeType(){return"discard"}}class sg extends Fm{constructor(){super(),this.condition=null,this.loopId=-1}get astNodeType(){return"break"}}class ag extends Fm{constructor(){super(),this.loopId=-1}get astNodeType(){return"continue"}}class lg extends Fm{constructor(e){super(),this.attributes=null,this.name=e}get astNodeType(){return"type"}get isStruct(){return!1}get isArray(){return!1}static maxFormatType(e){let t=e[0];if("f32"===t.name)return t;for(let i=1;i`}else if("vec2"===e||"vec3"===e||"vec4"===e)return e;return e}}hg.vec2f=new hg("vec2",lg.f32,null),hg.vec3f=new hg("vec3",lg.f32,null),hg.vec4f=new hg("vec4",lg.f32,null),hg.vec2i=new hg("vec2",lg.i32,null),hg.vec3i=new hg("vec3",lg.i32,null),hg.vec4i=new hg("vec4",lg.i32,null),hg.vec2u=new hg("vec2",lg.u32,null),hg.vec3u=new hg("vec3",lg.u32,null),hg.vec4u=new hg("vec4",lg.u32,null),hg.vec2h=new hg("vec2",lg.f16,null),hg.vec3h=new hg("vec3",lg.f16,null),hg.vec4h=new hg("vec4",lg.f16,null),hg.vec2b=new hg("vec2",lg.bool,null),hg.vec3b=new hg("vec3",lg.bool,null),hg.vec4b=new hg("vec4",lg.bool,null),hg.mat2x2f=new hg("mat2x2",lg.f32,null),hg.mat2x3f=new hg("mat2x3",lg.f32,null),hg.mat2x4f=new hg("mat2x4",lg.f32,null),hg.mat3x2f=new hg("mat3x2",lg.f32,null),hg.mat3x3f=new hg("mat3x3",lg.f32,null),hg.mat3x4f=new hg("mat3x4",lg.f32,null),hg.mat4x2f=new hg("mat4x2",lg.f32,null),hg.mat4x3f=new hg("mat4x3",lg.f32,null),hg.mat4x4f=new hg("mat4x4",lg.f32,null),hg.mat2x2h=new hg("mat2x2",lg.f16,null),hg.mat2x3h=new hg("mat2x3",lg.f16,null),hg.mat2x4h=new hg("mat2x4",lg.f16,null),hg.mat3x2h=new hg("mat3x2",lg.f16,null),hg.mat3x3h=new hg("mat3x3",lg.f16,null),hg.mat3x4h=new hg("mat3x4",lg.f16,null),hg.mat4x2h=new hg("mat4x2",lg.f16,null),hg.mat4x3h=new hg("mat4x3",lg.f16,null),hg.mat4x4h=new hg("mat4x4",lg.f16,null),hg.mat2x2i=new hg("mat2x2",lg.i32,null),hg.mat2x3i=new hg("mat2x3",lg.i32,null),hg.mat2x4i=new hg("mat2x4",lg.i32,null),hg.mat3x2i=new hg("mat3x2",lg.i32,null),hg.mat3x3i=new hg("mat3x3",lg.i32,null),hg.mat3x4i=new hg("mat3x4",lg.i32,null),hg.mat4x2i=new hg("mat4x2",lg.i32,null),hg.mat4x3i=new hg("mat4x3",lg.i32,null),hg.mat4x4i=new hg("mat4x4",lg.i32,null),hg.mat2x2u=new hg("mat2x2",lg.u32,null),hg.mat2x3u=new hg("mat2x3",lg.u32,null),hg.mat2x4u=new hg("mat2x4",lg.u32,null),hg.mat3x2u=new hg("mat3x2",lg.u32,null),hg.mat3x3u=new hg("mat3x3",lg.u32,null),hg.mat3x4u=new hg("mat3x4",lg.u32,null),hg.mat4x2u=new hg("mat4x2",lg.u32,null),hg.mat4x3u=new hg("mat4x3",lg.u32,null),hg.mat4x4u=new hg("mat4x4",lg.u32,null);class dg extends lg{constructor(e,t,i,r){super(e),this.storage=t,this.type=i,this.access=r}get astNodeType(){return"pointer"}}class pg extends lg{constructor(e,t,i,r){super(e),this.attributes=t,this.format=i,this.count=r}get astNodeType(){return"array"}get isArray(){return!0}}class fg extends lg{constructor(e,t,i){super(e),this.format=t,this.access=i}get astNodeType(){return"sampler"}}class mg extends Mm{constructor(){super(),this.postfix=null}}class gg extends mg{constructor(e){super(),this.value=e}get astNodeType(){return"stringExpr"}toString(){return this.value}constEvaluateString(){return this.value}}class _g extends mg{constructor(e,t){super(),this.type=e,this.args=t}get astNodeType(){return"createExpr"}search(e){if(e(this),this.args)for(const t of this.args)t.search(e)}constEvaluate(e,t){return t&&(t[0]=this.type),e.evalExpression(this,e.context)}}class Ag extends mg{constructor(e,t){super(),this.cachedReturnValue=null,this.name=e,this.args=t}get astNodeType(){return"callExpr"}setCachedReturnValue(e){this.cachedReturnValue=e}get isBuiltin(){return Lm.has(this.name)}constEvaluate(e,t){return e.evalExpression(this,e.context)}search(e){for(const t of this.args)t.search(e);e(this)}}class yg extends mg{constructor(e){super(),this.name=e}get astNodeType(){return"varExpr"}search(e){e(this),this.postfix&&this.postfix.search(e)}constEvaluate(e,t){return e.evalExpression(this,e.context)}}class vg extends mg{constructor(e,t){super(),this.name=e,this.initializer=t}get astNodeType(){return"constExpr"}constEvaluate(e,t){if(this.initializer){const t=e.evalExpression(this.initializer,e.context);return null!==t&&this.postfix?t.getSubData(e,this.postfix,e.context):t}return null}search(e){this.initializer.search(e)}}class xg extends mg{constructor(e,t){super(),this.value=e,this.type=t}get astNodeType(){return"literalExpr"}constEvaluate(e,t){return void 0!==t&&(t[0]=this.type),this.value}get isScalar(){return this.value instanceof zg}get isVector(){return this.value instanceof Ng||this.value instanceof Vg}get scalarValue(){return this.value instanceof zg?this.value.value:(console.error("Value is not scalar."),0)}get vectorValue(){return this.value instanceof Ng||this.value instanceof Vg?this.value.data:(console.error("Value is not a vector or matrix."),new Float32Array(0))}}class bg extends mg{constructor(e,t){super(),this.type=e,this.value=t}get astNodeType(){return"bitcastExpr"}search(e){this.value.search(e)}}class wg extends mg{constructor(e){super(),this.index=e}search(e){this.index.search(e)}}class Tg extends mg{constructor(){super()}}class Eg extends Tg{constructor(e,t){super(),this.operator=e,this.right=t}get astNodeType(){return"unaryOp"}constEvaluate(e,t){return e.evalExpression(this,e.context)}search(e){this.right.search(e)}}class Cg extends Tg{constructor(e,t,i){super(),this.operator=e,this.left=t,this.right=i}get astNodeType(){return"binaryOp"}_getPromotedType(e,t){return e.name===t.name?e:"f32"===e.name||"f32"===t.name?lg.f32:"u32"===e.name||"u32"===t.name?lg.u32:lg.i32}constEvaluate(e,t){return e.evalExpression(this,e.context)}search(e){this.left.search(e),this.right.search(e)}}class Bg extends Mm{constructor(e){super(),this.body=e}search(e){e(this),this.searchBlock(this.body,e)}}class Sg extends mg{constructor(){super()}get astNodeType(){return"default"}}class Ig extends Bg{constructor(e,t){super(t),this.selectors=e}get astNodeType(){return"case"}search(e){this.searchBlock(this.body,e)}}class Mg extends Bg{constructor(e){super(e)}get astNodeType(){return"default"}search(e){this.searchBlock(this.body,e)}}class Pg extends Mm{constructor(e,t,i){super(),this.name=e,this.type=t,this.attributes=i}get astNodeType(){return"argument"}}class Rg extends Mm{constructor(e,t){super(),this.condition=e,this.body=t}get astNodeType(){return"elseif"}search(e){this.condition.search(e),this.searchBlock(this.body,e)}}class Lg extends Mm{constructor(e,t,i){super(),this.name=e,this.type=t,this.attributes=i}get astNodeType(){return"member"}}class Fg extends Mm{constructor(e,t){super(),this.name=e,this.value=t}get astNodeType(){return"attribute"}}class kg{constructor(e,t){this.parent=null,this.typeInfo=e,this.parent=t,this.id=kg._id++}clone(){throw`Clone: Not implemented for ${this.constructor.name}`}setDataValue(e,t,i,r){console.error(`SetDataValue: Not implemented for ${this.constructor.name}`)}getSubData(e,t,i){return console.error(`GetDataValue: Not implemented for ${this.constructor.name}`),null}toString(){return`<${this.typeInfo.getTypeName()}>`}}kg._id=0;class Dg extends kg{constructor(){super(new nm("void",null),null)}toString(){return"void"}}Dg.void=new Dg;class Og extends kg{constructor(e){super(new lm("pointer",e.typeInfo,null),null),this.reference=e}clone(){return this}setDataValue(e,t,i,r){this.reference.setDataValue(e,t,i,r)}getSubData(e,t,i){return t?this.reference.getSubData(e,t,i):this}toString(){return`&${this.reference.toString()}`}}class zg extends kg{constructor(e,t,i=null){super(t,i),e instanceof Int32Array||e instanceof Uint32Array||e instanceof Float32Array?this.data=e:"x32"===this.typeInfo.name?e-Math.floor(e)!==0?this.data=new Float32Array([e]):this.data=e>=0?new Uint32Array([e]):new Int32Array([e]):"i32"===this.typeInfo.name||"bool"===this.typeInfo.name?this.data=new Int32Array([e]):"u32"===this.typeInfo.name?this.data=new Uint32Array([e]):"f32"===this.typeInfo.name||"f16"===this.typeInfo.name?this.data=new Float32Array([e]):console.error("ScalarData2: Invalid type",t)}clone(){if(this.data instanceof Float32Array)return new zg(new Float32Array(this.data),this.typeInfo,null);if(this.data instanceof Int32Array)return new zg(new Int32Array(this.data),this.typeInfo,null);if(this.data instanceof Uint32Array)return new zg(new Uint32Array(this.data),this.typeInfo,null);throw"ScalarData: Invalid data type"}get value(){return this.data[0]}set value(e){this.data[0]=e}setDataValue(e,t,i,r){if(i)return void console.error("SetDataValue: Scalar data does not support postfix",i);if(!(t instanceof zg))return void console.error("SetDataValue: Invalid value",t);let n=t.data[0];"i32"===this.typeInfo.name||"u32"===this.typeInfo.name?n=Math.floor(n):"bool"===this.typeInfo.name&&(n=n?1:0),this.data[0]=n}getSubData(e,t,i){return t?(console.error("getSubData: Scalar data does not support postfix",t),null):this}toString(){return`${this.value}`}}function Ug(e,t,i){const r=t.length;return 2===r?"f32"===i?new Ng(new Float32Array(t),e.getTypeInfo("vec2f")):"i32"===i||"bool"===i?new Ng(new Int32Array(t),e.getTypeInfo("vec2i")):"u32"===i?new Ng(new Uint32Array(t),e.getTypeInfo("vec2u")):"f16"===i?new Ng(new Float32Array(t),e.getTypeInfo("vec2h")):(console.error(`getSubData: Unknown format ${i}`),null):3===r?"f32"===i?new Ng(new Float32Array(t),e.getTypeInfo("vec3f")):"i32"===i||"bool"===i?new Ng(new Int32Array(t),e.getTypeInfo("vec3i")):"u32"===i?new Ng(new Uint32Array(t),e.getTypeInfo("vec3u")):"f16"===i?new Ng(new Float32Array(t),e.getTypeInfo("vec3h")):(console.error(`getSubData: Unknown format ${i}`),null):4===r?"f32"===i?new Ng(new Float32Array(t),e.getTypeInfo("vec4f")):"i32"===i||"bool"===i?new Ng(new Int32Array(t),e.getTypeInfo("vec4i")):"u32"===i?new Ng(new Uint32Array(t),e.getTypeInfo("vec4u")):"f16"===i?new Ng(new Float32Array(t),e.getTypeInfo("vec4h")):(console.error(`getSubData: Unknown format ${i}`),null):(console.error(`getSubData: Invalid vector size ${t.length}`),null)}class Ng extends kg{constructor(e,t,i=null){if(super(t,i),e instanceof Float32Array||e instanceof Uint32Array||e instanceof Int32Array)this.data=e;else{const t=this.typeInfo.name;"vec2f"===t||"vec3f"===t||"vec4f"===t?this.data=new Float32Array(e):"vec2i"===t||"vec3i"===t||"vec4i"===t?this.data=new Int32Array(e):"vec2u"===t||"vec3u"===t||"vec4u"===t?this.data=new Uint32Array(e):"vec2h"===t||"vec3h"===t||"vec4h"===t?this.data=new Float32Array(e):"vec2b"===t||"vec3b"===t||"vec4b"===t?this.data=new Int32Array(e):"vec2"===t||"vec3"===t||"vec4"===t?this.data=new Float32Array(e):console.error(`VectorData: Invalid type ${t}`)}}clone(){if(this.data instanceof Float32Array)return new Ng(new Float32Array(this.data),this.typeInfo,null);if(this.data instanceof Int32Array)return new Ng(new Int32Array(this.data),this.typeInfo,null);if(this.data instanceof Uint32Array)return new Ng(new Uint32Array(this.data),this.typeInfo,null);throw"VectorData: Invalid data type"}setDataValue(e,t,i,r){i instanceof gg?console.error("TODO: Set vector postfix"):t instanceof Ng?this.data=t.data:console.error("SetDataValue: Invalid value",t)}getSubData(e,t,i){if(null===t)return this;let r=e.getTypeInfo("f32");if(this.typeInfo instanceof cm)r=this.typeInfo.format||r;else{const t=this.typeInfo.name;"vec2f"===t||"vec3f"===t||"vec4f"===t?r=e.getTypeInfo("f32"):"vec2i"===t||"vec3i"===t||"vec4i"===t?r=e.getTypeInfo("i32"):"vec2b"===t||"vec3b"===t||"vec4b"===t?r=e.getTypeInfo("bool"):"vec2u"===t||"vec3u"===t||"vec4u"===t?r=e.getTypeInfo("u32"):"vec2h"===t||"vec3h"===t||"vec4h"===t?r=e.getTypeInfo("f16"):console.error(`GetSubData: Unknown type ${t}`)}let n=this;for(;null!==t&&null!==n;){if(t instanceof wg){const o=t.index;let s=-1;if(o instanceof xg){if(!(o.value instanceof zg))return console.error(`GetSubData: Invalid array index ${o.value}`),null;s=o.value.value}else{const t=e.evalExpression(o,i);if(!(t instanceof zg))return console.error("GetSubData: Unknown index type",o),null;s=t.value}if(s<0||s>=n.data.length)return console.error("GetSubData: Index out of range",s),null;if(n.data instanceof Float32Array){const e=new Float32Array(n.data.buffer,n.data.byteOffset+4*s,1);return new zg(e,r)}if(n.data instanceof Int32Array){const e=new Int32Array(n.data.buffer,n.data.byteOffset+4*s,1);return new zg(e,r)}if(n.data instanceof Uint32Array){const e=new Uint32Array(n.data.buffer,n.data.byteOffset+4*s,1);return new zg(e,r)}throw"GetSubData: Invalid data type"}if(!(t instanceof gg))return console.error("GetSubData: Unknown postfix",t),null;{const i=t.value.toLowerCase();if(1===i.length){let e=0;if("x"===i||"r"===i)e=0;else if("y"===i||"g"===i)e=1;else if("z"===i||"b"===i)e=2;else{if("w"!==i&&"a"!==i)return console.error(`GetSubData: Unknown member ${i}`),null;e=3}if(this.data instanceof Float32Array){let t=new Float32Array(this.data.buffer,this.data.byteOffset+4*e,1);return new zg(t,r,this)}if(this.data instanceof Int32Array){let t=new Int32Array(this.data.buffer,this.data.byteOffset+4*e,1);return new zg(t,r,this)}if(this.data instanceof Uint32Array){let t=new Uint32Array(this.data.buffer,this.data.byteOffset+4*e,1);return new zg(t,r,this)}}const o=[];for(const e of i)"x"===e||"r"===e?o.push(this.data[0]):"y"===e||"g"===e?o.push(this.data[1]):"z"===e||"b"===e?o.push(this.data[2]):"w"===e||"a"===e?o.push(this.data[3]):console.error(`GetDataValue: Unknown member ${e}`);n=Ug(e,o,r.name)}t=t.postfix}return n}toString(){let e=`${this.data[0]}`;for(let t=1;t=this.data.length)return console.error("GetDataValue: Index out of range",o),null;const s=r.endsWith("h")?"h":"f";let a;if("mat2x2"===r||"mat2x2f"===r||"mat2x2h"===r||"mat3x2"===r||"mat3x2f"===r||"mat3x2h"===r||"mat4x2"===r||"mat4x2f"===r||"mat4x2h"===r)a=new Ng(new Float32Array(this.data.buffer,this.data.byteOffset+2*o*4,2),e.getTypeInfo(`vec2${s}`));else if("mat2x3"===r||"mat2x3f"===r||"mat2x3h"===r||"mat3x3"===r||"mat3x3f"===r||"mat3x3h"===r||"mat4x3"===r||"mat4x3f"===r||"mat4x3h"===r)a=new Ng(new Float32Array(this.data.buffer,this.data.byteOffset+3*o*4,3),e.getTypeInfo(`vec3${s}`));else{if("mat2x4"!==r&&"mat2x4f"!==r&&"mat2x4h"!==r&&"mat3x4"!==r&&"mat3x4f"!==r&&"mat3x4h"!==r&&"mat4x4"!==r&&"mat4x4f"!==r&&"mat4x4h"!==r)return console.error(`GetDataValue: Unknown type ${r}`),null;a=new Ng(new Float32Array(this.data.buffer,this.data.byteOffset+4*o*4,4),e.getTypeInfo(`vec4${s}`))}return t.postfix?a.getSubData(e,t.postfix,i):a}return console.error("GetDataValue: Invalid postfix",t),null}toString(){let e=`${this.data[0]}`;for(let t=1;t"!==o&&"x32"!==o)if("u32"!==o&&"atomic"!==o)if("bool"!==o){if("vec2f"===o||"vec2h"===o){const e=new Float32Array(this.buffer,r,2);return void(t instanceof Ng?(e[0]=t.data[0],e[1]=t.data[1]):(e[0]=t[0],e[1]=t[1]))}if("vec3f"===o||"vec3h"===o){const e=new Float32Array(this.buffer,r,3);return void(t instanceof Ng?(e[0]=t.data[0],e[1]=t.data[1],e[2]=t.data[2]):(e[0]=t[0],e[1]=t[1],e[2]=t[2]))}if("vec4f"===o||"vec4h"===o){const e=new Float32Array(this.buffer,r,4);return void(t instanceof Ng?(e[0]=t.data[0],e[1]=t.data[1],e[2]=t.data[2],e[3]=t.data[3]):(e[0]=t[0],e[1]=t[1],e[2]=t[2],e[3]=t[3]))}if("vec2i"===o){const e=new Int32Array(this.buffer,r,2);return void(t instanceof Ng?(e[0]=t.data[0],e[1]=t.data[1]):(e[0]=t[0],e[1]=t[1]))}if("vec3i"===o){const e=new Int32Array(this.buffer,r,3);return void(t instanceof Ng?(e[0]=t.data[0],e[1]=t.data[1],e[2]=t.data[2]):(e[0]=t[0],e[1]=t[1],e[2]=t[2]))}if("vec4i"===o){const e=new Int32Array(this.buffer,r,4);return void(t instanceof Ng?(e[0]=t.data[0],e[1]=t.data[1],e[2]=t.data[2],e[3]=t.data[3]):(e[0]=t[0],e[1]=t[1],e[2]=t[2],e[3]=t[3]))}if("vec2u"===o){const e=new Uint32Array(this.buffer,r,2);return void(t instanceof Ng?(e[0]=t.data[0],e[1]=t.data[1]):(e[0]=t[0],e[1]=t[1]))}if("vec3u"===o){const e=new Uint32Array(this.buffer,r,3);return void(t instanceof Ng?(e[0]=t.data[0],e[1]=t.data[1],e[2]=t.data[2]):(e[0]=t[0],e[1]=t[1],e[2]=t[2]))}if("vec4u"===o){const e=new Uint32Array(this.buffer,r,4);return void(t instanceof Ng?(e[0]=t.data[0],e[1]=t.data[1],e[2]=t.data[2],e[3]=t.data[3]):(e[0]=t[0],e[1]=t[1],e[2]=t[2],e[3]=t[3]))}if("vec2b"===o){const e=new Uint32Array(this.buffer,r,2);return void(t instanceof Ng?(e[0]=t.data[0],e[1]=t.data[1]):(e[0]=t[0],e[1]=t[1]))}if("vec3b"===o){const e=new Uint32Array(this.buffer,r,3);return void(t instanceof Ng?(e[0]=t.data[0],e[1]=t.data[1],e[2]=t.data[2]):(e[0]=t[0],e[1]=t[1],e[2]=t[2]))}if("vec4b"===o){const e=new Uint32Array(this.buffer,r,4);return void(t instanceof Ng?(e[0]=t.data[0],e[1]=t.data[1],e[2]=t.data[2],e[3]=t.data[3]):(e[0]=t[0],e[1]=t[1],e[2]=t[2],e[3]=t[3]))}if("mat2x2f"===o||"mat2x2h"===o){const e=new Float32Array(this.buffer,r,4);return void(t instanceof Vg?(e[0]=t.data[0],e[1]=t.data[1],e[2]=t.data[2],e[3]=t.data[3]):(e[0]=t[0],e[1]=t[1],e[2]=t[2],e[3]=t[3]))}if("mat2x3f"===o||"mat2x3h"===o){const e=new Float32Array(this.buffer,r,6);return void(t instanceof Vg?(e[0]=t.data[0],e[1]=t.data[1],e[2]=t.data[2],e[3]=t.data[3],e[4]=t.data[4],e[5]=t.data[5]):(e[0]=t[0],e[1]=t[1],e[2]=t[2],e[3]=t[3],e[4]=t[4],e[5]=t[5]))}if("mat2x4f"===o||"mat2x4h"===o){const e=new Float32Array(this.buffer,r,8);return void(t instanceof Vg?(e[0]=t.data[0],e[1]=t.data[1],e[2]=t.data[2],e[3]=t.data[3],e[4]=t.data[4],e[5]=t.data[5],e[6]=t.data[6],e[7]=t.data[7]):(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]))}if("mat3x2f"===o||"mat3x2h"===o){const e=new Float32Array(this.buffer,r,6);return void(t instanceof Vg?(e[0]=t.data[0],e[1]=t.data[1],e[2]=t.data[2],e[3]=t.data[3],e[4]=t.data[4],e[5]=t.data[5]):(e[0]=t[0],e[1]=t[1],e[2]=t[2],e[3]=t[3],e[4]=t[4],e[5]=t[5]))}if("mat3x3f"===o||"mat3x3h"===o){const e=new Float32Array(this.buffer,r,9);return void(t instanceof Vg?(e[0]=t.data[0],e[1]=t.data[1],e[2]=t.data[2],e[3]=t.data[3],e[4]=t.data[4],e[5]=t.data[5],e[6]=t.data[6],e[7]=t.data[7],e[8]=t.data[8]):(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]))}if("mat3x4f"===o||"mat3x4h"===o){const e=new Float32Array(this.buffer,r,12);return void(t instanceof Vg?(e[0]=t.data[0],e[1]=t.data[1],e[2]=t.data[2],e[3]=t.data[3],e[4]=t.data[4],e[5]=t.data[5],e[6]=t.data[6],e[7]=t.data[7],e[8]=t.data[8],e[9]=t.data[9],e[10]=t.data[10],e[11]=t.data[11]):(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]))}if("mat4x2f"===o||"mat4x2h"===o){const e=new Float32Array(this.buffer,r,8);return void(t instanceof Vg?(e[0]=t.data[0],e[1]=t.data[1],e[2]=t.data[2],e[3]=t.data[3],e[4]=t.data[4],e[5]=t.data[5],e[6]=t.data[6],e[7]=t.data[7]):(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]))}if("mat4x3f"===o||"mat4x3h"===o){const e=new Float32Array(this.buffer,r,12);return void(t instanceof Vg?(e[0]=t.data[0],e[1]=t.data[1],e[2]=t.data[2],e[3]=t.data[3],e[4]=t.data[4],e[5]=t.data[5],e[6]=t.data[6],e[7]=t.data[7],e[8]=t.data[8],e[9]=t.data[9],e[10]=t.data[10],e[11]=t.data[11]):(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]))}if("mat4x4f"===o||"mat4x4h"===o){const e=new Float32Array(this.buffer,r,16);return void(t instanceof Vg?(e[0]=t.data[0],e[1]=t.data[1],e[2]=t.data[2],e[3]=t.data[3],e[4]=t.data[4],e[5]=t.data[5],e[6]=t.data[6],e[7]=t.data[7],e[8]=t.data[8],e[9]=t.data[9],e[10]=t.data[10],e[11]=t.data[11],e[12]=t.data[12],e[13]=t.data[13],e[14]=t.data[14],e[15]=t.data[15]):(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]))}if(t instanceof jg){if(i===t.typeInfo)return void new Uint8Array(this.buffer,r,t.buffer.byteLength).set(new Uint8Array(t.buffer));console.error("SetDataValue: Type mismatch",o,t.typeInfo.getTypeName())}else console.error(`SetData: Unknown type ${o}`)}else t instanceof zg&&(new Int32Array(this.buffer,r,1)[0]=t.value);else t instanceof zg&&(new Uint32Array(this.buffer,r,1)[0]=t.value);else t instanceof zg&&(new Int32Array(this.buffer,r,1)[0]=t.value);else t instanceof zg&&(new Float32Array(this.buffer,r,1)[0]=t.value)}getSubData(e,t,i){var r,n,o;if(null===t)return this;let s=this.offset,a=this.typeInfo;for(;t;){if(t instanceof wg){const r=t.index,n=r instanceof mg?e.evalExpression(r,i):r;let o=0;if(n instanceof zg?o=n.value:"number"==typeof n?o=n:console.error("GetDataValue: Invalid index type",r),a instanceof am)s+=o*a.stride,a=a.format;else{const t=a.getTypeName();"mat4x4"===t||"mat4x4f"===t||"mat4x4h"===t?(s+=16*o,a=e.getTypeInfo("vec4f")):console.error(`getDataValue: Type ${a.getTypeName()} is not an array`)}}else{if(!(t instanceof gg))return console.error("GetDataValue: Unknown postfix type",t),null;{const i=t.value;if(a instanceof sm){let e=!1;for(const t of a.members)if(t.name===i){s+=t.offset,a=t.type,e=!0;break}if(!e)return console.error(`GetDataValue: Member ${i} not found`),null}else if(a instanceof nm){const t=a.getTypeName();if("vec2f"===t||"vec3f"===t||"vec4f"===t||"vec2i"===t||"vec3i"===t||"vec4i"===t||"vec2u"===t||"vec3u"===t||"vec4u"===t||"vec2b"===t||"vec3b"===t||"vec4b"===t||"vec2h"===t||"vec3h"===t||"vec4h"===t||"vec2"===t||"vec3"===t||"vec4"===t){if(i.length>0&&i.length<5){let r="f";const n=[];for(let o=0;o=this.buffer.byteLength)return console.log("Insufficient buffer data"),null;const e=new Float32Array(this.buffer,s,3);n.push(e[l])}else if("vec4f"===t)n.push(new Float32Array(this.buffer,s,4)[l]);else if("vec2i"===t)r="i",n.push(new Int32Array(this.buffer,s,2)[l]);else if("vec3i"===t)r="i",n.push(new Int32Array(this.buffer,s,3)[l]);else if("vec4i"===t)r="i",n.push(new Int32Array(this.buffer,s,4)[l]);else if("vec2u"===t){r="u";const e=new Uint32Array(this.buffer,s,2);n.push(e[l])}else"vec3u"===t?(r="u",n.push(new Uint32Array(this.buffer,s,3)[l])):"vec4u"===t&&(r="u",n.push(new Uint32Array(this.buffer,s,4)[l]))}return 2===n.length?a=e.getTypeInfo(`vec2${r}`):3===n.length?a=e.getTypeInfo(`vec3${r}`):4===n.length?a=e.getTypeInfo(`vec4${r}`):console.error(`GetDataValue: Invalid vector length ${n.length}`),new Ng(n,a,null)}return console.error(`GetDataValue: Unknown member ${i}`),null}return console.error(`GetDataValue: Type ${t} is not a struct`),null}}}t=t.postfix}const l=a.getTypeName();return"f32"===l?new zg(new Float32Array(this.buffer,s,1),a,this):"i32"===l?new zg(new Int32Array(this.buffer,s,1),a,this):"u32"===l?new zg(new Uint32Array(this.buffer,s,1),a,this):"vec2f"===l?new Ng(new Float32Array(this.buffer,s,2),a,this):"vec3f"===l?new Ng(new Float32Array(this.buffer,s,3),a,this):"vec4f"===l?new Ng(new Float32Array(this.buffer,s,4),a,this):"vec2i"===l?new Ng(new Int32Array(this.buffer,s,2),a,this):"vec3i"===l?new Ng(new Int32Array(this.buffer,s,3),a,this):"vec4i"===l?new Ng(new Int32Array(this.buffer,s,4),a,this):"vec2u"===l?new Ng(new Uint32Array(this.buffer,s,2),a,this):"vec3u"===l?new Ng(new Uint32Array(this.buffer,s,3),a,this):"vec4u"===l?new Ng(new Uint32Array(this.buffer,s,4),a,this):a instanceof cm&&"atomic"===a.name?"u32"===(null===(r=a.format)||void 0===r?void 0:r.name)?new zg(new Uint32Array(this.buffer,s,1)[0],a.format,this):"i32"===(null===(n=a.format)||void 0===n?void 0:n.name)?new zg(new Int32Array(this.buffer,s,1)[0],a.format,this):(console.error(`GetDataValue: Invalid atomic format ${null===(o=a.format)||void 0===o?void 0:o.name}`),null):new jg(this.buffer,a,s,this)}toString(){let e="";if(this.typeInfo instanceof am)if("f32"===this.typeInfo.format.name){const t=new Float32Array(this.buffer,this.offset);e=`[${t[0]}`;for(let i=1;i0?null!==(e=i[0])&&void 0!==e?e:0:i instanceof Object&&null!==(t=i.width)&&void 0!==t?t:0}get height(){var e,t;const i=this.descriptor.size;return i instanceof Array&&i.length>1?null!==(e=i[1])&&void 0!==e?e:0:i instanceof Object&&null!==(t=i.height)&&void 0!==t?t:0}get depthOrArrayLayers(){var e,t;const i=this.descriptor.size;return i instanceof Array&&i.length>2?null!==(e=i[2])&&void 0!==e?e:0:i instanceof Object&&null!==(t=i.depthOrArrayLayers)&&void 0!==t?t:0}get format(){var e;return this.descriptor&&null!==(e=this.descriptor.format)&&void 0!==e?e:"rgba8unorm"}get sampleCount(){var e;return this.descriptor&&null!==(e=this.descriptor.sampleCount)&&void 0!==e?e:1}get mipLevelCount(){var e;return this.descriptor&&null!==(e=this.descriptor.mipLevelCount)&&void 0!==e?e:1}get dimension(){var e;return this.descriptor&&null!==(e=this.descriptor.dimension)&&void 0!==e?e:"2d"}getMipLevelSize(e){if(e>=this.mipLevelCount)return[0,0,0];const t=[this.width,this.height,this.depthOrArrayLayers];for(let i=0;i>e);return t}get texelByteSize(){const e=this.format,t=Im[e];return t?t.isDepthStencil?4:t.bytesPerBlock:0}get bytesPerRow(){return this.width*this.texelByteSize}get isDepthStencil(){const e=this.format,t=Im[e];return!!t&&t.isDepthStencil}getGpuSize(){const e=this.format,t=Im[e],i=this.width;if(!e||i<=0||!t)return-1;const r=this.height,n=this.depthOrArrayLayers,o=this.dimension;return i/t.blockWidth*("1d"===o?1:r/t.blockHeight)*t.bytesPerBlock*n}getPixel(e,t,i=0,r=0){const n=this.texelByteSize,o=this.bytesPerRow,s=this.height,a=this.data[r];return function(e,t,i,r,n,o,s,a,l){const c=r*(s>>=n)*(o>>=n)+i*s+t*a;switch(l){case"r8unorm":return[Bm(e,c,"8unorm",1)[0]];case"r8snorm":return[Bm(e,c,"8snorm",1)[0]];case"r8uint":return[Bm(e,c,"8uint",1)[0]];case"r8sint":return[Bm(e,c,"8sint",1)[0]];case"rg8unorm":{const t=Bm(e,c,"8unorm",2);return[t[0],t[1]]}case"rg8snorm":{const t=Bm(e,c,"8snorm",2);return[t[0],t[1]]}case"rg8uint":{const t=Bm(e,c,"8uint",2);return[t[0],t[1]]}case"rg8sint":{const t=Bm(e,c,"8sint",2);return[t[0],t[1]]}case"rgba8unorm-srgb":case"rgba8unorm":{const t=Bm(e,c,"8unorm",4);return[t[0],t[1],t[2],t[3]]}case"rgba8snorm":{const t=Bm(e,c,"8snorm",4);return[t[0],t[1],t[2],t[3]]}case"rgba8uint":{const t=Bm(e,c,"8uint",4);return[t[0],t[1],t[2],t[3]]}case"rgba8sint":{const t=Bm(e,c,"8sint",4);return[t[0],t[1],t[2],t[3]]}case"bgra8unorm-srgb":case"bgra8unorm":{const t=Bm(e,c,"8unorm",4);return[t[2],t[1],t[0],t[3]]}case"r16uint":return[Bm(e,c,"16uint",1)[0]];case"r16sint":return[Bm(e,c,"16sint",1)[0]];case"r16float":return[Bm(e,c,"16float",1)[0]];case"rg16uint":{const t=Bm(e,c,"16uint",2);return[t[0],t[1]]}case"rg16sint":{const t=Bm(e,c,"16sint",2);return[t[0],t[1]]}case"rg16float":{const t=Bm(e,c,"16float",2);return[t[0],t[1]]}case"rgba16uint":{const t=Bm(e,c,"16uint",4);return[t[0],t[1],t[2],t[3]]}case"rgba16sint":{const t=Bm(e,c,"16sint",4);return[t[0],t[1],t[2],t[3]]}case"rgba16float":{const t=Bm(e,c,"16float",4);return[t[0],t[1],t[2],t[3]]}case"r32uint":return[Bm(e,c,"32uint",1)[0]];case"r32sint":return[Bm(e,c,"32sint",1)[0]];case"depth16unorm":case"depth24plus":case"depth24plus-stencil8":case"depth32float":case"depth32float-stencil8":case"r32float":return[Bm(e,c,"32float",1)[0]];case"rg32uint":{const t=Bm(e,c,"32uint",2);return[t[0],t[1]]}case"rg32sint":{const t=Bm(e,c,"32sint",2);return[t[0],t[1]]}case"rg32float":{const t=Bm(e,c,"32float",2);return[t[0],t[1]]}case"rgba32uint":{const t=Bm(e,c,"32uint",4);return[t[0],t[1],t[2],t[3]]}case"rgba32sint":{const t=Bm(e,c,"32sint",4);return[t[0],t[1],t[2],t[3]]}case"rgba32float":{const t=Bm(e,c,"32float",4);return[t[0],t[1],t[2],t[3]]}case"rg11b10ufloat":{const t=new Uint32Array(e.buffer,c,1)[0],i=(4192256&t)>>11,r=(4290772992&t)>>22;return[Cm(2047&t),Cm(i),function(e){const t=112+(e>>5&31)<<23|(31&e)<<18;return Tm[0]=t,Em[0]}(r),1]}}return null}(new Uint8Array(a),e,t,i,r,s,o,n,this.format)}setPixel(e,t,i,r,n){const o=this.texelByteSize,s=this.bytesPerRow,a=this.height,l=this.data[r];!function(e,t,i,r,n,o,s,a,l,c){const u=r*(s>>=n)*(o>>=n)+i*s+t*a;switch(l){case"r8unorm":return void Sm(e,u,"8unorm",1,c);case"r8snorm":return void Sm(e,u,"8snorm",1,c);case"r8uint":return void Sm(e,u,"8uint",1,c);case"r8sint":return void Sm(e,u,"8sint",1,c);case"rg8unorm":return void Sm(e,u,"8unorm",2,c);case"rg8snorm":return void Sm(e,u,"8snorm",2,c);case"rg8uint":return void Sm(e,u,"8uint",2,c);case"rg8sint":return void Sm(e,u,"8sint",2,c);case"rgba8unorm-srgb":case"rgba8unorm":case"bgra8unorm-srgb":case"bgra8unorm":return void Sm(e,u,"8unorm",4,c);case"rgba8snorm":return void Sm(e,u,"8snorm",4,c);case"rgba8uint":return void Sm(e,u,"8uint",4,c);case"rgba8sint":return void Sm(e,u,"8sint",4,c);case"r16uint":return void Sm(e,u,"16uint",1,c);case"r16sint":return void Sm(e,u,"16sint",1,c);case"r16float":return void Sm(e,u,"16float",1,c);case"rg16uint":return void Sm(e,u,"16uint",2,c);case"rg16sint":return void Sm(e,u,"16sint",2,c);case"rg16float":return void Sm(e,u,"16float",2,c);case"rgba16uint":return void Sm(e,u,"16uint",4,c);case"rgba16sint":return void Sm(e,u,"16sint",4,c);case"rgba16float":return void Sm(e,u,"16float",4,c);case"r32uint":return void Sm(e,u,"32uint",1,c);case"r32sint":return void Sm(e,u,"32sint",1,c);case"depth16unorm":case"depth24plus":case"depth24plus-stencil8":case"depth32float":case"depth32float-stencil8":case"r32float":return void Sm(e,u,"32float",1,c);case"rg32uint":return void Sm(e,u,"32uint",2,c);case"rg32sint":return void Sm(e,u,"32sint",2,c);case"rg32float":return void Sm(e,u,"32float",2,c);case"rgba32uint":return void Sm(e,u,"32uint",4,c);case"rgba32sint":return void Sm(e,u,"32sint",4,c);case"rgba32float":return void Sm(e,u,"32float",4,c);case"rg11b10ufloat":console.error("TODO: rg11b10ufloat not supported for writing")}}(new Uint8Array(l),e,t,i,r,a,s,o,this.format,n)}}(e=>{e[e.token=0]="token",e[e.keyword=1]="keyword",e[e.reserved=2]="reserved"})(Zm||(Zm={}));class Hg{constructor(e,t,i){this.name=e,this.type=t,this.rule=i}toString(){return this.name}}class Qg{}$m=Qg,Qg.none=new Hg("",Zm.reserved,""),Qg.eof=new Hg("EOF",Zm.token,""),Qg.reserved={asm:new Hg("asm",Zm.reserved,"asm"),bf16:new Hg("bf16",Zm.reserved,"bf16"),do:new Hg("do",Zm.reserved,"do"),enum:new Hg("enum",Zm.reserved,"enum"),f16:new Hg("f16",Zm.reserved,"f16"),f64:new Hg("f64",Zm.reserved,"f64"),handle:new Hg("handle",Zm.reserved,"handle"),i8:new Hg("i8",Zm.reserved,"i8"),i16:new Hg("i16",Zm.reserved,"i16"),i64:new Hg("i64",Zm.reserved,"i64"),mat:new Hg("mat",Zm.reserved,"mat"),premerge:new Hg("premerge",Zm.reserved,"premerge"),regardless:new Hg("regardless",Zm.reserved,"regardless"),typedef:new Hg("typedef",Zm.reserved,"typedef"),u8:new Hg("u8",Zm.reserved,"u8"),u16:new Hg("u16",Zm.reserved,"u16"),u64:new Hg("u64",Zm.reserved,"u64"),unless:new Hg("unless",Zm.reserved,"unless"),using:new Hg("using",Zm.reserved,"using"),vec:new Hg("vec",Zm.reserved,"vec"),void:new Hg("void",Zm.reserved,"void")},Qg.keywords={array:new Hg("array",Zm.keyword,"array"),atomic:new Hg("atomic",Zm.keyword,"atomic"),bool:new Hg("bool",Zm.keyword,"bool"),f32:new Hg("f32",Zm.keyword,"f32"),i32:new Hg("i32",Zm.keyword,"i32"),mat2x2:new Hg("mat2x2",Zm.keyword,"mat2x2"),mat2x3:new Hg("mat2x3",Zm.keyword,"mat2x3"),mat2x4:new Hg("mat2x4",Zm.keyword,"mat2x4"),mat3x2:new Hg("mat3x2",Zm.keyword,"mat3x2"),mat3x3:new Hg("mat3x3",Zm.keyword,"mat3x3"),mat3x4:new Hg("mat3x4",Zm.keyword,"mat3x4"),mat4x2:new Hg("mat4x2",Zm.keyword,"mat4x2"),mat4x3:new Hg("mat4x3",Zm.keyword,"mat4x3"),mat4x4:new Hg("mat4x4",Zm.keyword,"mat4x4"),ptr:new Hg("ptr",Zm.keyword,"ptr"),sampler:new Hg("sampler",Zm.keyword,"sampler"),sampler_comparison:new Hg("sampler_comparison",Zm.keyword,"sampler_comparison"),struct:new Hg("struct",Zm.keyword,"struct"),texture_1d:new Hg("texture_1d",Zm.keyword,"texture_1d"),texture_2d:new Hg("texture_2d",Zm.keyword,"texture_2d"),texture_2d_array:new Hg("texture_2d_array",Zm.keyword,"texture_2d_array"),texture_3d:new Hg("texture_3d",Zm.keyword,"texture_3d"),texture_cube:new Hg("texture_cube",Zm.keyword,"texture_cube"),texture_cube_array:new Hg("texture_cube_array",Zm.keyword,"texture_cube_array"),texture_multisampled_2d:new Hg("texture_multisampled_2d",Zm.keyword,"texture_multisampled_2d"),texture_storage_1d:new Hg("texture_storage_1d",Zm.keyword,"texture_storage_1d"),texture_storage_2d:new Hg("texture_storage_2d",Zm.keyword,"texture_storage_2d"),texture_storage_2d_array:new Hg("texture_storage_2d_array",Zm.keyword,"texture_storage_2d_array"),texture_storage_3d:new Hg("texture_storage_3d",Zm.keyword,"texture_storage_3d"),texture_depth_2d:new Hg("texture_depth_2d",Zm.keyword,"texture_depth_2d"),texture_depth_2d_array:new Hg("texture_depth_2d_array",Zm.keyword,"texture_depth_2d_array"),texture_depth_cube:new Hg("texture_depth_cube",Zm.keyword,"texture_depth_cube"),texture_depth_cube_array:new Hg("texture_depth_cube_array",Zm.keyword,"texture_depth_cube_array"),texture_depth_multisampled_2d:new Hg("texture_depth_multisampled_2d",Zm.keyword,"texture_depth_multisampled_2d"),texture_external:new Hg("texture_external",Zm.keyword,"texture_external"),u32:new Hg("u32",Zm.keyword,"u32"),vec2:new Hg("vec2",Zm.keyword,"vec2"),vec3:new Hg("vec3",Zm.keyword,"vec3"),vec4:new Hg("vec4",Zm.keyword,"vec4"),bitcast:new Hg("bitcast",Zm.keyword,"bitcast"),block:new Hg("block",Zm.keyword,"block"),break:new Hg("break",Zm.keyword,"break"),case:new Hg("case",Zm.keyword,"case"),continue:new Hg("continue",Zm.keyword,"continue"),continuing:new Hg("continuing",Zm.keyword,"continuing"),default:new Hg("default",Zm.keyword,"default"),diagnostic:new Hg("diagnostic",Zm.keyword,"diagnostic"),discard:new Hg("discard",Zm.keyword,"discard"),else:new Hg("else",Zm.keyword,"else"),enable:new Hg("enable",Zm.keyword,"enable"),fallthrough:new Hg("fallthrough",Zm.keyword,"fallthrough"),false:new Hg("false",Zm.keyword,"false"),fn:new Hg("fn",Zm.keyword,"fn"),for:new Hg("for",Zm.keyword,"for"),function:new Hg("function",Zm.keyword,"function"),if:new Hg("if",Zm.keyword,"if"),let:new Hg("let",Zm.keyword,"let"),const:new Hg("const",Zm.keyword,"const"),loop:new Hg("loop",Zm.keyword,"loop"),while:new Hg("while",Zm.keyword,"while"),private:new Hg("private",Zm.keyword,"private"),read:new Hg("read",Zm.keyword,"read"),read_write:new Hg("read_write",Zm.keyword,"read_write"),return:new Hg("return",Zm.keyword,"return"),requires:new Hg("requires",Zm.keyword,"requires"),storage:new Hg("storage",Zm.keyword,"storage"),switch:new Hg("switch",Zm.keyword,"switch"),true:new Hg("true",Zm.keyword,"true"),alias:new Hg("alias",Zm.keyword,"alias"),type:new Hg("type",Zm.keyword,"type"),uniform:new Hg("uniform",Zm.keyword,"uniform"),var:new Hg("var",Zm.keyword,"var"),override:new Hg("override",Zm.keyword,"override"),workgroup:new Hg("workgroup",Zm.keyword,"workgroup"),write:new Hg("write",Zm.keyword,"write"),r8unorm:new Hg("r8unorm",Zm.keyword,"r8unorm"),r8snorm:new Hg("r8snorm",Zm.keyword,"r8snorm"),r8uint:new Hg("r8uint",Zm.keyword,"r8uint"),r8sint:new Hg("r8sint",Zm.keyword,"r8sint"),r16uint:new Hg("r16uint",Zm.keyword,"r16uint"),r16sint:new Hg("r16sint",Zm.keyword,"r16sint"),r16float:new Hg("r16float",Zm.keyword,"r16float"),rg8unorm:new Hg("rg8unorm",Zm.keyword,"rg8unorm"),rg8snorm:new Hg("rg8snorm",Zm.keyword,"rg8snorm"),rg8uint:new Hg("rg8uint",Zm.keyword,"rg8uint"),rg8sint:new Hg("rg8sint",Zm.keyword,"rg8sint"),r32uint:new Hg("r32uint",Zm.keyword,"r32uint"),r32sint:new Hg("r32sint",Zm.keyword,"r32sint"),r32float:new Hg("r32float",Zm.keyword,"r32float"),rg16uint:new Hg("rg16uint",Zm.keyword,"rg16uint"),rg16sint:new Hg("rg16sint",Zm.keyword,"rg16sint"),rg16float:new Hg("rg16float",Zm.keyword,"rg16float"),rgba8unorm:new Hg("rgba8unorm",Zm.keyword,"rgba8unorm"),rgba8unorm_srgb:new Hg("rgba8unorm_srgb",Zm.keyword,"rgba8unorm_srgb"),rgba8snorm:new Hg("rgba8snorm",Zm.keyword,"rgba8snorm"),rgba8uint:new Hg("rgba8uint",Zm.keyword,"rgba8uint"),rgba8sint:new Hg("rgba8sint",Zm.keyword,"rgba8sint"),bgra8unorm:new Hg("bgra8unorm",Zm.keyword,"bgra8unorm"),bgra8unorm_srgb:new Hg("bgra8unorm_srgb",Zm.keyword,"bgra8unorm_srgb"),rgb10a2unorm:new Hg("rgb10a2unorm",Zm.keyword,"rgb10a2unorm"),rg11b10float:new Hg("rg11b10float",Zm.keyword,"rg11b10float"),rg32uint:new Hg("rg32uint",Zm.keyword,"rg32uint"),rg32sint:new Hg("rg32sint",Zm.keyword,"rg32sint"),rg32float:new Hg("rg32float",Zm.keyword,"rg32float"),rgba16uint:new Hg("rgba16uint",Zm.keyword,"rgba16uint"),rgba16sint:new Hg("rgba16sint",Zm.keyword,"rgba16sint"),rgba16float:new Hg("rgba16float",Zm.keyword,"rgba16float"),rgba32uint:new Hg("rgba32uint",Zm.keyword,"rgba32uint"),rgba32sint:new Hg("rgba32sint",Zm.keyword,"rgba32sint"),rgba32float:new Hg("rgba32float",Zm.keyword,"rgba32float"),static_assert:new Hg("static_assert",Zm.keyword,"static_assert")},Qg.tokens={decimal_float_literal:new Hg("decimal_float_literal",Zm.token,/((-?[0-9]*\.[0-9]+|-?[0-9]+\.[0-9]*)((e|E)(\+|-)?[0-9]+)?[fh]?)|(-?[0-9]+(e|E)(\+|-)?[0-9]+[fh]?)|(-?[0-9]+[fh])/),hex_float_literal:new Hg("hex_float_literal",Zm.token,/-?0x((([0-9a-fA-F]*\.[0-9a-fA-F]+|[0-9a-fA-F]+\.[0-9a-fA-F]*)((p|P)(\+|-)?[0-9]+[fh]?)?)|([0-9a-fA-F]+(p|P)(\+|-)?[0-9]+[fh]?))/),int_literal:new Hg("int_literal",Zm.token,/-?0x[0-9a-fA-F]+|0i?|-?[1-9][0-9]*i?/),uint_literal:new Hg("uint_literal",Zm.token,/0x[0-9a-fA-F]+u|0u|[1-9][0-9]*u/),name:new Hg("name",Zm.token,/([_\p{XID_Start}][\p{XID_Continue}]+)|([\p{XID_Start}])/u),ident:new Hg("ident",Zm.token,/[_a-zA-Z][0-9a-zA-Z_]*/),and:new Hg("and",Zm.token,"&"),and_and:new Hg("and_and",Zm.token,"&&"),arrow:new Hg("arrow ",Zm.token,"->"),attr:new Hg("attr",Zm.token,"@"),forward_slash:new Hg("forward_slash",Zm.token,"/"),bang:new Hg("bang",Zm.token,"!"),bracket_left:new Hg("bracket_left",Zm.token,"["),bracket_right:new Hg("bracket_right",Zm.token,"]"),brace_left:new Hg("brace_left",Zm.token,"{"),brace_right:new Hg("brace_right",Zm.token,"}"),colon:new Hg("colon",Zm.token,":"),comma:new Hg("comma",Zm.token,","),equal:new Hg("equal",Zm.token,"="),equal_equal:new Hg("equal_equal",Zm.token,"=="),not_equal:new Hg("not_equal",Zm.token,"!="),greater_than:new Hg("greater_than",Zm.token,">"),greater_than_equal:new Hg("greater_than_equal",Zm.token,">="),shift_right:new Hg("shift_right",Zm.token,">>"),less_than:new Hg("less_than",Zm.token,"<"),less_than_equal:new Hg("less_than_equal",Zm.token,"<="),shift_left:new Hg("shift_left",Zm.token,"<<"),modulo:new Hg("modulo",Zm.token,"%"),minus:new Hg("minus",Zm.token,"-"),minus_minus:new Hg("minus_minus",Zm.token,"--"),period:new Hg("period",Zm.token,"."),plus:new Hg("plus",Zm.token,"+"),plus_plus:new Hg("plus_plus",Zm.token,"++"),or:new Hg("or",Zm.token,"|"),or_or:new Hg("or_or",Zm.token,"||"),paren_left:new Hg("paren_left",Zm.token,"("),paren_right:new Hg("paren_right",Zm.token,")"),semicolon:new Hg("semicolon",Zm.token,";"),star:new Hg("star",Zm.token,"*"),tilde:new Hg("tilde",Zm.token,"~"),underscore:new Hg("underscore",Zm.token,"_"),xor:new Hg("xor",Zm.token,"^"),plus_equal:new Hg("plus_equal",Zm.token,"+="),minus_equal:new Hg("minus_equal",Zm.token,"-="),times_equal:new Hg("times_equal",Zm.token,"*="),division_equal:new Hg("division_equal",Zm.token,"/="),modulo_equal:new Hg("modulo_equal",Zm.token,"%="),and_equal:new Hg("and_equal",Zm.token,"&="),or_equal:new Hg("or_equal",Zm.token,"|="),xor_equal:new Hg("xor_equal",Zm.token,"^="),shift_right_equal:new Hg("shift_right_equal",Zm.token,">>="),shift_left_equal:new Hg("shift_left_equal",Zm.token,"<<=")},Qg.simpleTokens={"@":$m.tokens.attr,"{":$m.tokens.brace_left,"}":$m.tokens.brace_right,":":$m.tokens.colon,",":$m.tokens.comma,"(":$m.tokens.paren_left,")":$m.tokens.paren_right,";":$m.tokens.semicolon},Qg.literalTokens={"&":$m.tokens.and,"&&":$m.tokens.and_and,"->":$m.tokens.arrow,"/":$m.tokens.forward_slash,"!":$m.tokens.bang,"[":$m.tokens.bracket_left,"]":$m.tokens.bracket_right,"=":$m.tokens.equal,"==":$m.tokens.equal_equal,"!=":$m.tokens.not_equal,">":$m.tokens.greater_than,">=":$m.tokens.greater_than_equal,">>":$m.tokens.shift_right,"<":$m.tokens.less_than,"<=":$m.tokens.less_than_equal,"<<":$m.tokens.shift_left,"%":$m.tokens.modulo,"-":$m.tokens.minus,"--":$m.tokens.minus_minus,".":$m.tokens.period,"+":$m.tokens.plus,"++":$m.tokens.plus_plus,"|":$m.tokens.or,"||":$m.tokens.or_or,"*":$m.tokens.star,"~":$m.tokens.tilde,_:$m.tokens.underscore,"^":$m.tokens.xor,"+=":$m.tokens.plus_equal,"-=":$m.tokens.minus_equal,"*=":$m.tokens.times_equal,"/=":$m.tokens.division_equal,"%=":$m.tokens.modulo_equal,"&=":$m.tokens.and_equal,"|=":$m.tokens.or_equal,"^=":$m.tokens.xor_equal,">>=":$m.tokens.shift_right_equal,"<<=":$m.tokens.shift_left_equal},Qg.regexTokens={decimal_float_literal:$m.tokens.decimal_float_literal,hex_float_literal:$m.tokens.hex_float_literal,int_literal:$m.tokens.int_literal,uint_literal:$m.tokens.uint_literal,ident:$m.tokens.ident},Qg.storage_class=[$m.keywords.function,$m.keywords.private,$m.keywords.workgroup,$m.keywords.uniform,$m.keywords.storage],Qg.access_mode=[$m.keywords.read,$m.keywords.write,$m.keywords.read_write],Qg.sampler_type=[$m.keywords.sampler,$m.keywords.sampler_comparison],Qg.sampled_texture_type=[$m.keywords.texture_1d,$m.keywords.texture_2d,$m.keywords.texture_2d_array,$m.keywords.texture_3d,$m.keywords.texture_cube,$m.keywords.texture_cube_array],Qg.multisampled_texture_type=[$m.keywords.texture_multisampled_2d],Qg.storage_texture_type=[$m.keywords.texture_storage_1d,$m.keywords.texture_storage_2d,$m.keywords.texture_storage_2d_array,$m.keywords.texture_storage_3d],Qg.depth_texture_type=[$m.keywords.texture_depth_2d,$m.keywords.texture_depth_2d_array,$m.keywords.texture_depth_cube,$m.keywords.texture_depth_cube_array,$m.keywords.texture_depth_multisampled_2d],Qg.texture_external_type=[$m.keywords.texture_external],Qg.any_texture_type=[...$m.sampled_texture_type,...$m.multisampled_texture_type,...$m.storage_texture_type,...$m.depth_texture_type,...$m.texture_external_type],Qg.texel_format=[$m.keywords.r8unorm,$m.keywords.r8snorm,$m.keywords.r8uint,$m.keywords.r8sint,$m.keywords.r16uint,$m.keywords.r16sint,$m.keywords.r16float,$m.keywords.rg8unorm,$m.keywords.rg8snorm,$m.keywords.rg8uint,$m.keywords.rg8sint,$m.keywords.r32uint,$m.keywords.r32sint,$m.keywords.r32float,$m.keywords.rg16uint,$m.keywords.rg16sint,$m.keywords.rg16float,$m.keywords.rgba8unorm,$m.keywords.rgba8unorm_srgb,$m.keywords.rgba8snorm,$m.keywords.rgba8uint,$m.keywords.rgba8sint,$m.keywords.bgra8unorm,$m.keywords.bgra8unorm_srgb,$m.keywords.rgb10a2unorm,$m.keywords.rg11b10float,$m.keywords.rg32uint,$m.keywords.rg32sint,$m.keywords.rg32float,$m.keywords.rgba16uint,$m.keywords.rgba16sint,$m.keywords.rgba16float,$m.keywords.rgba32uint,$m.keywords.rgba32sint,$m.keywords.rgba32float],Qg.const_literal=[$m.tokens.int_literal,$m.tokens.uint_literal,$m.tokens.decimal_float_literal,$m.tokens.hex_float_literal,$m.keywords.true,$m.keywords.false],Qg.literal_or_ident=[$m.tokens.ident,$m.tokens.int_literal,$m.tokens.uint_literal,$m.tokens.decimal_float_literal,$m.tokens.hex_float_literal,$m.tokens.name],Qg.element_count_expression=[$m.tokens.int_literal,$m.tokens.uint_literal,$m.tokens.ident],Qg.template_types=[$m.keywords.vec2,$m.keywords.vec3,$m.keywords.vec4,$m.keywords.mat2x2,$m.keywords.mat2x3,$m.keywords.mat2x4,$m.keywords.mat3x2,$m.keywords.mat3x3,$m.keywords.mat3x4,$m.keywords.mat4x2,$m.keywords.mat4x3,$m.keywords.mat4x4,$m.keywords.atomic,$m.keywords.bitcast,...$m.any_texture_type],Qg.attribute_name=[$m.tokens.ident,$m.keywords.block,$m.keywords.diagnostic],Qg.assignment_operators=[$m.tokens.equal,$m.tokens.plus_equal,$m.tokens.minus_equal,$m.tokens.times_equal,$m.tokens.division_equal,$m.tokens.modulo_equal,$m.tokens.and_equal,$m.tokens.or_equal,$m.tokens.xor_equal,$m.tokens.shift_right_equal,$m.tokens.shift_left_equal],Qg.increment_operators=[$m.tokens.plus_plus,$m.tokens.minus_minus];class $g{constructor(e,t,i,r,n){this.type=e,this.lexeme=t,this.line=i,this.start=r,this.end=n}toString(){return this.lexeme}isTemplateType(){return-1!=Qg.template_types.indexOf(this.type)}isArrayType(){return this.type==Qg.keywords.array}isArrayOrTemplateType(){return this.isArrayType()||this.isTemplateType()}}class Zg{constructor(e){this._tokens=[],this._start=0,this._current=0,this._line=1,this._source=null!=e?e:""}scanTokens(){for(;!this._isAtEnd();)if(this._start=this._current,!this.scanToken())throw`Invalid syntax at line ${this._line}`;return this._tokens.push(new $g(Qg.eof,"",this._line,this._current,this._current)),this._tokens}scanToken(){let e=this._advance();if("\n"==e)return this._line++,!0;if(this._isWhitespace(e))return!0;if("/"==e){if("/"==this._peekAhead()){for(;"\n"!=e;){if(this._isAtEnd())return!0;e=this._advance()}return this._line++,!0}if("*"==this._peekAhead()){this._advance();let t=1;for(;t>0;){if(this._isAtEnd())return!0;if(e=this._advance(),"\n"==e)this._line++;else if("*"==e){if("/"==this._peekAhead()&&(this._advance(),t--,0==t))return!0}else"/"==e&&"*"==this._peekAhead()&&(this._advance(),t++)}return!0}}const t=Qg.simpleTokens[e];if(t)return this._addToken(t),!0;let i=Qg.none;const r=this._isAlpha(e),n="_"===e;if(this._isAlphaNumeric(e)){let t=this._peekAhead();for(;this._isAlphaNumeric(t);)e+=this._advance(),t=this._peekAhead()}if(r){const t=Qg.keywords[e];if(t)return this._addToken(t),!0}if(r||n)return this._addToken(Qg.tokens.ident),!0;for(;;){let t=this._findType(e);const r=this._peekAhead();if("-"==e&&this._tokens.length>0){if("="==r)return this._current++,e+=r,this._addToken(Qg.tokens.minus_equal),!0;if("-"==r)return this._current++,e+=r,this._addToken(Qg.tokens.minus_minus),!0;const i=this._tokens.length-1;if((-1!=Qg.literal_or_ident.indexOf(this._tokens[i].type)||this._tokens[i].type==Qg.tokens.paren_right)&&">"!=r)return this._addToken(t),!0}if(">"==e&&(">"==r||"="==r)){let e=!1,i=this._tokens.length-1;for(let t=0;t<5&&i>=0&&-1===Qg.assignment_operators.indexOf(this._tokens[i].type);++t,--i)if(this._tokens[i].type===Qg.tokens.less_than){i>0&&this._tokens[i-1].isArrayOrTemplateType()&&(e=!0);break}if(e)return this._addToken(t),!0}if(t===Qg.none){let r=e,n=0;const o=2;for(let e=0;e=this._source.length}_isAlpha(e){return!this._isNumeric(e)&&!this._isWhitespace(e)&&"_"!==e&&"."!==e&&"("!==e&&")"!==e&&"["!==e&&"]"!==e&&"{"!==e&&"}"!==e&&","!==e&&";"!==e&&":"!==e&&"="!==e&&"!"!==e&&"<"!==e&&">"!==e&&"+"!==e&&"-"!==e&&"*"!==e&&"/"!==e&&"%"!==e&&"&"!==e&&"|"!==e&&"^"!==e&&"~"!==e&&"@"!==e&&"#"!==e&&"?"!==e&&"'"!==e&&"`"!==e&&'"'!==e&&"\\"!==e&&"\n"!==e&&"\r"!==e&&"\t"!==e&&"\0"!==e}_isNumeric(e){return e>="0"&&e<="9"}_isAlphaNumeric(e){return this._isAlpha(e)||this._isNumeric(e)||"_"===e}_isWhitespace(e){return" "==e||"\t"==e||"\r"==e}_advance(e=0){let t=this._source[this._current];return e=e||0,e++,this._current+=e,t}_peekAhead(e=0){return e=e||0,this._current+e>=this._source.length?"\0":this._source[this._current+e]}_addToken(e){const t=this._source.substring(this._start,this._current);this._tokens.push(new $g(e,t,this._line,this._start,this._current))}}function Wg(e){return Array.isArray(e)||(null==e?void 0:e.buffer)instanceof ArrayBuffer}const qg=new Float32Array(1),Kg=new Uint32Array(qg.buffer),Xg=new Uint32Array(qg.buffer),Jg=new Int32Array(1),Yg=new Float32Array(Jg.buffer),e_=new Uint32Array(Jg.buffer),t_=new Uint32Array(1),i_=new Float32Array(t_.buffer),r_=new Int32Array(t_.buffer);function n_(e,t,i){if(t===i)return e;if("f32"===t){if("i32"===i||"x32"===i)return qg[0]=e,Kg[0];if("u32"===i)return qg[0]=e,Xg[0]}else if("i32"===t||"x32"===t){if("f32"===i)return Jg[0]=e,Yg[0];if("u32"===i)return Jg[0]=e,e_[0]}else if("u32"===t){if("f32"===i)return t_[0]=e,i_[0];if("i32"===i||"x32"===i)return t_[0]=e,r_[0]}return console.error(`Unsupported cast from ${t} to ${i}`),e}class o_{constructor(e){this.resources=null,this.inUse=!1,this.info=null,this.node=e}}class s_{constructor(e,t){this.align=e,this.size=t}}class a_{constructor(){this.uniforms=[],this.storage=[],this.textures=[],this.samplers=[],this.aliases=[],this.overrides=[],this.structs=[],this.entry=new Am,this.functions=[],this._types=new Map,this._functions=new Map}_isStorageTexture(e){return"texture_storage_1d"==e.name||"texture_storage_2d"==e.name||"texture_storage_2d_array"==e.name||"texture_storage_3d"==e.name}updateAST(e){for(const t of e)t instanceof km&&this._functions.set(t.name,new o_(t));for(const t of e)if(t instanceof ug){const e=this.getTypeInfo(t,null);e instanceof sm&&this.structs.push(e)}for(const t of e)if(t instanceof ng)this.aliases.push(this._getAliasInfo(t));else{if(t instanceof Vm){const e=t,i=this._getAttributeNum(e.attributes,"id",0),r=null!=e.type?this.getTypeInfo(e.type,e.attributes):null;this.overrides.push(new mm(e.name,r,e.attributes,i));continue}if(this._isUniformVar(t)){const e=t,i=this._getAttributeNum(e.attributes,"group",0),r=this._getAttributeNum(e.attributes,"binding",0),n=this.getTypeInfo(e.type,e.attributes),o=new hm(e.name,n,i,r,e.attributes,um.Uniform,e.access);o.access||(o.access="read"),this.uniforms.push(o);continue}if(this._isStorageVar(t)){const e=t,i=this._getAttributeNum(e.attributes,"group",0),r=this._getAttributeNum(e.attributes,"binding",0),n=this.getTypeInfo(e.type,e.attributes),o=this._isStorageTexture(n),s=new hm(e.name,n,i,r,e.attributes,o?um.StorageTexture:um.Storage,e.access);s.access||(s.access="read"),this.storage.push(s);continue}if(this._isTextureVar(t)){const e=t,i=this._getAttributeNum(e.attributes,"group",0),r=this._getAttributeNum(e.attributes,"binding",0),n=this.getTypeInfo(e.type,e.attributes),o=this._isStorageTexture(n),s=new hm(e.name,n,i,r,e.attributes,o?um.StorageTexture:um.Texture,e.access);s.access||(s.access="read"),o?this.storage.push(s):this.textures.push(s);continue}if(this._isSamplerVar(t)){const e=t,i=this._getAttributeNum(e.attributes,"group",0),r=this._getAttributeNum(e.attributes,"binding",0),n=this.getTypeInfo(e.type,e.attributes),o=new hm(e.name,n,i,r,e.attributes,um.Sampler,e.access);this.samplers.push(o);continue}}for(const t of e)if(t instanceof km){const e=this._getAttribute(t,"vertex"),i=this._getAttribute(t,"fragment"),r=this._getAttribute(t,"compute"),n=e||i||r,o=new _m(t.name,null==n?void 0:n.name,t.attributes);o.attributes=t.attributes,o.startLine=t.startLine,o.endLine=t.endLine,this.functions.push(o),this._functions.get(t.name).info=o,n&&(this._functions.get(t.name).inUse=!0,o.inUse=!0,o.resources=this._findResources(t,!!n),o.inputs=this._getInputs(t.args),o.outputs=this._getOutputs(t.returnType),this.entry[n.name].push(o)),o.arguments=t.args.map(e=>new gm(e.name,this.getTypeInfo(e.type,e.attributes),e.attributes)),o.returnType=t.returnType?this.getTypeInfo(t.returnType,t.attributes):null;continue}for(const e of this._functions.values())e.info&&(e.info.inUse=e.inUse,this._addCalls(e.node,e.info.calls));for(const e of this._functions.values())e.node.search(t=>{var i,r,n;if(t instanceof Fg){if(t.value)if(Wg(t.value))for(const r of t.value)for(const t of this.overrides)r===t.name&&(null===(i=e.info)||void 0===i||i.overrides.push(t));else for(const i of this.overrides)t.value===i.name&&(null===(r=e.info)||void 0===r||r.overrides.push(i))}else if(t instanceof yg)for(const i of this.overrides)t.name===i.name&&(null===(n=e.info)||void 0===n||n.overrides.push(i))});for(const e of this.uniforms)this._markStructsInUse(e.type);for(const e of this.storage)this._markStructsInUse(e.type)}getFunctionInfo(e){for(const t of this.functions)if(t.name==e)return t;return null}getStructInfo(e){for(const t of this.structs)if(t.name==e)return t;return null}getOverrideInfo(e){for(const t of this.overrides)if(t.name==e)return t;return null}_markStructsInUse(e){if(e)if(e.isStruct){if(e.inUse=!0,e.members)for(const t of e.members)this._markStructsInUse(t.type)}else if(e.isArray)this._markStructsInUse(e.format);else if(e.isTemplate)e.format&&this._markStructsInUse(e.format);else{const t=this._getAlias(e.name);t&&this._markStructsInUse(t)}}_addCalls(e,t){var i;for(const r of e.calls){const e=null===(i=this._functions.get(r.name))||void 0===i?void 0:i.info;e&&t.add(e)}}findResource(e,t,i){if(i){for(const r of this.entry.compute)if(r.name===i)for(const i of r.resources)if(i.group==e&&i.binding==t)return i;for(const r of this.entry.vertex)if(r.name===i)for(const i of r.resources)if(i.group==e&&i.binding==t)return i;for(const r of this.entry.fragment)if(r.name===i)for(const i of r.resources)if(i.group==e&&i.binding==t)return i}for(const i of this.uniforms)if(i.group==e&&i.binding==t)return i;for(const i of this.storage)if(i.group==e&&i.binding==t)return i;for(const i of this.textures)if(i.group==e&&i.binding==t)return i;for(const i of this.samplers)if(i.group==e&&i.binding==t)return i;return null}_findResource(e){for(const t of this.uniforms)if(t.name==e)return t;for(const t of this.storage)if(t.name==e)return t;for(const t of this.textures)if(t.name==e)return t;for(const t of this.samplers)if(t.name==e)return t;return null}_markStructsFromAST(e){const t=this.getTypeInfo(e,null);this._markStructsInUse(t)}_findResources(e,t){const i=[],r=this,n=[];return e.search(o=>{if(o instanceof Pm)n.push({});else if(o instanceof Rm)n.pop();else if(o instanceof Nm){const e=o;t&&null!==e.type&&this._markStructsFromAST(e.type),n.length>0&&(n[n.length-1][e.name]=e)}else if(o instanceof _g){const e=o;t&&null!==e.type&&this._markStructsFromAST(e.type)}else if(o instanceof jm){const e=o;t&&null!==e.type&&this._markStructsFromAST(e.type),n.length>0&&(n[n.length-1][e.name]=e)}else if(o instanceof yg){const e=o;if(n.length>0&&n[n.length-1][e.name])return;const t=r._findResource(e.name);t&&i.push(t)}else if(o instanceof Ag){const n=o,s=r._functions.get(n.name);s&&(t&&(s.inUse=!0),e.calls.add(s.node),null===s.resources&&(s.resources=r._findResources(s.node,t)),i.push(...s.resources))}else if(o instanceof Km){const n=o,s=r._functions.get(n.name);s&&(t&&(s.inUse=!0),e.calls.add(s.node),null===s.resources&&(s.resources=r._findResources(s.node,t)),i.push(...s.resources))}}),[...new Map(i.map(e=>[e.name,e])).values()]}getBindGroups(){const e=[];function t(t,i){t>=e.length&&(e.length=t+1),void 0===e[t]&&(e[t]=[]),i>=e[t].length&&(e[t].length=i+1)}for(const i of this.uniforms)t(i.group,i.binding),e[i.group][i.binding]=i;for(const i of this.storage)t(i.group,i.binding),e[i.group][i.binding]=i;for(const i of this.textures)t(i.group,i.binding),e[i.group][i.binding]=i;for(const i of this.samplers)t(i.group,i.binding),e[i.group][i.binding]=i;return e}_getOutputs(e,t=void 0){if(void 0===t&&(t=[]),e instanceof ug)this._getStructOutputs(e,t);else{const i=this._getOutputInfo(e);null!==i&&t.push(i)}return t}_getStructOutputs(e,t){for(const i of e.members)if(i.type instanceof ug)this._getStructOutputs(i.type,t);else{const e=this._getAttribute(i,"location")||this._getAttribute(i,"builtin");if(null!==e){const r=this.getTypeInfo(i.type,i.type.attributes),n=this._parseInt(e.value),o=new fm(i.name,r,e.name,n);t.push(o)}}}_getOutputInfo(e){const t=this._getAttribute(e,"location")||this._getAttribute(e,"builtin");if(null!==t){const i=this.getTypeInfo(e,e.attributes),r=this._parseInt(t.value);return new fm("",i,t.name,r)}return null}_getInputs(e,t=void 0){void 0===t&&(t=[]);for(const i of e)if(i.type instanceof ug)this._getStructInputs(i.type,t);else{const e=this._getInputInfo(i);null!==e&&t.push(e)}return t}_getStructInputs(e,t){for(const i of e.members)if(i.type instanceof ug)this._getStructInputs(i.type,t);else{const e=this._getInputInfo(i);null!==e&&t.push(e)}}_getInputInfo(e){const t=this._getAttribute(e,"location")||this._getAttribute(e,"builtin");if(null!==t){const i=this._getAttribute(e,"interpolation"),r=this.getTypeInfo(e.type,e.attributes),n=this._parseInt(t.value),o=new pm(e.name,r,t.name,n);return null!==i&&(o.interpolation=this._parseString(i.value)),o}return null}_parseString(e){return e instanceof Array&&(e=e[0]),e}_parseInt(e){e instanceof Array&&(e=e[0]);const t=parseInt(e);return isNaN(t)?e:t}_getAlias(e){for(const t of this.aliases)if(t.name==e)return t.type;return null}_getAliasInfo(e){return new dm(e.name,this.getTypeInfo(e.type,null))}getTypeInfoByName(e){for(const t of this.structs)if(t.name==e)return t;for(const t of this.aliases)if(t.name==e)return t.type;return null}getTypeInfo(e,t=null){if(this._types.has(e))return this._types.get(e);if(e instanceof dg){const i=e.type?this.getTypeInfo(e.type,e.attributes):null,r=new lm(e.name,i,t);return this._types.set(e,r),this._updateTypeInfo(r),r}if(e instanceof pg){const i=e,r=i.format?this.getTypeInfo(i.format,i.attributes):null,n=new am(i.name,t);return n.format=r,n.count=i.count,this._types.set(e,n),this._updateTypeInfo(n),n}if(e instanceof ug){const i=e,r=new sm(i.name,t);r.startLine=i.startLine,r.endLine=i.endLine;for(const e of i.members){const t=this.getTypeInfo(e.type,e.attributes);r.members.push(new om(e.name,t,e.attributes))}return this._types.set(e,r),this._updateTypeInfo(r),r}if(e instanceof fg){const i=e,r=i.format instanceof lg,n=i.format?r?this.getTypeInfo(i.format,null):new nm(i.format,null):null,o=new cm(i.name,n,t,i.access);return this._types.set(e,o),this._updateTypeInfo(o),o}if(e instanceof hg){const i=e,r=i.format?this.getTypeInfo(i.format,null):null,n=new cm(i.name,r,t,i.access);return this._types.set(e,n),this._updateTypeInfo(n),n}const i=new nm(e.name,t);return this._types.set(e,i),this._updateTypeInfo(i),i}_updateTypeInfo(e){var t,i,r;const n=this._getTypeSize(e);if(e.size=null!==(t=null==n?void 0:n.size)&&void 0!==t?t:0,e instanceof am&&e.format){const t=this._getTypeSize(e.format);e.stride=Math.max(null!==(i=null==t?void 0:t.size)&&void 0!==i?i:0,null!==(r=null==t?void 0:t.align)&&void 0!==r?r:0),this._updateTypeInfo(e.format)}e instanceof lm&&this._updateTypeInfo(e.format),e instanceof sm&&this._updateStructInfo(e)}_updateStructInfo(e){var t;let i=0,r=0,n=0,o=0;for(let s=0,a=e.members.length;se.name),a_._samplerTypes=Qg.sampler_type.map(e=>e.name);let l_=0;class c_{constructor(e,t,i){this.id=l_++,this.name=e,this.value=t,this.node=i}clone(){return new c_(this.name,this.value,this.node)}}class u_{constructor(e){this.id=l_++,this.name=e.name,this.node=e}clone(){return new u_(this.node)}}class h_{constructor(e){this.parent=null,this.variables=new Map,this.functions=new Map,this.currentFunctionName="",this.id=l_++,e&&(this.parent=e,this.currentFunctionName=e.currentFunctionName)}getVariable(e){var t;return this.variables.has(e)?null!==(t=this.variables.get(e))&&void 0!==t?t:null:this.parent?this.parent.getVariable(e):null}getFunction(e){var t;return this.functions.has(e)?null!==(t=this.functions.get(e))&&void 0!==t?t:null:this.parent?this.parent.getFunction(e):null}createVariable(e,t,i){this.variables.set(e,new c_(e,t,null!=i?i:null))}setVariable(e,t,i){const r=this.getVariable(e);null!==r?r.value=t:this.createVariable(e,t,i)}getVariableValue(e){var t;const i=this.getVariable(e);return null!==(t=null==i?void 0:i.value)&&void 0!==t?t:null}clone(){return new h_(this)}}class d_{evalExpression(e,t){return null}getTypeInfo(e){return null}getVariableName(e,t){return""}}class p_{constructor(e){this.exec=e}getTypeInfo(e){return this.exec.getTypeInfo(e)}All(e,t){const i=this.exec.evalExpression(e.args[0],t);let r=!0;if(i instanceof Ng)return i.data.forEach(e=>{e||(r=!1)}),new zg(r?1:0,this.getTypeInfo("bool"));throw new Error(`All() expects a vector argument. Line ${e.line}`)}Any(e,t){const i=this.exec.evalExpression(e.args[0],t);if(i instanceof Ng){const e=i.data.some(e=>e);return new zg(e?1:0,this.getTypeInfo("bool"))}throw new Error(`Any() expects a vector argument. Line ${e.line}`)}Select(e,t){const i=this.exec.evalExpression(e.args[2],t);if(!(i instanceof zg))throw new Error(`Select() expects a bool condition. Line ${e.line}`);return i.value?this.exec.evalExpression(e.args[1],t):this.exec.evalExpression(e.args[0],t)}ArrayLength(e,t){let i=e.args[0];i instanceof Eg&&(i=i.right);const r=this.exec.evalExpression(i,t);if(r instanceof jg&&0===r.typeInfo.size){const e=r.typeInfo,t=r.buffer.byteLength/e.stride;return new zg(t,this.getTypeInfo("u32"))}return new zg(r.typeInfo.size,this.getTypeInfo("u32"))}Abs(e,t){const i=this.exec.evalExpression(e.args[0],t);if(i instanceof Ng)return new Ng(i.data.map(e=>Math.abs(e)),i.typeInfo);const r=i;return new zg(Math.abs(r.value),r.typeInfo)}Acos(e,t){const i=this.exec.evalExpression(e.args[0],t);if(i instanceof Ng)return new Ng(i.data.map(e=>Math.acos(e)),i.typeInfo);const r=i;return new zg(Math.acos(r.value),i.typeInfo)}Acosh(e,t){const i=this.exec.evalExpression(e.args[0],t);if(i instanceof Ng)return new Ng(i.data.map(e=>Math.acosh(e)),i.typeInfo);const r=i;return new zg(Math.acosh(r.value),i.typeInfo)}Asin(e,t){const i=this.exec.evalExpression(e.args[0],t);if(i instanceof Ng)return new Ng(i.data.map(e=>Math.asin(e)),i.typeInfo);const r=i;return new zg(Math.asin(r.value),i.typeInfo)}Asinh(e,t){const i=this.exec.evalExpression(e.args[0],t);if(i instanceof Ng)return new Ng(i.data.map(e=>Math.asinh(e)),i.typeInfo);const r=i;return new zg(Math.asinh(r.value),i.typeInfo)}Atan(e,t){const i=this.exec.evalExpression(e.args[0],t);if(i instanceof Ng)return new Ng(i.data.map(e=>Math.atan(e)),i.typeInfo);const r=i;return new zg(Math.atan(r.value),i.typeInfo)}Atanh(e,t){const i=this.exec.evalExpression(e.args[0],t);if(i instanceof Ng)return new Ng(i.data.map(e=>Math.atanh(e)),i.typeInfo);const r=i;return new zg(Math.atanh(r.value),i.typeInfo)}Atan2(e,t){const i=this.exec.evalExpression(e.args[0],t),r=this.exec.evalExpression(e.args[1],t);if(i instanceof Ng&&r instanceof Ng)return new Ng(i.data.map((e,t)=>Math.atan2(e,r.data[t])),i.typeInfo);const n=i,o=r;return new zg(Math.atan2(n.value,o.value),i.typeInfo)}Ceil(e,t){const i=this.exec.evalExpression(e.args[0],t);if(i instanceof Ng)return new Ng(i.data.map(e=>Math.ceil(e)),i.typeInfo);const r=i;return new zg(Math.ceil(r.value),i.typeInfo)}_clamp(e,t,i){return Math.min(Math.max(e,t),i)}Clamp(e,t){const i=this.exec.evalExpression(e.args[0],t),r=this.exec.evalExpression(e.args[1],t),n=this.exec.evalExpression(e.args[2],t);if(i instanceof Ng&&r instanceof Ng&&n instanceof Ng)return new Ng(i.data.map((e,t)=>this._clamp(e,r.data[t],n.data[t])),i.typeInfo);const o=i,s=r,a=n;return new zg(this._clamp(o.value,s.value,a.value),i.typeInfo)}Cos(e,t){const i=this.exec.evalExpression(e.args[0],t);if(i instanceof Ng)return new Ng(i.data.map(e=>Math.cos(e)),i.typeInfo);const r=i;return new zg(Math.cos(r.value),i.typeInfo)}Cosh(e,t){const i=this.exec.evalExpression(e.args[0],t);if(i instanceof Ng)return new Ng(i.data.map(e=>Math.cosh(e)),i.typeInfo);const r=i;return new zg(Math.cos(r.value),i.typeInfo)}CountLeadingZeros(e,t){const i=this.exec.evalExpression(e.args[0],t);if(i instanceof Ng)return new Ng(i.data.map(e=>Math.clz32(e)),i.typeInfo);const r=i;return new zg(Math.clz32(r.value),i.typeInfo)}_countOneBits(e){let t=0;for(;0!==e;)1&e&&t++,e>>=1;return t}CountOneBits(e,t){const i=this.exec.evalExpression(e.args[0],t);if(i instanceof Ng)return new Ng(i.data.map(e=>this._countOneBits(e)),i.typeInfo);const r=i;return new zg(this._countOneBits(r.value),i.typeInfo)}_countTrailingZeros(e){if(0===e)return 32;let t=0;for(;!(1&e);)e>>=1,t++;return t}CountTrailingZeros(e,t){const i=this.exec.evalExpression(e.args[0],t);if(i instanceof Ng)return new Ng(i.data.map(e=>this._countTrailingZeros(e)),i.typeInfo);const r=i;return new zg(this._countTrailingZeros(r.value),i.typeInfo)}Cross(e,t){const i=this.exec.evalExpression(e.args[0],t),r=this.exec.evalExpression(e.args[1],t);if(i instanceof Ng&&r instanceof Ng){if(3!==i.data.length||3!==r.data.length)return console.error(`Cross() expects 3D vectors. Line ${e.line}`),null;const t=i.data,n=r.data;return new Ng([t[1]*n[2]-n[1]*t[2],t[2]*n[0]-n[2]*t[0],t[0]*n[1]-n[0]*t[1]],i.typeInfo)}return console.error(`Cross() expects vector arguments. Line ${e.line}`),null}Degrees(e,t){const i=this.exec.evalExpression(e.args[0],t),r=180/Math.PI;return i instanceof Ng?new Ng(i.data.map(e=>e*r),i.typeInfo):new zg(i.value*r,this.getTypeInfo("f32"))}Determinant(e,t){const i=this.exec.evalExpression(e.args[0],t);if(i instanceof Vg){const e=i.data,t=i.typeInfo.getTypeName(),r=t.endsWith("h")?this.getTypeInfo("f16"):this.getTypeInfo("f32");if("mat2x2"===t||"mat2x2f"===t||"mat2x2h"===t)return new zg(e[0]*e[3]-e[1]*e[2],r);if("mat2x3"===t||"mat2x3f"===t||"mat2x3h"===t)return new zg(e[0]*(e[4]*e[8]-e[5]*e[7])-e[1]*(e[3]*e[8]-e[5]*e[6])+e[2]*(e[3]*e[7]-e[4]*e[6]),r);if("mat2x4"===t||"mat2x4f"===t||"mat2x4h"===t)console.error(`TODO: Determinant for ${t}`);else if("mat3x2"===t||"mat3x2f"===t||"mat3x2h"===t)console.error(`TODO: Determinant for ${t}`);else{if("mat3x3"===t||"mat3x3f"===t||"mat3x3h"===t)return new zg(e[0]*(e[4]*e[8]-e[5]*e[7])-e[1]*(e[3]*e[8]-e[5]*e[6])+e[2]*(e[3]*e[7]-e[4]*e[6]),r);"mat3x4"===t||"mat3x4f"===t||"mat3x4h"===t||"mat4x2"===t||"mat4x2f"===t||"mat4x2h"===t||"mat4x3"===t||"mat4x3f"===t||"mat4x3h"===t?console.error(`TODO: Determinant for ${t}`):"mat4x4"!==t&&"mat4x4f"!==t&&"mat4x4h"!==t||console.error(`TODO: Determinant for ${t}`)}}return console.error(`Determinant expects a matrix argument. Line ${e.line}`),null}Distance(e,t){const i=this.exec.evalExpression(e.args[0],t),r=this.exec.evalExpression(e.args[1],t);if(i instanceof Ng&&r instanceof Ng){let e=0;for(let t=0;tMath.exp(e)),i.typeInfo);const r=i;return new zg(Math.exp(r.value),i.typeInfo)}Exp2(e,t){const i=this.exec.evalExpression(e.args[0],t);if(i instanceof Ng)return new Ng(i.data.map(e=>Math.pow(2,e)),i.typeInfo);const r=i;return new zg(Math.pow(2,r.value),i.typeInfo)}ExtractBits(e,t){const i=this.exec.evalExpression(e.args[0],t),r=this.exec.evalExpression(e.args[1],t),n=this.exec.evalExpression(e.args[2],t);if("u32"!==r.typeInfo.name&&"x32"!==r.typeInfo.name)return console.error(`ExtractBits() expects an i32 offset argument. Line ${e.line}`),null;if("u32"!==n.typeInfo.name&&"x32"!==n.typeInfo.name)return console.error(`ExtractBits() expects an i32 count argument. Line ${e.line}`),null;const o=r.value,s=n.value;if(i instanceof Ng)return new Ng(i.data.map(e=>e>>o&(1<>o&(1<-e),i.typeInfo)}return console.error(`FaceForward() expects vector arguments. Line ${e.line}`),null}_firstLeadingBit(e){return 0===e?-1:31-Math.clz32(e)}FirstLeadingBit(e,t){const i=this.exec.evalExpression(e.args[0],t);if(i instanceof Ng)return new Ng(i.data.map(e=>this._firstLeadingBit(e)),i.typeInfo);const r=i;return new zg(this._firstLeadingBit(r.value),i.typeInfo)}_firstTrailingBit(e){return 0===e?-1:Math.log2(e&-e)}FirstTrailingBit(e,t){const i=this.exec.evalExpression(e.args[0],t);if(i instanceof Ng)return new Ng(i.data.map(e=>this._firstTrailingBit(e)),i.typeInfo);const r=i;return new zg(this._firstTrailingBit(r.value),i.typeInfo)}Floor(e,t){const i=this.exec.evalExpression(e.args[0],t);if(i instanceof Ng)return new Ng(i.data.map(e=>Math.floor(e)),i.typeInfo);const r=i;return new zg(Math.floor(r.value),i.typeInfo)}Fma(e,t){const i=this.exec.evalExpression(e.args[0],t),r=this.exec.evalExpression(e.args[1],t),n=this.exec.evalExpression(e.args[2],t);if(i instanceof Ng&&r instanceof Ng&&n instanceof Ng)return i.data.length!==r.data.length||i.data.length!==n.data.length?(console.error(`Fma() expects vectors of the same length. Line ${e.line}`),null):new Ng(i.data.map((e,t)=>e*r.data[t]+n.data[t]),i.typeInfo);const o=i,s=r,a=n;return new zg(o.value*s.value+a.value,o.typeInfo)}Fract(e,t){const i=this.exec.evalExpression(e.args[0],t);if(i instanceof Ng)return new Ng(i.data.map(e=>e-Math.floor(e)),i.typeInfo);const r=i;return new zg(r.value-Math.floor(r.value),i.typeInfo)}Frexp(e,t){return console.error(`TODO: frexp. Line ${e.line}`),null}InsertBits(e,t){const i=this.exec.evalExpression(e.args[0],t),r=this.exec.evalExpression(e.args[1],t),n=this.exec.evalExpression(e.args[2],t),o=this.exec.evalExpression(e.args[3],t);if("u32"!==n.typeInfo.name&&"x32"!==n.typeInfo.name)return console.error(`InsertBits() expects an i32 offset argument. Line ${e.line}`),null;const s=n.value,a=(1<e&l|r.data[t]<1/Math.sqrt(e)),i.typeInfo);const r=i;return new zg(1/Math.sqrt(r.value),i.typeInfo)}Ldexp(e,t){return console.error(`TODO: ldexp. Line ${e.line}`),null}Length(e,t){const i=this.exec.evalExpression(e.args[0],t);if(i instanceof Ng){let e=0;return i.data.forEach(t=>{e+=t*t}),new zg(Math.sqrt(e),this.getTypeInfo("f32"))}const r=i;return new zg(Math.abs(r.value),i.typeInfo)}Log(e,t){const i=this.exec.evalExpression(e.args[0],t);if(i instanceof Ng)return new Ng(i.data.map(e=>Math.log(e)),i.typeInfo);const r=i;return new zg(Math.log(r.value),i.typeInfo)}Log2(e,t){const i=this.exec.evalExpression(e.args[0],t);if(i instanceof Ng)return new Ng(i.data.map(e=>Math.log2(e)),i.typeInfo);const r=i;return new zg(Math.log2(r.value),i.typeInfo)}Max(e,t){const i=this.exec.evalExpression(e.args[0],t),r=this.exec.evalExpression(e.args[1],t);if(i instanceof Ng&&r instanceof Ng)return new Ng(i.data.map((e,t)=>Math.max(e,r.data[t])),i.typeInfo);const n=i,o=r;return new zg(Math.max(n.value,o.value),i.typeInfo)}Min(e,t){const i=this.exec.evalExpression(e.args[0],t),r=this.exec.evalExpression(e.args[1],t);if(i instanceof Ng&&r instanceof Ng)return new Ng(i.data.map((e,t)=>Math.min(e,r.data[t])),i.typeInfo);const n=i,o=r;return new zg(Math.min(n.value,o.value),i.typeInfo)}Mix(e,t){const i=this.exec.evalExpression(e.args[0],t),r=this.exec.evalExpression(e.args[1],t),n=this.exec.evalExpression(e.args[2],t);if(i instanceof Ng&&r instanceof Ng&&n instanceof Ng)return new Ng(i.data.map((e,t)=>i.data[t]*(1-n.data[t])+r.data[t]*n.data[t]),i.typeInfo);const o=r,s=n;return new zg(i.value*(1-s.value)+o.value*s.value,i.typeInfo)}Modf(e,t){const i=this.exec.evalExpression(e.args[0],t),r=this.exec.evalExpression(e.args[1],t);if(i instanceof Ng&&r instanceof Ng)return new Ng(i.data.map((e,t)=>e%r.data[t]),i.typeInfo);const n=r;return new zg(i.value%n.value,i.typeInfo)}Normalize(e,t){const i=this.exec.evalExpression(e.args[0],t);if(i instanceof Ng){const r=this.Length(e,t).value;return new Ng(i.data.map(e=>e/r),i.typeInfo)}return console.error(`Normalize() expects a vector argument. Line ${e.line}`),null}Pow(e,t){const i=this.exec.evalExpression(e.args[0],t),r=this.exec.evalExpression(e.args[1],t);if(i instanceof Ng&&r instanceof Ng)return new Ng(i.data.map((e,t)=>Math.pow(e,r.data[t])),i.typeInfo);const n=i,o=r;return new zg(Math.pow(n.value,o.value),i.typeInfo)}QuantizeToF16(e,t){const i=this.exec.evalExpression(e.args[0],t);return i instanceof Ng?new Ng(i.data.map(e=>e),i.typeInfo):new zg(i.value,i.typeInfo)}Radians(e,t){const i=this.exec.evalExpression(e.args[0],t);return i instanceof Ng?new Ng(i.data.map(e=>e*Math.PI/180),i.typeInfo):new zg(i.value*Math.PI/180,this.getTypeInfo("f32"))}Reflect(e,t){let i=this.exec.evalExpression(e.args[0],t),r=this.exec.evalExpression(e.args[1],t);if(i instanceof Ng&&r instanceof Ng){const e=this._dot(i.data,r.data);return new Ng(i.data.map((t,i)=>t-2*e*r.data[i]),i.typeInfo)}return console.error(`Reflect() expects vector arguments. Line ${e.line}`),null}Refract(e,t){let i=this.exec.evalExpression(e.args[0],t),r=this.exec.evalExpression(e.args[1],t),n=this.exec.evalExpression(e.args[2],t);if(i instanceof Ng&&r instanceof Ng&&n instanceof zg){const e=this._dot(r.data,i.data);return new Ng(i.data.map((t,i)=>{const o=1-n.value*n.value*(1-e*e);if(o<0)return 0;const s=Math.sqrt(o);return n.value*t-(n.value*e+s)*r.data[i]}),i.typeInfo)}return console.error(`Refract() expects vector arguments and a scalar argument. Line ${e.line}`),null}ReverseBits(e,t){return console.error(`TODO: reverseBits. Line ${e.line}`),null}Round(e,t){const i=this.exec.evalExpression(e.args[0],t);if(i instanceof Ng)return new Ng(i.data.map(e=>Math.round(e)),i.typeInfo);const r=i;return new zg(Math.round(r.value),i.typeInfo)}Saturate(e,t){const i=this.exec.evalExpression(e.args[0],t);if(i instanceof Ng)return new Ng(i.data.map(e=>Math.min(Math.max(e,0),1)),i.typeInfo);const r=i;return new zg(Math.min(Math.max(r.value,0),1),i.typeInfo)}Sign(e,t){const i=this.exec.evalExpression(e.args[0],t);if(i instanceof Ng)return new Ng(i.data.map(e=>Math.sign(e)),i.typeInfo);const r=i;return new zg(Math.sign(r.value),i.typeInfo)}Sin(e,t){const i=this.exec.evalExpression(e.args[0],t);if(i instanceof Ng)return new Ng(i.data.map(e=>Math.sin(e)),i.typeInfo);const r=i;return new zg(Math.sin(r.value),i.typeInfo)}Sinh(e,t){const i=this.exec.evalExpression(e.args[0],t);if(i instanceof Ng)return new Ng(i.data.map(e=>Math.sinh(e)),i.typeInfo);const r=i;return new zg(Math.sinh(r.value),i.typeInfo)}_smoothstep(e,t,i){const r=Math.min(Math.max((i-e)/(t-e),0),1);return r*r*(3-2*r)}SmoothStep(e,t){const i=this.exec.evalExpression(e.args[0],t),r=this.exec.evalExpression(e.args[1],t),n=this.exec.evalExpression(e.args[2],t);if(n instanceof Ng&&i instanceof Ng&&r instanceof Ng)return new Ng(n.data.map((e,t)=>this._smoothstep(i.data[t],r.data[t],e)),n.typeInfo);const o=i,s=r,a=n;return new zg(this._smoothstep(o.value,s.value,a.value),n.typeInfo)}Sqrt(e,t){const i=this.exec.evalExpression(e.args[0],t);if(i instanceof Ng)return new Ng(i.data.map(e=>Math.sqrt(e)),i.typeInfo);const r=i;return new zg(Math.sqrt(r.value),i.typeInfo)}Step(e,t){const i=this.exec.evalExpression(e.args[0],t),r=this.exec.evalExpression(e.args[1],t);if(r instanceof Ng&&i instanceof Ng)return new Ng(r.data.map((e,t)=>eMath.tan(e)),i.typeInfo);const r=i;return new zg(Math.tan(r.value),i.typeInfo)}Tanh(e,t){const i=this.exec.evalExpression(e.args[0],t);if(i instanceof Ng)return new Ng(i.data.map(e=>Math.tanh(e)),i.typeInfo);const r=i;return new zg(Math.tanh(r.value),i.typeInfo)}_getTransposeType(e){const t=e.getTypeName();return"mat2x2f"===t||"mat2x2h"===t?e:"mat2x3f"===t?this.getTypeInfo("mat3x2f"):"mat2x3h"===t?this.getTypeInfo("mat3x2h"):"mat2x4f"===t?this.getTypeInfo("mat4x2f"):"mat2x4h"===t?this.getTypeInfo("mat4x2h"):"mat3x2f"===t?this.getTypeInfo("mat2x3f"):"mat3x2h"===t?this.getTypeInfo("mat2x3h"):"mat3x3f"===t||"mat3x3h"===t?e:"mat3x4f"===t?this.getTypeInfo("mat4x3f"):"mat3x4h"===t?this.getTypeInfo("mat4x3h"):"mat4x2f"===t?this.getTypeInfo("mat2x4f"):"mat4x2h"===t?this.getTypeInfo("mat2x4h"):"mat4x3f"===t?this.getTypeInfo("mat3x4f"):"mat4x3h"===t?this.getTypeInfo("mat3x4h"):("mat4x4f"===t||"mat4x4h"===t||console.error(`Invalid matrix type ${t}`),e)}Transpose(e,t){const i=this.exec.evalExpression(e.args[0],t);if(!(i instanceof Vg))return console.error(`Transpose() expects a matrix argument. Line ${e.line}`),null;const r=this._getTransposeType(i.typeInfo);if("mat2x2"===i.typeInfo.name||"mat2x2f"===i.typeInfo.name||"mat2x2h"===i.typeInfo.name){const e=i.data;return new Vg([e[0],e[2],e[1],e[3]],r)}if("mat2x3"===i.typeInfo.name||"mat2x3f"===i.typeInfo.name||"mat2x3h"===i.typeInfo.name){const e=i.data;return new Vg([e[0],e[3],e[6],e[1],e[4],e[7]],r)}if("mat2x4"===i.typeInfo.name||"mat2x4f"===i.typeInfo.name||"mat2x4h"===i.typeInfo.name){const e=i.data;return new Vg([e[0],e[4],e[8],e[12],e[1],e[5],e[9],e[13]],r)}if("mat3x2"===i.typeInfo.name||"mat3x2f"===i.typeInfo.name||"mat3x2h"===i.typeInfo.name){const e=i.data;return new Vg([e[0],e[3],e[1],e[4],e[2],e[5]],r)}if("mat3x3"===i.typeInfo.name||"mat3x3f"===i.typeInfo.name||"mat3x3h"===i.typeInfo.name){const e=i.data;return new Vg([e[0],e[3],e[6],e[1],e[4],e[7],e[2],e[5],e[8]],r)}if("mat3x4"===i.typeInfo.name||"mat3x4f"===i.typeInfo.name||"mat3x4h"===i.typeInfo.name){const e=i.data;return new Vg([e[0],e[4],e[8],e[12],e[1],e[5],e[9],e[13],e[2],e[6],e[10],e[14]],r)}if("mat4x2"===i.typeInfo.name||"mat4x2f"===i.typeInfo.name||"mat4x2h"===i.typeInfo.name){const e=i.data;return new Vg([e[0],e[4],e[1],e[5],e[2],e[6]],r)}if("mat4x3"===i.typeInfo.name||"mat4x3f"===i.typeInfo.name||"mat4x3h"===i.typeInfo.name){const e=i.data;return new Vg([e[0],e[4],e[8],e[1],e[5],e[9],e[2],e[6],e[10]],r)}if("mat4x4"===i.typeInfo.name||"mat4x4f"===i.typeInfo.name||"mat4x4h"===i.typeInfo.name){const e=i.data;return new Vg([e[0],e[4],e[8],e[12],e[1],e[5],e[9],e[13],e[2],e[6],e[10],e[14],e[3],e[7],e[11],e[15]],r)}return console.error(`Invalid matrix type ${i.typeInfo.name}`),null}Trunc(e,t){const i=this.exec.evalExpression(e.args[0],t);if(i instanceof Ng)return new Ng(i.data.map(e=>Math.trunc(e)),i.typeInfo);const r=i;return new zg(Math.trunc(r.value),i.typeInfo)}Dpdx(e,t){return console.error(`TODO: dpdx. Line ${e.line}`),null}DpdxCoarse(e,t){return console.error(`TODO: dpdxCoarse. Line ${e.line}`),null}DpdxFine(e,t){return console.error("TODO: dpdxFine"),null}Dpdy(e,t){return console.error("TODO: dpdy"),null}DpdyCoarse(e,t){return console.error("TODO: dpdyCoarse"),null}DpdyFine(e,t){return console.error("TODO: dpdyFine"),null}Fwidth(e,t){return console.error("TODO: fwidth"),null}FwidthCoarse(e,t){return console.error("TODO: fwidthCoarse"),null}FwidthFine(e,t){return console.error("TODO: fwidthFine"),null}TextureDimensions(e,t){const i=e.args[0],r=e.args.length>1?this.exec.evalExpression(e.args[1],t).value:0;if(i instanceof yg){const n=i.name,o=t.getVariableValue(n);if(o instanceof Gg){if(r<0||r>=o.mipLevelCount)return console.error(`Invalid mip level for textureDimensions. Line ${e.line}`),null;const t=o.getMipLevelSize(r),i=o.dimension;return"1d"===i?new zg(t[0],this.getTypeInfo("u32")):"3d"===i?new Ng(t,this.getTypeInfo("vec3u")):"2d"===i?new Ng(t.slice(0,2),this.getTypeInfo("vec2u")):(console.error(`Invalid texture dimension ${i} not found. Line ${e.line}`),null)}return console.error(`Texture ${n} not found. Line ${e.line}`),null}return console.error(`Invalid texture argument for textureDimensions. Line ${e.line}`),null}TextureGather(e,t){return console.error("TODO: textureGather"),null}TextureGatherCompare(e,t){return console.error("TODO: textureGatherCompare"),null}TextureLoad(e,t){const i=e.args[0],r=this.exec.evalExpression(e.args[1],t),n=e.args.length>2?this.exec.evalExpression(e.args[2],t).value:0;if(!(r instanceof Ng)||2!==r.data.length)return console.error(`Invalid UV argument for textureLoad. Line ${e.line}`),null;if(i instanceof yg){const o=i.name,s=t.getVariableValue(o);if(s instanceof Gg){const t=Math.floor(r.data[0]),i=Math.floor(r.data[1]);if(t<0||t>=s.width||i<0||i>=s.height)return console.error(`Texture ${o} out of bounds. Line ${e.line}`),null;const a=s.getPixel(t,i,0,n);return null===a?(console.error(`Invalid texture format for textureLoad. Line ${e.line}`),null):new Ng(a,this.getTypeInfo("vec4f"))}return console.error(`Texture ${o} not found. Line ${e.line}`),null}return console.error(`Invalid texture argument for textureLoad. Line ${e.line}`),null}TextureNumLayers(e,t){const i=e.args[0];if(i instanceof yg){const r=i.name,n=t.getVariableValue(r);return n instanceof Gg?new zg(n.depthOrArrayLayers,this.getTypeInfo("u32")):(console.error(`Texture ${r} not found. Line ${e.line}`),null)}return console.error(`Invalid texture argument for textureNumLayers. Line ${e.line}`),null}TextureNumLevels(e,t){const i=e.args[0];if(i instanceof yg){const r=i.name,n=t.getVariableValue(r);return n instanceof Gg?new zg(n.mipLevelCount,this.getTypeInfo("u32")):(console.error(`Texture ${r} not found. Line ${e.line}`),null)}return console.error(`Invalid texture argument for textureNumLevels. Line ${e.line}`),null}TextureNumSamples(e,t){const i=e.args[0];if(i instanceof yg){const r=i.name,n=t.getVariableValue(r);return n instanceof Gg?new zg(n.sampleCount,this.getTypeInfo("u32")):(console.error(`Texture ${r} not found. Line ${e.line}`),null)}return console.error(`Invalid texture argument for textureNumSamples. Line ${e.line}`),null}TextureSample(e,t){return console.error("TODO: textureSample"),null}TextureSampleBias(e,t){return console.error("TODO: textureSampleBias"),null}TextureSampleCompare(e,t){return console.error("TODO: textureSampleCompare"),null}TextureSampleCompareLevel(e,t){return console.error("TODO: textureSampleCompareLevel"),null}TextureSampleGrad(e,t){return console.error("TODO: textureSampleGrad"),null}TextureSampleLevel(e,t){return console.error("TODO: textureSampleLevel"),null}TextureSampleBaseClampToEdge(e,t){return console.error("TODO: textureSampleBaseClampToEdge"),null}TextureStore(e,t){const i=e.args[0],r=this.exec.evalExpression(e.args[1],t),n=4===e.args.length?this.exec.evalExpression(e.args[2],t).value:0,o=4===e.args.length?this.exec.evalExpression(e.args[3],t).data:this.exec.evalExpression(e.args[2],t).data;if(4!==o.length)return console.error(`Invalid value argument for textureStore. Line ${e.line}`),null;if(!(r instanceof Ng)||2!==r.data.length)return console.error(`Invalid UV argument for textureStore. Line ${e.line}`),null;if(i instanceof yg){const s=i.name,a=t.getVariableValue(s);if(a instanceof Gg){const t=a.getMipLevelSize(0),i=Math.floor(r.data[0]),l=Math.floor(r.data[1]);return i<0||i>=t[0]||l<0||l>=t[1]?(console.error(`Texture ${s} out of bounds. Line ${e.line}`),null):(a.setPixel(i,l,0,n,Array.from(o)),null)}return console.error(`Texture ${s} not found. Line ${e.line}`),null}return console.error(`Invalid texture argument for textureStore. Line ${e.line}`),null}AtomicLoad(e,t){let i=e.args[0];i instanceof Eg&&(i=i.right);const r=this.exec.getVariableName(i,t);return t.getVariable(r).value.getSubData(this.exec,i.postfix,t)}AtomicStore(e,t){let i=e.args[0];i instanceof Eg&&(i=i.right);const r=this.exec.getVariableName(i,t),n=t.getVariable(r);let o=e.args[1];const s=this.exec.evalExpression(o,t),a=n.value.getSubData(this.exec,i.postfix,t);return a instanceof zg&&s instanceof zg&&(a.value=s.value),n.value instanceof jg&&n.value.setDataValue(this.exec,a,i.postfix,t),null}AtomicAdd(e,t){let i=e.args[0];i instanceof Eg&&(i=i.right);const r=this.exec.getVariableName(i,t),n=t.getVariable(r);let o=e.args[1];const s=this.exec.evalExpression(o,t),a=n.value.getSubData(this.exec,i.postfix,t),l=new zg(a.value,a.typeInfo);return a instanceof zg&&s instanceof zg&&(a.value+=s.value),n.value instanceof jg&&n.value.setDataValue(this.exec,a,i.postfix,t),l}AtomicSub(e,t){let i=e.args[0];i instanceof Eg&&(i=i.right);const r=this.exec.getVariableName(i,t),n=t.getVariable(r);let o=e.args[1];const s=this.exec.evalExpression(o,t),a=n.value.getSubData(this.exec,i.postfix,t),l=new zg(a.value,a.typeInfo);return a instanceof zg&&s instanceof zg&&(a.value-=s.value),n.value instanceof jg&&n.value.setDataValue(this.exec,a,i.postfix,t),l}AtomicMax(e,t){let i=e.args[0];i instanceof Eg&&(i=i.right);const r=this.exec.getVariableName(i,t),n=t.getVariable(r);let o=e.args[1];const s=this.exec.evalExpression(o,t),a=n.value.getSubData(this.exec,i.postfix,t),l=new zg(a.value,a.typeInfo);return a instanceof zg&&s instanceof zg&&(a.value=Math.max(a.value,s.value)),n.value instanceof jg&&n.value.setDataValue(this.exec,a,i.postfix,t),l}AtomicMin(e,t){let i=e.args[0];i instanceof Eg&&(i=i.right);const r=this.exec.getVariableName(i,t),n=t.getVariable(r);let o=e.args[1];const s=this.exec.evalExpression(o,t),a=n.value.getSubData(this.exec,i.postfix,t),l=new zg(a.value,a.typeInfo);return a instanceof zg&&s instanceof zg&&(a.value=Math.min(a.value,s.value)),n.value instanceof jg&&n.value.setDataValue(this.exec,a,i.postfix,t),l}AtomicAnd(e,t){let i=e.args[0];i instanceof Eg&&(i=i.right);const r=this.exec.getVariableName(i,t),n=t.getVariable(r);let o=e.args[1];const s=this.exec.evalExpression(o,t),a=n.value.getSubData(this.exec,i.postfix,t),l=new zg(a.value,a.typeInfo);return a instanceof zg&&s instanceof zg&&(a.value=a.value&s.value),n.value instanceof jg&&n.value.setDataValue(this.exec,a,i.postfix,t),l}AtomicOr(e,t){let i=e.args[0];i instanceof Eg&&(i=i.right);const r=this.exec.getVariableName(i,t),n=t.getVariable(r);let o=e.args[1];const s=this.exec.evalExpression(o,t),a=n.value.getSubData(this.exec,i.postfix,t),l=new zg(a.value,a.typeInfo);return a instanceof zg&&s instanceof zg&&(a.value=a.value|s.value),n.value instanceof jg&&n.value.setDataValue(this.exec,a,i.postfix,t),l}AtomicXor(e,t){let i=e.args[0];i instanceof Eg&&(i=i.right);const r=this.exec.getVariableName(i,t),n=t.getVariable(r);let o=e.args[1];const s=this.exec.evalExpression(o,t),a=n.value.getSubData(this.exec,i.postfix,t),l=new zg(a.value,a.typeInfo);return a instanceof zg&&s instanceof zg&&(a.value=a.value^s.value),n.value instanceof jg&&n.value.setDataValue(this.exec,a,i.postfix,t),l}AtomicExchange(e,t){let i=e.args[0];i instanceof Eg&&(i=i.right);const r=this.exec.getVariableName(i,t),n=t.getVariable(r);let o=e.args[1];const s=this.exec.evalExpression(o,t),a=n.value.getSubData(this.exec,i.postfix,t),l=new zg(a.value,a.typeInfo);return a instanceof zg&&s instanceof zg&&(a.value=s.value),n.value instanceof jg&&n.value.setDataValue(this.exec,a,i.postfix,t),l}AtomicCompareExchangeWeak(e,t){return console.error("TODO: atomicCompareExchangeWeak"),null}Pack4x8snorm(e,t){return console.error("TODO: pack4x8snorm"),null}Pack4x8unorm(e,t){return console.error("TODO: pack4x8unorm"),null}Pack4xI8(e,t){return console.error("TODO: pack4xI8"),null}Pack4xU8(e,t){return console.error("TODO: pack4xU8"),null}Pack4x8Clamp(e,t){return console.error("TODO: pack4x8Clamp"),null}Pack4xU8Clamp(e,t){return console.error("TODO: pack4xU8Clamp"),null}Pack2x16snorm(e,t){return console.error("TODO: pack2x16snorm"),null}Pack2x16unorm(e,t){return console.error("TODO: pack2x16unorm"),null}Pack2x16float(e,t){return console.error("TODO: pack2x16float"),null}Unpack4x8snorm(e,t){return console.error("TODO: unpack4x8snorm"),null}Unpack4x8unorm(e,t){return console.error("TODO: unpack4x8unorm"),null}Unpack4xI8(e,t){return console.error("TODO: unpack4xI8"),null}Unpack4xU8(e,t){return console.error("TODO: unpack4xU8"),null}Unpack2x16snorm(e,t){return console.error("TODO: unpack2x16snorm"),null}Unpack2x16unorm(e,t){return console.error("TODO: unpack2x16unorm"),null}Unpack2x16float(e,t){return console.error("TODO: unpack2x16float"),null}StorageBarrier(e,t){return null}TextureBarrier(e,t){return null}WorkgroupBarrier(e,t){return null}WorkgroupUniformLoad(e,t){return null}SubgroupAdd(e,t){return console.error("TODO: subgroupAdd"),null}SubgroupExclusiveAdd(e,t){return console.error("TODO: subgroupExclusiveAdd"),null}SubgroupInclusiveAdd(e,t){return console.error("TODO: subgroupInclusiveAdd"),null}SubgroupAll(e,t){return console.error("TODO: subgroupAll"),null}SubgroupAnd(e,t){return console.error("TODO: subgroupAnd"),null}SubgroupAny(e,t){return console.error("TODO: subgroupAny"),null}SubgroupBallot(e,t){return console.error("TODO: subgroupBallot"),null}SubgroupBroadcast(e,t){return console.error("TODO: subgroupBroadcast"),null}SubgroupBroadcastFirst(e,t){return console.error("TODO: subgroupBroadcastFirst"),null}SubgroupElect(e,t){return console.error("TODO: subgroupElect"),null}SubgroupMax(e,t){return console.error("TODO: subgroupMax"),null}SubgroupMin(e,t){return console.error("TODO: subgroupMin"),null}SubgroupMul(e,t){return console.error("TODO: subgroupMul"),null}SubgroupExclusiveMul(e,t){return console.error("TODO: subgroupExclusiveMul"),null}SubgroupInclusiveMul(e,t){return console.error("TODO: subgroupInclusiveMul"),null}SubgroupOr(e,t){return console.error("TODO: subgroupOr"),null}SubgroupShuffle(e,t){return console.error("TODO: subgroupShuffle"),null}SubgroupShuffleDown(e,t){return console.error("TODO: subgroupShuffleDown"),null}SubgroupShuffleUp(e,t){return console.error("TODO: subgroupShuffleUp"),null}SubgroupShuffleXor(e,t){return console.error("TODO: subgroupShuffleXor"),null}SubgroupXor(e,t){return console.error("TODO: subgroupXor"),null}QuadBroadcast(e,t){return console.error("TODO: quadBroadcast"),null}QuadSwapDiagonal(e,t){return console.error("TODO: quadSwapDiagonal"),null}QuadSwapX(e,t){return console.error("TODO: quadSwapX"),null}QuadSwapY(e,t){return console.error("TODO: quadSwapY"),null}}const f_={vec2:2,vec2f:2,vec2i:2,vec2u:2,vec2b:2,vec2h:2,vec3:3,vec3f:3,vec3i:3,vec3u:3,vec3b:3,vec3h:3,vec4:4,vec4f:4,vec4i:4,vec4u:4,vec4b:4,vec4h:4},m_={mat2x2:[2,2,4],mat2x2f:[2,2,4],mat2x2h:[2,2,4],mat2x3:[2,3,6],mat2x3f:[2,3,6],mat2x3h:[2,3,6],mat2x4:[2,4,8],mat2x4f:[2,4,8],mat2x4h:[2,4,8],mat3x2:[3,2,6],mat3x2f:[3,2,6],mat3x2h:[3,2,6],mat3x3:[3,3,9],mat3x3f:[3,3,9],mat3x3h:[3,3,9],mat3x4:[3,4,12],mat3x4f:[3,4,12],mat3x4h:[3,4,12],mat4x2:[4,2,8],mat4x2f:[4,2,8],mat4x2h:[4,2,8],mat4x3:[4,3,12],mat4x3f:[4,3,12],mat4x3h:[4,3,12],mat4x4:[4,4,16],mat4x4f:[4,4,16],mat4x4h:[4,4,16]};class g_ extends d_{constructor(e,t){var i;super(),this.ast=null!=e?e:[],this.reflection=new a_,this.reflection.updateAST(this.ast),this.context=null!==(i=null==t?void 0:t.clone())&&void 0!==i?i:new h_,this.builtins=new p_(this),this.typeInfo={bool:this.getTypeInfo(lg.bool),i32:this.getTypeInfo(lg.i32),u32:this.getTypeInfo(lg.u32),f32:this.getTypeInfo(lg.f32),f16:this.getTypeInfo(lg.f16),vec2f:this.getTypeInfo(hg.vec2f),vec2u:this.getTypeInfo(hg.vec2u),vec2i:this.getTypeInfo(hg.vec2i),vec2h:this.getTypeInfo(hg.vec2h),vec3f:this.getTypeInfo(hg.vec3f),vec3u:this.getTypeInfo(hg.vec3u),vec3i:this.getTypeInfo(hg.vec3i),vec3h:this.getTypeInfo(hg.vec3h),vec4f:this.getTypeInfo(hg.vec4f),vec4u:this.getTypeInfo(hg.vec4u),vec4i:this.getTypeInfo(hg.vec4i),vec4h:this.getTypeInfo(hg.vec4h),mat2x2f:this.getTypeInfo(hg.mat2x2f),mat2x3f:this.getTypeInfo(hg.mat2x3f),mat2x4f:this.getTypeInfo(hg.mat2x4f),mat3x2f:this.getTypeInfo(hg.mat3x2f),mat3x3f:this.getTypeInfo(hg.mat3x3f),mat3x4f:this.getTypeInfo(hg.mat3x4f),mat4x2f:this.getTypeInfo(hg.mat4x2f),mat4x3f:this.getTypeInfo(hg.mat4x3f),mat4x4f:this.getTypeInfo(hg.mat4x4f)}}getVariableValue(e){var t,i;const r=null!==(i=null===(t=this.context.getVariable(e))||void 0===t?void 0:t.value)&&void 0!==i?i:null;if(null===r)return null;if(r instanceof zg)return r.value;if(r instanceof Ng)return Array.from(r.data);if(r instanceof Vg)return Array.from(r.data);if(r instanceof jg&&r.typeInfo instanceof am){if("u32"===r.typeInfo.format.name)return Array.from(new Uint32Array(r.buffer,r.offset,r.typeInfo.count));if("i32"===r.typeInfo.format.name)return Array.from(new Int32Array(r.buffer,r.offset,r.typeInfo.count));if("f32"===r.typeInfo.format.name)return Array.from(new Float32Array(r.buffer,r.offset,r.typeInfo.count))}return console.error(`Unsupported return variable type ${r.typeInfo.name}`),null}execute(e){(e=null!=e?e:{}).constants&&this._setOverrides(e.constants,this.context),this._execStatements(this.ast,this.context)}dispatchWorkgroups(e,t,i,r){const n=this.context.clone();(r=null!=r?r:{}).constants&&this._setOverrides(r.constants,n),this._execStatements(this.ast,n);const o=n.getFunction(e);if(!o)return void console.error(`Function ${e} not found`);if("number"==typeof t)t=[t,1,1];else{if(0===t.length)return void console.error("Invalid dispatch count");1===t.length?t=[t[0],1,1]:2===t.length?t=[t[0],t[1],1]:t.length>3&&(t=[t[0],t[1],t[2]])}const s=t[0],a=t[1],l=t[2],c=this.getTypeInfo("vec3u");n.setVariable("@num_workgroups",new Ng(t,c));const u=this.reflection.getFunctionInfo(e);null===u&&console.error(`Function ${e} not found in reflection data`);for(const e in i)for(const t in i[e]){const r=i[e][t];n.variables.forEach(i=>{var n;const o=i.node;if(null==o?void 0:o.attributes){let s=null,a=null;for(const e of o.attributes)"binding"===e.name?s=e.value:"group"===e.name&&(a=e.value);if(t==s&&e==a){let s=!1;for(const r of u.resources)if(r.name===i.name&&r.group===parseInt(e)&&r.binding===parseInt(t)){s=!0;break}if(s)if(void 0!==r.texture&&void 0!==r.descriptor){const e=new Gg(r.texture,this.getTypeInfo(o.type),r.descriptor,null!==(n=r.texture.view)&&void 0!==n?n:null);i.value=e}else void 0!==r.uniform?i.value=new jg(r.uniform,this.getTypeInfo(o.type)):i.value=new jg(r,this.getTypeInfo(o.type))}}})}for(let e=0;e0){const e=i.getVariableValue(t.value[0]);r[0]=e instanceof zg?e.value:parseInt(t.value[0])}if(t.value.length>1){const e=i.getVariableValue(t.value[1]);r[1]=e instanceof zg?e.value:parseInt(t.value[1])}if(t.value.length>2){const e=i.getVariableValue(t.value[2]);r[2]=e instanceof zg?e.value:parseInt(t.value[2])}}const n=this.getTypeInfo("vec3u"),o=this.getTypeInfo("u32");i.setVariable("@workgroup_size",new Ng(r,n));const s=r[0],a=r[1],l=r[2];for(let c=0,u=0;c",n=null;if(e.variable instanceof Eg){const i=this._getVariableData(e.variable,t),r=this.evalExpression(e.value,t),n=e.operator;if("="===n){if(i instanceof zg||i instanceof Ng||i instanceof Vg){if(r instanceof zg||r instanceof Ng||r instanceof Vg&&i.data.length===r.data.length)return void i.data.set(r.data);console.error(`Invalid assignment. Line ${e.line}`)}else if(i instanceof jg&&r instanceof jg&&i.buffer.byteLength-i.offset>=r.buffer.byteLength-r.offset)return void(i.buffer.byteLength%4==0?new Uint32Array(i.buffer,i.offset,i.typeInfo.size/4).set(new Uint32Array(r.buffer,r.offset,r.typeInfo.size/4)):new Uint8Array(i.buffer,i.offset,i.typeInfo.size).set(new Uint8Array(r.buffer,r.offset,r.typeInfo.size)));return console.error(`Invalid assignment. Line ${e.line}`),null}if("+="===n)return i instanceof zg||i instanceof Ng||i instanceof Vg?r instanceof zg||r instanceof Ng||r instanceof Vg?void i.data.set(r.data.map((e,t)=>i.data[t]+e)):void console.error(`Invalid assignment . Line ${e.line}`):void console.error(`Invalid assignment. Line ${e.line}`);if("-="===n)return(i instanceof zg||i instanceof Ng||i instanceof Vg)&&(r instanceof zg||r instanceof Ng||r instanceof Vg)?void i.data.set(r.data.map((e,t)=>i.data[t]-e)):void console.error(`Invalid assignment. Line ${e.line}`)}if(e.variable instanceof Eg){if("*"===e.variable.operator){r=this.getVariableName(e.variable.right,t);const n=t.getVariable(r);if(!(n&&n.value instanceof Og))return void console.error(`Variable ${r} is not a pointer. Line ${e.line}`);i=n.value.reference;let o=e.variable.postfix;if(!o){let t=e.variable.right;for(;t instanceof Eg;){if(t.postfix){o=t.postfix;break}t=t.right}}o&&(i=i.getSubData(this,o,t))}}else{n=e.variable.postfix,r=this.getVariableName(e.variable,t);const o=t.getVariable(r);if(null===o)return void console.error(`Variable ${r} not found. Line ${e.line}`);i=o.value}if(i instanceof Og&&(i=i.reference),null===i)return void console.error(`Variable ${r} not found. Line ${e.line}`);const o=this.evalExpression(e.value,t),s=e.operator;if("="!==s){const r=i.getSubData(this,n,t);if(r instanceof Ng&&o instanceof zg){const t=r.data,i=o.value;if("+="===s)for(let e=0;e>="===s)for(let e=0;e>=i;else console.error(`Invalid operator ${s}. Line ${e.line}`)}else if(r instanceof Ng&&o instanceof Ng){const t=r.data,i=o.data;if(t.length!==i.length)return void console.error(`Vector length mismatch. Line ${e.line}`);if("+="===s)for(let e=0;e>="===s)for(let e=0;e>=i[e];else console.error(`Invalid operator ${s}. Line ${e.line}`)}else{if(!(r instanceof zg&&o instanceof zg))return void console.error(`Invalid type for ${e.operator} operator. Line ${e.line}`);"+="===s?r.value+=o.value:"-="===s?r.value-=o.value:"*="===s?r.value*=o.value:"/="===s?r.value/=o.value:"%="===s?r.value%=o.value:"&="===s?r.value&=o.value:"|="===s?r.value|=o.value:"^="===s?r.value^=o.value:"<<="===s?r.value<<=o.value:">>="===s?r.value>>=o.value:console.error(`Invalid operator ${s}. Line ${e.line}`)}return void(i instanceof jg&&i.setDataValue(this,r,n,t))}if(i instanceof jg)i.setDataValue(this,o,n,t);else if(n){if(!(i instanceof Ng||i instanceof Vg))return void console.error(`Variable ${r} is not a vector or matrix. Line ${e.line}`);if(n instanceof wg){const s=this.evalExpression(n.index,t).value;if(i instanceof Ng){if(!(o instanceof zg))return void console.error(`Invalid assignment to ${r}. Line ${e.line}`);i.data[s]=o.value}else{if(!(i instanceof Vg))return void console.error(`Invalid assignment to ${r}. Line ${e.line}`);{const s=this.evalExpression(n.index,t).value;if(s<0)return void console.error(`Invalid assignment to ${r}. Line ${e.line}`);if(!(o instanceof Ng))return void console.error(`Invalid assignment to ${r}. Line ${e.line}`);{const t=i.typeInfo.getTypeName();if("mat2x2"===t||"mat2x2f"===t||"mat2x2h"===t){if(!(s<2&&2===o.data.length))return void console.error(`Invalid assignment to ${r}. Line ${e.line}`);i.data[2*s]=o.data[0],i.data[2*s+1]=o.data[1]}else if("mat2x3"===t||"mat2x3f"===t||"mat2x3h"===t){if(!(s<2&&3===o.data.length))return void console.error(`Invalid assignment to ${r}. Line ${e.line}`);i.data[3*s]=o.data[0],i.data[3*s+1]=o.data[1],i.data[3*s+2]=o.data[2]}else if("mat2x4"===t||"mat2x4f"===t||"mat2x4h"===t){if(!(s<2&&4===o.data.length))return void console.error(`Invalid assignment to ${r}. Line ${e.line}`);i.data[4*s]=o.data[0],i.data[4*s+1]=o.data[1],i.data[4*s+2]=o.data[2],i.data[4*s+3]=o.data[3]}else if("mat3x2"===t||"mat3x2f"===t||"mat3x2h"===t){if(!(s<3&&2===o.data.length))return void console.error(`Invalid assignment to ${r}. Line ${e.line}`);i.data[2*s]=o.data[0],i.data[2*s+1]=o.data[1]}else if("mat3x3"===t||"mat3x3f"===t||"mat3x3h"===t){if(!(s<3&&3===o.data.length))return void console.error(`Invalid assignment to ${r}. Line ${e.line}`);i.data[3*s]=o.data[0],i.data[3*s+1]=o.data[1],i.data[3*s+2]=o.data[2]}else if("mat3x4"===t||"mat3x4f"===t||"mat3x4h"===t){if(!(s<3&&4===o.data.length))return void console.error(`Invalid assignment to ${r}. Line ${e.line}`);i.data[4*s]=o.data[0],i.data[4*s+1]=o.data[1],i.data[4*s+2]=o.data[2],i.data[4*s+3]=o.data[3]}else if("mat4x2"===t||"mat4x2f"===t||"mat4x2h"===t){if(!(s<4&&2===o.data.length))return void console.error(`Invalid assignment to ${r}. Line ${e.line}`);i.data[2*s]=o.data[0],i.data[2*s+1]=o.data[1]}else if("mat4x3"===t||"mat4x3f"===t||"mat4x3h"===t){if(!(s<4&&3===o.data.length))return void console.error(`Invalid assignment to ${r}. Line ${e.line}`);i.data[3*s]=o.data[0],i.data[3*s+1]=o.data[1],i.data[3*s+2]=o.data[2]}else{if("mat4x4"!==t&&"mat4x4f"!==t&&"mat4x4h"!==t)return void console.error(`Invalid assignment to ${r}. Line ${e.line}`);if(!(s<4&&4===o.data.length))return void console.error(`Invalid assignment to ${r}. Line ${e.line}`);i.data[4*s]=o.data[0],i.data[4*s+1]=o.data[1],i.data[4*s+2]=o.data[2],i.data[4*s+3]=o.data[3]}}}}}else if(n instanceof gg){const t=n.value;if(!(i instanceof Ng))return void console.error(`Invalid assignment to ${t}. Variable ${r} is not a vector. Line ${e.line}`);if(o instanceof zg){if(t.length>1)return void console.error(`Invalid assignment to ${t} for variable ${r}. Line ${e.line}`);if("x"===t)i.data[0]=o.value;else if("y"===t){if(i.data.length<2)return void console.error(`Invalid assignment to ${t} for variable ${r}. Line ${e.line}`);i.data[1]=o.value}else if("z"===t){if(i.data.length<3)return void console.error(`Invalid assignment to ${t} for variable ${r}. Line ${e.line}`);i.data[2]=o.value}else if("w"===t){if(i.data.length<4)return void console.error(`Invalid assignment to ${t} for variable ${r}. Line ${e.line}`);i.data[3]=o.value}}else{if(!(o instanceof Ng))return void console.error(`Invalid assignment to ${r}. Line ${e.line}`);if(t.length!==o.data.length)return void console.error(`Invalid assignment to ${t} for variable ${r}. Line ${e.line}`);for(let n=0;n+e);return new Ng(e,i.typeInfo)}const e=r,t=this._maxFormatTypeInfo([i.typeInfo,i.typeInfo]);return new zg(+e,t)}case"-":{if(Wg(r)){const e=r.map((e,t)=>-e);return new Ng(e,i.typeInfo)}const e=r,t=this._maxFormatTypeInfo([i.typeInfo,i.typeInfo]);return new zg(-e,t)}case"!":{if(Wg(r)){const e=r.map((e,t)=>e?0:1);return new Ng(e,i.typeInfo)}const e=r,t=this._maxFormatTypeInfo([i.typeInfo,i.typeInfo]);return new zg(e?0:1,t)}case"~":{if(Wg(r)){const e=r.map((e,t)=>~e);return new Ng(e,i.typeInfo)}const e=r,t=this._maxFormatTypeInfo([i.typeInfo,i.typeInfo]);return new zg(~e,t)}}return console.error(`Invalid unary operator ${e.operator}. Line ${e.line}`),null}_evalBinaryOp(e,t){const i=this.evalExpression(e.left,t),r=this.evalExpression(e.right,t),n=i instanceof zg?i.value:i instanceof Ng||i instanceof Vg?Array.from(i.data):null,o=r instanceof zg?r.value:r instanceof Ng||r instanceof Vg?Array.from(r.data):null;switch(e.operator){case"+":{if(Wg(n)&&Wg(o)){const t=n,r=o;if(t.length!==r.length)return console.error(`Vector length mismatch. Line ${e.line}.`),null;const s=t.map((e,t)=>e+r[t]);return new Ng(s,i.typeInfo)}if(Wg(n)){const e=o,t=n.map((t,i)=>t+e);return new Ng(t,i.typeInfo)}if(Wg(o)){const e=n,t=o.map((t,i)=>e+t);return new Ng(t,r.typeInfo)}const t=n,s=o,a=this._maxFormatTypeInfo([i.typeInfo,r.typeInfo]);return new zg(t+s,a)}case"-":{if(Wg(n)&&Wg(o)){const t=n,r=o;if(t.length!==r.length)return console.error(`Vector length mismatch. Line ${e.line}.`),null;const s=t.map((e,t)=>e-r[t]);return new Ng(s,i.typeInfo)}if(Wg(n)){const e=o,t=n.map((t,i)=>t-e);return new Ng(t,i.typeInfo)}if(Wg(o)){const e=n,t=o.map((t,i)=>e-t);return new Ng(t,r.typeInfo)}const t=n,s=o,a=this._maxFormatTypeInfo([i.typeInfo,r.typeInfo]);return new zg(t-s,a)}case"*":{if(Wg(n)&&Wg(o)){const t=n,s=o;if(i instanceof Vg&&r instanceof Vg){const n=function(e,t,i,r){if(void 0===m_[t.name]||void 0===m_[r.name])return null;const n=m_[t.name][0],o=m_[t.name][1],s=m_[r.name][0];if(n!==m_[r.name][1])return null;const a=new Array(s*o);for(let t=0;te*s[t]);return new Ng(r,i.typeInfo)}}if(Wg(n)){const e=o,t=n.map((t,i)=>t*e);return i instanceof Vg?new Vg(t,i.typeInfo):new Ng(t,i.typeInfo)}if(Wg(o)){const e=n,t=o.map((t,i)=>e*t);return r instanceof Vg?new Vg(t,r.typeInfo):new Ng(t,r.typeInfo)}const t=n,s=o,a=this._maxFormatTypeInfo([i.typeInfo,r.typeInfo]);return new zg(t*s,a)}case"%":{if(Wg(n)&&Wg(o)){const t=n,r=o;if(t.length!==r.length)return console.error(`Vector length mismatch. Line ${e.line}.`),null;const s=t.map((e,t)=>e%r[t]);return new Ng(s,i.typeInfo)}if(Wg(n)){const e=o,t=n.map((t,i)=>t%e);return new Ng(t,i.typeInfo)}if(Wg(o)){const e=n,t=o.map((t,i)=>e%t);return new Ng(t,r.typeInfo)}const t=n,s=o,a=this._maxFormatTypeInfo([i.typeInfo,r.typeInfo]);return new zg(t%s,a)}case"/":{if(Wg(n)&&Wg(o)){const t=n,r=o;if(t.length!==r.length)return console.error(`Vector length mismatch. Line ${e.line}.`),null;const s=t.map((e,t)=>e/r[t]);return new Ng(s,i.typeInfo)}if(Wg(n)){const e=o,t=n.map((t,i)=>t/e);return new Ng(t,i.typeInfo)}if(Wg(o)){const e=n,t=o.map((t,i)=>e/t);return new Ng(t,r.typeInfo)}const t=n,s=o,a=this._maxFormatTypeInfo([i.typeInfo,r.typeInfo]);return new zg(t/s,a)}case"&":{if(Wg(n)&&Wg(o)){const t=n,r=o;if(t.length!==r.length)return console.error(`Vector length mismatch. Line ${e.line}.`),null;const s=t.map((e,t)=>e&r[t]);return new Ng(s,i.typeInfo)}if(Wg(n)){const e=o,t=n.map((t,i)=>t&e);return new Ng(t,i.typeInfo)}if(Wg(o)){const e=n,t=o.map((t,i)=>e&t);return new Ng(t,r.typeInfo)}const t=n,s=o,a=this._maxFormatTypeInfo([i.typeInfo,r.typeInfo]);return new zg(t&s,a)}case"|":{if(Wg(n)&&Wg(o)){const t=n,r=o;if(t.length!==r.length)return console.error(`Vector length mismatch. Line ${e.line}.`),null;const s=t.map((e,t)=>e|r[t]);return new Ng(s,i.typeInfo)}if(Wg(n)){const e=o,t=n.map((t,i)=>t|e);return new Ng(t,i.typeInfo)}if(Wg(o)){const e=n,t=o.map((t,i)=>e|t);return new Ng(t,r.typeInfo)}const t=n,s=o,a=this._maxFormatTypeInfo([i.typeInfo,r.typeInfo]);return new zg(t|s,a)}case"^":{if(Wg(n)&&Wg(o)){const t=n,r=o;if(t.length!==r.length)return console.error(`Vector length mismatch. Line ${e.line}.`),null;const s=t.map((e,t)=>e^r[t]);return new Ng(s,i.typeInfo)}if(Wg(n)){const e=o,t=n.map((t,i)=>t^e);return new Ng(t,i.typeInfo)}if(Wg(o)){const e=n,t=o.map((t,i)=>e^t);return new Ng(t,r.typeInfo)}const t=n,s=o,a=this._maxFormatTypeInfo([i.typeInfo,r.typeInfo]);return new zg(t^s,a)}case"<<":{if(Wg(n)&&Wg(o)){const t=n,r=o;if(t.length!==r.length)return console.error(`Vector length mismatch. Line ${e.line}.`),null;const s=t.map((e,t)=>e<t<e<>":{if(Wg(n)&&Wg(o)){const t=n,r=o;if(t.length!==r.length)return console.error(`Vector length mismatch. Line ${e.line}.`),null;const s=t.map((e,t)=>e>>r[t]);return new Ng(s,i.typeInfo)}if(Wg(n)){const e=o,t=n.map((t,i)=>t>>e);return new Ng(t,i.typeInfo)}if(Wg(o)){const e=n,t=o.map((t,i)=>e>>t);return new Ng(t,r.typeInfo)}const t=n,s=o,a=this._maxFormatTypeInfo([i.typeInfo,r.typeInfo]);return new zg(t>>s,a)}case">":if(Wg(n)&&Wg(o)){const t=n,r=o;if(t.length!==r.length)return console.error(`Vector length mismatch. Line ${e.line}.`),null;const s=t.map((e,t)=>e>r[t]?1:0);return new Ng(s,i.typeInfo)}if(Wg(n)){const e=o,t=n.map((t,i)=>t>e?1:0);return new Ng(t,i.typeInfo)}if(Wg(o)){const e=n,t=o.map((t,i)=>e>t?1:0);return new Ng(t,r.typeInfo)}return new zg(n>o?1:0,this.getTypeInfo("bool"));case"<":if(Wg(n)&&Wg(o)){const t=n,r=o;if(t.length!==r.length)return console.error(`Vector length mismatch. Line ${e.line}.`),null;const s=t.map((e,t)=>etee===r[t]?1:0);return new Ng(s,i.typeInfo)}if(Wg(n)){const e=o,t=n.map((t,i)=>t==e?1:0);return new Ng(t,i.typeInfo)}if(Wg(o)){const e=n,t=o.map((t,i)=>e==t?1:0);return new Ng(t,r.typeInfo)}return new zg(n===o?1:0,this.getTypeInfo("bool"));case"!=":if(Wg(n)&&Wg(o)){const t=n,r=o;if(t.length!==r.length)return console.error(`Vector length mismatch. Line ${e.line}.`),null;const s=t.map((e,t)=>e!==r[t]?1:0);return new Ng(s,i.typeInfo)}if(Wg(n)){const e=o,t=n.map((t,i)=>t!==e?1:0);return new Ng(t,i.typeInfo)}if(Wg(o)){const e=n,t=o.map((t,i)=>e!==t?1:0);return new Ng(t,r.typeInfo)}return new zg(n!==o?1:0,this.getTypeInfo("bool"));case">=":if(Wg(n)&&Wg(o)){const t=n,r=o;if(t.length!==r.length)return console.error(`Vector length mismatch. Line ${e.line}.`),null;const s=t.map((e,t)=>e>=r[t]?1:0);return new Ng(s,i.typeInfo)}if(Wg(n)){const e=o,t=n.map((t,i)=>t>=e?1:0);return new Ng(t,i.typeInfo)}if(Wg(o)){const e=n,t=o.map((t,i)=>e>=t?1:0);return new Ng(t,r.typeInfo)}return new zg(n>=o?1:0,this.getTypeInfo("bool"));case"<=":if(Wg(n)&&Wg(o)){const t=n,r=o;if(t.length!==r.length)return console.error(`Vector length mismatch. Line ${e.line}.`),null;const s=t.map((e,t)=>e<=r[t]?1:0);return new Ng(s,i.typeInfo)}if(Wg(n)){const e=o,t=n.map((t,i)=>t<=e?1:0);return new Ng(t,i.typeInfo)}if(Wg(o)){const e=n,t=o.map((t,i)=>e<=t?1:0);return new Ng(t,r.typeInfo)}return new zg(n<=o?1:0,this.getTypeInfo("bool"));case"&&":if(Wg(n)&&Wg(o)){const t=n,r=o;if(t.length!==r.length)return console.error(`Vector length mismatch. Line ${e.line}.`),null;const s=t.map((e,t)=>e&&r[t]?1:0);return new Ng(s,i.typeInfo)}if(Wg(n)){const e=o,t=n.map((t,i)=>t&&e?1:0);return new Ng(t,i.typeInfo)}if(Wg(o)){const e=n,t=o.map((t,i)=>e&&t?1:0);return new Ng(t,r.typeInfo)}return new zg(n&&o?1:0,this.getTypeInfo("bool"));case"||":if(Wg(n)&&Wg(o)){const t=n,r=o;if(t.length!==r.length)return console.error(`Vector length mismatch. Line ${e.line}.`),null;const s=t.map((e,t)=>e||r[t]?1:0);return new Ng(s,i.typeInfo)}if(Wg(n)){const e=o,t=n.map((t,i)=>t||e?1:0);return new Ng(t,i.typeInfo)}if(Wg(o)){const e=n,t=o.map((t,i)=>e||t?1:0);return new Ng(t,r.typeInfo)}return new zg(n||o?1:0,this.getTypeInfo("bool"))}return console.error(`Unknown operator ${e.operator}. Line ${e.line}`),null}_evalCall(e,t){if(null!==e.cachedReturnValue)return e.cachedReturnValue;const i=t.clone();i.currentFunctionName=e.name;const r=t.getFunction(e.name);if(!r)return e.isBuiltin?this._callBuiltinFunction(e,i):this.getTypeInfo(e.name)?this._evalCreate(e,t):(console.error(`Unknown function "${e.name}". Line ${e.line}`),null);for(let t=0;tn?o.slice(0,n):o,i).getSubData(this,e.postfix,t)}_callConstructorMatrix(e,t){const i=this.getTypeInfo(e.type),r=e.type.getTypeName(),n=m_[r];if(void 0===n)return console.error(`Invalid matrix constructor ${r}. Line ${e.line}`),null;const o=[];if(e instanceof xg)if(e.isVector){const t=e.vectorValue;for(const e of t)o.push(e)}else o.push(e.scalarValue);else if(e.args)for(const i of e.args){const e=this.evalExpression(i,t);e instanceof Ng?o.push(...e.data):e instanceof zg?o.push(e.value):e instanceof Vg&&o.push(...e.data)}if(i instanceof cm&&null===i.format&&(i.format=this.getTypeInfo("f32")),0===o.length){const r=new Array(n[2]).fill(0);return new Vg(r,i).getSubData(this,e.postfix,t)}return o.length!==n[2]?(console.error(`Invalid matrix constructor. Line ${e.line}`),null):new Vg(o,i).getSubData(this,e.postfix,t)}}g_._breakObj=new kg(new nm("BREAK",null),null),g_._continueObj=new kg(new nm("CONTINUE",null),null),g_._priority=new Map([["f32",0],["f16",1],["u32",2],["i32",3],["x32",3]]);class __{constructor(){this.constants=new Map,this.aliases=new Map,this.structs=new Map}}class A_{constructor(){this._tokens=[],this._current=0,this._currentLine=1,this._deferArrayCountEval=[],this._currentLoop=[],this._context=new __,this._exec=new g_,this._forwardTypeCount=0}parse(e){this._initialize(e),this._deferArrayCountEval.length=0;const t=[];for(;!this._isAtEnd();){const e=this._global_decl_or_directive();if(!e)break;t.push(e)}if(this._deferArrayCountEval.length>0){for(const t of this._deferArrayCountEval){const i=t.arrayType,r=t.countNode;if(r instanceof yg){const t=r.name,n=this._context.constants.get(t);if(n)try{const e=n.constEvaluate(this._exec);i.count=e}catch(e){}}}this._deferArrayCountEval.length=0}if(this._forwardTypeCount>0)for(const e of t)e.search(e=>{e instanceof Lg||e instanceof dg?e.type=this._forwardType(e.type):e instanceof pg?e.format=this._forwardType(e.format):e instanceof Nm||e instanceof jm||e instanceof Gm?e.type=this._forwardType(e.type):e instanceof km?e.returnType=this._forwardType(e.returnType):e instanceof Pg&&(e.type=this._forwardType(e.type))});return t}_forwardType(e){if(e instanceof cg){const t=this._getType(e.name);if(t)return t}else e instanceof dg?e.type=this._forwardType(e.type):e instanceof pg&&(e.format=this._forwardType(e.format));return e}_initialize(e){if(e)if("string"==typeof e){const t=new Zg(e);this._tokens=t.scanTokens()}else this._tokens=e;else this._tokens=[];this._current=0}_updateNode(e,t){return e.line=null!=t?t:this._currentLine,e}_error(e,t){return{token:e,message:t,toString:()=>`${t}`}}_isAtEnd(){return this._current>=this._tokens.length||this._peek().type==Qg.eof}_match(e){if(e instanceof Hg)return!!this._check(e)&&(this._advance(),!0);for(let t=0,i=e.length;t0){const e=this._currentLoop[this._currentLoop.length-1];t.loopId=e.id}e=t,this._check(Qg.keywords.if)&&(this._advance(),t.condition=this._optional_paren_expression())}else if(this._match(Qg.keywords.continue)){const t=this._updateNode(new ag);if(!(this._currentLoop.length>0))throw this._error(this._peek(),`Continue statement must be inside a loop. Line: ${t.line}`);{const e=this._currentLoop[this._currentLoop.length-1];t.loopId=e.id}e=t}else e=this._increment_decrement_statement()||this._func_call_statement()||this._assignment_statement();return null!=e&&this._consume(Qg.tokens.semicolon,"Expected ';' after statement."),e}_static_assert_statement(){if(!this._match(Qg.keywords.static_assert))return null;const e=this._currentLine,t=this._optional_paren_expression();return this._updateNode(new Dm(t),e)}_while_statement(){if(!this._match(Qg.keywords.while))return null;const e=this._updateNode(new Om(null,null));return this._currentLoop.push(e),e.condition=this._optional_paren_expression(),this._check(Qg.tokens.attr)&&this._attribute(),e.body=this._compound_statement(),this._currentLoop.pop(),e}_continuing_statement(){const e=this._currentLoop.length>0?this._currentLoop[this._currentLoop.length-1].id:-1;if(!this._match(Qg.keywords.continuing))return null;const t=this._currentLine,i=this._compound_statement();return this._updateNode(new zm(i,e),t)}_for_statement(){if(!this._match(Qg.keywords.for))return null;this._consume(Qg.tokens.paren_left,"Expected '('.");const e=this._updateNode(new Um(null,null,null,null));return this._currentLoop.push(e),e.init=this._check(Qg.tokens.semicolon)?null:this._for_init(),this._consume(Qg.tokens.semicolon,"Expected ';'."),e.condition=this._check(Qg.tokens.semicolon)?null:this._short_circuit_or_expression(),this._consume(Qg.tokens.semicolon,"Expected ';'."),e.increment=this._check(Qg.tokens.paren_right)?null:this._for_increment(),this._consume(Qg.tokens.paren_right,"Expected ')'."),this._check(Qg.tokens.attr)&&this._attribute(),e.body=this._compound_statement(),this._currentLoop.pop(),e}_for_init(){return this._variable_statement()||this._func_call_statement()||this._assignment_statement()}_for_increment(){return this._func_call_statement()||this._increment_decrement_statement()||this._assignment_statement()}_variable_statement(){if(this._check(Qg.keywords.var)){const e=this._variable_decl();if(null===e)throw this._error(this._peek(),"Variable declaration expected.");let t=null;return this._match(Qg.tokens.equal)&&(t=this._short_circuit_or_expression()),this._updateNode(new Nm(e.name,e.type,e.storage,e.access,t),e.line)}if(this._match(Qg.keywords.let)){const e=this._currentLine,t=this._consume(Qg.tokens.name,"Expected name for let.").toString();let i=null;if(this._match(Qg.tokens.colon)){const e=this._attribute();i=this._type_decl(),null!=i&&(i.attributes=e)}this._consume(Qg.tokens.equal,"Expected '=' for let.");const r=this._short_circuit_or_expression();return this._updateNode(new jm(t,i,null,null,r),e)}if(this._match(Qg.keywords.const)){const e=this._currentLine,t=this._consume(Qg.tokens.name,"Expected name for const.").toString();let i=null;if(this._match(Qg.tokens.colon)){const e=this._attribute();i=this._type_decl(),null!=i&&(i.attributes=e)}this._consume(Qg.tokens.equal,"Expected '=' for const.");const r=this._short_circuit_or_expression();return null===i&&r instanceof xg&&(i=r.type),this._updateNode(new Gm(t,i,null,null,r),e)}return null}_increment_decrement_statement(){const e=this._current,t=this._unary_expression();if(null==t)return null;if(!this._check(Qg.increment_operators))return this._current=e,null;const i=this._consume(Qg.increment_operators,"Expected increment operator");return this._updateNode(new Wm(i.type===Qg.tokens.plus_plus?Hm.increment:Hm.decrement,t))}_assignment_statement(){let e=null;const t=this._currentLine;if(this._check(Qg.tokens.brace_right))return null;let i=this._match(Qg.tokens.underscore);if(i||(e=this._unary_expression()),!i&&null==e)return null;const r=this._consume(Qg.assignment_operators,"Expected assignment operator."),n=this._short_circuit_or_expression();return this._updateNode(new qm(Qm.parse(r.lexeme),e,n),t)}_func_call_statement(){if(!this._check(Qg.tokens.ident))return null;const e=this._currentLine,t=this._current,i=this._consume(Qg.tokens.ident,"Expected function name."),r=this._argument_expression_list();return null===r?(this._current=t,null):this._updateNode(new Km(i.lexeme,r),e)}_loop_statement(){if(!this._match(Qg.keywords.loop))return null;this._check(Qg.tokens.attr)&&this._attribute(),this._consume(Qg.tokens.brace_left,"Expected '{' for loop.");const e=this._updateNode(new Xm([],null));this._currentLoop.push(e);let t=this._statement();for(;null!==t;){if(Array.isArray(t))for(let i of t)e.body.push(i);else e.body.push(t);if(t instanceof zm){e.continuing=t;break}t=this._statement()}return this._currentLoop.pop(),this._consume(Qg.tokens.brace_right,"Expected '}' for loop."),e}_switch_statement(){if(!this._match(Qg.keywords.switch))return null;const e=this._updateNode(new Jm(null,[]));if(this._currentLoop.push(e),e.condition=this._optional_paren_expression(),this._check(Qg.tokens.attr)&&this._attribute(),this._consume(Qg.tokens.brace_left,"Expected '{' for switch."),e.cases=this._switch_body(),null==e.cases||0==e.cases.length)throw this._error(this._previous(),"Expected 'case' or 'default'.");return this._consume(Qg.tokens.brace_right,"Expected '}' for switch."),this._currentLoop.pop(),e}_switch_body(){const e=[];let t=!1;for(;this._check([Qg.keywords.default,Qg.keywords.case]);){if(this._match(Qg.keywords.case)){const i=this._case_selectors();for(const e of i)if(e instanceof Sg){if(t)throw this._error(this._previous(),"Multiple default cases in switch statement.");t=!0;break}this._match(Qg.tokens.colon),this._check(Qg.tokens.attr)&&this._attribute(),this._consume(Qg.tokens.brace_left,"Exected '{' for switch case.");const r=this._case_body();this._consume(Qg.tokens.brace_right,"Exected '}' for switch case."),e.push(this._updateNode(new Ig(i,r)))}if(this._match(Qg.keywords.default)){if(t)throw this._error(this._previous(),"Multiple default cases in switch statement.");this._match(Qg.tokens.colon),this._check(Qg.tokens.attr)&&this._attribute(),this._consume(Qg.tokens.brace_left,"Exected '{' for switch default.");const i=this._case_body();this._consume(Qg.tokens.brace_right,"Exected '}' for switch default."),e.push(this._updateNode(new Mg(i)))}}return e}_case_selectors(){const e=[];for(this._match(Qg.keywords.default)?e.push(this._updateNode(new Sg)):e.push(this._shift_expression());this._match(Qg.tokens.comma);)this._match(Qg.keywords.default)?e.push(this._updateNode(new Sg)):e.push(this._shift_expression());return e}_case_body(){if(this._match(Qg.keywords.fallthrough))return this._consume(Qg.tokens.semicolon,"Expected ';'"),[];let e=this._statement();if(null==e)return[];e instanceof Array||(e=[e]);const t=this._case_body();return 0==t.length?e:[...e,t[0]]}_if_statement(){if(!this._match(Qg.keywords.if))return null;const e=this._currentLine,t=this._optional_paren_expression();this._check(Qg.tokens.attr)&&this._attribute();const i=this._compound_statement();let r=[];this._match_elseif()&&(this._check(Qg.tokens.attr)&&this._attribute(),r=this._elseif_statement(r));let n=null;return this._match(Qg.keywords.else)&&(this._check(Qg.tokens.attr)&&this._attribute(),n=this._compound_statement()),this._updateNode(new Ym(t,i,r,n),e)}_match_elseif(){return this._tokens[this._current].type===Qg.keywords.else&&this._tokens[this._current+1].type===Qg.keywords.if&&(this._advance(),this._advance(),!0)}_elseif_statement(e=[]){const t=this._optional_paren_expression(),i=this._compound_statement();return e.push(this._updateNode(new Rg(t,i))),this._match_elseif()&&(this._check(Qg.tokens.attr)&&this._attribute(),this._elseif_statement(e)),e}_return_statement(){if(!this._match(Qg.keywords.return))return null;const e=this._short_circuit_or_expression();return this._updateNode(new eg(e))}_short_circuit_or_expression(){let e=this._short_circuit_and_expr();for(;this._match(Qg.tokens.or_or);)e=this._updateNode(new Cg(this._previous().toString(),e,this._short_circuit_and_expr()));return e}_short_circuit_and_expr(){let e=this._inclusive_or_expression();for(;this._match(Qg.tokens.and_and);)e=this._updateNode(new Cg(this._previous().toString(),e,this._inclusive_or_expression()));return e}_inclusive_or_expression(){let e=this._exclusive_or_expression();for(;this._match(Qg.tokens.or);)e=this._updateNode(new Cg(this._previous().toString(),e,this._exclusive_or_expression()));return e}_exclusive_or_expression(){let e=this._and_expression();for(;this._match(Qg.tokens.xor);)e=this._updateNode(new Cg(this._previous().toString(),e,this._and_expression()));return e}_and_expression(){let e=this._equality_expression();for(;this._match(Qg.tokens.and);)e=this._updateNode(new Cg(this._previous().toString(),e,this._equality_expression()));return e}_equality_expression(){const e=this._relational_expression();return this._match([Qg.tokens.equal_equal,Qg.tokens.not_equal])?this._updateNode(new Cg(this._previous().toString(),e,this._relational_expression())):e}_relational_expression(){let e=this._shift_expression();for(;this._match([Qg.tokens.less_than,Qg.tokens.greater_than,Qg.tokens.less_than_equal,Qg.tokens.greater_than_equal]);)e=this._updateNode(new Cg(this._previous().toString(),e,this._shift_expression()));return e}_shift_expression(){let e=this._additive_expression();for(;this._match([Qg.tokens.shift_left,Qg.tokens.shift_right]);)e=this._updateNode(new Cg(this._previous().toString(),e,this._additive_expression()));return e}_additive_expression(){let e=this._multiplicative_expression();for(;this._match([Qg.tokens.plus,Qg.tokens.minus]);)e=this._updateNode(new Cg(this._previous().toString(),e,this._multiplicative_expression()));return e}_multiplicative_expression(){let e=this._unary_expression();for(;this._match([Qg.tokens.star,Qg.tokens.forward_slash,Qg.tokens.modulo]);)e=this._updateNode(new Cg(this._previous().toString(),e,this._unary_expression()));return e}_unary_expression(){return this._match([Qg.tokens.minus,Qg.tokens.bang,Qg.tokens.tilde,Qg.tokens.star,Qg.tokens.and])?this._updateNode(new Eg(this._previous().toString(),this._unary_expression())):this._singular_expression()}_singular_expression(){const e=this._primary_expression(),t=this._postfix_expression();return t&&(e.postfix=t),e}_postfix_expression(){if(this._match(Qg.tokens.bracket_left)){const e=this._short_circuit_or_expression();this._consume(Qg.tokens.bracket_right,"Expected ']'.");const t=this._updateNode(new wg(e)),i=this._postfix_expression();return i&&(t.postfix=i),t}if(this._match(Qg.tokens.period)){const e=this._consume(Qg.tokens.name,"Expected member name."),t=this._postfix_expression(),i=this._updateNode(new gg(e.lexeme));return t&&(i.postfix=t),i}return null}_getStruct(e){return this._context.aliases.has(e)?this._context.aliases.get(e).type:this._context.structs.has(e)?this._context.structs.get(e):null}_getType(e){const t=this._getStruct(e);if(null!==t)return t;switch(e){case"void":return lg.void;case"bool":return lg.bool;case"i32":return lg.i32;case"u32":return lg.u32;case"f32":return lg.f32;case"f16":return lg.f16;case"vec2f":return hg.vec2f;case"vec3f":return hg.vec3f;case"vec4f":return hg.vec4f;case"vec2i":return hg.vec2i;case"vec3i":return hg.vec3i;case"vec4i":return hg.vec4i;case"vec2u":return hg.vec2u;case"vec3u":return hg.vec3u;case"vec4u":return hg.vec4u;case"vec2h":return hg.vec2h;case"vec3h":return hg.vec3h;case"vec4h":return hg.vec4h;case"mat2x2f":return hg.mat2x2f;case"mat2x3f":return hg.mat2x3f;case"mat2x4f":return hg.mat2x4f;case"mat3x2f":return hg.mat3x2f;case"mat3x3f":return hg.mat3x3f;case"mat3x4f":return hg.mat3x4f;case"mat4x2f":return hg.mat4x2f;case"mat4x3f":return hg.mat4x3f;case"mat4x4f":return hg.mat4x4f;case"mat2x2h":return hg.mat2x2h;case"mat2x3h":return hg.mat2x3h;case"mat2x4h":return hg.mat2x4h;case"mat3x2h":return hg.mat3x2h;case"mat3x3h":return hg.mat3x3h;case"mat3x4h":return hg.mat3x4h;case"mat4x2h":return hg.mat4x2h;case"mat4x3h":return hg.mat4x3h;case"mat4x4h":return hg.mat4x4h;case"mat2x2i":return hg.mat2x2i;case"mat2x3i":return hg.mat2x3i;case"mat2x4i":return hg.mat2x4i;case"mat3x2i":return hg.mat3x2i;case"mat3x3i":return hg.mat3x3i;case"mat3x4i":return hg.mat3x4i;case"mat4x2i":return hg.mat4x2i;case"mat4x3i":return hg.mat4x3i;case"mat4x4i":return hg.mat4x4i;case"mat2x2u":return hg.mat2x2u;case"mat2x3u":return hg.mat2x3u;case"mat2x4u":return hg.mat2x4u;case"mat3x2u":return hg.mat3x2u;case"mat3x3u":return hg.mat3x3u;case"mat3x4u":return hg.mat3x4u;case"mat4x2u":return hg.mat4x2u;case"mat4x3u":return hg.mat4x3u;case"mat4x4u":return hg.mat4x4u}return null}_validateTypeRange(e,t){if("i32"===t.name){if(e<-2147483648||e>2147483647)throw this._error(this._previous(),`Value out of range for i32: ${e}. Line: ${this._currentLine}.`)}else if("u32"===t.name&&(e<0||e>4294967295))throw this._error(this._previous(),`Value out of range for u32: ${e}. Line: ${this._currentLine}.`)}_primary_expression(){if(this._match(Qg.tokens.ident)){const e=this._previous().toString();if(this._check(Qg.tokens.paren_left)){const t=this._argument_expression_list(),i=this._getType(e);return null!==i?this._updateNode(new _g(i,t)):this._updateNode(new Ag(e,t))}if(this._context.constants.has(e)){const t=this._context.constants.get(e);return this._updateNode(new vg(e,t.value))}return this._updateNode(new yg(e))}if(this._match(Qg.tokens.int_literal)){const e=this._previous().toString();let t=e.endsWith("i")||e.endsWith("i")?lg.i32:e.endsWith("u")||e.endsWith("U")?lg.u32:lg.x32;const i=parseInt(e);return this._validateTypeRange(i,t),this._updateNode(new xg(new zg(i,this._exec.getTypeInfo(t)),t))}if(this._match(Qg.tokens.uint_literal)){const e=parseInt(this._previous().toString());return this._validateTypeRange(e,lg.u32),this._updateNode(new xg(new zg(e,this._exec.getTypeInfo(lg.u32)),lg.u32))}if(this._match([Qg.tokens.decimal_float_literal,Qg.tokens.hex_float_literal])){let e=this._previous().toString(),t=e.endsWith("h");t&&(e=e.substring(0,e.length-1));const i=parseFloat(e);this._validateTypeRange(i,t?lg.f16:lg.f32);const r=t?lg.f16:lg.f32;return this._updateNode(new xg(new zg(i,this._exec.getTypeInfo(r)),r))}if(this._match([Qg.keywords.true,Qg.keywords.false])){let e=this._previous().toString()===Qg.keywords.true.rule;return this._updateNode(new xg(new zg(e?1:0,this._exec.getTypeInfo(lg.bool)),lg.bool))}if(this._check(Qg.tokens.paren_left))return this._paren_expression();if(this._match(Qg.keywords.bitcast)){this._consume(Qg.tokens.less_than,"Expected '<'.");const e=this._type_decl();this._consume(Qg.tokens.greater_than,"Expected '>'.");const t=this._paren_expression();return this._updateNode(new bg(e,t))}const e=this._type_decl(),t=this._argument_expression_list();return this._updateNode(new _g(e,t))}_argument_expression_list(){if(!this._match(Qg.tokens.paren_left))return null;const e=[];do{if(this._check(Qg.tokens.paren_right))break;const t=this._short_circuit_or_expression();e.push(t)}while(this._match(Qg.tokens.comma));return this._consume(Qg.tokens.paren_right,"Expected ')' for agument list"),e}_optional_paren_expression(){this._match(Qg.tokens.paren_left);const e=this._short_circuit_or_expression();return this._match(Qg.tokens.paren_right),e}_paren_expression(){this._consume(Qg.tokens.paren_left,"Expected '('.");const e=this._short_circuit_or_expression();return this._consume(Qg.tokens.paren_right,"Expected ')'."),e}_struct_decl(){if(!this._match(Qg.keywords.struct))return null;const e=this._currentLine,t=this._consume(Qg.tokens.ident,"Expected name for struct.").toString();this._consume(Qg.tokens.brace_left,"Expected '{' for struct body.");const i=[];for(;!this._check(Qg.tokens.brace_right);){const e=this._attribute(),t=this._consume(Qg.tokens.name,"Expected variable name.").toString();this._consume(Qg.tokens.colon,"Expected ':' for struct member type.");const r=this._attribute(),n=this._type_decl();null!=n&&(n.attributes=r),this._check(Qg.tokens.brace_right)?this._match(Qg.tokens.comma):this._consume(Qg.tokens.comma,"Expected ',' for struct member."),i.push(this._updateNode(new Lg(t,n,e)))}this._consume(Qg.tokens.brace_right,"Expected '}' after struct body.");const r=this._currentLine,n=this._updateNode(new ug(t,i,e,r),e);return this._context.structs.set(t,n),n}_global_variable_decl(){const e=this._variable_decl();if(!e)return null;if(this._match(Qg.tokens.equal)){const t=this._const_expression();e.value=t}if(null!==e.type&&e.value instanceof xg){if("x32"!==e.value.type.name&&e.type.getTypeName()!==e.value.type.getTypeName())throw this._error(this._peek(),`Invalid cast from ${e.value.type.name} to ${e.type.name}. Line:${this._currentLine}`);e.value.isScalar&&this._validateTypeRange(e.value.scalarValue,e.type),e.value.type=e.type}else null===e.type&&e.value instanceof xg&&(e.type="x32"===e.value.type.name?lg.i32:e.value.type,e.value.isScalar&&this._validateTypeRange(e.value.scalarValue,e.type));return e}_override_variable_decl(){const e=this._override_decl();return e&&this._match(Qg.tokens.equal)&&(e.value=this._const_expression()),e}_global_const_decl(){var e;if(!this._match(Qg.keywords.const))return null;const t=this._consume(Qg.tokens.name,"Expected variable name"),i=this._currentLine;let r=null;if(this._match(Qg.tokens.colon)){const e=this._attribute();r=this._type_decl(),null!=r&&(r.attributes=e)}let n=null;this._consume(Qg.tokens.equal,"const declarations require an assignment");const o=this._short_circuit_or_expression();try{let e=[lg.f32],i=o.constEvaluate(this._exec,e);i instanceof zg&&this._validateTypeRange(i.value,e[0]),e[0]instanceof hg&&null===e[0].format&&i.typeInfo instanceof cm&&null!==i.typeInfo.format&&("f16"===i.typeInfo.format.name?e[0].format=lg.f16:"f32"===i.typeInfo.format.name?e[0].format=lg.f32:"i32"===i.typeInfo.format.name?e[0].format=lg.i32:"u32"===i.typeInfo.format.name?e[0].format=lg.u32:"bool"===i.typeInfo.format.name?e[0].format=lg.bool:console.error(`TODO: impelement template format type ${i.typeInfo.format.name}`)),n=this._updateNode(new xg(i,e[0])),this._exec.context.setVariable(t.toString(),i)}catch(e){n=o}if(null!==r&&n instanceof xg){if("x32"!==n.type.name&&r.getTypeName()!==n.type.getTypeName())throw this._error(this._peek(),`Invalid cast from ${n.type.name} to ${r.name}. Line:${this._currentLine}`);n.type=r,n.isScalar&&this._validateTypeRange(n.scalarValue,n.type)}else null===r&&n instanceof xg&&(r=null!==(e=null==n?void 0:n.type)&&void 0!==e?e:lg.f32,r===lg.x32&&(r=lg.i32));const s=this._updateNode(new Gm(t.toString(),r,"","",n),i);return this._context.constants.set(s.name,s),s}_global_let_decl(){if(!this._match(Qg.keywords.let))return null;const e=this._currentLine,t=this._consume(Qg.tokens.name,"Expected variable name");let i=null;if(this._match(Qg.tokens.colon)){const e=this._attribute();i=this._type_decl(),null!=i&&(i.attributes=e)}let r=null;if(this._match(Qg.tokens.equal)&&(r=this._const_expression()),null!==i&&r instanceof xg){if("x32"!==r.type.name&&i.getTypeName()!==r.type.getTypeName())throw this._error(this._peek(),`Invalid cast from ${r.type.name} to ${i.name}. Line:${this._currentLine}`);r.type=i}else null===i&&r instanceof xg&&(i="x32"===r.type.name?lg.i32:r.type);return r instanceof xg&&r.isScalar&&this._validateTypeRange(r.scalarValue,i),this._updateNode(new jm(t.toString(),i,"","",r),e)}_const_expression(){return this._short_circuit_or_expression()}_variable_decl(){if(!this._match(Qg.keywords.var))return null;const e=this._currentLine;let t="",i="";this._match(Qg.tokens.less_than)&&(t=this._consume(Qg.storage_class,"Expected storage_class.").toString(),this._match(Qg.tokens.comma)&&(i=this._consume(Qg.access_mode,"Expected access_mode.").toString()),this._consume(Qg.tokens.greater_than,"Expected '>'."));const r=this._consume(Qg.tokens.name,"Expected variable name");let n=null;if(this._match(Qg.tokens.colon)){const e=this._attribute();n=this._type_decl(),null!=n&&(n.attributes=e)}return this._updateNode(new Nm(r.toString(),n,t,i,null),e)}_override_decl(){if(!this._match(Qg.keywords.override))return null;const e=this._consume(Qg.tokens.name,"Expected variable name");let t=null;if(this._match(Qg.tokens.colon)){const e=this._attribute();t=this._type_decl(),null!=t&&(t.attributes=e)}return this._updateNode(new Vm(e.toString(),t,null))}_diagnostic(){this._consume(Qg.tokens.paren_left,"Expected '('");const e=this._consume(Qg.tokens.ident,"Expected severity control name.");this._consume(Qg.tokens.comma,"Expected ','");let t=this._consume(Qg.tokens.ident,"Expected diagnostic rule name.").toString();return this._match(Qg.tokens.period)&&(t+=`.${this._consume(Qg.tokens.ident,"Expected diagnostic message.").toString()}`),this._consume(Qg.tokens.paren_right,"Expected ')'"),this._updateNode(new rg(e.toString(),t))}_enable_directive(){const e=this._consume(Qg.tokens.ident,"identity expected.");return this._updateNode(new tg(e.toString()))}_requires_directive(){const e=[this._consume(Qg.tokens.ident,"identity expected.").toString()];for(;this._match(Qg.tokens.comma);){const t=this._consume(Qg.tokens.ident,"identity expected.");e.push(t.toString())}return this._updateNode(new ig(e))}_type_alias(){const e=this._consume(Qg.tokens.ident,"identity expected.");this._consume(Qg.tokens.equal,"Expected '=' for type alias.");let t=this._type_decl();if(null===t)throw this._error(this._peek(),"Expected Type for Alias.");this._context.aliases.has(t.name)&&(t=this._context.aliases.get(t.name).type);const i=this._updateNode(new ng(e.toString(),t));return this._context.aliases.set(i.name,i),i}_type_decl(){if(this._check([Qg.tokens.ident,...Qg.texel_format,Qg.keywords.bool,Qg.keywords.f32,Qg.keywords.i32,Qg.keywords.u32])){const e=this._advance().toString();if(this._context.structs.has(e))return this._context.structs.get(e);if(this._context.aliases.has(e))return this._context.aliases.get(e).type;if(!this._getType(e)){const t=this._updateNode(new cg(e));return this._forwardTypeCount++,t}return this._updateNode(new lg(e))}let e=this._texture_sampler_types();if(e)return e;if(this._check(Qg.template_types)){let e=this._advance().toString(),t=null,i=null;return this._match(Qg.tokens.less_than)&&(t=this._type_decl(),i=null,this._match(Qg.tokens.comma)&&(i=this._consume(Qg.access_mode,"Expected access_mode for pointer").toString()),this._consume(Qg.tokens.greater_than,"Expected '>' for type.")),this._updateNode(new hg(e,t,i))}if(this._match(Qg.keywords.ptr)){let e=this._previous().toString();this._consume(Qg.tokens.less_than,"Expected '<' for pointer.");const t=this._consume(Qg.storage_class,"Expected storage_class for pointer");this._consume(Qg.tokens.comma,"Expected ',' for pointer.");const i=this._type_decl();let r=null;return this._match(Qg.tokens.comma)&&(r=this._consume(Qg.access_mode,"Expected access_mode for pointer").toString()),this._consume(Qg.tokens.greater_than,"Expected '>' for pointer."),this._updateNode(new dg(e,t.toString(),i,r))}const t=this._attribute();if(this._match(Qg.keywords.array)){let i=null,r=-1;const n=this._previous();let o=null;if(this._match(Qg.tokens.less_than)){i=this._type_decl(),this._context.aliases.has(i.name)&&(i=this._context.aliases.get(i.name).type);let t="";if(this._match(Qg.tokens.comma)){o=this._shift_expression();try{t=o.constEvaluate(this._exec).toString(),o=null}catch(e){t="1"}}this._consume(Qg.tokens.greater_than,"Expected '>' for array."),r=t?parseInt(t):0}const s=this._updateNode(new pg(n.toString(),t,i,r));return o&&this._deferArrayCountEval.push({arrayType:s,countNode:o}),s}return null}_texture_sampler_types(){if(this._match(Qg.sampler_type))return this._updateNode(new fg(this._previous().toString(),null,null));if(this._match(Qg.depth_texture_type))return this._updateNode(new fg(this._previous().toString(),null,null));if(this._match(Qg.sampled_texture_type)||this._match(Qg.multisampled_texture_type)){const e=this._previous();this._consume(Qg.tokens.less_than,"Expected '<' for sampler type.");const t=this._type_decl();return this._consume(Qg.tokens.greater_than,"Expected '>' for sampler type."),this._updateNode(new fg(e.toString(),t,null))}if(this._match(Qg.storage_texture_type)){const e=this._previous();this._consume(Qg.tokens.less_than,"Expected '<' for sampler type.");const t=this._consume(Qg.texel_format,"Invalid texel format.").toString();this._consume(Qg.tokens.comma,"Expected ',' after texel format.");const i=this._consume(Qg.access_mode,"Expected access mode for storage texture type.").toString();return this._consume(Qg.tokens.greater_than,"Expected '>' for sampler type."),this._updateNode(new fg(e.toString(),t,i))}return null}_attribute(){let e=[];for(;this._match(Qg.tokens.attr);){const t=this._consume(Qg.attribute_name,"Expected attribute name"),i=this._updateNode(new Fg(t.toString(),null));if(this._match(Qg.tokens.paren_left)){if(i.value=this._consume(Qg.literal_or_ident,"Expected attribute value").toString(),this._check(Qg.tokens.comma)){this._advance();do{const e=this._consume(Qg.literal_or_ident,"Expected attribute value").toString();i.value instanceof Array||(i.value=[i.value]),i.value.push(e)}while(this._match(Qg.tokens.comma))}this._consume(Qg.tokens.paren_right,"Expected ')'")}e.push(i)}return 0==e.length?null:e}}class y_ extends a_{constructor(e){super(),e&&this.update(e)}update(e){const t=(new A_).parse(e);this.updateAST(t)}}function v_(e){const t={attributes:[],bindings:[]};let i;try{i=function(e){try{return new y_(e)}catch(e){if(e instanceof Error)throw e;let t="WGSL parse error";throw"object"==typeof e&&e?.message&&(t+=`: ${e.message} `),"object"==typeof e&&e?.token&&(t+=e.token.line||""),new Error(t,{cause:e})}}(e)}catch(e){return jp.error(e.message)(),t}for(const e of i.uniforms){const i=[];for(const t of e.type?.members||[])i.push({name:t.name,type:x_(t.type)});t.bindings.push({type:"uniform",name:e.name,location:e.binding,group:e.group,members:i})}const r=i.entry.vertex[0],n=r?.inputs.length||0;for(let e=0;e`:e.name}const b_={name:"fp32",vs:"#ifdef LUMA_FP32_TAN_PRECISION_WORKAROUND\nconst float TWO_PI = 6.2831854820251465;\nconst float PI_2 = 1.5707963705062866;\nconst float PI_16 = 0.1963495463132858;\nconst float SIN_TABLE_0 = 0.19509032368659973;\nconst float SIN_TABLE_1 = 0.3826834261417389;\nconst float SIN_TABLE_2 = 0.5555702447891235;\nconst float SIN_TABLE_3 = 0.7071067690849304;\nconst float COS_TABLE_0 = 0.9807852506637573;\nconst float COS_TABLE_1 = 0.9238795042037964;\nconst float COS_TABLE_2 = 0.8314695954322815;\nconst float COS_TABLE_3 = 0.7071067690849304;\nconst float INVERSE_FACTORIAL_3 = 1.666666716337204e-01;\nconst float INVERSE_FACTORIAL_5 = 8.333333767950535e-03;\nconst float INVERSE_FACTORIAL_7 = 1.9841270113829523e-04;\nconst float INVERSE_FACTORIAL_9 = 2.75573188446287533e-06;\nfloat sin_taylor_fp32(float a) {\nfloat r, s, t, x;\nif (a == 0.0) {\nreturn 0.0;\n}\nx = -a * a;\ns = a;\nr = a;\nr = r * x;\nt = r * INVERSE_FACTORIAL_3;\ns = s + t;\nr = r * x;\nt = r * INVERSE_FACTORIAL_5;\ns = s + t;\nr = r * x;\nt = r * INVERSE_FACTORIAL_7;\ns = s + t;\nr = r * x;\nt = r * INVERSE_FACTORIAL_9;\ns = s + t;\nreturn s;\n}\nvoid sincos_taylor_fp32(float a, out float sin_t, out float cos_t) {\nif (a == 0.0) {\nsin_t = 0.0;\ncos_t = 1.0;\n}\nsin_t = sin_taylor_fp32(a);\ncos_t = sqrt(1.0 - sin_t * sin_t);\n}\nfloat tan_taylor_fp32(float a) {\nfloat sin_a;\nfloat cos_a;\nif (a == 0.0) {\nreturn 0.0;\n}\nfloat z = floor(a / TWO_PI);\nfloat r = a - TWO_PI * z;\nfloat t;\nfloat q = floor(r / PI_2 + 0.5);\nint j = int(q);\nif (j < -2 || j > 2) {\nreturn 1.0 / 0.0;\n}\nt = r - PI_2 * q;\nq = floor(t / PI_16 + 0.5);\nint k = int(q);\nint abs_k = int(abs(float(k)));\nif (abs_k > 4) {\nreturn 1.0 / 0.0;\n} else {\nt = t - PI_16 * q;\n}\nfloat u = 0.0;\nfloat v = 0.0;\nfloat sin_t, cos_t;\nfloat s, c;\nsincos_taylor_fp32(t, sin_t, cos_t);\nif (k == 0) {\ns = sin_t;\nc = cos_t;\n} else {\nif (abs(float(abs_k) - 1.0) < 0.5) {\nu = COS_TABLE_0;\nv = SIN_TABLE_0;\n} else if (abs(float(abs_k) - 2.0) < 0.5) {\nu = COS_TABLE_1;\nv = SIN_TABLE_1;\n} else if (abs(float(abs_k) - 3.0) < 0.5) {\nu = COS_TABLE_2;\nv = SIN_TABLE_2;\n} else if (abs(float(abs_k) - 4.0) < 0.5) {\nu = COS_TABLE_3;\nv = SIN_TABLE_3;\n}\nif (k > 0) {\ns = u * sin_t + v * cos_t;\nc = u * cos_t - v * sin_t;\n} else {\ns = u * sin_t - v * cos_t;\nc = u * cos_t + v * sin_t;\n}\n}\nif (j == 0) {\nsin_a = s;\ncos_a = c;\n} else if (j == 1) {\nsin_a = c;\ncos_a = -s;\n} else if (j == -1) {\nsin_a = -c;\ncos_a = s;\n} else {\nsin_a = -s;\ncos_a = -c;\n}\nreturn sin_a / cos_a;\n}\n#endif\nfloat tan_fp32(float a) {\n#ifdef LUMA_FP32_TAN_PRECISION_WORKAROUND\nreturn tan_taylor_fp32(a);\n#else\nreturn tan(a);\n#endif\n}\n"},w_={name:"picking",vs:"uniform pickingUniforms {\nfloat isActive;\nfloat isAttribute;\nfloat isHighlightActive;\nfloat useFloatColors;\nvec3 highlightedObjectColor;\nvec4 highlightColor;\n} picking;\nout vec4 picking_vRGBcolor_Avalid;\nvec3 picking_normalizeColor(vec3 color) {\nreturn picking.useFloatColors > 0.5 ? color : color / 255.0;\n}\nvec4 picking_normalizeColor(vec4 color) {\nreturn picking.useFloatColors > 0.5 ? color : color / 255.0;\n}\nbool picking_isColorZero(vec3 color) {\nreturn dot(color, vec3(1.0)) < 0.00001;\n}\nbool picking_isColorValid(vec3 color) {\nreturn dot(color, vec3(1.0)) > 0.00001;\n}\nbool isVertexHighlighted(vec3 vertexColor) {\nvec3 highlightedObjectColor = picking_normalizeColor(picking.highlightedObjectColor);\nreturn\nbool(picking.isHighlightActive) && picking_isColorZero(abs(vertexColor - highlightedObjectColor));\n}\nvoid picking_setPickingColor(vec3 pickingColor) {\npickingColor = picking_normalizeColor(pickingColor);\nif (bool(picking.isActive)) {\npicking_vRGBcolor_Avalid.a = float(picking_isColorValid(pickingColor));\nif (!bool(picking.isAttribute)) {\npicking_vRGBcolor_Avalid.rgb = pickingColor;\n}\n} else {\npicking_vRGBcolor_Avalid.a = float(isVertexHighlighted(pickingColor));\n}\n}\nvoid picking_setPickingAttribute(float value) {\nif (bool(picking.isAttribute)) {\npicking_vRGBcolor_Avalid.r = value;\n}\n}\nvoid picking_setPickingAttribute(vec2 value) {\nif (bool(picking.isAttribute)) {\npicking_vRGBcolor_Avalid.rg = value;\n}\n}\nvoid picking_setPickingAttribute(vec3 value) {\nif (bool(picking.isAttribute)) {\npicking_vRGBcolor_Avalid.rgb = value;\n}\n}\n",fs:"uniform pickingUniforms {\nfloat isActive;\nfloat isAttribute;\nfloat isHighlightActive;\nfloat useFloatColors;\nvec3 highlightedObjectColor;\nvec4 highlightColor;\n} picking;\nin vec4 picking_vRGBcolor_Avalid;\nvec4 picking_filterHighlightColor(vec4 color) {\nif (picking.isActive > 0.5) {\nreturn color;\n}\nbool selected = bool(picking_vRGBcolor_Avalid.a);\nif (selected) {\nfloat highLightAlpha = picking.highlightColor.a;\nfloat blendedAlpha = highLightAlpha + color.a * (1.0 - highLightAlpha);\nfloat highLightRatio = highLightAlpha / blendedAlpha;\nvec3 blendedRGB = mix(color.rgb, picking.highlightColor.rgb, highLightRatio);\nreturn vec4(blendedRGB, blendedAlpha);\n} else {\nreturn color;\n}\n}\nvec4 picking_filterPickingColor(vec4 color) {\nif (bool(picking.isActive)) {\nif (picking_vRGBcolor_Avalid.a == 0.0) {\ndiscard;\n}\nreturn picking_vRGBcolor_Avalid;\n}\nreturn color;\n}\nvec4 picking_filterColor(vec4 color) {\nvec4 highlightColor = picking_filterHighlightColor(color);\nreturn picking_filterPickingColor(highlightColor);\n}\n",uniformTypes:{isActive:"f32",isAttribute:"f32",isHighlightActive:"f32",useFloatColors:"f32",highlightedObjectColor:"vec3",highlightColor:"vec4"},defaultUniforms:{isActive:!1,isAttribute:!1,isHighlightActive:!1,useFloatColors:!0,highlightedObjectColor:[0,0,0],highlightColor:[0,1,1,1]},getUniforms:function(e={},t){const i={};if(void 0===e.highlightedObjectColor);else if(null===e.highlightedObjectColor)i.isHighlightActive=!1;else{i.isHighlightActive=!0;const t=e.highlightedObjectColor.slice(0,3);i.highlightedObjectColor=t}if(e.highlightColor){const t=Array.from(e.highlightColor,e=>e/255);Number.isFinite(t[3])||(t[3]=1),i.highlightColor=t}void 0!==e.isActive&&(i.isActive=Boolean(e.isActive),i.isAttribute=Boolean(e.isAttribute));void 0!==e.useFloatColors&&(i.useFloatColors=Boolean(e.useFloatColors));return i}};function T_(e,t=[],i=0){const r=Math.fround(e),n=e-r;return t[i]=r,t[i+1]=n,t}function E_(e){return e-Math.fround(e)}function C_(e){const t=new Float32Array(32);for(let i=0;i<4;++i)for(let r=0;r<4;++r){const n=4*i+r;T_(e[4*r+i],t,2*n)}return t}const B_={ONE:1};const S_={name:"fp64-arithmetic",vs:"uniform float ONE;\nvec2 split(float a) {\nconst float SPLIT = 4097.0;\nfloat t = a * SPLIT;\n#if defined(LUMA_FP64_CODE_ELIMINATION_WORKAROUND)\nfloat a_hi = t * ONE - (t - a);\nfloat a_lo = a * ONE - a_hi;\n#else\nfloat a_hi = t - (t - a);\nfloat a_lo = a - a_hi;\n#endif\nreturn vec2(a_hi, a_lo);\n}\nvec2 split2(vec2 a) {\nvec2 b = split(a.x);\nb.y += a.y;\nreturn b;\n}\nvec2 quickTwoSum(float a, float b) {\n#if defined(LUMA_FP64_CODE_ELIMINATION_WORKAROUND)\nfloat sum = (a + b) * ONE;\nfloat err = b - (sum - a) * ONE;\n#else\nfloat sum = a + b;\nfloat err = b - (sum - a);\n#endif\nreturn vec2(sum, err);\n}\nvec2 twoSum(float a, float b) {\nfloat s = (a + b);\n#if defined(LUMA_FP64_CODE_ELIMINATION_WORKAROUND)\nfloat v = (s * ONE - a) * ONE;\nfloat err = (a - (s - v) * ONE) * ONE * ONE * ONE + (b - v);\n#else\nfloat v = s - a;\nfloat err = (a - (s - v)) + (b - v);\n#endif\nreturn vec2(s, err);\n}\nvec2 twoSub(float a, float b) {\nfloat s = (a - b);\n#if defined(LUMA_FP64_CODE_ELIMINATION_WORKAROUND)\nfloat v = (s * ONE - a) * ONE;\nfloat err = (a - (s - v) * ONE) * ONE * ONE * ONE - (b + v);\n#else\nfloat v = s - a;\nfloat err = (a - (s - v)) - (b + v);\n#endif\nreturn vec2(s, err);\n}\nvec2 twoSqr(float a) {\nfloat prod = a * a;\nvec2 a_fp64 = split(a);\n#if defined(LUMA_FP64_CODE_ELIMINATION_WORKAROUND)\nfloat err = ((a_fp64.x * a_fp64.x - prod) * ONE + 2.0 * a_fp64.x *\na_fp64.y * ONE * ONE) + a_fp64.y * a_fp64.y * ONE * ONE * ONE;\n#else\nfloat err = ((a_fp64.x * a_fp64.x - prod) + 2.0 * a_fp64.x * a_fp64.y) + a_fp64.y * a_fp64.y;\n#endif\nreturn vec2(prod, err);\n}\nvec2 twoProd(float a, float b) {\nfloat prod = a * b;\nvec2 a_fp64 = split(a);\nvec2 b_fp64 = split(b);\nfloat err = ((a_fp64.x * b_fp64.x - prod) + a_fp64.x * b_fp64.y +\na_fp64.y * b_fp64.x) + a_fp64.y * b_fp64.y;\nreturn vec2(prod, err);\n}\nvec2 sum_fp64(vec2 a, vec2 b) {\nvec2 s, t;\ns = twoSum(a.x, b.x);\nt = twoSum(a.y, b.y);\ns.y += t.x;\ns = quickTwoSum(s.x, s.y);\ns.y += t.y;\ns = quickTwoSum(s.x, s.y);\nreturn s;\n}\nvec2 sub_fp64(vec2 a, vec2 b) {\nvec2 s, t;\ns = twoSub(a.x, b.x);\nt = twoSub(a.y, b.y);\ns.y += t.x;\ns = quickTwoSum(s.x, s.y);\ns.y += t.y;\ns = quickTwoSum(s.x, s.y);\nreturn s;\n}\nvec2 mul_fp64(vec2 a, vec2 b) {\nvec2 prod = twoProd(a.x, b.x);\nprod.y += a.x * b.y;\n#if defined(LUMA_FP64_HIGH_BITS_OVERFLOW_WORKAROUND)\nprod = split2(prod);\n#endif\nprod = quickTwoSum(prod.x, prod.y);\nprod.y += a.y * b.x;\n#if defined(LUMA_FP64_HIGH_BITS_OVERFLOW_WORKAROUND)\nprod = split2(prod);\n#endif\nprod = quickTwoSum(prod.x, prod.y);\nreturn prod;\n}\nvec2 div_fp64(vec2 a, vec2 b) {\nfloat xn = 1.0 / b.x;\n#if defined(LUMA_FP64_HIGH_BITS_OVERFLOW_WORKAROUND)\nvec2 yn = mul_fp64(a, vec2(xn, 0));\n#else\nvec2 yn = a * xn;\n#endif\nfloat diff = (sub_fp64(a, mul_fp64(b, yn))).x;\nvec2 prod = twoProd(xn, diff);\nreturn sum_fp64(yn, prod);\n}\nvec2 sqrt_fp64(vec2 a) {\nif (a.x == 0.0 && a.y == 0.0) return vec2(0.0, 0.0);\nif (a.x < 0.0) return vec2(0.0 / 0.0, 0.0 / 0.0);\nfloat x = 1.0 / sqrt(a.x);\nfloat yn = a.x * x;\n#if defined(LUMA_FP64_CODE_ELIMINATION_WORKAROUND)\nvec2 yn_sqr = twoSqr(yn) * ONE;\n#else\nvec2 yn_sqr = twoSqr(yn);\n#endif\nfloat diff = sub_fp64(a, yn_sqr).x;\nvec2 prod = twoProd(x * 0.5, diff);\n#if defined(LUMA_FP64_HIGH_BITS_OVERFLOW_WORKAROUND)\nreturn sum_fp64(split(yn), prod);\n#else\nreturn sum_fp64(vec2(yn, 0.0), prod);\n#endif\n}\n",getUniforms:function(){return B_},fp64ify:T_,fp64LowPart:E_,fp64ifyMatrix4:C_},I_=1/Math.PI*180,M_=1/180*Math.PI;globalThis.mathgl=globalThis.mathgl||{config:{EPSILON:1e-12,debug:!1,precision:4,printTypes:!1,printDegrees:!1,printRowMajor:!0,_cartographicRadians:!1}};const P_=globalThis.mathgl.config;function R_(e,{precision:t=P_.precision}={}){return e=function(e){return Math.round(e/P_.EPSILON)*P_.EPSILON}(e),`${parseFloat(e.toPrecision(t))}`}function L_(e){return Array.isArray(e)||ArrayBuffer.isView(e)&&!(e instanceof DataView)}function F_(e){return function(e,t){return N_(e,e=>e*M_,t)}(e)}function k_(e){return D_(e)}function D_(e,t){return N_(e,e=>e*I_,t)}function O_(e,t,i){return N_(e,e=>Math.max(t,Math.min(i,e)))}function z_(e,t,i){return L_(e)?e.map((e,r)=>z_(e,t[r],i)):i*t+(1-i)*e}function U_(e,t,i){const r=P_.EPSILON;i&&(P_.EPSILON=i);try{if(e===t)return!0;if(L_(e)&&L_(t)){if(e.length!==t.length)return!1;for(let i=0;i0?", ":"")+R_(this[i],e);return`${e.printTypes?this.constructor.name:""}[${t}]`}equals(e){if(!e||this.length!==e.length)return!1;for(let t=0;t=0&&e=0&&e0?this.copy([e,...t]):this.identity()}copy(e){return this[0]=e[0],this[1]=e[1],this[2]=e[2],this[3]=e[3],this[4]=e[4],this[5]=e[5],this[6]=e[6],this[7]=e[7],this[8]=e[8],this.check()}identity(){return this.copy(xA)}fromObject(e){return this.check()}fromQuaternion(e){return function(e,t){const i=t[0],r=t[1],n=t[2],o=t[3],s=i+i,a=r+r,l=n+n,c=i*s,u=r*s,h=r*a,d=n*s,p=n*a,f=n*l,m=o*s,g=o*a,_=o*l;e[0]=1-h-f,e[3]=u-_,e[6]=d+g,e[1]=u+_,e[4]=1-c-f,e[7]=p-m,e[2]=d-g,e[5]=p+m,e[8]=1-c-h}(this,e),this.check()}set(e,t,i,r,n,o,s,a,l){return this[0]=e,this[1]=t,this[2]=i,this[3]=r,this[4]=n,this[5]=o,this[6]=s,this[7]=a,this[8]=l,this.check()}setRowMajor(e,t,i,r,n,o,s,a,l){return this[0]=e,this[1]=r,this[2]=s,this[3]=t,this[4]=n,this[5]=a,this[6]=i,this[7]=o,this[8]=l,this.check()}determinant(){return function(e){const t=e[0],i=e[1],r=e[2],n=e[3],o=e[4],s=e[5],a=e[6],l=e[7],c=e[8];return t*(c*o-s*l)+i*(-c*n+s*a)+r*(l*n-o*a)}(this)}transpose(){return function(e,t){if(e===t){const i=t[1],r=t[2],n=t[5];e[1]=t[3],e[2]=t[6],e[3]=i,e[5]=t[7],e[6]=r,e[7]=n}else e[0]=t[0],e[1]=t[3],e[2]=t[6],e[3]=t[1],e[4]=t[4],e[5]=t[7],e[6]=t[2],e[7]=t[5],e[8]=t[8]}(this,this),this.check()}invert(){return function(e,t){const i=t[0],r=t[1],n=t[2],o=t[3],s=t[4],a=t[5],l=t[6],c=t[7],u=t[8],h=u*s-a*c,d=-u*o+a*l,p=c*o-s*l;let f=i*h+r*d+n*p;f&&(f=1/f,e[0]=h*f,e[1]=(-u*r+n*c)*f,e[2]=(a*r-n*s)*f,e[3]=d*f,e[4]=(u*i-n*l)*f,e[5]=(-a*i+n*o)*f,e[6]=p*f,e[7]=(-c*i+r*l)*f,e[8]=(s*i-r*o)*f)}(this,this),this.check()}multiplyLeft(e){return AA(this,e,this),this.check()}multiplyRight(e){return AA(this,this,e),this.check()}rotate(e){return function(e,t,i){const r=t[0],n=t[1],o=t[2],s=t[3],a=t[4],l=t[5],c=t[6],u=t[7],h=t[8],d=Math.sin(i),p=Math.cos(i);e[0]=p*r+d*s,e[1]=p*n+d*a,e[2]=p*o+d*l,e[3]=p*s-d*r,e[4]=p*a-d*n,e[5]=p*l-d*o,e[6]=c,e[7]=u,e[8]=h}(this,this,e),this.check()}scale(e){return Array.isArray(e)?yA(this,this,e):yA(this,this,[e,e]),this.check()}translate(e){return function(e,t,i){const r=t[0],n=t[1],o=t[2],s=t[3],a=t[4],l=t[5],c=t[6],u=t[7],h=t[8],d=i[0],p=i[1];e[0]=r,e[1]=n,e[2]=o,e[3]=s,e[4]=a,e[5]=l,e[6]=d*r+p*s+c,e[7]=d*n+p*a+u,e[8]=d*o+p*l+h}(this,this,e),this.check()}transform(e,t){let i;switch(e.length){case 2:i=K_(t||[-0,-0],e,this);break;case 3:i=lA(t||[-0,-0,-0],e,this);break;case 4:i=eA(t||[-0,-0,-0,-0],e,this);break;default:throw new Error("Illegal vector")}return G_(i,e.length),i}transformVector(e,t){return this.transform(e,t)}transformVector2(e,t){return this.transform(e,t)}transformVector3(e,t){return this.transform(e,t)}}let wA,TA=null;function EA(e,t){const i=t[0],r=t[1],n=t[2],o=t[3],s=t[4],a=t[5],l=t[6],c=t[7],u=t[8],h=t[9],d=t[10],p=t[11],f=t[12],m=t[13],g=t[14],_=t[15],A=i*a-r*s,y=i*l-n*s,v=i*c-o*s,x=r*l-n*a,b=r*c-o*a,w=n*c-o*l,T=u*m-h*f,E=u*g-d*f,C=u*_-p*f,B=h*g-d*m,S=h*_-p*m,I=d*_-p*g;let M=A*I-y*S+v*B+x*C-b*E+w*T;return M?(M=1/M,e[0]=(a*I-l*S+c*B)*M,e[1]=(n*S-r*I-o*B)*M,e[2]=(m*w-g*b+_*x)*M,e[3]=(d*b-h*w-p*x)*M,e[4]=(l*C-s*I-c*E)*M,e[5]=(i*I-n*C+o*E)*M,e[6]=(g*v-f*w-_*y)*M,e[7]=(u*w-d*v+p*y)*M,e[8]=(s*S-a*C+c*T)*M,e[9]=(r*C-i*S-o*T)*M,e[10]=(f*b-m*v+_*A)*M,e[11]=(h*v-u*b-p*A)*M,e[12]=(a*E-s*B-l*T)*M,e[13]=(i*B-r*E+n*T)*M,e[14]=(m*y-f*x-g*A)*M,e[15]=(u*x-h*y+d*A)*M,e):null}function CA(e,t,i){const r=t[0],n=t[1],o=t[2],s=t[3],a=t[4],l=t[5],c=t[6],u=t[7],h=t[8],d=t[9],p=t[10],f=t[11],m=t[12],g=t[13],_=t[14],A=t[15];let y=i[0],v=i[1],x=i[2],b=i[3];return e[0]=y*r+v*a+x*h+b*m,e[1]=y*n+v*l+x*d+b*g,e[2]=y*o+v*c+x*p+b*_,e[3]=y*s+v*u+x*f+b*A,y=i[4],v=i[5],x=i[6],b=i[7],e[4]=y*r+v*a+x*h+b*m,e[5]=y*n+v*l+x*d+b*g,e[6]=y*o+v*c+x*p+b*_,e[7]=y*s+v*u+x*f+b*A,y=i[8],v=i[9],x=i[10],b=i[11],e[8]=y*r+v*a+x*h+b*m,e[9]=y*n+v*l+x*d+b*g,e[10]=y*o+v*c+x*p+b*_,e[11]=y*s+v*u+x*f+b*A,y=i[12],v=i[13],x=i[14],b=i[15],e[12]=y*r+v*a+x*h+b*m,e[13]=y*n+v*l+x*d+b*g,e[14]=y*o+v*c+x*p+b*_,e[15]=y*s+v*u+x*f+b*A,e}function BA(e,t,i){const r=i[0],n=i[1],o=i[2];let s,a,l,c,u,h,d,p,f,m,g,_;return t===e?(e[12]=t[0]*r+t[4]*n+t[8]*o+t[12],e[13]=t[1]*r+t[5]*n+t[9]*o+t[13],e[14]=t[2]*r+t[6]*n+t[10]*o+t[14],e[15]=t[3]*r+t[7]*n+t[11]*o+t[15]):(s=t[0],a=t[1],l=t[2],c=t[3],u=t[4],h=t[5],d=t[6],p=t[7],f=t[8],m=t[9],g=t[10],_=t[11],e[0]=s,e[1]=a,e[2]=l,e[3]=c,e[4]=u,e[5]=h,e[6]=d,e[7]=p,e[8]=f,e[9]=m,e[10]=g,e[11]=_,e[12]=s*r+u*n+f*o+t[12],e[13]=a*r+h*n+m*o+t[13],e[14]=l*r+d*n+g*o+t[14],e[15]=c*r+p*n+_*o+t[15]),e}function SA(e,t,i){const r=i[0],n=i[1],o=i[2];return e[0]=t[0]*r,e[1]=t[1]*r,e[2]=t[2]*r,e[3]=t[3]*r,e[4]=t[4]*n,e[5]=t[5]*n,e[6]=t[6]*n,e[7]=t[7]*n,e[8]=t[8]*o,e[9]=t[9]*o,e[10]=t[10]*o,e[11]=t[11]*o,e[12]=t[12],e[13]=t[13],e[14]=t[14],e[15]=t[15],e}function IA(e,t,i){const r=Math.sin(i),n=Math.cos(i),o=t[4],s=t[5],a=t[6],l=t[7],c=t[8],u=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*n+c*r,e[5]=s*n+u*r,e[6]=a*n+h*r,e[7]=l*n+d*r,e[8]=c*n-o*r,e[9]=u*n-s*r,e[10]=h*n-a*r,e[11]=d*n-l*r,e}function MA(e,t,i){const r=Math.sin(i),n=Math.cos(i),o=t[0],s=t[1],a=t[2],l=t[3],c=t[4],u=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*n+c*r,e[1]=s*n+u*r,e[2]=a*n+h*r,e[3]=l*n+d*r,e[4]=c*n-o*r,e[5]=u*n-s*r,e[6]=h*n-a*r,e[7]=d*n-l*r,e}const PA=function(e,t,i,r,n){const o=1/Math.tan(t/2);if(e[0]=o/i,e[1]=0,e[2]=0,e[3]=0,e[4]=0,e[5]=o,e[6]=0,e[7]=0,e[8]=0,e[9]=0,e[11]=-1,e[12]=0,e[13]=0,e[15]=0,null!=n&&n!==1/0){const t=1/(r-n);e[10]=(n+r)*t,e[14]=2*n*r*t}else e[10]=-1,e[14]=-2*r;return e};const RA=function(e,t,i,r,n,o,s){const a=1/(t-i),l=1/(r-n),c=1/(o-s);return e[0]=-2*a,e[1]=0,e[2]=0,e[3]=0,e[4]=0,e[5]=-2*l,e[6]=0,e[7]=0,e[8]=0,e[9]=0,e[10]=2*c,e[11]=0,e[12]=(t+i)*a,e[13]=(n+r)*l,e[14]=(s+o)*c,e[15]=1,e};function LA(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 FA(e,t,i){const r=t[0],n=t[1],o=t[2],s=t[3];return e[0]=i[0]*r+i[4]*n+i[8]*o+i[12]*s,e[1]=i[1]*r+i[5]*n+i[9]*o+i[13]*s,e[2]=i[2]*r+i[6]*n+i[10]*o+i[14]*s,e[3]=i[3]*r+i[7]*n+i[11]*o+i[15]*s,e}var kA;!function(){const e=function(){const e=new Z_(4);return Z_!=Float32Array&&(e[0]=0,e[1]=0,e[2]=0,e[3]=0),e}()}(),function(e){e[e.COL0ROW0=0]="COL0ROW0",e[e.COL0ROW1=1]="COL0ROW1",e[e.COL0ROW2=2]="COL0ROW2",e[e.COL0ROW3=3]="COL0ROW3",e[e.COL1ROW0=4]="COL1ROW0",e[e.COL1ROW1=5]="COL1ROW1",e[e.COL1ROW2=6]="COL1ROW2",e[e.COL1ROW3=7]="COL1ROW3",e[e.COL2ROW0=8]="COL2ROW0",e[e.COL2ROW1=9]="COL2ROW1",e[e.COL2ROW2=10]="COL2ROW2",e[e.COL2ROW3=11]="COL2ROW3",e[e.COL3ROW0=12]="COL3ROW0",e[e.COL3ROW1=13]="COL3ROW1",e[e.COL3ROW2=14]="COL3ROW2",e[e.COL3ROW3=15]="COL3ROW3"}(kA||(kA={}));const DA=45*Math.PI/180,OA=1,zA=.1,UA=500,NA=Object.freeze([1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1]);class VA extends _A{static get IDENTITY(){return function(){GA||(GA=new VA,Object.freeze(GA));return GA}()}static get ZERO(){return function(){jA||(jA=new VA([0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0]),Object.freeze(jA));return jA}()}get ELEMENTS(){return 16}get RANK(){return 4}get INDICES(){return kA}constructor(e){super(-0,-0,-0,-0,-0,-0,-0,-0,-0,-0,-0,-0,-0,-0,-0,-0),1===arguments.length&&Array.isArray(e)?this.copy(e):this.identity()}copy(e){return this[0]=e[0],this[1]=e[1],this[2]=e[2],this[3]=e[3],this[4]=e[4],this[5]=e[5],this[6]=e[6],this[7]=e[7],this[8]=e[8],this[9]=e[9],this[10]=e[10],this[11]=e[11],this[12]=e[12],this[13]=e[13],this[14]=e[14],this[15]=e[15],this.check()}set(e,t,i,r,n,o,s,a,l,c,u,h,d,p,f,m){return this[0]=e,this[1]=t,this[2]=i,this[3]=r,this[4]=n,this[5]=o,this[6]=s,this[7]=a,this[8]=l,this[9]=c,this[10]=u,this[11]=h,this[12]=d,this[13]=p,this[14]=f,this[15]=m,this.check()}setRowMajor(e,t,i,r,n,o,s,a,l,c,u,h,d,p,f,m){return this[0]=e,this[1]=n,this[2]=l,this[3]=d,this[4]=t,this[5]=o,this[6]=c,this[7]=p,this[8]=i,this[9]=s,this[10]=u,this[11]=f,this[12]=r,this[13]=a,this[14]=h,this[15]=m,this.check()}toRowMajor(e){return e[0]=this[0],e[1]=this[4],e[2]=this[8],e[3]=this[12],e[4]=this[1],e[5]=this[5],e[6]=this[9],e[7]=this[13],e[8]=this[2],e[9]=this[6],e[10]=this[10],e[11]=this[14],e[12]=this[3],e[13]=this[7],e[14]=this[11],e[15]=this[15],e}identity(){return this.copy(NA)}fromObject(e){return this.check()}fromQuaternion(e){return function(e,t){const i=t[0],r=t[1],n=t[2],o=t[3],s=i+i,a=r+r,l=n+n,c=i*s,u=r*s,h=r*a,d=n*s,p=n*a,f=n*l,m=o*s,g=o*a,_=o*l;e[0]=1-h-f,e[1]=u+_,e[2]=d-g,e[3]=0,e[4]=u-_,e[5]=1-c-f,e[6]=p+m,e[7]=0,e[8]=d+g,e[9]=p-m,e[10]=1-c-h,e[11]=0,e[12]=0,e[13]=0,e[14]=0,e[15]=1}(this,e),this.check()}frustum(e){const{left:t,right:i,bottom:r,top:n,near:o=zA,far:s=UA}=e;return s===1/0?function(e,t,i,r,n,o){const s=2*o/(i-t),a=2*o/(n-r),l=(i+t)/(i-t),c=(n+r)/(n-r),u=-1,h=-1,d=-2*o;e[0]=s,e[1]=0,e[2]=0,e[3]=0,e[4]=0,e[5]=a,e[6]=0,e[7]=0,e[8]=l,e[9]=c,e[10]=u,e[11]=h,e[12]=0,e[13]=0,e[14]=d,e[15]=0}(this,t,i,r,n,o):function(e,t,i,r,n,o,s){const a=1/(i-t),l=1/(n-r),c=1/(o-s);e[0]=2*o*a,e[1]=0,e[2]=0,e[3]=0,e[4]=0,e[5]=2*o*l,e[6]=0,e[7]=0,e[8]=(i+t)*a,e[9]=(n+r)*l,e[10]=(s+o)*c,e[11]=-1,e[12]=0,e[13]=0,e[14]=s*o*2*c,e[15]=0}(this,t,i,r,n,o,s),this.check()}lookAt(e){const{eye:t,center:i=[0,0,0],up:r=[0,1,0]}=e;return function(e,t,i,r){let n,o,s,a,l,c,u,h,d,p;const f=t[0],m=t[1],g=t[2],_=r[0],A=r[1],y=r[2],v=i[0],x=i[1],b=i[2];Math.abs(f-v)<$_&&Math.abs(m-x)<$_&&Math.abs(g-b)<$_?function(e){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):(h=f-v,d=m-x,p=g-b,n=1/Math.sqrt(h*h+d*d+p*p),h*=n,d*=n,p*=n,o=A*p-y*d,s=y*h-_*p,a=_*d-A*h,n=Math.sqrt(o*o+s*s+a*a),n?(n=1/n,o*=n,s*=n,a*=n):(o=0,s=0,a=0),l=d*a-p*s,c=p*o-h*a,u=h*s-d*o,n=Math.sqrt(l*l+c*c+u*u),n?(n=1/n,l*=n,c*=n,u*=n):(l=0,c=0,u=0),e[0]=o,e[1]=l,e[2]=h,e[3]=0,e[4]=s,e[5]=c,e[6]=d,e[7]=0,e[8]=a,e[9]=u,e[10]=p,e[11]=0,e[12]=-(o*f+s*m+a*g),e[13]=-(l*f+c*m+u*g),e[14]=-(h*f+d*m+p*g),e[15]=1)}(this,t,i,r),this.check()}ortho(e){const{left:t,right:i,bottom:r,top:n,near:o=zA,far:s=UA}=e;return RA(this,t,i,r,n,o,s),this.check()}orthographic(e){const{fovy:t=DA,aspect:i=OA,focalDistance:r=1,near:n=zA,far:o=UA}=e;HA(t);const s=t/2,a=r*Math.tan(s),l=a*i;return this.ortho({left:-l,right:l,bottom:-a,top:a,near:n,far:o})}perspective(e){const{fovy:t=45*Math.PI/180,aspect:i=1,near:r=.1,far:n=500}=e;return HA(t),PA(this,t,i,r,n),this.check()}determinant(){return function(e){const t=e[0],i=e[1],r=e[2],n=e[3],o=e[4],s=e[5],a=e[6],l=e[7],c=e[8],u=e[9],h=e[10],d=e[11],p=e[12],f=e[13],m=e[14],g=t*s-i*o,_=t*a-r*o,A=i*a-r*s,y=c*f-u*p,v=c*m-h*p,x=u*m-h*f;return l*(t*x-i*v+r*y)-n*(o*x-s*v+a*y)+e[15]*(c*A-u*_+h*g)-d*(p*A-f*_+m*g)}(this)}getScale(e=[-0,-0,-0]){return e[0]=Math.sqrt(this[0]*this[0]+this[1]*this[1]+this[2]*this[2]),e[1]=Math.sqrt(this[4]*this[4]+this[5]*this[5]+this[6]*this[6]),e[2]=Math.sqrt(this[8]*this[8]+this[9]*this[9]+this[10]*this[10]),e}getTranslation(e=[-0,-0,-0]){return e[0]=this[12],e[1]=this[13],e[2]=this[14],e}getRotation(e,t){e=e||[-0,-0,-0,-0,-0,-0,-0,-0,-0,-0,-0,-0,-0,-0,-0,-0],t=t||[-0,-0,-0];const i=this.getScale(t),r=1/i[0],n=1/i[1],o=1/i[2];return e[0]=this[0]*r,e[1]=this[1]*n,e[2]=this[2]*o,e[3]=0,e[4]=this[4]*r,e[5]=this[5]*n,e[6]=this[6]*o,e[7]=0,e[8]=this[8]*r,e[9]=this[9]*n,e[10]=this[10]*o,e[11]=0,e[12]=0,e[13]=0,e[14]=0,e[15]=1,e}getRotationMatrix3(e,t){e=e||[-0,-0,-0,-0,-0,-0,-0,-0,-0],t=t||[-0,-0,-0];const i=this.getScale(t),r=1/i[0],n=1/i[1],o=1/i[2];return e[0]=this[0]*r,e[1]=this[1]*n,e[2]=this[2]*o,e[3]=this[4]*r,e[4]=this[5]*n,e[5]=this[6]*o,e[6]=this[8]*r,e[7]=this[9]*n,e[8]=this[10]*o,e}transpose(){return function(e,t){if(e===t){const i=t[1],r=t[2],n=t[3],o=t[6],s=t[7],a=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]=r,e[9]=o,e[11]=t[14],e[12]=n,e[13]=s,e[14]=a}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]}(this,this),this.check()}invert(){return EA(this,this),this.check()}multiplyLeft(e){return CA(this,e,this),this.check()}multiplyRight(e){return CA(this,this,e),this.check()}rotateX(e){return IA(this,this,e),this.check()}rotateY(e){return function(e,t,i){const r=Math.sin(i),n=Math.cos(i),o=t[0],s=t[1],a=t[2],l=t[3],c=t[8],u=t[9],h=t[10],d=t[11];t!==e&&(e[4]=t[4],e[5]=t[5],e[6]=t[6],e[7]=t[7],e[12]=t[12],e[13]=t[13],e[14]=t[14],e[15]=t[15]),e[0]=o*n-c*r,e[1]=s*n-u*r,e[2]=a*n-h*r,e[3]=l*n-d*r,e[8]=o*r+c*n,e[9]=s*r+u*n,e[10]=a*r+h*n,e[11]=l*r+d*n}(this,this,e),this.check()}rotateZ(e){return MA(this,this,e),this.check()}rotateXYZ(e){return this.rotateX(e[0]).rotateY(e[1]).rotateZ(e[2])}rotateAxis(e,t){return function(e,t,i,r){let n,o,s,a,l,c,u,h,d,p,f,m,g,_,A,y,v,x,b,w,T,E,C,B,S=r[0],I=r[1],M=r[2],P=Math.sqrt(S*S+I*I+M*M);P<$_||(P=1/P,S*=P,I*=P,M*=P,o=Math.sin(i),n=Math.cos(i),s=1-n,a=t[0],l=t[1],c=t[2],u=t[3],h=t[4],d=t[5],p=t[6],f=t[7],m=t[8],g=t[9],_=t[10],A=t[11],y=S*S*s+n,v=I*S*s+M*o,x=M*S*s-I*o,b=S*I*s-M*o,w=I*I*s+n,T=M*I*s+S*o,E=S*M*s+I*o,C=I*M*s-S*o,B=M*M*s+n,e[0]=a*y+h*v+m*x,e[1]=l*y+d*v+g*x,e[2]=c*y+p*v+_*x,e[3]=u*y+f*v+A*x,e[4]=a*b+h*w+m*T,e[5]=l*b+d*w+g*T,e[6]=c*b+p*w+_*T,e[7]=u*b+f*w+A*T,e[8]=a*E+h*C+m*B,e[9]=l*E+d*C+g*B,e[10]=c*E+p*C+_*B,e[11]=u*E+f*C+A*B,t!==e&&(e[12]=t[12],e[13]=t[13],e[14]=t[14],e[15]=t[15]))}(this,this,e,t),this.check()}scale(e){return SA(this,this,Array.isArray(e)?e:[e,e,e]),this.check()}translate(e){return BA(this,this,e),this.check()}transform(e,t){return 4===e.length?(G_(t=FA(t||[-0,-0,-0,-0],e,this),4),t):this.transformAsPoint(e,t)}transformAsPoint(e,t){const{length:i}=e;let r;switch(i){case 2:r=X_(t||[-0,-0],e,this);break;case 3:r=aA(t||[-0,-0,-0],e,this);break;default:throw new Error("Illegal vector")}return G_(r,e.length),r}transformAsVector(e,t){let i;switch(e.length){case 2:i=J_(t||[-0,-0],e,this);break;case 3:i=Y_(t||[-0,-0,-0],e,this);break;default:throw new Error("Illegal vector")}return G_(i,e.length),i}transformPoint(e,t){return this.transformAsPoint(e,t)}transformVector(e,t){return this.transformAsPoint(e,t)}transformDirection(e,t){return this.transformAsVector(e,t)}makeRotationX(e){return this.identity().rotateX(e)}makeTranslation(e,t,i){return this.identity().translate([e,t,i])}}let jA,GA;function HA(e){if(e>2*Math.PI)throw Error("expected radians")}function QA(){const e=new Z_(4);return Z_!=Float32Array&&(e[0]=0,e[1]=0,e[2]=0),e[3]=1,e}function $A(e,t,i){i*=.5;const r=Math.sin(i);return e[0]=r*t[0],e[1]=r*t[1],e[2]=r*t[2],e[3]=Math.cos(i),e}function ZA(e,t,i){const r=t[0],n=t[1],o=t[2],s=t[3],a=i[0],l=i[1],c=i[2],u=i[3];return e[0]=r*u+s*a+n*c-o*l,e[1]=n*u+s*l+o*a-r*c,e[2]=o*u+s*c+r*l-n*a,e[3]=s*u-r*a-n*l-o*c,e}function WA(e,t,i,r){const n=t[0],o=t[1],s=t[2],a=t[3];let l,c,u,h,d,p=i[0],f=i[1],m=i[2],g=i[3];return l=n*p+o*f+s*m+a*g,l<0&&(l=-l,p=-p,f=-f,m=-m,g=-g),1-l>$_?(c=Math.acos(l),d=Math.sin(c),u=Math.sin((1-r)*c)/d,h=Math.sin(r*c)/d):(u=1-r,h=r),e[0]=u*n+h*p,e[1]=u*o+h*f,e[2]=u*s+h*m,e[3]=u*a+h*g,e}function qA(e,t){const i=t[0]+t[4]+t[8];let r;if(i>0)r=Math.sqrt(i+1),e[3]=.5*r,r=.5/r,e[0]=(t[5]-t[7])*r,e[1]=(t[6]-t[2])*r,e[2]=(t[1]-t[3])*r;else{let i=0;t[4]>t[0]&&(i=1),t[8]>t[3*i+i]&&(i=2);const n=(i+1)%3,o=(i+2)%3;r=Math.sqrt(t[3*i+i]-t[3*n+n]-t[3*o+o]+1),e[i]=.5*r,r=.5/r,e[3]=(t[3*n+o]-t[3*o+n])*r,e[n]=(t[3*n+i]+t[3*i+n])*r,e[o]=(t[3*o+i]+t[3*i+o])*r}return e}const KA=function(e,t,i){return e[0]=t[0]+i[0],e[1]=t[1]+i[1],e[2]=t[2]+i[2],e[3]=t[3]+i[3],e},XA=LA,JA=function(e,t){return e[0]*t[0]+e[1]*t[1]+e[2]*t[2]+e[3]*t[3]},YA=function(e,t,i,r){const n=t[0],o=t[1],s=t[2],a=t[3];return e[0]=n+r*(i[0]-n),e[1]=o+r*(i[1]-o),e[2]=s+r*(i[2]-s),e[3]=a+r*(i[3]-a),e},ey=function(e){const t=e[0],i=e[1],r=e[2],n=e[3];return Math.sqrt(t*t+i*i+r*r+n*n)},ty=function(e){const t=e[0],i=e[1],r=e[2],n=e[3];return t*t+i*i+r*r+n*n},iy=function(e,t){const i=t[0],r=t[1],n=t[2],o=t[3];let s=i*i+r*r+n*n+o*o;return s>0&&(s=1/Math.sqrt(s)),e[0]=i*s,e[1]=r*s,e[2]=n*s,e[3]=o*s,e},ry=function(){const e=iA(),t=nA(1,0,0),i=nA(0,1,0);return function(r,n,o){const s=oA(n,o);return s<-.999999?(sA(e,t,n),hA(e)<1e-6&&sA(e,i,n),function(e,t){const i=t[0],r=t[1],n=t[2];let o=i*i+r*r+n*n;o>0&&(o=1/Math.sqrt(o)),e[0]=t[0]*o,e[1]=t[1]*o,e[2]=t[2]*o}(e,e),$A(r,e,Math.PI),r):s>.999999?(r[0]=0,r[1]=0,r[2]=0,r[3]=1,r):(sA(e,n,o),r[0]=e[0],r[1]=e[1],r[2]=e[2],r[3]=1+s,iy(r,r))}}();!function(){const e=QA(),t=QA()}(),function(){const e=function(){const e=new Z_(9);return Z_!=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}()}();const ny=[0,0,0,1];class oy extends V_{constructor(e=0,t=0,i=0,r=1){super(-0,-0,-0,-0),Array.isArray(e)&&1===arguments.length?this.copy(e):this.set(e,t,i,r)}copy(e){return this[0]=e[0],this[1]=e[1],this[2]=e[2],this[3]=e[3],this.check()}set(e,t,i,r){return this[0]=e,this[1]=t,this[2]=i,this[3]=r,this.check()}fromObject(e){return this[0]=e.x,this[1]=e.y,this[2]=e.z,this[3]=e.w,this.check()}fromMatrix3(e){return qA(this,e),this.check()}fromAxisRotation(e,t){return $A(this,e,t),this.check()}identity(){var e;return(e=this)[0]=0,e[1]=0,e[2]=0,e[3]=1,this.check()}setAxisAngle(e,t){return this.fromAxisRotation(e,t)}get ELEMENTS(){return 4}get x(){return this[0]}set x(e){this[0]=j_(e)}get y(){return this[1]}set y(e){this[1]=j_(e)}get z(){return this[2]}set z(e){this[2]=j_(e)}get w(){return this[3]}set w(e){this[3]=j_(e)}len(){return ey(this)}lengthSquared(){return ty(this)}dot(e){return JA(this,e)}rotationTo(e,t){return ry(this,e,t),this.check()}add(e){return KA(this,this,e),this.check()}calculateW(){return function(e,t){const i=t[0],r=t[1],n=t[2];e[0]=i,e[1]=r,e[2]=n,e[3]=Math.sqrt(Math.abs(1-i*i-r*r-n*n))}(this,this),this.check()}conjugate(){return function(e,t){e[0]=-t[0],e[1]=-t[1],e[2]=-t[2],e[3]=t[3]}(this,this),this.check()}invert(){return function(e,t){const i=t[0],r=t[1],n=t[2],o=t[3],s=i*i+r*r+n*n+o*o,a=s?1/s:0;e[0]=-i*a,e[1]=-r*a,e[2]=-n*a,e[3]=o*a}(this,this),this.check()}lerp(e,t,i){return void 0===i?this.lerp(this,e,t):(YA(this,e,t,i),this.check())}multiplyRight(e){return ZA(this,this,e),this.check()}multiplyLeft(e){return ZA(this,e,this),this.check()}normalize(){const e=this.len(),t=e>0?1/e:0;return this[0]=this[0]*t,this[1]=this[1]*t,this[2]=this[2]*t,this[3]=this[3]*t,0===e&&(this[3]=1),this.check()}rotateX(e){return function(e,t,i){i*=.5;const r=t[0],n=t[1],o=t[2],s=t[3],a=Math.sin(i),l=Math.cos(i);e[0]=r*l+s*a,e[1]=n*l+o*a,e[2]=o*l-n*a,e[3]=s*l-r*a}(this,this,e),this.check()}rotateY(e){return function(e,t,i){i*=.5;const r=t[0],n=t[1],o=t[2],s=t[3],a=Math.sin(i),l=Math.cos(i);e[0]=r*l-o*a,e[1]=n*l+s*a,e[2]=o*l+r*a,e[3]=s*l-n*a}(this,this,e),this.check()}rotateZ(e){return function(e,t,i){i*=.5;const r=t[0],n=t[1],o=t[2],s=t[3],a=Math.sin(i),l=Math.cos(i);e[0]=r*l+n*a,e[1]=n*l-r*a,e[2]=o*l+s*a,e[3]=s*l-o*a}(this,this,e),this.check()}scale(e){return XA(this,this,e),this.check()}slerp(e,t,i){let r,n,o;switch(arguments.length){case 1:({start:r=ny,target:n,ratio:o}=e);break;case 2:r=this,n=e,o=t;break;default:r=e,n=t,o=i}return WA(this,r,n,o),this.check()}transformVector4(e,t=new gA){return function(e,t,i){const r=t[0],n=t[1],o=t[2],s=i[0],a=i[1],l=i[2],c=i[3],u=c*r+a*o-l*n,h=c*n+l*r-s*o,d=c*o+s*n-a*r,p=-s*r-a*n-l*o;e[0]=u*c+p*-s+h*-l-d*-a,e[1]=h*c+p*-a+d*-s-u*-l,e[2]=d*c+p*-l+u*-a-h*-s,e[3]=t[3]}(t,e,this),G_(t,4)}lengthSq(){return this.lengthSquared()}setFromAxisAngle(e,t){return this.setAxisAngle(e,t)}premultiply(e){return this.multiplyLeft(e)}multiply(e){return this.multiplyRight(e)}}const sy="#if (defined(SHADER_TYPE_FRAGMENT) && defined(LIGHTING_FRAGMENT)) || (defined(SHADER_TYPE_VERTEX) && defined(LIGHTING_VERTEX))\nstruct AmbientLight {\nvec3 color;\n};\nstruct PointLight {\nvec3 color;\nvec3 position;\nvec3 attenuation;\n};\nstruct DirectionalLight {\nvec3 color;\nvec3 direction;\n};\nuniform AmbientLight lighting_uAmbientLight;\nuniform PointLight lighting_uPointLight[MAX_LIGHTS];\nuniform DirectionalLight lighting_uDirectionalLight[MAX_LIGHTS];\nuniform int lighting_uPointLightCount;\nuniform int lighting_uDirectionalLightCount;\nuniform bool lighting_uEnabled;\nfloat getPointLightAttenuation(PointLight pointLight, float distance) {\nreturn pointLight.attenuation.x\n+ pointLight.attenuation.y * distance\n+ pointLight.attenuation.z * distance * distance;\n}\n#endif\n",ay={lightSources:{}};function ly(e={}){const{color:t=[0,0,0],intensity:i=1}=e;return t.map(e=>e*i/255)}const cy={name:"lights",vs:sy,fs:sy,getUniforms:function e(t=ay){if("lightSources"in t){const{ambientLight:e,pointLights:i,directionalLights:r}=t.lightSources||{};return e||i&&i.length>0||r&&r.length>0?Object.assign({},function({ambientLight:e,pointLights:t=[],directionalLights:i=[]}){const r={};return r["lighting_uAmbientLight.color"]=e?ly(e):[0,0,0],t.forEach((e,t)=>{r[`lighting_uPointLight[${t}].color`]=ly(e),r[`lighting_uPointLight[${t}].position`]=e.position,r[`lighting_uPointLight[${t}].attenuation`]=e.attenuation||[1,0,0]}),r.lighting_uPointLightCount=t.length,i.forEach((e,t)=>{r[`lighting_uDirectionalLight[${t}].color`]=ly(e),r[`lighting_uDirectionalLight[${t}].direction`]=e.direction}),r.lighting_uDirectionalLightCount=i.length,r}({ambientLight:e,pointLights:i,directionalLights:r}),{lighting_uEnabled:!0}):{lighting_uEnabled:!1}}if("lights"in t){const i={pointLights:[],directionalLights:[]};for(const e of t.lights||[])switch(e.type){case"ambient":i.ambientLight=e;break;case"directional":i.directionalLights?.push(e);break;case"point":i.pointLights?.push(e)}return e({lightSources:i})}return{}},defines:{MAX_LIGHTS:3}},uy="uniform float lighting_uAmbient;\nuniform float lighting_uDiffuse;\nuniform float lighting_uShininess;\nuniform vec3 lighting_uSpecularColor;\nvec3 lighting_getLightColor(vec3 surfaceColor, vec3 light_direction, vec3 view_direction, vec3 normal_worldspace, vec3 color) {\nvec3 halfway_direction = normalize(light_direction + view_direction);\nfloat lambertian = dot(light_direction, normal_worldspace);\nfloat specular = 0.0;\nif (lambertian > 0.0) {\nfloat specular_angle = max(dot(normal_worldspace, halfway_direction), 0.0);\nspecular = pow(specular_angle, lighting_uShininess);\n}\nlambertian = max(lambertian, 0.0);\nreturn (lambertian * lighting_uDiffuse * surfaceColor + specular * lighting_uSpecularColor) * color;\n}\nvec3 lighting_getLightColor(vec3 surfaceColor, vec3 cameraPosition, vec3 position_worldspace, vec3 normal_worldspace) {\nvec3 lightColor = surfaceColor;\nif (lighting_uEnabled) {\nvec3 view_direction = normalize(cameraPosition - position_worldspace);\nlightColor = lighting_uAmbient * surfaceColor * lighting_uAmbientLight.color;\nfor (int i = 0; i < MAX_LIGHTS; i++) {\nif (i >= lighting_uPointLightCount) {\nbreak;\n}\nPointLight pointLight = lighting_uPointLight[i];\nvec3 light_position_worldspace = pointLight.position;\nvec3 light_direction = normalize(light_position_worldspace - position_worldspace);\nlightColor += lighting_getLightColor(surfaceColor, light_direction, view_direction, normal_worldspace, pointLight.color);\n}\nfor (int i = 0; i < MAX_LIGHTS; i++) {\nif (i >= lighting_uDirectionalLightCount) {\nbreak;\n}\nDirectionalLight directionalLight = lighting_uDirectionalLight[i];\nlightColor += lighting_getLightColor(surfaceColor, -directionalLight.direction, view_direction, normal_worldspace, directionalLight.color);\n}\n}\nreturn lightColor;\n}\nvec3 lighting_getSpecularLightColor(vec3 cameraPosition, vec3 position_worldspace, vec3 normal_worldspace) {\nvec3 lightColor = vec3(0, 0, 0);\nvec3 surfaceColor = vec3(0, 0, 0);\nif (lighting_uEnabled) {\nvec3 view_direction = normalize(cameraPosition - position_worldspace);\nfor (int i = 0; i < MAX_LIGHTS; i++) {\nif (i >= lighting_uPointLightCount) {\nbreak;\n}\nPointLight pointLight = lighting_uPointLight[i];\nvec3 light_position_worldspace = pointLight.position;\nvec3 light_direction = normalize(light_position_worldspace - position_worldspace);\nlightColor += lighting_getLightColor(surfaceColor, light_direction, view_direction, normal_worldspace, pointLight.color);\n}\nfor (int i = 0; i < MAX_LIGHTS; i++) {\nif (i >= lighting_uDirectionalLightCount) {\nbreak;\n}\nDirectionalLight directionalLight = lighting_uDirectionalLight[i];\nlightColor += lighting_getLightColor(surfaceColor, -directionalLight.direction, view_direction, normal_worldspace, directionalLight.color);\n}\n}\nreturn lightColor;\n}\n",hy={};function dy(e=hy){if(!("material"in e))return{};const{material:t}=e;return t?function(e){const{ambient:t=.35,diffuse:i=.6,shininess:r=32,specularColor:n=[30,30,30]}=e;return{lighting_uAmbient:t,lighting_uDiffuse:i,lighting_uShininess:r,lighting_uSpecularColor:n.map(e=>e/255)}}(t):{lighting_uEnabled:!1}}const py={name:"gouraud-lighting",dependencies:[cy],vs:uy,defines:{LIGHTING_VERTEX:1},getUniforms:dy},fy={name:"phong-lighting",dependencies:[cy],fs:uy,defines:{LIGHTING_FRAGMENT:1},getUniforms:dy},my={name:"pbr",vs:"uniform mat4 u_MVPMatrix;\nuniform mat4 u_ModelMatrix;\nuniform mat4 u_NormalMatrix;\nout vec3 pbr_vPosition;\nout vec2 pbr_vUV;\n#ifdef HAS_NORMALS\n# ifdef HAS_TANGENTS\nout mat3 pbr_vTBN;\n# else\nout vec3 pbr_vNormal;\n# endif\n#endif\nvoid pbr_setPositionNormalTangentUV(vec4 position, vec4 normal, vec4 tangent, vec2 uv)\n{\nvec4 pos = u_ModelMatrix * position;\npbr_vPosition = vec3(pos.xyz) / pos.w;\n#ifdef HAS_NORMALS\n#ifdef HAS_TANGENTS\nvec3 normalW = normalize(vec3(u_NormalMatrix * vec4(normal.xyz, 0.0)));\nvec3 tangentW = normalize(vec3(u_ModelMatrix * vec4(tangent.xyz, 0.0)));\nvec3 bitangentW = cross(normalW, tangentW) * tangent.w;\npbr_vTBN = mat3(tangentW, bitangentW, normalW);\n#else\npbr_vNormal = normalize(vec3(u_ModelMatrix * vec4(normal.xyz, 0.0)));\n#endif\n#endif\n#ifdef HAS_UV\npbr_vUV = uv;\n#else\npbr_vUV = vec2(0.,0.);\n#endif\n}\n",fs:"precision highp float;\nuniform bool pbr_uUnlit;\n#ifdef USE_IBL\nuniform samplerCube u_DiffuseEnvSampler;\nuniform samplerCube u_SpecularEnvSampler;\nuniform sampler2D u_brdfLUT;\nuniform vec2 u_ScaleIBLAmbient;\n#endif\n#ifdef HAS_BASECOLORMAP\nuniform sampler2D u_BaseColorSampler;\n#endif\n#ifdef HAS_NORMALMAP\nuniform sampler2D u_NormalSampler;\nuniform float u_NormalScale;\n#endif\n#ifdef HAS_EMISSIVEMAP\nuniform sampler2D u_EmissiveSampler;\nuniform vec3 u_EmissiveFactor;\n#endif\n#ifdef HAS_METALROUGHNESSMAP\nuniform sampler2D u_MetallicRoughnessSampler;\n#endif\n#ifdef HAS_OCCLUSIONMAP\nuniform sampler2D u_OcclusionSampler;\nuniform float u_OcclusionStrength;\n#endif\n#ifdef ALPHA_CUTOFF\nuniform float u_AlphaCutoff;\n#endif\nuniform vec2 u_MetallicRoughnessValues;\nuniform vec4 u_BaseColorFactor;\nuniform vec3 u_Camera;\n#ifdef PBR_DEBUG\nuniform vec4 u_ScaleDiffBaseMR;\nuniform vec4 u_ScaleFGDSpec;\n#endif\nin vec3 pbr_vPosition;\nin vec2 pbr_vUV;\n#ifdef HAS_NORMALS\n#ifdef HAS_TANGENTS\nin mat3 pbr_vTBN;\n#else\nin vec3 pbr_vNormal;\n#endif\n#endif\nstruct PBRInfo\n{\nfloat NdotL;\nfloat NdotV;\nfloat NdotH;\nfloat LdotH;\nfloat VdotH;\nfloat perceptualRoughness;\nfloat metalness;\nvec3 reflectance0;\nvec3 reflectance90;\nfloat alphaRoughness;\nvec3 diffuseColor;\nvec3 specularColor;\nvec3 n;\nvec3 v;\n};\nconst float M_PI = 3.141592653589793;\nconst float c_MinRoughness = 0.04;\nvec4 SRGBtoLINEAR(vec4 srgbIn)\n{\n#ifdef MANUAL_SRGB\n#ifdef SRGB_FAST_APPROXIMATION\nvec3 linOut = pow(srgbIn.xyz,vec3(2.2));\n#else\nvec3 bLess = step(vec3(0.04045),srgbIn.xyz);\nvec3 linOut = mix( srgbIn.xyz/vec3(12.92), pow((srgbIn.xyz+vec3(0.055))/vec3(1.055),vec3(2.4)), bLess );\n#endif\nreturn vec4(linOut,srgbIn.w);;\n#else\nreturn srgbIn;\n#endif\n}\nvec3 getNormal()\n{\n#ifndef HAS_TANGENTS\nvec3 pos_dx = dFdx(pbr_vPosition);\nvec3 pos_dy = dFdy(pbr_vPosition);\nvec3 tex_dx = dFdx(vec3(pbr_vUV, 0.0));\nvec3 tex_dy = dFdy(vec3(pbr_vUV, 0.0));\nvec3 t = (tex_dy.t * pos_dx - tex_dx.t * pos_dy) / (tex_dx.s * tex_dy.t - tex_dy.s * tex_dx.t);\n#ifdef HAS_NORMALS\nvec3 ng = normalize(pbr_vNormal);\n#else\nvec3 ng = cross(pos_dx, pos_dy);\n#endif\nt = normalize(t - ng * dot(ng, t));\nvec3 b = normalize(cross(ng, t));\nmat3 tbn = mat3(t, b, ng);\n#else\nmat3 tbn = pbr_vTBN;\n#endif\n#ifdef HAS_NORMALMAP\nvec3 n = texture(u_NormalSampler, pbr_vUV).rgb;\nn = normalize(tbn * ((2.0 * n - 1.0) * vec3(u_NormalScale, u_NormalScale, 1.0)));\n#else\nvec3 n = normalize(tbn[2].xyz);\n#endif\nreturn n;\n}\n#ifdef USE_IBL\nvec3 getIBLContribution(PBRInfo pbrInputs, vec3 n, vec3 reflection)\n{\nfloat mipCount = 9.0;\nfloat lod = (pbrInputs.perceptualRoughness * mipCount);\nvec3 brdf = SRGBtoLINEAR(texture(u_brdfLUT,\nvec2(pbrInputs.NdotV, 1.0 - pbrInputs.perceptualRoughness))).rgb;\nvec3 diffuseLight = SRGBtoLINEAR(textureCube(u_DiffuseEnvSampler, n)).rgb;\n#ifdef USE_TEX_LOD\nvec3 specularLight = SRGBtoLINEAR(textureCubeLod(u_SpecularEnvSampler, reflection, lod)).rgb;\n#else\nvec3 specularLight = SRGBtoLINEAR(textureCube(u_SpecularEnvSampler, reflection)).rgb;\n#endif\nvec3 diffuse = diffuseLight * pbrInputs.diffuseColor;\nvec3 specular = specularLight * (pbrInputs.specularColor * brdf.x + brdf.y);\ndiffuse *= u_ScaleIBLAmbient.x;\nspecular *= u_ScaleIBLAmbient.y;\nreturn diffuse + specular;\n}\n#endif\nvec3 diffuse(PBRInfo pbrInputs)\n{\nreturn pbrInputs.diffuseColor / M_PI;\n}\nvec3 specularReflection(PBRInfo pbrInputs)\n{\nreturn pbrInputs.reflectance0 +\n(pbrInputs.reflectance90 - pbrInputs.reflectance0) *\npow(clamp(1.0 - pbrInputs.VdotH, 0.0, 1.0), 5.0);\n}\nfloat geometricOcclusion(PBRInfo pbrInputs)\n{\nfloat NdotL = pbrInputs.NdotL;\nfloat NdotV = pbrInputs.NdotV;\nfloat r = pbrInputs.alphaRoughness;\nfloat attenuationL = 2.0 * NdotL / (NdotL + sqrt(r * r + (1.0 - r * r) * (NdotL * NdotL)));\nfloat attenuationV = 2.0 * NdotV / (NdotV + sqrt(r * r + (1.0 - r * r) * (NdotV * NdotV)));\nreturn attenuationL * attenuationV;\n}\nfloat microfacetDistribution(PBRInfo pbrInputs)\n{\nfloat roughnessSq = pbrInputs.alphaRoughness * pbrInputs.alphaRoughness;\nfloat f = (pbrInputs.NdotH * roughnessSq - pbrInputs.NdotH) * pbrInputs.NdotH + 1.0;\nreturn roughnessSq / (M_PI * f * f);\n}\nvoid PBRInfo_setAmbientLight(inout PBRInfo pbrInputs) {\npbrInputs.NdotL = 1.0;\npbrInputs.NdotH = 0.0;\npbrInputs.LdotH = 0.0;\npbrInputs.VdotH = 1.0;\n}\nvoid PBRInfo_setDirectionalLight(inout PBRInfo pbrInputs, vec3 lightDirection) {\nvec3 n = pbrInputs.n;\nvec3 v = pbrInputs.v;\nvec3 l = normalize(lightDirection);\nvec3 h = normalize(l+v);\npbrInputs.NdotL = clamp(dot(n, l), 0.001, 1.0);\npbrInputs.NdotH = clamp(dot(n, h), 0.0, 1.0);\npbrInputs.LdotH = clamp(dot(l, h), 0.0, 1.0);\npbrInputs.VdotH = clamp(dot(v, h), 0.0, 1.0);\n}\nvoid PBRInfo_setPointLight(inout PBRInfo pbrInputs, PointLight pointLight) {\nvec3 light_direction = normalize(pointLight.position - pbr_vPosition);\nPBRInfo_setDirectionalLight(pbrInputs, light_direction);\n}\nvec3 calculateFinalColor(PBRInfo pbrInputs, vec3 lightColor) {\nvec3 F = specularReflection(pbrInputs);\nfloat G = geometricOcclusion(pbrInputs);\nfloat D = microfacetDistribution(pbrInputs);\nvec3 diffuseContrib = (1.0 - F) * diffuse(pbrInputs);\nvec3 specContrib = F * G * D / (4.0 * pbrInputs.NdotL * pbrInputs.NdotV);\nreturn pbrInputs.NdotL * lightColor * (diffuseContrib + specContrib);\n}\nvec4 pbr_filterColor(vec4 colorUnused)\n{\n#ifdef HAS_BASECOLORMAP\nvec4 baseColor = SRGBtoLINEAR(texture(u_BaseColorSampler, pbr_vUV)) * u_BaseColorFactor;\n#else\nvec4 baseColor = u_BaseColorFactor;\n#endif\n#ifdef ALPHA_CUTOFF\nif (baseColor.a < u_AlphaCutoff) {\ndiscard;\n}\n#endif\nvec3 color = vec3(0, 0, 0);\nif(pbr_uUnlit){\ncolor.rgb = baseColor.rgb;\n}\nelse{\nfloat perceptualRoughness = u_MetallicRoughnessValues.y;\nfloat metallic = u_MetallicRoughnessValues.x;\n#ifdef HAS_METALROUGHNESSMAP\nvec4 mrSample = texture(u_MetallicRoughnessSampler, pbr_vUV);\nperceptualRoughness = mrSample.g * perceptualRoughness;\nmetallic = mrSample.b * metallic;\n#endif\nperceptualRoughness = clamp(perceptualRoughness, c_MinRoughness, 1.0);\nmetallic = clamp(metallic, 0.0, 1.0);\nfloat alphaRoughness = perceptualRoughness * perceptualRoughness;\nvec3 f0 = vec3(0.04);\nvec3 diffuseColor = baseColor.rgb * (vec3(1.0) - f0);\ndiffuseColor *= 1.0 - metallic;\nvec3 specularColor = mix(f0, baseColor.rgb, metallic);\nfloat reflectance = max(max(specularColor.r, specularColor.g), specularColor.b);\nfloat reflectance90 = clamp(reflectance * 25.0, 0.0, 1.0);\nvec3 specularEnvironmentR0 = specularColor.rgb;\nvec3 specularEnvironmentR90 = vec3(1.0, 1.0, 1.0) * reflectance90;\nvec3 n = getNormal();\nvec3 v = normalize(u_Camera - pbr_vPosition);\nfloat NdotV = clamp(abs(dot(n, v)), 0.001, 1.0);\nvec3 reflection = -normalize(reflect(v, n));\nPBRInfo pbrInputs = PBRInfo(\n0.0,\nNdotV,\n0.0,\n0.0,\n0.0,\nperceptualRoughness,\nmetallic,\nspecularEnvironmentR0,\nspecularEnvironmentR90,\nalphaRoughness,\ndiffuseColor,\nspecularColor,\nn,\nv\n);\n#ifdef USE_LIGHTS\nPBRInfo_setAmbientLight(pbrInputs);\ncolor += calculateFinalColor(pbrInputs, lighting_uAmbientLight.color);\nfor(int i = 0; i < lighting_uDirectionalLightCount; i++) {\nif (i < lighting_uDirectionalLightCount) {\nPBRInfo_setDirectionalLight(pbrInputs, lighting_uDirectionalLight[i].direction);\ncolor += calculateFinalColor(pbrInputs, lighting_uDirectionalLight[i].color);\n}\n}\nfor(int i = 0; i < lighting_uPointLightCount; i++) {\nif (i < lighting_uPointLightCount) {\nPBRInfo_setPointLight(pbrInputs, lighting_uPointLight[i]);\nfloat attenuation = getPointLightAttenuation(lighting_uPointLight[i], distance(lighting_uPointLight[i].position, pbr_vPosition));\ncolor += calculateFinalColor(pbrInputs, lighting_uPointLight[i].color / attenuation);\n}\n}\n#endif\n#ifdef USE_IBL\ncolor += getIBLContribution(pbrInputs, n, reflection);\n#endif\n#ifdef HAS_OCCLUSIONMAP\nfloat ao = texture(u_OcclusionSampler, pbr_vUV).r;\ncolor = mix(color, color * ao, u_OcclusionStrength);\n#endif\n#ifdef HAS_EMISSIVEMAP\nvec3 emissive = SRGBtoLINEAR(texture(u_EmissiveSampler, pbr_vUV)).rgb * u_EmissiveFactor;\ncolor += emissive;\n#endif\n#ifdef PBR_DEBUG\ncolor = mix(color, baseColor.rgb, u_ScaleDiffBaseMR.y);\ncolor = mix(color, vec3(metallic), u_ScaleDiffBaseMR.z);\ncolor = mix(color, vec3(perceptualRoughness), u_ScaleDiffBaseMR.w);\n#endif\n}\nreturn vec4(pow(color,vec3(1.0/2.2)), baseColor.a);\n}\n",defines:{LIGHTING_FRAGMENT:1},dependencies:[cy]},gy="#define SMOOTH_EDGE_RADIUS 0.5";var _y={name:"geometry",vs:`\n${gy}\n\nstruct VertexGeometry {\n vec4 position;\n vec3 worldPosition;\n vec3 worldPositionAlt;\n vec3 normal;\n vec2 uv;\n vec3 pickingColor;\n} geometry = VertexGeometry(\n vec4(0.0, 0.0, 1.0, 0.0),\n vec3(0.0),\n vec3(0.0),\n vec3(0.0),\n vec2(0.0),\n vec3(0.0)\n);\n`,fs:`\n${gy}\n\nstruct FragmentGeometry {\n vec2 uv;\n} geometry;\n\nfloat smoothedge(float edge, float x) {\n return smoothstep(edge - SMOOTH_EDGE_RADIUS, edge + SMOOTH_EDGE_RADIUS, x);\n}\n`};const Ay={DEFAULT:-1,LNGLAT:1,METER_OFFSETS:2,LNGLAT_OFFSETS:3,CARTESIAN:0};Object.defineProperty(Ay,"IDENTITY",{get:()=>(rp.deprecated("COORDINATE_SYSTEM.IDENTITY","COORDINATE_SYSTEM.CARTESIAN")(),0)});const yy={WEB_MERCATOR:1,GLOBE:2,WEB_MERCATOR_AUTO_OFFSET:4,IDENTITY:0},vy={common:0,meters:1,pixels:2},xy={click:{handler:"onClick"},panstart:{handler:"onDragStart"},panmove:{handler:"onDrag"},panend:{handler:"onDragEnd"}};var by=`${Object.keys(Ay).map(e=>`const int COORDINATE_SYSTEM_${e} = ${Ay[e]};`).join("")}\n${Object.keys(yy).map(e=>`const int PROJECTION_MODE_${e} = ${yy[e]};`).join("")}\n${Object.keys(vy).map(e=>`const int UNIT_${e.toUpperCase()} = ${vy[e]};`).join("")}\nuniform int project_uCoordinateSystem;\nuniform int project_uProjectionMode;\nuniform float project_uScale;\nuniform bool project_uWrapLongitude;\nuniform vec3 project_uCommonUnitsPerMeter;\nuniform vec3 project_uCommonUnitsPerWorldUnit;\nuniform vec3 project_uCommonUnitsPerWorldUnit2;\nuniform vec4 project_uCenter;\nuniform mat4 project_uModelMatrix;\nuniform mat4 project_uViewProjectionMatrix;\nuniform vec2 project_uViewportSize;\nuniform float project_uDevicePixelRatio;\nuniform float project_uFocalDistance;\nuniform vec3 project_uCameraPosition;\nuniform vec3 project_uCoordinateOrigin;\nuniform vec3 project_uCommonOrigin;\nuniform bool project_uPseudoMeters;\nconst float TILE_SIZE = 512.0;\nconst float PI = 3.1415926536;\nconst float WORLD_SCALE = TILE_SIZE / (PI * 2.0);\nconst vec3 ZERO_64_LOW = vec3(0.0);\nconst float EARTH_RADIUS = 6370972.0;\nconst float GLOBE_RADIUS = 256.0;\nfloat project_size_at_latitude(float lat) {\nfloat y = clamp(lat, -89.9, 89.9);\nreturn 1.0 / cos(radians(y));\n}\nfloat project_size() {\nif (project_uProjectionMode == PROJECTION_MODE_WEB_MERCATOR &&\nproject_uCoordinateSystem == COORDINATE_SYSTEM_LNGLAT &&\nproject_uPseudoMeters == false) {\nif (geometry.position.w == 0.0) {\nreturn project_size_at_latitude(geometry.worldPosition.y);\n}\nfloat y = geometry.position.y / TILE_SIZE * 2.0 - 1.0;\nfloat y2 = y * y;\nfloat y4 = y2 * y2;\nfloat y6 = y4 * y2;\nreturn 1.0 + 4.9348 * y2 + 4.0587 * y4 + 1.5642 * y6;\n}\nreturn 1.0;\n}\nfloat project_size_at_latitude(float meters, float lat) {\nreturn meters * project_uCommonUnitsPerMeter.z * project_size_at_latitude(lat);\n}\nfloat project_size(float meters) {\nreturn meters * project_uCommonUnitsPerMeter.z * project_size();\n}\nvec2 project_size(vec2 meters) {\nreturn meters * project_uCommonUnitsPerMeter.xy * project_size();\n}\nvec3 project_size(vec3 meters) {\nreturn meters * project_uCommonUnitsPerMeter * project_size();\n}\nvec4 project_size(vec4 meters) {\nreturn vec4(meters.xyz * project_uCommonUnitsPerMeter, meters.w);\n}\nmat3 project_get_orientation_matrix(vec3 up) {\nvec3 uz = normalize(up);\nvec3 ux = abs(uz.z) == 1.0 ? vec3(1.0, 0.0, 0.0) : normalize(vec3(uz.y, -uz.x, 0));\nvec3 uy = cross(uz, ux);\nreturn mat3(ux, uy, uz);\n}\nbool project_needs_rotation(vec3 commonPosition, out mat3 transform) {\nif (project_uProjectionMode == PROJECTION_MODE_GLOBE) {\ntransform = project_get_orientation_matrix(commonPosition);\nreturn true;\n}\nreturn false;\n}\nvec3 project_normal(vec3 vector) {\nvec4 normal_modelspace = project_uModelMatrix * vec4(vector, 0.0);\nvec3 n = normalize(normal_modelspace.xyz * project_uCommonUnitsPerMeter);\nmat3 rotation;\nif (project_needs_rotation(geometry.position.xyz, rotation)) {\nn = rotation * n;\n}\nreturn n;\n}\nvec4 project_offset_(vec4 offset) {\nfloat dy = offset.y;\nvec3 commonUnitsPerWorldUnit = project_uCommonUnitsPerWorldUnit + project_uCommonUnitsPerWorldUnit2 * dy;\nreturn vec4(offset.xyz * commonUnitsPerWorldUnit, offset.w);\n}\nvec2 project_mercator_(vec2 lnglat) {\nfloat x = lnglat.x;\nif (project_uWrapLongitude) {\nx = mod(x + 180., 360.0) - 180.;\n}\nfloat y = clamp(lnglat.y, -89.9, 89.9);\nreturn vec2(\nradians(x) + PI,\nPI + log(tan_fp32(PI * 0.25 + radians(y) * 0.5))\n) * WORLD_SCALE;\n}\nvec3 project_globe_(vec3 lnglatz) {\nfloat lambda = radians(lnglatz.x);\nfloat phi = radians(lnglatz.y);\nfloat cosPhi = cos(phi);\nfloat D = (lnglatz.z / EARTH_RADIUS + 1.0) * GLOBE_RADIUS;\nreturn vec3(\nsin(lambda) * cosPhi,\n-cos(lambda) * cosPhi,\nsin(phi)\n) * D;\n}\nvec4 project_position(vec4 position, vec3 position64Low) {\nvec4 position_world = project_uModelMatrix * position;\nif (project_uProjectionMode == PROJECTION_MODE_WEB_MERCATOR) {\nif (project_uCoordinateSystem == COORDINATE_SYSTEM_LNGLAT) {\nreturn vec4(\nproject_mercator_(position_world.xy),\nproject_size_at_latitude(position_world.z, position_world.y),\nposition_world.w\n);\n}\nif (project_uCoordinateSystem == COORDINATE_SYSTEM_CARTESIAN) {\nposition_world.xyz += project_uCoordinateOrigin;\n}\n}\nif (project_uProjectionMode == PROJECTION_MODE_GLOBE) {\nif (project_uCoordinateSystem == COORDINATE_SYSTEM_LNGLAT) {\nreturn vec4(\nproject_globe_(position_world.xyz),\nposition_world.w\n);\n}\n}\nif (project_uProjectionMode == PROJECTION_MODE_WEB_MERCATOR_AUTO_OFFSET) {\nif (project_uCoordinateSystem == COORDINATE_SYSTEM_LNGLAT) {\nif (abs(position_world.y - project_uCoordinateOrigin.y) > 0.25) {\nreturn vec4(\nproject_mercator_(position_world.xy) - project_uCommonOrigin.xy,\nproject_size(position_world.z),\nposition_world.w\n);\n}\n}\n}\nif (project_uProjectionMode == PROJECTION_MODE_IDENTITY ||\n(project_uProjectionMode == PROJECTION_MODE_WEB_MERCATOR_AUTO_OFFSET &&\n(project_uCoordinateSystem == COORDINATE_SYSTEM_LNGLAT ||\nproject_uCoordinateSystem == COORDINATE_SYSTEM_CARTESIAN))) {\nposition_world.xyz -= project_uCoordinateOrigin;\n}\nreturn project_offset_(position_world) + project_offset_(project_uModelMatrix * vec4(position64Low, 0.0));\n}\nvec4 project_position(vec4 position) {\nreturn project_position(position, ZERO_64_LOW);\n}\nvec3 project_position(vec3 position, vec3 position64Low) {\nvec4 projected_position = project_position(vec4(position, 1.0), position64Low);\nreturn projected_position.xyz;\n}\nvec3 project_position(vec3 position) {\nvec4 projected_position = project_position(vec4(position, 1.0), ZERO_64_LOW);\nreturn projected_position.xyz;\n}\nvec2 project_position(vec2 position) {\nvec4 projected_position = project_position(vec4(position, 0.0, 1.0), ZERO_64_LOW);\nreturn projected_position.xy;\n}\nvec4 project_common_position_to_clipspace(vec4 position, mat4 viewProjectionMatrix, vec4 center) {\nreturn viewProjectionMatrix * position + center;\n}\nvec4 project_common_position_to_clipspace(vec4 position) {\nreturn project_common_position_to_clipspace(position, project_uViewProjectionMatrix, project_uCenter);\n}\nvec2 project_pixel_size_to_clipspace(vec2 pixels) {\nvec2 offset = pixels / project_uViewportSize * project_uDevicePixelRatio * 2.0;\nreturn offset * project_uFocalDistance;\n}\nfloat project_size_to_pixel(float meters) {\nreturn project_size(meters) * project_uScale;\n}\nfloat project_size_to_pixel(float size, int unit) {\nif (unit == UNIT_METERS) return project_size_to_pixel(size);\nif (unit == UNIT_COMMON) return size * project_uScale;\nreturn size;\n}\nfloat project_pixel_size(float pixels) {\nreturn pixels / project_uScale;\n}\nvec2 project_pixel_size(vec2 pixels) {\nreturn pixels / project_uScale;\n}\n`;function wy(e,t){if(e===t)return!0;if(Array.isArray(e)){const i=e.length;if(!t||t.length!==i)return!1;for(let r=0;r{for(const n in r)if(!wy(r[n],i[n])){t=e(r),i=r;break}return t}}const Ey=[0,0,0,0],Cy=[1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,0],By=[1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1],Sy=[0,0,0],Iy=[0,0,0],My=Ty(function({viewport:e,devicePixelRatio:t,coordinateSystem:i,coordinateOrigin:r}){const{projectionCenter:n,viewProjectionMatrix:o,originCommon:s,cameraPosCommon:a,shaderCoordinateOrigin:l,geospatialOrigin:c}=function(e,t,i){const{viewMatrixUncentered:r,projectionMatrix:n}=e;let{viewMatrix:o,viewProjectionMatrix:s}=e,a=Ey,l=Ey,c=e.cameraPosition;const{geospatialOrigin:u,shaderCoordinateOrigin:h,offsetMode:d}=Py(e,t,i);d&&(l=e.projectPosition(u||h),c=[c[0]-l[0],c[1]-l[1],c[2]-l[2]],l[3]=1,a=FA([],l,s),o=r||o,s=CA([],n,o),s=CA([],s,Cy));return{viewMatrix:o,viewProjectionMatrix:s,projectionCenter:a,originCommon:l,cameraPosCommon:c,shaderCoordinateOrigin:h,geospatialOrigin:u}}(e,i,r),u=e.getDistanceScales(),h=[e.width*t,e.height*t],d=FA([],[0,0,-e.focalDistance,1],e.projectionMatrix)[3]||1,p={project_uCoordinateSystem:i,project_uProjectionMode:e.projectionMode,project_uCoordinateOrigin:l,project_uCommonOrigin:s.slice(0,3),project_uCenter:n,project_uPseudoMeters:Boolean(e._pseudoMeters),project_uViewportSize:h,project_uDevicePixelRatio:t,project_uFocalDistance:d,project_uCommonUnitsPerMeter:u.unitsPerMeter,project_uCommonUnitsPerWorldUnit:u.unitsPerMeter,project_uCommonUnitsPerWorldUnit2:Sy,project_uScale:e.scale,project_uWrapLongitude:!1,project_uViewProjectionMatrix:o,project_uModelMatrix:By,project_uCameraPosition:a};if(c){const t=e.getDistanceScales(c);switch(i){case Ay.METER_OFFSETS:p.project_uCommonUnitsPerWorldUnit=t.unitsPerMeter,p.project_uCommonUnitsPerWorldUnit2=t.unitsPerMeter2;break;case Ay.LNGLAT:case Ay.LNGLAT_OFFSETS:e._pseudoMeters||(p.project_uCommonUnitsPerMeter=t.unitsPerMeter),p.project_uCommonUnitsPerWorldUnit=t.unitsPerDegree,p.project_uCommonUnitsPerWorldUnit2=t.unitsPerDegree2;break;case Ay.CARTESIAN:p.project_uCommonUnitsPerWorldUnit=[1,1,t.unitsPerMeter[2]],p.project_uCommonUnitsPerWorldUnit2=[0,0,t.unitsPerMeter2[2]]}}return p});function Py(e,t,i=Iy){i.length<3&&(i=[i[0],i[1],0]);let r,n=i,o=!0;switch(r=t===Ay.LNGLAT_OFFSETS||t===Ay.METER_OFFSETS?i:e.isGeospatial?[Math.fround(e.longitude),Math.fround(e.latitude),0]:null,e.projectionMode){case yy.WEB_MERCATOR:t!==Ay.LNGLAT&&t!==Ay.CARTESIAN||(r=[0,0,0],o=!1);break;case yy.WEB_MERCATOR_AUTO_OFFSET:t===Ay.LNGLAT?n=r:t===Ay.CARTESIAN&&(n=[Math.fround(e.center[0]),Math.fround(e.center[1]),0],r=e.unprojectPosition(n),n[0]-=i[0],n[1]-=i[1],n[2]-=i[2]);break;case yy.IDENTITY:n=e.position.map(Math.fround),n[2]=n[2]||0;break;case yy.GLOBE:o=!1,r=null;break;default:o=!1}return{geospatialOrigin:r,shaderCoordinateOrigin:n,offsetMode:o}}const Ry={};var Ly={name:"project",dependencies:[b_,_y],vs:by,getUniforms:function(e=Ry){return"viewport"in e?function({viewport:e,devicePixelRatio:t=1,modelMatrix:i=null,coordinateSystem:r=Ay.DEFAULT,coordinateOrigin:n=Iy,autoWrapLongitude:o=!1}){r===Ay.DEFAULT&&(r=e.isGeospatial?Ay.LNGLAT:Ay.CARTESIAN);const s=My({viewport:e,devicePixelRatio:t,coordinateSystem:r,coordinateOrigin:n});return s.project_uWrapLongitude=o,s.project_uModelMatrix=i||By,s}(e):{}}};var Fy={name:"project32",dependencies:[Ly],vs:"\nvec4 project_position_to_clipspace(\n vec3 position, vec3 position64Low, vec3 offset, out vec4 commonPosition\n) {\n vec3 projectedPosition = project_position(position, position64Low);\n mat3 rotation;\n if (project_needs_rotation(projectedPosition, rotation)) {\n // offset is specified as ENU\n // when in globe projection, rotate offset so that the ground alighs with the surface of the globe\n offset = rotation * offset;\n }\n commonPosition = vec4(projectedPosition + offset, 1.0);\n return project_common_position_to_clipspace(commonPosition);\n}\n\nvec4 project_position_to_clipspace(\n vec3 position, vec3 position64Low, vec3 offset\n) {\n vec4 commonPosition;\n return project_position_to_clipspace(position, position64Low, offset, commonPosition);\n}\n"};function ky(e,t){const i=FA([],t,e);return LA(i,i,1/i[3]),i}function Dy(e,t){const i=e%t;return i<0?t+i:i}function Oy(e,t,i){return ei?i:e}const zy=Math.log2||function(e){return Math.log(e)*Math.LOG2E};function Uy(e,t){if(!e)throw new Error(t||"@math.gl/web-mercator: assertion failed.")}const Ny=Math.PI,Vy=Ny/4,jy=Ny/180,Gy=180/Ny,Hy=512,Qy=4003e4,$y=85.051129,Zy=1.5;function Wy(e){const[t,i]=e;Uy(Number.isFinite(t)),Uy(Number.isFinite(i)&&i>=-90&&i<=90,"invalid latitude");const r=i*jy;return[Hy*(t*jy+Ny)/(2*Ny),Hy*(Ny+Math.log(Math.tan(Vy+.5*r)))/(2*Ny)]}function qy(e){const[t,i]=e,r=t/Hy*(2*Ny)-Ny,n=2*(Math.atan(Math.exp(i/Hy*(2*Ny)-Ny))-Vy);return[r*Gy,n*Gy]}function Ky(e){const{latitude:t}=e;Uy(Number.isFinite(t));const i=Math.cos(t*jy);return function(e){return zy(e)}(Qy*i)-9}function Xy(e){return 12790407194604047e-21/Math.cos(e*jy)}function Jy(e){const{latitude:t,longitude:i,highPrecision:r=!1}=e;Uy(Number.isFinite(t)&&Number.isFinite(i));const n=Hy,o=Math.cos(t*jy),s=n/360,a=s/o,l=12790407194604047e-21/o,c={unitsPerMeter:[l,l,l],metersPerUnit:[1/l,1/l,1/l],unitsPerDegree:[s,a,l],degreesPerUnit:[.703125,1/a,1/l]};if(r){const e=jy*Math.tan(t*jy)/o,i=s*e/2,r=12790407194604047e-21*e,n=r/a*l;c.unitsPerDegree2=[0,i,r],c.unitsPerMeter2=[n,0,n]}return c}function Yy(e,t){const[i,r,n]=e,[o,s,a]=t,{unitsPerMeter:l,unitsPerMeter2:c}=Jy({longitude:i,latitude:r,highPrecision:!0}),u=Wy(e);u[0]+=o*(l[0]+c[0]*s),u[1]+=s*(l[1]+c[1]*s);const h=qy(u),d=(n||0)+(a||0);return Number.isFinite(n)||Number.isFinite(a)?[h[0],h[1],d]:h}function ev(e){return 2*Math.atan(.5/e)*Gy}function tv(e){return.5/Math.tan(.5*e*jy)}function iv(e,t){const[i,r,n=0]=e;return Uy(Number.isFinite(i)&&Number.isFinite(r)&&Number.isFinite(n)),ky(t,[i,r,n,1])}function rv(e,t,i=0){const[r,n,o]=e;if(Uy(Number.isFinite(r)&&Number.isFinite(n),"invalid pixel coordinate"),Number.isFinite(o)){return ky(t,[r,n,o,1])}const s=ky(t,[r,n,0,1]),a=ky(t,[r,n,1,1]),l=s[2],c=a[2];return q_([],s,a,l===c?0:((i||0)-l)/(c-l))}function nv(e){const{width:t,height:i,bounds:r,minExtent:n=0,maxZoom:o=24,offset:s=[0,0]}=e,[[a,l],[c,u]]=r,h=function(e=0){if("number"==typeof e)return{top:e,bottom:e,left:e,right:e};return Uy(Number.isFinite(e.top)&&Number.isFinite(e.bottom)&&Number.isFinite(e.left)&&Number.isFinite(e.right)),e}(e.padding),d=Wy([a,Oy(u,-85.051129,$y)]),p=Wy([c,Oy(l,-85.051129,$y)]),f=[Math.max(Math.abs(p[0]-d[0]),n),Math.max(Math.abs(p[1]-d[1]),n)],m=[t-h.left-h.right-2*Math.abs(s[0]),i-h.top-h.bottom-2*Math.abs(s[1])];Uy(m[0]>0&&m[1]>0);const g=m[0]/f[0],_=m[1]/f[1],A=(h.right-h.left)/2/g,y=(h.top-h.bottom)/2/_,v=qy([(p[0]+d[0])/2+A,(p[1]+d[1])/2+y]),x=Math.min(o,zy(Math.abs(Math.min(g,_))));return Uy(Number.isFinite(x)),{longitude:v[0],latitude:v[1],zoom:x}}const ov=Math.PI/180;function sv(e,t,i){const{pixelUnprojectionMatrix:r}=e,n=ky(r,[t,0,1,1]),o=ky(r,[t,e.height,1,1]),s=qy(q_([],n,o,(i*e.distanceScales.unitsPerMeter[2]-n[2])/(o[2]-n[2])));return s.push(i),s}const av=Ty(function({viewport:e,center:t}){return new VA(e.viewProjectionMatrix).invert().transform(t)}),lv=Ty(function({viewport:e,shadowMatrices:t}){const i=[],r=e.pixelUnprojectionMatrix,n=e.isGeospatial?void 0:1,o=[[0,0,n],[e.width,0,n],[0,e.height,n],[e.width,e.height,n],[0,0,-1],[e.width,0,-1],[0,e.height,-1],[e.width,e.height,-1]].map(e=>function(e,t){const[i,r,n]=e,o=rv([i,r,n],t);if(Number.isFinite(n))return o;return[o[0],o[1],0]}(e,r));for(const r of t){const t=r.clone().translate(new mA(e.center).negate()),n=o.map(e=>t.transform(e)),s=(new VA).ortho({left:Math.min(...n.map(e=>e[0])),right:Math.max(...n.map(e=>e[0])),bottom:Math.min(...n.map(e=>e[1])),top:Math.max(...n.map(e=>e[1])),near:Math.min(...n.map(e=>-e[2])),far:Math.max(...n.map(e=>-e[2]))});i.push(s.multiplyRight(r))}return i}),cv=[0,0,0,1],uv=[1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,0];var hv={name:"shadow",dependencies:[Ly],vs:"\nconst int max_lights = 2;\nuniform mat4 shadow_uViewProjectionMatrices[max_lights];\nuniform vec4 shadow_uProjectCenters[max_lights];\nuniform bool shadow_uDrawShadowMap;\nuniform bool shadow_uUseShadowMap;\nuniform int shadow_uLightId;\nuniform float shadow_uLightCount;\n\nout vec3 shadow_vPosition[max_lights];\n\nvec4 shadow_setVertexPosition(vec4 position_commonspace) {\n if (shadow_uDrawShadowMap) {\n return project_common_position_to_clipspace(position_commonspace, shadow_uViewProjectionMatrices[shadow_uLightId], shadow_uProjectCenters[shadow_uLightId]);\n }\n if (shadow_uUseShadowMap) {\n for (int i = 0; i < max_lights; i++) {\n if(i < int(shadow_uLightCount)) {\n vec4 shadowMap_position = project_common_position_to_clipspace(position_commonspace, shadow_uViewProjectionMatrices[i], shadow_uProjectCenters[i]);\n shadow_vPosition[i] = (shadowMap_position.xyz / shadowMap_position.w + 1.0) / 2.0;\n }\n }\n }\n return gl_Position;\n}\n",fs:"\nconst int max_lights = 2;\nuniform bool shadow_uDrawShadowMap;\nuniform bool shadow_uUseShadowMap;\nuniform sampler2D shadow_uShadowMap0;\nuniform sampler2D shadow_uShadowMap1;\nuniform vec4 shadow_uColor;\nuniform float shadow_uLightCount;\n\nin vec3 shadow_vPosition[max_lights];\n\nconst vec4 bitPackShift = vec4(1.0, 255.0, 65025.0, 16581375.0);\nconst vec4 bitUnpackShift = 1.0 / bitPackShift;\nconst vec4 bitMask = vec4(1.0 / 255.0, 1.0 / 255.0, 1.0 / 255.0, 0.0);\n\nfloat shadow_getShadowWeight(vec3 position, sampler2D shadowMap) {\n vec4 rgbaDepth = texture(shadowMap, position.xy);\n\n float z = dot(rgbaDepth, bitUnpackShift);\n return smoothstep(0.001, 0.01, position.z - z);\n}\n\nvec4 shadow_filterShadowColor(vec4 color) {\n if (shadow_uDrawShadowMap) {\n vec4 rgbaDepth = fract(gl_FragCoord.z * bitPackShift);\n rgbaDepth -= rgbaDepth.gbaa * bitMask;\n return rgbaDepth;\n }\n if (shadow_uUseShadowMap) {\n float shadowAlpha = 0.0;\n shadowAlpha += shadow_getShadowWeight(shadow_vPosition[0], shadow_uShadowMap0);\n if(shadow_uLightCount > 1.0) {\n shadowAlpha += shadow_getShadowWeight(shadow_vPosition[1], shadow_uShadowMap1);\n }\n shadowAlpha *= shadow_uColor.a / shadow_uLightCount;\n float blendedAlpha = shadowAlpha + color.a * (1.0 - shadowAlpha);\n\n return vec4(\n mix(color.rgb, shadow_uColor.rgb, shadowAlpha / blendedAlpha),\n blendedAlpha\n );\n }\n return color;\n}\n",inject:{"vs:DECKGL_FILTER_GL_POSITION":"\n position = shadow_setVertexPosition(geometry.position);\n ","fs:DECKGL_FILTER_COLOR":"\n color = shadow_filterShadowColor(color);\n "},getUniforms:(e={},t={})=>"viewport"in e&&(e.drawToShadowMap||e.shadowMaps&&e.shadowMaps.length>0)?function(e,t){const{shadowEnabled:i=!0}=e;if(!i||!e.shadowMatrices||!e.shadowMatrices.length)return{shadow_uDrawShadowMap:!1,shadow_uUseShadowMap:!1,shadow_uShadowMap0:e.dummyShadowMap,shadow_uShadowMap1:e.dummyShadowMap};const r={shadow_uDrawShadowMap:Boolean(e.drawToShadowMap),shadow_uUseShadowMap:!!e.shadowMaps&&e.shadowMaps.length>0,shadow_uColor:e.shadowColor||cv,shadow_uLightId:e.shadowLightId||0,shadow_uLightCount:e.shadowMatrices.length},n=av({viewport:e.viewport,center:t.project_uCenter}),o=[],s=lv({shadowMatrices:e.shadowMatrices,viewport:e.viewport}).slice();for(let i=0;ithis.device.clearWebGL(e))}const c={totalCount:t.length,visibleCount:0,compositeCount:0,pickableCount:0};e.setParameters({viewport:l});for(let i=0;i{const s=n.props._offset,a=n.id,l=n.parent&&n.parent.id;let c;if(l&&!(l in t)&&r(n.parent,!1),l in i){const e=i[l]=i[l]||Bv(t[l],t);c=e(n,o),i[a]=e}else Number.isFinite(s)?(c=s+(t[l]||0),i[a]=null):c=e;return o&&c>=e&&(e=c+1),t[a]=c,c};return r}class Sv extends Cv{constructor(e,t){super(e,t),this.shadowMap=e.createTexture({width:1,height:1,sampler:{minFilter:"linear",magFilter:"linear",addressModeU:"clamp-to-edge",addressModeV:"clamp-to-edge"}}),this.depthBuffer=e.createTexture({format:"depth16unorm",width:1,height:1,mipmaps:!1,dataFormat:6402,type:5125}),this.fbo=e.createFramebuffer({id:"shadowmap",width:1,height:1,colorAttachments:[this.shadowMap],depthStencilAttachment:this.depthBuffer})}render(e){const t=this.fbo,i=this.device.canvasContext.cssToDeviceRatio(),r=e.viewports[0],n=r.width*i,o=r.height*i;n===t.width&&o===t.height||t.resize({width:n,height:o}),super.render({...e,clearColor:[1,1,1,1],target:t,pass:"shadow"})}getLayerParameters(e,t,i){return{...e.props.parameters,blend:!1,depthRange:[0,1],depthTest:!0}}shouldDrawLayer(e){return!1!==e.props.shadowEnabled}getModuleParameters(){return{drawToShadowMap:!0}}delete(){this.fbo&&(this.fbo.destroy(),this.fbo=null),this.shadowMap&&(this.shadowMap.destroy(),this.shadowMap=null),this.depthBuffer&&(this.depthBuffer.destroy(),this.depthBuffer=null)}}const Iv={color:[255,255,255],intensity:1},Mv=[{color:[255,255,255],intensity:1,direction:[-1,3,-1]},{color:[255,255,255],intensity:.9,direction:[1,-8,-2.5]}],Pv=[0,0,0,200/255];class Rv{constructor(e={}){this.id="lighting-effect",this.shadowColor=Pv,this.shadow=!1,this.ambientLight=null,this.directionalLights=[],this.pointLights=[],this.shadowPasses=[],this.shadowMaps=[],this.dummyShadowMap=null,this.setProps(e)}setup(e){this.context=e;const{device:t,deck:i}=e;this.shadow&&!this.dummyShadowMap&&(this._createShadowPasses(t),i._addDefaultShaderModule(hv),this.dummyShadowMap=t.createTexture({width:1,height:1}))}setProps(e){this.ambientLight=null,this.directionalLights=[],this.pointLights=[];for(const t in e){const i=e[t];switch(i.type){case"ambient":this.ambientLight=i;break;case"directional":this.directionalLights.push(i);break;case"point":this.pointLights.push(i)}}this._applyDefaultLights(),this.shadow=this.directionalLights.some(e=>e.shadow),this.context&&this.setup(this.context),this.props=e}preRender({layers:e,layerFilter:t,viewports:i,onViewportActive:r,views:n}){if(this.shadow){this.shadowMatrices=this._calculateMatrices();for(let o=0;ot.getProjectedLight({layer:e})),pointLights:this.pointLights.map(t=>t.getProjectedLight({layer:e}))},t}cleanup(e){for(const e of this.shadowPasses)e.delete();this.shadowPasses.length=0,this.shadowMaps.length=0,this.dummyShadowMap&&(this.dummyShadowMap.destroy(),this.dummyShadowMap=null,e.deck._removeDefaultShaderModule(hv))}_calculateMatrices(){const e=[];for(const t of this.directionalLights){const i=(new VA).lookAt({eye:new mA(t.direction).negate()});e.push(i)}return e}_createShadowPasses(e){for(let t=0;tr&&(n=r);const o=this._pool,s=e.BYTES_PER_ELEMENT*n,a=o.findIndex(e=>e.byteLength>=s);if(a>=0){const t=new e(o.splice(a,1)[0],0,n);return i&&t.fill(0),t}return new e(n)}_release(e){if(!ArrayBuffer.isView(e))return;const t=this._pool,{buffer:i}=e,{byteLength:r}=i,n=t.findIndex(e=>e.byteLength>=r);n<0?t.push(i):(n>0||t.lengththis.opts.poolSize&&t.shift()}};const Fv=new mA;function kv(e,t,i,r){Fv.set(e,t,i);const n=Fv.len();return{distance:r/n,normal:new mA(-e/n,-t/n,-i/n)}}function Dv(e){return e-Math.fround(e)}let Ov;function zv(e,t){const{size:i=1,startIndex:r=0}=t,n=void 0!==t.endIndex?t.endIndex:e.length,o=(n-r)/i;Ov=Lv.allocate(Ov,o,{type:Float32Array,size:2*i});let s=r,a=0;for(;s(90-e.pitch)*ov-.01?(l=sv(e,0,t),c=sv(e,i,t)):(l=n([0,0],o),c=n([i,0],o)),[s,a,c,l]}(this,e.z||0);return[Math.min(t[0][0],t[1][0],t[2][0],t[3][0]),Math.min(t[0][1],t[1][1],t[2][1],t[3][1]),Math.max(t[0][0],t[1][0],t[2][0],t[3][0]),Math.max(t[0][1],t[1][1],t[2][1],t[3][1])]}fitBounds(e,t={}){const{width:i,height:r}=this,{longitude:n,latitude:o,zoom:s}=nv({width:i,height:r,bounds:e,...t});return new $v({width:i,height:r,longitude:n,latitude:o,zoom:s})}}$v.displayName="WebMercatorViewport";var Zv=$v;const Wv=[0,0,0];function qv(e,t,i=!1){const r=t.projectPosition(e);if(i&&t instanceof Zv){const[i,n,o=0]=e,s=t.getDistanceScales([i,n]);r[2]=o*s.unitsPerMeter[2]}return r}function Kv(e,{viewport:t,modelMatrix:i,coordinateSystem:r,coordinateOrigin:n,offsetMode:o}){let[s,a,l=0]=e;switch(i&&([s,a,l]=FA([],[s,a,l,1],i)),r){case Ay.LNGLAT:return qv([s,a,l],t,o);case Ay.LNGLAT_OFFSETS:return qv([s+n[0],a+n[1],l+(n[2]||0)],t,o);case Ay.METER_OFFSETS:return qv(Yy(n,[s,a,l]),t,o);case Ay.CARTESIAN:default:return t.isGeospatial?[s+n[0],a+n[1],l+n[2]]:t.projectPosition([s,a,l])}}function Xv(e,t){const{viewport:i,coordinateSystem:r,coordinateOrigin:n,modelMatrix:o,fromCoordinateSystem:s,fromCoordinateOrigin:a}=function(e){const{viewport:t,modelMatrix:i,coordinateOrigin:r}=e;let{coordinateSystem:n,fromCoordinateSystem:o,fromCoordinateOrigin:s}=e;return n===Ay.DEFAULT&&(n=t.isGeospatial?Ay.LNGLAT:Ay.CARTESIAN),void 0===o&&(o=n),void 0===s&&(s=r),{viewport:t,coordinateSystem:n,coordinateOrigin:r,modelMatrix:i,fromCoordinateSystem:o,fromCoordinateOrigin:s}}(t),{autoOffset:l=!0}=t,{geospatialOrigin:c=Wv,shaderCoordinateOrigin:u=Wv,offsetMode:h=!1}=l?Py(i,r,n):{},d=Kv(e,{viewport:i,modelMatrix:o,coordinateSystem:s,coordinateOrigin:a,offsetMode:h});if(h){const e=i.projectPosition(c||u);uA(d,d,e)}return d}let Jv=1,Yv=1;class ex{time=0;channels=new Map;animations=new Map;playing=!1;lastEngineTime=-1;constructor(){}addChannel(e){const{delay:t=0,duration:i=Number.POSITIVE_INFINITY,rate:r=1,repeat:n=1}=e,o=Jv++,s={time:0,delay:t,duration:i,rate:r,repeat:n};return this._setChannelTime(s,this.time),this.channels.set(o,s),o}removeChannel(e){this.channels.delete(e);for(const[t,i]of this.animations)i.channel===e&&this.detachAnimation(t)}isFinished(e){const t=this.channels.get(e);return void 0!==t&&this.time>=t.delay+t.duration*t.repeat}getTime(e){if(void 0===e)return this.time;const t=this.channels.get(e);return void 0===t?-1:t.time}setTime(e){this.time=Math.max(0,e);const t=this.channels.values();for(const e of t)this._setChannelTime(e,this.time);const i=this.animations.values();for(const e of i){const{animation:t,channel:i}=e;t.setTime(this.getTime(i))}}play(){this.playing=!0}pause(){this.playing=!1,this.lastEngineTime=-1}reset(){this.setTime(0)}attachAnimation(e,t){const i=Yv++;return this.animations.set(i,{animation:e,channel:t}),e.setTime(this.getTime(t)),i}detachAnimation(e){this.animations.delete(e)}update(e){this.playing&&(-1===this.lastEngineTime&&(this.lastEngineTime=e),this.setTime(this.time+(e-this.lastEngineTime)),this.lastEngineTime=e)}_setChannelTime(e,t){const i=t-e.delay;i>=e.duration*e.repeat?e.time=e.duration*e.rate:(e.time=Math.max(0,i)%e.duration,e.time*=e.rate)}}let tx=0;const ix={device:null,onAddHTML:()=>"",onInitialize:async()=>null,onRender:()=>{},onFinalize:()=>{},onError:e=>console.error(e),stats:uf.stats.get("animation-loop-"+tx++),useDevicePixels:!0,autoResizeViewport:!1,autoResizeDrawingBuffer:!1};class rx{device=null;canvas=null;props;animationProps=null;timeline=null;stats;cpuTime;gpuTime;frameRate;display;needsRedraw="initialized";_initialized=!1;_running=!1;_animationFrameId=null;_nextFramePromise=null;_resolveNextFrame=null;_cpuStartTime=0;constructor(e){if(this.props={...ix,...e},!(e=this.props).device)throw new Error("No device provided");const{useDevicePixels:t=!0}=this.props;this.stats=e.stats||new Eh({id:"animation-loop-stats"}),this.cpuTime=this.stats.get("CPU Time"),this.gpuTime=this.stats.get("GPU Time"),this.frameRate=this.stats.get("Frame Rate"),this.setProps({autoResizeViewport:e.autoResizeViewport,autoResizeDrawingBuffer:e.autoResizeDrawingBuffer,useDevicePixels:t}),this.start=this.start.bind(this),this.stop=this.stop.bind(this),this._onMousemove=this._onMousemove.bind(this),this._onMouseleave=this._onMouseleave.bind(this)}destroy(){this.stop(),this._setDisplay(null)}delete(){this.destroy()}setNeedsRedraw(e){return this.needsRedraw=this.needsRedraw||e,this}setProps(e){return"autoResizeViewport"in e&&(this.props.autoResizeViewport=e.autoResizeViewport||!1),"autoResizeDrawingBuffer"in e&&(this.props.autoResizeDrawingBuffer=e.autoResizeDrawingBuffer||!1),"useDevicePixels"in e&&(this.props.useDevicePixels=e.useDevicePixels||!1),this}async start(){if(this._running)return this;this._running=!0;try{let e;return this._initialized||(this._initialized=!0,await this._initDevice(),this._initialize(),await this.props.onInitialize(this._getAnimationProps())),this._running?(!1!==e&&(this._cancelAnimationFrame(),this._requestAnimationFrame()),this):null}catch(e){const t=e instanceof Error?e:new Error("Unknown error");throw this.props.onError(t),t}}stop(){return this._running&&(this.animationProps&&this.props.onFinalize(this.animationProps),this._cancelAnimationFrame(),this._nextFramePromise=null,this._resolveNextFrame=null,this._running=!1),this}redraw(){return this.device?.isLost||(this._beginFrameTimers(),this._setupFrame(),this._updateAnimationProps(),this._renderFrame(this._getAnimationProps()),this._clearNeedsRedraw(),this._resolveNextFrame&&(this._resolveNextFrame(this),this._nextFramePromise=null,this._resolveNextFrame=null),this._endFrameTimers()),this}attachTimeline(e){return this.timeline=e,this.timeline}detachTimeline(){this.timeline=null}waitForRender(){return this.setNeedsRedraw("waitForRender"),this._nextFramePromise||(this._nextFramePromise=new Promise(e=>{this._resolveNextFrame=e})),this._nextFramePromise}async toDataURL(){if(this.setNeedsRedraw("toDataURL"),await this.waitForRender(),this.canvas instanceof HTMLCanvasElement)return this.canvas.toDataURL();throw new Error("OffscreenCanvas")}_initialize(){this._startEventHandling(),this._initializeAnimationProps(),this._updateAnimationProps(),this._resizeCanvasDrawingBuffer(),this._resizeViewport()}_setDisplay(e){this.display&&(this.display.destroy(),this.display.animationLoop=null),e&&(e.animationLoop=this),this.display=e}_requestAnimationFrame(){var e;this._running&&(this._animationFrameId=(e=this._animationFrame.bind(this),"undefined"!=typeof window&&window.requestAnimationFrame?window.requestAnimationFrame(e):setTimeout(e,1e3/60)))}_cancelAnimationFrame(){var e;null!==this._animationFrameId&&(e=this._animationFrameId,"undefined"!=typeof window&&window.cancelAnimationFrame?window.cancelAnimationFrame(e):clearTimeout(e),this._animationFrameId=null)}_animationFrame(){this._running&&(this.redraw(),this._requestAnimationFrame())}_renderFrame(e){this.display?this.display._renderFrame(e):(this.props.onRender(this._getAnimationProps()),this.device.submit())}_clearNeedsRedraw(){this.needsRedraw=!1}_setupFrame(){this._resizeCanvasDrawingBuffer(),this._resizeViewport()}_initializeAnimationProps(){if(!this.device)throw new Error("loop");this.animationProps={animationLoop:this,device:this.device,canvas:this.device?.canvasContext?.canvas,timeline:this.timeline,useDevicePixels:this.props.useDevicePixels,needsRedraw:!1,width:1,height:1,aspect:1,time:0,startTime:Date.now(),engineTime:0,tick:0,tock:0,_mousePosition:null}}_getAnimationProps(){if(!this.animationProps)throw new Error("animationProps");return this.animationProps}_updateAnimationProps(){if(!this.animationProps)return;const{width:e,height:t,aspect:i}=this._getSizeAndAspect();e===this.animationProps.width&&t===this.animationProps.height||this.setNeedsRedraw("drawing buffer resized"),i!==this.animationProps.aspect&&this.setNeedsRedraw("drawing buffer aspect changed"),this.animationProps.width=e,this.animationProps.height=t,this.animationProps.aspect=i,this.animationProps.needsRedraw=this.needsRedraw,this.animationProps.engineTime=Date.now()-this.animationProps.startTime,this.timeline&&this.timeline.update(this.animationProps.engineTime),this.animationProps.tick=Math.floor(this.animationProps.time/1e3*60),this.animationProps.tock++,this.animationProps.time=this.timeline?this.timeline.getTime():this.animationProps.engineTime}async _initDevice(){if(this.device=await this.props.device,!this.device)throw new Error("No device provided");this.canvas=this.device.canvasContext?.canvas||null}_createInfoDiv(){if(this.canvas&&this.props.onAddHTML){const e=document.createElement("div");document.body.appendChild(e),e.style.position="relative";const t=document.createElement("div");t.style.position="absolute",t.style.left="10px",t.style.bottom="10px",t.style.width="300px",t.style.background="white",this.canvas instanceof HTMLCanvasElement&&e.appendChild(this.canvas),e.appendChild(t);const i=this.props.onAddHTML(t);i&&(t.innerHTML=i)}}_getSizeAndAspect(){if(!this.device)return{width:1,height:1,aspect:1};const[e,t]=this.device?.canvasContext?.getPixelSize()||[1,1];let i=1;const r=this.device?.canvasContext?.canvas;return r&&r.clientHeight?i=r.clientWidth/r.clientHeight:e>0&&t>0&&(i=e/t),{width:e,height:t,aspect:i}}_resizeViewport(){this.props.autoResizeViewport&&this.device.gl&&this.device.gl.viewport(0,0,this.device.gl.drawingBufferWidth,this.device.gl.drawingBufferHeight)}_resizeCanvasDrawingBuffer(){this.props.autoResizeDrawingBuffer&&this.device?.canvasContext?.resize({useDevicePixels:this.props.useDevicePixels})}_beginFrameTimers(){this.frameRate.timeEnd(),this.frameRate.timeStart(),this.cpuTime.timeStart()}_endFrameTimers(){this.cpuTime.timeEnd()}_startEventHandling(){this.canvas&&(this.canvas.addEventListener("mousemove",this._onMousemove.bind(this)),this.canvas.addEventListener("mouseleave",this._onMouseleave.bind(this)))}_onMousemove(e){e instanceof MouseEvent&&(this._getAnimationProps()._mousePosition=[e.offsetX,e.offsetY])}_onMouseleave(e){this._getAnimationProps()._mousePosition=null}}class nx{id;userData={};topology;bufferLayout=[];vertexCount;indices;attributes;constructor(e){this.id=e.id||Zp("geometry"),this.topology=e.topology,this.indices=e.indices||null,this.attributes=e.attributes,this.vertexCount=e.vertexCount,this.bufferLayout=e.bufferLayout||[],this.indices&&lf(this.indices.usage===Kp.INDEX)}destroy(){this.indices?.destroy();for(const e of Object.values(this.attributes))e.destroy()}getVertexCount(){return this.vertexCount}getAttributes(){return this.attributes}getIndexes(){return this.indices}_calculateVertexCount(e){return e.byteLength/12}}function ox(e,t){if(t instanceof nx)return t;const i=function(e,t){if(!t.indices)return;const i=t.indices.value;return e.createBuffer({usage:Kp.INDEX,data:i})}(e,t),{attributes:r,bufferLayout:n}=function(e,t){const i=[],r={};for(const[n,o]of Object.entries(t.attributes)){let t=n;switch(n){case"POSITION":t="positions";break;case"NORMAL":t="normals";break;case"TEXCOORD_0":t="texCoords";break;case"COLOR_0":t="colors"}r[t]=e.createBuffer({data:o.value,id:`${n}-buffer`});const{value:s,size:a,normalized:l}=o;i.push({name:t,format:Yf(s,a,l)})}const n=t._calculateVertexCount(t.attributes,t.indices);return{attributes:r,bufferLayout:i,vertexCount:n}}(e,t);return new nx({topology:t.topology||"triangle-list",bufferLayout:n,vertexCount:t.vertexCount,indices:i,attributes:r})}class sx{modules;moduleUniforms;moduleBindings;moduleUniformsChanged;constructor(e){const t=Ep(Object.values(e).filter(e=>e.dependencies));for(const i of t)e[i.name]=i;jp.log(1,"Creating ShaderInputs with modules",Object.keys(e))(),this.modules=e,this.moduleUniforms={},this.moduleBindings={};for(const[t,i]of Object.entries(e)){const e=t;this.moduleUniforms[e]=i.defaultUniforms||{},this.moduleBindings[e]={}}}destroy(){}setProps(e){for(const t of Object.keys(e)){const i=t,r=e[i],n=this.modules[i];if(!n){jp.warn(`Module ${t} not found`)();continue}const o=this.moduleUniforms[i],s=this.moduleBindings[i],a=n.getUniforms?.(r,o)||r,{uniforms:l,bindings:c}=em(a);this.moduleUniforms[i]={...o,...l},this.moduleBindings[i]={...s,...c}}}getModules(){return Object.values(this.modules)}getUniformValues(){return this.moduleUniforms}getBindings(){const e={};for(const t of Object.values(this.moduleBindings))Object.assign(e,t);return e}getDebugTable(){const e={};for(const[t,i]of Object.entries(this.moduleUniforms))for(const[r,n]of Object.entries(i))e[`${t}.${r}`]={type:this.modules[t].uniformTypes?.[r],value:String(n)};return e}}class ax{static defaultProps={...If.defaultProps};device;_hashCounter=0;_hashes={};_renderPipelineCache={};_computePipelineCache={};static getDefaultPipelineFactory(e){return e._lumaData.defaultPipelineFactory=e._lumaData.defaultPipelineFactory||new ax(e),e._lumaData.defaultPipelineFactory}constructor(e){this.device=e}createRenderPipeline(e){const t={...If.defaultProps,...e},i=this._hashRenderPipeline(t);if(!this._renderPipelineCache[i]){const e=this.device.createRenderPipeline({...t,id:t.id?`${t.id}-cached`:void 0});e.hash=i,this._renderPipelineCache[i]={pipeline:e,useCount:0}}return this._renderPipelineCache[i].useCount++,this._renderPipelineCache[i].pipeline}createComputePipeline(e){const t={...Pf.defaultProps,...e},i=this._hashComputePipeline(t);if(!this._computePipelineCache[i]){const e=this.device.createComputePipeline({...t,id:t.id?`${t.id}-cached`:void 0});e.hash=i,this._computePipelineCache[i]={pipeline:e,useCount:0}}return this._computePipelineCache[i].useCount++,this._computePipelineCache[i].pipeline}release(e){const t=e.hash,i=e instanceof Pf?this._computePipelineCache:this._renderPipelineCache;i[t].useCount--,0===i[t].useCount&&(i[t].pipeline.destroy(),delete i[t])}_hashComputePipeline(e){return`${this._getHash(e.shader.source)}`}_hashRenderPipeline(e){const t=this._getHash(e.vs.source),i=e.fs?this._getHash(e.fs.source):0,r=this._getHash(JSON.stringify(e.bufferLayout));if("webgl"===this.device.type)return`${t}/${i}V-BL${r}`;{const n=this._getHash(JSON.stringify(e.parameters));return`${t}/${i}V-T${e.topology}P${n}BL${r}`}}_getHash(e){return void 0===this._hashes[e]&&(this._hashes[e]=this._hashCounter++),this._hashes[e]}}class lx{static defaultProps={...Ef.defaultProps};device;_cache={};static getDefaultShaderFactory(e){return e._lumaData.defaultShaderFactory||=new lx(e),e._lumaData.defaultShaderFactory}constructor(e){this.device=e}createShader(e){const t=this._hashShader(e);let i=this._cache[t];if(!i){const r=this.device.createShader({...e,id:e.id?`${e.id}-cached`:void 0});this._cache[t]=i={shader:r,useCount:0}}return i.useCount++,i.shader}release(e){const t=this._hashShader(e),i=this._cache[t];i&&(i.useCount--,0===i.useCount&&(delete this._cache[t],i.shader.destroy()))}_hashShader(e){return`${e.stage}:${e.source}`}}let cx=null,ux=null;class hx{static defaultProps={...If.defaultProps,source:null,vs:null,fs:null,id:"unnamed",handle:void 0,userData:{},defines:{},modules:[],moduleSettings:void 0,geometry:null,indexBuffer:null,attributes:{},constantAttributes:{},varyings:[],isInstanced:void 0,instanceCount:0,vertexCount:0,shaderInputs:void 0,pipelineFactory:void 0,shaderFactory:void 0,transformFeedback:void 0,shaderAssembler:Np.getDefaultShaderAssembler(),debugShaders:void 0,disableWarnings:void 0};device;id;source;vs;fs;pipelineFactory;shaderFactory;userData={};parameters;topology;bufferLayout;isInstanced=void 0;instanceCount=0;vertexCount;indexBuffer=null;bufferAttributes={};constantAttributes={};bindings={};uniforms={};vertexArray;transformFeedback=null;pipeline;shaderInputs;_uniformStore;_attributeInfos={};_gpuGeometry=null;_getModuleUniforms;props;_pipelineNeedsUpdate="newly created";_needsRedraw="initializing";_destroyed=!1;_lastDrawTimestamp=-1;constructor(e,t){this.props={...hx.defaultProps,...t},t=this.props,this.id=t.id||Zp("model"),this.device=e,Object.assign(this.userData,t.userData);const i=Object.fromEntries(this.props.modules?.map(e=>[e.name,e])||[]);this.setShaderInputs(t.shaderInputs||new sx(i));const r=function(e){return{type:e.type,shaderLanguage:e.info.shadingLanguage,shaderLanguageVersion:e.info.shadingLanguageVersion,gpu:e.info.gpu,features:e.features}}(e),n=(this.props.modules?.length>0?this.props.modules:this.shaderInputs?.getModules())||[];if("webgpu"===this.device.type&&this.props.source){this.props.shaderLayout||=v_(this.props.source);const{source:e,getUniforms:t}=this.props.shaderAssembler.assembleShader({platformInfo:r,...this.props,modules:n});this.source=e,this._getModuleUniforms=t}else{const{vs:e,fs:t,getUniforms:i}=this.props.shaderAssembler.assembleShaderPair({platformInfo:r,...this.props,modules:n});this.vs=e,this.fs=t,this._getModuleUniforms=i}this.vertexCount=this.props.vertexCount,this.instanceCount=this.props.instanceCount,this.topology=this.props.topology,this.bufferLayout=this.props.bufferLayout,this.parameters=this.props.parameters,t.geometry&&this.setGeometry(t.geometry),this.pipelineFactory=t.pipelineFactory||ax.getDefaultPipelineFactory(this.device),this.shaderFactory=t.shaderFactory||lx.getDefaultShaderFactory(this.device),this.pipeline=this._updatePipeline(),this.vertexArray=e.createVertexArray({renderPipeline:this.pipeline}),this._gpuGeometry&&this._setGeometryAttributes(this._gpuGeometry),"isInstanced"in t&&(this.isInstanced=t.isInstanced),t.instanceCount&&this.setInstanceCount(t.instanceCount),t.vertexCount&&this.setVertexCount(t.vertexCount),t.indexBuffer&&this.setIndexBuffer(t.indexBuffer),t.attributes&&this.setAttributes(t.attributes),t.constantAttributes&&this.setConstantAttributes(t.constantAttributes),t.bindings&&this.setBindings(t.bindings),t.uniforms&&this.setUniforms(t.uniforms),t.moduleSettings&&this.updateModuleSettings(t.moduleSettings),t.transformFeedback&&(this.transformFeedback=t.transformFeedback),Object.seal(this)}destroy(){this._destroyed||(this.pipelineFactory.release(this.pipeline),this.shaderFactory.release(this.pipeline.vs),this.pipeline.fs&&this.shaderFactory.release(this.pipeline.fs),this._uniformStore.destroy(),this._gpuGeometry?.destroy(),this._destroyed=!0)}needsRedraw(){this._getBindingsUpdateTimestamp()>this._lastDrawTimestamp&&this.setNeedsRedraw("contents of bound textures or buffers updated");const e=this._needsRedraw;return this._needsRedraw=!1,e}setNeedsRedraw(e){this._needsRedraw||=e}predraw(){this.updateShaderInputs(),this.pipeline=this._updatePipeline()}draw(e){let t;this.predraw();try{this._logDrawCallStart(),this.pipeline=this._updatePipeline(),this.pipeline.setBindings(this.bindings,{disableWarnings:this.props.disableWarnings}),Wp(this.uniforms)||this.pipeline.setUniformsWebGL(this.uniforms);const{indexBuffer:i}=this.vertexArray,r=i?i.byteLength/("uint32"===i.indexType?4:2):void 0;t=this.pipeline.draw({renderPass:e,vertexArray:this.vertexArray,isInstanced:this.isInstanced,vertexCount:this.vertexCount,instanceCount:this.instanceCount,indexCount:r,transformFeedback:this.transformFeedback||void 0,parameters:this.parameters,topology:this.topology})}finally{this._logDrawCallEnd()}return this._logFramebuffer(e),t?(this._lastDrawTimestamp=this.device.timestamp,this._needsRedraw=!1):this._needsRedraw="waiting for resource initialization",t}setGeometry(e){this._gpuGeometry?.destroy();const t=e&&ox(this.device,e);t&&(this.setTopology(t.topology||"triangle-list"),this.bufferLayout=dx(t.bufferLayout,this.bufferLayout),this.vertexArray&&this._setGeometryAttributes(t)),this._gpuGeometry=t}setTopology(e){e!==this.topology&&(this.topology=e,this._setPipelineNeedsUpdate("topology"))}setBufferLayout(e){this.bufferLayout=this._gpuGeometry?dx(e,this._gpuGeometry.bufferLayout):e,this._setPipelineNeedsUpdate("bufferLayout"),this.pipeline=this._updatePipeline(),this.vertexArray=this.device.createVertexArray({renderPipeline:this.pipeline}),this._gpuGeometry&&this._setGeometryAttributes(this._gpuGeometry)}setParameters(e){rm(e,this.parameters,2)||(this.parameters=e,this._setPipelineNeedsUpdate("parameters"))}setInstanceCount(e){this.instanceCount=e,void 0===this.isInstanced&&e>0&&(this.isInstanced=!0),this.setNeedsRedraw("instanceCount")}setVertexCount(e){this.vertexCount=e,this.setNeedsRedraw("vertexCount")}setShaderInputs(e){this.shaderInputs=e,this._uniformStore=new Kf(this.shaderInputs.modules);for(const e of Object.keys(this.shaderInputs.modules)){const t=this._uniformStore.getManagedUniformBuffer(this.device,e);this.bindings[`${e}Uniforms`]=t}this.setNeedsRedraw("shaderInputs")}updateShaderInputs(){this._uniformStore.setUniforms(this.shaderInputs.getUniformValues()),this.setBindings(this.shaderInputs.getBindings()),this.setNeedsRedraw("shaderInputs")}setBindings(e){Object.assign(this.bindings,e),this.setNeedsRedraw("bindings")}setTransformFeedback(e){this.transformFeedback=e,this.setNeedsRedraw("transformFeedback")}setIndexBuffer(e){this.vertexArray.setIndexBuffer(e),this.setNeedsRedraw("indexBuffer")}setAttributes(e,t){e.indices&&jp.warn(`Model:${this.id} setAttributes() - indexBuffer should be set using setIndexBuffer()`)();for(const[i,r]of Object.entries(e)){const e=this.bufferLayout.find(e=>px(e).includes(i));if(!e){jp.warn(`Model(${this.id}): Missing layout for buffer "${i}".`)();continue}const n=px(e);let o=!1;for(const e of n){const t=this._attributeInfos[e];t&&(this.vertexArray.setBuffer(t.location,r),o=!0)}o||(t?.disableWarnings??this.props.disableWarnings)||jp.warn(`Model(${this.id}): Ignoring buffer "${r.id}" for unknown attribute "${i}"`)()}this.setNeedsRedraw("attributes")}setConstantAttributes(e,t){for(const[i,r]of Object.entries(e)){const e=this._attributeInfos[i];e?this.vertexArray.setConstantWebGL(e.location,r):(t?.disableWarnings??this.props.disableWarnings)||jp.warn(`Model "${this.id}: Ignoring constant supplied for unknown attribute "${i}"`)()}this.setNeedsRedraw("constants")}setUniforms(e){Wp(e)||(this.pipeline.setUniformsWebGL(e),Object.assign(this.uniforms,e)),this.setNeedsRedraw("uniforms")}updateModuleSettings(e){const{bindings:t,uniforms:i}=em(this._getModuleUniforms(e));Object.assign(this.bindings,t),Object.assign(this.uniforms,i),this.setNeedsRedraw("moduleSettings")}_getBindingsUpdateTimestamp(){let e=0;for(const t of Object.values(this.bindings))t instanceof yf?e=Math.max(e,t.texture.updateTimestamp):t instanceof Kp||t instanceof Af?e=Math.max(e,t.updateTimestamp):t instanceof Bf||(e=Math.max(e,t.buffer.updateTimestamp));return e}_setGeometryAttributes(e){const t={...e.attributes};for(const[e]of Object.entries(t))this.pipeline.shaderLayout.attributes.find(t=>t.name===e)||"positions"===e||delete t[e];this.vertexCount=e.vertexCount,this.setIndexBuffer(e.indices||null),this.setAttributes(e.attributes,{disableWarnings:!0}),this.setAttributes(t,{disableWarnings:this.props.disableWarnings}),this.setNeedsRedraw("geometry attributes")}_setPipelineNeedsUpdate(e){this._pipelineNeedsUpdate||=e,this.setNeedsRedraw(e)}_updatePipeline(){if(this._pipelineNeedsUpdate){let e=null,t=null;this.pipeline&&(jp.log(1,`Model ${this.id}: Recreating pipeline because "${this._pipelineNeedsUpdate}".`)(),e=this.pipeline.vs,t=this.pipeline.fs),this._pipelineNeedsUpdate=!1;const i=this.shaderFactory.createShader({id:`${this.id}-vertex`,stage:"vertex",source:this.source||this.vs,debug:this.props.debugShaders});let r=null;this.source?r=i:this.fs&&(r=this.shaderFactory.createShader({id:`${this.id}-fragment`,stage:"fragment",source:this.source||this.fs,debug:this.props.debugShaders})),this.pipeline=this.pipelineFactory.createRenderPipeline({...this.props,bufferLayout:this.bufferLayout,topology:this.topology,parameters:this.parameters,vs:i,fs:r}),this._attributeInfos=Of(this.pipeline.shaderLayout,this.bufferLayout),e&&this.shaderFactory.release(e),t&&this.shaderFactory.release(t)}return this.pipeline}_lastLogTime=0;_logOpen=!1;_logDrawCallStart(){const e=jp.level>3?0:1e4;jp.level<2||Date.now()-this._lastLogTime>> DRAWING MODEL ${this.id}`,{collapsed:jp.level<=2})())}_logDrawCallEnd(){if(this._logOpen){const e=function(e){const t={},i="Values";if(0===e.attributes.length&&!e.varyings?.length)return{"No attributes or varyings":{[i]:"N/A"}};for(const r of e.attributes)r&&(t[`in ${r.location} ${r.name}: ${r.type}`]={[i]:r.stepMode||"vertex"});for(const r of e.varyings||[])t[`out ${r.location} ${r.name}`]={[i]:JSON.stringify(r.accessor)};return t}(this.pipeline.shaderLayout,this.id);jp.table(2,e)();const t=this.shaderInputs.getDebugTable();for(const[e,i]of Object.entries(this.uniforms))t[e]={value:i};jp.table(2,t)();const i=this._getAttributeDebugTable();jp.table(2,this._attributeInfos)(),jp.table(2,i)(),jp.groupEnd(2)(),this._logOpen=!1}}_drawCount=0;_logFramebuffer(e){const t=jp.get("framebuffer");if(this._drawCount++,!t||this._drawCount++>3&&this._drawCount%60)return;const i=e.props.framebuffer;i&&function(e,{id:t,minimap:i,opaque:r,top:n="0",left:o="0",rgbaScale:s=1}){cx||(cx=document.createElement("canvas"),cx.id=t,cx.title=t,cx.style.zIndex="100",cx.style.position="absolute",cx.style.top=n,cx.style.left=o,cx.style.border="blue 1px solid",cx.style.transform="scaleY(-1)",document.body.appendChild(cx),ux=cx.getContext("2d")),cx.width===e.width&&cx.height===e.height||(cx.width=e.width/2,cx.height=e.height/2,cx.style.width="400px",cx.style.height="400px");const a=e.device.readPixelsToArrayWebGL(e),l=ux.createImageData(e.width,e.height);for(let e=0;et.name===e.name);t<0?i.push(e):i[t]=e}return i}function px(e){return e.attributes?e.attributes?.map(e=>e.attribute):[e.name]}class fx{device;model;transformFeedback;static isSupported(e){return"webgl"===e?.info?.type}constructor(e,t=hx.defaultProps){lf(fx.isSupported(e),"BufferTransform not yet implemented on WebGPU"),this.device=e,this.model=new hx(this.device,{id:t.id||"buffer-transform-model",fs:t.fs||Vp(),topology:t.topology||"point-list",...t}),this.transformFeedback=this.device.createTransformFeedback({layout:this.model.pipeline.shaderLayout,buffers:t.feedbackBuffers}),this.model.setTransformFeedback(this.transformFeedback),Object.seal(this)}destroy(){this.model&&this.model.destroy()}delete(){this.destroy()}run(e){const t=this.device.beginRenderPass(e);this.model.draw(t),t.end()}update(...e){console.warn("TextureTransform#update() not implemented")}getBuffer(e){return this.transformFeedback.getBuffer(e)}readAsync(e){const t=this.getBuffer(e);if(t instanceof Kp)return t.readAsync();const{buffer:i,byteOffset:r=0,byteLength:n=i.byteLength}=t;return i.readAsync(r,n)}}class mx{id;topology;vertexCount;indices;attributes;userData={};constructor(e){const{attributes:t={},indices:i=null,vertexCount:r=null}=e;this.id=e.id||Zp("geometry"),this.topology=e.topology,i&&(this.indices=ArrayBuffer.isView(i)?{value:i,size:1}:i),this.attributes={};for(const[e,i]of Object.entries(t)){const t=ArrayBuffer.isView(i)?{value:i}:i;lf(ArrayBuffer.isView(t.value),`${this._print(e)}: must be typed array or object with value as typed array`),"POSITION"!==e&&"positions"!==e||t.size||(t.size=3),"indices"===e?(lf(!this.indices),this.indices=t):this.attributes[e]=t}this.indices&&void 0!==this.indices.isIndexed&&(this.indices=Object.assign({},this.indices),delete this.indices.isIndexed),this.vertexCount=r||this._calculateVertexCount(this.attributes,this.indices)}getVertexCount(){return this.vertexCount}getAttributes(){return this.indices?{indices:this.indices,...this.attributes}:this.attributes}_print(e){return`Geometry ${this.id} attribute ${e}`}_setAttributes(e,t){return this}_calculateVertexCount(e,t){if(t)return t.value.length;let i=1/0;for(const t of Object.values(e)){const{value:e,size:r,constant:n}=t;!n&&e&&r>=1&&(i=Math.min(i,e.length/r))}return lf(Number.isFinite(i)),i}}class gx{id;matrix=new VA;display=!0;position=new mA;rotation=new mA;scale=new mA(1,1,1);userData={};props={};constructor(e={}){const{id:t}=e;this.id=t||Zp(this.constructor.name),this._setScenegraphNodeProps(e)}getBounds(){return null}destroy(){}delete(){this.destroy()}setProps(e){return this._setScenegraphNodeProps(e),this}toString(){return`{type: ScenegraphNode, id: ${this.id})}`}setPosition(e){return lf(3===e.length,"setPosition requires vector argument"),this.position=e,this}setRotation(e){return lf(3===e.length,"setRotation requires vector argument"),this.rotation=e,this}setScale(e){return lf(3===e.length,"setScale requires vector argument"),this.scale=e,this}setMatrix(e,t=!0){t?this.matrix.copy(e):this.matrix=e}setMatrixComponents(e){const{position:t,rotation:i,scale:r,update:n=!0}=e;return t&&this.setPosition(t),i&&this.setRotation(i),r&&this.setScale(r),n&&this.updateMatrix(),this}updateMatrix(){const e=this.position,t=this.rotation,i=this.scale;return this.matrix.identity(),this.matrix.translate(e),this.matrix.rotateXYZ(t),this.matrix.scale(i),this}update(e={}){const{position:t,rotation:i,scale:r}=e;return t&&this.setPosition(t),i&&this.setRotation(i),r&&this.setScale(r),this.updateMatrix(),this}getCoordinateUniforms(e,t){lf(e),t=t||this.matrix;const i=new VA(e).multiplyRight(t),r=i.invert(),n=r.transpose();return{viewMatrix:e,modelMatrix:t,objectMatrix:t,worldMatrix:i,worldInverseMatrix:r,worldInverseTransposeMatrix:n}}_setScenegraphNodeProps(e){"display"in e&&(this.display=e.display),"position"in e&&this.setPosition(e.position),"rotation"in e&&this.setRotation(e.rotation),"scale"in e&&this.setScale(e.scale),"matrix"in e&&this.setMatrix(e.matrix),Object.assign(this.props,e)}}class _x extends gx{children;constructor(e={}){e=Array.isArray(e)?{children:e}:e;const{children:t=[]}=e;jp.assert(t.every(e=>e instanceof gx),"every child must an instance of ScenegraphNode"),super(e),this.children=t}getBounds(){const e=[[1/0,1/0,1/0],[-1/0,-1/0,-1/0]];return this.traverse((t,{worldMatrix:i})=>{const r=t.getBounds();if(!r)return;const[n,o]=r,s=new mA(n).add(o).divide([2,2,2]);i.transformAsPoint(s,s);const a=new mA(o).subtract(n).divide([2,2,2]);i.transformAsVector(a,a);for(let t=0;t<8;t++){const i=new mA(1&t?-1:1,2&t?-1:1,4&t?-1:1).multiply(a).add(s);for(let t=0;t<3;t++)e[0][t]=Math.min(e[0][t],i[t]),e[1][t]=Math.max(e[1][t],i[t])}}),Number.isFinite(e[0][0])?e:null}destroy(){this.children.forEach(e=>e.destroy()),this.removeAll(),super.destroy()}add(...e){for(const t of e)Array.isArray(t)?this.add(...t):this.children.push(t);return this}remove(e){const t=this.children,i=t.indexOf(e);return i>-1&&t.splice(i,1),this}removeAll(){return this.children=[],this}traverse(e,{worldMatrix:t=new VA}={}){const i=new VA(t).multiplyRight(this.matrix);for(const t of this.children)t instanceof _x?t.traverse(e,{worldMatrix:i}):e(t,{worldMatrix:i})}}class Ax extends gx{model;bounds=null;managedResources;constructor(e){super(e),this.model=e.model,this.managedResources=e.managedResources||[],this.bounds=e.bounds||null,this.setProps(e)}getBounds(){return this.bounds}destroy(){this.model&&(this.model.destroy(),this.model=null),this.managedResources.forEach(e=>e.destroy()),this.managedResources=[]}draw(e){return this.model.draw(e)}}const yx={blendColorOperation:"add",blendColorSrcFactor:"one",blendColorDstFactor:"zero",blendAlphaOperation:"add",blendAlphaSrcFactor:"constant-alpha",blendAlphaDstFactor:"zero"};class vx extends Cv{constructor(){super(...arguments),this._colorEncoderState=null}render(e){return"pickingFBO"in e?this._drawPickingBuffer(e):super.render(e)}_drawPickingBuffer({layers:e,layerFilter:t,views:i,viewports:r,onViewportActive:n,pickingFBO:o,deviceRect:{x:s,y:a,width:l,height:c},cullRect:u,effects:h,pass:d="picking",pickZ:p,moduleParameters:f}){this.pickZ=p;const m=this._resetColorEncoder(p),g=[s,a,l,c],_=super.render({target:o,layers:e,layerFilter:t,views:i,viewports:r,onViewportActive:n,cullRect:u,effects:h?.filter(e=>e.useInPicking),pass:d,isPicking:!0,moduleParameters:f,clearColor:[0,0,0,0],colorMask:15,scissorRect:g});this._colorEncoderState=null;return{decodePickingColor:m&&xx.bind(null,m),stats:_}}shouldDrawLayer(e){const{pickable:t,operation:i}=e.props;return t&&i.includes("draw")||i.includes("terrain")||i.includes("mask")}getModuleParameters(){return{picking:{isActive:1,isAttribute:this.pickZ},lightSources:{}}}getLayerParameters(e,t,i){const r={depthMask:!0,depthTest:!0,depthRange:[0,1],...e.props.parameters},{pickable:n,operation:o}=e.props;return!this._colorEncoderState||o.includes("terrain")?r.blend=!1:n&&o.includes("draw")&&(Object.assign(r,yx),r.blend=!0,r.blendColor=function(e,t,i){const{byLayer:r,byAlpha:n}=e;let o,s=r.get(t);s?(s.viewports.push(i),o=s.a):(o=r.size+1,o<=255?(s={a:o,layer:t,viewports:[i]},r.set(t,s),n[o]=s):(rp.warn("Too many pickable layers, only picking the first 255")(),o=0));return[0,0,0,o/255]}(this._colorEncoderState,e,i)),r}_resetColorEncoder(e){return this._colorEncoderState=e?null:{byLayer:new Map,byAlpha:[]},this._colorEncoderState}}function xx(e,t){const i=e.byAlpha[t[3]];return i&&{pickedLayer:i.layer,pickedViewports:i.viewports,pickedObjectIndex:i.layer.decodePickingColor(t)}}const bx="Awaiting state",wx="Matched. State transferred from previous layer",Tx="Initialized",Ex="Discarded. Awaiting garbage collection",Cx="No longer matched. Awaiting garbage collection",Bx="Finalized! Awaiting garbage collection",Sx=Symbol.for("component"),Ix=Symbol.for("propTypes"),Mx=Symbol.for("deprecatedProps"),Px=Symbol.for("asyncPropDefaults"),Rx=Symbol.for("asyncPropOriginal"),Lx=Symbol.for("asyncPropResolved");function Fx(e,t=()=>!0){return Array.isArray(e)?kx(e,t,[]):t(e)?[e]:[]}function kx(e,t,i){let r=-1;for(;++r0}delete(){}getData(){return this.isLoaded?this._error?Promise.reject(this._error):this._content:this._loader.then(()=>this.getData())}setData(e,t){if(e===this._data&&!t)return;this._data=e;const i=++this._loadCount;let r=e;"string"==typeof e&&(r=Ld(e)),r instanceof Promise?(this.isLoaded=!1,this._loader=r.then(e=>{this._loadCount===i&&(this.isLoaded=!0,this._error=void 0,this._content=e)}).catch(e=>{this._loadCount===i&&(this.isLoaded=!0,this._error=e||!0)})):(this.isLoaded=!0,this._error=void 0,this._content=e);for(const e of this._subscribers)e.onChange(this.getData())}}class zx{constructor(e){this.protocol=e.protocol||"resource://",this._context={device:e.device,gl:e.device?.gl,resourceManager:this},this._resources={},this._consumers={},this._pruneRequest=null}contains(e){return!!e.startsWith(this.protocol)||e in this._resources}add({resourceId:e,data:t,forceUpdate:i=!1,persistent:r=!0}){let n=this._resources[e];n?n.setData(t,i):(n=new Ox(e,t,this._context),this._resources[e]=n),n.persistent=r}remove(e){const t=this._resources[e];t&&(t.delete(),delete this._resources[e])}unsubscribe({consumerId:e}){const t=this._consumers[e];if(t){for(const e in t){const i=t[e],r=this._resources[i.resourceId];r&&r.unsubscribe(i)}delete this._consumers[e],this.prune()}}subscribe({resourceId:e,onChange:t,consumerId:i,requestId:r="default"}){const{_resources:n,protocol:o}=this;e.startsWith(o)&&(n[e=e.replace(o,"")]||this.add({resourceId:e,data:null,persistent:!1}));const s=n[e];if(this._track(i,r,s,t),s)return s.getData()}prune(){this._pruneRequest||(this._pruneRequest=setTimeout(()=>this._prune(),0))}finalize(){for(const e in this._resources)this._resources[e].delete()}_track(e,t,i,r){const n=this._consumers,o=n[e]=n[e]||{};let s=o[t];const a=s&&s.resourceId&&this._resources[s.resourceId];a&&(a.unsubscribe(s),this.prune()),i&&(s?(s.onChange=r,s.resourceId=i.id):s={onChange:r,resourceId:i.id},o[t]=s,i.subscribe(s))}_prune(){this._pruneRequest=null;for(const e of Object.keys(this._resources)){const t=this._resources[e];t.persistent||t.inUse()||(t.delete(),delete this._resources[e])}}}class Ux{constructor(e,t){this._lastRenderedLayers=[],this._needsRedraw=!1,this._needsUpdate=!1,this._nextLayers=null,this._debug=!1,this._defaultShaderModulesChanged=!1,this.activateViewport=e=>{ap("layerManager.activateViewport",this,e),e&&(this.context.viewport=e)};const{deck:i,stats:r,viewport:n,timeline:o}=t||{};this.layers=[],this.resourceManager=new zx({device:e,protocol:"deck://"}),this.context={mousePosition:null,userData:{},layerManager:this,device:e,gl:e?.gl,deck:i,shaderAssembler:mv(),defaultShaderModules:[],renderPass:void 0,stats:r||new Eh({id:"deck.gl"}),viewport:n||new Qv({id:"DEFAULT-INITIAL-VIEWPORT"}),timeline:o||new ex,resourceManager:this.resourceManager,onError:void 0},Object.seal(this)}finalize(){this.resourceManager.finalize();for(const e of this.layers)this._finalizeLayer(e)}needsRedraw(e={clearRedrawFlags:!1}){let t=this._needsRedraw;e.clearRedrawFlags&&(this._needsRedraw=!1);for(const i of this.layers){const r=i.getNeedsRedraw(e);t=t||r}return t}needsUpdate(){return this._nextLayers&&this._nextLayers!==this._lastRenderedLayers?"layers changed":this._defaultShaderModulesChanged?"shader modules changed":this._needsUpdate}setNeedsRedraw(e){this._needsRedraw=this._needsRedraw||e}setNeedsUpdate(e){this._needsUpdate=this._needsUpdate||e}getLayers({layerIds:e}={}){return e?this.layers.filter(t=>e.find(e=>0===t.id.indexOf(e))):this.layers}setProps(e){"debug"in e&&(this._debug=e.debug),"userData"in e&&(this.context.userData=e.userData),"layers"in e&&(this._nextLayers=e.layers),"onError"in e&&(this.context.onError=e.onError)}setLayers(e,t){ap("layerManager.setLayers",this,t,e),this._lastRenderedLayers=e;const i=Fx(e,Boolean);for(const e of i)e.context=this.context;this._updateLayers(this.layers,i)}updateLayers(){const e=this.needsUpdate();e&&(this.setNeedsRedraw(`updating layers: ${e}`),this.setLayers(this._nextLayers||this._lastRenderedLayers,e)),this._nextLayers=null}addDefaultShaderModule(e){const{defaultShaderModules:t}=this.context;t.find(t=>t.name===e.name)||(t.push(e),this._defaultShaderModulesChanged=!0)}removeDefaultShaderModule(e){const{defaultShaderModules:t}=this.context,i=t.findIndex(t=>t.name===e.name);i>=0&&(t.splice(i,1),this._defaultShaderModulesChanged=!0)}_handleError(e,t,i){i.raiseError(t,`${e} of ${i}`)}_updateLayers(e,t){const i={};for(const t of e)i[t.id]?rp.warn(`Multiple old layers with same id ${t.id}`)():i[t.id]=t;if(this._defaultShaderModulesChanged){for(const t of e)t.setNeedsUpdate(),t.setChangeFlags({extensionsChanged:!0});this._defaultShaderModulesChanged=!1}const r=[];this._updateSublayersRecursively(t,i,r),this._finalizeOldLayers(i);let n=!1;for(const e of r)if(e.hasUniformTransition()){n=`Uniform transition in ${e}`;break}this._needsUpdate=n,this.layers=r}_updateSublayersRecursively(e,t,i){for(const r of e){r.context=this.context;const e=t[r.id];null===e&&rp.warn(`Multiple new layers with same id ${r.id}`)(),t[r.id]=null;let n=null;try{this._debug&&e!==r&&r.validateProps(),e?(this._transferLayerState(e,r),this._updateLayer(r)):this._initializeLayer(r),i.push(r),n=r.isComposite?r.getSubLayers():null}catch(e){this._handleError("matching",e,r)}n&&this._updateSublayersRecursively(n,t,i)}}_finalizeOldLayers(e){for(const t in e){const i=e[t];i&&this._finalizeLayer(i)}}_initializeLayer(e){try{e._initialize(),e.lifecycle=Tx}catch(t){this._handleError("initialization",t,e)}}_transferLayerState(e,t){t._transferState(e),t.lifecycle=wx,t!==e&&(e.lifecycle=Ex)}_updateLayer(e){try{e._update()}catch(t){this._handleError("update",t,e)}}_finalizeLayer(e){this._needsRedraw=this._needsRedraw||`finalized ${e}`,e.lifecycle=Cx;try{e._finalize(),e.lifecycle=Bx}catch(t){this._handleError("finalization",t,e)}}}function Nx(e,t,i){if(e===t)return!0;if(!i||!e||!t)return!1;if(Array.isArray(e)){if(!Array.isArray(t)||e.length!==t.length)return!1;for(let r=0;rt.containsPixel(e)):this._viewports}getViews(){const e={};return this.views.forEach(t=>{e[t.id]=t}),e}getView(e){return this.views.find(t=>t.id===e)}getViewState(e){const t="string"==typeof e?this.getView(e):e,i=t&&this.viewState[t.getViewStateId()]||this.viewState;return t?t.filterViewState(i):i}getViewport(e){return this._viewportMap[e]}unproject(e,t){const i=this.getViewports(),r={x:e[0],y:e[1]};for(let n=i.length-1;n>=0;--n){const o=i[n];if(o.containsPixel(r)){const i=e.slice();return i[0]-=o.x,i[1]-=o.y,o.unproject(i,t)}}return null}setProps(e){e.views&&this._setViews(e.views),e.viewState&&this._setViewState(e.viewState),("width"in e||"height"in e)&&this._setSize(e.width,e.height),this._isUpdating||this._update()}_update(){this._isUpdating=!0,this._needsUpdate&&(this._needsUpdate=!1,this._rebuildViewports()),this._needsUpdate&&(this._needsUpdate=!1,this._rebuildViewports()),this._isUpdating=!1}_setSize(e,t){e===this.width&&t===this.height||(this.width=e,this.height=t,this.setNeedsUpdate("Size changed"))}_setViews(e){e=Fx(e,Boolean);this._diffViews(e,this.views)&&this.setNeedsUpdate("views changed"),this.views=e}_setViewState(e){if(e){!Nx(e,this.viewState,3)&&this.setNeedsUpdate("viewState changed"),this.viewState=e}else rp.warn("missing `viewState` or `initialViewState`")()}_createController(e,t){return new(0,t.type)({timeline:this.timeline,eventManager:this._eventManager,onViewStateChange:this._eventCallbacks.onViewStateChange,onStateChange:this._eventCallbacks.onInteractionStateChange,makeViewport:t=>this.getView(e.id)?.makeViewport({viewState:t,width:this.width,height:this.height})})}_updateController(e,t,i,r){const n=e.controller;if(n&&i){const o={...t,...n,id:e.id,x:i.x,y:i.y,width:i.width,height:i.height};return r&&r.constructor===n.type||(r=this._createController(e,o)),r&&r.setProps(o),r}return null}_rebuildViewports(){const{views:e}=this,t=this.controllers;this._viewports=[],this.controllers={};let i=!1;for(let r=e.length;r--;){const n=e[r],o=this.getViewState(n),s=n.makeViewport({viewState:o,width:this.width,height:this.height});let a=t[n.id];const l=Boolean(n.controller);l&&!a&&(i=!0),!i&&l||!a||(a.finalize(),a=null),this.controllers[n.id]=this._updateController(n,o,s,a),s&&this._viewports.unshift(s)}for(const e in t){const i=t[e];i&&!this.controllers[e]&&i.finalize()}this._buildViewportMap()}_buildViewportMap(){this._viewportMap={},this._viewports.forEach(e=>{e.id&&(this._viewportMap[e.id]=this._viewportMap[e.id]||e)})}_diffViews(e,t){return e.length!==t.length||e.some((i,r)=>!e[r].equals(t[r]))}}const jx=/([0-9]+\.?[0-9]*)(%|px)/;function Gx(e){switch(typeof e){case"number":return{position:e,relative:!1};case"string":const t=jx.exec(e);if(t&&t.length>=3){const e="%"===t[2],i=parseFloat(t[1]);return{position:e?i/100:i,relative:e}}default:throw new Error(`Could not parse position string ${e}`)}}function Hx(e,t){return e.relative?Math.round(e.position*t):e.position}class Qx{constructor(e){const{id:t,x:i=0,y:r=0,width:n="100%",height:o="100%",padding:s=null}=e;this.id=t||this.constructor.displayName||"view",this.props={...e,id:this.id},this._x=Gx(i),this._y=Gx(r),this._width=Gx(n),this._height=Gx(o),this._padding=s&&{left:Gx(s.left||0),right:Gx(s.right||0),top:Gx(s.top||0),bottom:Gx(s.bottom||0)},this.equals=this.equals.bind(this),Object.seal(this)}equals(e){return this===e||this.ViewportType===e.ViewportType&&Nx(this.props,e.props,2)}makeViewport({width:e,height:t,viewState:i}){i=this.filterViewState(i);const r=this.getDimensions({width:e,height:t});return r.height&&r.width?new this.ViewportType({...i,...this.props,...r}):null}getViewStateId(){const{viewState:e}=this.props;return"string"==typeof e?e:e?.id||this.id}filterViewState(e){if(this.props.viewState&&"object"==typeof this.props.viewState){if(!this.props.viewState.id)return this.props.viewState;const t={...e};for(const e in this.props.viewState)"id"!==e&&(t[e]=this.props.viewState[e]);return t}return e}getDimensions({width:e,height:t}){const i={x:Hx(this._x,e),y:Hx(this._y,t),width:Hx(this._width,e),height:Hx(this._height,t)};return this._padding&&(i.padding={left:Hx(this._padding.left,e),top:Hx(this._padding.top,t),right:Hx(this._padding.right,e),bottom:Hx(this._padding.bottom,t)}),i}get controller(){const e=this.props.controller;return e?!0===e?{type:this.ControllerType}:"function"==typeof e?{type:e}:{type:this.ControllerType,...e}:null}}class $x{constructor(e){this._inProgress=!1,this._handle=null,this.time=0,this.settings={duration:0},this._timeline=e}get inProgress(){return this._inProgress}start(e){this.cancel(),this.settings=e,this._inProgress=!0,this.settings.onStart?.(this)}end(){this._inProgress&&(this._timeline.removeChannel(this._handle),this._handle=null,this._inProgress=!1,this.settings.onEnd?.(this))}cancel(){this._inProgress&&(this.settings.onInterrupt?.(this),this._timeline.removeChannel(this._handle),this._handle=null,this._inProgress=!1)}update(){if(!this._inProgress)return!1;if(null===this._handle){const{_timeline:e,settings:t}=this;this._handle=e.addChannel({delay:e.getTime(),duration:t.duration})}return this.time=this._timeline.getTime(this._handle),this._onUpdate(),this.settings.onUpdate?.(this),this._timeline.isFinished(this._handle)&&this.end(),!0}_onUpdate(){}}const Zx=()=>{},Wx=2,qx=3,Kx=e=>e,Xx=1;class Jx{constructor(e){this._onTransitionUpdate=e=>{const{time:t,settings:{interpolator:i,startProps:r,endProps:n,duration:o,easing:s}}=e,a=s(t/o),l=i.interpolateProps(r,n,a);this.propsInTransition=this.getControllerState({...this.props,...l}).getViewportProps(),this.onViewStateChange({viewState:this.propsInTransition,oldViewState:this.props})},this.getControllerState=e.getControllerState,this.propsInTransition=null,this.transition=new $x(e.timeline),this.onViewStateChange=e.onViewStateChange||Zx,this.onStateChange=e.onStateChange||Zx}finalize(){this.transition.cancel()}getViewportInTransition(){return this.propsInTransition}processViewStateChange(e){let t=!1;const i=this.props;if(this.props=e,!i||this._shouldIgnoreViewportChange(i,e))return!1;if(this._isTransitionEnabled(e)){let r=i;if(this.transition.inProgress){const{interruption:e,endProps:t}=this.transition.settings;r={...i,...e===Wx?t:this.propsInTransition||i}}this._triggerTransition(r,e),t=!0}else this.transition.cancel();return t}updateTransition(){this.transition.update()}_isTransitionEnabled(e){const{transitionDuration:t,transitionInterpolator:i}=e;return(t>0||"auto"===t)&&Boolean(i)}_isUpdateDueToCurrentTransition(e){return!(!this.transition.inProgress||!this.propsInTransition)&&this.transition.settings.interpolator.arePropsEqual(e,this.propsInTransition)}_shouldIgnoreViewportChange(e,t){if(this.transition.inProgress){return this.transition.settings.interruption===qx||this._isUpdateDueToCurrentTransition(t)}return!this._isTransitionEnabled(t)||t.transitionInterpolator.arePropsEqual(e,t)}_triggerTransition(e,t){const i=this.getControllerState(e),r=this.getControllerState(t).shortestPathFrom(i),n=t.transitionInterpolator,o=n.getDuration?n.getDuration(e,t):t.transitionDuration;if(0===o)return;const s=n.initializeProps(e,r);this.propsInTransition={};const a={duration:o,easing:t.transitionEasing||Kx,interpolator:n,interruption:t.transitionInterruption||Xx,startProps:s.start,endProps:s.end,onStart:t.onTransitionStart,onUpdate:this._onTransitionUpdate,onInterrupt:this._onTransitionEnd(t.onTransitionInterrupt),onEnd:this._onTransitionEnd(t.onTransitionEnd)};this.transition.start(a),this.onStateChange({inTransition:!0}),this.updateTransition()}_onTransitionEnd(e){return t=>{this.propsInTransition=null,this.onStateChange({inTransition:!1,isZooming:!1,isPanning:!1,isRotating:!1}),e?.(t)}}}function Yx(e,t){if(!e)throw new Error(t||"deck.gl: assertion failed.")}class eb{constructor(e){const{compare:t,extract:i,required:r}=e;this._propsToCompare=t,this._propsToExtract=i||t,this._requiredProps=r}arePropsEqual(e,t){for(const i of this._propsToCompare)if(!(i in e)||!(i in t)||!U_(e[i],t[i]))return!1;return!0}initializeProps(e,t){const i={},r={};for(const n of this._propsToExtract)(n in e||n in t)&&(i[n]=e[n],r[n]=t[n]);return this._checkRequiredProps(i),this._checkRequiredProps(r),{start:i,end:r}}getDuration(e,t){return t.transitionDuration}_checkRequiredProps(e){this._requiredProps&&this._requiredProps.forEach(t=>{const i=e[t];Yx(Number.isFinite(i)||Array.isArray(i),`${t} is required for transition`)})}}const tb=["longitude","latitude","zoom","bearing","pitch"],ib=["longitude","latitude","zoom"];class rb extends eb{constructor(e={}){const t=Array.isArray(e)?e:e.transitionProps,i=Array.isArray(e)?{}:e;i.transitionProps=Array.isArray(t)?{compare:t,required:t}:t||{compare:tb,required:ib},super(i.transitionProps),this.opts=i}initializeProps(e,t){const i=super.initializeProps(e,t),{makeViewport:r,around:n}=this.opts;if(r&&n){const o=r(e),s=r(t),a=o.unproject(n);i.start.around=n,Object.assign(i.end,{around:s.project(a),aroundPosition:a,width:t.width,height:t.height})}return i}interpolateProps(e,t,i){const r={};for(const n of this._propsToExtract)r[n]=z_(e[n]||0,t[n]||0,i);if(t.aroundPosition&&this.opts.makeViewport){const n=this.opts.makeViewport({...t,...r});Object.assign(r,n.panByPosition(t.aroundPosition,z_(e.around,t.around,i)))}return r}}const nb={transitionDuration:0},ob=e=>1-(1-e)*(1-e),sb=["wheel"],ab=["panstart","panmove","panend"],lb=["pinchstart","pinchmove","pinchend"],cb=["tripanstart","tripanmove","tripanend"],ub=["doubletap"],hb=["keydown"],db={};class pb{constructor(e){this.state={},this._events={},this._interactionState={isDragging:!1},this._customEvents=[],this._eventStartBlocked=null,this._panMove=!1,this.invertPan=!1,this.dragMode="rotate",this.inertia=0,this.scrollZoom=!0,this.dragPan=!0,this.dragRotate=!0,this.doubleClickZoom=!0,this.touchZoom=!0,this.touchRotate=!1,this.keyboard=!0,this.transitionManager=new Jx({...e,getControllerState:e=>new this.ControllerState(e),onViewStateChange:this._onTransition.bind(this),onStateChange:this._setInteractionState.bind(this)}),this.handleEvent=this.handleEvent.bind(this),this.eventManager=e.eventManager,this.onViewStateChange=e.onViewStateChange||(()=>{}),this.onStateChange=e.onStateChange||(()=>{}),this.makeViewport=e.makeViewport}set events(e){this.toggleEvents(this._customEvents,!1),this.toggleEvents(e,!0),this._customEvents=e,this.props&&this.setProps(this.props)}finalize(){for(const e in this._events)this._events[e]&&this.eventManager?.off(e,this.handleEvent);this.transitionManager.finalize()}handleEvent(e){this._controllerState=void 0;const t=this._eventStartBlocked;switch(e.type){case"panstart":return!t&&this._onPanStart(e);case"panmove":return this._onPan(e);case"panend":return this._onPanEnd(e);case"pinchstart":return!t&&this._onPinchStart(e);case"pinchmove":return this._onPinch(e);case"pinchend":return this._onPinchEnd(e);case"tripanstart":return!t&&this._onTriplePanStart(e);case"tripanmove":return this._onTriplePan(e);case"tripanend":return this._onTriplePanEnd(e);case"doubletap":return this._onDoubleTap(e);case"wheel":return this._onWheel(e);case"keydown":return this._onKeyDown(e);default:return!1}}get controllerState(){return this._controllerState=this._controllerState||new this.ControllerState({makeViewport:this.makeViewport,...this.props,...this.state}),this._controllerState}getCenter(e){const{x:t,y:i}=this.props,{offsetCenter:r}=e;return[r.x-t,r.y-i]}isPointInBounds(e,t){const{width:i,height:r}=this.props;if(t&&t.handled)return!1;const n=e[0]>=0&&e[0]<=i&&e[1]>=0&&e[1]<=r;return n&&t&&t.stopPropagation(),n}isFunctionKeyPressed(e){const{srcEvent:t}=e;return Boolean(t.metaKey||t.altKey||t.ctrlKey||t.shiftKey)}isDragging(){return this._interactionState.isDragging||!1}blockEvents(e){const t=setTimeout(()=>{this._eventStartBlocked===t&&(this._eventStartBlocked=null)},e);this._eventStartBlocked=t}setProps(e){e.dragMode&&(this.dragMode=e.dragMode),this.props=e,"transitionInterpolator"in e||(e.transitionInterpolator=this._getTransitionProps().transitionInterpolator),this.transitionManager.processViewStateChange(e);const{inertia:t}=e;this.inertia=Number.isFinite(t)?t:!0===t?300:0;const{scrollZoom:i=!0,dragPan:r=!0,dragRotate:n=!0,doubleClickZoom:o=!0,touchZoom:s=!0,touchRotate:a=!1,keyboard:l=!0}=e,c=Boolean(this.onViewStateChange);this.toggleEvents(sb,c&&i),this.toggleEvents(ab,c),this.toggleEvents(lb,c&&(s||a)),this.toggleEvents(cb,c&&a),this.toggleEvents(ub,c&&o),this.toggleEvents(hb,c&&l),this.scrollZoom=i,this.dragPan=r,this.dragRotate=n,this.doubleClickZoom=o,this.touchZoom=s,this.touchRotate=a,this.keyboard=l}updateTransition(){this.transitionManager.updateTransition()}toggleEvents(e,t){this.eventManager&&e.forEach(e=>{this._events[e]!==t&&(this._events[e]=t,t?this.eventManager.on(e,this.handleEvent):this.eventManager.off(e,this.handleEvent))})}updateViewport(e,t=null,i={}){const r={...e.getViewportProps(),...t},n=this.controllerState!==e;if(this.state=e.getState(),this._setInteractionState(i),n){const e=this.controllerState&&this.controllerState.getViewportProps();this.onViewStateChange&&this.onViewStateChange({viewState:r,interactionState:this._interactionState,oldViewState:e,viewId:this.props.id})}}_onTransition(e){this.onViewStateChange({...e,interactionState:this._interactionState,viewId:this.props.id})}_setInteractionState(e){Object.assign(this._interactionState,e),this.onStateChange(this._interactionState)}_onPanStart(e){const t=this.getCenter(e);if(!this.isPointInBounds(t,e))return!1;let i=this.isFunctionKeyPressed(e)||e.rightButton||!1;(this.invertPan||"pan"===this.dragMode)&&(i=!i);const r=this.controllerState[i?"panStart":"rotateStart"]({pos:t});return this._panMove=i,this.updateViewport(r,nb,{isDragging:!0}),!0}_onPan(e){return!!this.isDragging()&&(this._panMove?this._onPanMove(e):this._onPanRotate(e))}_onPanEnd(e){return!!this.isDragging()&&(this._panMove?this._onPanMoveEnd(e):this._onPanRotateEnd(e))}_onPanMove(e){if(!this.dragPan)return!1;const t=this.getCenter(e),i=this.controllerState.pan({pos:t});return this.updateViewport(i,nb,{isDragging:!0,isPanning:!0}),!0}_onPanMoveEnd(e){const{inertia:t}=this;if(this.dragPan&&t&&e.velocity){const i=this.getCenter(e),r=[i[0]+e.velocityX*t/2,i[1]+e.velocityY*t/2],n=this.controllerState.pan({pos:r}).panEnd();this.updateViewport(n,{...this._getTransitionProps(),transitionDuration:t,transitionEasing:ob},{isDragging:!1,isPanning:!0})}else{const e=this.controllerState.panEnd();this.updateViewport(e,null,{isDragging:!1,isPanning:!1})}return!0}_onPanRotate(e){if(!this.dragRotate)return!1;const t=this.getCenter(e),i=this.controllerState.rotate({pos:t});return this.updateViewport(i,nb,{isDragging:!0,isRotating:!0}),!0}_onPanRotateEnd(e){const{inertia:t}=this;if(this.dragRotate&&t&&e.velocity){const i=this.getCenter(e),r=[i[0]+e.velocityX*t/2,i[1]+e.velocityY*t/2],n=this.controllerState.rotate({pos:r}).rotateEnd();this.updateViewport(n,{...this._getTransitionProps(),transitionDuration:t,transitionEasing:ob},{isDragging:!1,isRotating:!0})}else{const e=this.controllerState.rotateEnd();this.updateViewport(e,null,{isDragging:!1,isRotating:!1})}return!0}_onWheel(e){if(!this.scrollZoom)return!1;const t=this.getCenter(e);if(!this.isPointInBounds(t,e))return!1;e.srcEvent.preventDefault();const{speed:i=.01,smooth:r=!1}=!0===this.scrollZoom?{}:this.scrollZoom,{delta:n}=e;let o=2/(1+Math.exp(-Math.abs(n*i)));n<0&&0!==o&&(o=1/o);const s=this.controllerState.zoom({pos:t,scale:o});return this.updateViewport(s,{...this._getTransitionProps({around:t}),transitionDuration:r?250:1},{isZooming:!0,isPanning:!0}),!0}_onTriplePanStart(e){const t=this.getCenter(e);if(!this.isPointInBounds(t,e))return!1;const i=this.controllerState.rotateStart({pos:t});return this.updateViewport(i,nb,{isDragging:!0}),!0}_onTriplePan(e){if(!this.touchRotate)return!1;if(!this.isDragging())return!1;const t=this.getCenter(e);t[0]-=e.deltaX;const i=this.controllerState.rotate({pos:t});return this.updateViewport(i,nb,{isDragging:!0,isRotating:!0}),!0}_onTriplePanEnd(e){if(!this.isDragging())return!1;const{inertia:t}=this;if(this.touchRotate&&t&&e.velocityY){const i=this.getCenter(e),r=[i[0],i[1]+=e.velocityY*t/2],n=this.controllerState.rotate({pos:r});this.updateViewport(n,{...this._getTransitionProps(),transitionDuration:t,transitionEasing:ob},{isDragging:!1,isRotating:!0}),this.blockEvents(t)}else{const e=this.controllerState.rotateEnd();this.updateViewport(e,null,{isDragging:!1,isRotating:!1})}return!0}_onPinchStart(e){const t=this.getCenter(e);if(!this.isPointInBounds(t,e))return!1;const i=this.controllerState.zoomStart({pos:t}).rotateStart({pos:t});return db._startPinchRotation=e.rotation,db._lastPinchEvent=e,this.updateViewport(i,nb,{isDragging:!0}),!0}_onPinch(e){if(!this.touchZoom&&!this.touchRotate)return!1;if(!this.isDragging())return!1;let t=this.controllerState;if(this.touchZoom){const{scale:i}=e,r=this.getCenter(e);t=t.zoom({pos:r,scale:i})}if(this.touchRotate){const{rotation:i}=e;t=t.rotate({deltaAngleX:db._startPinchRotation-i})}return this.updateViewport(t,nb,{isDragging:!0,isPanning:this.touchZoom,isZooming:this.touchZoom,isRotating:this.touchRotate}),db._lastPinchEvent=e,!0}_onPinchEnd(e){if(!this.isDragging())return!1;const{inertia:t}=this,{_lastPinchEvent:i}=db;if(this.touchZoom&&t&&i&&e.scale!==i.scale){const r=this.getCenter(e);let n=this.controllerState.rotateEnd();const o=Math.log2(e.scale),s=(o-Math.log2(i.scale))/(e.deltaTime-i.deltaTime),a=Math.pow(2,o+s*t/2);n=n.zoom({pos:r,scale:a}).zoomEnd(),this.updateViewport(n,{...this._getTransitionProps({around:r}),transitionDuration:t,transitionEasing:ob},{isDragging:!1,isPanning:this.touchZoom,isZooming:this.touchZoom,isRotating:!1}),this.blockEvents(t)}else{const e=this.controllerState.zoomEnd().rotateEnd();this.updateViewport(e,null,{isDragging:!1,isPanning:!1,isZooming:!1,isRotating:!1})}return db._startPinchRotation=null,db._lastPinchEvent=null,!0}_onDoubleTap(e){if(!this.doubleClickZoom)return!1;const t=this.getCenter(e);if(!this.isPointInBounds(t,e))return!1;const i=this.isFunctionKeyPressed(e),r=this.controllerState.zoom({pos:t,scale:i?.5:2});return this.updateViewport(r,this._getTransitionProps({around:t}),{isZooming:!0,isPanning:!0}),this.blockEvents(100),!0}_onKeyDown(e){if(!this.keyboard)return!1;const t=this.isFunctionKeyPressed(e),{zoomSpeed:i,moveSpeed:r,rotateSpeedX:n,rotateSpeedY:o}=!0===this.keyboard?{}:this.keyboard,{controllerState:s}=this;let a;const l={};switch(e.srcEvent.code){case"Minus":a=t?s.zoomOut(i).zoomOut(i):s.zoomOut(i),l.isZooming=!0;break;case"Equal":a=t?s.zoomIn(i).zoomIn(i):s.zoomIn(i),l.isZooming=!0;break;case"ArrowLeft":t?(a=s.rotateLeft(n),l.isRotating=!0):(a=s.moveLeft(r),l.isPanning=!0);break;case"ArrowRight":t?(a=s.rotateRight(n),l.isRotating=!0):(a=s.moveRight(r),l.isPanning=!0);break;case"ArrowUp":t?(a=s.rotateUp(o),l.isRotating=!0):(a=s.moveUp(r),l.isPanning=!0);break;case"ArrowDown":t?(a=s.rotateDown(o),l.isRotating=!0):(a=s.moveDown(r),l.isPanning=!0);break;default:return!1}return this.updateViewport(a,this._getTransitionProps(),l),!0}_getTransitionProps(e){const{transition:t}=this;return t&&t.transitionInterpolator?e?{...t,transitionInterpolator:new rb({...e,...t.transitionInterpolator.opts,makeViewport:this.controllerState.makeViewport})}:t:nb}}class fb{constructor(e,t){this._viewportProps=this.applyConstraints(e),this._state=t}getViewportProps(){return this._viewportProps}getState(){return this._state}}class mb extends fb{constructor(e){const{width:t,height:i,latitude:r,longitude:n,zoom:o,bearing:s=0,pitch:a=0,altitude:l=1.5,position:c=[0,0,0],maxZoom:u=20,minZoom:h=0,maxPitch:d=60,minPitch:p=0,startPanLngLat:f,startZoomLngLat:m,startRotatePos:g,startBearing:_,startPitch:A,startZoom:y,normalize:v=!0}=e;Yx(Number.isFinite(n)),Yx(Number.isFinite(r)),Yx(Number.isFinite(o)),super({width:t,height:i,latitude:r,longitude:n,zoom:o,bearing:s,pitch:a,altitude:l,maxZoom:u,minZoom:h,maxPitch:d,minPitch:p,normalize:v,position:c},{startPanLngLat:f,startZoomLngLat:m,startRotatePos:g,startBearing:_,startPitch:A,startZoom:y}),this.makeViewport=e.makeViewport}panStart({pos:e}){return this._getUpdatedState({startPanLngLat:this._unproject(e)})}pan({pos:e,startPos:t}){const i=this.getState().startPanLngLat||this._unproject(t);if(!i)return this;const r=this.makeViewport(this.getViewportProps()).panByPosition(i,e);return this._getUpdatedState(r)}panEnd(){return this._getUpdatedState({startPanLngLat:null})}rotateStart({pos:e}){return this._getUpdatedState({startRotatePos:e,startBearing:this.getViewportProps().bearing,startPitch:this.getViewportProps().pitch})}rotate({pos:e,deltaAngleX:t=0,deltaAngleY:i=0}){const{startRotatePos:r,startBearing:n,startPitch:o}=this.getState();if(!r||void 0===n||void 0===o)return this;let s;return s=e?this._getNewRotation(e,r,o,n):{bearing:n+t,pitch:o+i},this._getUpdatedState(s)}rotateEnd(){return this._getUpdatedState({startBearing:null,startPitch:null})}zoomStart({pos:e}){return this._getUpdatedState({startZoomLngLat:this._unproject(e),startZoom:this.getViewportProps().zoom})}zoom({pos:e,startPos:t,scale:i}){let{startZoom:r,startZoomLngLat:n}=this.getState();if(n||(r=this.getViewportProps().zoom,n=this._unproject(t)||this._unproject(e)),!n)return this;const{maxZoom:o,minZoom:s}=this.getViewportProps();let a=r+Math.log2(i);a=O_(a,s,o);const l=this.makeViewport({...this.getViewportProps(),zoom:a});return this._getUpdatedState({zoom:a,...l.panByPosition(n,e)})}zoomEnd(){return this._getUpdatedState({startZoomLngLat:null,startZoom:null})}zoomIn(e=2){return this._zoomFromCenter(e)}zoomOut(e=2){return this._zoomFromCenter(1/e)}moveLeft(e=100){return this._panFromCenter([e,0])}moveRight(e=100){return this._panFromCenter([-e,0])}moveUp(e=100){return this._panFromCenter([0,e])}moveDown(e=100){return this._panFromCenter([0,-e])}rotateLeft(e=15){return this._getUpdatedState({bearing:this.getViewportProps().bearing-e})}rotateRight(e=15){return this._getUpdatedState({bearing:this.getViewportProps().bearing+e})}rotateUp(e=10){return this._getUpdatedState({pitch:this.getViewportProps().pitch+e})}rotateDown(e=10){return this._getUpdatedState({pitch:this.getViewportProps().pitch-e})}shortestPathFrom(e){const t=e.getViewportProps(),i={...this.getViewportProps()},{bearing:r,longitude:n}=i;return Math.abs(r-t.bearing)>180&&(i.bearing=r<0?r+360:r-360),Math.abs(n-t.longitude)>180&&(i.longitude=n<0?n+360:n-360),i}applyConstraints(e){const{maxZoom:t,minZoom:i,zoom:r}=e;e.zoom=O_(r,i,t);const{maxPitch:n,minPitch:o,pitch:s}=e;e.pitch=O_(s,o,n);const{normalize:a=!0}=e;return a&&Object.assign(e,function(e){const{width:t,height:i,pitch:r=0}=e;let{longitude:n,latitude:o,zoom:s,bearing:a=0}=e;(n<-180||n>180)&&(n=Dy(n+180,360)-180),(a<-180||a>180)&&(a=Dy(a+180,360)-180);const l=zy(i/512);if(s<=l)s=l,o=0;else{const e=i/2/Math.pow(2,s),t=qy([0,e])[1];if(ot&&(o=t)}}return{width:t,height:i,longitude:n,latitude:o,zoom:s,pitch:r,bearing:a}}(e)),e}_zoomFromCenter(e){const{width:t,height:i}=this.getViewportProps();return this.zoom({pos:[t/2,i/2],scale:e})}_panFromCenter(e){const{width:t,height:i}=this.getViewportProps();return this.pan({startPos:[t/2,i/2],pos:[t/2+e[0],i/2+e[1]]})}_getUpdatedState(e){return new this.constructor({makeViewport:this.makeViewport,...this.getViewportProps(),...this.getState(),...e})}_unproject(e){const t=this.makeViewport(this.getViewportProps());return e&&t.unproject(e)}_getNewRotation(e,t,i,r){const n=e[0]-t[0],o=e[1]-t[1],s=e[1],a=t[1],{width:l,height:c}=this.getViewportProps(),u=n/l;let h=0;o>0?Math.abs(c-a)>5&&(h=o/(a-c)*1.2):o<0&&a>5&&(h=1-s/a),h=O_(h,-1,1);const{minPitch:d,maxPitch:p}=this.getViewportProps();let f=i;return h>0?f=i+h*(p-i):h<0&&(f=i-h*(d-i)),{pitch:f,bearing:r+180*u}}}class gb extends pb{constructor(){super(...arguments),this.ControllerState=mb,this.transition={transitionDuration:300,transitionInterpolator:new rb({transitionProps:{compare:["longitude","latitude","zoom","bearing","pitch","position"],required:["longitude","latitude","zoom"]}})},this.dragMode="pan"}setProps(e){e.position=e.position||[0,0,0];const t=this.props;super.setProps(e);(!t||t.height!==e.height)&&this.updateViewport(new this.ControllerState({makeViewport:this.makeViewport,...e,...this.state}))}}class _b extends Qx{constructor(e={}){super(e)}get ViewportType(){return Zv}get ControllerType(){return gb}}_b.displayName="MapView";var Ab=_b;const yb=new Rv;class vb{constructor(e){this._resolvedEffects=[],this._defaultEffects=[],this.effects=[],this._context=e,this._needsRedraw="Initial render",this._setEffects([])}addDefaultEffect(e){const t=this._defaultEffects;if(!t.find(t=>t.id===e.id)){const i=t.findIndex(t=>{return i=e,(t.order??1/0)-(i.order??1/0)>0;var i});i<0?t.push(e):t.splice(i,0,e),e.setup(this._context),this._setEffects(this.effects)}}setProps(e){"effects"in e&&(Nx(e.effects,this.effects,1)||this._setEffects(e.effects))}needsRedraw(e={clearRedrawFlags:!1}){const t=this._needsRedraw;return e.clearRedrawFlags&&(this._needsRedraw=!1),t}getEffects(){return this._resolvedEffects}_setEffects(e){const t={};for(const e of this.effects)t[e.id]=e;const i=[];for(const r of e){const e=t[r.id];let n=r;e&&e!==r?e.setProps?(e.setProps(r.props),n=e):e.cleanup(this._context):e||r.setup(this._context),i.push(n),delete t[r.id]}for(const e in t)t[e].cleanup(this._context);this.effects=i,this._resolvedEffects=i.concat(this._defaultEffects),e.some(e=>e instanceof Rv)||this._resolvedEffects.push(yb),this._needsRedraw="effects changed"}finalize(){for(const e of this._resolvedEffects)e.cleanup(this._context);this.effects.length=0,this._resolvedEffects.length=0,this._defaultEffects.length=0}}class xb extends Cv{shouldDrawLayer(e){const{operation:t}=e.props;return t.includes("draw")||t.includes("terrain")}}class bb{constructor(e){this.device=e,this.layerFilter=null,this.drawPickingColors=!1,this.drawLayersPass=new xb(e),this.pickLayersPass=new vx(e),this.renderCount=0,this._needsRedraw="Initial render",this.renderBuffers=[],this.lastPostProcessEffect=null}setProps(e){this.layerFilter!==e.layerFilter&&(this.layerFilter=e.layerFilter,this._needsRedraw="layerFilter changed"),this.drawPickingColors!==e.drawPickingColors&&(this.drawPickingColors=e.drawPickingColors,this._needsRedraw="drawPickingColors changed")}renderLayers(e){if(!e.viewports.length)return;const t=this.drawPickingColors?this.pickLayersPass:this.drawLayersPass,i={layerFilter:this.layerFilter,isPicking:this.drawPickingColors,...e};i.effects&&this._preRender(i.effects,i);const r=this.lastPostProcessEffect?this.renderBuffers[0]:i.target;this.lastPostProcessEffect&&(i.clearColor=[0,0,0,0],i.clearCanvas=!0);const n=t.render({...i,target:r});i.effects&&this._postRender(i.effects,i),this.renderCount++,ap("deckRenderer.renderLayers",this,n,e)}needsRedraw(e={clearRedrawFlags:!1}){const t=this._needsRedraw;return e.clearRedrawFlags&&(this._needsRedraw=!1),t}finalize(){const{renderBuffers:e}=this;for(const t of e)t.delete();e.length=0}_preRender(e,t){this.lastPostProcessEffect=null,t.preRenderStats=t.preRenderStats||{};for(const i of e)t.preRenderStats[i.id]=i.preRender(t),i.postRender&&(this.lastPostProcessEffect=i.id);this.lastPostProcessEffect&&this._resizeRenderBuffers()}_resizeRenderBuffers(){const{renderBuffers:e}=this,t=this.device.canvasContext.getDrawingBufferSize();0===e.length&&[0,1].map(t=>{const i=this.device.createTexture({sampler:{minFilter:"linear",magFilter:"linear"}});e.push(this.device.createFramebuffer({id:`deck-renderbuffer-${t}`,colorAttachments:[i]}))});for(const i of e)i.resize(t)}_postRender(e,t){const{renderBuffers:i}=this,r={...t,inputBuffer:i[0],swapBuffer:i[1]};for(const n of e)if(n.postRender){r.target=n.id===this.lastPostProcessEffect?t.target:void 0;const e=n.postRender(r);r.inputBuffer=e,r.swapBuffer=e===i[0]?i[1]:i[0]}}}const wb={pickedColor:null,pickedObjectIndex:-1};function Tb({pickedColors:e,decodePickingColor:t,deviceX:i,deviceY:r,deviceRadius:n,deviceRect:o}){const{x:s,y:a,width:l,height:c}=o;let u=n*n,h=-1,d=0;for(let t=0;tu)d+=4*l;else for(let t=0;t=0){const e=t+s-i,r=e*e+o;r<=u&&(u=r,h=d)}d+=4}}if(h>=0){const i=e.slice(h,h+4),r=t(i);if(r){const e=Math.floor(h/4/l),t=h/4-e*l;return{...r,pickedColor:i,pickedX:s+t,pickedY:a+e}}rp.error("Picked non-existent layer. Is picking buffer corrupt?")()}return wb}function Eb({pickInfo:e,viewports:t,pixelRatio:i,x:r,y:n,z:o}){let s,a=t[0];if(t.length>1&&(a=function(e,t){for(let i=e.length-1;i>=0;i--){const r=e[i];if(r.containsPixel(t))return r}return e[0]}(e?.pickedViewports||t,{x:r,y:n})),a){const e=[r-a.x,n-a.y];void 0!==o&&(e[2]=o),s=a.unproject(e)}return{color:null,layer:null,viewport:a,index:-1,picked:!1,x:r,y:n,pixel:[r,n],coordinate:s,devicePixel:e&&"pickedX"in e?[e.pickedX,e.pickedY]:void 0,pixelRatio:i}}function Cb(e){const{pickInfo:t,lastPickedInfo:i,mode:r,layers:n}=e,{pickedColor:o,pickedLayer:s,pickedObjectIndex:a}=t,l=s?[s]:[];if("hover"===r){const e=i.index,t=i.layerId,r=s?s.props.id:null;if(r!==t||a!==e){if(r!==t){const e=n.find(e=>e.props.id===t);e&&l.unshift(e)}i.layerId=r,i.index=a,i.info=null}}const c=Eb(e),u=new Map;return u.set(null,c),l.forEach(e=>{let t={...c};e===s&&(t.color=o,t.index=a,t.picked=!0),t=Bb({layer:e,info:t,mode:r});const n=t.layer;e===s&&"hover"===r&&(i.info=t),u.set(n.id,t),"hover"===r&&n.updateAutoHighlight(t)}),u}function Bb({layer:e,info:t,mode:i}){for(;e&&t;){const r=t.layer||null;t.sourceLayer=r,t.layer=e,t=e.getPickingInfo({info:t,mode:i,sourceLayer:r}),e=e.parent}return t}class Sb{constructor(e){this._pickable=!0,this.device=e,this.pickLayersPass=new vx(e),this.lastPickedInfo={index:-1,layerId:null,info:null}}setProps(e){"layerFilter"in e&&(this.layerFilter=e.layerFilter),"_pickable"in e&&(this._pickable=e._pickable)}finalize(){this.pickingFBO&&this.pickingFBO.destroy(),this.depthFBO&&this.depthFBO.destroy()}pickObject(e){return this._pickClosestObject(e)}pickObjects(e){return this._pickVisibleObjects(e)}getLastPickedObject({x:e,y:t,layers:i,viewports:r},n=this.lastPickedInfo.info){const o=n&&n.layer&&n.layer.id,s=n&&n.viewport&&n.viewport.id,a=o?i.find(e=>e.id===o):null,l=s&&r.find(e=>e.id===s)||r[0],c=l&&l.unproject([e-l.x,t-l.y]),u={x:e,y:t,viewport:l,coordinate:c,layer:a};return{...n,...u}}_resizeBuffer(){if(!this.pickingFBO&&(this.pickingFBO=this.device.createFramebuffer({colorAttachments:["rgba8unorm"],depthStencilAttachment:"depth16unorm"}),this.device.isTextureFormatRenderable("rgba32float"))){const e=this.device.createFramebuffer({colorAttachments:["rgba32float"],depthStencilAttachment:"depth16unorm"});this.depthFBO=e}const{canvas:e}=this.device.getCanvasContext();this.pickingFBO?.resize({width:e.width,height:e.height}),this.depthFBO?.resize({width:e.width,height:e.height})}_getPickable(e){if(!1===this._pickable)return null;const t=e.filter(e=>this.pickLayersPass.shouldDrawLayer(e)&&!e.isComposite);return t.length?t:null}_pickClosestObject({layers:e,views:t,viewports:i,x:r,y:n,radius:o=0,depth:s=1,mode:a="query",unproject3D:l,onViewportActive:c,effects:u}){const h=this.device.canvasContext.cssToDeviceRatio(),d=this._getPickable(e);if(!d||0===i.length)return{result:[],emptyInfo:Eb({viewports:i,x:r,y:n,pixelRatio:h})};this._resizeBuffer();const p=this.device.canvasContext.cssToDevicePixels([r,n],!0),f=[p.x+Math.floor(p.width/2),p.y+Math.floor(p.height/2)],m=Math.round(o*h),{width:g,height:_}=this.pickingFBO,A=this._getPickingRect({deviceX:f[0],deviceY:f[1],deviceRadius:m,deviceWidth:g,deviceHeight:_}),y={x:r-o,y:n-o,width:2*o+1,height:2*o+1};let v;const x=[],b=new Set;for(let e=0;e=0){const n=e.slice(r,r+4),o=n.join(",");if(!i.has(o)){const e=t(n);e?i.set(o,{...e,color:n}):rp.error("Picked non-existent layer. Is picking buffer corrupt?")()}}return Array.from(i.values())}(this._drawAndSample({layers:h,views:t,viewports:i,onViewportActive:c,deviceRect:y,cullRect:{x:r,y:n,width:o,height:s},effects:u,pass:`picking:${a}`})),x=new Map,b=[],w=Number.isFinite(l);for(let e=0;e=l);e++){const t=v[e];let i={color:t.pickedColor,layer:null,index:t.pickedObjectIndex,picked:!0,x:r,y:n,pixelRatio:d};i=Bb({layer:t.pickedLayer,info:i,mode:a});const o=i.layer.id;x.has(o)||x.set(o,new Set);const s=x.get(o),l=i.object??i.index;s.has(l)||(s.add(l),b.push(i))}return b}_drawAndSample({layers:e,views:t,viewports:i,onViewportActive:r,deviceRect:n,cullRect:o,effects:s,pass:a},l=!1){const c=l?this.depthFBO:this.pickingFBO,u={layers:e,layerFilter:this.layerFilter,views:t,viewports:i,onViewportActive:r,pickingFBO:c,deviceRect:n,cullRect:o,effects:s,pass:a,pickZ:l,preRenderStats:{},isPicking:!0};for(const e of s)e.useInPicking&&(u.preRenderStats[e.id]=e.preRender(u));const{decodePickingColor:h}=this.pickLayersPass.render(u),{x:d,y:p,width:f,height:m}=n,g=new(l?Float32Array:Uint8Array)(f*m*4);return this.device.readPixelsToArrayWebGL(c,{sourceX:d,sourceY:p,sourceWidth:f,sourceHeight:m,target:g}),{pickedColors:g,decodePickingColor:h}}_getPickingRect({deviceX:e,deviceY:t,deviceRadius:i,deviceWidth:r,deviceHeight:n}){const o=Math.max(0,e-i),s=Math.max(0,t-i),a=Math.min(r,e+i+1)-o,l=Math.min(n,t+i+1)-s;return a<=0||l<=0?null:{x:o,y:s,width:a,height:l}}}const Ib={"top-left":{top:0,left:0},"top-right":{top:0,right:0},"bottom-left":{bottom:0,left:0},"bottom-right":{bottom:0,right:0},fill:{top:0,left:0,bottom:0,right:0}},Mb="top-left",Pb="__root";class Rb{constructor({deck:e,parentElement:t}){this.defaultWidgets=[],this.widgets=[],this.resolvedWidgets=[],this.containers={},this.lastViewports={},this.deck=e,this.parentElement=t}getWidgets(){return this.resolvedWidgets}setProps(e){e.widgets&&!Nx(e.widgets,this.widgets,1)&&this._setWidgets(e.widgets)}finalize(){for(const e of this.getWidgets())this._remove(e);this.defaultWidgets.length=0,this.resolvedWidgets.length=0;for(const e in this.containers)this.containers[e].remove()}addDefault(e){this.defaultWidgets.find(t=>t.id===e.id)||(this._add(e),this.defaultWidgets.push(e),this._setWidgets(this.widgets))}_setWidgets(e){const t={};for(const e of this.resolvedWidgets)t[e.id]=e;this.resolvedWidgets.length=0;for(const e of this.defaultWidgets)t[e.id]=null,this.resolvedWidgets.push(e);for(let i of e){const e=t[i.id];e?e.viewId!==i.viewId||e.placement!==i.placement?(this._remove(e),this._add(i)):i!==e&&(e.setProps(i.props),i=e):this._add(i),t[i.id]=null,this.resolvedWidgets.push(i)}for(const e in t){const i=t[e];i&&this._remove(i)}this.widgets=e}_add(e){const{viewId:t=null,placement:i=Mb}=e,r=e.onAdd({deck:this.deck,viewId:t});r&&this._getContainer(t,i).append(r),e._element=r}_remove(e){e.onRemove(),e._element&&e._element.remove(),e._element=void 0}_getContainer(e,t){const i=e||Pb;let r=this.containers[i];r||(r=document.createElement("div"),r.style.pointerEvents="none",r.style.position="absolute",r.style.overflow="hidden",this.parentElement?.append(r),this.containers[i]=r);let n=r.querySelector(`.${t}`);return n||(n=document.createElement("div"),n.className=t,n.style.position="absolute",n.style.zIndex="2",Object.assign(n.style,Ib[t]),r.append(n)),n}_updateContainers(){const e=this.deck.width,t=this.deck.height;for(const i in this.containers){const r=this.lastViewports[i]||null,n=i===Pb||r,o=this.containers[i];n?(o.style.display="block",o.style.left=`${r?r.x:0}px`,o.style.top=`${r?r.y:0}px`,o.style.width=`${r?r.width:e}px`,o.style.height=`${r?r.height:t}px`):o.style.display="none"}}onRedraw({viewports:e,layers:t}){const i=e.reduce((e,t)=>(e[t.id]=t,e),{}),{lastViewports:r}=this;for(const n of this.getWidgets()){const{viewId:o}=n;if(o){const e=i[o];e&&(n.onViewportChange&&!e.equals(r[o])&&n.onViewportChange(e),n.onRedraw?.({viewports:[e],layers:t}))}else{if(n.onViewportChange)for(const t of e)t.equals(r[t.id])||n.onViewportChange(t);n.onRedraw?.({viewports:e,layers:t})}}this.lastViewports=i,this._updateContainers()}onHover(e,t){for(const i of this.getWidgets()){const{viewId:r}=i;r&&r!==e.viewport?.id||i.onHover?.(e,t)}}onEvent(e,t){const i=xy[t.type];if(i)for(const r of this.getWidgets()){const{viewId:n}=r;n&&n!==e.viewport?.id||r[i.handler]?.(e,t)}}}const Lb={zIndex:"1",position:"absolute",pointerEvents:"none",color:"#a0a7b4",backgroundColor:"#29323c",padding:"10px",top:"0",left:"0",display:"none"};class Fb{constructor(){this.id="default-tooltip",this.placement="fill",this.props={},this.isVisible=!1}onAdd({deck:e}){const t=document.createElement("div");return t.className="deck-tooltip",Object.assign(t.style,Lb),this.deck=e,this.element=t,t}onRemove(){this.deck=void 0,this.element=void 0}setProps(){}onViewportChange(e){this.isVisible&&e.id===this.lastViewport?.id&&e!==this.lastViewport&&this.setTooltip(null)}onHover(e){const{deck:t}=this,i=t&&t.props.getTooltip;if(!i)return;const r=i(e);this.lastViewport=e.viewport,this.setTooltip(r,e.x,e.y)}setTooltip(e,t,i){const r=this.element;if(r){if("string"==typeof e)r.innerText=e;else{if(!e)return this.isVisible=!1,void(r.style.display="none");e.text&&(r.innerText=e.text),e.html&&(r.innerHTML=e.html),e.className&&(r.className=e.className)}this.isVisible=!0,r.style.display="block",r.style.transform=`translate(${t}px, ${i}px)`,e&&"object"==typeof e&&"style"in e&&Object.assign(r.style,e.style)}}}var kb;!function(e){e[e.DEPTH_BUFFER_BIT=256]="DEPTH_BUFFER_BIT",e[e.STENCIL_BUFFER_BIT=1024]="STENCIL_BUFFER_BIT",e[e.COLOR_BUFFER_BIT=16384]="COLOR_BUFFER_BIT",e[e.POINTS=0]="POINTS",e[e.LINES=1]="LINES",e[e.LINE_LOOP=2]="LINE_LOOP",e[e.LINE_STRIP=3]="LINE_STRIP",e[e.TRIANGLES=4]="TRIANGLES",e[e.TRIANGLE_STRIP=5]="TRIANGLE_STRIP",e[e.TRIANGLE_FAN=6]="TRIANGLE_FAN",e[e.ZERO=0]="ZERO",e[e.ONE=1]="ONE",e[e.SRC_COLOR=768]="SRC_COLOR",e[e.ONE_MINUS_SRC_COLOR=769]="ONE_MINUS_SRC_COLOR",e[e.SRC_ALPHA=770]="SRC_ALPHA",e[e.ONE_MINUS_SRC_ALPHA=771]="ONE_MINUS_SRC_ALPHA",e[e.DST_ALPHA=772]="DST_ALPHA",e[e.ONE_MINUS_DST_ALPHA=773]="ONE_MINUS_DST_ALPHA",e[e.DST_COLOR=774]="DST_COLOR",e[e.ONE_MINUS_DST_COLOR=775]="ONE_MINUS_DST_COLOR",e[e.SRC_ALPHA_SATURATE=776]="SRC_ALPHA_SATURATE",e[e.CONSTANT_COLOR=32769]="CONSTANT_COLOR",e[e.ONE_MINUS_CONSTANT_COLOR=32770]="ONE_MINUS_CONSTANT_COLOR",e[e.CONSTANT_ALPHA=32771]="CONSTANT_ALPHA",e[e.ONE_MINUS_CONSTANT_ALPHA=32772]="ONE_MINUS_CONSTANT_ALPHA",e[e.FUNC_ADD=32774]="FUNC_ADD",e[e.FUNC_SUBTRACT=32778]="FUNC_SUBTRACT",e[e.FUNC_REVERSE_SUBTRACT=32779]="FUNC_REVERSE_SUBTRACT",e[e.BLEND_EQUATION=32777]="BLEND_EQUATION",e[e.BLEND_EQUATION_RGB=32777]="BLEND_EQUATION_RGB",e[e.BLEND_EQUATION_ALPHA=34877]="BLEND_EQUATION_ALPHA",e[e.BLEND_DST_RGB=32968]="BLEND_DST_RGB",e[e.BLEND_SRC_RGB=32969]="BLEND_SRC_RGB",e[e.BLEND_DST_ALPHA=32970]="BLEND_DST_ALPHA",e[e.BLEND_SRC_ALPHA=32971]="BLEND_SRC_ALPHA",e[e.BLEND_COLOR=32773]="BLEND_COLOR",e[e.ARRAY_BUFFER_BINDING=34964]="ARRAY_BUFFER_BINDING",e[e.ELEMENT_ARRAY_BUFFER_BINDING=34965]="ELEMENT_ARRAY_BUFFER_BINDING",e[e.LINE_WIDTH=2849]="LINE_WIDTH",e[e.ALIASED_POINT_SIZE_RANGE=33901]="ALIASED_POINT_SIZE_RANGE",e[e.ALIASED_LINE_WIDTH_RANGE=33902]="ALIASED_LINE_WIDTH_RANGE",e[e.CULL_FACE_MODE=2885]="CULL_FACE_MODE",e[e.FRONT_FACE=2886]="FRONT_FACE",e[e.DEPTH_RANGE=2928]="DEPTH_RANGE",e[e.DEPTH_WRITEMASK=2930]="DEPTH_WRITEMASK",e[e.DEPTH_CLEAR_VALUE=2931]="DEPTH_CLEAR_VALUE",e[e.DEPTH_FUNC=2932]="DEPTH_FUNC",e[e.STENCIL_CLEAR_VALUE=2961]="STENCIL_CLEAR_VALUE",e[e.STENCIL_FUNC=2962]="STENCIL_FUNC",e[e.STENCIL_FAIL=2964]="STENCIL_FAIL",e[e.STENCIL_PASS_DEPTH_FAIL=2965]="STENCIL_PASS_DEPTH_FAIL",e[e.STENCIL_PASS_DEPTH_PASS=2966]="STENCIL_PASS_DEPTH_PASS",e[e.STENCIL_REF=2967]="STENCIL_REF",e[e.STENCIL_VALUE_MASK=2963]="STENCIL_VALUE_MASK",e[e.STENCIL_WRITEMASK=2968]="STENCIL_WRITEMASK",e[e.STENCIL_BACK_FUNC=34816]="STENCIL_BACK_FUNC",e[e.STENCIL_BACK_FAIL=34817]="STENCIL_BACK_FAIL",e[e.STENCIL_BACK_PASS_DEPTH_FAIL=34818]="STENCIL_BACK_PASS_DEPTH_FAIL",e[e.STENCIL_BACK_PASS_DEPTH_PASS=34819]="STENCIL_BACK_PASS_DEPTH_PASS",e[e.STENCIL_BACK_REF=36003]="STENCIL_BACK_REF",e[e.STENCIL_BACK_VALUE_MASK=36004]="STENCIL_BACK_VALUE_MASK",e[e.STENCIL_BACK_WRITEMASK=36005]="STENCIL_BACK_WRITEMASK",e[e.VIEWPORT=2978]="VIEWPORT",e[e.SCISSOR_BOX=3088]="SCISSOR_BOX",e[e.COLOR_CLEAR_VALUE=3106]="COLOR_CLEAR_VALUE",e[e.COLOR_WRITEMASK=3107]="COLOR_WRITEMASK",e[e.UNPACK_ALIGNMENT=3317]="UNPACK_ALIGNMENT",e[e.PACK_ALIGNMENT=3333]="PACK_ALIGNMENT",e[e.MAX_TEXTURE_SIZE=3379]="MAX_TEXTURE_SIZE",e[e.MAX_VIEWPORT_DIMS=3386]="MAX_VIEWPORT_DIMS",e[e.SUBPIXEL_BITS=3408]="SUBPIXEL_BITS",e[e.RED_BITS=3410]="RED_BITS",e[e.GREEN_BITS=3411]="GREEN_BITS",e[e.BLUE_BITS=3412]="BLUE_BITS",e[e.ALPHA_BITS=3413]="ALPHA_BITS",e[e.DEPTH_BITS=3414]="DEPTH_BITS",e[e.STENCIL_BITS=3415]="STENCIL_BITS",e[e.POLYGON_OFFSET_UNITS=10752]="POLYGON_OFFSET_UNITS",e[e.POLYGON_OFFSET_FACTOR=32824]="POLYGON_OFFSET_FACTOR",e[e.TEXTURE_BINDING_2D=32873]="TEXTURE_BINDING_2D",e[e.SAMPLE_BUFFERS=32936]="SAMPLE_BUFFERS",e[e.SAMPLES=32937]="SAMPLES",e[e.SAMPLE_COVERAGE_VALUE=32938]="SAMPLE_COVERAGE_VALUE",e[e.SAMPLE_COVERAGE_INVERT=32939]="SAMPLE_COVERAGE_INVERT",e[e.COMPRESSED_TEXTURE_FORMATS=34467]="COMPRESSED_TEXTURE_FORMATS",e[e.VENDOR=7936]="VENDOR",e[e.RENDERER=7937]="RENDERER",e[e.VERSION=7938]="VERSION",e[e.IMPLEMENTATION_COLOR_READ_TYPE=35738]="IMPLEMENTATION_COLOR_READ_TYPE",e[e.IMPLEMENTATION_COLOR_READ_FORMAT=35739]="IMPLEMENTATION_COLOR_READ_FORMAT",e[e.BROWSER_DEFAULT_WEBGL=37444]="BROWSER_DEFAULT_WEBGL",e[e.STATIC_DRAW=35044]="STATIC_DRAW",e[e.STREAM_DRAW=35040]="STREAM_DRAW",e[e.DYNAMIC_DRAW=35048]="DYNAMIC_DRAW",e[e.ARRAY_BUFFER=34962]="ARRAY_BUFFER",e[e.ELEMENT_ARRAY_BUFFER=34963]="ELEMENT_ARRAY_BUFFER",e[e.BUFFER_SIZE=34660]="BUFFER_SIZE",e[e.BUFFER_USAGE=34661]="BUFFER_USAGE",e[e.CURRENT_VERTEX_ATTRIB=34342]="CURRENT_VERTEX_ATTRIB",e[e.VERTEX_ATTRIB_ARRAY_ENABLED=34338]="VERTEX_ATTRIB_ARRAY_ENABLED",e[e.VERTEX_ATTRIB_ARRAY_SIZE=34339]="VERTEX_ATTRIB_ARRAY_SIZE",e[e.VERTEX_ATTRIB_ARRAY_STRIDE=34340]="VERTEX_ATTRIB_ARRAY_STRIDE",e[e.VERTEX_ATTRIB_ARRAY_TYPE=34341]="VERTEX_ATTRIB_ARRAY_TYPE",e[e.VERTEX_ATTRIB_ARRAY_NORMALIZED=34922]="VERTEX_ATTRIB_ARRAY_NORMALIZED",e[e.VERTEX_ATTRIB_ARRAY_POINTER=34373]="VERTEX_ATTRIB_ARRAY_POINTER",e[e.VERTEX_ATTRIB_ARRAY_BUFFER_BINDING=34975]="VERTEX_ATTRIB_ARRAY_BUFFER_BINDING",e[e.CULL_FACE=2884]="CULL_FACE",e[e.FRONT=1028]="FRONT",e[e.BACK=1029]="BACK",e[e.FRONT_AND_BACK=1032]="FRONT_AND_BACK",e[e.BLEND=3042]="BLEND",e[e.DEPTH_TEST=2929]="DEPTH_TEST",e[e.DITHER=3024]="DITHER",e[e.POLYGON_OFFSET_FILL=32823]="POLYGON_OFFSET_FILL",e[e.SAMPLE_ALPHA_TO_COVERAGE=32926]="SAMPLE_ALPHA_TO_COVERAGE",e[e.SAMPLE_COVERAGE=32928]="SAMPLE_COVERAGE",e[e.SCISSOR_TEST=3089]="SCISSOR_TEST",e[e.STENCIL_TEST=2960]="STENCIL_TEST",e[e.NO_ERROR=0]="NO_ERROR",e[e.INVALID_ENUM=1280]="INVALID_ENUM",e[e.INVALID_VALUE=1281]="INVALID_VALUE",e[e.INVALID_OPERATION=1282]="INVALID_OPERATION",e[e.OUT_OF_MEMORY=1285]="OUT_OF_MEMORY",e[e.CONTEXT_LOST_WEBGL=37442]="CONTEXT_LOST_WEBGL",e[e.CW=2304]="CW",e[e.CCW=2305]="CCW",e[e.DONT_CARE=4352]="DONT_CARE",e[e.FASTEST=4353]="FASTEST",e[e.NICEST=4354]="NICEST",e[e.GENERATE_MIPMAP_HINT=33170]="GENERATE_MIPMAP_HINT",e[e.BYTE=5120]="BYTE",e[e.UNSIGNED_BYTE=5121]="UNSIGNED_BYTE",e[e.SHORT=5122]="SHORT",e[e.UNSIGNED_SHORT=5123]="UNSIGNED_SHORT",e[e.INT=5124]="INT",e[e.UNSIGNED_INT=5125]="UNSIGNED_INT",e[e.FLOAT=5126]="FLOAT",e[e.DOUBLE=5130]="DOUBLE",e[e.DEPTH_COMPONENT=6402]="DEPTH_COMPONENT",e[e.ALPHA=6406]="ALPHA",e[e.RGB=6407]="RGB",e[e.RGBA=6408]="RGBA",e[e.LUMINANCE=6409]="LUMINANCE",e[e.LUMINANCE_ALPHA=6410]="LUMINANCE_ALPHA",e[e.UNSIGNED_SHORT_4_4_4_4=32819]="UNSIGNED_SHORT_4_4_4_4",e[e.UNSIGNED_SHORT_5_5_5_1=32820]="UNSIGNED_SHORT_5_5_5_1",e[e.UNSIGNED_SHORT_5_6_5=33635]="UNSIGNED_SHORT_5_6_5",e[e.FRAGMENT_SHADER=35632]="FRAGMENT_SHADER",e[e.VERTEX_SHADER=35633]="VERTEX_SHADER",e[e.COMPILE_STATUS=35713]="COMPILE_STATUS",e[e.DELETE_STATUS=35712]="DELETE_STATUS",e[e.LINK_STATUS=35714]="LINK_STATUS",e[e.VALIDATE_STATUS=35715]="VALIDATE_STATUS",e[e.ATTACHED_SHADERS=35717]="ATTACHED_SHADERS",e[e.ACTIVE_ATTRIBUTES=35721]="ACTIVE_ATTRIBUTES",e[e.ACTIVE_UNIFORMS=35718]="ACTIVE_UNIFORMS",e[e.MAX_VERTEX_ATTRIBS=34921]="MAX_VERTEX_ATTRIBS",e[e.MAX_VERTEX_UNIFORM_VECTORS=36347]="MAX_VERTEX_UNIFORM_VECTORS",e[e.MAX_VARYING_VECTORS=36348]="MAX_VARYING_VECTORS",e[e.MAX_COMBINED_TEXTURE_IMAGE_UNITS=35661]="MAX_COMBINED_TEXTURE_IMAGE_UNITS",e[e.MAX_VERTEX_TEXTURE_IMAGE_UNITS=35660]="MAX_VERTEX_TEXTURE_IMAGE_UNITS",e[e.MAX_TEXTURE_IMAGE_UNITS=34930]="MAX_TEXTURE_IMAGE_UNITS",e[e.MAX_FRAGMENT_UNIFORM_VECTORS=36349]="MAX_FRAGMENT_UNIFORM_VECTORS",e[e.SHADER_TYPE=35663]="SHADER_TYPE",e[e.SHADING_LANGUAGE_VERSION=35724]="SHADING_LANGUAGE_VERSION",e[e.CURRENT_PROGRAM=35725]="CURRENT_PROGRAM",e[e.NEVER=512]="NEVER",e[e.LESS=513]="LESS",e[e.EQUAL=514]="EQUAL",e[e.LEQUAL=515]="LEQUAL",e[e.GREATER=516]="GREATER",e[e.NOTEQUAL=517]="NOTEQUAL",e[e.GEQUAL=518]="GEQUAL",e[e.ALWAYS=519]="ALWAYS",e[e.KEEP=7680]="KEEP",e[e.REPLACE=7681]="REPLACE",e[e.INCR=7682]="INCR",e[e.DECR=7683]="DECR",e[e.INVERT=5386]="INVERT",e[e.INCR_WRAP=34055]="INCR_WRAP",e[e.DECR_WRAP=34056]="DECR_WRAP",e[e.NEAREST=9728]="NEAREST",e[e.LINEAR=9729]="LINEAR",e[e.NEAREST_MIPMAP_NEAREST=9984]="NEAREST_MIPMAP_NEAREST",e[e.LINEAR_MIPMAP_NEAREST=9985]="LINEAR_MIPMAP_NEAREST",e[e.NEAREST_MIPMAP_LINEAR=9986]="NEAREST_MIPMAP_LINEAR",e[e.LINEAR_MIPMAP_LINEAR=9987]="LINEAR_MIPMAP_LINEAR",e[e.TEXTURE_MAG_FILTER=10240]="TEXTURE_MAG_FILTER",e[e.TEXTURE_MIN_FILTER=10241]="TEXTURE_MIN_FILTER",e[e.TEXTURE_WRAP_S=10242]="TEXTURE_WRAP_S",e[e.TEXTURE_WRAP_T=10243]="TEXTURE_WRAP_T",e[e.TEXTURE_2D=3553]="TEXTURE_2D",e[e.TEXTURE=5890]="TEXTURE",e[e.TEXTURE_CUBE_MAP=34067]="TEXTURE_CUBE_MAP",e[e.TEXTURE_BINDING_CUBE_MAP=34068]="TEXTURE_BINDING_CUBE_MAP",e[e.TEXTURE_CUBE_MAP_POSITIVE_X=34069]="TEXTURE_CUBE_MAP_POSITIVE_X",e[e.TEXTURE_CUBE_MAP_NEGATIVE_X=34070]="TEXTURE_CUBE_MAP_NEGATIVE_X",e[e.TEXTURE_CUBE_MAP_POSITIVE_Y=34071]="TEXTURE_CUBE_MAP_POSITIVE_Y",e[e.TEXTURE_CUBE_MAP_NEGATIVE_Y=34072]="TEXTURE_CUBE_MAP_NEGATIVE_Y",e[e.TEXTURE_CUBE_MAP_POSITIVE_Z=34073]="TEXTURE_CUBE_MAP_POSITIVE_Z",e[e.TEXTURE_CUBE_MAP_NEGATIVE_Z=34074]="TEXTURE_CUBE_MAP_NEGATIVE_Z",e[e.MAX_CUBE_MAP_TEXTURE_SIZE=34076]="MAX_CUBE_MAP_TEXTURE_SIZE",e[e.TEXTURE0=33984]="TEXTURE0",e[e.ACTIVE_TEXTURE=34016]="ACTIVE_TEXTURE",e[e.REPEAT=10497]="REPEAT",e[e.CLAMP_TO_EDGE=33071]="CLAMP_TO_EDGE",e[e.MIRRORED_REPEAT=33648]="MIRRORED_REPEAT",e[e.TEXTURE_WIDTH=4096]="TEXTURE_WIDTH",e[e.TEXTURE_HEIGHT=4097]="TEXTURE_HEIGHT",e[e.FLOAT_VEC2=35664]="FLOAT_VEC2",e[e.FLOAT_VEC3=35665]="FLOAT_VEC3",e[e.FLOAT_VEC4=35666]="FLOAT_VEC4",e[e.INT_VEC2=35667]="INT_VEC2",e[e.INT_VEC3=35668]="INT_VEC3",e[e.INT_VEC4=35669]="INT_VEC4",e[e.BOOL=35670]="BOOL",e[e.BOOL_VEC2=35671]="BOOL_VEC2",e[e.BOOL_VEC3=35672]="BOOL_VEC3",e[e.BOOL_VEC4=35673]="BOOL_VEC4",e[e.FLOAT_MAT2=35674]="FLOAT_MAT2",e[e.FLOAT_MAT3=35675]="FLOAT_MAT3",e[e.FLOAT_MAT4=35676]="FLOAT_MAT4",e[e.SAMPLER_2D=35678]="SAMPLER_2D",e[e.SAMPLER_CUBE=35680]="SAMPLER_CUBE",e[e.LOW_FLOAT=36336]="LOW_FLOAT",e[e.MEDIUM_FLOAT=36337]="MEDIUM_FLOAT",e[e.HIGH_FLOAT=36338]="HIGH_FLOAT",e[e.LOW_INT=36339]="LOW_INT",e[e.MEDIUM_INT=36340]="MEDIUM_INT",e[e.HIGH_INT=36341]="HIGH_INT",e[e.FRAMEBUFFER=36160]="FRAMEBUFFER",e[e.RENDERBUFFER=36161]="RENDERBUFFER",e[e.RGBA4=32854]="RGBA4",e[e.RGB5_A1=32855]="RGB5_A1",e[e.RGB565=36194]="RGB565",e[e.DEPTH_COMPONENT16=33189]="DEPTH_COMPONENT16",e[e.STENCIL_INDEX=6401]="STENCIL_INDEX",e[e.STENCIL_INDEX8=36168]="STENCIL_INDEX8",e[e.DEPTH_STENCIL=34041]="DEPTH_STENCIL",e[e.RENDERBUFFER_WIDTH=36162]="RENDERBUFFER_WIDTH",e[e.RENDERBUFFER_HEIGHT=36163]="RENDERBUFFER_HEIGHT",e[e.RENDERBUFFER_INTERNAL_FORMAT=36164]="RENDERBUFFER_INTERNAL_FORMAT",e[e.RENDERBUFFER_RED_SIZE=36176]="RENDERBUFFER_RED_SIZE",e[e.RENDERBUFFER_GREEN_SIZE=36177]="RENDERBUFFER_GREEN_SIZE",e[e.RENDERBUFFER_BLUE_SIZE=36178]="RENDERBUFFER_BLUE_SIZE",e[e.RENDERBUFFER_ALPHA_SIZE=36179]="RENDERBUFFER_ALPHA_SIZE",e[e.RENDERBUFFER_DEPTH_SIZE=36180]="RENDERBUFFER_DEPTH_SIZE",e[e.RENDERBUFFER_STENCIL_SIZE=36181]="RENDERBUFFER_STENCIL_SIZE",e[e.FRAMEBUFFER_ATTACHMENT_OBJECT_TYPE=36048]="FRAMEBUFFER_ATTACHMENT_OBJECT_TYPE",e[e.FRAMEBUFFER_ATTACHMENT_OBJECT_NAME=36049]="FRAMEBUFFER_ATTACHMENT_OBJECT_NAME",e[e.FRAMEBUFFER_ATTACHMENT_TEXTURE_LEVEL=36050]="FRAMEBUFFER_ATTACHMENT_TEXTURE_LEVEL",e[e.FRAMEBUFFER_ATTACHMENT_TEXTURE_CUBE_MAP_FACE=36051]="FRAMEBUFFER_ATTACHMENT_TEXTURE_CUBE_MAP_FACE",e[e.COLOR_ATTACHMENT0=36064]="COLOR_ATTACHMENT0",e[e.DEPTH_ATTACHMENT=36096]="DEPTH_ATTACHMENT",e[e.STENCIL_ATTACHMENT=36128]="STENCIL_ATTACHMENT",e[e.DEPTH_STENCIL_ATTACHMENT=33306]="DEPTH_STENCIL_ATTACHMENT",e[e.NONE=0]="NONE",e[e.FRAMEBUFFER_COMPLETE=36053]="FRAMEBUFFER_COMPLETE",e[e.FRAMEBUFFER_INCOMPLETE_ATTACHMENT=36054]="FRAMEBUFFER_INCOMPLETE_ATTACHMENT",e[e.FRAMEBUFFER_INCOMPLETE_MISSING_ATTACHMENT=36055]="FRAMEBUFFER_INCOMPLETE_MISSING_ATTACHMENT",e[e.FRAMEBUFFER_INCOMPLETE_DIMENSIONS=36057]="FRAMEBUFFER_INCOMPLETE_DIMENSIONS",e[e.FRAMEBUFFER_UNSUPPORTED=36061]="FRAMEBUFFER_UNSUPPORTED",e[e.FRAMEBUFFER_BINDING=36006]="FRAMEBUFFER_BINDING",e[e.RENDERBUFFER_BINDING=36007]="RENDERBUFFER_BINDING",e[e.READ_FRAMEBUFFER=36008]="READ_FRAMEBUFFER",e[e.DRAW_FRAMEBUFFER=36009]="DRAW_FRAMEBUFFER",e[e.MAX_RENDERBUFFER_SIZE=34024]="MAX_RENDERBUFFER_SIZE",e[e.INVALID_FRAMEBUFFER_OPERATION=1286]="INVALID_FRAMEBUFFER_OPERATION",e[e.UNPACK_FLIP_Y_WEBGL=37440]="UNPACK_FLIP_Y_WEBGL",e[e.UNPACK_PREMULTIPLY_ALPHA_WEBGL=37441]="UNPACK_PREMULTIPLY_ALPHA_WEBGL",e[e.UNPACK_COLORSPACE_CONVERSION_WEBGL=37443]="UNPACK_COLORSPACE_CONVERSION_WEBGL",e[e.READ_BUFFER=3074]="READ_BUFFER",e[e.UNPACK_ROW_LENGTH=3314]="UNPACK_ROW_LENGTH",e[e.UNPACK_SKIP_ROWS=3315]="UNPACK_SKIP_ROWS",e[e.UNPACK_SKIP_PIXELS=3316]="UNPACK_SKIP_PIXELS",e[e.PACK_ROW_LENGTH=3330]="PACK_ROW_LENGTH",e[e.PACK_SKIP_ROWS=3331]="PACK_SKIP_ROWS",e[e.PACK_SKIP_PIXELS=3332]="PACK_SKIP_PIXELS",e[e.TEXTURE_BINDING_3D=32874]="TEXTURE_BINDING_3D",e[e.UNPACK_SKIP_IMAGES=32877]="UNPACK_SKIP_IMAGES",e[e.UNPACK_IMAGE_HEIGHT=32878]="UNPACK_IMAGE_HEIGHT",e[e.MAX_3D_TEXTURE_SIZE=32883]="MAX_3D_TEXTURE_SIZE",e[e.MAX_ELEMENTS_VERTICES=33e3]="MAX_ELEMENTS_VERTICES",e[e.MAX_ELEMENTS_INDICES=33001]="MAX_ELEMENTS_INDICES",e[e.MAX_TEXTURE_LOD_BIAS=34045]="MAX_TEXTURE_LOD_BIAS",e[e.MAX_FRAGMENT_UNIFORM_COMPONENTS=35657]="MAX_FRAGMENT_UNIFORM_COMPONENTS",e[e.MAX_VERTEX_UNIFORM_COMPONENTS=35658]="MAX_VERTEX_UNIFORM_COMPONENTS",e[e.MAX_ARRAY_TEXTURE_LAYERS=35071]="MAX_ARRAY_TEXTURE_LAYERS",e[e.MIN_PROGRAM_TEXEL_OFFSET=35076]="MIN_PROGRAM_TEXEL_OFFSET",e[e.MAX_PROGRAM_TEXEL_OFFSET=35077]="MAX_PROGRAM_TEXEL_OFFSET",e[e.MAX_VARYING_COMPONENTS=35659]="MAX_VARYING_COMPONENTS",e[e.FRAGMENT_SHADER_DERIVATIVE_HINT=35723]="FRAGMENT_SHADER_DERIVATIVE_HINT",e[e.RASTERIZER_DISCARD=35977]="RASTERIZER_DISCARD",e[e.VERTEX_ARRAY_BINDING=34229]="VERTEX_ARRAY_BINDING",e[e.MAX_VERTEX_OUTPUT_COMPONENTS=37154]="MAX_VERTEX_OUTPUT_COMPONENTS",e[e.MAX_FRAGMENT_INPUT_COMPONENTS=37157]="MAX_FRAGMENT_INPUT_COMPONENTS",e[e.MAX_SERVER_WAIT_TIMEOUT=37137]="MAX_SERVER_WAIT_TIMEOUT",e[e.MAX_ELEMENT_INDEX=36203]="MAX_ELEMENT_INDEX",e[e.RED=6403]="RED",e[e.RGB8=32849]="RGB8",e[e.RGBA8=32856]="RGBA8",e[e.RGB10_A2=32857]="RGB10_A2",e[e.TEXTURE_3D=32879]="TEXTURE_3D",e[e.TEXTURE_WRAP_R=32882]="TEXTURE_WRAP_R",e[e.TEXTURE_MIN_LOD=33082]="TEXTURE_MIN_LOD",e[e.TEXTURE_MAX_LOD=33083]="TEXTURE_MAX_LOD",e[e.TEXTURE_BASE_LEVEL=33084]="TEXTURE_BASE_LEVEL",e[e.TEXTURE_MAX_LEVEL=33085]="TEXTURE_MAX_LEVEL",e[e.TEXTURE_COMPARE_MODE=34892]="TEXTURE_COMPARE_MODE",e[e.TEXTURE_COMPARE_FUNC=34893]="TEXTURE_COMPARE_FUNC",e[e.SRGB=35904]="SRGB",e[e.SRGB8=35905]="SRGB8",e[e.SRGB8_ALPHA8=35907]="SRGB8_ALPHA8",e[e.COMPARE_REF_TO_TEXTURE=34894]="COMPARE_REF_TO_TEXTURE",e[e.RGBA32F=34836]="RGBA32F",e[e.RGB32F=34837]="RGB32F",e[e.RGBA16F=34842]="RGBA16F",e[e.RGB16F=34843]="RGB16F",e[e.TEXTURE_2D_ARRAY=35866]="TEXTURE_2D_ARRAY",e[e.TEXTURE_BINDING_2D_ARRAY=35869]="TEXTURE_BINDING_2D_ARRAY",e[e.R11F_G11F_B10F=35898]="R11F_G11F_B10F",e[e.RGB9_E5=35901]="RGB9_E5",e[e.RGBA32UI=36208]="RGBA32UI",e[e.RGB32UI=36209]="RGB32UI",e[e.RGBA16UI=36214]="RGBA16UI",e[e.RGB16UI=36215]="RGB16UI",e[e.RGBA8UI=36220]="RGBA8UI",e[e.RGB8UI=36221]="RGB8UI",e[e.RGBA32I=36226]="RGBA32I",e[e.RGB32I=36227]="RGB32I",e[e.RGBA16I=36232]="RGBA16I",e[e.RGB16I=36233]="RGB16I",e[e.RGBA8I=36238]="RGBA8I",e[e.RGB8I=36239]="RGB8I",e[e.RED_INTEGER=36244]="RED_INTEGER",e[e.RGB_INTEGER=36248]="RGB_INTEGER",e[e.RGBA_INTEGER=36249]="RGBA_INTEGER",e[e.R8=33321]="R8",e[e.RG8=33323]="RG8",e[e.R16F=33325]="R16F",e[e.R32F=33326]="R32F",e[e.RG16F=33327]="RG16F",e[e.RG32F=33328]="RG32F",e[e.R8I=33329]="R8I",e[e.R8UI=33330]="R8UI",e[e.R16I=33331]="R16I",e[e.R16UI=33332]="R16UI",e[e.R32I=33333]="R32I",e[e.R32UI=33334]="R32UI",e[e.RG8I=33335]="RG8I",e[e.RG8UI=33336]="RG8UI",e[e.RG16I=33337]="RG16I",e[e.RG16UI=33338]="RG16UI",e[e.RG32I=33339]="RG32I",e[e.RG32UI=33340]="RG32UI",e[e.R8_SNORM=36756]="R8_SNORM",e[e.RG8_SNORM=36757]="RG8_SNORM",e[e.RGB8_SNORM=36758]="RGB8_SNORM",e[e.RGBA8_SNORM=36759]="RGBA8_SNORM",e[e.RGB10_A2UI=36975]="RGB10_A2UI",e[e.TEXTURE_IMMUTABLE_FORMAT=37167]="TEXTURE_IMMUTABLE_FORMAT",e[e.TEXTURE_IMMUTABLE_LEVELS=33503]="TEXTURE_IMMUTABLE_LEVELS",e[e.UNSIGNED_INT_2_10_10_10_REV=33640]="UNSIGNED_INT_2_10_10_10_REV",e[e.UNSIGNED_INT_10F_11F_11F_REV=35899]="UNSIGNED_INT_10F_11F_11F_REV",e[e.UNSIGNED_INT_5_9_9_9_REV=35902]="UNSIGNED_INT_5_9_9_9_REV",e[e.FLOAT_32_UNSIGNED_INT_24_8_REV=36269]="FLOAT_32_UNSIGNED_INT_24_8_REV",e[e.UNSIGNED_INT_24_8=34042]="UNSIGNED_INT_24_8",e[e.HALF_FLOAT=5131]="HALF_FLOAT",e[e.RG=33319]="RG",e[e.RG_INTEGER=33320]="RG_INTEGER",e[e.INT_2_10_10_10_REV=36255]="INT_2_10_10_10_REV",e[e.CURRENT_QUERY=34917]="CURRENT_QUERY",e[e.QUERY_RESULT=34918]="QUERY_RESULT",e[e.QUERY_RESULT_AVAILABLE=34919]="QUERY_RESULT_AVAILABLE",e[e.ANY_SAMPLES_PASSED=35887]="ANY_SAMPLES_PASSED",e[e.ANY_SAMPLES_PASSED_CONSERVATIVE=36202]="ANY_SAMPLES_PASSED_CONSERVATIVE",e[e.MAX_DRAW_BUFFERS=34852]="MAX_DRAW_BUFFERS",e[e.DRAW_BUFFER0=34853]="DRAW_BUFFER0",e[e.DRAW_BUFFER1=34854]="DRAW_BUFFER1",e[e.DRAW_BUFFER2=34855]="DRAW_BUFFER2",e[e.DRAW_BUFFER3=34856]="DRAW_BUFFER3",e[e.DRAW_BUFFER4=34857]="DRAW_BUFFER4",e[e.DRAW_BUFFER5=34858]="DRAW_BUFFER5",e[e.DRAW_BUFFER6=34859]="DRAW_BUFFER6",e[e.DRAW_BUFFER7=34860]="DRAW_BUFFER7",e[e.DRAW_BUFFER8=34861]="DRAW_BUFFER8",e[e.DRAW_BUFFER9=34862]="DRAW_BUFFER9",e[e.DRAW_BUFFER10=34863]="DRAW_BUFFER10",e[e.DRAW_BUFFER11=34864]="DRAW_BUFFER11",e[e.DRAW_BUFFER12=34865]="DRAW_BUFFER12",e[e.DRAW_BUFFER13=34866]="DRAW_BUFFER13",e[e.DRAW_BUFFER14=34867]="DRAW_BUFFER14",e[e.DRAW_BUFFER15=34868]="DRAW_BUFFER15",e[e.MAX_COLOR_ATTACHMENTS=36063]="MAX_COLOR_ATTACHMENTS",e[e.COLOR_ATTACHMENT1=36065]="COLOR_ATTACHMENT1",e[e.COLOR_ATTACHMENT2=36066]="COLOR_ATTACHMENT2",e[e.COLOR_ATTACHMENT3=36067]="COLOR_ATTACHMENT3",e[e.COLOR_ATTACHMENT4=36068]="COLOR_ATTACHMENT4",e[e.COLOR_ATTACHMENT5=36069]="COLOR_ATTACHMENT5",e[e.COLOR_ATTACHMENT6=36070]="COLOR_ATTACHMENT6",e[e.COLOR_ATTACHMENT7=36071]="COLOR_ATTACHMENT7",e[e.COLOR_ATTACHMENT8=36072]="COLOR_ATTACHMENT8",e[e.COLOR_ATTACHMENT9=36073]="COLOR_ATTACHMENT9",e[e.COLOR_ATTACHMENT10=36074]="COLOR_ATTACHMENT10",e[e.COLOR_ATTACHMENT11=36075]="COLOR_ATTACHMENT11",e[e.COLOR_ATTACHMENT12=36076]="COLOR_ATTACHMENT12",e[e.COLOR_ATTACHMENT13=36077]="COLOR_ATTACHMENT13",e[e.COLOR_ATTACHMENT14=36078]="COLOR_ATTACHMENT14",e[e.COLOR_ATTACHMENT15=36079]="COLOR_ATTACHMENT15",e[e.SAMPLER_3D=35679]="SAMPLER_3D",e[e.SAMPLER_2D_SHADOW=35682]="SAMPLER_2D_SHADOW",e[e.SAMPLER_2D_ARRAY=36289]="SAMPLER_2D_ARRAY",e[e.SAMPLER_2D_ARRAY_SHADOW=36292]="SAMPLER_2D_ARRAY_SHADOW",e[e.SAMPLER_CUBE_SHADOW=36293]="SAMPLER_CUBE_SHADOW",e[e.INT_SAMPLER_2D=36298]="INT_SAMPLER_2D",e[e.INT_SAMPLER_3D=36299]="INT_SAMPLER_3D",e[e.INT_SAMPLER_CUBE=36300]="INT_SAMPLER_CUBE",e[e.INT_SAMPLER_2D_ARRAY=36303]="INT_SAMPLER_2D_ARRAY",e[e.UNSIGNED_INT_SAMPLER_2D=36306]="UNSIGNED_INT_SAMPLER_2D",e[e.UNSIGNED_INT_SAMPLER_3D=36307]="UNSIGNED_INT_SAMPLER_3D",e[e.UNSIGNED_INT_SAMPLER_CUBE=36308]="UNSIGNED_INT_SAMPLER_CUBE",e[e.UNSIGNED_INT_SAMPLER_2D_ARRAY=36311]="UNSIGNED_INT_SAMPLER_2D_ARRAY",e[e.MAX_SAMPLES=36183]="MAX_SAMPLES",e[e.SAMPLER_BINDING=35097]="SAMPLER_BINDING",e[e.PIXEL_PACK_BUFFER=35051]="PIXEL_PACK_BUFFER",e[e.PIXEL_UNPACK_BUFFER=35052]="PIXEL_UNPACK_BUFFER",e[e.PIXEL_PACK_BUFFER_BINDING=35053]="PIXEL_PACK_BUFFER_BINDING",e[e.PIXEL_UNPACK_BUFFER_BINDING=35055]="PIXEL_UNPACK_BUFFER_BINDING",e[e.COPY_READ_BUFFER=36662]="COPY_READ_BUFFER",e[e.COPY_WRITE_BUFFER=36663]="COPY_WRITE_BUFFER",e[e.COPY_READ_BUFFER_BINDING=36662]="COPY_READ_BUFFER_BINDING",e[e.COPY_WRITE_BUFFER_BINDING=36663]="COPY_WRITE_BUFFER_BINDING",e[e.FLOAT_MAT2x3=35685]="FLOAT_MAT2x3",e[e.FLOAT_MAT2x4=35686]="FLOAT_MAT2x4",e[e.FLOAT_MAT3x2=35687]="FLOAT_MAT3x2",e[e.FLOAT_MAT3x4=35688]="FLOAT_MAT3x4",e[e.FLOAT_MAT4x2=35689]="FLOAT_MAT4x2",e[e.FLOAT_MAT4x3=35690]="FLOAT_MAT4x3",e[e.UNSIGNED_INT_VEC2=36294]="UNSIGNED_INT_VEC2",e[e.UNSIGNED_INT_VEC3=36295]="UNSIGNED_INT_VEC3",e[e.UNSIGNED_INT_VEC4=36296]="UNSIGNED_INT_VEC4",e[e.UNSIGNED_NORMALIZED=35863]="UNSIGNED_NORMALIZED",e[e.SIGNED_NORMALIZED=36764]="SIGNED_NORMALIZED",e[e.VERTEX_ATTRIB_ARRAY_INTEGER=35069]="VERTEX_ATTRIB_ARRAY_INTEGER",e[e.VERTEX_ATTRIB_ARRAY_DIVISOR=35070]="VERTEX_ATTRIB_ARRAY_DIVISOR",e[e.TRANSFORM_FEEDBACK_BUFFER_MODE=35967]="TRANSFORM_FEEDBACK_BUFFER_MODE",e[e.MAX_TRANSFORM_FEEDBACK_SEPARATE_COMPONENTS=35968]="MAX_TRANSFORM_FEEDBACK_SEPARATE_COMPONENTS",e[e.TRANSFORM_FEEDBACK_VARYINGS=35971]="TRANSFORM_FEEDBACK_VARYINGS",e[e.TRANSFORM_FEEDBACK_BUFFER_START=35972]="TRANSFORM_FEEDBACK_BUFFER_START",e[e.TRANSFORM_FEEDBACK_BUFFER_SIZE=35973]="TRANSFORM_FEEDBACK_BUFFER_SIZE",e[e.TRANSFORM_FEEDBACK_PRIMITIVES_WRITTEN=35976]="TRANSFORM_FEEDBACK_PRIMITIVES_WRITTEN",e[e.MAX_TRANSFORM_FEEDBACK_INTERLEAVED_COMPONENTS=35978]="MAX_TRANSFORM_FEEDBACK_INTERLEAVED_COMPONENTS",e[e.MAX_TRANSFORM_FEEDBACK_SEPARATE_ATTRIBS=35979]="MAX_TRANSFORM_FEEDBACK_SEPARATE_ATTRIBS",e[e.INTERLEAVED_ATTRIBS=35980]="INTERLEAVED_ATTRIBS",e[e.SEPARATE_ATTRIBS=35981]="SEPARATE_ATTRIBS",e[e.TRANSFORM_FEEDBACK_BUFFER=35982]="TRANSFORM_FEEDBACK_BUFFER",e[e.TRANSFORM_FEEDBACK_BUFFER_BINDING=35983]="TRANSFORM_FEEDBACK_BUFFER_BINDING",e[e.TRANSFORM_FEEDBACK=36386]="TRANSFORM_FEEDBACK",e[e.TRANSFORM_FEEDBACK_PAUSED=36387]="TRANSFORM_FEEDBACK_PAUSED",e[e.TRANSFORM_FEEDBACK_ACTIVE=36388]="TRANSFORM_FEEDBACK_ACTIVE",e[e.TRANSFORM_FEEDBACK_BINDING=36389]="TRANSFORM_FEEDBACK_BINDING",e[e.FRAMEBUFFER_ATTACHMENT_COLOR_ENCODING=33296]="FRAMEBUFFER_ATTACHMENT_COLOR_ENCODING",e[e.FRAMEBUFFER_ATTACHMENT_COMPONENT_TYPE=33297]="FRAMEBUFFER_ATTACHMENT_COMPONENT_TYPE",e[e.FRAMEBUFFER_ATTACHMENT_RED_SIZE=33298]="FRAMEBUFFER_ATTACHMENT_RED_SIZE",e[e.FRAMEBUFFER_ATTACHMENT_GREEN_SIZE=33299]="FRAMEBUFFER_ATTACHMENT_GREEN_SIZE",e[e.FRAMEBUFFER_ATTACHMENT_BLUE_SIZE=33300]="FRAMEBUFFER_ATTACHMENT_BLUE_SIZE",e[e.FRAMEBUFFER_ATTACHMENT_ALPHA_SIZE=33301]="FRAMEBUFFER_ATTACHMENT_ALPHA_SIZE",e[e.FRAMEBUFFER_ATTACHMENT_DEPTH_SIZE=33302]="FRAMEBUFFER_ATTACHMENT_DEPTH_SIZE",e[e.FRAMEBUFFER_ATTACHMENT_STENCIL_SIZE=33303]="FRAMEBUFFER_ATTACHMENT_STENCIL_SIZE",e[e.FRAMEBUFFER_DEFAULT=33304]="FRAMEBUFFER_DEFAULT",e[e.DEPTH24_STENCIL8=35056]="DEPTH24_STENCIL8",e[e.DRAW_FRAMEBUFFER_BINDING=36006]="DRAW_FRAMEBUFFER_BINDING",e[e.READ_FRAMEBUFFER_BINDING=36010]="READ_FRAMEBUFFER_BINDING",e[e.RENDERBUFFER_SAMPLES=36011]="RENDERBUFFER_SAMPLES",e[e.FRAMEBUFFER_ATTACHMENT_TEXTURE_LAYER=36052]="FRAMEBUFFER_ATTACHMENT_TEXTURE_LAYER",e[e.FRAMEBUFFER_INCOMPLETE_MULTISAMPLE=36182]="FRAMEBUFFER_INCOMPLETE_MULTISAMPLE",e[e.UNIFORM_BUFFER=35345]="UNIFORM_BUFFER",e[e.UNIFORM_BUFFER_BINDING=35368]="UNIFORM_BUFFER_BINDING",e[e.UNIFORM_BUFFER_START=35369]="UNIFORM_BUFFER_START",e[e.UNIFORM_BUFFER_SIZE=35370]="UNIFORM_BUFFER_SIZE",e[e.MAX_VERTEX_UNIFORM_BLOCKS=35371]="MAX_VERTEX_UNIFORM_BLOCKS",e[e.MAX_FRAGMENT_UNIFORM_BLOCKS=35373]="MAX_FRAGMENT_UNIFORM_BLOCKS",e[e.MAX_COMBINED_UNIFORM_BLOCKS=35374]="MAX_COMBINED_UNIFORM_BLOCKS",e[e.MAX_UNIFORM_BUFFER_BINDINGS=35375]="MAX_UNIFORM_BUFFER_BINDINGS",e[e.MAX_UNIFORM_BLOCK_SIZE=35376]="MAX_UNIFORM_BLOCK_SIZE",e[e.MAX_COMBINED_VERTEX_UNIFORM_COMPONENTS=35377]="MAX_COMBINED_VERTEX_UNIFORM_COMPONENTS",e[e.MAX_COMBINED_FRAGMENT_UNIFORM_COMPONENTS=35379]="MAX_COMBINED_FRAGMENT_UNIFORM_COMPONENTS",e[e.UNIFORM_BUFFER_OFFSET_ALIGNMENT=35380]="UNIFORM_BUFFER_OFFSET_ALIGNMENT",e[e.ACTIVE_UNIFORM_BLOCKS=35382]="ACTIVE_UNIFORM_BLOCKS",e[e.UNIFORM_TYPE=35383]="UNIFORM_TYPE",e[e.UNIFORM_SIZE=35384]="UNIFORM_SIZE",e[e.UNIFORM_BLOCK_INDEX=35386]="UNIFORM_BLOCK_INDEX",e[e.UNIFORM_OFFSET=35387]="UNIFORM_OFFSET",e[e.UNIFORM_ARRAY_STRIDE=35388]="UNIFORM_ARRAY_STRIDE",e[e.UNIFORM_MATRIX_STRIDE=35389]="UNIFORM_MATRIX_STRIDE",e[e.UNIFORM_IS_ROW_MAJOR=35390]="UNIFORM_IS_ROW_MAJOR",e[e.UNIFORM_BLOCK_BINDING=35391]="UNIFORM_BLOCK_BINDING",e[e.UNIFORM_BLOCK_DATA_SIZE=35392]="UNIFORM_BLOCK_DATA_SIZE",e[e.UNIFORM_BLOCK_ACTIVE_UNIFORMS=35394]="UNIFORM_BLOCK_ACTIVE_UNIFORMS",e[e.UNIFORM_BLOCK_ACTIVE_UNIFORM_INDICES=35395]="UNIFORM_BLOCK_ACTIVE_UNIFORM_INDICES",e[e.UNIFORM_BLOCK_REFERENCED_BY_VERTEX_SHADER=35396]="UNIFORM_BLOCK_REFERENCED_BY_VERTEX_SHADER",e[e.UNIFORM_BLOCK_REFERENCED_BY_FRAGMENT_SHADER=35398]="UNIFORM_BLOCK_REFERENCED_BY_FRAGMENT_SHADER",e[e.OBJECT_TYPE=37138]="OBJECT_TYPE",e[e.SYNC_CONDITION=37139]="SYNC_CONDITION",e[e.SYNC_STATUS=37140]="SYNC_STATUS",e[e.SYNC_FLAGS=37141]="SYNC_FLAGS",e[e.SYNC_FENCE=37142]="SYNC_FENCE",e[e.SYNC_GPU_COMMANDS_COMPLETE=37143]="SYNC_GPU_COMMANDS_COMPLETE",e[e.UNSIGNALED=37144]="UNSIGNALED",e[e.SIGNALED=37145]="SIGNALED",e[e.ALREADY_SIGNALED=37146]="ALREADY_SIGNALED",e[e.TIMEOUT_EXPIRED=37147]="TIMEOUT_EXPIRED",e[e.CONDITION_SATISFIED=37148]="CONDITION_SATISFIED",e[e.WAIT_FAILED=37149]="WAIT_FAILED",e[e.SYNC_FLUSH_COMMANDS_BIT=1]="SYNC_FLUSH_COMMANDS_BIT",e[e.COLOR=6144]="COLOR",e[e.DEPTH=6145]="DEPTH",e[e.STENCIL=6146]="STENCIL",e[e.MIN=32775]="MIN",e[e.MAX=32776]="MAX",e[e.DEPTH_COMPONENT24=33190]="DEPTH_COMPONENT24",e[e.STREAM_READ=35041]="STREAM_READ",e[e.STREAM_COPY=35042]="STREAM_COPY",e[e.STATIC_READ=35045]="STATIC_READ",e[e.STATIC_COPY=35046]="STATIC_COPY",e[e.DYNAMIC_READ=35049]="DYNAMIC_READ",e[e.DYNAMIC_COPY=35050]="DYNAMIC_COPY",e[e.DEPTH_COMPONENT32F=36012]="DEPTH_COMPONENT32F",e[e.DEPTH32F_STENCIL8=36013]="DEPTH32F_STENCIL8",e[e.INVALID_INDEX=4294967295]="INVALID_INDEX",e[e.TIMEOUT_IGNORED=-1]="TIMEOUT_IGNORED",e[e.MAX_CLIENT_WAIT_TIMEOUT_WEBGL=37447]="MAX_CLIENT_WAIT_TIMEOUT_WEBGL",e[e.UNMASKED_VENDOR_WEBGL=37445]="UNMASKED_VENDOR_WEBGL",e[e.UNMASKED_RENDERER_WEBGL=37446]="UNMASKED_RENDERER_WEBGL",e[e.MAX_TEXTURE_MAX_ANISOTROPY_EXT=34047]="MAX_TEXTURE_MAX_ANISOTROPY_EXT",e[e.TEXTURE_MAX_ANISOTROPY_EXT=34046]="TEXTURE_MAX_ANISOTROPY_EXT",e[e.R16_EXT=33322]="R16_EXT",e[e.RG16_EXT=33324]="RG16_EXT",e[e.RGB16_EXT=32852]="RGB16_EXT",e[e.RGBA16_EXT=32859]="RGBA16_EXT",e[e.R16_SNORM_EXT=36760]="R16_SNORM_EXT",e[e.RG16_SNORM_EXT=36761]="RG16_SNORM_EXT",e[e.RGB16_SNORM_EXT=36762]="RGB16_SNORM_EXT",e[e.RGBA16_SNORM_EXT=36763]="RGBA16_SNORM_EXT",e[e.COMPRESSED_RGB_S3TC_DXT1_EXT=33776]="COMPRESSED_RGB_S3TC_DXT1_EXT",e[e.COMPRESSED_RGBA_S3TC_DXT1_EXT=33777]="COMPRESSED_RGBA_S3TC_DXT1_EXT",e[e.COMPRESSED_RGBA_S3TC_DXT3_EXT=33778]="COMPRESSED_RGBA_S3TC_DXT3_EXT",e[e.COMPRESSED_RGBA_S3TC_DXT5_EXT=33779]="COMPRESSED_RGBA_S3TC_DXT5_EXT",e[e.COMPRESSED_SRGB_S3TC_DXT1_EXT=35916]="COMPRESSED_SRGB_S3TC_DXT1_EXT",e[e.COMPRESSED_SRGB_ALPHA_S3TC_DXT1_EXT=35917]="COMPRESSED_SRGB_ALPHA_S3TC_DXT1_EXT",e[e.COMPRESSED_SRGB_ALPHA_S3TC_DXT3_EXT=35918]="COMPRESSED_SRGB_ALPHA_S3TC_DXT3_EXT",e[e.COMPRESSED_SRGB_ALPHA_S3TC_DXT5_EXT=35919]="COMPRESSED_SRGB_ALPHA_S3TC_DXT5_EXT",e[e.COMPRESSED_RED_RGTC1_EXT=36283]="COMPRESSED_RED_RGTC1_EXT",e[e.COMPRESSED_SIGNED_RED_RGTC1_EXT=36284]="COMPRESSED_SIGNED_RED_RGTC1_EXT",e[e.COMPRESSED_RED_GREEN_RGTC2_EXT=36285]="COMPRESSED_RED_GREEN_RGTC2_EXT",e[e.COMPRESSED_SIGNED_RED_GREEN_RGTC2_EXT=36286]="COMPRESSED_SIGNED_RED_GREEN_RGTC2_EXT",e[e.COMPRESSED_RGBA_BPTC_UNORM_EXT=36492]="COMPRESSED_RGBA_BPTC_UNORM_EXT",e[e.COMPRESSED_SRGB_ALPHA_BPTC_UNORM_EXT=36493]="COMPRESSED_SRGB_ALPHA_BPTC_UNORM_EXT",e[e.COMPRESSED_RGB_BPTC_SIGNED_FLOAT_EXT=36494]="COMPRESSED_RGB_BPTC_SIGNED_FLOAT_EXT",e[e.COMPRESSED_RGB_BPTC_UNSIGNED_FLOAT_EXT=36495]="COMPRESSED_RGB_BPTC_UNSIGNED_FLOAT_EXT",e[e.COMPRESSED_R11_EAC=37488]="COMPRESSED_R11_EAC",e[e.COMPRESSED_SIGNED_R11_EAC=37489]="COMPRESSED_SIGNED_R11_EAC",e[e.COMPRESSED_RG11_EAC=37490]="COMPRESSED_RG11_EAC",e[e.COMPRESSED_SIGNED_RG11_EAC=37491]="COMPRESSED_SIGNED_RG11_EAC",e[e.COMPRESSED_RGB8_ETC2=37492]="COMPRESSED_RGB8_ETC2",e[e.COMPRESSED_RGBA8_ETC2_EAC=37493]="COMPRESSED_RGBA8_ETC2_EAC",e[e.COMPRESSED_SRGB8_ETC2=37494]="COMPRESSED_SRGB8_ETC2",e[e.COMPRESSED_SRGB8_ALPHA8_ETC2_EAC=37495]="COMPRESSED_SRGB8_ALPHA8_ETC2_EAC",e[e.COMPRESSED_RGB8_PUNCHTHROUGH_ALPHA1_ETC2=37496]="COMPRESSED_RGB8_PUNCHTHROUGH_ALPHA1_ETC2",e[e.COMPRESSED_SRGB8_PUNCHTHROUGH_ALPHA1_ETC2=37497]="COMPRESSED_SRGB8_PUNCHTHROUGH_ALPHA1_ETC2",e[e.COMPRESSED_RGB_PVRTC_4BPPV1_IMG=35840]="COMPRESSED_RGB_PVRTC_4BPPV1_IMG",e[e.COMPRESSED_RGBA_PVRTC_4BPPV1_IMG=35842]="COMPRESSED_RGBA_PVRTC_4BPPV1_IMG",e[e.COMPRESSED_RGB_PVRTC_2BPPV1_IMG=35841]="COMPRESSED_RGB_PVRTC_2BPPV1_IMG",e[e.COMPRESSED_RGBA_PVRTC_2BPPV1_IMG=35843]="COMPRESSED_RGBA_PVRTC_2BPPV1_IMG",e[e.COMPRESSED_RGB_ETC1_WEBGL=36196]="COMPRESSED_RGB_ETC1_WEBGL",e[e.COMPRESSED_RGB_ATC_WEBGL=35986]="COMPRESSED_RGB_ATC_WEBGL",e[e.COMPRESSED_RGBA_ATC_EXPLICIT_ALPHA_WEBGL=35986]="COMPRESSED_RGBA_ATC_EXPLICIT_ALPHA_WEBGL",e[e.COMPRESSED_RGBA_ATC_INTERPOLATED_ALPHA_WEBGL=34798]="COMPRESSED_RGBA_ATC_INTERPOLATED_ALPHA_WEBGL",e[e.COMPRESSED_RGBA_ASTC_4x4_KHR=37808]="COMPRESSED_RGBA_ASTC_4x4_KHR",e[e.COMPRESSED_RGBA_ASTC_5x4_KHR=37809]="COMPRESSED_RGBA_ASTC_5x4_KHR",e[e.COMPRESSED_RGBA_ASTC_5x5_KHR=37810]="COMPRESSED_RGBA_ASTC_5x5_KHR",e[e.COMPRESSED_RGBA_ASTC_6x5_KHR=37811]="COMPRESSED_RGBA_ASTC_6x5_KHR",e[e.COMPRESSED_RGBA_ASTC_6x6_KHR=37812]="COMPRESSED_RGBA_ASTC_6x6_KHR",e[e.COMPRESSED_RGBA_ASTC_8x5_KHR=37813]="COMPRESSED_RGBA_ASTC_8x5_KHR",e[e.COMPRESSED_RGBA_ASTC_8x6_KHR=37814]="COMPRESSED_RGBA_ASTC_8x6_KHR",e[e.COMPRESSED_RGBA_ASTC_8x8_KHR=37815]="COMPRESSED_RGBA_ASTC_8x8_KHR",e[e.COMPRESSED_RGBA_ASTC_10x5_KHR=37816]="COMPRESSED_RGBA_ASTC_10x5_KHR",e[e.COMPRESSED_RGBA_ASTC_10x6_KHR=37817]="COMPRESSED_RGBA_ASTC_10x6_KHR",e[e.COMPRESSED_RGBA_ASTC_10x8_KHR=37818]="COMPRESSED_RGBA_ASTC_10x8_KHR",e[e.COMPRESSED_RGBA_ASTC_10x10_KHR=37819]="COMPRESSED_RGBA_ASTC_10x10_KHR",e[e.COMPRESSED_RGBA_ASTC_12x10_KHR=37820]="COMPRESSED_RGBA_ASTC_12x10_KHR",e[e.COMPRESSED_RGBA_ASTC_12x12_KHR=37821]="COMPRESSED_RGBA_ASTC_12x12_KHR",e[e.COMPRESSED_SRGB8_ALPHA8_ASTC_4x4_KHR=37840]="COMPRESSED_SRGB8_ALPHA8_ASTC_4x4_KHR",e[e.COMPRESSED_SRGB8_ALPHA8_ASTC_5x4_KHR=37841]="COMPRESSED_SRGB8_ALPHA8_ASTC_5x4_KHR",e[e.COMPRESSED_SRGB8_ALPHA8_ASTC_5x5_KHR=37842]="COMPRESSED_SRGB8_ALPHA8_ASTC_5x5_KHR",e[e.COMPRESSED_SRGB8_ALPHA8_ASTC_6x5_KHR=37843]="COMPRESSED_SRGB8_ALPHA8_ASTC_6x5_KHR",e[e.COMPRESSED_SRGB8_ALPHA8_ASTC_6x6_KHR=37844]="COMPRESSED_SRGB8_ALPHA8_ASTC_6x6_KHR",e[e.COMPRESSED_SRGB8_ALPHA8_ASTC_8x5_KHR=37845]="COMPRESSED_SRGB8_ALPHA8_ASTC_8x5_KHR",e[e.COMPRESSED_SRGB8_ALPHA8_ASTC_8x6_KHR=37846]="COMPRESSED_SRGB8_ALPHA8_ASTC_8x6_KHR",e[e.COMPRESSED_SRGB8_ALPHA8_ASTC_8x8_KHR=37847]="COMPRESSED_SRGB8_ALPHA8_ASTC_8x8_KHR",e[e.COMPRESSED_SRGB8_ALPHA8_ASTC_10x5_KHR=37848]="COMPRESSED_SRGB8_ALPHA8_ASTC_10x5_KHR",e[e.COMPRESSED_SRGB8_ALPHA8_ASTC_10x6_KHR=37849]="COMPRESSED_SRGB8_ALPHA8_ASTC_10x6_KHR",e[e.COMPRESSED_SRGB8_ALPHA8_ASTC_10x8_KHR=37850]="COMPRESSED_SRGB8_ALPHA8_ASTC_10x8_KHR",e[e.COMPRESSED_SRGB8_ALPHA8_ASTC_10x10_KHR=37851]="COMPRESSED_SRGB8_ALPHA8_ASTC_10x10_KHR",e[e.COMPRESSED_SRGB8_ALPHA8_ASTC_12x10_KHR=37852]="COMPRESSED_SRGB8_ALPHA8_ASTC_12x10_KHR",e[e.COMPRESSED_SRGB8_ALPHA8_ASTC_12x12_KHR=37853]="COMPRESSED_SRGB8_ALPHA8_ASTC_12x12_KHR",e[e.QUERY_COUNTER_BITS_EXT=34916]="QUERY_COUNTER_BITS_EXT",e[e.CURRENT_QUERY_EXT=34917]="CURRENT_QUERY_EXT",e[e.QUERY_RESULT_EXT=34918]="QUERY_RESULT_EXT",e[e.QUERY_RESULT_AVAILABLE_EXT=34919]="QUERY_RESULT_AVAILABLE_EXT",e[e.TIME_ELAPSED_EXT=35007]="TIME_ELAPSED_EXT",e[e.TIMESTAMP_EXT=36392]="TIMESTAMP_EXT",e[e.GPU_DISJOINT_EXT=36795]="GPU_DISJOINT_EXT",e[e.COMPLETION_STATUS_KHR=37297]="COMPLETION_STATUS_KHR",e[e.DEPTH_CLAMP_EXT=34383]="DEPTH_CLAMP_EXT",e[e.FIRST_VERTEX_CONVENTION_WEBGL=36429]="FIRST_VERTEX_CONVENTION_WEBGL",e[e.LAST_VERTEX_CONVENTION_WEBGL=36430]="LAST_VERTEX_CONVENTION_WEBGL",e[e.PROVOKING_VERTEX_WEBL=36431]="PROVOKING_VERTEX_WEBL",e[e.POLYGON_MODE_WEBGL=2880]="POLYGON_MODE_WEBGL",e[e.POLYGON_OFFSET_LINE_WEBGL=10754]="POLYGON_OFFSET_LINE_WEBGL",e[e.LINE_WEBGL=6913]="LINE_WEBGL",e[e.FILL_WEBGL=6914]="FILL_WEBGL",e[e.MAX_CLIP_DISTANCES_WEBGL=3378]="MAX_CLIP_DISTANCES_WEBGL",e[e.MAX_CULL_DISTANCES_WEBGL=33529]="MAX_CULL_DISTANCES_WEBGL",e[e.MAX_COMBINED_CLIP_AND_CULL_DISTANCES_WEBGL=33530]="MAX_COMBINED_CLIP_AND_CULL_DISTANCES_WEBGL",e[e.CLIP_DISTANCE0_WEBGL=12288]="CLIP_DISTANCE0_WEBGL",e[e.CLIP_DISTANCE1_WEBGL=12289]="CLIP_DISTANCE1_WEBGL",e[e.CLIP_DISTANCE2_WEBGL=12290]="CLIP_DISTANCE2_WEBGL",e[e.CLIP_DISTANCE3_WEBGL=12291]="CLIP_DISTANCE3_WEBGL",e[e.CLIP_DISTANCE4_WEBGL=12292]="CLIP_DISTANCE4_WEBGL",e[e.CLIP_DISTANCE5_WEBGL=12293]="CLIP_DISTANCE5_WEBGL",e[e.CLIP_DISTANCE6_WEBGL=12294]="CLIP_DISTANCE6_WEBGL",e[e.CLIP_DISTANCE7_WEBGL=12295]="CLIP_DISTANCE7_WEBGL",e[e.POLYGON_OFFSET_CLAMP_EXT=36379]="POLYGON_OFFSET_CLAMP_EXT",e[e.LOWER_LEFT_EXT=36001]="LOWER_LEFT_EXT",e[e.UPPER_LEFT_EXT=36002]="UPPER_LEFT_EXT",e[e.NEGATIVE_ONE_TO_ONE_EXT=37726]="NEGATIVE_ONE_TO_ONE_EXT",e[e.ZERO_TO_ONE_EXT=37727]="ZERO_TO_ONE_EXT",e[e.CLIP_ORIGIN_EXT=37724]="CLIP_ORIGIN_EXT",e[e.CLIP_DEPTH_MODE_EXT=37725]="CLIP_DEPTH_MODE_EXT",e[e.SRC1_COLOR_WEBGL=35065]="SRC1_COLOR_WEBGL",e[e.SRC1_ALPHA_WEBGL=34185]="SRC1_ALPHA_WEBGL",e[e.ONE_MINUS_SRC1_COLOR_WEBGL=35066]="ONE_MINUS_SRC1_COLOR_WEBGL",e[e.ONE_MINUS_SRC1_ALPHA_WEBGL=35067]="ONE_MINUS_SRC1_ALPHA_WEBGL",e[e.MAX_DUAL_SOURCE_DRAW_BUFFERS_WEBGL=35068]="MAX_DUAL_SOURCE_DRAW_BUFFERS_WEBGL",e[e.MIRROR_CLAMP_TO_EDGE_EXT=34627]="MIRROR_CLAMP_TO_EDGE_EXT"}(kb||(kb={}));const Db={3042:!1,32773:new Float32Array([0,0,0,0]),32777:32774,34877:32774,32969:1,32968:0,32971:1,32970:0,3106:new Float32Array([0,0,0,0]),3107:[!0,!0,!0,!0],2884:!1,2885:1029,2929:!1,2931:1,2932:513,2928:new Float32Array([0,1]),2930:!0,3024:!0,35725:null,36006:null,36007:null,34229:null,34964:null,2886:2305,33170:4352,2849:1,32823:!1,32824:0,10752:0,32926:!1,32928:!1,32938:1,32939:!1,3089:!1,3088:new Int32Array([0,0,1024,1024]),2960:!1,2961:0,2968:4294967295,36005:4294967295,2962:519,2967:0,2963:4294967295,34816:519,36003:0,36004:4294967295,2964:7680,2965:7680,2966:7680,34817:7680,34818:7680,34819:7680,2978:[0,0,1024,1024],36389:null,36662:null,36663:null,35053:null,35055:null,35723:4352,36010:null,35977:!1,3333:4,3317:4,37440:!1,37441:!1,37443:37444,3330:0,3332:0,3331:0,3314:0,32878:0,3316:0,3315:0,32877:0},Ob=(e,t,i)=>t?e.enable(i):e.disable(i),zb=(e,t,i)=>e.hint(i,t),Ub=(e,t,i)=>e.pixelStorei(i,t),Nb=(e,t,i)=>{const r=36006===i?36009:36008;return e.bindFramebuffer(r,t)},Vb=(e,t,i)=>{const r={34964:34962,36662:36662,36663:36663,35053:35051,35055:35052}[i];e.bindBuffer(r,t)};function jb(e){return Array.isArray(e)||ArrayBuffer.isView(e)&&!(e instanceof DataView)}const Gb={3042:Ob,32773:(e,t)=>e.blendColor(...t),32777:"blendEquation",34877:"blendEquation",32969:"blendFunc",32968:"blendFunc",32971:"blendFunc",32970:"blendFunc",3106:(e,t)=>e.clearColor(...t),3107:(e,t)=>e.colorMask(...t),2884:Ob,2885:(e,t)=>e.cullFace(t),2929:Ob,2931:(e,t)=>e.clearDepth(t),2932:(e,t)=>e.depthFunc(t),2928:(e,t)=>e.depthRange(...t),2930:(e,t)=>e.depthMask(t),3024:Ob,35723:zb,35725:(e,t)=>e.useProgram(t),36007:(e,t)=>e.bindRenderbuffer(36161,t),36389:(e,t)=>e.bindTransformFeedback?.(36386,t),34229:(e,t)=>e.bindVertexArray(t),36006:Nb,36010:Nb,34964:Vb,36662:Vb,36663:Vb,35053:Vb,35055:Vb,2886:(e,t)=>e.frontFace(t),33170:zb,2849:(e,t)=>e.lineWidth(t),32823:Ob,32824:"polygonOffset",10752:"polygonOffset",35977:Ob,32926:Ob,32928:Ob,32938:"sampleCoverage",32939:"sampleCoverage",3089:Ob,3088:(e,t)=>e.scissor(...t),2960:Ob,2961:(e,t)=>e.clearStencil(t),2968:(e,t)=>e.stencilMaskSeparate(1028,t),36005:(e,t)=>e.stencilMaskSeparate(1029,t),2962:"stencilFuncFront",2967:"stencilFuncFront",2963:"stencilFuncFront",34816:"stencilFuncBack",36003:"stencilFuncBack",36004:"stencilFuncBack",2964:"stencilOpFront",2965:"stencilOpFront",2966:"stencilOpFront",34817:"stencilOpBack",34818:"stencilOpBack",34819:"stencilOpBack",2978:(e,t)=>e.viewport(...t),34383:Ob,10754:Ob,12288:Ob,12289:Ob,12290:Ob,12291:Ob,12292:Ob,12293:Ob,12294:Ob,12295:Ob,3333:Ub,3317:Ub,37440:Ub,37441:Ub,37443:Ub,3330:Ub,3332:Ub,3331:Ub,3314:Ub,32878:Ub,3316:Ub,3315:Ub,32877:Ub,framebuffer:(e,t)=>{const i=t&&"handle"in t?t.handle:t;return e.bindFramebuffer(36160,i)},blend:(e,t)=>t?e.enable(3042):e.disable(3042),blendColor:(e,t)=>e.blendColor(...t),blendEquation:(e,t)=>{const i="number"==typeof t?[t,t]:t;e.blendEquationSeparate(...i)},blendFunc:(e,t)=>{const i=2===t?.length?[...t,...t]:t;e.blendFuncSeparate(...i)},clearColor:(e,t)=>e.clearColor(...t),clearDepth:(e,t)=>e.clearDepth(t),clearStencil:(e,t)=>e.clearStencil(t),colorMask:(e,t)=>e.colorMask(...t),cull:(e,t)=>t?e.enable(2884):e.disable(2884),cullFace:(e,t)=>e.cullFace(t),depthTest:(e,t)=>t?e.enable(2929):e.disable(2929),depthFunc:(e,t)=>e.depthFunc(t),depthMask:(e,t)=>e.depthMask(t),depthRange:(e,t)=>e.depthRange(...t),dither:(e,t)=>t?e.enable(3024):e.disable(3024),derivativeHint:(e,t)=>{e.hint(35723,t)},frontFace:(e,t)=>e.frontFace(t),mipmapHint:(e,t)=>e.hint(33170,t),lineWidth:(e,t)=>e.lineWidth(t),polygonOffsetFill:(e,t)=>t?e.enable(32823):e.disable(32823),polygonOffset:(e,t)=>e.polygonOffset(...t),sampleCoverage:(e,t)=>e.sampleCoverage(...t),scissorTest:(e,t)=>t?e.enable(3089):e.disable(3089),scissor:(e,t)=>e.scissor(...t),stencilTest:(e,t)=>t?e.enable(2960):e.disable(2960),stencilMask:(e,t)=>{t=jb(t)?t:[t,t];const[i,r]=t;e.stencilMaskSeparate(1028,i),e.stencilMaskSeparate(1029,r)},stencilFunc:(e,t)=>{t=jb(t)&&3===t.length?[...t,...t]:t;const[i,r,n,o,s,a]=t;e.stencilFuncSeparate(1028,i,r,n),e.stencilFuncSeparate(1029,o,s,a)},stencilOp:(e,t)=>{t=jb(t)&&3===t.length?[...t,...t]:t;const[i,r,n,o,s,a]=t;e.stencilOpSeparate(1028,i,r,n),e.stencilOpSeparate(1029,o,s,a)},viewport:(e,t)=>e.viewport(...t)};function Hb(e,t,i){return void 0!==t[e]?t[e]:i[e]}const Qb={blendEquation:(e,t,i)=>e.blendEquationSeparate(Hb(32777,t,i),Hb(34877,t,i)),blendFunc:(e,t,i)=>e.blendFuncSeparate(Hb(32969,t,i),Hb(32968,t,i),Hb(32971,t,i),Hb(32970,t,i)),polygonOffset:(e,t,i)=>e.polygonOffset(Hb(32824,t,i),Hb(10752,t,i)),sampleCoverage:(e,t,i)=>e.sampleCoverage(Hb(32938,t,i),Hb(32939,t,i)),stencilFuncFront:(e,t,i)=>e.stencilFuncSeparate(1028,Hb(2962,t,i),Hb(2967,t,i),Hb(2963,t,i)),stencilFuncBack:(e,t,i)=>e.stencilFuncSeparate(1029,Hb(34816,t,i),Hb(36003,t,i),Hb(36004,t,i)),stencilOpFront:(e,t,i)=>e.stencilOpSeparate(1028,Hb(2964,t,i),Hb(2965,t,i),Hb(2966,t,i)),stencilOpBack:(e,t,i)=>e.stencilOpSeparate(1029,Hb(34817,t,i),Hb(34818,t,i),Hb(34819,t,i))},$b={enable:(e,t)=>e({[t]:!0}),disable:(e,t)=>e({[t]:!1}),pixelStorei:(e,t,i)=>e({[t]:i}),hint:(e,t,i)=>e({[t]:i}),useProgram:(e,t)=>e({35725:t}),bindRenderbuffer:(e,t,i)=>e({36007:i}),bindTransformFeedback:(e,t,i)=>e({36389:i}),bindVertexArray:(e,t)=>e({34229:t}),bindFramebuffer:(e,t,i)=>{switch(t){case 36160:return e({36006:i,36010:i});case 36009:return e({36006:i});case 36008:return e({36010:i});default:return null}},bindBuffer:(e,t,i)=>{const r={34962:[34964],36662:[36662],36663:[36663],35051:[35053],35052:[35055]}[t];return r?e({[r]:i}):{valueChanged:!0}},blendColor:(e,t,i,r,n)=>e({32773:new Float32Array([t,i,r,n])}),blendEquation:(e,t)=>e({32777:t,34877:t}),blendEquationSeparate:(e,t,i)=>e({32777:t,34877:i}),blendFunc:(e,t,i)=>e({32969:t,32968:i,32971:t,32970:i}),blendFuncSeparate:(e,t,i,r,n)=>e({32969:t,32968:i,32971:r,32970:n}),clearColor:(e,t,i,r,n)=>e({3106:new Float32Array([t,i,r,n])}),clearDepth:(e,t)=>e({2931:t}),clearStencil:(e,t)=>e({2961:t}),colorMask:(e,t,i,r,n)=>e({3107:[t,i,r,n]}),cullFace:(e,t)=>e({2885:t}),depthFunc:(e,t)=>e({2932:t}),depthRange:(e,t,i)=>e({2928:new Float32Array([t,i])}),depthMask:(e,t)=>e({2930:t}),frontFace:(e,t)=>e({2886:t}),lineWidth:(e,t)=>e({2849:t}),polygonOffset:(e,t,i)=>e({32824:t,10752:i}),sampleCoverage:(e,t,i)=>e({32938:t,32939:i}),scissor:(e,t,i,r,n)=>e({3088:new Int32Array([t,i,r,n])}),stencilMask:(e,t)=>e({2968:t,36005:t}),stencilMaskSeparate:(e,t,i)=>e({[1028===t?2968:36005]:i}),stencilFunc:(e,t,i,r)=>e({2962:t,2967:i,2963:r,34816:t,36003:i,36004:r}),stencilFuncSeparate:(e,t,i,r,n)=>e({[1028===t?2962:34816]:i,[1028===t?2967:36003]:r,[1028===t?2963:36004]:n}),stencilOp:(e,t,i,r)=>e({2964:t,2965:i,2966:r,34817:t,34818:i,34819:r}),stencilOpSeparate:(e,t,i,r,n)=>e({[1028===t?2964:34817]:i,[1028===t?2965:34818]:r,[1028===t?2966:34819]:n}),viewport:(e,t,i,r,n)=>e({2978:[t,i,r,n]})},Zb=(e,t)=>e.isEnabled(t),Wb={3042:Zb,2884:Zb,2929:Zb,3024:Zb,32823:Zb,32926:Zb,32928:Zb,3089:Zb,2960:Zb,35977:Zb},qb=new Set([34016,36388,36387,35983,35368,34965,35739,35738,3074,34853,34854,34855,34856,34857,34858,34859,34860,34861,34862,34863,34864,34865,34866,34867,34868,35097,32873,35869,32874,34068]);function Kb(e,t){if(function(e){for(const t in e)return!1;return!0}(t))return;const i={};for(const r in t){const n=Number(r),o=Gb[r];o&&("string"==typeof o?i[o]=!0:o(e,t[r],n))}const r=e.state&&e.state.cache;if(r)for(const n in i){(0,Qb[n])(e,t,r)}}function Xb(e,t=Db){if("number"==typeof t){const i=t,r=Wb[i];return r?r(e,i):e.getParameter(i)}const i=Array.isArray(t)?t:Object.keys(t),r={};for(const t of i){const i=Wb[t];r[t]=i?i(e,Number(t)):e.getParameter(Number(t))}return r}function Jb(e,t){if(e===t)return!0;const i=Array.isArray(e)||ArrayBuffer.isView(e),r=Array.isArray(t)||ArrayBuffer.isView(t);if(i&&r&&e.length===t.length){for(let i=0;i{}}={}){this.gl=e,this.cache=t?Xb(e):Object.assign({},Db),this.log=i,this._updateCache=this._updateCache.bind(this),Object.seal(this)}push(e={}){this.stateStack.push({})}pop(){lf(this.stateStack.length>0);const e=this.stateStack[this.stateStack.length-1];Kb(this.gl,e),this.stateStack.pop()}_updateCache(e){let t,i=!1;const r=this.stateStack.length>0?this.stateStack[this.stateStack.length-1]:null;for(const n in e){lf(void 0!==n);const o=e[n],s=this.cache[n];Jb(o,s)||(i=!0,t=s,r&&!(n in r)&&(r[n]=s),this.cache[n]=o)}return{valueChanged:i,oldValue:t}}}function ew(e){return e.state}function tw(e,t){const{enable:i=!0,copyState:r}=t;if(lf(void 0!==r),!e.state){e.state=new Yb(e,{copyState:r}),function(e){const t=e.useProgram.bind(e);e.useProgram=function(i){const r=ew(e);r.program!==i&&(t(i),r.program=i)}}(e);for(const t in $b){ow(e,t,$b[t])}nw(e,"getParameter"),nw(e,"isEnabled")}return ew(e).enable=i,e}function iw(e){let t=ew(e);t||(tw(e,{copyState:!1}),t=ew(e)),t.push()}function rw(e){const t=ew(e);lf(t),t.pop()}function nw(e,t){const i=e[t].bind(e);e[t]=function(t){if(void 0===t||qb.has(t))return i(t);const r=ew(e);return t in r.cache||(r.cache[t]=i(t)),r.enable?r.cache[t]:i(t)},Object.defineProperty(e[t],"name",{value:`${t}-from-cache`,configurable:!1})}function ow(e,t,i){if(!e[t])return;const r=e[t].bind(e);e[t]=function(...t){const n=ew(e),{valueChanged:o,oldValue:s}=i(n._updateCache,...t);return o&&r(...t),s},Object.defineProperty(e[t],"name",{value:`${t}-to-cache`,configurable:!1})}const sw={powerPreference:"high-performance",onContextLost:()=>console.error("WebGL context lost"),onContextRestored:()=>console.info("WebGL context restored")};function aw(e,t,i){return void 0===i[t]&&(i[t]=e.getExtension(t)||null),i[t]}function lw(e,t){const i=e.getParameter(7936),r=e.getParameter(7937);aw(e,"WEBGL_debug_renderer_info",t);const n=t.WEBGL_debug_renderer_info,o=e.getParameter(n?n.UNMASKED_VENDOR_WEBGL:7936)||i,s=e.getParameter(n?n.UNMASKED_RENDERER_WEBGL:7937)||r,a=e.getParameter(7938),l=cw(o,s),c=function(e,t){if(/Metal/i.exec(e)||/Metal/i.exec(t))return"metal";if(/ANGLE/i.exec(e)||/ANGLE/i.exec(t))return"opengl";return"unknown"}(o,s),u=function(e,t){if(/SwiftShader/i.exec(e)||/SwiftShader/i.exec(t))return"cpu";switch(cw(e,t)){case"intel":return"integrated";case"software":return"cpu";case"unknown":return"unknown";default:return"discrete"}}(o,s);return{type:"webgl",gpu:l,gpuType:u,gpuBackend:c,vendor:o,renderer:s,version:a,shadingLanguage:"glsl",shadingLanguageVersion:300}}function cw(e,t){return/NVIDIA/i.exec(e)||/NVIDIA/i.exec(t)?"nvidia":/INTEL/i.exec(e)||/INTEL/i.exec(t)?"intel":/Apple/i.exec(e)||/Apple/i.exec(t)?"apple":/AMD/i.exec(e)||/AMD/i.exec(t)||/ATI/i.exec(e)||/ATI/i.exec(t)?"amd":/SwiftShader/i.exec(e)||/SwiftShader/i.exec(t)?"software":"unknown"}function uw(e){switch(e){case"uint8":case"unorm8":return 5121;case"sint8":case"snorm8":return 5120;case"uint16":case"unorm16":return 5123;case"sint16":case"snorm16":return 5122;case"uint32":return 5125;case"sint32":return 5124;case"float16":return 5131;case"float32":return 5126}throw new Error(String(e))}const hw="texture-compression-bc",dw="texture-compression-astc",pw="texture-compression-etc2",fw="texture-compression-pvrtc-webgl",mw="texture-compression-atc-webgl",gw="float32-renderable-webgl",_w="float16-renderable-webgl",Aw="snorm8-renderable-webgl",yw="norm16-renderable-webgl",vw="snorm16-renderable-webgl",xw="float32-filterable",bw="float16-filterable-webgl",ww="WEBGL_compressed_texture_s3tc",Tw="WEBGL_compressed_texture_s3tc_srgb",Ew="EXT_texture_compression_rgtc",Cw="EXT_texture_compression_bptc",Bw="EXT_texture_norm16",Sw="EXT_render_snorm",Iw={"float32-renderable-webgl":["EXT_color_buffer_float"],"float16-renderable-webgl":["EXT_color_buffer_half_float"],"rgb9e5ufloat_renderable-webgl":["WEBGL_render_shared_exponent"],"snorm8-renderable-webgl":[Sw],"norm16-renderable-webgl":[Bw],"snorm16-renderable-webgl":[Bw,Sw],"float32-filterable":["OES_texture_float_linear"],"float16-filterable-webgl":["OES_texture_half_float_linear"],"texture-filterable-anisotropic-webgl":["EXT_texture_filter_anisotropic"],"texture-blend-float-webgl":["EXT_float_blend"],"texture-compression-bc":[ww,Tw,Ew,Cw],"texture-compression-bc5-webgl":[Ew],"texture-compression-bc7-webgl":[Cw],"texture-compression-etc2":["WEBGL_compressed_texture_etc"],"texture-compression-astc":["WEBGL_compressed_texture_astc"],"texture-compression-etc1-webgl":["WEBGL_compressed_texture_etc1"],"texture-compression-pvrtc-webgl":["WEBGL_compressed_texture_pvrtc"],"texture-compression-atc-webgl":["WEBGL_compressed_texture_atc"]};const Mw={"rgb8unorm-unsized":{gl:6407,b:4,c:2,bpp:4,dataFormat:6407,types:[5121,33635]},"rgba8unorm-unsized":{gl:6408,b:4,c:2,bpp:4,dataFormat:6408,types:[5121,32819,32820]},r8unorm:{gl:33321,b:1,c:1,rb:!0},r8snorm:{gl:36756,b:1,c:1,render:Aw},r8uint:{gl:33330,b:1,c:1,rb:!0},r8sint:{gl:33329,b:1,c:1,rb:!0},rg8unorm:{gl:33323,b:2,c:2,rb:!0},rg8snorm:{gl:36757,b:2,c:2,render:Aw},rg8uint:{gl:33336,b:2,c:2,rb:!0},rg8sint:{gl:33335,b:2,c:2,rb:!0},r16uint:{gl:33332,b:2,c:1,rb:!0},r16sint:{gl:33331,b:2,c:1,rb:!0},r16float:{gl:33325,b:2,c:1,render:_w,filter:"float16-filterable-webgl",rb:!0},"r16unorm-webgl":{gl:33322,b:2,c:1,f:yw,rb:!0},"r16snorm-webgl":{gl:36760,b:2,c:1,f:vw},"rgba4unorm-webgl":{gl:32854,b:2,c:4,wgpu:!1,rb:!0},"rgb565unorm-webgl":{gl:36194,b:2,c:4,wgpu:!1,rb:!0},"rgb5a1unorm-webgl":{gl:32855,b:2,c:4,wgpu:!1,rb:!0},"rgb8unorm-webgl":{gl:32849,b:3,c:3,wgpu:!1},"rgb8snorm-webgl":{gl:36758,b:3,c:3,wgpu:!1},rgba8unorm:{gl:32856,b:4,c:2,bpp:4},"rgba8unorm-srgb":{gl:35907,b:4,c:4,bpp:4},rgba8snorm:{gl:36759,b:4,c:4,render:Aw},rgba8uint:{gl:36220,b:4,c:4,bpp:4},rgba8sint:{gl:36238,b:4,c:4,bpp:4},bgra8unorm:{b:4,c:4},"bgra8unorm-srgb":{b:4,c:4},rg16uint:{gl:33338,b:4,c:1,bpp:4},rg16sint:{gl:33337,b:4,c:2,bpp:4},rg16float:{gl:33327,bpp:4,b:4,c:2,render:_w,filter:bw,rb:!0},"rg16unorm-webgl":{gl:33324,b:2,c:2,render:yw},"rg16snorm-webgl":{gl:36761,b:2,c:2,render:vw},r32uint:{gl:33334,b:4,c:1,bpp:4,rb:!0},r32sint:{gl:33333,b:4,c:1,bpp:4,rb:!0},r32float:{gl:33326,bpp:4,b:4,c:1,render:gw,filter:xw},rgb9e5ufloat:{gl:35901,b:4,c:3,p:1,render:"rgb9e5ufloat_renderable-webgl"},rg11b10ufloat:{gl:35898,b:4,c:3,p:1,render:gw,rb:!0},rgb10a2unorm:{gl:32857,b:4,c:4,p:1,rb:!0},"rgb10a2uint-webgl":{b:4,c:4,gl:36975,p:1,wgpu:!1,bpp:4,rb:!0},"rgb16unorm-webgl":{gl:32852,b:2,c:3,f:yw},"rgb16snorm-webgl":{gl:36762,b:2,c:3,f:yw},rg32uint:{gl:33340,b:8,c:2,rb:!0},rg32sint:{gl:33339,b:8,c:2,rb:!0},rg32float:{gl:33328,b:8,c:2,render:gw,filter:xw,rb:!0},rgba16uint:{gl:36214,b:8,c:4,rb:!0},rgba16sint:{gl:36232,b:8,c:4,rb:!0},rgba16float:{gl:34842,b:8,c:4,render:_w,filter:bw},"rgba16unorm-webgl":{gl:32859,b:2,c:4,render:yw,rb:!0},"rgba16snorm-webgl":{gl:36763,b:2,c:4,render:vw},"rgb32float-webgl":{gl:34837,render:gw,filter:xw,gl2ext:"EXT_color_buffer_float",dataFormat:6407,types:[5126]},rgba32uint:{gl:36208,b:16,c:4,rb:!0},rgba32sint:{gl:36226,b:16,c:4,rb:!0},rgba32float:{gl:34836,b:16,c:4,render:gw,filter:xw,rb:!0},stencil8:{gl:36168,b:1,c:1,attachment:36128,rb:!0},depth16unorm:{gl:33189,b:2,c:1,attachment:36096,dataFormat:6402,types:[5123],rb:!0},depth24plus:{gl:33190,b:3,c:1,attachment:36096,dataFormat:6402,types:[5125]},depth32float:{gl:36012,b:4,c:1,attachment:36096,dataFormat:6402,types:[5126],rb:!0},"depth24plus-stencil8":{gl:35056,b:4,c:2,p:1,attachment:33306,rb:!0,depthTexture:!0,dataFormat:34041,types:[34042]},"depth24unorm-stencil8":{gl:35056,b:4,c:2,p:1,attachment:33306,dataFormat:34041,types:[34042],rb:!0},"depth32float-stencil8":{gl:36013,b:5,c:2,p:1,attachment:33306,dataFormat:34041,types:[36269],rb:!0},"bc1-rgb-unorm-webgl":{gl:33776,x:ww,f:hw},"bc1-rgb-unorm-srgb-webgl":{gl:35916,x:Tw,f:hw},"bc1-rgba-unorm":{gl:33777,x:ww,f:hw},"bc1-rgba-unorm-srgb":{gl:35916,x:Tw,f:hw},"bc2-rgba-unorm":{gl:33778,x:ww,f:hw},"bc2-rgba-unorm-srgb":{gl:35918,x:Tw,f:hw},"bc3-rgba-unorm":{gl:33779,x:ww,f:hw},"bc3-rgba-unorm-srgb":{gl:35919,x:Tw,f:hw},"bc4-r-unorm":{gl:36283,x:Ew,f:hw},"bc4-r-snorm":{gl:36284,x:Ew,f:hw},"bc5-rg-unorm":{gl:36285,x:Ew,f:hw},"bc5-rg-snorm":{gl:36286,x:Ew,f:hw},"bc6h-rgb-ufloat":{gl:36495,x:Cw,f:hw},"bc6h-rgb-float":{gl:36494,x:Cw,f:hw},"bc7-rgba-unorm":{gl:36492,x:Cw,f:hw},"bc7-rgba-unorm-srgb":{gl:36493,x:Cw,f:hw},"etc2-rgb8unorm":{gl:37492,f:pw},"etc2-rgb8unorm-srgb":{gl:37494,f:pw},"etc2-rgb8a1unorm":{gl:37496,f:pw},"etc2-rgb8a1unorm-srgb":{gl:37497,f:pw},"etc2-rgba8unorm":{gl:37493,f:pw},"etc2-rgba8unorm-srgb":{gl:37495,f:pw},"eac-r11unorm":{gl:37488,f:pw},"eac-r11snorm":{gl:37489,f:pw},"eac-rg11unorm":{gl:37490,f:pw},"eac-rg11snorm":{gl:37491,f:pw},"astc-4x4-unorm":{gl:37808,f:dw},"astc-4x4-unorm-srgb":{gl:37840,f:dw},"astc-5x4-unorm":{gl:37809,f:dw},"astc-5x4-unorm-srgb":{gl:37841,f:dw},"astc-5x5-unorm":{gl:37810,f:dw},"astc-5x5-unorm-srgb":{gl:37842,f:dw},"astc-6x5-unorm":{gl:37811,f:dw},"astc-6x5-unorm-srgb":{gl:37843,f:dw},"astc-6x6-unorm":{gl:37812,f:dw},"astc-6x6-unorm-srgb":{gl:37844,f:dw},"astc-8x5-unorm":{gl:37813,f:dw},"astc-8x5-unorm-srgb":{gl:37845,f:dw},"astc-8x6-unorm":{gl:37814,f:dw},"astc-8x6-unorm-srgb":{gl:37846,f:dw},"astc-8x8-unorm":{gl:37815,f:dw},"astc-8x8-unorm-srgb":{gl:37847,f:dw},"astc-10x5-unorm":{gl:37819,f:dw},"astc-10x5-unorm-srgb":{gl:37851,f:dw},"astc-10x6-unorm":{gl:37817,f:dw},"astc-10x6-unorm-srgb":{gl:37849,f:dw},"astc-10x8-unorm":{gl:37818,f:dw},"astc-10x8-unorm-srgb":{gl:37850,f:dw},"astc-10x10-unorm":{gl:37819,f:dw},"astc-10x10-unorm-srgb":{gl:37851,f:dw},"astc-12x10-unorm":{gl:37820,f:dw},"astc-12x10-unorm-srgb":{gl:37852,f:dw},"astc-12x12-unorm":{gl:37821,f:dw},"astc-12x12-unorm-srgb":{gl:37853,f:dw},"pvrtc-rgb4unorm-webgl":{gl:35840,f:fw},"pvrtc-rgba4unorm-webgl":{gl:35842,f:fw},"pvrtc-rbg2unorm-webgl":{gl:35841,f:fw},"pvrtc-rgba2unorm-webgl":{gl:35843,f:fw},"etc1-rbg-unorm-webgl":{gl:36196,f:"texture-compression-etc1-webgl"},"atc-rgb-unorm-webgl":{gl:35986,f:mw},"atc-rgba-unorm-webgl":{gl:35986,f:mw},"atc-rgbai-unorm-webgl":{gl:34798,f:mw}},Pw={6403:1,36244:1,33319:2,33320:2,6407:3,36248:3,6408:4,36249:4,6402:1,34041:1,6406:1,6409:1,6410:2},Rw={5126:4,5125:4,5124:4,5123:2,5122:2,5131:2,5120:1,5121:1};function Lw(e,t,i){const r=Mw[t];if(!r)return!1;if(void 0===r.gl)return!1;const n=r.x||r.gl2ext;return!n||Boolean(aw(e,n,i))}function Fw(e){const t=Mw[e],i=t?.gl;if(void 0===i)throw new Error(`Unsupported texture format ${e}`);return i}function kw(e){const t=Mw[e],i=Fw(e),r=rf(e);return{format:i,dataFormat:t?.dataFormat||Ow(r.format,r.integer,r.normalized,i),type:r.dataType?uw(r.dataType):t?.types?.[0]||5121,compressed:r.compressed}}function Dw(e){const t=kw(e);return(Pw[t.dataFormat]||4)*(Rw[t.type]||1)}function Ow(e,t,i,r){if(6408===r||6407===r)return r;switch(e){case"r":return t&&!i?36244:6403;case"rg":return t&&!i?33320:33319;case"rgb":return t&&!i?36248:6407;case"rgba":return t&&!i?36249:6408;default:return 6408}}const zw={"depth-clip-control":"EXT_depth_clamp","timer-query-webgl":"EXT_disjoint_timer_query_webgl2","compilation-status-async-webgl":"KHR_parallel_shader_compile","polygon-mode-webgl":"WEBGL_polygon_mode","provoking-vertex-webgl":"WEBGL_provoking_vertex","shader-clip-cull-distance-webgl":"WEBGL_clip_cull_distance","shader-noperspective-interpolation-webgl":"NV_shader_noperspective_interpolation","shader-conservative-depth-webgl":"EXT_conservative_depth"};class Uw extends sf{gl;extensions;testedFeatures=new Set;constructor(e,t,i){super([],i),this.gl=e,this.extensions=t,aw(e,"EXT_color_buffer_float",t)}*[Symbol.iterator](){const e=this.getFeatures();for(const t of e)this.has(t)&&(yield t);return[]}has(e){return!this.disabledFeatures[e]&&(this.testedFeatures.has(e)||(this.testedFeatures.add(e),function(e){return e in Iw}(e)&&function(e,t,i){return(Iw[t]||[]).every(t=>aw(e,t,i))}(this.gl,e,this.extensions)&&this.features.add(e),this.getWebGLFeature(e)&&this.features.add(e)),this.features.has(e))}initializeFeatures(){const e=this.getFeatures().filter(e=>"polygon-mode-webgl"!==e);for(const t of e)this.has(t)}getFeatures(){return[...Object.keys(zw),...Object.keys(Iw)]}getWebGLFeature(e){const t=zw[e];return"string"==typeof t?Boolean(aw(this.gl,t,this.extensions)):Boolean(t)}}class Nw extends of{get maxTextureDimension1D(){return 0}get maxTextureDimension2D(){return this.getParameter(3379)}get maxTextureDimension3D(){return this.getParameter(32883)}get maxTextureArrayLayers(){return this.getParameter(35071)}get maxBindGroups(){return 0}get maxDynamicUniformBuffersPerPipelineLayout(){return 0}get maxDynamicStorageBuffersPerPipelineLayout(){return 0}get maxSampledTexturesPerShaderStage(){return this.getParameter(35660)}get maxSamplersPerShaderStage(){return this.getParameter(35661)}get maxStorageBuffersPerShaderStage(){return 0}get maxStorageTexturesPerShaderStage(){return 0}get maxUniformBuffersPerShaderStage(){return this.getParameter(35375)}get maxUniformBufferBindingSize(){return this.getParameter(35376)}get maxStorageBufferBindingSize(){return 0}get minUniformBufferOffsetAlignment(){return this.getParameter(35380)}get minStorageBufferOffsetAlignment(){return 0}get maxVertexBuffers(){return 16}get maxVertexAttributes(){return this.getParameter(34921)}get maxVertexBufferArrayStride(){return 2048}get maxInterStageShaderComponents(){return this.getParameter(35659)}get maxComputeWorkgroupStorageSize(){return 0}get maxComputeInvocationsPerWorkgroup(){return 0}get maxComputeWorkgroupSizeX(){return 0}get maxComputeWorkgroupSizeY(){return 0}get maxComputeWorkgroupSizeZ(){return 0}get maxComputeWorkgroupsPerDimension(){return 0}gl;limits={};constructor(e){super(),this.gl=e}getParameter(e){return void 0===this.limits[e]&&(this.limits[e]=this.gl.getParameter(e)),this.limits[e]}}function Vw(e,t,i){if(function(e){for(const t in e)return!1;return!0}(t))return i(e);const{nocatch:r=!0}=t;let n;if(iw(e),Kb(e,t),r)n=i(e),rw(e);else try{n=i(e)}finally{rw(e)}return n}function jw(e,t,i,r){if(Wp(t))return r(e);const n=e;iw(n.gl);try{return function(e,t){const i=e,{gl:r}=i;if(t.cullMode)switch(t.cullMode){case"none":r.disable(2884);break;case"front":r.enable(2884),r.cullFace(1028);break;case"back":r.enable(2884),r.cullFace(1029)}t.frontFace&&r.frontFace(Zw("frontFace",t.frontFace,{ccw:2305,cw:2304}));t.unclippedDepth&&e.features.has("depth-clip-control")&&r.enable(34383);void 0!==t.depthBias&&(r.enable(32823),r.polygonOffset(t.depthBias,t.depthBiasSlopeScale||0));if(t.provokingVertex&&e.features.has("provoking-vertex-webgl")){const e=i.getExtension("WEBGL_provoking_vertex").WEBGL_provoking_vertex,r=Zw("provokingVertex",t.provokingVertex,{first:36429,last:36430});e?.provokingVertexWEBGL(r)}if((t.polygonMode||t.polygonOffsetLine)&&e.features.has("polygon-mode-webgl")){if(t.polygonMode){const e=i.getExtension("WEBGL_polygon_mode").WEBGL_polygon_mode,r=Zw("polygonMode",t.polygonMode,{fill:6914,line:6913});e?.polygonModeWEBGL(1028,r),e?.polygonModeWEBGL(1029,r)}t.polygonOffsetLine&&r.enable(10754)}e.features.has("shader-clip-cull-distance-webgl")&&(t.clipDistance0&&r.enable(12288),t.clipDistance1&&r.enable(12289),t.clipDistance2&&r.enable(12290),t.clipDistance3&&r.enable(12291),t.clipDistance4&&r.enable(12292),t.clipDistance5&&r.enable(12293),t.clipDistance6&&r.enable(12294),t.clipDistance7&&r.enable(12295));void 0!==t.depthWriteEnabled&&r.depthMask(t.depthWriteEnabled);t.depthCompare&&("always"!==t.depthCompare?r.enable(2929):r.disable(2929),r.depthFunc(Gw("depthCompare",t.depthCompare)));if(t.stencilWriteMask){const e=t.stencilWriteMask;r.stencilMaskSeparate(1028,e),r.stencilMaskSeparate(1029,e)}t.stencilReadMask&&jp.warn("stencilReadMask not supported under WebGL");if(t.stencilCompare){const e=t.stencilReadMask||4294967295,i=Gw("depthCompare",t.stencilCompare);"always"!==t.stencilCompare?r.enable(2960):r.disable(2960),r.stencilFuncSeparate(1028,i,0,e),r.stencilFuncSeparate(1029,i,0,e)}if(t.stencilPassOperation&&t.stencilFailOperation&&t.stencilDepthFailOperation){const e=Hw("stencilPassOperation",t.stencilPassOperation),i=Hw("stencilFailOperation",t.stencilFailOperation),n=Hw("stencilDepthFailOperation",t.stencilDepthFailOperation);r.stencilOpSeparate(1028,i,n,e),r.stencilOpSeparate(1029,i,n,e)}if(t.blendColorOperation||t.blendAlphaOperation){r.enable(3042);const e=Qw("blendColorOperation",t.blendColorOperation||"add"),i=Qw("blendAlphaOperation",t.blendAlphaOperation||"add");r.blendEquationSeparate(e,i);const n=$w("blendColorSrcFactor",t.blendColorSrcFactor||"one"),o=$w("blendColorDstFactor",t.blendColorDstFactor||"zero"),s=$w("blendAlphaSrcFactor",t.blendAlphaSrcFactor||"one"),a=$w("blendAlphaDstFactor",t.blendAlphaDstFactor||"zero");r.blendFuncSeparate(n,o,s,a)}}(e,t),Kb(n.gl,i),r(e)}finally{rw(n.gl)}}function Gw(e,t){return Zw(e,t,{never:512,less:513,equal:514,"less-equal":515,greater:516,"not-equal":517,"greater-equal":518,always:519})}function Hw(e,t){return Zw(e,t,{keep:7680,zero:0,replace:7681,invert:5386,"increment-clamp":7682,"decrement-clamp":7683,"increment-wrap":34055,"decrement-wrap":34056})}function Qw(e,t){return Zw(e,t,{add:32774,subtract:32778,"reverse-subtract":32779,min:32775,max:32776})}function $w(e,t){return Zw(e,t,{one:1,zero:0,"src-color":768,"one-minus-src-color":769,"dst-color":774,"one-minus-dst-color":775,"src-alpha":770,"one-minus-src-alpha":771,"dst-alpha":772,"one-minus-dst-alpha":773,"src-alpha-saturated":776,"constant-color":32769,"one-minus-constant-color":32770,"constant-alpha":32771,"one-minus-constant-alpha":32772})}function Zw(e,t,i){if(!(t in i))throw new Error(function(e,t){return`Illegal parameter ${t} for ${e}`}(e,t));return i[t]}function Ww(e){const t={};return e.addressModeU&&(t[10242]=qw(e.addressModeU)),e.addressModeV&&(t[10243]=qw(e.addressModeV)),e.addressModeW&&(t[32882]=qw(e.addressModeW)),e.magFilter&&(t[10240]=Kw(e.magFilter)),(e.minFilter||e.mipmapFilter)&&(t[10241]=function(e,t){if(!t)return Kw(e);switch(e){case"nearest":return"nearest"===t?9984:9986;case"linear":return"nearest"===t?9985:9987}}(e.minFilter||"linear",e.mipmapFilter)),void 0!==e.lodMinClamp&&(t[33082]=e.lodMinClamp),void 0!==e.lodMaxClamp&&(t[33083]=e.lodMaxClamp),"comparison-sampler"===e.type&&(t[34892]=34894),e.compare&&(t[34893]=Gw("compare",e.compare)),e.maxAnisotropy&&(t[34046]=e.maxAnisotropy),t}function qw(e){switch(e){case"clamp-to-edge":return 33071;case"repeat":return 10497;case"mirror-repeat":return 33648}}function Kw(e){switch(e){case"nearest":return 9728;case"linear":return 9729}}class Xw extends Kp{device;gl;handle;glTarget;glUsage;glIndexType=5123;byteLength;bytesUsed;constructor(e,t={}){super(e,t),this.device=e,this.gl=this.device.gl;const i="object"==typeof t?t.handle:void 0;this.handle=i||this.gl.createBuffer(),e.setSpectorMetadata(this.handle,{...this.props,data:typeof this.props.data}),this.glTarget=function(e){if(e&Kp.INDEX)return 34963;if(e&Kp.VERTEX)return 34962;if(e&Kp.UNIFORM)return 35345;return 34962}(this.props.usage),this.glUsage=function(e){if(e&Kp.INDEX)return 35044;if(e&Kp.VERTEX)return 35044;if(e&Kp.UNIFORM)return 35048;return 35044}(this.props.usage),this.glIndexType="uint32"===this.props.indexType?5125:5123,t.data?this._initWithData(t.data,t.byteOffset,t.byteLength):this._initWithByteLength(t.byteLength||0)}_initWithData(e,t=0,i=e.byteLength+t){const r=this.glTarget;this.gl.bindBuffer(r,this.handle),this.gl.bufferData(r,i,this.glUsage),this.gl.bufferSubData(r,t,e),this.gl.bindBuffer(r,null),this.bytesUsed=i,this.byteLength=i,this._setDebugData(e,t,i),this.trackAllocatedMemory(i)}_initWithByteLength(e){lf(e>=0);let t=e;0===e&&(t=new Float32Array(0));const i=this.glTarget;return this.gl.bindBuffer(i,this.handle),this.gl.bufferData(i,t,this.glUsage),this.gl.bindBuffer(i,null),this.bytesUsed=e,this.byteLength=e,this._setDebugData(null,0,e),this.trackAllocatedMemory(e),this}destroy(){!this.destroyed&&this.handle&&(this.removeStats(),this.trackDeallocatedMemory(),this.gl.deleteBuffer(this.handle),this.destroyed=!0,this.handle=null)}write(e,t=0){const i=36663;this.gl.bindBuffer(i,this.handle),this.gl.bufferSubData(i,t,e),this.gl.bindBuffer(i,null),this._setDebugData(e,t,e.byteLength)}async readAsync(e=0,t){return this.readSyncWebGL(e,t)}readSyncWebGL(e=0,t){t=t??this.byteLength-e;const i=new Uint8Array(t);return this.gl.bindBuffer(36662,this.handle),this.gl.getBufferSubData(36662,e,i,0,t),this.gl.bindBuffer(36662,null),this._setDebugData(i,e,t),i}}class Jw extends Bf{device;handle;parameters;constructor(e,t){super(e,t),this.device=e,this.parameters=Ww(t),this.handle=this.handle||this.device.gl.createSampler(),this._setSamplerParameters(this.parameters)}destroy(){this.handle&&(this.device.gl.deleteSampler(this.handle),this.handle=void 0)}toString(){return`Sampler(${this.id},${JSON.stringify(this.props)})`}_setSamplerParameters(e){for(const[t,i]of Object.entries(e)){const e=Number(t);switch(e){case 33082:case 33083:this.device.gl.samplerParameterf(this.handle,e,i);break;default:this.device.gl.samplerParameteri(this.handle,e,i)}}}}class Yw extends yf{device;gl;handle;texture;constructor(e,t){super(e,{...Af.defaultProps,...t}),this.device=e,this.gl=this.device.gl,this.handle=null,this.texture=t.texture}}const eT={parameters:{},pixelStore:{},pixels:null,border:0,dataFormat:void 0,textureUnit:void 0,target:void 0};class tT extends Af{static FACES=[34069,34070,34071,34072,34073,34074];MAX_ATTRIBUTES;device;gl;handle;sampler=void 0;view=void 0;glFormat=void 0;type=void 0;dataFormat=void 0;mipmaps=void 0;target;textureUnit=void 0;loaded=!1;_video;constructor(e,t){super(e,{...eT,format:"rgba8unorm",...t}),this.device=e,this.gl=this.device.gl,this.handle=this.props.handle||this.gl.createTexture(),this.device.setSpectorMetadata(this.handle,{...this.props,data:typeof this.props.data}),this.glFormat=6408,this.target=function(e){switch(e.dimension){case"2d":return 3553;case"cube":return 34067;case"2d-array":return 35866;case"3d":return 32879;default:throw new Error(e.dimension)}}(this.props),this.loaded=!1,"string"==typeof this.props?.data&&Object.assign(this.props,{data:tm(this.props.data)}),this.initialize(this.props),Object.seal(this)}destroy(){this.handle&&(this.gl.deleteTexture(this.handle),this.removeStats(),this.trackDeallocatedMemory("Texture"),this.destroyed=!0)}toString(){return`Texture(${this.id},${this.width}x${this.height})`}createView(e){return new Yw(this.device,{...e,texture:this})}initialize(e={}){if("cube"===this.props.dimension)return this.initializeCube(e);let t=e.data;if(t instanceof Promise)return t.then(t=>this.initialize(Object.assign({},e,{pixels:t,data:t}))),this;const i="undefined"!=typeof HTMLVideoElement&&t instanceof HTMLVideoElement;if(i&&t.readyStatethis.initialize(e)),this;const{parameters:r={}}=e,{pixels:n=null,pixelStore:o={},textureUnit:s,mipmaps:a=!0}=e;t||(t=n);let{width:l,height:c,dataFormat:u,type:h,compressed:d=!1}=e;const{depth:p=0}=e,f=Fw(e.format);return({width:l,height:c,compressed:d,dataFormat:u,type:h}=this._deduceParameters({format:e.format,type:h,dataFormat:u,compressed:d,data:t,width:l,height:c})),this.width=l,this.height=c,this.glFormat=f,this.type=h,this.dataFormat=u,this.textureUnit=s,Number.isFinite(this.textureUnit)&&(this.gl.activeTexture(33984+this.textureUnit),this.gl.bindTexture(this.target,this.handle)),this.mipmaps=a,this.setImageData({data:t,width:l,height:c,depth:p,format:e.format,type:h,dataFormat:u,parameters:o,compressed:d}),this.setSampler(e.sampler),this._setSamplerParameters(r),this.view=this.createView({...this.props,mipLevelCount:1,arrayLayerCount:1}),a&&this.device.isTextureFormatFilterable(e.format)&&this.generateMipmap(),i&&(this._video={video:t,parameters:r,lastTime:t.readyState>=HTMLVideoElement.HAVE_CURRENT_DATA?t.currentTime:-1}),this}initializeCube(e){const{mipmaps:t=!0,parameters:i={}}=e;return this.setCubeMapImageData(e).then(()=>{this.loaded=!0,t&&this.generateMipmap(e),this.setSampler(e.sampler),this._setSamplerParameters(i)}),this}setSampler(e={}){let t;e instanceof Jw?(this.sampler=e,t=e.props):(this.sampler=new Jw(this.device,e),t=e);const i=Ww(t);return this._setSamplerParameters(i),this}resize(e){const{height:t,width:i,mipmaps:r=!1}=e;return i!==this.width||t!==this.height?this.initialize({width:i,height:t,format:this.format,type:this.type,dataFormat:this.dataFormat,mipmaps:r}):this}update(){if(this._video){const{video:e,parameters:t,lastTime:i}=this._video;if(i===e.currentTime||e.readyState{this.gl.generateMipmap(this.target)}),this.gl.bindTexture(this.target,null),this}setImageData(e){if("3d"===this.props.dimension||"2d-array"===this.props.dimension)return this.setImageData3D(e);this.trackDeallocatedMemory("Texture");const{target:t=this.target,pixels:i=null,level:r=0,glFormat:n=this.glFormat,offset:o=0,parameters:s={}}=e;let{data:a=null,type:l=this.type,width:c=this.width,height:u=this.height,dataFormat:h=this.dataFormat,compressed:d=!1}=e;a||(a=i),({type:l,dataFormat:h,compressed:d,width:c,height:u}=this._deduceParameters({format:this.props.format,type:l,dataFormat:h,compressed:d,data:a,width:c,height:u}));const{gl:p}=this;p.bindTexture(this.target,this.handle);let f=null;if(({data:a,dataType:f}=this._getDataType({data:a,compressed:d})),Vw(this.gl,s,()=>{switch(f){case"null":case"browser-object":p.texImage2D(t,r,n,c,u,0,h,l,a);break;case"typed-array":p.texImage2D(t,r,n,c,u,0,h,l,a,o);break;case"buffer":this.device.gl.bindBuffer(35052,a.handle||a),this.device.gl.texImage2D(t,r,n,c,u,0,h,l,o),this.device.gl.bindBuffer(35052,null);break;case"compressed":for(const[e,i]of a.entries())p.compressedTexImage2D(t,e,i.format,i.width,i.height,0,i.data);break;default:lf(!1,"Unknown image data type")}}),a&&a.byteLength)this.trackAllocatedMemory(a.byteLength,"Texture");else{const e=Dw(this.props.format);this.trackAllocatedMemory(this.width*this.height*e,"Texture")}return this.loaded=!0,this}setSubImageData({target:e=this.target,pixels:t=null,data:i=null,x:r=0,y:n=0,width:o=this.width,height:s=this.height,level:a=0,glFormat:l=this.glFormat,type:c=this.type,dataFormat:u=this.dataFormat,compressed:h=!1,offset:d=0,parameters:p={}}){if(({type:c,dataFormat:u,compressed:h,width:o,height:s}=this._deduceParameters({format:this.props.format,type:c,dataFormat:u,compressed:h,data:i,width:o,height:s})),lf(1===this.depth,"texSubImage not supported for 3D textures"),i||(i=t),i&&i.data){const e=i;i=e.data,o=e.shape[0],s=e.shape[1]}i instanceof Xw&&(i=i.handle),this.gl.bindTexture(this.target,this.handle),Vw(this.gl,p,()=>{h?this.gl.compressedTexSubImage2D(e,a,r,n,o,s,l,i):null===i?this.gl.texSubImage2D(e,a,r,n,o,s,u,c,null):ArrayBuffer.isView(i)?this.gl.texSubImage2D(e,a,r,n,o,s,u,c,i,d):"undefined"!=typeof WebGLBuffer&&i instanceof WebGLBuffer?(this.device.gl.bindBuffer(35052,i),this.device.gl.texSubImage2D(e,a,r,n,o,s,u,c,d),this.device.gl.bindBuffer(35052,null)):this.device.gl.texSubImage2D(e,a,r,n,o,s,u,c,i)}),this.gl.bindTexture(this.target,null)}copyFramebuffer(e={}){return jp.error("Texture.copyFramebuffer({...}) is no logner supported, use copyToTexture(source, target, opts})")(),null}getActiveUnit(){return this.gl.getParameter(34016)-33984}bind(e=this.textureUnit){const{gl:t}=this;return void 0!==e&&(this.textureUnit=e,t.activeTexture(33984+e)),t.bindTexture(this.target,this.handle),e}unbind(e=this.textureUnit){const{gl:t}=this;return void 0!==e&&(this.textureUnit=e,t.activeTexture(33984+e)),t.bindTexture(this.target,null),e}_getDataType({data:e,compressed:t=!1}){return t?{data:e,dataType:"compressed"}:null===e?{data:e,dataType:"null"}:ArrayBuffer.isView(e)?{data:e,dataType:"typed-array"}:e instanceof Xw?{data:e.handle,dataType:"buffer"}:"undefined"!=typeof WebGLBuffer&&e instanceof WebGLBuffer?{data:e,dataType:"buffer"}:{data:e,dataType:"browser-object"}}_deduceParameters(e){const{format:t,data:i}=e;let{width:r,height:n,dataFormat:o,type:s,compressed:a}=e;const l=kw(t);return o=o||l.dataFormat,s=s||l.type,a=a||l.compressed,({width:r,height:n}=this._deduceImageSize(i,r,n)),{dataFormat:o,type:s,compressed:a,width:r,height:n,format:t,data:i}}_deduceImageSize(e,t,i){let r;return r="undefined"!=typeof ImageData&&e instanceof ImageData?{width:e.width,height:e.height}:"undefined"!=typeof HTMLImageElement&&e instanceof HTMLImageElement?{width:e.naturalWidth,height:e.naturalHeight}:"undefined"!=typeof HTMLCanvasElement&&e instanceof HTMLCanvasElement||"undefined"!=typeof ImageBitmap&&e instanceof ImageBitmap?{width:e.width,height:e.height}:"undefined"!=typeof HTMLVideoElement&&e instanceof HTMLVideoElement?{width:e.videoWidth,height:e.videoHeight}:e?{width:t,height:i}:{width:t>=0?t:1,height:i>=0?i:1},lf(r,"Could not deduced texture size"),lf(void 0===t||r.width===t,"Deduced texture width does not match supplied width"),lf(void 0===i||r.height===i,"Deduced texture height does not match supplied height"),r}async setCubeMapImageData(e){const{gl:t}=this,{width:i,height:r,pixels:n,data:o,format:s=6408,type:a=5121}=e,l=n||o,c=await Promise.all(tT.FACES.map(e=>{const t=l[e];return Promise.all(Array.isArray(t)?t:[t])}));this.bind(),tT.FACES.forEach((e,n)=>{c[n].length>1&&!1!==this.props.mipmaps&&jp.warn(`${this.id} has mipmap and multiple LODs.`)(),c[n].forEach((n,o)=>{i&&r?t.texImage2D(e,o,s,i,r,0,s,a,n):t.texImage2D(e,o,s,s,a,n)})}),this.unbind()}setImageDataForFace(e){const{face:t,width:i,height:r,pixels:n,data:o,format:s=6408,type:a=5121}=e,{gl:l}=this,c=n||o;return this.bind(),c instanceof Promise?c.then(i=>this.setImageDataForFace(Object.assign({},e,{face:t,data:i,pixels:i}))):this.width||this.height?l.texImage2D(t,0,s,i,r,0,s,a,c):l.texImage2D(t,0,s,s,a,c),this}setImageData3D(e){const{level:t=0,dataFormat:i,format:r,type:n,width:o,height:s,depth:a=1,offset:l=0,data:c,parameters:u={}}=e;this.trackDeallocatedMemory("Texture"),this.gl.bindTexture(this.target,this.handle);const h=kw(r);if(Vw(this.gl,u,()=>{ArrayBuffer.isView(c)&&this.gl.texImage3D(this.target,t,h.format,o,s,a,0,h.dataFormat,h.type,c),c instanceof Xw&&(this.gl.bindBuffer(35052,c.handle),this.gl.texImage3D(this.target,t,i,o,s,a,0,r,n,l))}),c&&c.byteLength)this.trackAllocatedMemory(c.byteLength,"Texture");else{const e=Dw(this.props.format);this.trackAllocatedMemory(this.width*this.height*this.depth*e,"Texture")}return this.loaded=!0,this}_setSamplerParameters(e){if(!Wp(e)){!function(e){jp.log(1,"texture sampler parameters",e)()}(e),this.gl.bindTexture(this.target,this.handle);for(const[t,i]of Object.entries(e)){const e=Number(t),r=i;switch(e){case 33082:case 33083:this.gl.texParameterf(this.target,e,r);break;default:this.gl.texParameteri(this.target,e,r)}}this.gl.bindTexture(this.target,null)}}}class iT extends Sf{device;gl;handle;get texture(){return this.colorAttachments[0]}constructor(e,t){super(e,t);const i=null===t.handle;if(this.device=e,this.gl=e.gl,this.handle=this.props.handle||i?this.props.handle:this.gl.createFramebuffer(),!i){e.setSpectorMetadata(this.handle,{id:this.props.id,props:this.props}),this.autoCreateAttachmentTextures();const i=this.gl.bindFramebuffer(36160,this.handle);for(let e=0;evoid 0===e?"undefined":e);let i=globalThis.WebGLDebugUtils.glFunctionArgsToString(e,t);return i=`${i.slice(0,100)}${i.length>100?"...":""}`,`gl.${e}(${i})`}function uT(e,t,i,r){r=Array.from(r).map(e=>void 0===e?"undefined":e);const n=`${globalThis.WebGLDebugUtils.glEnumToString(t)} in gl.${i}(${globalThis.WebGLDebugUtils.glFunctionArgsToString(i,r)})`;if(jp.error(n)(),e.throwOnError)throw new Error(n)}function hT(e,t,i){let r="";if(jp.level>=1&&(r=cT(t,i),jp.log(1,r)()),e.break&&e.break.length>0){r=r||cT(t,i);e.break.every(e=>-1!==r.indexOf(e))}for(const n of i)if(void 0===n){if(r=r||cT(t,i),e.throwOnError)throw new Error(`Undefined argument: ${r}`);jp.error(`Undefined argument: ${r}`)()}}function dT(e){const t=e.toLowerCase();return["warning","error","info"].includes(t)?t:"info"}class pT extends Ef{device;handle;constructor(e,t){switch(super(e,t),this.device=e,this.props.stage){case"vertex":this.handle=this.props.handle||this.device.gl.createShader(35633);break;case"fragment":this.handle=this.props.handle||this.device.gl.createShader(35632);break;default:throw new Error(this.props.stage)}this._compile(this.source)}destroy(){this.handle&&(this.removeStats(),this.device.gl.deleteShader(this.handle),this.destroyed=!0)}async getCompilationInfo(){return await this._waitForCompilationComplete(),this.getCompilationInfoSync()}getCompilationInfoSync(){return function(e){const t=e.split(/\r?\n/),i=[];for(const e of t){if(e.length<=1)continue;const t=e.split(":");if(2===t.length){const[e,r]=t;i.push({message:r.trim(),type:dT(e),lineNum:0,linePos:0});continue}const[r,n,o,...s]=t;let a=parseInt(o,10);isNaN(a)&&(a=0);let l=parseInt(n,10);isNaN(l)&&(l=0),i.push({message:s.join(":").trim(),type:dT(r),lineNum:a,linePos:l})}return i}(this.device.gl.getShaderInfoLog(this.handle))}getTranslatedSource(){const e=this.device.getExtension("WEBGL_debug_shaders").WEBGL_debug_shaders;return e?.getTranslatedShaderSource(this.handle)}async _compile(e){e=(e=>e.startsWith("#version ")?e:`#version 100\n${e}`)(e);const{gl:t}=this.device;if(t.shaderSource(this.handle,e),t.compileShader(this.handle),0!==jp.level){if(this.device.features.has("compilation-status-async-webgl"))jp.once(1,"Shader compilation is asynchronous")(),await this._waitForCompilationComplete(),jp.info(2,`Shader ${this.id} - async compilation complete: ${this.compilationStatus}`)(),this._getCompilationStatus(),this.debugShader();else if(this._getCompilationStatus(),this.debugShader(),"error"===this.compilationStatus)throw new Error(`GLSL compilation errors in ${this.props.stage} shader ${this.props.id}`)}else this.compilationStatus="pending"}async _waitForCompilationComplete(){const e=async e=>await new Promise(t=>setTimeout(t,e));if(!this.device.features.has("compilation-status-async-webgl"))return void await e(10);const{gl:t}=this.device;for(;;){if(t.getShaderParameter(this.handle,37297))return;await e(10)}}_getCompilationStatus(){this.compilationStatus=this.device.gl.getShaderParameter(this.handle,35713)?"success":"error"}}const fT=6144,mT=[1,2,4,8];class gT extends Mf{device;glParameters;constructor(e,t){super(e,t),this.device=e,iw(this.device.gl),this.setParameters(this.props.parameters),this.clear()}end(){rw(this.device.gl)}pushDebugGroup(e){}popDebugGroup(){}insertDebugMarker(e){}setParameters(e={}){const t={...this.glParameters};this.props.framebuffer&&(t.framebuffer=this.props.framebuffer),this.props.depthReadOnly&&(t.depthMask=!this.props.depthReadOnly),t.stencilMask=this.props.stencilReadOnly?0:1,t[35977]=this.props.discard,e.viewport&&(e.viewport.length>=6?(t.viewport=e.viewport.slice(0,4),t.depthRange=[e.viewport[4],e.viewport[5]]):t.viewport=e.viewport),e.scissorRect&&(t.scissorTest=!0,t.scissor=e.scissorRect),e.blendConstant&&(t.blendColor=e.blendConstant),e.stencilReference&&(console.warn("RenderPassParameters.stencilReference not yet implemented in WebGL"),e[2967]=e.stencilReference),e.colorMask&&(t.colorMask=mT.map(t=>Boolean(t&e.colorMask))),this.glParameters=t,Kb(this.device.gl,t)}beginOcclusionQuery(e){const t=this.props.occlusionQuerySet;t?.beginOcclusionQuery()}endOcclusionQuery(){const e=this.props.occlusionQuerySet;e?.endOcclusionQuery()}clear(){const e={...this.glParameters};let t=0;!1!==this.props.clearColor&&(t|=16384,e.clearColor=this.props.clearColor),!1!==this.props.clearDepth&&(t|=256,e.clearDepth=this.props.clearDepth),!1!==this.props.clearStencil&&(t|=1024,e.clearStencil=this.props.clearStencil),0!==t&&Vw(this.device.gl,e,()=>{this.device.gl.clear(t)})}clearColorBuffer(e=0,t=[0,0,0,0]){Vw(this.device.gl,{framebuffer:this.props.framebuffer},()=>{switch(t.constructor){case Int32Array:this.device.gl.clearBufferiv(fT,e,t);break;case Uint32Array:this.device.gl.clearBufferuiv(fT,e,t);break;case Float32Array:default:this.device.gl.clearBufferfv(fT,e,t)}})}}function _T(e,t){const{clamped:i=!0}=t||{};switch(e){case 5126:return Float32Array;case 5123:case 33635:case 32819:case 32820:return Uint16Array;case 5125:return Uint32Array;case 5121:return i?Uint8ClampedArray:Uint8Array;case 5120:return Int8Array;case 5122:return Int16Array;case 5124:return Int32Array;default:throw new Error("Failed to deduce typed array type from GL constant")}}const AT={offset:0,stride:0,type:5126,size:1,divisor:0,normalized:!1,integer:!1},yT={deprecatedProps:{instanced:"divisor",isInstanced:"divisor"}};class vT{offset;stride;type;size;divisor;normalized;integer;buffer;index;static getBytesPerElement(e){return _T(e.type||5126).BYTES_PER_ELEMENT}static getBytesPerVertex(e){lf(e.size);return _T(e.type||5126).BYTES_PER_ELEMENT*e.size}static resolve(...e){return new vT(...[AT,...e])}constructor(...e){e.forEach(e=>this._assign(e)),Object.freeze(this)}toString(){return JSON.stringify(this)}get BYTES_PER_ELEMENT(){return vT.getBytesPerElement(this)}get BYTES_PER_VERTEX(){return vT.getBytesPerVertex(this)}_assign(e={}){return void 0!==(e=function(e,t,i){const{removedProps:r={},deprecatedProps:n={},replacedProps:o={}}=i;for(const i in r)if(i in t){const t=r[i]?`${e}.${r[i]}`:"N/A";jp.removed(`${e}.${i}`,t)()}for(const i in n)if(i in t){const t=n[i];jp.deprecated(`${e}.${i}`,`${e}.${t}`)()}let s=null;for(const[i,r]of Object.entries(o))i in t&&(jp.deprecated(`${e}.${i}`,`${e}.${r}`)(),s=s||Object.assign({},t),s[r]=t[i],delete s[i]);return s||t}("Accessor",e,yT)).type&&(this.type=e.type,5124!==e.type&&5125!==e.type||(this.integer=!0)),void 0!==e.size&&(this.size=e.size),void 0!==e.offset&&(this.offset=e.offset),void 0!==e.stride&&(this.stride=e.stride),void 0!==e.normalize&&(this.normalized=e.normalize),void 0!==e.normalized&&(this.normalized=e.normalized),void 0!==e.integer&&(this.integer=e.integer),void 0!==e.divisor&&(this.divisor=e.divisor),void 0!==e.buffer&&(this.buffer=e.buffer),void 0!==e.index&&("boolean"==typeof e.index?this.index=e.index?1:0:this.index=e.index),void 0!==e.instanced&&(this.divisor=e.instanced?1:0),void 0!==e.isInstanced&&(this.divisor=e.isInstanced?1:0),void 0===this.offset&&delete this.offset,void 0===this.stride&&delete this.stride,void 0===this.type&&delete this.type,void 0===this.size&&delete this.size,void 0===this.divisor&&delete this.divisor,void 0===this.normalized&&delete this.normalized,void 0===this.integer&&delete this.integer,void 0===this.buffer&&delete this.buffer,void 0===this.index&&delete this.index,this}}function xT(e){return bT.includes(e)}const bT=[35678,35680,35679,35682,36289,36292,36293,36298,36299,36300,36303,36306,36307,36308,36311],wT={5126:[5126,1,"float","f32","float32"],35664:[5126,2,"vec2","vec2","float32x2"],35665:[5126,3,"vec3","vec3","float32x3"],35666:[5126,4,"vec4","vec4","float32x4"],5124:[5124,1,"int","i32","sint32"],35667:[5124,2,"ivec2","vec2","sint32x2"],35668:[5124,3,"ivec3","vec3","sint32x3"],35669:[5124,4,"ivec4","vec4","sint32x4"],5125:[5125,1,"uint","u32","uint32"],36294:[5125,2,"uvec2","vec2","uint32x2"],36295:[5125,3,"uvec3","vec3","uint32x3"],36296:[5125,4,"uvec4","vec4","uint32x4"],35670:[5126,1,"bool","f32","float32"],35671:[5126,2,"bvec2","vec2","float32x2"],35672:[5126,3,"bvec3","vec3","float32x3"],35673:[5126,4,"bvec4","vec4","float32x4"],35674:[5126,8,"mat2","mat2x2"],35685:[5126,8,"mat2x3","mat2x3"],35686:[5126,8,"mat2x4","mat2x4"],35687:[5126,12,"mat3x2","mat3x2"],35675:[5126,12,"mat3","mat3x3"],35688:[5126,12,"mat3x4","mat3x4"],35689:[5126,16,"mat4x2","mat4x2"],35690:[5126,16,"mat4x3","mat4x3"],35676:[5126,16,"mat4","mat4x4"]};function TT(e){const t=wT[e];if(!t)throw new Error("uniform");const[i,r,,n]=t;return{format:n,components:r,glType:i}}function ET(e){const t=wT[e];if(!t)throw new Error("attribute");const[,i,,r,n]=t;return{attributeType:r,vertexFormat:n,components:i}}function CT(e,t){const i={attributes:[],bindings:[]};i.attributes=function(e,t){const i=[],r=e.getProgramParameter(t,35721);for(let n=0;n=0){const{attributeType:e}=ET(s),t=/instance/i.test(o)?"instance":"vertex";i.push({name:o,location:a,stepMode:t,type:e})}}return i.sort((e,t)=>e.location-t.location),i}(e,t);const r=function(e,t){const i=(i,r)=>e.getActiveUniformBlockParameter(t,i,r),r=[],n=e.getProgramParameter(t,35382);for(let o=0;oe.location-t.location),r}(e,t);for(const e of r){const t=e.uniforms.map(e=>({name:e.name,format:e.format,byteOffset:e.byteOffset,byteStride:e.byteStride,arrayLength:e.arrayLength}));i.bindings.push({type:"uniform",name:e.name,location:e.location,visibility:(e.vertex?1:0)&(e.fragment?2:0),minBindingSize:e.byteLength,uniforms:t})}const n=function(e,t){const i=[],r=e.getProgramParameter(t,35718);for(let n=0;n1)for(let r=0;re.location-t.location),i}(e,t);return s?.length&&(i.varyings=s),i}const BT={35678:["2d","float"],35680:["cube","float"],35679:["3d","float"],35682:["3d","depth"],36289:["2d-array","float"],36292:["2d-array","depth"],36293:["cube","float"],36298:["2d","sint"],36299:["3d","sint"],36300:["cube","sint"],36303:["2d-array","uint"],36306:["2d","uint"],36307:["3d","uint"],36308:["cube","uint"],36311:["2d-array","uint"]};function ST(e){const t=BT[e];if(!t)throw new Error("sampler");const[i,r]=t;return{viewDimension:i,sampleType:r}}function IT(e){if("]"!==e[e.length-1])return{name:e,length:1,isArray:!1};const t=/([^[]*)(\[[0-9]+\])?/.exec(e);if(!t||t.length<2)throw new Error(`Failed to parse GLSL uniform name ${e}`);return{name:t[1],length:t[2]?1:0,isArray:Boolean(t[2])}}function MT(e,t,i,r){const n=e;let o=r;!0===o&&(o=1),!1===o&&(o=0);const s="number"==typeof o?[o]:o;switch(i){case 35678:case 35680:case 35679:case 35682:case 36289:case 36292:case 36293:case 36298:case 36299:case 36300:case 36303:case 36306:case 36307:case 36308:case 36311:if("number"!=typeof r)throw new Error("samplers must be set to integers");return e.uniform1i(t,r);case 5126:return e.uniform1fv(t,s);case 35664:return e.uniform2fv(t,s);case 35665:return e.uniform3fv(t,s);case 35666:return e.uniform4fv(t,s);case 5124:case 35670:return e.uniform1iv(t,s);case 35667:case 35671:return e.uniform2iv(t,s);case 35668:case 35672:return e.uniform3iv(t,s);case 35669:case 35673:return e.uniform4iv(t,s);case 5125:return n.uniform1uiv(t,s,1);case 36294:return n.uniform2uiv(t,s,2);case 36295:return n.uniform3uiv(t,s,3);case 36296:return n.uniform4uiv(t,s,4);case 35674:return e.uniformMatrix2fv(t,!1,s);case 35675:return e.uniformMatrix3fv(t,!1,s);case 35676:return e.uniformMatrix4fv(t,!1,s);case 35685:return n.uniformMatrix2x3fv(t,!1,s);case 35686:return n.uniformMatrix2x4fv(t,!1,s);case 35687:return n.uniformMatrix3x2fv(t,!1,s);case 35688:return n.uniformMatrix3x4fv(t,!1,s);case 35689:return n.uniformMatrix4x2fv(t,!1,s);case 35690:return n.uniformMatrix4x3fv(t,!1,s)}throw new Error("Illegal uniform")}class PT extends If{device;handle;vs;fs;introspectedLayout;uniforms={};bindings={};varyings=null;_uniformCount=0;_uniformSetters={};constructor(e,t){super(e,t),this.device=e,this.handle=this.props.handle||this.device.gl.createProgram(),this.device.setSpectorMetadata(this.handle,{id:this.props.id}),this.vs=t.vs,this.fs=t.fs;const{varyings:i,bufferMode:r=35981}=t;switch(i&&i.length>0&&(this.varyings=i,this.device.gl.transformFeedbackVaryings(this.handle,i,r)),this._linkShaders(),jp.time(1,`RenderPipeline ${this.id} - shaderLayout introspection`)(),this.introspectedLayout=CT(this.device.gl,this.handle),jp.timeEnd(1,`RenderPipeline ${this.id} - shaderLayout introspection`)(),this.shaderLayout=function(e,t){const i={...e,attributes:e.attributes.map(e=>({...e}))};for(const e of t?.attributes||[]){const t=i.attributes.find(t=>t.name===e.name);t?(t.type=e.type||t.type,t.stepMode=e.stepMode||t.stepMode):jp.warn(`shader layout attribute ${e.name} not present in shader`)}return i}(this.introspectedLayout,t.shaderLayout),this.props.topology){case"triangle-fan-webgl":case"line-loop-webgl":jp.warn(`Primitive topology ${this.props.topology} is deprecated and will be removed in v9.1`)}}destroy(){this.handle&&(this.device.gl.deleteProgram(this.handle),this.destroyed=!0)}setBindings(e,t){for(const[i,r]of Object.entries(e)){const e=this.shaderLayout.bindings.find(e=>e.name===i)||this.shaderLayout.bindings.find(e=>e.name===`${i}Uniforms`);if(!e){const e=this.shaderLayout.bindings.map(e=>`"${e.name}"`).join(", ");t?.disableWarnings||jp.warn(`Unknown binding "${i}" in render pipeline "${this.id}", expected one of ${e}`)();continue}switch(r||jp.warn(`Unsetting binding "${i}" in render pipeline "${this.id}"`)(),e.type){case"uniform":if(!(r instanceof Xw||r.buffer instanceof Xw))throw new Error("buffer value");break;case"texture":if(!(r instanceof Yw||r instanceof tT||r instanceof iT))throw new Error("texture value");break;case"sampler":jp.warn(`Ignoring sampler ${i}`)();break;default:throw new Error(e.type)}this.bindings[i]=r}}draw(e){const{renderPass:t,parameters:i=this.props.parameters,topology:r=this.props.topology,vertexArray:n,vertexCount:o,instanceCount:s,isInstanced:a=!1,firstVertex:l=0,transformFeedback:c}=e,u=function(e){switch(e){case"point-list":return 0;case"line-list":return 1;case"line-strip":return 3;case"line-loop-webgl":return 2;case"triangle-list":return 4;case"triangle-strip":return 5;case"triangle-fan-webgl":return 6;default:throw new Error(e)}}(r),h=Boolean(n.indexBuffer),d=n.indexBuffer?.glIndexType;if("success"!==this.linkStatus)return jp.info(2,`RenderPipeline:${this.id}.draw() aborted - waiting for shader linking`)(),!1;if(!this._areTexturesRenderable()||0===o)return jp.info(2,`RenderPipeline:${this.id}.draw() aborted - textures not yet loaded`)(),!1;if(0===o)return jp.info(2,`RenderPipeline:${this.id}.draw() aborted - no vertices to draw`)(),!0;this.device.gl.useProgram(this.handle),n.bindBeforeRender(t),c&&c.begin(this.props.topology),this._applyBindings(),this._applyUniforms();const p=t;return jw(this.device,i,p.glParameters,()=>{h&&a?this.device.gl.drawElementsInstanced(u,o||0,d,l,s||0):h?this.device.gl.drawElements(u,o||0,d,l):a?this.device.gl.drawArraysInstanced(u,l,o||0,s||0):this.device.gl.drawArrays(u,l,o||0),c&&c.end()}),n.unbindAfterRender(t),!0}setUniformsWebGL(e){const{bindings:t}=em(e);Object.keys(t).forEach(e=>{jp.warn(`Unsupported value "${JSON.stringify(t[e])}" used in setUniforms() for key ${e}. Use setBindings() instead?`)()}),Object.assign(this.uniforms,e)}async _linkShaders(){const{gl:e}=this.device;if(e.attachShader(this.handle,this.vs.handle),e.attachShader(this.handle,this.fs.handle),jp.time(4,`linkProgram for ${this.id}`)(),e.linkProgram(this.handle),jp.timeEnd(4,`linkProgram for ${this.id}`)(),jp.level,!this.device.features.has("compilation-status-async-webgl")){const e=this._getLinkStatus();return void this._reportLinkStatus(e)}jp.once(1,"RenderPipeline linking is asynchronous")(),await this._waitForLinkComplete(),jp.info(2,`RenderPipeline ${this.id} - async linking complete: ${this.linkStatus}`)();const t=this._getLinkStatus();this._reportLinkStatus(t)}_reportLinkStatus(e){if("success"!==e){if("error"===this.vs.compilationStatus)throw this.vs.debugShader(),new Error(`Error during compilation of shader ${this.vs.id}`);if("error"===this.fs?.compilationStatus)throw this.fs.debugShader(),new Error(`Error during compilation of shader ${this.fs.id}`);throw new Error(`Error during ${e}: ${this.device.gl.getProgramInfoLog(this.handle)}`)}}_getLinkStatus(){const{gl:e}=this.device;if(!e.getProgramParameter(this.handle,35714))return this.linkStatus="error","linking";e.validateProgram(this.handle);return e.getProgramParameter(this.handle,35715)?(this.linkStatus="success","success"):(this.linkStatus="error","validation")}async _waitForLinkComplete(){const e=async e=>await new Promise(t=>setTimeout(t,e));if(!this.device.features.has("compilation-status-async-webgl"))return void await e(10);const{gl:t}=this.device;for(;;){if(t.getProgramParameter(this.handle,37297))return;await e(10)}}_areTexturesRenderable(){let e=!0;for(const[,t]of Object.entries(this.bindings))t instanceof tT&&(t.update(),e=e&&t.loaded);return e}_applyBindings(){if("success"!==this.linkStatus)return;const{gl:e}=this.device;e.useProgram(this.handle);let t=0,i=0;for(const r of this.shaderLayout.bindings){const n=this.bindings[r.name]||this.bindings[r.name.replace(/Uniforms$/,"")];if(!n)throw new Error(`No value for binding ${r.name} in ${this.id}`);switch(r.type){case"uniform":const{name:o}=r,s=e.getUniformBlockIndex(this.handle,o);if(4294967295===s)throw new Error(`Invalid uniform block name ${o}`);e.uniformBlockBinding(this.handle,i,s),n instanceof Xw?e.bindBufferBase(35345,i,n.handle):e.bindBufferRange(35345,i,n.buffer.handle,n.offset||0,n.size||n.buffer.byteLength-n.offset),i+=1;break;case"texture":if(!(n instanceof Yw||n instanceof tT||n instanceof iT))throw new Error("texture");let a;if(n instanceof Yw)a=n.texture;else if(n instanceof tT)a=n;else{if(!(n instanceof iT&&n.colorAttachments[0]instanceof Yw))throw new Error("No texture");jp.warn("Passing framebuffer in texture binding may be deprecated. Use fbo.colorAttachments[0] instead")(),a=n.colorAttachments[0].texture}e.activeTexture(33984+t),e.bindTexture(a.target,a.handle),t+=1;break;case"sampler":break;case"storage":case"read-only-storage":throw new Error(`binding type '${r.type}' not supported in WebGL`)}}}_applyUniforms(){for(const e of this.shaderLayout.uniforms||[]){const{name:t,location:i,type:r,textureUnit:n}=e,o=this.uniforms[t]??n;void 0!==o&&MT(this.device.gl,i,r,o)}}}class RT extends Lf{device;commands=[];constructor(e){super(e,{}),this.device=e}submitCommands(e=this.commands){for(const t of e)switch(t.name){case"copy-buffer-to-buffer":LT(this.device,t.options);break;case"copy-buffer-to-texture":FT(this.device,t.options);break;case"copy-texture-to-buffer":kT(this.device,t.options);break;case"copy-texture-to-texture":DT(this.device,t.options)}}}function LT(e,t){const i=t.source,r=t.destination;e.gl.bindBuffer(36662,i.handle),e.gl.bindBuffer(36663,r.handle),e.gl.copyBufferSubData(36662,36663,t.sourceOffset??0,t.destinationOffset??0,t.size),e.gl.bindBuffer(36662,null),e.gl.bindBuffer(36663,null)}function FT(e,t){throw new Error("Not implemented")}function kT(e,t){const{source:i,mipLevel:r=0,aspect:n="all",width:o=t.source.width,height:s=t.source.height,depthOrArrayLayers:a=0,origin:l=[0,0],destination:c,byteOffset:u=0,bytesPerRow:h,rowsPerImage:d}=t;if("all"!==n)throw new Error("not supported");if(0!==r||0!==a||h||d)throw new Error("not implemented");const{framebuffer:p,destroyFramebuffer:f}=OT(i);let m;try{const t=c,i=o||p.width,r=s||p.height,n=kw(p.texture.props.format),a=n.dataFormat,h=n.type;e.gl.bindBuffer(35051,t.handle),m=e.gl.bindFramebuffer(36160,p.handle),e.gl.readPixels(l[0],l[1],i,r,a,h,u)}finally{e.gl.bindBuffer(35051,null),void 0!==m&&e.gl.bindFramebuffer(36160,m),f&&p.destroy()}}function DT(e,t){const{source:i,destinationMipLevel:r=0,origin:n=[0,0],destinationOrigin:o=[0,0],destination:s}=t;let{width:a=t.destination.width,height:l=t.destination.height}=t;const{framebuffer:c,destroyFramebuffer:u}=OT(i),[h,d]=n,[p,f,m]=o,g=e.gl.bindFramebuffer(36160,c.handle);let _,A=null;if(!(s instanceof tT))throw new Error("invalid destination");switch(A=s,a=Number.isFinite(a)?a:A.width,l=Number.isFinite(l)?l:A.height,A.bind(0),_=A.target,_){case 3553:case 34067:e.gl.copyTexSubImage2D(_,r,p,f,h,d,a,l);break;case 35866:case 32879:e.gl.copyTexSubImage3D(_,r,p,f,m,h,d,a,l)}A&&A.unbind(),e.gl.bindFramebuffer(36160,g),u&&c.destroy()}function OT(e){if(e instanceof Af){const{width:t,height:i,id:r}=e;return{framebuffer:e.device.createFramebuffer({id:`framebuffer-for-${r}`,width:t,height:i,colorAttachments:[e]}),destroyFramebuffer:!0}}return{framebuffer:e,destroyFramebuffer:!1}}class zT extends Rf{device;commandBuffer;constructor(e,t){super(e,t),this.device=e,this.commandBuffer=new RT(e)}destroy(){}finish(){this.commandBuffer.submitCommands()}copyBufferToBuffer(e){this.commandBuffer.commands.push({name:"copy-buffer-to-buffer",options:e})}copyBufferToTexture(e){this.commandBuffer.commands.push({name:"copy-buffer-to-texture",options:e})}copyTextureToBuffer(e){this.commandBuffer.commands.push({name:"copy-texture-to-buffer",options:e})}copyTextureToTexture(e){this.commandBuffer.commands.push({name:"copy-texture-to-texture",options:e})}pushDebugGroup(e){}popDebugGroup(){}insertDebugMarker(e){}resolveQuerySet(e,t,i){}}class UT extends Nf{get[Symbol.toStringTag](){return"VertexArray"}device;handle;buffer=null;bufferValue=null;static isConstantAttributeZeroSupported(e){return"Chrome"==(t||Pu()?Mu(t)?"Electron":(t||Iu.userAgent||"").indexOf("Edge")>-1?"Edge":globalThis.chrome?"Chrome":globalThis.safari?"Safari":globalThis.mozInnerScreenX?"Firefox":"Unknown":"Node");var t}constructor(e,t){super(e,t),this.device=e,this.handle=this.device.gl.createVertexArray()}destroy(){super.destroy(),this.buffer&&this.buffer?.destroy(),this.handle&&(this.device.gl.deleteVertexArray(this.handle),this.handle=void 0)}setIndexBuffer(e){const t=e;if(t&&34963!==t.glTarget)throw new Error("Use .setBuffer()");this.device.gl.bindVertexArray(this.handle),this.device.gl.bindBuffer(34963,t?t.handle:null),this.indexBuffer=t,this.device.gl.bindVertexArray(null)}setBuffer(e,t){const i=t;if(34963===i.glTarget)throw new Error("Use .setIndexBuffer()");const{size:r,type:n,stride:o,offset:s,normalized:a,integer:l,divisor:c}=this._getAccessor(e);this.device.gl.bindVertexArray(this.handle),this.device.gl.bindBuffer(34962,i.handle),l?this.device.gl.vertexAttribIPointer(e,r,n,o,s):this.device.gl.vertexAttribPointer(e,r,n,a,o,s),this.device.gl.bindBuffer(34962,null),this.device.gl.enableVertexAttribArray(e),this.device.gl.vertexAttribDivisor(e,c||0),this.attributes[e]=i,this.device.gl.bindVertexArray(null)}setConstantWebGL(e,t){this._enable(e,!1),this.attributes[e]=t}bindBeforeRender(){this.device.gl.bindVertexArray(this.handle),this._applyConstantAttributes()}unbindAfterRender(){this.device.gl.bindVertexArray(null)}_applyConstantAttributes(){for(let e=0;e{for(const t in e)this.setBuffer(t,e[t])})}setBuffer(e,t){const i=this._getVaryingIndex(e),{buffer:r,byteLength:n,byteOffset:o}=this._getBufferRange(t);if(i<0)return this.unusedBuffers[e]=r,void jp.warn(`${this.id} unusedBuffers varying buffer ${e}`)();this.buffers[i]={buffer:r,byteLength:n,byteOffset:o},this.bindOnUse||this._bindBuffer(i,r,o,n)}getBuffer(e){if(VT(e))return this.buffers[e]||null;const t=this._getVaryingIndex(e);return t>=0?this.buffers[t]:null}bind(e=this.handle){if("function"!=typeof e)return this.gl.bindTransformFeedback(36386,e),this;let t;return this._bound?t=e():(this.gl.bindTransformFeedback(36386,this.handle),this._bound=!0,t=e(),this._bound=!1,this.gl.bindTransformFeedback(36386,null)),t}unbind(){this.bind(null)}_getBufferRange(e){if(e instanceof Xw)return{buffer:e,byteOffset:0,byteLength:e.byteLength};const{buffer:t,byteOffset:i=0,byteLength:r=e.buffer.byteLength}=e;return{buffer:t,byteOffset:i,byteLength:r}}_getVaryingIndex(e){if(VT(e))return Number(e);for(const t of this.layout.varyings)if(e===t.name)return t.location;return-1}_bindBuffers(){for(const e in this.buffers){const{buffer:t,byteLength:i,byteOffset:r}=this._getBufferRange(this.buffers[e]);this._bindBuffer(Number(e),t,r,i)}}_unbindBuffers(){for(const e in this.buffers)this.gl.bindBufferBase(35982,Number(e),null)}_bindBuffer(e,t,i=0,r){const n=t&&t.handle;n&&void 0!==r?this.gl.bindBufferRange(35982,e,n,i,r):this.gl.bindBufferBase(35982,e,n)}}function VT(e){return"number"==typeof e?Number.isInteger(e):/^\d+$/.test(e)}class jT extends jf{device;handle;target=null;_queryPending=!1;_pollingPromise=null;get[Symbol.toStringTag](){return"Query"}constructor(e,t){if(super(e,t),this.device=e,t.count>1)throw new Error("WebGL QuerySet can only have one value");this.handle=this.device.gl.createQuery(),Object.seal(this)}destroy(){this.device.gl.deleteQuery(this.handle)}beginTimestampQuery(){return this._begin(35007)}endTimestampQuery(){this._end()}beginOcclusionQuery(e){return this._begin(e?.conservative?36202:35887)}endOcclusionQuery(){this._end()}beginTransformFeedbackQuery(){return this._begin(35976)}endTransformFeedbackQuery(){this._end()}async resolveQuery(){return[await this.pollQuery()]}_begin(e){this._queryPending||(this.target=e,this.device.gl.beginQuery(this.target,this.handle))}_end(){this._queryPending||this.target&&(this.device.gl.endQuery(this.target),this.target=null,this._queryPending=!0)}isResultAvailable(){if(!this._queryPending)return!1;const e=this.device.gl.getQueryParameter(this.handle,34919);return e&&(this._queryPending=!1),e}isTimerDisjoint(){return this.device.gl.getParameter(36795)}getResult(){return this.device.gl.getQueryParameter(this.handle,34918)}getTimerMilliseconds(){return this.getResult()/1e6}pollQuery(e=Number.POSITIVE_INFINITY){if(this._pollingPromise)return this._pollingPromise;let t=0;return this._pollingPromise=new Promise((i,r)=>{const n=()=>{this.isResultAvailable()?(i(this.getResult()),this._pollingPromise=null):t++>e?(r("Timed out"),this._pollingPromise=null):requestAnimationFrame(n)};requestAnimationFrame(n)}),this._pollingPromise}}function GT(e){switch(e){case 6406:case 33326:case 6403:return 1;case 33328:case 33319:return 2;case 6407:case 34837:return 3;case 6408:case 34836:return 4;default:return lf(!1),0}}function HT(e,t){const{sourceX:i=0,sourceY:r=0,sourceFormat:n=6408,sourceAttachment:o=36064}=t||{};let{target:s=null,sourceWidth:a,sourceHeight:l,sourceType:c}=t||{};const{framebuffer:u,deleteFramebuffer:h}=$T(e);lf(u);const{gl:d,handle:p}=u;a=a||u.width,l=l||u.height;const f=o-36064;c=c||u.colorAttachments[f]?.texture?.type||5121,s=function(e,t,i,r,n){if(e)return e;t=t||5121;const o=_T(t,{clamped:!1}),s=GT(i);return new o(r*n*s)}(s,c,n,a,l),c=c||function(e){switch(ArrayBuffer.isView(e)?e.constructor:e){case Float32Array:return 5126;case Uint16Array:return 5123;case Uint32Array:return 5125;case Uint8Array:case Uint8ClampedArray:return 5121;case Int8Array:return 5120;case Int16Array:return 5122;case Int32Array:return 5124;default:throw new Error("Failed to deduce GL constant from typed array")}}(s);const m=d.bindFramebuffer(36160,p);return d.readPixels(i,r,a,l,n,c,s),d.bindFramebuffer(36160,m||null),h&&u.destroy(),s}function QT(e,t){const{target:i,sourceX:r=0,sourceY:n=0,sourceFormat:o=6408,targetByteOffset:s=0}=t||{};let{sourceWidth:a,sourceHeight:l,sourceType:c}=t||{};const{framebuffer:u,deleteFramebuffer:h}=$T(e);lf(u),a=a||u.width,l=l||u.height;const d=u;c=c||5121;let p=i;if(!p){const e=GT(o),t=function(e){switch(e){case 5121:return 1;case 33635:case 32819:case 32820:return 2;case 5126:return 4;default:return lf(!1),0}}(c),i=s+a*l*e*t;p=d.device.createBuffer({byteLength:i})}const f=e.device.createCommandEncoder();return f.copyTextureToBuffer({source:e,width:a,height:l,origin:[r,n],destination:p,byteOffset:s}),f.destroy(),h&&u.destroy(),p}function $T(e){return e instanceof Sf?{framebuffer:e,deleteFramebuffer:!1}:{framebuffer:ZT(e),deleteFramebuffer:!0}}function ZT(e,t){const{device:i,width:r,height:n,id:o}=e;return i.createFramebuffer({...t,id:`framebuffer-for-${o}`,width:r,height:n,colorAttachments:[e]})}class WT extends af{static type="webgl";type="webgl";handle;features;limits;info;canvasContext;lost;_resolveContextLost;static isSupported(){return"undefined"!=typeof WebGL2RenderingContext}static attach(e){if(e instanceof WT)return e;if(e?.device instanceof af)return e.device;if(!function(e){if("undefined"!=typeof WebGL2RenderingContext&&e instanceof WebGL2RenderingContext)return!0;return Boolean(e&&Number.isFinite(e._version))}(e))throw new Error("Invalid WebGL2RenderingContext");return new WT({gl:e})}static async create(e={}){jp.groupCollapsed(1,"WebGLDevice created")();const t=[];e.debug&&t.push(async function(){Pu()&&!globalThis.WebGLDebugUtils&&(globalThis.global=globalThis.global||globalThis,globalThis.global.module={},await im("https://unpkg.com/webgl-debug@2.0.1/index.js"))}()),e.spector&&t.push(async function(){if(!globalThis.SPECTOR)try{await im("https://cdn.jsdelivr.net/npm/spectorjs@0.9.30/dist/spector.bundle.js")}catch(e){jp.warn(String(e))}}()),"string"==typeof e.canvas&&t.push(mf.pageLoaded);const i=await Promise.allSettled(t);for(const e of i)"rejected"===e.status&&jp.error(`Failed to initialize debug libraries ${e.reason}`)();if(jp.probe(2,"DOM is loaded")(),e.gl?.device)return jp.warn("reattaching existing device")(),WT.attach(e.gl);const r=new WT(e),n=`Created ${r.type}${r.debug?" debug":""} context: ${r.info.vendor}, ${r.info.renderer} for canvas: ${r.canvasContext.id}`;return jp.probe(1,n)(),jp.table(1,r.info)(),jp.groupEnd(1)(),r}constructor(e){super({...e,id:e.id||Zp("webgl-device")});const t=e.gl?.device;if(t)throw new Error(`WebGL context already attached to device ${t.id}`);const i=e.gl?.canvas||e.canvas,r=!e.gl;this.canvasContext=new rT(this,{...e,autoResize:r,canvas:i}),this.lost=new Promise(e=>{this._resolveContextLost=e});let n=e.gl||null;if(n||=function(e,t){t={...sw,...t};let i=null;const r=e=>i=e.statusMessage||i;e.addEventListener("webglcontextcreationerror",r,!1);let n=null;if(n||=e.getContext("webgl2",t),e.removeEventListener("webglcontextcreationerror",r,!1),!n)throw new Error(`Failed to create WebGL context: ${i||"Unknown error"}`);if(t.onContextLost){const{onContextLost:i}=t;e.addEventListener("webglcontextlost",e=>i(e),!1)}if(t.onContextRestored){const{onContextRestored:i}=t;e.addEventListener("webglcontextrestored",e=>i(e),!1)}return n}(this.canvasContext.canvas,{...e,onContextLost:e=>this._resolveContextLost?.({reason:"destroyed",message:"Entered sleep mode, or too many apps or browser tabs are using the GPU."})}),!n)throw new Error("WebGL context creation failed");this.handle=n,this.gl=n,this.gl.device=this,this.gl._version=2,e.spector&&(this.spectorJS=function(e){if(e={...nT,...e},!e?.spector)return null;if(!oT&&globalThis.SPECTOR&&(jp.probe(1,"SPECTOR found and initialized")(),oT=new globalThis.SPECTOR.Spector,globalThis.luma&&(globalThis.luma.spector=oT)),!oT)return null;if(sT||(sT=!0,oT.spyCanvases(),oT?.onCaptureStarted.add(e=>jp.info("Spector capture started:",e)()),oT?.onCapture.add(e=>{jp.info("Spector capture complete:",e)(),oT?.getResultUI(),oT?.resultView.display(),oT?.resultView.addCapture(e)})),e?.canvas){if("string"==typeof e.spector&&e.spector!==e.canvas.id)return oT;oT?.startCapture(e?.canvas,500),new Promise(e=>setTimeout(e,2e3)).then(e=>{jp.info("Spector capture stopped after 2 seconds")(),oT?.stopCapture()})}return oT}({...this.props,canvas:this.handle.canvas})),this.info=lw(this.gl,this._extensions),this.limits=new Nw(this.gl),this.features=new Uw(this.gl,this._extensions,this.props.disabledFeatures),this.props.initalizeFeatures&&this.features.initializeFeatures(),r&&this.canvasContext.resize();const{enable:o=!0,copyState:s=!1}=e;tw(this.gl,{enable:o,copyState:s,log:(...e)=>jp.log(1,...e)()}),e.debug&&(this.gl=lT(this.gl,{...e,throwOnError:!0}),this.debug=!0,jp.level=Math.max(jp.level,1),jp.warn("WebGL debug mode activated. Performance reduced.")())}destroy(){}get isLost(){return this.gl.isContextLost()}getSize(){return[this.gl.drawingBufferWidth,this.gl.drawingBufferHeight]}isTextureFormatSupported(e){return Lw(this.gl,e,this._extensions)}isTextureFormatFilterable(e){return function(e,t,i){if(!Lw(e,t,i))return!1;if(t.startsWith("depth")||t.startsWith("stencil"))return!1;try{if(rf(t).signed)return!1}catch{return!1}return t.endsWith("32float")?Boolean(aw(e,"OES_texture_float_linear, extensions",i)):!t.endsWith("16float")||Boolean(aw(e,"OES_texture_half_float_linear, extensions",i))}(this.gl,e,this._extensions)}isTextureFormatRenderable(e){return function(e,t,i){return!!Lw(e,t,i)&&"number"!=typeof t}(this.gl,e,this._extensions)}createCanvasContext(e){throw new Error("WebGL only supports a single canvas")}createBuffer(e){const t=this._getBufferProps(e);return new Xw(this,t)}_createTexture(e){return new tT(this,e)}createExternalTexture(e){throw new Error("createExternalTexture() not implemented")}createSampler(e){return new Jw(this,e)}createShader(e){return new pT(this,e)}createFramebuffer(e){return new iT(this,e)}createVertexArray(e){return new UT(this,e)}createTransformFeedback(e){return new NT(this,e)}createQuerySet(e){return new jT(this,e)}createRenderPipeline(e){return new PT(this,e)}beginRenderPass(e){return new gT(this,e)}createComputePipeline(e){throw new Error("ComputePipeline not supported in WebGL")}beginComputePass(e){throw new Error("ComputePass not supported in WebGL")}renderPass=null;createCommandEncoder(e){return new zT(this,e)}submit(){this.renderPass?.end(),this.renderPass=null}readPixelsToArrayWebGL(e,t){return HT(e,t)}readPixelsToBufferWebGL(e,t){return QT(e,t)}setParametersWebGL(e){Kb(this.gl,e)}getParametersWebGL(e){return Xb(this.gl,e)}withParametersWebGL(e,t){return Vw(this.gl,e,t)}clearWebGL(e){!function(e,t){const{framebuffer:i=null,color:r=null,depth:n=null,stencil:o=null}=t||{},s={};i&&(s.framebuffer=i);let a=0;r&&(a|=16384,!0!==r&&(s.clearColor=r)),n&&(a|=256,!0!==n&&(s.clearDepth=n)),o&&(a|=1024,!0!==n&&(s.clearStencil=n)),lf(0!==a,"clear: bad arguments");const l=e.gl;Vw(l,s,()=>{l.clear(a)})}(this,e)}resetWebGL(){jp.warn("WebGLDevice.resetWebGL is deprecated, use only for debugging")(),function(e){Kb(e,Db)}(this.gl)}gl;debug=!1;_canvasSizeInfo={clientWidth:0,clientHeight:0,devicePixelRatio:1};_extensions={};_polyfilled=!1;spectorJS;loseDevice(){let e=!1;const t=this.getExtension("WEBGL_lose_context").WEBGL_lose_context;return t&&(e=!0,t.loseContext()),this._resolveContextLost?.({reason:"destroyed",message:"Application triggered context loss"}),e}pushState(){iw(this.gl)}popState(){rw(this.gl)}setSpectorMetadata(e,t){e.__SPECTOR_Metadata=t}getGLKey(e,t){t=t||this.gl2||this.gl;const i=Number(e);for(const e in t)if(t[e]===i)return`GL.${e}`;return String(e)}_constants;setConstantAttributeWebGL(e,t){const i=this.limits.maxVertexAttributes;this._constants=this._constants||new Array(i).fill(null);const r=this._constants[e];switch(r&&function(e,t){if(!e||!t||e.length!==t.length||e.constructor!==t.constructor)return!1;for(let i=0;i{e.push(new Te(o,i+(o-t)/(n-t)*(r-i)))}:(e,t,i,n,r,o)=>{e.push(new Te(t+(o-i)/(r-i)*(n-t),o))};for(const s of e){const e=[];for(const r of s){if(r.length<=2)continue;const s=[];for(let e=0;et&&o(s,a,l,c,u,t):h>i?d=t&&o(s,a,l,c,u,t),d>i&&h<=i&&o(s,a,l,c,u,i)}let a=r[r.length-1];const l=0===n?a.x:a.y;l>=t&&l<=i&&s.push(a),s.length&&(a=s[s.length-1],s[0].x===a.x&&s[0].y===a.y||s.push(s[0]),e.push(s))}e.length&&r.push(e)}return r}function md(e,t){const i=_d(e),n=_d([t]),r=pd.intersection(i,n);return null==r?[]:Ad(r)}function gd(e,t){const i=65536;let n=_d(e,i);const r=[];for(;t.valid();t.next()){const[e,n]=t.get(),o=e.x*i,s=e.y*i,a=n.x*i,l=n.y*i,c=a-o,u=l-s,h=Math.hypot(c,u);if(0===h)continue;const d=Math.trunc(u/h*3),p=-Math.trunc(c/h*3);r.push([[[o,s],[a,l],[a+d,l+p],[o+d,s+p],[o,s]]])}return r.length>0&&(n=pd.diff(n,r)),Ad(n,1/i)}function _d(e,t=1){return[e.map(e=>e.map(e=>[e.x*t,e.y*t]))]}function Ad(e,t=1){return e.map(e=>e.map((e,i)=>{const n=e.map(e=>new Te(e[0]*t,e[1]*t).round());return i>0&&n.reverse(),n}))}class yd{constructor(e,t){this.layoutVertexArray=new pa,this.indexArray=new Fa,this.lineIndexArray=new Ia,this.triangleSegments=new hl,this.lineSegments=new hl,this.programConfigurations=new Nl(e.layers,{zoom:e.zoom,lut:e.lut}),this.uploaded=!1,t&&(this.elevatedLayoutVertexArray=new ga)}update(e,t,i,n,r,o,s,a){this.programConfigurations.updatePaintArrays(e,t,r,i,n,o,s,a)}isEmpty(){return 0===this.layoutVertexArray.length}needsUpload(){return this.programConfigurations.needsUpload}upload(e){this.uploaded||(this.layoutVertexBuffer=e.createVertexBuffer(this.layoutVertexArray,Ch.members),this.indexBuffer=e.createIndexBuffer(this.indexArray),this.lineIndexBuffer=e.createIndexBuffer(this.lineIndexArray),this.elevatedLayoutVertexArray&&this.elevatedLayoutVertexArray.length>0&&(this.elevatedLayoutVertexBuffer=e.createVertexBuffer(this.elevatedLayoutVertexArray,Sh.members))),this.programConfigurations.upload(e),this.uploaded=!0}destroy(){this.layoutVertexBuffer&&(this.elevatedLayoutVertexBuffer&&this.elevatedLayoutVertexBuffer.destroy(),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,s){this.programConfigurations.populatePaintArrays(this.layoutVertexArray.length,e,t,i,n,r,o,void 0,s)}}class vd{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 yd(e,!1),this.elevationBufferData=new yd(e,!0),this.stateDependentLayerIds=this.layers.filter(e=>e.isStateDependent()).map(e=>e.id),this.projection=e.projection,this.elevationMode=this.layers[0].layout.get("fill-elevation-reference"),this.sourceLayerIndex=e.sourceLayerIndex,this.worldview=e.worldview,this.hasAppearances=null}updateFootprints(e,t){}updateAppearances(e,t,i,n){}populate(e,t,i,n){this.hasPattern=od("fill",this.layers,this.pixelRatio,t);const r=this.layers[0].layout.get("fill-sort-key"),o=[];for(const{feature:s,id:a,index:l,sourceLayerIndex:c}of e){const e=this.layers[0]._featureFilter.needGeometry,u=Ic(s,e);if(!this.layers[0]._featureFilter.filter(new Es(this.zoom,{worldview:this.worldview,activeFloors:t.activeFloors}),u,i))continue;const h=r?r.evaluate(u,{},i,t.availableImages):void 0,d={id:a,properties:s.properties,type:s.type,sourceLayerIndex:c,index:l,geometry:e?u.geometry:Bc(s,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:s}=n;if(this.hasPattern){const e=sd("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,s,this.index)}}update(e,t,i,n,r,o,s){this.bufferData.update(e,t,i,n,r,o,s,this.worldview),this.elevationBufferData.update(e,t,i,n,r,o,s,this.worldview),this.elevatedStructures&&this.elevatedStructures.update(e,t,i,n,r,o,s,this.worldview)}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)}isEmpty(){return this.bufferData.isEmpty()&&this.elevationBufferData.isEmpty()}uploadPending(){return!this.uploaded||this.bufferData.needsUpload()||this.elevationBufferData.needsUpload()}upload(e){this.bufferData.upload(e),this.elevationBufferData.upload(e),this.elevatedStructures&&this.elevatedStructures.upload(e)}destroy(){this.bufferData.destroy(),this.elevationBufferData.destroy(),this.elevatedStructures&&this.elevatedStructures.destroy()}addFeature(e,t,i,n,r,o=[],s,a){const l=id(t,500);"none"!==this.elevationMode?this.addElevatedRoadFeature(e,l,n,i,a):this.addGeometry(l,this.bufferData),this.bufferData.populatePaintArrays(e,i,r,o,n,s,this.worldview),this.elevationBufferData.populatePaintArrays(e,i,r,o,n,s,this.worldview)}getUnevaluatedPortalGraph(){return this.elevatedStructures?this.elevatedStructures.unevaluatedPortals:void 0}getElevationPolygons(){return this.elevatedStructures?this.elevatedStructures.portalPolygons:void 0}setEvaluatedPortalGraph(e,t,i,n,r){this.elevatedStructures&&(this.elevatedStructures.construct(e),this.elevatedStructures.populatePaintArrays(t,i,n,r,this.worldview))}addElevatedRoadFeature(e,t,i,n,r){const o=new Array,s=tu.getElevationFeature(e,r);if(!s)return void this.addGeometry(t,this.bufferData);{const e=this.clipPolygonsToTile(t,1);e.length>0&&o.push({polygons:e,elevationFeature:s,elevationTileID:i})}const a={guardRailEnabled:this.layers[0].layout.get("fill-construct-bridge-guard-rail").evaluate(e,{},i),featureIndex:n};for(const t of o)if(t.elevationFeature){if("hd-road-base"===this.elevationMode){this.elevatedStructures||(this.elevatedStructures=new ud(t.elevationTileID,this.layers,this.zoom,this.lut));const i=t.elevationFeature.isTunnel();let n=0;e.properties.hasOwnProperty(zc)&&(n=+e.properties[zc]);for(const e of t.polygons)this.elevatedStructures.addPortalCandidates(t.elevationFeature.id,e,i,t.elevationFeature,n)}null==t.elevationFeature.constantHeight&&(t.polygons=this.prepareElevatedPolygons(t.polygons,t.elevationFeature,t.elevationTileID));const r=new iu(i,t.elevationTileID);this.addElevatedGeometry(t.polygons,r,t.elevationFeature,"hd-road-base"===this.elevationMode?0:.05,n,a)}}addElevatedGeometry(e,t,i,n,r,o){const s={elevation:i,elevationSampler:t,bias:n,index:r,featureInfo:o},[a,l]=this.addGeometry(e,this.elevationBufferData,s);null==this.elevationBufferData.heightRange?this.elevationBufferData.heightRange={min:a,max:l}:(this.elevationBufferData.heightRange.min=Math.min(this.elevationBufferData.heightRange.min,a),this.elevationBufferData.heightRange.max=Math.max(this.elevationBufferData.heightRange.max,l))}addGeometry(e,t,i){let n=Number.POSITIVE_INFINITY,r=Number.NEGATIVE_INFINITY,o=null;i&&(o=i.elevationSampler.constantElevation(i.elevation,i.bias),null!=o&&(n=o,r=o));const s=(e,s,a)=>{if(null!=i)if(s.push(e),null!=o)t.elevatedLayoutVertexArray.emplaceBack(o),a.push(o);else{const o=i.elevationSampler.pointElevation(e,i.elevation,i.bias);t.elevatedLayoutVertexArray.emplaceBack(o),a.push(o),n=Math.min(n,o),r=Math.max(r,o)}};for(const n of e){let e=0;for(const t of n)e+=t.length;const r=t.triangleSegments.prepareSegment(e,t.layoutVertexArray,t.indexArray),o=r.vertexLength,a=[],l=[],c=[],u=[],h=[],d=t.layoutVertexArray.length;for(const e of n){if(0===e.length)continue;e!==n[0]&&l.push(a.length/2);const r=t.lineSegments.prepareSegment(e.length,t.layoutVertexArray,t.lineIndexArray),o=r.vertexLength;i&&h.push(t.layoutVertexArray.length-d),s(e[0],c,u),t.layoutVertexArray.emplaceBack(e[0].x,e[0].y),t.lineIndexArray.emplaceBack(o+e.length-1,o),a.push(e[0].x),a.push(e[0].y);for(let i=1;i0&&i&&"hd-road-base"===this.elevationMode){const e=i.elevation.isTunnel(),t=i.elevation.safeArea,n=this.elevatedStructures.addVertices(c,u);this.elevatedStructures.addTriangles(p,n,e);const r=h.length;if(r>0){for(let o=0;o=i&&c.max.x<=r&&c.min.y>=n&&c.max.y<=o?a:l).push(t)}if(a.length===e.length)return e;const c=[new Te(i,n),new Te(r,n),new Te(r,o),new Te(i,o),new Te(i,n)],u=a;for(const e of l)u.push(...md(e,c));return u}}let xd,bd,wd,Td;es(vd,"FillBucket",{omit:["layers","patternFeatures"]}),es(yd,"FillBufferData"),es(ud,"ElevatedStructures");class Ed{constructor(e,t,i,n){if(this.triangleCount=t.length/3,this.min=new Te(0,0),this.max=new Te(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;te.cellIdx-t.cellIdx||e.triIdx-t.triIdx);let c=0;for(;cthis.max.x||this.min.x>e.x||e.y>this.max.y||this.min.y>e.y)return;const i=Cd(e.x-this.min.x,this.xScale,this.cellsX),n=Cd(e.y-this.min.y,this.yScale,this.cellsY),r=this.cells[n*this.cellsX+i];if(r){this._lazyInitLookup();for(let e=0;ethis.max.x||this.min.x>t.x)return;if(e.y>this.max.y||this.min.y>t.y)return;this._lazyInitLookup();const n=Cd(e.x-this.min.x,this.xScale,this.cellsX),r=Cd(t.x-this.min.x,this.xScale,this.cellsX),o=Cd(e.y-this.min.y,this.yScale,this.cellsY),s=Cd(t.y-this.min.y,this.yScale,this.cellsY);for(let e=o;e<=s;e++)for(let t=n;t<=r;t++){const n=this.cells[e*this.cellsX+t];if(n)for(let e=0;ee.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){}populate(e,t,i,n){const r=[];for(const{feature:o,id:s,index:a,sourceLayerIndex:l}of e){const e=this.layers[0]._featureFilter.needGeometry,c=Ic(o,e);if(!this.layers[0]._featureFilter.filter(new Es(this.zoom,{worldview:this.worldview,activeFloors:t.activeFloors}),c,i))continue;const u={id:s,properties:o.properties,type:o.type,sourceLayerIndex:l,index:a,geometry:e?c.geometry:Bc(o,i,n),patterns:{}};r.push(u)}for(const n of r){const{geometry:r,index:o,sourceLayerIndex:s}=n;this.addFeature(n,r,o,i,{},t.availableImages,t.brightness),t.featureIndex.insert(e[o].feature,r,o,s,this.index)}}isEmpty(){return 0===this.footprints.length}uploadPending(){return!1}upload(e){}update(e,t,i,n,r,o,s){}destroy(){}addFeature(e,t,i,n,r,o=[],s){for(const e of id(t,2)){const t=[],i=[],n=[],r=new Te(1/0,1/0),o=new Te(-1/0,-1/0);for(const s of e)if(0!==s.length){s!==e[0]&&n.push(i.length/2);for(let e=0;et===e)}(n,e.clipScope)}function Ud(e,t){return e.x-t.x||e.y-t.y}function Nd(e,t){return 0===Ud(e.min,t.min)&&0===Ud(e.max,t.max)}function Vd(e,t){return!(e.min.x>t.max.x||e.max.xt.max.y||e.max.ynew Te((e.x+o.x*Nn)*a-s.x*Nn,(e.y+o.y*Nn)*a-s.y*Nn))}return Qd(i,r,e.indices,0,e.indices.length,0,0)}function Zd(e,t,i,n){const r=Math.pow(2,n.z-i.z);return new Te((e+i.x*Nn)*r-n.x*Nn,(t+i.y*Nn)*r-n.y*Nn)}function Wd(e,t){const i=[];t.grid.queryPoint(e,i);const n=t.indices,r=t.vertices;for(let t=0;t0&&(n.length>1&&i.push(n),n=[])}return n.length>1&&i.push(n),i}const Xd=Mc.types,Jd=["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"],Yd=["fill-extrusion-flood-light-ground-radius"],ep=Math.pow(2,13),tp=Math.pow(2,15)-1,ip=new Te(0,1),np=2147483648,rp=7,op=450;function sp(e,t,i,n,r,o,s,a){e.emplaceBack((t<<1)+s,(i<<1)+o,(Math.floor(n*ep)<<1)+r,Math.round(a))}function ap(e,t,i){e.emplaceBack(t.x*Nn,t.y*Nn,i?1:0)}function lp(e,t,i,n,r,o){e.emplaceBack(t.x,t.y,(i.x<<1)+n,(i.y<<1)+r,o)}function cp(e,t,i){const n=16384;e.emplaceBack(t.x,t.y,t.z,i[0]*n,i[1]*n,i[2]*n)}class up{constructor(){this.vertexOffset=0,this.vertexCount=0,this.indexOffset=0,this.indexCount=0}}class hp{constructor(){this.centroidXY=new Te(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 Te(Number.MAX_VALUE,Number.MAX_VALUE),this.max=new Te(-Number.MAX_VALUE,-Number.MAX_VALUE),this.height=0,this.buildingId=0}span(){return new Te(this.max.x-this.min.x,this.max.y-this.min.y)}}class dp{constructor(){this.acc=new Te(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.xe.max.x&&(e.max.x=t.x,n=!0),t.ye.max.y&&(e.max.y=t.y,n=!0),((0===t.x||t.x===Nn)&&t.x===i.x)!=((0===t.y||t.y===Nn)&&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,di(t.y,e.y,(0-t.x)/(e.x-t.x))),t.x>Nn!=e.x>Nn&&this.addBorderIntersection(1,di(t.y,e.y,(Nn-t.x)/(e.x-t.x))),t.y<0!=e.y<0&&this.addBorderIntersection(2,di(t.x,e.x,(0-t.y)/(e.y-t.y))),t.y>Nn!=e.y>Nn&&this.addBorderIntersection(3,di(t.x,e.x,(Nn-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];ti[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 Te(0,0):new Te(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 pp(e,t){const i=e.add(t)._unit(),n=Fe(e.x*i.x+e.y*i.y,-1,1);var r,o,s;return r=Math.acos(n),Math.min(4,Math.max(-4,Math.tan(r)))/4*tp*((o=e).x*(s=t).y-o.y*s.x<0?-1:1)}const fp=[e=>e.x<0,e=>e.x>Nn,e=>e.y<0,e=>e.y>Nn];function mp(e,t,i,n){const r=[4];if(0===n)return r;i._mult(n);const o=e.sub(i),s=t.sub(i),a=[e,t,o,s];for(let e=0;e<4;e++)for(const t of a)if(fp[e](t)){r.push(e);break}return r}class gp{constructor(e){this.groundRadiusArray=null,this.groundRadiusBuffer=null,this.vertexArray=new ya,this.indexArray=new Fa,this.programConfigurations=new Nl(e.layers,{zoom:e.zoom,lut:e.lut},e=>Yd.includes(e)),this._segments=new hl,this.hiddenByLandmarkVertexArray=new Wa,this._segmentToGroundQuads={},this._segmentToGroundQuads[0]=[],this._segmentToRegionTriCounts={},this._segmentToRegionTriCounts[0]=[0,0,0,0,0],this.regionSegments={},this.regionSegments[4]=new hl}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 s=this._segments._prepareSegment(4*r,this.vertexArray.length,2*this._segmentToGroundQuads[o].length);let a;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];a=pp(t.sub(e[r-1])._perp()._unit(),i.sub(t)._perp()._unit())}for(let l=0;le.region-t.region);for(let i=0;ie+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 hl);const r={vertexOffset:n.vertexOffset,primitiveOffset:n.primitiveOffset+o,vertexLength:n.vertexLength,primitiveLength:t};i.get().push(r)}o+=t}for(let e=0;e0?this.hiddenByLandmarkVertexBuffer=e.createVertexBuffer(this.hiddenByLandmarkVertexArray,Ld.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 _p{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=[],this.footprintIndices=new Fa,this.footprintVertices=new pa,this.footprintSegments=[],this.layoutVertexArray=new ma,this.centroidVertexArray=new ol,this.wallVertexArray=new al,this.indexArray=new Fa,this.programConfigurations=new Nl(e.layers,{zoom:e.zoom,lut:e.lut},e=>Jd.includes(e)),this.segments=new hl,this.stateDependentLayerIds=this.layers.filter(e=>e.isStateDependent()).map(e=>e.id),this.groundEffect=new gp(e),this.maxHeight=0,this.partLookup={},this.triangleSubSegments=[],this.polygonSegments=[],this.worldview=e.worldview,this.hasAppearances=null}updateFootprints(e,t){}updateAppearances(e,t,i,n){}populate(e,t,i,n){this.features=[],this.hasPattern=od("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=yc(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:s,sourceLayerIndex:a}of e){const e=this.layers[0]._featureFilter.needGeometry,l=Ic(r,e);if(!this.layers[0]._featureFilter.filter(new Es(this.zoom,{worldview:this.worldview,activeFloors:t.activeFloors}),l,i))continue;const c={id:o,sourceLayerIndex:a,index:s,geometry:e?l.geometry:Bc(r,i,n),properties:r.properties,type:r.type,patterns:{}},u=this.layoutVertexArray.length,h="Polygon"===Xd[c.type];if(this.hasPattern)this.features.push({featureId:r.id,feature:sd("fill-extrusion",this.layers,c,this.zoom,this.pixelRatio,t)});else if(this.wallMode)for(const e of c.geometry)for(const o of Kd(e,h))this.addFeature(r.id,c,[o],s,i,{},t.availableImages,n,t.brightness);else this.addFeature(r.id,c,c.geometry,s,i,{},t.availableImages,n,t.brightness);t.featureIndex.insert(r,c.geometry,s,a,this.index,u)}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:s}of this.features){const a="Polygon"===Xd[s.type],{geometry:l}=s;if(this.wallMode)for(const c of l)for(const l of Kd(c,a))this.addFeature(e,s,[l],s.index,t,i,n,r,o);else this.addFeature(e,s,l,s.index,t,i,n,r,o)}this.sortBorders(),"mercator"===this.projection.name&&this.splitToSubtiles()}update(e,t,i,n,r,o,s){this.programConfigurations.updatePaintArrays(e,t,r,i,n,o,s,this.worldview),this.groundEffect.update(e,t,r,i,n,o,s,this.worldview)}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,kd),this.indexBuffer=e.createIndexBuffer(this.indexArray),this.wallVertexBuffer=e.createVertexBuffer(this.wallVertexArray,Rd.members),this.layoutVertexExtArray&&(this.layoutVertexExtBuffer=e.createVertexBuffer(this.layoutVertexExtArray,Fd.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,Pd.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,s,a,l){const c=this.layers[0].paint.get("fill-extrusion-flood-light-ground-radius").evaluate(t,{})/this.tileToMeter,u=[new Te(0,0),new Te(Nn,Nn)],h=a.projection,d="globe"===h.name,p=this.wallMode||"Polygon"===Xd[t.type],f=new dp;f.centroidDataIndex=this.centroidData.length;const m=new hp;m.buildingId=e,t.properties&&t.properties.hasOwnProperty("building_id")&&(m.buildingId=t.properties.building_id);const g=this.layers[0].paint.get("fill-extrusion-base").evaluate(t,{},r)<=0,_=this.layers[0].paint.get("fill-extrusion-height").evaluate(t,{},r);let A;if(m.height=_,m.vertexArrayOffset=this.layoutVertexArray.length,m.groundVertexArrayOffset=this.groundEffect.vertexArray.length,d&&!this.layoutVertexExtArray&&(this.layoutVertexExtArray=new Ta),this.wallMode){if(d)return void Ze("Non zero fill-extrusion-line-width is not yet supported on globe.");if(1!==i.length)return;A=function(e){const t=e[0].x===e[e.length-1].x&&e[0].y===e[e.length-1].y,i=function(e){let t=0;const i=e.length;for(let n=0;n=0}(e);i||(e=e.reverse());const n={geometry:[],joinNormals:[],indices:[]},r=[],o=[],s=[];let a=e.length;for(;a>=2&&e[a-1].equals(e[a-2]);)a--;if(a<(t?3:2))return n;let l,c,u,h,d,p=0;for(;p0;let _="miter";const A=2;"miter"===_&&m>A&&(_="bevel"),"bevel"===_&&(m>100&&(_="flipbevel"),m{const a=new Te(e.x,e.y),l=new Te(e.x,e.y);a.x+=t.x*n,a.y+=t.y*n,l.x-=t.x*Math.max(i,1),l.y-=t.y*Math.max(i,1),s.push(t),r.push(a),o.push(l)};if("miter"===_)n._mult(m),y(l,n,0,0);else if("flipbevel"===_)n=d.mult(-1),y(l,n,0,0),y(l,n.mult(-1),0,0);else{const e=-Math.sqrt(m*m-1),t=g?e:0,i=g?0:e;c&&y(l,h,t,i),u&&y(l,d,t,i)}}n.geometry=[...r,...o.reverse(),r[0]],n.joinNormals=[...s,...s.reverse(),s[s.length-1]];const f=n.geometry.length-1;for(let e=0;ee<(t.length-1)/2||e===t.length-1,v=this.wallMode?[i]:id(i,500);for(let e=v.length-1;e>=0;e--){const t=v[e];(0===t.length||(x=t[0]).every(e=>e.x<=0)||x.every(e=>e.x>=Nn)||x.every(e=>e.y<=0)||x.every(e=>e.y>=Nn))&&v.splice(e,1)}var x;let b;if(d)b=Cp(v,u,r);else{b=[];for(const e of v)b.push({polygon:e,bounds:u})}const w=p?this.edgeRadius:0,T=w>0&&this.zoom<17,E=(e,t)=>{if(0===e.length)return!1;const i=e[e.length-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)p&&!t[0].equals(t[t.length-1])&&t.push(t[0]),n+=p?t.length-1:t.length;const o=this.segments.prepareSegment((p?5:4)*n,this.layoutVertexArray,this.indexArray);m.footprintSegIdx<0&&(m.footprintSegIdx=this.footprintSegments.length),m.polygonSegIdx<0&&(m.polygonSegIdx=this.polygonSegments.length);const s={triangleArrayOffset:this.indexArray.length,triangleCount:0,triangleSegIdx:this.segments.segments.length-1},a=new up;if(a.vertexOffset=this.footprintVertices.length,a.indexOffset=3*this.footprintIndices.length,a.ringIndices=[],p){const n=[],s=[];i=o.vertexLength;for(let i=0;i4&&wp(s[s.length-2],s[0],s[1]),l=w?yp(s[s.length-2],s[0],s[1],w):0;const u=[];let _,v,x;v=s[1].sub(s[0])._perp()._unit();let b=!0;for(let e=1,n=0;e0?1:0,I=c.dist(p);if(n+I>32768&&(n=0),w){x=T.sub(p)._perp()._unit();let e=vp(c,p,T,Ap(v,x),w);isNaN(e)&&(e=0);const t=p.sub(c)._unit();c=c.add(t.mult(l))._round(),p=p.add(t.mult(-e))._round(),l=e,v=x,g&&this.zoom>=17&&(E(u,c)||u.push(c),E(u,p)||u.push(p))}const M=o.vertexLength,P=s.length>4&&wp(c,p,T);let R=Tp(n,a,b);if(sp(this.layoutVertexArray,c.x,c.y,S,B,0,0,R),sp(this.layoutVertexArray,c.x,c.y,S,B,0,1,R),this.wallMode){const t=y(e-1,s),i=A.joinNormals[e-1];ap(this.wallVertexArray,i,t),ap(this.wallVertexArray,i,t)}if(n+=I,R=Tp(n,P,!b),a=P,sp(this.layoutVertexArray,p.x,p.y,S,B,0,0,R),sp(this.layoutVertexArray,p.x,p.y,S,B,0,1,R),this.wallMode){const t=y(e,s),i=A.joinNormals[e];ap(this.wallVertexArray,i,t),ap(this.wallVertexArray,i,t)}if(o.vertexLength+=4,this.indexArray.emplaceBack(M+0,M+1,M+2),this.indexArray.emplaceBack(M+1,M+3,M+2),o.primitiveLength+=2,w){const n=i+(1===e?s.length-2:e-2),r=1===e?i:n+1;if(this.indexArray.emplaceBack(M+1,n,M+3),this.indexArray.emplaceBack(n,r,M+3),o.primitiveLength+=2,void 0===_&&(_=M),!xp(T,s[e],t)){const t=e===s.length-1?_:o.vertexLength;this.indexArray.emplaceBack(M+2,M+3,t),this.indexArray.emplaceBack(M+3,t+1,t),this.indexArray.emplaceBack(M+3,r,t+1),o.primitiveLength+=3}b=!b}if(d){const e=this.layoutVertexExtArray,t=h.projectTilePoint(c.x,c.y,r),i=h.projectTilePoint(p.x,p.y,r),n=h.upVector(r,c.x,c.y),o=h.upVector(r,p.x,p.y);cp(e,t,n),cp(e,t,n),cp(e,i,o),cp(e,i,o)}}p&&(i+=s.length-1),g&&w&&this.zoom>=17&&(0!==u.length&&E(u,u[0])&&u.pop(),this.groundEffect.addData(u,t,c,w>0))}this.footprintSegments.push(a),s.triangleCount=this.indexArray.length-s.triangleArrayOffset,this.polygonSegments.push(s),++m.footprintSegLen,++m.polygonSegLen}if(m.vertexCount=this.layoutVertexArray.length-m.vertexArrayOffset,m.groundVertexCount=this.groundEffect.vertexArray.length-m.groundVertexArrayOffset,0!==m.vertexCount){if(m.centroidXY=f.borders?ip:this.encodeCentroid(f,m),this.centroidData.push(m),f.borders){this.featuresOnBorder.push(f);const e=this.featuresOnBorder.length-1;for(let t=0;tthis.featuresOnBorder[t].borders[e][0]-this.featuresOnBorder[i].borders[e][0])}splitToSubtiles(){const e=[];for(let t=0;tNn),r=2*n+(+(i.min.x+i.max.x>Nn)^n);for(let n=0;ne.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 s=0,a=n,l=n;for(let t=a;t0&&this.triangleSubSegments.push({segment:u,min:o,max:c}),a=l;for(let t=a;t[e[0]*(1-i[0])+t[0]*i[0],e[1]*(1-i[1])+t[1]*i[1]],d=[],p=[];for(const e of this.triangleSubSegments){d[0]=e.min.x/Nn,d[1]=e.min.y/Nn,p[0]=e.max.x/Nn,p[1]=e.max.y/Nn;const t=h(c,u,d),s=h(c,u,p);if(0===new Jc([t[0],t[1],r],[s[0],s[1],o]).intersectsPrecise(i)){l&&(n.segments.push(l),l=void 0);continue}const a=e.segment;l&&l.vertexOffset!==a.vertexOffset&&(n.segments.push(l),l=void 0),l?(l.vertexLength+=a.vertexLength,l.primitiveLength+=a.primitiveLength):l={vertexOffset:a.vertexOffset,primitiveLength:a.primitiveLength,vertexLength:a.vertexLength,primitiveOffset:a.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(7,Math.round(n.y*this.tileToMeter/10));return new Te(Fe(i.x,1,Nn-1)<<3|r,Fe(i.y,1,Nn-1)<<3|o)}encodeBorderCentroid(e){if(!e.borders)return new Te(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 Te(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 Te((t[e][0]+t[e][1])/2<<3|6,6|(t[2][0]!==i?0:65528))}}showCentroid(e){const t=this.centroidData[e.centroidDataIndex];t.flags&=2147483647,t.centroidXY.x=0,t.centroidXY.y=0,this.writeCentroidToBuffer(t)}writeCentroidToBuffer(e){this.groundEffect.updateHiddenByLandmark(e);const t=e.vertexArrayOffset,i=e.vertexCount+e.vertexArrayOffset,n=e.flags&np?ip: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;ei.max.x||i.min.x>t.max.x||t.min.y>i.max.y||i.min.y>t.max.y))for(let o=0;ot!=l>t&&e<(this.footprintVertices.int16[2*(a+o.vertexOffset)+0]-i)*(t-s)/(l-s)+i&&(n=!n)}s=i}}return n}getHeightAtTileCoord(e,t){let i=Number.NEGATIVE_INFINITY,n=!0;const r=4*(e+Nn)*Nn+(t+Nn);if(this.partLookup.hasOwnProperty(r)){const e=this.partLookup[r];return e?{height:e.height,hidden:!!(e.flags&np)}:void 0}for(const o of this.centroidData)e>o.max.x||o.min.x>e||t>o.max.y||o.min.y>t||o.height<=i||this.footprintContainsPoint(e,t,o)&&(i=o.height,this.partLookup[r]=o,n=!!(o.flags&np));if(i!==Number.NEGATIVE_INFINITY)return{height:i,hidden:n};this.partLookup[r]=void 0}}function Ap(e,t){const i=e.add(t)._unit();return e.x*i.x+e.y*i.y}function yp(e,t,i,n){const r=t.sub(e)._perp()._unit(),o=i.sub(t)._perp()._unit();return vp(e,t,i,Ap(r,o),n)}function vp(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 xp(e,t,i){return e.xi[1].x&&t.x>i[1].x||e.yi[1].y&&t.y>i[1].y}function bp(e,t){return e.xt[1].x||e.yt[1].y}function wp(e,t,i){if(e.x<0||e.x>=Nn||t.x<0||t.x>=Nn||i.x<0||i.x>=Nn)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 Tp(e,t,i){const n=t?2|e:-3&e;return i?1|n:-2&n}function Ep(){const e=Math.PI/32,t=Math.tan(e),i=ic;return i*Math.sqrt(1+2*t*t)-i}function Cp(e,t,i){const n=1<{for(const i of e)s.push({polygon:i,bounds:t})},l=Math.ceil(Math.log2(i)),c=Math.ceil(Math.log2(n)),u=l-c,h=[];for(let e=0;e0?0:1);for(let e=0;et+1?p.push({polygons:d,bounds:e,depth:t+1}):a(d,e)}if(f.length){const e=[new Te(0===i?u:n.x,1===i?u:n.y),s];h.length>t+1?p.push({polygons:f,bounds:e,depth:t+1}):a(f,e)}}return s}(e,t,Math.ceil((o-r)/11.25),Math.ceil((s-a)/11.25),1,(e,t,r)=>{if(0===e)return.5*(t+r);{const e=pc((i.y+t/Nn)/n);return(uc(.5*(pc((i.y+r/Nn)/n)+e))*n-i.y)*Nn}})}function Sp(e,t,i,n,r,o){const s=Math.pow(2,n.z-r.z);for(let a=0;a=s[i]&&(n=t,s=e),n[i]r&&Rp(n,s,i,r),n[i]o&&Rp(s,n,i,o)}}function Fp(e,t,i,n,r,o){const s=[];for(let a=0;a=n&&d.x>=n||(u.x>=n?u=new Te(n,u.y+(n-u.x)/(d.x-u.x)*(d.y-u.y))._round():d.x>=n&&(d=new Te(n,u.y+(n-u.x)/(d.x-u.x)*(d.y-u.y))._round()),u.y>=r&&d.y>=r||(u.y>=r?u=new Te(u.x+(r-u.y)/(d.y-u.y)*(d.x-u.x),r)._round():d.y>=r&&(d=new Te(u.x+(r-u.y)/(d.y-u.y)*(d.x-u.x),r)._round()),c&&u.equals(c[c.length-1])||(c=[u],s.push(c),o&&o.push({progress:{min:f+Dp(m,g,u)*p,max:1},parentIndex:a,prevPoint:m,nextPoint:g})),c.push(d),o&&(o[o.length-1].progress.max=f+Dp(m,g,d)*p,o[o.length-1].nextPoint=g)))))}if(o&&h>0)for(let e=u;ee.t-t.t);let s=0,a=0,l=[];for(n.push(l);s!==e.length;){if(a===o.length){for(;s!==e.length;)0!==l.length&&l[l.length-1].equals(e[s])||l.push(e[s]),s++;break}o[a].t<=s?(0!==l.length&&l[l.length-1].equals(o[a].point)||l.push(o[a].point),Math.trunc(o[a].t),a++):(0!==l.length&&l[l.length-1].equals(e[s])||l.push(e[s]),s++)}}function Dp(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 Op(e,t){return e.x*t.x+e.y*t.y}function zp(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{e[0]=t,e[1]=i,e[2]=n,e[3]=1},_=Ep();i>0&&(i+=_),n+=_;for(const _ of t){const t=[],A=[];for(const h of _){const d=h.x+r.x,_=h.y+r.y,y=e.projection.projectTilePoint(d,_,u),v=e.projection.upVector(u,h.x,h.y);let x=i,b=n;if(s){const e=Vp(d,_,i,n,s,a,l,c);x+=e.base,b+=e.top}0!==i?g(f,y.x+v[0]*p*x,y.y+v[1]*p*x,y.z+v[2]*p*x):g(f,y.x,y.y,y.z),g(m,y.x+v[0]*p*b,y.y+v[1]*p*b,y.z+v[2]*p*b),j(f,f,o),j(m,m,o),t.push(new Mp(f[0],f[1],f[2])),A.push(new Mp(m[0],m[1],m[2]))}h.push(t),d.push(A)}return[h,d]}(e,t,i,n,r,o,s,a,l,c,u):s?function(e,t,i,n,r,o,s,a,l){const c=[],u=[],h=[0,0,0,1];for(const d of e){const e=[],p=[];for(const c of d){const u=c.x+n.x,d=c.y+n.y,f=Vp(u,d,t,i,o,s,a,l);h[0]=u,h[1]=d,h[2]=f.base,h[3]=1,Y(h,h,r),h[3]=Math.max(h[3],1e-5);const m=new Mp(h[0]/h[3],h[1]/h[3],h[2]/h[3]);h[0]=u,h[1]=d,h[2]=f.top,h[3]=1,Y(h,h,r),h[3]=Math.max(h[3],1e-5);const g=new Mp(h[0]/h[3],h[1]/h[3],h[2]/h[3]);e.push(m),p.push(g)}c.push(e),u.push(p)}return[c,u]}(t,i,n,r,o,s,a,l,c):function(e,t,i,n,r){const o=[],s=[],a=r[8]*t,l=r[9]*t,c=r[10]*t,u=r[11]*t,h=r[8]*i,d=r[9]*i,p=r[10]*i,f=r[11]*i;for(const t of e){const e=[],i=[];for(const o of t){const t=o.x+n.x,s=o.y+n.y,m=r[0]*t+r[4]*s+r[12],g=r[1]*t+r[5]*s+r[13],_=r[2]*t+r[6]*s+r[14],A=r[3]*t+r[7]*s+r[15],y=m+a,v=g+l,x=_+c,b=Math.max(A+u,1e-5),w=m+h,T=g+d,E=_+p,C=Math.max(A+f,1e-5);e.push(new Mp(y/b,v/b,x/b)),i.push(new Mp(w/C,T/C,E/C))}o.push(e),s.push(i)}return[o,s]}(t,i,n,r,o)}function Vp(e,t,i,n,r,o,s,a){const l=s*r.getElevationAt(e,t,!0,!0),c=0!==o[0],u=c?0===o[1]?s*(o[0]/rp-op):s*function(e,t,i){const n=Math.floor(t[0]/8),r=Math.floor(t[1]/8),o=10*(t[0]-8*n),s=10*(t[1]-8*r),a=e.getElevationAt(n,r,!0,!0),l=e.getMeterToDEM(i),c=Math.floor(.5*(o*l-1)),u=Math.floor(.5*(s*l-1)),h=e.tileCoordToPixel(n,r),d=2*c+1,p=2*u+1,f=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-c,h.y-u,d,p),m=Math.abs(f[0]-f[1]),g=Math.abs(f[2]-f[3]),_=Math.abs(f[0]-f[2])+Math.abs(f[1]-f[3]),A=Math.min(.25,.5*l*(m+g)/d),y=Math.min(.25,.5*l*_/p);return a+Math.max(A*o,y*s)}(r,o,a):l;return{base:l+(0===i?-1:i),top:c?Math.max(u+n,l+i+2):l+n}}class jp{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=void 0,this._callback=()=>{}}}class Gp{constructor(){this.tasks={},this.taskQueue=[],Ve(["process"],this),this.invoker=new jp(this.process),this.nextId=0}add(e,t){const i=this.nextId++,n=function({type:e,isSymbolTile:t,zoom:i}){return i=i||0,"message"===e?0:"maybePrepare"!==e||t?"parseTile"!==e||t?"parseTile"===e&&t?300-i:"maybePrepare"===e&&t?400-i:500:200-i:100-i}(t);if(0===n){try{e()}finally{}return null}return this.tasks[i]={fn:e,metadata:t,priority:n,id:i},this.taskQueue.push(i),this.invoker.trigger(),{cancel:()=>{delete this.tasks[i]}}}process(){try{if(this.taskQueue=this.taskQueue.filter(e=>!!this.tasks[e]),!this.taskQueue.length)return;const e=this.pick();if(null===e)return;const t=this.tasks[e];if(delete this.tasks[e],this.taskQueue.length&&this.invoker.trigger(),!t)return;t.fn()}finally{}}pick(){let e=null,t=1/0;for(let i=0;i{i&&delete this.callbacks[s],this.target.postMessage({id:s,type:"",targetMapId:n,sourceMapId:this.mapId})}}}receive(e){const t=e.data;if(!t)return;const i=t.id;if(i&&(!t.targetMapId||this.mapId===t.targetMapId))if(""===t.type){const e=this.cancelCallbacks[i];delete this.cancelCallbacks[i],e&&e.cancel()}else if(t.mustQueue||Xe(self)){const e=this.callbacks[i],n=this.scheduler.add(()=>this.processTask(i,t),e&&e.metadata||{type:"message"});n&&(this.cancelCallbacks[i]=n)}else this.processTask(i,t)}processTask(e,t){if(delete this.cancelCallbacks[e],""===t.type){const i=this.callbacks[e];delete this.callbacks[e],i&&(t.error?i(rs(t.error)):i(null,rs(t.data)))}else{const i=new Set,n=t.hasCallback?(t,n)=>{this.target.postMessage({id:e,type:"",sourceMapId:this.mapId,error:t?ns(t):null,data:ns(n,i)},i)}:()=>{},r=rs(t.data);if(this.parent[t.type])this.parent[t.type](t.sourceMapId,r,n);else if(this.parent.getWorkerSource){const e=t.type.split("."),{source:i,scope:o}=r;this.parent.getWorkerSource(t.sourceMapId,e[0],i,o)[e[1]](r,n)}else n(new Error(`Could not find function ${t.type}`))}}remove(){this.scheduler.remove(),this.target.removeEventListener("message",this.receive,!1)}}var Qp={workerUrl:"",workerClass:null,workerParams:void 0};const $p="mapboxgl_preloaded_worker_pool";class Zp{constructor(){this.active={}}acquire(e,t=Zp.workerCount){if(!this.workers)for(this.workers=[];this.workers.length{e.terminate()}),this.workers=null)}isPreloaded(){return!!this.active[$p]}numActive(){return Object.keys(this.active).length}}Zp.workerCount=2;class Wp{constructor(e,t,i="Worker",n=Zp.workerCount){this.workerPool=e,this.actors=[],this.currentActor=0,this.id=Ue();const r=this.workerPool.acquire(this.id,n);for(let e=0;e{this.ready=!0})}broadcast(e,t,i){Oe(this.actors,(i,n)=>{i.send(e,t,n)},i=i||function(){})}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)}}let qp,Kp;function Xp(){return qp||(qp=new Zp),qp}Wp.Actor=Hp;class Jp{constructor(e){this.module=e}createIntArray(e){const t=new Int32Array(e),i=this.module.malloc(t.length*t.BYTES_PER_ELEMENT);return this.module.heap32.set(t,i/t.BYTES_PER_ELEMENT),i}createFloatArray(e){const t=new Float32Array(e),i=this.module.malloc(t.length*t.BYTES_PER_ELEMENT);return this.module.heapF32.set(t,i/t.BYTES_PER_ELEMENT),i}createStringBuffer(e){const t=this.module.malloc(e.length+1);for(let i=0;ie.arrayBuffer()).then(e=>{t.buffers[i]=e})}function Tf(e,t){const i=e.json.bufferViews[t];return new Uint8Array(e.buffers[i.buffer],i.byteOffset||0,i.byteLength)}function Ef(e,t,i,n){if(e.uri){const r=bf(e.uri,n);return fetch(r).then(e=>e.blob()).then(e=>createImageBitmap(e)).then(e=>{t.images[i]=e})}if(void 0!==e.bufferView){const n=Tf(t,e.bufferView),r=new Blob([n],{type:e.mimeType});return createImageBitmap(r).then(e=>{t.images[i]=e})}}function Cf(e,t=0,i){const n={json:null,images:[],buffers:[]};if(new Uint32Array(e,t,1)[0]===vf){const i=new Uint32Array(e,t);let r=2;const o=(i[r++]>>2)-3,s=i[r++]>>2;if(r++,n.json=JSON.parse(xf.decode(i.subarray(r,r+s))),r+=s,r{const e=[],t=a&&a.includes(gf),r=a&&a.includes(Af);if(t&&e.push(function(){if(!tf)return null!=Yp?Yp:(Yp=function(e){let t,i=null;function n(){t=new Uint8Array(i.buffer)}function r(){throw new Error("Unexpected Draco error.")}const o={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)),s=Math.ceil((o-r)/65536);try{return i.grow(s),n(),!0}catch(e){return!1}},b:r}};return(WebAssembly.instantiateStreaming?WebAssembly.instantiateStreaming(e,o):e.then(e=>e.arrayBuffer()).then(e=>WebAssembly.instantiate(e,o))).then(e=>{const{Rb:r,Qb:o,P:s,T:a,X:l,Ja:c,La:u,Qa:h,Va:d,Wa:p,eb:f,jb:m,f:g,e:_,yb:A,zb:y,Ab:v,Bb:x,Db:b,Gb:w}=e.instance.exports;i=_;const T=(()=>{let e=0,i=0,n=0,s=0;return a=>{n&&(r(s),r(e),i+=n,n=e=0),e||(i+=128,e=o(i));const l=a.length+7&-8;let c=e;l>=i&&(n=l,c=s=o(l));for(let e=0;e{tf=e,Yp=void 0}))}()),r&&e.push(function(){if(rf)return;const e=function(e){let t;const i=WebAssembly.instantiateStreaming(e,{}).then(e=>{t=e.instance,t.exports.__wasm_call_ctors()}),n={NONE:"",OCTAHEDRAL:"meshopt_decodeFilterOct",QUATERNION:"meshopt_decodeFilterQuat",EXPONENTIAL:"meshopt_decodeFilterExp"},r={ATTRIBUTES:"meshopt_decodeVertexBuffer",TRIANGLES:"meshopt_decodeIndexBuffer",INDICES:"meshopt_decodeIndexSequence"};return{ready:i,supported:!0,decodeGltfBuffer(e,i,o,s,a,l){!function(e,t,i,n,r,o,s){const a=e.exports.sbrk,l=n+3&-4,c=a(l*r),u=a(o.length),h=new Uint8Array(e.exports.memory.buffer);h.set(o,u);const d=t(c,n,r,u,o.length);if(0===d&&s&&s(c,l,r),i.set(h.subarray(c,c+n*r)),a(c-a(0)),0!==d)throw new Error(`Malformed buffer data: ${d}`)}(t,t.exports[r[a]],e,i,o,s,t.exports[n[l]])}}}(fetch(uf()));return e.ready.then(()=>{rf=e})}()),o)for(let t=0;t{if(t&&s)for(const{primitives:e}of s)for(const t of e)_f(t,n);if(r&&s&&l)for(const e of l)yf(e,n);return n})})}function Sf(e){return fetch(e).then(e=>e.arrayBuffer()).then(t=>Cf(t,0,e))}function Bf(e){switch(e){case WebGL2RenderingContext.RGBA8: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 If(e){switch(e){case WebGL2RenderingContext.RGBA8:return WebGL2RenderingContext.UNSIGNED_BYTE;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}}class Mf{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:s,y:a}=t&&t.position?t.position:{x:0,y:0},l=s+i,c=a+n;!this.size||this.size[0]===l&&this.size[1]===c||(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 u=e instanceof HTMLImageElement||e instanceof HTMLCanvasElement||e instanceof HTMLVideoElement||e instanceof ImageData||ImageBitmap&&e instanceof ImageBitmap;if(!this.size&&l>0&&c>0){const e=this.useMipmap?Math.floor(Math.log2(Math.max(l,c)))+1:1;o.texStorage2D(o.TEXTURE_2D,e,this.format,l,c),this.size=[l,c]}this.size&&(u?o.texSubImage2D(o.TEXTURE_2D,0,s,a,Bf(this.format),If(this.format),e):"data"in e&&e.data&&o.texSubImage2D(o.TEXTURE_2D,0,s,a,i,n,Bf(this.format),If(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:s}=o;s.bindTexture(s.TEXTURE_2D,this.texture),t!==this.magFilter&&(s.texParameteri(s.TEXTURE_2D,s.TEXTURE_MAG_FILTER,t),this.magFilter=t),e!==this.minFilter&&(s.texParameteri(s.TEXTURE_2D,s.TEXTURE_MIN_FILTER,this.useMipmap?e===s.NEAREST?s.NEAREST_MIPMAP_NEAREST:s.LINEAR_MIPMAP_LINEAR:e),this.minFilter=e),i!==this.wrapS&&(s.texParameteri(s.TEXTURE_2D,s.TEXTURE_WRAP_S,i),this.wrapS=i),n!==this.wrapT&&(s.texParameteri(s.TEXTURE_2D,s.TEXTURE_WRAP_T,n),this.wrapT=n),r!==this.compareMode&&(r?(s.texParameteri(s.TEXTURE_2D,s.TEXTURE_COMPARE_MODE,s.COMPARE_REF_TO_TEXTURE),s.texParameteri(s.TEXTURE_2D,s.TEXTURE_COMPARE_FUNC,r)):s.texParameteri(s.TEXTURE_2D,s.TEXTURE_COMPARE_MODE,s.NONE),this.compareMode=r)}destroy(){const{gl:e}=this.context;e.deleteTexture(this.texture),this.texture=null}}class Pf{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)}}const Rf=ha([{name:"a_pos_3f",components:3,type:"Float32"}]),Lf=ha([{name:"a_color_3f",components:3,type:"Float32"}]),Ff=ha([{name:"a_color_4f",components:4,type:"Float32"}]),kf=ha([{name:"a_uv_2f",components:2,type:"Float32"}]),Df=ha([{name:"a_normal_3f",components:3,type:"Float32"}]),Of=ha([{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"}]),zf=ha([{name:"a_pbr",components:4,type:"Uint16"},{name:"a_heightBasedEmissiveStrength",components:3,type:"Float32"}]);function Uf(e,t){const i=Vf(e.projection,e.zoom,e.width,e.height),n=function(e,t,i,n,r){const o=new rc(i.lng-180*jf,i.lat),s=new rc(i.lng+180*jf,i.lat),a=e.project(o.lng,o.lat),l=e.project(s.lng,s.lat),u=-Math.atan2(l.y-a.y,l.x-a.x),d=vc.fromLngLat(i);d.y=Fe(d.y,-1+jf,1-jf);const f=d.toLngLat(),m=e.project(f.lng,f.lat),_=vc.fromLngLat(f);_.x+=jf;const A=_.toLngLat(),y=e.project(A.lng,A.lat),v=Hf(y.x-m.x,y.y-m.y,u),x=vc.fromLngLat(f);x.y+=jf;const b=x.toLngLat(),w=e.project(b.lng,b.lat),T=Hf(w.x-m.x,w.y-m.y,u),E=Math.abs(v.x)/Math.abs(T.y),C=c([]);g(C,C,-u*(1-(r?0:n)));const S=c([]);return p(S,S,[1,1-(1-E)*n,1]),S[4]=-T.x/T.y*n,g(S,S,u),h(S,C,S),S}(e.projection,0,e.center,i,t),r=Nf(e);return p(n,n,[r,r,1]),n}function Nf(e){const t=e.projection,i=Vf(e.projection,e.zoom,e.width,e.height),n=Gf(t,e.center),r=Gf(t,rc.convert(t.center));return Math.pow(2,n*i+(1-i)*r)}function Vf(e,t,i,n,r=1/0){const o=e.range;if(!o)return 0;const s=Math.min(r,Math.max(i,n)),a=Math.log2(s/1024);return ke(o[0]+a,o[1]+a,t)}const jf=1/4e4;function Gf(e,t){const i=Fe(t.lat,-mc,mc),n=new rc(t.lng-180*jf,i),r=new rc(t.lng+180*jf,i),o=e.project(n.lng,i),s=e.project(r.lng,i),a=vc.fromLngLat(n),l=vc.fromLngLat(r),c=s.x-o.x,u=s.y-o.y,h=l.x-a.x,d=l.y-a.y,p=Math.sqrt((h*h+d*d)/(c*c+u*u));return Math.log2(p)}function Hf(e,t,i){const n=Math.cos(i),r=Math.sin(i);return{x:e*n-t*r,y:e*r+t*n}}function Qf(e,t,i){c(e),g(e,e,Be(t[2])),f(e,e,Be(t[0])),m(e,e,Be(t[1])),p(e,e,i),h(e,e,[1,0,0,0,0,0,1,0,0,1,0,0,0,0,0,1])}function $f(e,t,i,n,r,o,s,a){const l=[i[0]-t[0],i[1]-t[1],0],c=[n[0]-t[0],n[1]-t[1],0];if(T(l)<1e-12||T(c)<1e-12)return te(e);const u=N([],l,c);z(u,u),B(c,n,t),l[2]=(o-r)*a,c[2]=(s-r)*a;const h=l;return N(h,l,c),z(h,h),le(e,u,h)}function Zf(e,t,i=!1){const n=th(t.zoom),r=function(e,t,i){const n=t.worldSize,r=[e[12],e[13],e[14]],o=pc(r[1]/n),s=dc(r[0]/n),a=c([]),l=hc(1,o)*n,u=hc(1,0)*n*_c(o,t.zoom),f=1/Ju(n);let m=u*f;if(i){const e=Vf(t.projection,t.zoom,t.width,t.height,1024);m=f*t.projection.pixelSpaceConversion(t.center.lat,n,e)}const g=tc(o,s);S(g,g,R([],z([],g),l*m*r[2]));const _=function(e){const t=[e[0],e[1],e[2]];let i=[0,1,0];const n=N([],i,t);return N(i,t,n),0===D(i)&&(i=[0,1,0],N(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]}(g);p(a,a,[m,m,m*l]),d(a,a,[-r[0],-r[1],-r[2]]);const A=h([],t.globeMatrix,_);return h(A,A,a),h(A,A,e),A}(e,t,i);if(n>0){const i=function(e,t){const i=t.worldSize,n=hc(1,0)*i*_c(t.center.lat,t.zoom)/Ju(i),r=hc(1,t.center.lat)*i,o=c([]);m(o,o,Be(t.center.lng)),f(o,o,Be(t.center.lat)),d(o,o,[0,0,$l]),p(o,o,[n,n,n*r]);const s=t.point;return d(o,o,[-s.x,-s.y,0]),h(o,o,e),h(o,t.globeMatrix,o)}(e,t);return function(e,t,i){const n=(e,t,i)=>{const n=T(e),r=T(t),o=ju(e,t,i);return R(o,o,1/T(o)*di(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),s=n([e[8],e[9],e[10]],[t[8],t[9],t[10]],i),a=ju([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,s[0],s[1],s[2],0,a[0],a[1],a[2],1]}(r,i,n)}return r}function Wf(e,t,i,n){const r=Jc.projectAabbCorners(n,i);let o=Number.MAX_VALUE;for(let e=0;e0||0===s&&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(ru(e,s))return o}const qf=64,Kf={CoordinateSpaceTile:1,HasMapboxMeshFeatures:4,HasMeshoptCompression:8};function Xf(e,t,i,n,r,o,s,a,l,u=!1){const f=i.zoom,m=i.project(n),g=_c(n.lat,f),_=1/g;c(e),d(e,e,[m.x+s[0]*_,m.y+s[1]*_,s[2]]);let A=1,y=1;const x=i.worldSize;if(u){if("mercator"===i.projection.name){let e=0;i.elevation&&(e=i.elevation.getAtPointOrZero(new vc(m.x/x,m.y/x),0));const t=Y([],[m.x,m.y,e,1],i.projMatrix)[3]/i.cameraToCenterDistance;A=t,y=t*_c(i.center.lat,f)}else if("globe"===i.projection.name){const t=Zf(e,i),r=[0,0,0,1];Y(r,r,h([],i.projMatrix,t));const o=r[3]/i.cameraToCenterDistance,s=th(f),a=i.projection.pixelsPerMeter(n.lat,x)*_c(n.lat,f),l=i.projection.pixelsPerMeter(i.center.lat,x)*_c(i.center.lat,f);A=o/di(a,gc(i.center.lat),s),y=o*g/a,A*=l,y*=l}}else A=_;p(e,e,[A,A,y]);const b=[...e],w=t.orientation,T=[];if(Qf(T,[w[0]+(r?r[0]:0),w[1]+(r?r[1]:0),w[2]+(r?r[2]:0)],o),h(e,b,T),a&&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 s=Jc.projectAabbCorners(i,n),a=hc(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]],s=e[r.corners[2]],a=[o[0]-n[0],o[1]-n[1],t*(o[2]-n[2])],l=N(a,a,[s[0]-n[0],s[1]-n[1],t*(s[2]-n[2])]);z(l,l),r.dotProductWithUp=U(l,i)}return n.sort((e,t)=>e.dotProductWithUp-t.dotProductWithUp),n[0].corners}(s,a),c=s[l[0]],u=s[l[1]],h=s[l[2]],d=s[l[3]],p=o.getAtPointOrZero(new vc(c[0]/t.worldSize,c[1]/t.worldSize),0),f=o.getAtPointOrZero(new vc(u[0]/t.worldSize,u[1]/t.worldSize),0),m=o.getAtPointOrZero(new vc(h[0]/t.worldSize,h[1]/t.worldSize),0),g=o.getAtPointOrZero(new vc(d[0]/t.worldSize,d[1]/t.worldSize),0),_=(p+g)/2,A=(f+m)/2;return _>A?f=t.gl.NEAREST_MIPMAP_NEAREST}),e.uploaded=!0,e.image=null)}function em(e,t,i){e.indexBuffer=t.createIndexBuffer(e.indexArray,!1,!0),e.vertexBuffer=t.createVertexBuffer(e.vertexArray,Rf.members,!1,!0),e.normalArray&&(e.normalBuffer=t.createVertexBuffer(e.normalArray,Df.members,!1,!0)),e.texcoordArray&&(e.texcoordBuffer=t.createVertexBuffer(e.texcoordArray,kf.members,!1,!0)),e.colorArray&&(e.colorBuffer=t.createVertexBuffer(e.colorArray,(12===e.colorArray.bytesPerElement?Lf:Ff).members,!1,!0)),e.featureArray&&(e.pbrBuffer=t.createVertexBuffer(e.featureArray,zf.members,!0)),e.segments=hl.simpleSegment(0,0,e.vertexArray.length,e.indexArray.length);const n=e.material;n.pbrMetallicRoughness.baseColorTexture&&Yf(n.pbrMetallicRoughness.baseColorTexture,t),n.pbrMetallicRoughness.metallicRoughnessTexture&&Yf(n.pbrMetallicRoughness.metallicRoughnessTexture,t),n.normalTexture&&Yf(n.normalTexture,t),n.occlusionTexture&&Yf(n.occlusionTexture,t,i),n.emissionTexture&&Yf(n.emissionTexture,t)}function tm(e,t,i){if(e.meshes)for(const n of e.meshes)em(n,t,i);if(e.children)for(const n of e.children)tm(n,t,i)}function im(e){if(e.meshes)for(const t of e.meshes)t.indexArray.destroy(),t.vertexArray.destroy(),t.colorArray&&t.colorArray.destroy(),t.normalArray&&t.normalArray.destroy(),t.texcoordArray&&t.texcoordArray.destroy(),t.featureArray&&t.featureArray.destroy();if(e.children)for(const t of e.children)im(t)}function nm(e){if(e.meshes)for(const i of e.meshes)i.vertexBuffer&&(i.vertexBuffer.destroy(),i.indexBuffer.destroy(),i.normalBuffer&&i.normalBuffer.destroy(),i.texcoordBuffer&&i.texcoordBuffer.destroy(),i.colorBuffer&&i.colorBuffer.destroy(),i.pbrBuffer&&i.pbrBuffer.destroy(),i.segments.destroy(),i.material&&((t=i.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()));var t;if(e.children)for(const t of e.children)nm(t)}function rm(e,t){const i=e.json.bufferViews[t.bufferView],n=df[t.componentType];return new n(e.buffers[i.buffer],(t.byteOffset||0)+(i.byteOffset||0),t.count*(i.byteStride&&i.byteStride!==ff[t.type]*n.BYTES_PER_ELEMENT?i.byteStride/n.BYTES_PER_ELEMENT:ff[t.type]))}function om(e,t,i,n){const r=df[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),s=e.json.bufferViews[t.bufferView],a=s.byteStride?s.byteStride/r.BYTES_PER_ELEMENT:ff[t.type],l=i.float32,c=l.length/i.capacity;for(let e=0,i=0;e0){for(let r=0;r0){o.texcoordArray=new ja;const e=t.json.accessors[r.TEXCOORD_0];o.texcoordArray.resize(e.count);const i=rm(t,e);om(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=rm(t,e))}void 0!==r._FEATURE_RGBA4444&&(o.featureData=new Uint32Array(rm(t,t.json.accessors[r._FEATURE_RGBA4444]).buffer));const h=e.material;return o.material=function(e,t){const{emissiveFactor:i=[0,0,0],alphaMode:n="OPAQUE",alphaCutoff:r=.5,normalTexture:o,occlusionTexture:s,emissiveTexture:a,doubleSided:l,name:c}=e,{baseColorFactor:u=[1,1,1,1],metallicFactor:h=1,roughnessFactor:d=1,baseColorTexture:p,metallicRoughnessTexture:f}=e.pbrMetallicRoughness||{},m=s?t[s.index]:void 0;if(s&&s.extensions&&s.extensions.KHR_texture_transform&&m){const e=s.extensions.KHR_texture_transform;m.offsetScale=[e.offset[0],e.offset[1],e.scale[0],e.scale[1]]}return{name:c,pbrMetallicRoughness:{baseColorFactor:new li(...u),metallicFactor:h,roughnessFactor:d,baseColorTexture:p?t[p.index]:void 0,metallicRoughnessTexture:f?t[f.index]:void 0},doubleSided:l,emissiveFactor:new li(...i),alphaMode:n,alphaCutoff:r,normalTexture:o?t[o.index]:void 0,occlusionTexture:m,emissionTexture:a?t[a.index]:void 0,defined:void 0===e.defined}}(void 0!==h?t.json.materials[h]:{defined:!1},i),o}function am(e,t,i){const{matrix:n,rotation:r,translation:o,scale:s,mesh:a,extras:c,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],s=t[2],a=t[3],l=r+r,c=o+o,u=s+s,h=r*l,d=r*c,p=r*u,f=o*c,m=o*u,g=s*u,_=a*l,A=a*c,y=a*u,v=n[0],x=n[1],b=n[2];return e[0]=(1-(f+g))*v,e[1]=(d+y)*v,e[2]=(p-A)*v,e[3]=0,e[4]=(d-y)*x,e[5]=(1-(h+g))*x,e[6]=(m+_)*x,e[7]=0,e[8]=(p+A)*b,e[9]=(m-_)*b,e[10]=(1-(h+f))*b,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],s||[1,1,1]),d.globalMatrix=l(d.localMatrix),void 0!==a){d.meshes=i[a];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(c&&(c.id&&(d.id=c.id),c.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;e1&&n[n.length-1].equals(n[0])&&n.pop();let r=0;for(let e=0;e0&&n.reverse();const o=Mh(n.flatMap(e=>[e.x,e.y]),[]);return 0===o.length?null:{vertices:n,indices:o}}function um(e,t){const i=[],n=[];let r=0;const o=[];for(const s of e){r=i.length;const e=s.vertexArray.float32,a=s.indexArray.uint16;for(let n=0;n0&&([n[e+1],n[e+2]]=[n[e+2],n[e+1]])}return{vertices:i,indices:n}}function hm(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=[];for(const n of e.json.meshes){const r=[];for(const i of n.primitives)r.push(sm(i,e,t));i.push(r)}return i}(e,t),{scenes:n,scene:r,nodes:o}=e.json,s=n?n[r||0].nodes:[...o.keys()],a=[];for(const t of s)a.push(am(o[t],e,i));return function(e,t,i){const n={},r=new Set;for(let o=0;o0){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)}}(a,s,e.json.nodes),a}function dm(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=qf/(e.aabb.max[0]-i+2),o=qf/(e.aabb.max[1]-n+2);for(let s=0;se.heightmap[c*qf+l]&&(e.heightmap[c*qf+l]=a)}}function pm(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 s of e){const e=Math.min(10,Math.max(4,1.3*s.height))*t,a=[-s.normal[1],s.normal[0],0],l=Math.min(.29,.1*s.width/s.depth),c=s.width-2*s.depth*t*(l+.01),u=L([],s.pos,a,c/2),h=L([],s.pos,a,-c/2),d=[u[0],u[1],u[2]+s.height],p=[h[0],h[1],h[2]+s.height],f=L([],s.normal,a,l);R(f,f,e);const m=L([],s.normal,a,-l);R(m,m,e),S(f,u,f),S(m,h,m),u[2]+=.1,h[2]+=.1,n.emplaceBack(f[0],f[1],f[2]),n.emplaceBack(m[0],m[1],m[2]),n.emplaceBack(u[0],u[1],u[2]),n.emplaceBack(h[0],h[1],h[2]),n.emplaceBack(d[0],d[1],d[2]),n.emplaceBack(p[0],p[1],p[2]),n.emplaceBack(u[0],u[1],u[2]),n.emplaceBack(h[0],h[1],h[2]),n.emplaceBack(f[0],f[1],f[2]),n.emplaceBack(m[0],m[1],m[2]);const g=c/e/2;r.emplaceBack(-g-l,-1,g,.8),r.emplaceBack(g+l,-1,g,.8),r.emplaceBack(-g,0,g,1.3),r.emplaceBack(g,0,g,1.3),r.emplaceBack(g+l,-.8,g,.7),r.emplaceBack(g+l,-.8,g,.7),r.emplaceBack(0,0,g,1.3),r.emplaceBack(0,0,g,1.3),r.emplaceBack(g+l,-1.2,g,.8),r.emplaceBack(g+l,-1.2,g,.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 fm(e,t){const i={};i.indexArray=new Fa,i.vertexArray=new xa,i.colorArray=new Sa,pm(e,t,i.indexArray,i.vertexArray,i.colorArray);const n={defined:!0};n.emissiveFactor=li.black;const r={};return r.baseColorFactor=li.white,n.pbrMetallicRoughness=r,i.material=n,i.aabb=new Jc([1/0,1/0,1/0],[-1/0,-1/0,-1/0]),i}const mm=ha([{name:"a_pos_3f",components:3,type:"Float32"}]),gm=ha([{name:"a_normal_3",components:3,type:"Int16"}]),_m=ha([{name:"a_centroid_3",components:3,type:"Int16"}]),Am=ha([{name:"a_part_color_emissive",components:2,type:"Uint16"}]),ym=ha([{name:"a_faux_facade_color_emissive",components:2,type:"Uint16"}]),vm=ha([{name:"a_faux_facade_data",components:4,type:"Uint16"}]),xm=ha([{name:"a_faux_facade_vertical_range",components:2,type:"Uint16"}]),bm=ha([{name:"a_bloom_attenuation",components:4,type:"Float32"}]),wm=ha([{name:"a_flood_light_wall_radius_1i16",components:1,type:"Uint16"}]),Tm=Mc.types,Em=32767;function Cm(e,t){const i=Nn+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}class Sm{constructor(){this.layoutVertexArray=new xa,this.layoutAttenuationArray=new Sa,this.layoutColorArray=new Ia,this.indexArray=new Fa,this.indexArrayForConflation=new Fa,this.segmentsBucket=new hl}}class Bm{constructor(){this.layoutVertexArray=new xa,this.layoutNormalArray=new fa,this.layoutCentroidArray=new fa,this.layoutColorArray=new Ia,this.layoutFacadePaintArray=null,this.layoutFacadeDataArray=null,this.layoutFacadeVerticalRangeArray=null,this.layoutFloodLightDataArray=new Ha,this.layoutAOArray=new ga,this.indexArray=new Fa,this.indexArrayForConflation=new Fa,this.segmentsBucket=new hl,this.entranceBloom=new Sm}}class Im{constructor(e){this.colorBufferUploaded=!1,this.maxHeight=0,this.replacementUpdateTime=0,this.activeReplacements=[],this.footprints=[],this.featuresOnBorder=[],this.buildingFeatures=[],this.buildingWithoutFacade=new Bm,this.buildingWithFacade=new Bm,this.indexArrayForConflationUploaded=!1,this.featureFootprintLookup=new Map,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.buildingWithFacade.layoutFacadePaintArray=new Ia,this.buildingWithFacade.layoutFacadeDataArray=new wa,this.buildingWithFacade.layoutFacadeVerticalRangeArray=new Ia,this.programConfigurations=new Nl(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 gp(e),this.groundEffect.groundRadiusArray=new ga,this.hasAppearances=null}updateFootprints(e,t){for(const i of this.footprints)t.push({footprint:i,id:e})}updateAppearances(e,t,i,n){}prepare(){return function(){if(null!=lf||null!=af)return null;if(null!=sf)return sf;const e=fetch(st.BUILDING_GEN_URL);return sf=function(e){let t,i,n,r;function o(){t=new Uint8Array(r.buffer),i=new Int32Array(r.buffer),n=new Float32Array(r.buffer)}function s(){throw new Error("Unexpected BuildingGen error.")}const a=()=>{},l={a:{a:s,f:function(e){const i=t.length,n=Math.max(e>>>0,Math.ceil(1.2*i)),s=Math.ceil((n-i)/65536);try{return r.grow(s),o(),!0}catch(e){return!1}},g:s,b:a,c:a,d:a,e:a}};return(WebAssembly.instantiateStreaming?WebAssembly.instantiateStreaming(e,l):e.then(e=>e.arrayBuffer()).then(e=>WebAssembly.instantiate(e,l))).then(e=>{const s=e.instance.exports;return(0,s.g)(),r=s.f,o(),new Jp({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,getColorsPtr:s.y,getColorsLength:s.z,getAOPtr:s.A,getAOLength:s.B,getUVPtr:s.C,getUVLength:s.D,getFauxFacadePtr:s.E,getFauxFacadeLength:s.F,getIndicesPtr:s.G,getIndicesLength:s.H,getBuildingPart:s.I,getRingCount:s.J,getRingPtr:s.K,getRingLength:s.L,free:s.M,malloc:s.N,heapU8:t,heap32:i,heapF32:n})})}(e).then(e=>(sf=null,lf=e,lf)).catch(e=>{Ze("Could not load building-gen"),sf=null,af=e}),sf}()}populate(e,t,i,n){const r=hf();if(!r)return;const o=yc(i);this.tileToMeter=o,this.brightness=t.brightness,r.setStyle({convertToMeters:!1,entranceColorRgb:[1,1,1],facadeGlazingColorRgb:[.5607843137254902,.6745098039215687,.7215686274509804],normalScale:[1,-1,o],ridgeHeight:3,roofColorRgb:[.886274516,.784313738,.713725507],tileToMeters:o,tileZoom:16,wallColorRgb:[.988235294,.933333337,.811764717]}),r.setAOOptions(!1,.3),r.setMetricOptions(!1,16),r.setStructuralOptions(!0),r.setFacadeClassifierOptions(3);const s=new Map,a=new Map;for(const{feature:t}of e){if("LineString"!==Tm[t.type]){s.set(t.id,t.properties.source_id);continue}const e=this.layers[0]._featureFilter.needGeometry,r=Ic(t,e);if(!this.layers[0]._featureFilter.filter(new Es(this.zoom),r,i))continue;const o=e?r.geometry:Bc(t,i,n),l=[];for(const e of o)for(const t of e)l.push({x:t.x,y:t.y});const c={coordinates:l,crossPerc:t.properties.cross_perc,distanceToRoad:t.properties.distance_to_road,entrances:t.properties.entrances,sourceId:0},u=t.properties.source_id;let h=a.get(u);h||(h=[],a.set(u,h)),h.push(c)}this.maxHeight=0;for(const{feature:l,id:c,index:u,sourceLayerIndex:h}of e){if("LineString"===Tm[l.type])continue;const e=this.layers[0]._featureFilter.needGeometry,d=Ic(l,e);if(!this.layers[0]._featureFilter.filter(new Es(this.zoom),d,i))continue;const p=e?d.geometry:Bc(l,i,n),f=id(p,500);if(!Cm(p,163))continue;const m=this.layers[0],g=m.layout.get("building-roof-shape").evaluate(l,{},i);if("flat"===g)continue;const _=m.layout.get("building-base").evaluate(l,{},i),A=m.layout.get("building-height").evaluate(l,{},i),y=m.layout.get("building-flood-light-ground-radius").evaluate(l,{},i),v=m.paint.get("building-ambient-occlusion-intensity"),x=y/this.tileToMeter;let b=m.layout.get("building-flood-light-wall-radius").evaluate(l,{},i);b=Fe(b,0,2048);const w=b/2048*Em,T=s.get(c);let E;E=a.has(T)?a.get(T):[];const C=0!==E.length&&m.layout.get("building-facade").evaluate(l,{},i);r.setFacadeOptions(4,!0),r.setFauxFacadeOptions(C,!1,1);let S=0,B=0,I=0,M=0,P=0,R=0;if(C){let e=Math.round(m.layout.get("building-facade-floors").evaluate(l,{},i));if(0===_){e=Math.max(1,e-(E.length>0?1:0));let t=4;if(A>100){const e=[10,13,15];t=e[l.id?l.id%e.length:0],r.setFacadeOptions(t,!0)}P=1.6803*t/o}else P=_/o;R=A/o,P=Math.min(P,R),I=m.layout.get("building-facade-unit-width").evaluate(l,{},i)/o,M=(R-P)/e,r.setFauxFacadeOptions(!0,!0,I);const t=m.layout.get("building-facade-window").evaluate(l,{},i);S=t[0],B=t[1]}const L=[],F=new Te(1/0,1/0),k=new Te(-1/0,-1/0),D=new Te(0,0);let O=0;for(const e of f)if(e.length>0){const t=[];for(const i of e){const e=[];for(let t=i.length-1;t>=0;t--){const n=i[t];e.push({x:n.x,y:n.y}),F.x=Math.min(F.x,n.x),F.y=Math.min(F.y,n.y),k.x=Math.max(k.x,n.x),k.y=Math.max(k.y,n.y),D.x+=n.x,D.y+=n.y,O++}t.push(e)}L.push({id:l.id?l.id:0,height:A,minHeight:_,sourceId:0,roofType:g,coordinates:t})}D.x/=O||1,D.y/=O||1;const z=r.generateMesh(L,E);if("string"==typeof z){Ze(`Unable to generate building ${l.id}: ${z}`);continue}if(0===z.meshes.length||0===z.modifiedPolygonRings.length)continue;let U=0;for(const e of z.meshes)U+=e.positions.length/3;const N=C?this.buildingWithFacade:this.buildingWithoutFacade,V=N.segmentsBucket.prepareSegment(U,N.layoutVertexArray,N.indexArray),j=[];let G=null,H=0,Q=-1;const $=N.layoutVertexArray.length,Z=N.indexArray.length;let W=0;for(const e of z.meshes){const t=N.layoutVertexArray.length;if("entrance"===e.buildingPart){const t=new Array;for(let i=0;iNn||F.y<0||k.y>Nn)&&this.featuresOnBorder.push({featureId:l.id,footprintIndex:this.footprints.length});{const e=Mh(K,null,2),t=new Ed(X,e,8,256);let i=l.id;l.properties&&l.properties.hasOwnProperty("building_id")&&(i=l.properties.building_id);const n={vertices:X,indices:e,grid:t,min:J,max:Y,buildingId:i,hiddenFlags:0,indicesOffset:Z,indicesLength:q,bloomIndicesOffset:H,bloomIndicesLength:Q,groundEffectVertexOffset:ee,groundEffectVertexLength:te,hasFauxFacade:C,segment:V,height:W};void 0!==l.id&&this.featureFootprintLookup.set(l.id,this.footprints.length),this.footprints.push(n)}this.programConfigurations.populatePaintArrays(N.layoutVertexArray.length,l,u,{},t.availableImages,i,t.brightness),this.groundEffect.addPaintPropertiesData(l,u,{},t.availableImages,i,t.brightness),t.featureIndex.insert(l,p,u,h,this.index,$)}this.groundEffect.prepareBorderSegments(),this.evaluate(this.layers[0],{})}update(e,t,i,n,r,o,s){this.programConfigurations.updatePaintArrays(e,t,r,i,n,o,s),this.groundEffect.update(e,t,r,i,n,o,s),this.evaluate(this.layers[0],e),this.colorBufferUploaded=!1}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,mm.members),t.layoutNormalBuffer=e.createVertexBuffer(t.layoutNormalArray,gm.members),t.layoutCentroidBuffer=e.createVertexBuffer(t.layoutCentroidArray,_m.members),t.layoutFloodLightDataBuffer=e.createVertexBuffer(t.layoutFloodLightDataArray,wm.members),t.layoutFacadeDataArray&&t.layoutFacadeDataArray.length&&(t.layoutFacadeDataBuffer=e.createVertexBuffer(t.layoutFacadeDataArray,vm.members)),t.layoutFacadeVerticalRangeArray&&t.layoutFacadeVerticalRangeArray.length&&(t.layoutFacadeVerticalRangeBuffer=e.createVertexBuffer(t.layoutFacadeVerticalRangeArray,xm.members)),t.entranceBloom.layoutVertexArray.length&&(t.entranceBloom.layoutVertexBuffer=e.createVertexBuffer(t.entranceBloom.layoutVertexArray,mm.members),t.entranceBloom.layoutAttenuationBuffer=e.createVertexBuffer(t.entranceBloom.layoutAttenuationArray,bm.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{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,Am.members,!0),t.layoutFacadePaintArray&&(t.layoutFacadePaintBuffer?t.layoutFacadePaintBuffer.updateData(t.layoutFacadePaintArray):t.layoutFacadePaintBuffer=e.createVertexBuffer(t.layoutFacadePaintArray,ym.members,!0)),t.entranceBloom.layoutColorBuffer?t.entranceBloom.layoutColorBuffer.updateData(t.entranceBloom.layoutColorArray):t.entranceBloom.layoutColorBuffer=e.createVertexBuffer(t.entranceBloom.layoutColorArray,Am.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.buildingFeatures){const r=t[n.promoteId],o=n.feature;o.properties["building-part"]="roof";const s=e.paint.get("building-color").evaluate(o,r,this.canonical).toPremultipliedRenderColor(this.lut),a=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),c=e.paint.get("building-emissive-strength").evaluate(o,r,this.canonical);o.properties["building-part"]="window";const u=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),p=e.paint.get("building-emissive-strength").evaluate(o,r,this.canonical),f=n.hasFauxFacade?this.buildingWithFacade:this.buildingWithoutFacade;for(const e of n.parts){let t,r=s;"roof"===e.part?(r=s,t=a):"wall"===e.part?(r=l,t=c):"facade_glazing"===e.part?(r=u,t=h):"entrance"===e.part&&(r=d,t=p),t=Fe(t,0,1);for(let o=0;ot.max.x||n.max.xt.max.y||n.max.ys.max.x||s.min.x>e||t>s.max.y||s.min.y>t||s.height<=i||Wd(o,s)&&(i=s.height,this.footprintLookup[r]=s,n=0!==s.hiddenFlags);if(i!==Number.NEGATIVE_INFINITY)return{height:i,hidden:n};this.footprintLookup[r]=void 0}}function Mm(e,t,i,n,r,o){const s=Math.pow(2,n.z-r.z);for(let a=0;a1&&(s=e[++o]);const l=Math.abs(a-s.left),c=Math.abs(a-s.right),u=Math.min(l,c);let h;const d=t/i*(n+1);if(s.isDash){const e=n-Math.abs(d);h=Math.sqrt(u*u+e*e)}else h=n-Math.sqrt(u*u+d*d);this.image.data[r+a]=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[e.length-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,s=e[o];for(let i=0;i1&&(s=e[++o]);const n=Math.abs(i-s.left),a=Math.abs(i-s.right),l=Math.min(n,a);this.image.data[r+i]=Math.max(0,Math.min(255,(s.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 Ze("LineAtlas out of space"),null;0===e.length&&e.push(1);let s=0;for(let t=0;te.fqid),this.index=e.index,this.projection=e.projection,this.hasPattern=!1,this.hasCrossSlope=!1,this.patternFeatures=[],this.lineClipsArray=[],this.gradients={},this.layers.forEach(e=>{this.gradients[e.id]={}}),this.layoutVertexArray=new va,this.layoutVertexArray2=new xa,this.patternVertexArray=new xa,this.indexArray=new Fa,this.programConfigurations=new Nl(e.layers,{zoom:e.zoom,lut:e.lut}),this.segments=new hl,this.maxLineLength=0,this.zOffsetVertexArray=new xa,this.stateDependentLayerIds=this.layers.filter(e=>e.isStateDependent()).map(e=>e.id),this.tessellationStep=e.tessellationStep?e.tessellationStep:Nn/64,this.worldview=e.worldview,this.hasAppearances=null}updateFootprints(e,t){}updateAppearances(e,t,i,n){}populate(e,t,i,n){this.hasPattern=od("line",this.layers,this.pixelRatio,t);const r=this.layers[0].layout.get("line-sort-key");this.tileToMeter=yc(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&&Ze(`line-elevation-reference: ground is used for the layer ${this.layerIds[0]} because non-zero line-z-offset value was found.`)}const s=this.layers[0].layout.get("line-cross-slope");this.hasCrossSlope="offset"===this.elevationType&&void 0!==s;const a=[];for(const{feature:o,id:s,index:l,sourceLayerIndex:c}of e){const e=this.layers[0]._featureFilter.needGeometry,u=Ic(o,e);if(!this.layers[0]._featureFilter.filter(new Es(this.zoom,{worldview:this.worldview,activeFloors:t.activeFloors}),u,i))continue;const h=r?r.evaluate(u,{},i):void 0,d={id:s,properties:o.properties,type:o.type,sourceLayerIndex:c,index:l,geometry:e?u.geometry:Bc(o,i,n),patterns:{},sortKey:h};a.push(d)}r&&a.sort((e,t)=>e.sortKey-t.sortKey);const{lineAtlas:l,featureIndex:c}=t,u=this.addConstantDashes(l);for(const n of a){const{geometry:r,index:o,sourceLayerIndex:s}=n;if(u&&this.addFeatureDashes(n,l),this.hasPattern){const e=sd("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);c.insert(e[o].feature,r,o,s,this.index)}}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 s,a;if("constant"===r.kind){if(s=r.value,!s)continue}else s=r.evaluate({zoom:i},e);a="constant"===o.kind?o.value:o.evaluate({zoom:i},e),t.addDash(s,a),e.patterns[n.id]=[t.getKey(s,a)]}}update(e,t,i,n,r,o,s,a){this.programConfigurations.updatePaintArrays(e,t,r,i,n,o,s,a)}addFeatures(e,t,i,n,r,o){for(const e of this.patternFeatures)this.addFeature(e,e.geometry,e.index,t,i,n,o)}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,Om)),0!==this.patternVertexArray.length&&(this.patternVertexBuffer=e.createVertexBuffer(this.patternVertexArray,Um)),!this.zOffsetVertexBuffer&&this.zOffsetVertexArray.length>0&&(this.zOffsetVertexBuffer=e.createVertexBuffer(this.zOffsetVertexArray,Fm.members,!0)),this.layoutVertexBuffer=e.createVertexBuffer(this.layoutVertexArray,km),this.indexBuffer=e.createIndexBuffer(this.indexArray)),this.programConfigurations.upload(e),this.uploaded=!0}destroy(){this.layoutVertexBuffer&&(this.zOffsetVertexBuffer&&this.zOffsetVertexBuffer.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&&e.properties.hasOwnProperty(i)&&e.properties.hasOwnProperty(n))return{start:+e.properties[i],end:+e.properties[n]}}addFeature(e,t,i,n,r,o,s,a){const l=this.layers[0].layout,c=l.get("line-join").evaluate(e,{}),u=l.get("line-cap").evaluate(e,{}),h=l.get("line-miter-limit"),d=l.get("line-round-limit");this.lineClips=this.lineFeatureClips(e),this.lineFeature=e;const p=!(!e.properties||!e.properties.hasOwnProperty("mapbox_line_metrics"))&&e.properties.mapbox_line_metrics;this.zOffsetValue=l.get("line-z-offset").value;const f=this.layers[0].paint.get("line-width").value;if("constant"!==f.kind&&!1===f.isLineProgressConstant&&(this.variableWidthValue=f),"road"===this.elevationType){const i=this.layoutVertexArray.length;if(!this.addElevatedRoadFeature(e,t,n,a,c,u,h,d)){const[r,o]=this.clipRuntimeLinesToTile(t,1);for(let t=0;t0?s.parentIndex:null)}this.fillNonElevatedRoadSegment(i)}}else for(let i=0;i0?i:null);this.programConfigurations.populatePaintArrays(this.layoutVertexArray.length,e,i,r,o,n,s,void 0,this.worldview)}computeSegNextDir(e,t){return e.nextPoint.sub(t.at(-2)).unit()}computeSegPrevDir(e,t){return t[1].sub(e.prevPoint).unit()}clipLinesToTile(e,t){return Fp(e,-t,-t,Nn+t,Nn+t)}clipRuntimeLinesToTile(e,t){const i=[];return[Fp(e,-t,-t,Nn+t,Nn+t,i),i]}addElevatedRoadFeature(e,t,i,n,r,o,s,a){const l=[],c=tu.getElevationFeature(e,n);if(c){const e=this.clipLinesToTile(t,1),n=this.prepareElevatedLines(e,c,i);for(const e of n)l.push({geometry:e,elevation:c,elevationTileID:i,segment:{progress:{min:0,max:1},nextDir:void 0,prevDir:void 0}})}if(0===l.length)return!1;for(const t of l){const n=this.layoutVertexArray.length;this.addLine(t.geometry,e,i,r,o,s,a);const l=new iu(i,t.elevationTileID);if(t.elevation)for(let e=n;e>1,this.layoutVertexArray.int16[6*e+1]>>1),n=l.pointElevation(i,t.elevation,.05);this.updateHeightRange(n),this.zOffsetVertexArray.emplaceBack(n,0,0)}else this.fillNonElevatedRoadSegment(n)}return!0}prepareElevatedLines(e,t,i){if(null!=t.constantHeight)return e;const n=[],r=1/yc(i);for(const i of e)kp(i,new Yc(t,r),0,n);return n}fillNonElevatedRoadSegment(e){for(let t=e;t0,h=a&&a.progress.max<1;if(this.lineClips){let i={min:this.lineClips.start,max:this.lineClips.end},n=1;if(a){const e=this.lineClips.end-this.lineClips.start;i=function(e,t,i){return{min:ot(e.min,t,i),max:ot(e.max,t,i)}}(a.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=2&&e[p-1].equals(e[p-2]);)p--;let f=0;for(;f0,M=this.overscaling<=16?15*Nn/(512*this.overscaling):0;if(i&&"round"===a)if(Co&&(a="bevel"),"bevel"===a&&(C>2&&(a="flipbevel"),C2*M){const t=g.sub(g.sub(_)._mult(M/e)._round());this.updateDistance(_,t),this.addCurrentVertex(t,y,0,0,m,w),_=t}this.updateDistance(_,g),T._mult(C),this.addCurrentVertex(g,T,0,0,m,w);const t=g.dist(A);if(t>2*M){const e=g.add(A.sub(g)._mult(M/t)._round());this.updateDistance(g,e),this.addCurrentVertex(e,v,0,0,m,w),g=e}}else T._mult(C),this.addCurrentVertex(g,T,0,0,m,w);else if("flipbevel"===a){if(C>100)T=v.mult(-1);else{const e=C*y.add(v).mag()/y.sub(v).mag();T._perp()._mult(e*(I?-1:1))}this.addCurrentVertex(g,T,0,0,m,w),this.addCurrentVertex(g,T.mult(-1),0,0,m,w)}else if("bevel"===a||"fakeround"===a){null!=w&&_&&this.addCurrentVertex(g,b||y,-1,-1,m,w);const e=g.dist(_)<=2*M&&"bevel"!==a,t=T.mult(I?1:-1);t._mult(C);const i=v.mult(I?-1:1),n=y.mult(I?-1:1),r=this.evaluateLineProgressFeatures(this.distance);if(null==w&&(this.addHalfVertex(g,t.x,t.y,!1,!I,0,m,r),e||this.addHalfVertex(g,t.x+2*n.x,t.y+2*n.y,!1,I,0,m,r)),"fakeround"===a){const e=Math.round(180*S/Math.PI/20);this.addHalfVertex(g,n.x,n.y,!1,I,0,m,r);for(let t=0;t1){this.lineSoFar=e.w;const d=(t.x-e.x)/u,p=(t.y-e.y)/u,f=(t.z-e.z)/u,m=(t.w-e.w)/u;for(let t=1;t=0&&this.e2>=0&&(this.indexArray.emplaceBack(this.e1,this.e2,c),a.primitiveLength++),o?this.e2=c:this.e1=c,null!=l&&this.zOffsetVertexArray.emplaceBack(l.zOffset,l.variableWidth,l.variableWidth)}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 Qm(e,t,i){return e.xi||e.yi}let $m,Zm;function Wm(e,t,i){return t*(Nn/(e.tileSize*Math.pow(2,i-e.tileID.overscaledZ)))}es(Hm,"LineBucket",{omit:["layers","patternFeatures","currentVertex","currentVertexIsOutside"]});const qm=(e,t,i)=>(1-i)*e+i*t;function Km(e,t){return 1/Wm(e,1,t.tileZoom)}function Xm(e,t,i,n){return e.translatePosMatrix(n||t.tileID.projMatrix,t,i.paint.get("line-translate"),i.paint.get("line-translate-anchor"))}const Jm=e=>{const t=[];Ym(e)&&t.push("RENDER_LINE_DASH"),e.paint.get("line-gradient")&&t.push("RENDER_LINE_GRADIENT");const i=e.paint.get("line-trim-offset");0===i[0]&&0===i[1]||t.push("RENDER_LINE_TRIM_OFFSET"),0!==e.paint.get("line-border-width").constantOr(1)&&t.push("RENDER_LINE_BORDER");const n="none"===e.layout.get("line-join").constantOr("miter"),r=!!e.paint.get("line-pattern").constantOr(1);return n&&r&&t.push("LINE_JOIN_NONE"),t};function Ym(e){const t=e.paint.get("line-dasharray").value;return"constant"!==t.kind||t.value}let eg;const tg=()=>eg||(eg={layout:$m||($m=new Os({"line-cap":new ks(zs.layout_line["line-cap"]),"line-join":new ks(zs.layout_line["line-join"]),"line-miter-limit":new Fs(zs.layout_line["line-miter-limit"]),"line-round-limit":new Fs(zs.layout_line["line-round-limit"]),"line-sort-key":new ks(zs.layout_line["line-sort-key"]),"line-z-offset":new ks(zs.layout_line["line-z-offset"]),"line-elevation-reference":new Fs(zs.layout_line["line-elevation-reference"]),"line-cross-slope":new Fs(zs.layout_line["line-cross-slope"]),visibility:new Fs(zs.layout_line.visibility),"line-width-unit":new Fs(zs.layout_line["line-width-unit"])})),paint:Zm||(Zm=new Os({"line-opacity":new ks(zs.paint_line["line-opacity"]),"line-color":new ks(zs.paint_line["line-color"]),"line-translate":new Fs(zs.paint_line["line-translate"]),"line-translate-anchor":new Fs(zs.paint_line["line-translate-anchor"]),"line-width":new ks(zs.paint_line["line-width"]),"line-gap-width":new ks(zs.paint_line["line-gap-width"]),"line-offset":new ks(zs.paint_line["line-offset"]),"line-blur":new ks(zs.paint_line["line-blur"]),"line-dasharray":new ks(zs.paint_line["line-dasharray"]),"line-pattern":new ks(zs.paint_line["line-pattern"]),"line-pattern-cross-fade":new Fs(zs.paint_line["line-pattern-cross-fade"]),"line-gradient":new Ds(zs.paint_line["line-gradient"]),"line-trim-offset":new Fs(zs.paint_line["line-trim-offset"]),"line-trim-fade-range":new Fs(zs.paint_line["line-trim-fade-range"]),"line-trim-color":new Fs(zs.paint_line["line-trim-color"]),"line-emissive-strength":new Fs(zs.paint_line["line-emissive-strength"]),"line-border-width":new ks(zs.paint_line["line-border-width"]),"line-border-color":new ks(zs.paint_line["line-border-color"]),"line-occlusion-opacity":new Fs(zs.paint_line["line-occlusion-opacity"]),"line-color-use-theme":new ks({type:"string",default:"default","property-type":"data-driven"}),"line-gradient-use-theme":new ks({type:"string",default:"default","property-type":"data-driven"}),"line-trim-color-use-theme":new ks({type:"string",default:"default","property-type":"data-driven"}),"line-border-color-use-theme":new ks({type:"string",default:"default","property-type":"data-driven"})}))},eg);class ig extends ks{possiblyEvaluate(e,t){return t=new Es(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=Object.assign({},t,{zoom:Math.floor(t.zoom)}),super.evaluate(e,t,i,n)}}let ng;function rg(e,t){return t>0?t+2*e:e}const og=ha([{name:"a_pos_offset",components:4,type:"Int16"},{name:"a_tex_size",components:4,type:"Uint16"},{name:"a_pixeloffset",components:4,type:"Int16"}],4),sg=ha([{name:"a_globe_anchor",components:3,type:"Int16"},{name:"a_globe_normal",components:3,type:"Float32"}],4),ag=ha([{name:"a_projected_pos",components:4,type:"Float32"}],4);ha([{name:"a_fade_opacity",components:1,type:"Uint32"}],4);const lg=ha([{name:"a_auto_z_offset",components:1,type:"Float32"}],4),cg=ha([{name:"a_x_axis",components:3,type:"Float32"},{name:"a_y_axis",components:3,type:"Float32"}]),ug=ha([{name:"a_texb",components:2,type:"Uint16"}]),hg=ha([{name:"a_placed",components:2,type:"Uint8"},{name:"a_shift",components:2,type:"Float32"},{name:"a_elevation_from_sea",components:2,type:"Float32"}]),dg=ha([{name:"a_size_scale",components:1,type:"Float32"},{name:"a_padding",components:2,type:"Float32"},{name:"a_auto_z_offset",components:1,type:"Float32"}]);ha([{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 pg=ha([{name:"a_pos",components:3,type:"Int16"},{name:"a_anchor_pos",components:2,type:"Int16"},{name:"a_extrude",components:2,type:"Int16"}],4),fg=ha([{name:"a_pos_2f",components:2,type:"Float32"},{name:"a_radius",components:1,type:"Float32"},{name:"a_flags",components:2,type:"Int16"}],4);ha([{name:"triangle",components:3,type:"Uint16"}]),ha([{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"}]),ha([{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"}]),ha([{type:"Float32",name:"offsetX"}]),ha([{type:"Int16",name:"x"},{type:"Int16",name:"y"}]);var mg=24;function gg(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()),Ts.applyArabicShaping&&(e=Ts.applyArabicShaping(e)),e}(e.text,t,i)}),e}const _g={"!":"︕","#":"#",$:"$","%":"%","&":"&","(":"︵",")":"︶","*":"*","+":"+",",":"︐","-":"︲",".":"・","/":"/",":":"︓",";":"︔","<":"︿","=":"=",">":"﹀","?":"︖","@":"@","[":"﹇","\\":"\","]":"﹈","^":"^",_:"︳","`":"`","{":"︷","|":"―","}":"︸","~":"~","¢":"¢","£":"£","¥":"¥","¦":"¦","¬":"¬","¯":" ̄","–":"︲","—":"︱","‘":"﹃","’":"﹄","“":"﹁","”":"﹂","…":"︙","‧":"・","₩":"₩","、":"︑","。":"︒","〈":"︿","〉":"﹀","《":"︽","》":"︾","「":"﹁","」":"﹂","『":"﹃","』":"﹄","【":"︻","】":"︼","〔":"︹","〕":"︺","〖":"︗","〗":"︘","!":"︕","(":"︵",")":"︶",",":"︐","-":"︲",".":"・",":":"︓",";":"︔","<":"︿",">":"﹀","?":"︖","[":"﹇","]":"﹈","_":"︳","{":"︷","|":"―","}":"︸","⦅":"︵","⦆":"︶","。":"︒","「":"﹁","」":"﹂","←":"↑","→":"↓"};function Ag(e){return"︶"===e||"﹈"===e||"︸"===e||"﹄"===e||"﹂"===e||"︾"===e||"︼"===e||"︺"===e||"︘"===e||"﹀"===e||"︐"===e||"︓"===e||"︔"===e||"`"===e||" ̄"===e||"︑"===e||"︒"===e}function yg(e){return"︵"===e||"﹇"===e||"︷"===e||"﹃"===e||"﹁"===e||"︽"===e||"︻"===e||"︹"===e||"︗"===e||"︿"===e}const vg=4294967296,xg=1/vg,bg="undefined"==typeof TextDecoder?null:new TextDecoder("utf-8");let wg=class{constructor(e=new Uint8Array(16)){this.buf=ArrayBuffer.isView(e)?e:new Uint8Array(e),this.dataView=new DataView(this.buf.buffer),this.pos=0,this.type=0,this.length=this.buf.length}readFields(e,t,i=this.length){for(;this.pos>3,r=this.pos;this.type=7&i,e(n,t,this),this.pos===r&&this.skip(i)}return t}readMessage(e,t){return this.readFields(e,t,this.readVarint()+this.pos)}readFixed32(){const e=this.dataView.getUint32(this.pos,!0);return this.pos+=4,e}readSFixed32(){const e=this.dataView.getInt32(this.pos,!0);return this.pos+=4,e}readFixed64(){const e=this.dataView.getUint32(this.pos,!0)+this.dataView.getUint32(this.pos+4,!0)*vg;return this.pos+=8,e}readSFixed64(){const e=this.dataView.getUint32(this.pos,!0)+this.dataView.getInt32(this.pos+4,!0)*vg;return this.pos+=8,e}readFloat(){const e=this.dataView.getFloat32(this.pos,!0);return this.pos+=4,e}readDouble(){const e=this.dataView.getFloat64(this.pos,!0);return this.pos+=8,e}readVarint(e){const t=this.buf;let i,n;return n=t[this.pos++],i=127&n,n<128?i:(n=t[this.pos++],i|=(127&n)<<7,n<128?i:(n=t[this.pos++],i|=(127&n)<<14,n<128?i:(n=t[this.pos++],i|=(127&n)<<21,n<128?i:(n=t[this.pos],i|=(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 Tg(e,r,t);if(o=n[i.pos++],r|=(127&o)<<3,o<128)return Tg(e,r,t);if(o=n[i.pos++],r|=(127&o)<<10,o<128)return Tg(e,r,t);if(o=n[i.pos++],r|=(127&o)<<17,o<128)return Tg(e,r,t);if(o=n[i.pos++],r|=(127&o)<<24,o<128)return Tg(e,r,t);if(o=n[i.pos++],r|=(1&o)<<31,o<128)return Tg(e,r,t);throw new Error("Expected varint not more than 10 bytes")}(i,e,this)))))}readVarint64(){return this.readVarint(!0)}readSVarint(){const e=this.readVarint();return e%2==1?(e+1)/-2:e/2}readBoolean(){return Boolean(this.readVarint())}readString(){const e=this.readVarint()+this.pos,t=this.pos;return this.pos=e,e-t>=12&&bg?bg.decode(this.buf.subarray(t,e)):function(e,t,i){let n="",r=t;for(;r239?4:t>223?3:t>191?2:1;if(r+c>i)break;1===c?t<128&&(l=t):2===c?(o=e[r+1],128==(192&o)&&(l=(31&t)<<6|63&o,l<=127&&(l=null))):3===c?(o=e[r+1],s=e[r+2],128==(192&o)&&128==(192&s)&&(l=(15&t)<<12|(63&o)<<6|63&s,(l<=2047||l>=55296&&l<=57343)&&(l=null))):4===c&&(o=e[r+1],s=e[r+2],a=e[r+3],128==(192&o)&&128==(192&s)&&128==(192&a)&&(l=(15&t)<<18|(63&o)<<12|(63&s)<<6|63&a,(l<=65535||l>=1114112)&&(l=null))),null===l?(l=65533,c=1):l>65535&&(l-=65536,n+=String.fromCharCode(l>>>10&1023|55296),l=56320|1023&l),n+=String.fromCharCode(l),r+=c}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.pos127;);else if(2===t)this.pos=this.readVarint()+this.pos;else if(5===t)this.pos+=4;else{if(1!==t)throw new Error(`Unimplemented type: ${t}`);this.pos+=8}}writeTag(e,t){this.writeVarint(e<<3|t)}realloc(e){let t=this.length||16;for(;t268435455||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;o55295&&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&&Eg(t,i,this),this.pos=t-1,this.writeVarint(i),this.pos+=i}writeFloat(e){this.realloc(4),this.dataView.setFloat32(this.pos,e,!0),this.pos+=4}writeDouble(e){this.realloc(8),this.dataView.setFloat64(this.pos,e,!0),this.pos+=8}writeBytes(e){const t=e.length;this.writeVarint(t),this.realloc(t);for(let i=0;i=128&&Eg(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,Cg,t)}writePackedSVarint(e,t){t.length&&this.writeMessage(e,Sg,t)}writePackedBoolean(e,t){t.length&&this.writeMessage(e,Mg,t)}writePackedFloat(e,t){t.length&&this.writeMessage(e,Bg,t)}writePackedDouble(e,t){t.length&&this.writeMessage(e,Ig,t)}writePackedFixed32(e,t){t.length&&this.writeMessage(e,Pg,t)}writePackedSFixed32(e,t){t.length&&this.writeMessage(e,Rg,t)}writePackedFixed64(e,t){t.length&&this.writeMessage(e,Lg,t)}writePackedSFixed64(e,t){t.length&&this.writeMessage(e,Fg,t)}writeBytesField(e,t){this.writeTag(e,2),this.writeBytes(t)}writeFixed32Field(e,t){this.writeTag(e,5),this.writeFixed32(t)}writeSFixed32Field(e,t){this.writeTag(e,5),this.writeSFixed32(t)}writeFixed64Field(e,t){this.writeTag(e,1),this.writeFixed64(t)}writeSFixed64Field(e,t){this.writeTag(e,1),this.writeSFixed64(t)}writeVarintField(e,t){this.writeTag(e,0),this.writeVarint(t)}writeSVarintField(e,t){this.writeTag(e,0),this.writeSVarint(t)}writeStringField(e,t){this.writeTag(e,2),this.writeString(t)}writeFloatField(e,t){this.writeTag(e,5),this.writeFloat(t)}writeDoubleField(e,t){this.writeTag(e,1),this.writeDouble(t)}writeBooleanField(e,t){this.writeVarintField(e,+t)}};function Tg(e,t,i){return i?4294967296*t+(e>>>0):4294967296*(t>>>0)+(e>>>0)}function Eg(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);for(let t=i.pos-1;t>=e;t--)i.buf[t+n]=i.buf[t]}function Cg(e,t){for(let i=0;i=0&&i>=e&&Hg[this.text.charCodeAt(i)];i--)t--;this.text=this.text.substring(e,t),this.sectionIndex=this.sectionIndex.slice(e,t)}substring(e,t){const i=new jg;return i.text=this.text.substring(e,t),i.sectionIndex=this.sectionIndex.slice(e,t),i.sections=this.sections,i}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(Vg.forText(e.scale,e.fontStack||t));const i=this.sections.length-1;for(let t=0;t=63743?null:++this.imageSectionID:(this.imageSectionID=57344,this.imageSectionID)}}function Gg(e,t,i,n,r,o,s,a,l,c,u,h,d,p,f,m=1){const g=jg.fromFeature(e,r,m);h===Ng.vertical&&g.verticalizePunctuation(d);let _=[];const A=function(e,t,i,n,r,o){if(!e)return[];const s=[],a=function(e,t,i,n,r,o){let s=0;for(let i=0;i=0;let c=0;for(let i=0;i0&&o>x&&(x=o)}else{const e=i[a.fontStack];if(!e)continue;e[m]&&(T=e[m]);const n=t[a.fontStack];if(!n)continue;const o=n.glyphs[m];if(!o)continue;if(y=o.metrics,C=8203!==m?mg:0,g){const e=void 0!==n.ascender?Math.abs(n.ascender):0,t=void 0!==n.descender?Math.abs(n.descender):0,i=(e+t)*_;b-i/2;){if(s--,s<0)return!1;a-=e[s].dist(o),o=e[s]}a+=e[s].dist(e[s+1]),s++;const l=[];let c=0;for(;an;)c-=l.shift().angleDelta;if(c>r)return!1;s++,a+=t.dist(i)}return!0}function h_(e){let t=0;for(let i=0;ic){const u=(c-l)/o,h=di(n.x,r.x,u),d=di(n.y,r.y,u),p=new c_(h,d,0,r.angleTo(n),i);return!s||u_(e,p,a,s,t)?p:void 0}l+=o}}function m_(e,t,i,n,r,o,s,a,l){const c=d_(n,o,s),u=p_(n,r),h=u*s,d=0===e[0].x||e[0].x===l||0===e[0].y||e[0].y===l;return t-h=0&&_=0&&A=0&&d+c<=u){const i=new c_(_,A,0,m,t);n&&!u_(e,i,o,n,r)||p.push(i)}}h+=f}return a||p.length||s||(p=g_(e,h/2,i,n,r,o,s,!0,l)),p}function __(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&&e1?s-1:s,wh.copy(n.data,l,{x:0,y:0},{x:a,y:c},n.data,i),wh.copy(n.data,l,{x:0,y:h-s},{x:a,y:c-s},{width:u,height:s},i),wh.copy(n.data,l,{x:0,y:0},{x:a,y:c+h},{width:u,height:s},i),wh.copy(n.data,l,{x:u-s,y:0},{x:a-s,y:c},{width:s,height:h},i),wh.copy(n.data,l,{x:0,y:0},{x:a+u,y:c},{width:s,height:h},i),wh.copy(n.data,l,{x:u-s,y:h-s},{x:a-s,y:c-s},{width:s,height:s},i),wh.copy(n.data,l,{x:0,y:h-s},{x:a+u,y:c-s},{width:s,height:s},i),wh.copy(n.data,l,{x:0,y:0},{x:a+u,y:c+h},{width:s,height:s},i),wh.copy(n.data,l,{x:u-s,y:0},{x:a-s,y:c+h},{width:s,height:s},i)}this.lut=i,this.image=l,this.iconPositions=n,this.patternPositions=r}addImages(e,t,i,n){for(const[r,o]of e.entries()){const{bin:e,imagePosition:s,imageVariant:a}=v_(r,o,i);t.set(r,s),n.push(e),o.hasRenderCallback&&this.haveRenderCallbacks.push(a.id)}}patchUpdatedImages(e,t,i){this.haveRenderCallbacks=this.haveRenderCallbacks.filter(t=>e.hasImage(t,i)),e.dispatchRenderCallbacks(this.haveRenderCallbacks,i);for(const n of e.getUpdatedImages(i)){for(const r of this.iconPositions.keys()){const o=Oi.parse(r);if(ri.isEqual(o.id,n)){const o=e.getImage(n,i);this.patchUpdatedImage(this.iconPositions.get(r),o,t,null)}}for(const r of this.patternPositions.keys()){const o=Oi.parse(r);if(ri.isEqual(o.id,n)){const o=e.getImage(n,i);this.patchUpdatedImage(this.patternPositions.get(r),o,t,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,s=e.sdf;if(this.lut||s){const e={width:t.data.width,height:t.data.height},a=new wh(e);wh.copy(t.data,a,{x:0,y:0},{x:0,y:0},e,n,s),i.update(a,{position:{x:r,y:o}})}else i.update(t.data,{position:{x:r,y:o}})}}es(y_,"ImagePosition"),es(x_,"ImageAtlas");const b_=1e20;function w_(e,t,i,n,r,o,s,a,l){for(let c=t;c-1);l++,o[l]=a,s[l]=c,s[l+1]=b_}for(let a=0,l=0;a{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 s=Math.floor(t/256);if(256*s>65535)return Ze("glyphs > 65535 not supported"),void i(null,{stack:e,id:t,glyph:o});if(r.ranges[s])return void i(null,{stack:e,id:t,glyph:o});let a=r.requests[s];a||(a=r.requests[s]=[],S_.loadGlyphRange(e,s,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[s]=!0}for(const i of a)i(e,t);delete r.requests[s]})),a.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!==C_.none&&(this.localGlyphMode===C_.all?!!this.localFontFamily:!!this.localFontFamily&&(os["CJK Unified Ideographs"](e)||os["Hangul Syllables"](e)||os.Hiragana(e)||os.Katakana(e)||os["CJK Symbols and Punctuation"](e)||os["CJK Unified Ideographs Extension A"](e)||os["CJK Unified Ideographs Extension B"](e)||os.Osage(e)))}_tinySDF(e,t,i){const n=this.localFontFamily;if(!n||!this._doesCharSupportLocalGlyph(i))return;let r=e.tinySDF;if(!r){let i="400";/bold/i.test(t)?i="900":/medium/i.test(t)?i="500":/light/i.test(t)&&(i="200"),r=e.tinySDF=new S_.TinySDF({fontFamily:n,fontWeight:i,fontSize:24*E_,buffer:3*E_,radius:8*E_}),r.fontWeight=i}if(this.localGlyphs[r.fontWeight][i])return this.localGlyphs[r.fontWeight][i];const o=String.fromCodePoint(i),{data:s,width:a,height:l,glyphWidth:c,glyphHeight:u,glyphLeft:h,glyphTop:d,glyphAdvance:p}=r.draw(o);return this.localGlyphs[r.fontWeight][i]={id:i,bitmap:new bh({width:a,height:l},s),metrics:{width:c/E_,height:u/E_,left:h/E_,top:d/E_-27,advance:p/E_,localGlyph:!0}}}}S_.loadGlyphRange=function(e,t,i,n,r){const o=256*t,s=o+255,a=n.transformRequest(n.normalizeGlyphsURL(i).replace("{fontstack}",e).replace("{range}",`${o}-${s}`),kt.Glyphs);Ut(a,(e,t)=>{if(e)r(e);else if(t){const e={},i=function(e){return new wg(e).readFields(Dg,{})}(t);for(const t of i.glyphs)e[t.id]=t;r(null,{glyphs:e,ascender:i.ascender,descender:i.descender})}})},S_.TinySDF=class{constructor({fontSize:e=24,buffer:t=3,radius:i=8,cutoff:n=.25,fontFamily:r="sans-serif",fontWeight:o="normal",fontStyle:s="normal",lang:a=null}={}){this.buffer=t,this.cutoff=n,this.radius=i,this.lang=a;const l=this.size=e+4*t,c=this._createCanvas(l),u=this.ctx=c.getContext("2d",{willReadFrequently:!0});u.font=`${s} ${o} ${e}px ${r}`,u.textBaseline="alphabetic",u.textAlign="left",u.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){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),s=Math.ceil(i),a=Math.max(0,Math.min(this.size-this.buffer,Math.ceil(o-r))),l=Math.min(this.size-this.buffer,s+Math.ceil(n)),c=a+2*this.buffer,u=l+2*this.buffer,h=Math.max(c*u,0),d=new Uint8ClampedArray(h),p={data:d,width:c,height:u,glyphWidth:a,glyphHeight:l,glyphTop:s,glyphLeft:0,glyphAdvance:t};if(0===a||0===l)return p;const{ctx:f,buffer:m,gridInner:g,gridOuter:_}=this;this.lang&&(f.lang=this.lang),f.clearRect(m,m,a,l),f.fillText(e,m,m+s);const A=f.getImageData(m,m,a,l);_.fill(b_,0,h),g.fill(0,0,h);for(let e=0;e0?e*e:0,g[n]=e<0?e*e:0}}w_(_,0,0,c,u,c,this.f,this.v,this.z),w_(g,m,m,a,l,c,this.f,this.v,this.z);for(let e=0;e{const d=k_(n.stretch-A,y,u,e.left*r),p=D_(n.fixed-b,w,n.stretch,f),g=k_(o.stretch-v,x,h,e.top*r),_=D_(o.fixed-T,E,o.stretch,m),C=k_(l.stretch-A,y,u,e.left*r),S=D_(l.fixed-b,w,l.stretch,f),B=k_(c.stretch-v,x,h,e.top*r),I=D_(c.fixed-T,E,c.stretch,m),M=new Te(d,g),P=new Te(C,g),R=new Te(C,B),L=new Te(d,B),F=new Te(p/a,_/a),k=new Te(S/a,I/a),D=t*Math.PI/180;if(D){const e=Math.sin(D),t=Math.cos(D),i=[t,-e,e,t];M._matMult(i),P._matMult(i),L._matMult(i),R._matMult(i)}const O=n.stretch+n.fixed,z=l.stretch+l.fixed,U=o.stretch+o.fixed,N=c.stretch+c.fixed,V=e.imageSecondary;return{tl:M,tr:P,bl:L,br:R,texPrimary:{x:s.paddedRect.x+B_+O,y:s.paddedRect.y+B_+U,w:z-O,h:N-U},texSecondary:V?{x:V.paddedRect.x+B_+O,y:V.paddedRect.y+B_+U,w:z-O,h:N-U}:void 0,writingMode:void 0,glyphOffset:[0,0],sectionIndex:0,pixelOffsetTL:F,pixelOffsetBR:k,minFontScaleX:w/a/u,minFontScaleY:E/a/h,isSDF:i}};if(n&&(s.stretchX||s.stretchY)){const e=L_(d,g,f),t=L_(p,_,m);for(let i=0;io)&&(o=t.x),(!e||t.y>s)&&(s=t.y)}const l=Math.min(o-n,s-r);let c=l/2;const u=new Un([],U_);if(0===l)return new Te(n,r);for(let t=n;th.d||!h.d)&&(h=n,i&&console.log("found best %d after %d probes",Math.round(1e4*n.d)/1e4,d)),n.max-h.d<=t||(c=n.h/2,u.push(new N_(n.p.x-c,n.p.y-c,c,e)),u.push(new N_(n.p.x+c,n.p.y-c,c,e)),u.push(new N_(n.p.x-c,n.p.y+c,c,e)),u.push(new N_(n.p.x+c,n.p.y+c,c,e)),d+=4)}return i&&(console.log(`num probes: ${d}`),console.log(`best distance: ${h.d}`)),h.p}function U_(e,t){return t.max-e.max}class N_{constructor(e,t,i,n){this.p=new Te(e,t),this.h=i,this.d=function(e,t){let i=!1,n=1/0;for(let r=0;re.y!=a.y>e.y&&e.x<(a.x-r.x)*(e.y-r.y)/(a.y-r.y)+r.x&&(i=!i),n=Math.min(n,pu(e,r,a))}}return(i?1:-1)*Math.sqrt(n)}(this.p,n),this.max=this.d+this.h*Math.SQRT2}}const V_=Object.keys,j_=Number.POSITIVE_INFINITY,G_=Math.sqrt(2);function H_(e,t,i,n){const r=e.collisionPadding||[0,0,0,0],o={top:e.top-r[1],bottom:e.bottom+r[3],left:e.left-r[0],right:e.right+r[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}(o,n),i&&function(e,t){if(!t)return;const i=Be(t),n=new Te(e.left,e.top),r=new Te(e.right,e.top),o=new Te(e.left,e.bottom),s=new Te(e.right,e.bottom);n._rotateAround(i,new Te(0,0)),r._rotateAround(i,new Te(0,0)),o._rotateAround(i,new Te(0,0)),s._rotateAround(i,new Te(0,0)),e.left=Math.min(n.x,r.x,o.x,s.x),e.right=Math.max(n.x,r.x,o.x,s.x),e.top=Math.min(n.y,r.y,o.y,s.y),e.bottom=Math.max(n.y,r.y,o.y,s.y)}(o,i),t?{top:Math.min(t.top,o.top),bottom:Math.max(t.bottom,o.bottom),left:Math.min(t.left,o.left),right:Math.max(t.right,o.right),scaled:t.scaled||o.scaled}:o}function Q_(e,[t,i]){let n=0,r=0;if(i===j_){t<0&&(t=0);const i=t/G_;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]}function $_(e,t,i,n,r,o,s,a,l,c,u){const h=e.layers[0],d=h.appearances;if(0===d.length)return{iconBBox:null,iconVerticalBBox:null};let p=null,f=null;const m=n.get("icon-rotate").evaluate(r,{},o);t&&(p=H_(t,p,m,s),i)&&(f=H_(i,f,m+90,s));const[g,_]=n.get("icon-size-scale-range"),A=Fe(1,g,_);for(const i of d){const n=i.getUnevaluatedProperties(),d=void 0!==n._values["icon-image"].value,g=void 0!==n._values["icon-size"].value,_=void 0!==n._values["icon-offset"].value,y=void 0!==n._values["icon-rotate"].value;if(d||g||_||y){const v=_?h.getAppearanceValueAndResolveTokens(i,"icon-offset",r,o,[]):null,x=v&&Array.isArray(v)?v:a,b=y?h.getAppearanceValueAndResolveTokens(i,"icon-rotate",r,o,[]):null,w="number"==typeof b?b:m,T=g?h.getAppearanceValueAndResolveTokens(i,"icon-size",r,o,[]):null,E="number"==typeof T?T*l.iconScaleFactor:s;let C=null,S=null,B=null;if(d){const t=h.getAppearanceValueAndResolveTokens(i,"icon-image",r,o,[]);if(t){const i=e.getResolvedImageFromTokens(t),s=n._values["icon-size"],a=q_(i,s_(e.zoom,s,e.worldview),s,o,e.zoom,r,e.pixelRatio,A,e.worldview);B=c.get(a.iconPrimary.toString())}}else t&&(B=t.imagePrimary);B&&(C=e_(B,null,x,u),e.allowVerticalPlacement&&(S=e_(B,null,x,u))),C&&(p=H_(C,p,w,E)),S&&(f=H_(S,f,w+90,E))}}return{iconBBox:p,iconVerticalBBox:f}}function Z_(e,t,i,n,r,o,s,a,l){if(!t||!t.usvg)return;const c=r_(n),u=r_(r),h="both"!==o&&"width"!==o||!i_(n)?1:u.width/c.width,d="both"!==o&&"height"!==o||!n_(n)?1:u.height/c.height;i.scaleSelf(h,d);const p=i.toString();s.set(p,i),a.set(p,t);const{imagePosition:f}=v_(p,t,A_);l.set(p,f)}function W_(e,t,i,n,r,o,s,a,l){if(!e)return;const c=function(e,t,i,n,r,o){if("camera"===e.kind)return e.maxSize;if("composite"===e.kind){const n=t.possiblyEvaluate(new Es(e.maxZoom,{worldview:o}),i).evaluate(r,{},i),s=t.possiblyEvaluate(new Es(e.minZoom,{worldview:o}),i).evaluate(r,{},i);return Math.max(n,s)}return t.possiblyEvaluate(new Es(n,{worldview:o})).evaluate(r,{},i)}(t,i,n,r,o,l);return e.scaleSelf(c*a*s)}function q_(e,t,i,n,r,o,s,a,l){return{iconPrimary:W_(e.getPrimary(),t,i,n,r,o,s,a,l),iconSecondary:W_(e.getSecondary(),t,i,n,r,o,s,a,l)}}function K_(e,t,i){if(!t)return;const n=i.get(e.toString()),r=i.get(t.toString());n&&r&&(n.paddedRect.w===r.paddedRect.w&&n.paddedRect.h===r.paddedRect.h||Ze(`Mismatch in icon variant sizes: ${e.toString()} and ${t.toString()}`),n.usvg!==r.usvg&&Ze(`Mismatch in icon variant image types: ${e.id} and ${t.id}`))}function X_(e,t,i,n){if(!e)return;const r=t.get(i.toString());if(e.imagePrimary=r,n){const i=t.get(n.toString());e.imageSecondary=i}}function J_(e,t){for(const i in e.horizontal)Y_(e.horizontal[i],t);Y_(e.vertical,t)}function Y_(e,t){if(e)for(const i of e.positionedLines)for(const e of i.positionedGlyphs)if(null!==e.image){const i=e.image.toString();e.rect=t.get(i).paddedRect}}function eA(e){switch(e){case"right":case"top-right":case"bottom-right":return"right";case"left":case"top-left":case"bottom-left":return"left"}return"center"}function tA(e,t,i,n,r,o,s,a,l){const c=sA(o.horizontal)||o.vertical,u=i.get("icon-text-fit-padding").evaluate(n,{},r);let h,d=t;return t&&"none"!==l&&(e.allowVerticalPlacement&&o.vertical&&(h=t_(t,o.vertical,l,u,a,s)),c&&(d=t_(t,c,l,u,a,s))),{defaultShapedIcon:d,verticallyShapedIcon:h}}function iA(e,t,i,n,r,o,s,a,l,c,u,h,d,p,f,m,g,_,A,y,v,x){let b=s.textMaxSize.evaluate(t,{},d);void 0===b?b=a*s.textScaleFactor:b*=s.textScaleFactor;const w=e.layers[0].layout,T=mg,E=a*s.textScaleFactor/T,C=sA(i.horizontal)||i.vertical;if("none"!==g&&e.appearanceFeatureData&&t.index18&&k>2&&(k>>=1),Math.max(Nn/(512*k),1)*w.get("symbol-spacing")),M=w.get("text-padding")*e.tilePixelRatio,P=w.get("icon-padding")*e.tilePixelRatio,R=Be(w.get("text-max-angle")),L="map"===w.get("icon-rotation-alignment")&&"point"!==y,F=I/2;var k;!1===e.hasAnyIconTextFit&&"none"!==g&&(e.hasAnyIconTextFit=!0);const D=t.properties?+t.properties[Oc]:null,O=D&&e.elevationFeatureIdToIndex?e.elevationFeatureIdToIndex.get(D):65535,z=(a,l,y)=>{if(l.x<0||l.x>=Nn||l.y<0||l.y>=Nn)return;let b=null;if(S){const{x:e,y:t,z:i}=p.projectTilePoint(l.x,l.y,y);b={anchor:new c_(e,t,i,0,void 0),up:p.upVector(y,l.x,l.y)}}!function(e,t,i,n,r,o,s,a,l,c,u,h,d,p,f,m,g,_,A,y,v,x,b,w,T,E,C,S,B,I,M){const P=e.addToLineVertexArray(t,n);let R,L,F,k,D,O,z,U=0,N=0,V=0,j=0,G=-1,H=-1;const Q={};let $=Jt("");const Z=i?i.anchor:t,W="none"!==S;let q=0,K=0;if(void 0===l._unevaluatedLayout.getValue("text-radial-offset")){const e=l.layout.get("text-offset").evaluate(v,{},T);q=e[0]*mg,K=e[1]*mg}else q=l.layout.get("text-radial-offset").evaluate(v,{},T)*mg,K=j_;if(e.allowVerticalPlacement&&r.vertical){const e=r.vertical;if(f)O=lA(e),a&&(z=lA(a));else{const i=l.layout.get("text-rotate").evaluate(v,{},T)+90;F=aA(c,Z,t,u,h,d,e,p,i,m),a&&(k=aA(c,Z,t,u,h,d,a,_,i,null,M))}}if(o){const n=e.iconSizeData,r=l.layout.get("icon-rotate").evaluate(v,{},T),s=M_(o,r,b,W,x.iconScaleFactor),p=a?M_(a,r,b,W,x.iconScaleFactor):void 0;L=aA(c,Z,t,u,h,d,o,_,r,null,I);const f=function(e,t,i,n,r,o,s,a){const l=e.layers[0],c=l.appearances;let u=t.length;if(i&&(u=Math.max(u,i.length)),0===c.length)return u;const[h,d]=n.get("icon-size-scale-range"),p=Fe(1,h,d);for(const t of c){const i=t.getUnevaluatedProperties();if(void 0!==i._values["icon-image"].value){const n=l.getAppearanceValueAndResolveTokens(t,"icon-image",r,o,[]);if(n){const t=e.getResolvedImageFromTokens(n);if(t){const n=i._values["icon-size"],l=q_(t,s_(e.zoom,n,e.worldview),n,o,e.zoom,r,e.pixelRatio,p,e.worldview),c=s.get(l.iconPrimary.toString());u=Math.max(u,P_(c,a))}}}}return u}(e,s,p,l.layout,v,T,e.iconAtlasPositions,W);U=4*f;let m=null;"source"===n.kind?(m=[o_*l.layout.get("icon-size").evaluate(v,{},T)*x.iconScaleFactor],m[0]>rA&&Ze(`${e.layerIds[0]}: Value for "icon-size" is >= ${nA}. Reduce your "icon-size".`)):"composite"===n.kind&&(m=[o_*x.compositeIconSizes[0].evaluate(v,{},T)*x.iconScaleFactor,o_*x.compositeIconSizes[1].evaluate(v,{},T)*x.iconScaleFactor],(m[0]>rA||m[1]>rA)&&Ze(`${e.layerIds[0]}: Value for "icon-size" is >= ${nA}. Reduce your "icon-size".`)),e.addSymbols(e.icon,s,m,y,A,v,void 0,i,t,P.lineStartIndex,P.lineLength,-1,w,T,E,C,e.symbolInstances.length,f),G=e.icon.placedSymbolArray.length-1,p&&(N=4*f,e.addSymbols(e.icon,p,m,y,A,v,Ng.vertical,i,t,P.lineStartIndex,P.lineLength,-1,w,T,E,C,e.symbolInstances.length,f),H=e.icon.placedSymbolArray.length-1)}for(const n in r.horizontal){const o=n,a=r.horizontal[o];R||($=Jt(a.text),f?D=lA(a):R=aA(c,Z,t,u,h,d,a,p,l.layout.get("text-rotate").evaluate(v,{},T),m));const g=1===a.positionedLines.length;if(V+=oA(e,i,t,a,s,l,f,v,m,P,r.vertical?Ng.horizontal:Ng.horizontalOnly,g?V_(r.horizontal):[o],Q,G,x,w,T,e.symbolInstances.length,E),g)break}r.vertical&&(j+=oA(e,i,t,r.vertical,s,l,f,v,m,P,Ng.vertical,["vertical"],Q,H,x,w,T,e.symbolInstances.length,E));let X=-1;const J=(e,t)=>e?Math.max(e,t):t;X=J(D,X),X=J(O,X),X=J(z,X);const Y=X>-1?1:0;e.glyphOffsetArray.length>=65535&&Ze("Too many glyphs being rendered in a tile. See https://github.com/mapbox/mapbox-gl-js/issues/2907"),void 0!==v.sortKey&&e.addToSortKeyRanges(e.symbolInstances.length,v.sortKey),e.symbolInstances.emplaceBack(t.x,t.y,Z.x,Z.y,Z.z,Q.right>=0?Q.right:-1,Q.center>=0?Q.center:-1,Q.left>=0?Q.left:-1,Q.vertical>=0?Q.vertical:-1,G,H,$,void 0!==R?R:e.collisionBoxArray.length,void 0!==R?R+1:e.collisionBoxArray.length,void 0!==F?F:e.collisionBoxArray.length,void 0!==F?F+1:e.collisionBoxArray.length,void 0!==L?L:e.collisionBoxArray.length,void 0!==L?L+1:e.collisionBoxArray.length,k||e.collisionBoxArray.length,k?k+1:e.collisionBoxArray.length,u,V,j,U,N,Y,0,q,K,X,0,W?1:0,B)}(e,l,b,a,i,n,o,r,e.layers[0],e.collisionBoxArray,t.index,t.sourceLayerIndex,e.index,M,A,c,0,P,L,_,t,s,u,h,d,f,m,g,O,v,x)};if("line"===y)for(const r of Fp(t.geometry,0,0,Nn,Nn)){const t=m_(r,I,R,i.vertical||C,n,T,B,e.overscaling,Nn);for(const i of t)C&&cA(e,C.text,F,i)||z(r,i,d)}else if("line-center"===y){for(const e of t.geometry)if(e.length>1){const t=f_(e,R,i.vertical||C,n,T,B);t&&z(e,t,d)}}else if("Polygon"===t.type)for(const e of id(t.geometry,0)){const t=z_(e,16);z(e[0],new c_(t.x,t.y,0,0,void 0),d)}else if("LineString"===t.type)for(const e of t.geometry)z(e,new c_(e[0].x,e[0].y,0,0,void 0),d);else if("Point"===t.type)for(const e of t.geometry)for(const t of e)z([t],new c_(t.x,t.y,0,0,void 0),d)}const nA=255,rA=nA*o_;function oA(e,t,i,n,r,o,s,a,l,c,u,h,d,p,f,m,g,_,A){const y=function(e,t,i,n,r,o,s,a){const l=[];if(0===t.positionedLines.length)return l;const c=n.layout.get("text-rotate").evaluate(o,{})*Math.PI/180,u=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 h=Math.abs(t.top-t.bottom);for(const e of t.positionedLines)h-=e.lineOffset;const d=t.positionedLines.length,p=h/d;let f=t.top-i[1];for(let e=0;erA&&Ze(`${e.layerIds[0]}: Value for "text-size" is >= ${nA}. Reduce your "text-size".`)):"composite"===v.kind&&(x=[o_*f.compositeTextSizes[0].evaluate(a,{},g)*f.textScaleFactor,o_*f.compositeTextSizes[1].evaluate(a,{},g)*f.textScaleFactor],(x[0]>rA||x[1]>rA)&&Ze(`${e.layerIds[0]}: Value for "text-size" is >= ${nA}. Reduce your "text-size".`)),e.addSymbols(e.text,y,x,l,s,a,u,t,i,c.lineStartIndex,c.lineLength,p,m,g,A,!1,_,y.length);for(const t of h)d[t]=e.text.placedSymbolArray.length-1;return 4*y.length}function sA(e){for(const t in e)return e[t];return null}function aA(e,t,i,n,r,o,s,a,l,c,u){let h,d,p,f;if(h=u?u.top:s.top,d=u?u.bottom:s.bottom,p=u?u.left:s.left,f=u?u.right:s.right,Yg(s)&&s.collisionPadding){const e=s.collisionPadding;p-=e[0],h-=e[1],f+=e[2],d+=e[3]}if(l){const e=new Te(p,h),t=new Te(f,h),i=new Te(p,d),n=new Te(f,d),r=Be(l);let o=new Te(0,0);c&&(o=new Te(c[0],c[1])),e._rotateAround(r,o),t._rotateAround(r,o),i._rotateAround(r,o),n._rotateAround(r,o),p=Math.min(e.x,t.x,i.x,n.x),f=Math.max(e.x,t.x,i.x,n.x),h=Math.min(e.y,t.y,i.y,n.y),d=Math.max(e.y,t.y,i.y,n.y)}return e.emplaceBack(t.x,t.y,t.z,i.x,i.y,p,h,f,d,a,n,r,o),e.length-1}function lA(e){Yg(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 cA(e,t,i,n){const r=e.compareText;if(t in r){const e=r[t];for(let t=e.length-1;t>=0;t--)if(n.dist(e[t])y&&(v(e,c,n,r,a,l),v(c,i,a,l,o,s))}v(h,d,n,o,r,o),v(d,p,r,o,r,s),v(p,f,r,s,n,s),v(f,h,n,s,n,o),m-=y,g-=y,_+=y,A+=y;const x=1/Math.max(_-m,A-g);return{scale:x,x:m*x,y:g*x,x2:_*x,y2:A*x,projection:t}}function dA(e,{x:t,y:i},n=0){return new Te(((t-n)*e.scale-e.x)*Nn,(i*e.scale-e.y)*Nn)}const pA=c(new Float32Array(16));class fA{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 rc(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 hc(1,e)*t}pixelSpaceConversion(e,t,i){return 1}farthestPixelDistance(e){return uA(e,e.pixelsPerMeter)}pointCoordinate(e,t,i,n){const r=e.horizonLineFromTop(!1),o=new Te(t,Math.max(r,i));return e.rayIntersectionCoordinate(e.pointRayIntersection(o,n))}pointCoordinate3D(e,t,i){const n=new Te(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.y0?t<-wA+i&&(t=-wA+i):t>wA-i&&(t=wA-i);const o=r/Math.pow(TA(t),n);let s=o*Math.sin(n*e),a=r-o*Math.cos(n*e);return s=.5*(s/Math.PI+.5),a=.5*(a/Math.PI+.5),{x:s,y:this.southernCenter?a:1-a,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),s=Math.sign(i)*Math.sqrt(e*e+r*r);let a=Math.atan2(e,Math.abs(r))*o;r*i<0&&(a-=Math.PI*Math.sign(e)*o);const l=Fe(Ie(a/i)+this.center[0],-180,180),c=Fe(Ie(2*Math.atan(Math.pow(n/s,1/i))-wA),-mc,mc);return new rc(l,this.southernCenter?-c:c)}}class CA extends fA{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:cc(e),y:uc(t),z:0}}unproject(e,t){const i=dc(e),n=pc(t);return new rc(i,n)}}const SA=Be(mc);class BA extends fA{project(e,t){const i=(t=Be(t))*t,n=i*i;return{x:.5*((e=Be(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=Fe(i-r,-SA,SA)}while(Math.abs(r)>1e-6&&--n>0);o=i*i;const s=Fe(Ie(e/(.8707+o*(o*(o*o*o*(.003971-.001529*o)-.013791)-.131979))),-180,180),a=Ie(i);return new rc(s,a)}}const IA=Be(mc);class MA extends fA{project(e,t){t=Be(t),e=Be(e);const i=Math.cos(t),n=2/Math.PI,r=Math.acos(i*Math.cos(e/2)),o=Math.sin(r)/r,s=.5*(e*n+2*i*Math.sin(e/2)/o)||0,a=.5*(t+Math.sin(t)/o)||0;return{x:.5*(s/Math.PI+.5),y:1-.5*(a/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 s=0,a=0;do{const r=Math.cos(n),o=Math.sin(n),l=2*o*r,c=o*o,u=r*r,h=Math.cos(i/2),d=Math.sin(i/2),p=2*h*d,f=d*d,m=1-u*h*h,g=m?1/m:0,_=m?Math.acos(r*h)*Math.sqrt(1/m):0,A=.5*(2*_*r*d+2*i/Math.PI)-e,y=.5*(_*o+n)-t,v=.5*g*(u*f+_*r*h*c)+1/Math.PI,x=g*(p*l/4-_*o*d),b=.125*g*(l*d-_*o*u*p),w=.5*g*(c*h+_*f*r)+.5,T=x*b-w*v;s=(y*x-A*w)/T,a=(A*b-y*v)/T,i=Fe(i-s,-Math.PI,Math.PI),n=Fe(n-a,-IA,IA)}while((Math.abs(s)>o||Math.abs(a)>o)&&--r>0);return new rc(Ie(i),Ie(n))}}class PA extends fA{constructor(e){super(e),this.center=e.center||[0,0],this.parallels=e.parallels||[0,0],this.cosPhi=Math.max(.01,Math.cos(Be(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:Be(e)*n*i+.5,y:-Math.sin(Be(t))/n*i+.5,z:0}}unproject(e,t){const{scale:i,cosPhi:n}=this,r=-(t-.5)/i,o=Fe(Ie((e-.5)/i)/n,-180,180),s=Math.asin(Fe(r*n,-1,1)),a=Fe(Ie(s),-mc,mc);return new rc(o,a)}}class RA extends CA{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=Zu(e,t,i);return j(n,n,Ku(Vu(i))),{x:n[0],y:n[1],z:n[2]}}locationPoint(e,t,i){const n=tc(t.lat,t.lng),r=z([],n),o=i?e._centerAltitude+i:e.elevation?e.elevation.getAtPointOrZero(e.locationCoordinate(t),e._centerAltitude):e._centerAltitude;L(n,n,r,hc(1,0)*Nn*o);const s=c(new Float64Array(16));return h(s,e.pixelMatrix,e.globeMatrix),j(n,n,s),new Te(n[0],n[1])}pixelsPerMeter(e,t){return hc(1,0)*t}pixelSpaceConversion(e,t,i){const n=hc(1,e)*t,r=di(hc(1,45)*t,n,i);return this.pixelsPerMeter(e,t)/r}createTileMatrix(e,t,i){const n=Xu(Vu(i.canonical));return h(new Float64Array(16),e.globeMatrix,n)}createInversionMatrix(e,t){const{center:i}=e,n=Ku(Vu(t));return m(n,n,Be(i.lng)),f(n,n,Be(i.lat)),p(n,n,[e._pixelsPerMercatorPixel,e._pixelsPerMercatorPixel,1]),Float32Array.from(n)}pointCoordinate(e,t,i,n){return zu(e,t,i,!0)||new vc(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!zu(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(),s=S([],R([],o,-i),[0,0,n]),a=e.worldSize/(2*Math.PI),l=[0,0,-a],c=e.width/e.height,u=Math.tan(e.fovAboveCenter),h=R([],r.up(),u),d=R([],r.right(),u*c),p=z([],S([],S([],o,h),d)),f=[];let m;if(new Qc(s,p).closestPointOnSphere(l,a,f)){const t=S([],f,l),i=Z([],t,s);m=Math.cos(e.fovAboveCenter)*T(i)}else{const e=Z([],s,l),t=Z([],l,s);z(t,t);const i=T(e)-a;m=Math.sqrt(i*(i+2*a));const n=Math.acos(m/(a+i))-Math.acos(U(o,t));m*=Math.cos(n)}return 1.01*m}(e,this.pixelsPerMeter(e.center.lat,e.worldSize)),i=th(e.zoom);if(i>0){const n=uA(e,hc(1,e.center.lat)*e.worldSize),r=e.worldSize/(2*Math.PI),o=Math.max(e.width,e.height)/e.worldSize*Math.PI;return di(t,n+r*(1-Math.cos(o)),Math.pow(i,10))}return t}upVector(e,t,i){return Zu(t,i,e,1)}upVectorScale(e){return{metersToTile:Du(Wu(Vu(e)))}}}function LA(e){const t=e.parallels,i=!!t&&Math.abs(t[0]+t[1])<.01;switch(e.name){case"mercator":return new CA(e);case"equirectangular":return new bA(e);case"naturalEarth":return new BA(e);case"equalEarth":return new xA(e);case"winkelTripel":return new MA(e);case"albers":return i?new PA(e):new mA(e);case"lambertConformalConic":return i?new PA(e):new EA(e);case"globe":return new RA(e)}throw new Error(`Invalid projection name: ${e.name}`)}const FA=Mc.types,kA=[{name:"a_fade_opacity",components:1,type:"Uint8",offset:0}];function DA(e,t,i,n,r,o,s,a,l,c,u,h,d){const p=a?Math.min(rA,Math.round(a[0])):0,f=a?Math.min(rA,Math.round(a[1])):0;e.emplaceBack(t,i,Math.round(32*n),Math.round(32*r),o,s,(p<<1)+(l?1:0),0+(f<<1),16*c,16*u,256*h,256*d)}function OA(e,t,i){e.emplaceBack(t,i)}function zA(e,t,i,n,r,o,s){e.emplaceBack(t,i,n,r,o,s)}const UA=(e,t,i,n)=>{for(let r=0;r0&&(this.iconTransitioningVertexBuffer=e.createVertexBuffer(this.iconTransitioningVertexArray,ug.members,!0)),this.globeExtVertexArray.length>0&&(this.globeExtVertexBuffer=e.createVertexBuffer(this.globeExtVertexArray,sg.members,!0)),!this.zOffsetVertexBuffer&&(this.zOffsetVertexArray.length>0||r)&&(this.zOffsetVertexBuffer=e.createVertexBuffer(this.zOffsetVertexArray,lg.members,!0)),!this.orientationVertexBuffer&&this.orientationVertexArray&&this.orientationVertexArray.length>0&&(this.orientationVertexBuffer=e.createVertexBuffer(this.orientationVertexArray,cg.members,!0)),this.opacityVertexBuffer.itemSize=1),(i||n)&&this.programConfigurations.upload(e))}destroy(){this.layoutVertexBuffer&&(this.layoutVertexBuffer.destroy(),this.indexBuffer.destroy(),this.programConfigurations.destroy(),this.segments.destroy(),this.dynamicLayoutVertexBuffer.destroy(),this.opacityVertexBuffer.destroy(),this.iconTransitioningVertexBuffer&&this.iconTransitioningVertexBuffer.destroy(),this.globeExtVertexBuffer&&this.globeExtVertexBuffer.destroy(),this.zOffsetVertexBuffer&&this.zOffsetVertexBuffer.destroy(),this.orientationVertexBuffer&&this.orientationVertexBuffer.destroy())}}es(jA,"SymbolBuffers");class GA{constructor(e,t,i){this.layoutVertexArray=new e,this.layoutAttributes=t,this.indexArray=new i,this.segments=new hl,this.collisionVertexArray=new La,this.collisionVertexArrayExt=new Sa}upload(e){this.layoutVertexBuffer=e.createVertexBuffer(this.layoutVertexArray,this.layoutAttributes),this.indexBuffer=e.createIndexBuffer(this.indexArray),this.collisionVertexBuffer=e.createVertexBuffer(this.collisionVertexArray,hg.members,!0),this.collisionVertexBufferExt=e.createVertexBuffer(this.collisionVertexArrayExt,dg.members,!0)}destroy(){this.layoutVertexBuffer&&(this.layoutVertexBuffer.destroy(),this.indexBuffer.destroy(),this.segments.destroy(),this.collisionVertexBuffer.destroy(),this.collisionVertexBufferExt.destroy())}}es(GA,"CollisionBuffers");class HA{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=c([]),this.placementViewportMatrix=c([]);const t=this.layers[0]._unevaluatedLayout._values;this.worldview=e.worldview,this.textSizeData=s_(this.zoom,t["text-size"],this.worldview),this.iconSizeData=s_(this.zoom,t["icon-size"],this.worldview);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=>Ng[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.elevationStateComplete=!1,this.activeReplacements=[],this.replacementUpdateTime=0,this.hasAnySecondaryIcon=!1,this.hasAppearances=null,this.lastActiveApperance=null}hasAnyAppearanceProperty(e){const t=this.layers[0].getAppearances();return!(!t||0===t.length)&&t.some(t=>null!=t.getProperty(e))}createArrays(){this.text=new jA(new Nl(this.layers,{zoom:this.zoom,lut:this.lut},e=>e.startsWith("text")||e.startsWith("symbol"))),this.icon=new jA(new Nl(this.layers,{zoom:this.zoom,lut:this.lut},e=>e.startsWith("icon")||e.startsWith("symbol"))),this.glyphOffsetArray=new tl,this.lineVertexArray=new il,this.symbolInstances=new el}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=_g[i];e&&(t[e.charCodeAt(0)]=!0)}}}calculateEffectiveAppearanceIconSize(e,t,i,n,r,o){let s=1;const a=e.getUnevaluatedProperties()._values["icon-size"],l=s_(this.zoom,a,this.worldview),c=l_(l,t);if("constant"!==l.kind&&"camera"!==l.kind||(s=c.uSize),"composite"===l.kind){const{minZoom:e,maxZoom:t}=l,o=a.possiblyEvaluate(new Es(e,{worldview:this.worldview}),n),u=a.possiblyEvaluate(new Es(t,{worldview:this.worldview}),n),h=o.evaluate(i,{},n,r);s=h+(u.evaluate(i,{},n,r)-h)*c.uSizeT}return"source"===l.kind&&(s=a.possiblyEvaluate(new Es(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!jd(this.activeReplacements,i)&&(this.activeReplacements=i,!0)}getResolvedImageFromTokens(e){return"string"==typeof e?zi.build(e):e}populate(e,t,i,n){const r=this.layers[0],o=r.layout,s="globe"===this.projection.name,a=o.get("text-font"),l=o.get("text-field"),c=o.get("icon-image"),[u,h]=o.get("icon-size-scale-range"),d=Fe(t.scaleFactor||1,u,h),p=("constant"!==l.value.kind||l.value.value instanceof Di&&!l.value.value.isEmpty()||l.value.value.toString().length>0)&&("constant"!==a.value.kind||a.value.value.length>0),f="constant"!==c.value.kind||!!c.value.value||Object.keys(c.parameters).length>0,m=this.hasAnyAppearanceProperty("icon-image"),g=o.get("symbol-sort-key");if(this.features=[],this.appearanceFeatureData=[],!p&&!f&&!m)return;const _=t.iconDependencies,A=t.glyphDependencies,y=t.availableImages,v=new Es(this.zoom,{worldview:this.worldview,activeFloors:t.activeFloors}),x=e=>{const t=e.id.toString();_.has(t)?_.get(t).push(e):_.set(t,[e])};for(const t of e){const{feature:e,id:l,index:c,sourceLayerIndex:u}=t,h=r._featureFilter.needGeometry,b=Ic(e,h);if(!r._featureFilter.filter(v,b,i))continue;if(h||(b.geometry=Bc(e,i,n)),s&&1!==e.type&&i.z<=5){const e=b.geometry,t=.98078528056,n=(e,n)=>U(Zu(e.x,e.y,i,1),Zu(n.x,n.y,i,1)){if(!e.getProperty("icon-image"))return;const t=this.getCombinedIconPrimary(e,E,b,i,y,B,d);t&&x(t)}),w){const e=a.evaluate(b,{},i).join(","),t="map"===o.get("text-rotation-alignment")&&"point"!==o.get("symbol-placement");this.allowVerticalPlacement=this.writingModes&&this.writingModes.indexOf(Ng.vertical)>=0;for(const i of w.sections)if(i.image){const e=i.image.getPrimary().scaleSelf(this.pixelRatio),t=e.id.toString(),n=_.get(t)||[];n.push(e),_.set(t,n)}else{const n=ss(w.toString()),r=i.fontStack||e,o=A[r]=A[r]||{};this.calculateGlyphDependencies(i.text,o,t,this.allowVerticalPlacement,n)}}}if("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 s(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 a(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][t[0].length-1]:t[0][0];return`${e}:${n.x}:${n.y}`}for(let c=0;ce.geometry)}(this.features)),"hd-road-markup"===o.get("symbol-elevation-reference")){if(this.elevationType="road",t.elevationFeatures){!this.elevationFeatures&&t.elevationFeatures.length>0&&(this.elevationFeatures=[],this.elevationFeatureIdToIndex=new Map);for(const e of t.elevationFeatures)this.elevationFeatureIdToIndex.set(e.id,this.elevationFeatures.length),this.elevationFeatures.push(e)}}else 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)}getCombinedIconPrimary(e,t,i,n,r,o,s){let a,l;const c=e.getUnevaluatedProperties();if(void 0!==c._values["icon-image"].value){const o=t.getAppearanceValueAndResolveTokens(e,"icon-image",i,n,r);a=this.getResolvedImageFromTokens(o)}else{const e=t.getValueAndResolveTokens("icon-image",i,n,r);a=this.getResolvedImageFromTokens(e)}if(a){const e=c._values["icon-size"]||t._unevaluatedLayout._values["icon-size"];l=q_(a,s_(this.zoom,e,this.worldview),e,n,this.zoom,o,this.pixelRatio,s,this.worldview).iconPrimary}return l}updateAppearanceBasedIconTextures(e,t,i,n){if(!this.appearanceFeatureData)return!1;if(!this.icon.layoutVertexArray||0===this.icon.layoutVertexArray.length)return!1;const r=this.layers[0];let o=!1,s=0;const a=r.layout,[l,c]=a.get("icon-size-scale-range"),u=Fe(1,l,c);for(let a=0;a=0){const a=c.id,h=t&&void 0!==a?t[String(a)]:void 0,d={type:"Point",id:c.id,properties:c.properties,geometry:[]},p=this.layers[0].appearances&&this.layers[0].appearances.find(t=>t.isActive({globals:n,feature:d,canonical:e,featureState:h}));if(c.activeAppearance===p)continue;if(p){c.activeAppearance=p;const t={sortKey:void 0,text:void 0,icon:null,index:l.featureIndex,sourceLayerIndex:l.featureIndex,geometry:[],properties:c.properties,type:"Point",id:c.id};if(!p.hasCachedIconPrimary()){const n=this.getCombinedIconPrimary(p,r,d,e,i,t,u);p.setCachedIconPrimary(n)}const a=p.getCachedIconPrimary();if(!a)continue;const h=a.toString(),f=this.iconAtlasPositions&&this.iconAtlasPositions.get(h);if(f){const t=r.getAppearanceValueAndResolveTokens(p,"icon-offset",d,e,i),a=t&&Array.isArray(t)?t:[0,0];let h=e_(f,void 0,a,r.layout.get("icon-anchor").evaluate(d,{},e));const m=r.getAppearanceValueAndResolveTokens(p,"icon-rotate",d,e,i),g="number"==typeof m?m:0,_=f.sdf,A=r.layout.get("icon-text-fit").constantOr("none");"none"!==A&&c.textShaping&&c.iconTextFitPadding&&c.fontScale&&(h=t_(h,c.textShaping,A,c.iconTextFitPadding,a,c.fontScale));const y=this.calculateEffectiveAppearanceIconSize(p,n.zoom,d,e,i,u),v=0,x=1+(Math.min(rA,Math.round(y*o_))<<1),b=M_(h,g,_,"none"!==A,u);c.isUsingAppearanceVertexData||(c.isUsingAppearanceVertexData=!0,c.layoutBasedVertexData=this.icon.getIconVertexData(s,l.numIconVertices));for(let e=0;e0&&(this.icon.updateIconVertexData(s,0,0,0,0,0,0,0,0,0,0,0,0),this.icon.updateIconVertexData(s+1,0,0,0,0,0,0,0,0,0,0,0,0),this.icon.updateIconVertexData(s+2,0,0,0,0,0,0,0,0,0,0,0,0),this.icon.updateIconVertexData(s+3,0,0,0,0,0,0,0,0,0,0,0,0),o=!0),s+=l.numIconVertices,c.activeAppearance=null;else if(c.isUsingAppearanceVertexData){const e=12,t=c.layoutBasedVertexData.length/e;for(let i=0;i0||u>0,f=h>0,m=this.elevationFeatures[s.elevationFeatureIndex];if(m){const e=new Te(s.tileAnchorX,s.tileAnchorY),c=.075+m.pointElevation(e);s.zOffset!==c&&(t=!0,s.zOffset=c),0!==c&&(this.hasAnyZOffset=!0);const u=m.computeSlopeNormal(e,n),h=le(ee(),E(0,0,1),u);H(a,a,h),H(l,l,h),a[2]*=i,l[2]*=i,1===a[0]&&0===a[1]&&0===a[2]&&0===l[0]&&1===l[1]&&0===l[2]||(r=r||p,o=o||f)}if(p&&(UA(this.text.orientationVertexArray,c,a,l),UA(this.text.orientationVertexArray,u,a,l)),f){const{placedIconSymbolIndex:e,verticalPlacedIconSymbolIndex:t}=s;e>=0&&UA(this.icon.orientationVertexArray,h,a,l),t>=0&&UA(this.icon.orientationVertexArray,d,a,l)}}r||(this.text.orientationVertexArray=void 0),o||(this.icon.orientationVertexArray=void 0),t&&(this.zOffsetBuffersNeedUpload=!0,this.zOffsetSortDirty=!0)}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;i0;if((r>0||o>0)&&(e(this.text.zOffsetVertexArray,r,a),e(this.text.zOffsetVertexArray,o,a)),l){const{placedIconSymbolIndex:e,verticalPlacedIconSymbolIndex:i}=n;e>=0&&t(this.icon.zOffsetVertexArray,s,a),i>=0&&t(this.icon.zOffsetVertexArray,n.numVerticalIconVertices,a)}}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,!1),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){return!!(e&&t&&i)&&!(!this.icon.layoutVertexArray||0===this.icon.layoutVertexArray.length)&&!!this.icon.layoutVertexArray.arrayBuffer&&void(this.updateAppearanceBasedIconTextures(e,t,i,n)&&this.icon.layoutVertexBuffer&&null!==this.icon.layoutVertexArray.arrayBuffer&&this.icon.layoutVertexArray.length===this.icon.layoutVertexBuffer.length&&this.icon.layoutVertexBuffer.updateData(this.icon.layoutVertexArray))}destroyDebugData(){this.textCollisionBox.destroy(),this.iconCollisionBox.destroy()}getProjection(){return this.projectionInstance||(this.projectionInstance=LA(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,s,a,l,c,u,h,d,p,f,m,g,_){const A=e.indexArray,y=e.layoutVertexArray,v=e.globeExtVertexArray,x=e.segments.prepareSegment(4*_,y,A,this.canOverlap?o.sortKey:void 0),b=this.glyphOffsetArray.length,w=x.vertexLength,T=this.allowVerticalPlacement&&s===Ng.vertical?Math.PI/2:0,E=o.text&&o.text.sections;for(let n=0;n=0?t.rightJustifiedTextSymbolIndex:t.centerJustifiedTextSymbolIndex>=0?t.centerJustifiedTextSymbolIndex:t.leftJustifiedTextSymbolIndex>=0?t.leftJustifiedTextSymbolIndex:t.verticalPlacedTextSymbolIndex>=0?t.verticalPlacedTextSymbolIndex:n),o=a_(this.textSizeData,e,r)/mg;return this.tilePixelRatio*o}getSymbolInstanceIconSize(e,t,i){const n=this.icon.placedSymbolArray.get(i),r=a_(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,s){for(let s=n;s0}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;tn[e]-n[t]||r[t]-r[e]),o}getSortedIndexesByZOffset(){if(!this.zOffsetSortDirty)return this.symbolInstanceIndexesSortedZOffset;if(!this.symbolInstanceIndexesSortedZOffset){this.symbolInstanceIndexesSortedZOffset=[];for(let e=0;ethis.symbolInstances.get(t).zOffset-this.symbolInstances.get(e).zOffset)}addToSortKeyRanges(e,t){const i=this.sortKeyRanges[this.sortKeyRanges.length-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&&!(this.text.segments.get().length>1||this.icon.segments.get().length>1)){this.symbolInstanceIndexes=this.getSortedSymbolIndexes(e),this.sortedAngle=e,this.text.indexArray.clear(),this.icon.indexArray.clear(),this.featureSortOrder=[];for(const e of this.symbolInstanceIndexes){const t=this.symbolInstances.get(e);this.featureSortOrder.push(t.featureIndex);const{rightJustifiedTextSymbolIndex:i,centerJustifiedTextSymbolIndex:n,leftJustifiedTextSymbolIndex:r,verticalPlacedTextSymbolIndex:o,placedIconSymbolIndex:s,verticalPlacedIconSymbolIndex:a}=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),s>=0&&this.addIndicesForPlacedSymbol(this.icon,s),a>=0&&this.addIndicesForPlacedSymbol(this.icon,a)}this.text.indexBuffer&&this.text.indexBuffer.updateData(this.text.indexArray),this.icon.indexBuffer&&this.icon.indexBuffer.updateData(this.icon.indexArray)}}getElevationFeatureForText(e){const t=this.symbolInstances.get(this.text.symbolInstanceIndices[e]).elevationFeatureIndex;let i;return this.elevationFeatures&&ti in e?String(e[i]):"")}let $A,ZA,WA;es(HA,"SymbolBucket",{omit:["layers","collisionBoxArray","compareText","features"]}),HA.addDynamicAttributes=NA;class qA{constructor(e){this.type=e.property.overrides?e.property.overrides.runtimeType:_i,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}}es(qA,"FormatSectionOverride",{omit:["defaultValue"]});const KA=()=>WA||(WA={layout:$A||($A=new Os({"symbol-placement":new Fs(zs.layout_symbol["symbol-placement"]),"symbol-spacing":new Fs(zs.layout_symbol["symbol-spacing"]),"symbol-avoid-edges":new Fs(zs.layout_symbol["symbol-avoid-edges"]),"symbol-sort-key":new ks(zs.layout_symbol["symbol-sort-key"]),"symbol-z-order":new Fs(zs.layout_symbol["symbol-z-order"]),"symbol-z-elevate":new Fs(zs.layout_symbol["symbol-z-elevate"]),"symbol-elevation-reference":new Fs(zs.layout_symbol["symbol-elevation-reference"]),"icon-allow-overlap":new Fs(zs.layout_symbol["icon-allow-overlap"]),"icon-ignore-placement":new Fs(zs.layout_symbol["icon-ignore-placement"]),"icon-optional":new Fs(zs.layout_symbol["icon-optional"]),"icon-rotation-alignment":new Fs(zs.layout_symbol["icon-rotation-alignment"]),"icon-size":new ks(zs.layout_symbol["icon-size"]),"icon-size-scale-range":new Fs(zs.layout_symbol["icon-size-scale-range"]),"icon-text-fit":new ks(zs.layout_symbol["icon-text-fit"]),"icon-text-fit-padding":new ks(zs.layout_symbol["icon-text-fit-padding"]),"icon-image":new ks(zs.layout_symbol["icon-image"]),"icon-image-use-theme":new Fs({type:"string",default:"default","property-type":"data-constant"}),"icon-rotate":new ks(zs.layout_symbol["icon-rotate"]),"icon-padding":new Fs(zs.layout_symbol["icon-padding"]),"icon-keep-upright":new Fs(zs.layout_symbol["icon-keep-upright"]),"icon-offset":new ks(zs.layout_symbol["icon-offset"]),"icon-anchor":new ks(zs.layout_symbol["icon-anchor"]),"icon-pitch-alignment":new Fs(zs.layout_symbol["icon-pitch-alignment"]),"text-pitch-alignment":new Fs(zs.layout_symbol["text-pitch-alignment"]),"text-rotation-alignment":new Fs(zs.layout_symbol["text-rotation-alignment"]),"text-field":new ks(zs.layout_symbol["text-field"]),"text-font":new ks(zs.layout_symbol["text-font"]),"text-size":new ks(zs.layout_symbol["text-size"]),"text-size-scale-range":new Fs(zs.layout_symbol["text-size-scale-range"]),"text-max-width":new ks(zs.layout_symbol["text-max-width"]),"text-line-height":new ks(zs.layout_symbol["text-line-height"]),"text-letter-spacing":new ks(zs.layout_symbol["text-letter-spacing"]),"text-justify":new ks(zs.layout_symbol["text-justify"]),"text-radial-offset":new ks(zs.layout_symbol["text-radial-offset"]),"text-variable-anchor":new Fs(zs.layout_symbol["text-variable-anchor"]),"text-anchor":new ks(zs.layout_symbol["text-anchor"]),"text-max-angle":new Fs(zs.layout_symbol["text-max-angle"]),"text-writing-mode":new Fs(zs.layout_symbol["text-writing-mode"]),"text-rotate":new ks(zs.layout_symbol["text-rotate"]),"text-padding":new Fs(zs.layout_symbol["text-padding"]),"text-keep-upright":new Fs(zs.layout_symbol["text-keep-upright"]),"text-transform":new ks(zs.layout_symbol["text-transform"]),"text-offset":new ks(zs.layout_symbol["text-offset"]),"text-allow-overlap":new Fs(zs.layout_symbol["text-allow-overlap"]),"text-ignore-placement":new Fs(zs.layout_symbol["text-ignore-placement"]),"text-optional":new Fs(zs.layout_symbol["text-optional"]),visibility:new Fs(zs.layout_symbol.visibility)})),paint:ZA||(ZA=new Os({"icon-opacity":new ks(zs.paint_symbol["icon-opacity"]),"icon-occlusion-opacity":new ks(zs.paint_symbol["icon-occlusion-opacity"]),"icon-emissive-strength":new ks(zs.paint_symbol["icon-emissive-strength"]),"text-emissive-strength":new ks(zs.paint_symbol["text-emissive-strength"]),"icon-color":new ks(zs.paint_symbol["icon-color"]),"icon-halo-color":new ks(zs.paint_symbol["icon-halo-color"]),"icon-halo-width":new ks(zs.paint_symbol["icon-halo-width"]),"icon-halo-blur":new ks(zs.paint_symbol["icon-halo-blur"]),"icon-translate":new Fs(zs.paint_symbol["icon-translate"]),"icon-translate-anchor":new Fs(zs.paint_symbol["icon-translate-anchor"]),"icon-image-cross-fade":new Fs(zs.paint_symbol["icon-image-cross-fade"]),"text-opacity":new ks(zs.paint_symbol["text-opacity"]),"text-occlusion-opacity":new ks(zs.paint_symbol["text-occlusion-opacity"]),"text-color":new ks(zs.paint_symbol["text-color"],{runtimeType:xi,getOverride:e=>e.textColor,hasOverride:e=>!!e.textColor}),"text-halo-color":new ks(zs.paint_symbol["text-halo-color"]),"text-halo-width":new ks(zs.paint_symbol["text-halo-width"]),"text-halo-blur":new ks(zs.paint_symbol["text-halo-blur"]),"text-translate":new Fs(zs.paint_symbol["text-translate"]),"text-translate-anchor":new Fs(zs.paint_symbol["text-translate-anchor"]),"icon-color-saturation":new Fs(zs.paint_symbol["icon-color-saturation"]),"icon-color-contrast":new Fs(zs.paint_symbol["icon-color-contrast"]),"icon-color-brightness-min":new Fs(zs.paint_symbol["icon-color-brightness-min"]),"icon-color-brightness-max":new Fs(zs.paint_symbol["icon-color-brightness-max"]),"symbol-z-offset":new ks(zs.paint_symbol["symbol-z-offset"]),"icon-color-use-theme":new ks({type:"string",default:"default","property-type":"data-driven"}),"icon-halo-color-use-theme":new ks({type:"string",default:"default","property-type":"data-driven"}),"text-color-use-theme":new ks({type:"string",default:"default","property-type":"data-driven"}),"text-halo-color-use-theme":new ks({type:"string",default:"default","property-type":"data-driven"})}))},WA);class XA extends aa{constructor(e,t,i,n){super(e,KA(),t,i,n,e.layout?e.layout["icon-image-use-theme"]:null),this._colorAdjustmentMatrix=c([]),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)}),"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.indexOf(t)<0&&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=rt(e),t=nt(t);const r=a(),o=e/3,s=1-2*o,l=[s,o,o,0,o,s,o,0,o,o,s,0,0,0,0,1],c=.5-.5*t,u=n-i;return h(r,[u,0,0,0,0,u,0,0,0,0,u,0,i,i,i,1],[t,0,0,0,0,t,0,0,0,0,t,0,c,c,c,1]),h(r,r,l),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()||jo(o.value)||!r?r:QA(t.properties,r)}getAppearanceValueAndResolveTokens(e,t,i,n,r){const o=e.getProperty(t);if(!o)return;const s=o.evaluate(i,{},n,r),a=e.getUnevaluatedProperties()._values[t];return a.isDataDriven()||jo(a.value)||!s||"string"!=typeof s?s:QA(i.properties,s)}createBucket(e){return new HA(e)}queryRadius(){return 0}queryIntersectsFeature(){return!1}_setPaintOverrides(){for(const e of KA().paint.overridableProperties){if(!XA.hasPaintOverride(this.layout,e))continue;const t=this.paint.get(e),i=new qA(t),n=new Vo(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 Ho("source",n):new Qo("composite",n,t.value.zoomStops,t.value.interpolationType),this.paint._values[e]=new Rs(t.property,r,t.parameters)}}_handleOverridablePaintPropertyUpdate(e,t,i){return!(!this.layout||t.isDataDriven()||i.isDataDriven())&&XA.hasPaintOverride(this.layout,e)}static hasPaintOverride(e,t){const i=e.get("text-field"),n=KA().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 Di)o(i.value.value.sections);else if("source"===i.value.kind){const e=t=>{r||(t instanceof Gi&&Vi(t.value)===Ei?o(t.value.sections):t instanceof Zi?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 Ul(this,{zoom:t,lut:i}),overrideFog:!1}}hasElevation(){return this.layout&&"hd-road-markup"===this.layout.get("symbol-elevation-reference")}}let JA,YA,ey,ty;var iy=ha([{name:"a_pos",type:"Int16",components:2},{name:"a_texture_pos",type:"Int16",components:2}]);function ny(e,t,i,n,r,a,l,c){const u=[e,t,1,i,n,1,r,a,1],h=[l,c,1],d=o([],u),[p,f,m]=G(h,h,d);return s(u,u,[p,0,0,0,f,0,0,0,m])}function ry(e,t,i,n,r,a,l,c){const u=function(e,t,i,n,r,a,l,c){const u=ny(0,0,1,0,1,1,0,1),h=ny(e,t,i,n,r,a,l,c);return s(h,h,o([],u))}(e,t,i,n,r,a,l,c);return[u[2]/u[8]/Nn,u[5]/u[8]/Nn]}function oy(e){return[e[0],Math.min(Math.max(e[1],-mc),mc)]}class sy extends ni{constructor(e,t,i,n){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(n),this.options=t,this._dirty=!1}load(e,t){if(this._loaded=t||!1,this.fire(new Yt("dataloading",{dataType:"source"})),this.url=this.options.url,!this.url)return e&&(this.coordinates=e),this._loaded=!0,void this._finishLoading();this._imageRequest=Ht(this.map._requestManager.transformRequest(this.url,kt.Image),(t,i)=>{this._imageRequest=null,this._loaded=!0,t?this.fire(new ei(t)):i&&(this.image=i instanceof HTMLImageElement?gt.getImageData(i):i,this._dirty=!0,this.width=this.image.width,this.height=this.image.height,e&&(this.coordinates=e),this._finishLoading())})}loaded(){return this._loaded}updateImage(e){return e.url?(this._imageRequest&&e.url!==this.options.url&&(this._imageRequest.cancel(),this._imageRequest=null),this.options.url=e.url,this.load(e.coordinates,this._loaded),this):this}setTexture(e){if(!(e.handle instanceof WebGLTexture))throw new Error("The provided handle is not a WebGLTexture instance");return this.texture=new Pf(this.map.painter.context,e.handle),this.width=e.dimensions[0],this.height=e.dimensions[1],this._dirty=!1,this._loaded=!0,this._finishLoading(),this}_finishLoading(){this.map&&(this.setCoordinates(this.coordinates),this.fire(new Yt("data",{dataType:"source",sourceDataType:"metadata"})))}onAdd(e){this.map=e,this.load()}onRemove(e){this._imageRequest&&(this._imageRequest.cancel(),this._imageRequest=null),!this.texture||this.texture instanceof Pf||this.texture.destroy(),this.boundsBuffer&&(this.boundsBuffer.destroy(),this.elevatedGlobeVertexBuffer&&this.elevatedGlobeVertexBuffer.destroy(),this.elevatedGlobeIndexBuffer&&this.elevatedGlobeIndexBuffer.destroy())}setCoordinates(e){if(this.coordinates=e,this._boundsArray=void 0,this._unsupportedCoords=!1,!e.length)return this;this.onNorthPole=!1,this.onSouthPole=!1;let t=e[0][1],i=e[0][1];for(const n of e)n[1]>i&&(i=n[1]),n[1]mc?this.onNorthPole=!0:n<-mc&&(this.onSouthPole=!0),!this.onNorthPole&&!this.onSouthPole){const t=e.map(vc.fromLngLat);this.tileID=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);const o=Math.max(n-t,r-i),s=Math.max(0,Math.floor(-Math.log2(o))),a=Math.pow(2,s);let l=Math.floor((t+n)/2*a);return l>1&&(l-=1),new Su(s,l,Math.floor((i+r)/2*a))}(t),this.minzoom=this.maxzoom=this.tileID.z}return this.fire(new Yt("data",{dataType:"source",sourceDataType:"content"})),this}_clear(){!this.texture||this.texture instanceof Pf||(this.texture.destroy(),this._dirty=!0),this.texture=null,this._boundsArray=void 0,this._unsupportedCoords=!1}_prepareData(e){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 t=hA(new Su(0,0,0),this.map.transform.projection),i=[t.projection.project(this.coordinates[0][0],this.coordinates[0][1]),t.projection.project(this.coordinates[1][0],this.coordinates[1][1]),t.projection.project(this.coordinates[2][0],this.coordinates[2][1]),t.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,n=e[2].x-e[1].x,r=e[2].y-e[1].y,o=e[3].x-e[2].x,s=e[3].y-e[2].y,a=e[0].x-e[3].x,l=e[0].y-e[3].y,c=t*r-n*i,u=n*s-o*r,h=o*l-a*s,d=a*i-t*l;return c>0&&u>0&&h>0&&d>0||c<0&&u<0&&h<0&&d<0}(i))return console.warn("Image source coordinates are defining non-convex area in the Mercator projection"),void(this._unsupportedCoords=!0);const n=hA(this.tileID,this.map.transform.projection),[r,a,l,c]=this.coordinates.map(e=>{const t=n.projection.project(e[0],e[1]);return dA(n,t)._round()});this.perspectiveTransform=ry(r.x,r.y,a.x,a.y,l.x,l.y,c.x,c.y);const u=this._boundsArray=new ma;u.emplaceBack(r.x,r.y,0,0),u.emplaceBack(a.x,a.y,Nn,0),u.emplaceBack(c.x,c.y,0,Nn),u.emplaceBack(l.x,l.y,Nn,Nn),this.boundsBuffer&&(this.boundsBuffer.destroy(),this.elevatedGlobeVertexBuffer&&this.elevatedGlobeVertexBuffer.destroy(),this.elevatedGlobeIndexBuffer&&this.elevatedGlobeIndexBuffer.destroy()),this.boundsBuffer=e.createVertexBuffer(u,iy.members),this.boundsSegments=hl.simpleSegment(0,0,4,2);const h=[],d=[oy((p=this.coordinates)[0]),oy(p[1]),oy(p[2]),oy(p[3])];var p;const[f,m,g,_]=function(e){let t=e[0][0],i=t,n=e[0][1],r=n;for(let o=1;oi&&(i=e[o][0]),e[o][1]r&&(r=e[o][1]);return[t,n,i-t,r-n]}(d);{const n=new ma,[r,a,l,c]=function(e){let t=e[0].x,i=t,n=e[0].y,r=n;for(let o=1;oi&&(i=e[o].x),e[o].yr&&(r=e[o].y);return[t,n,i-t,r-n]}(i),u=e=>[(e.x-r)/l,(e.y-a)/c],[d,p,A,y]=i.map(u),v=function(e,t,i,n,r,a,l,c){const u=ny(0,0,1,0,1,1,0,1);return s(u,u,o([],ny(e,t,i,n,r,a,l,c)))}(d[0],d[1],p[0],p[1],A[0],A[1],y[0],y[1]);this.elevatedGlobePerspectiveTransform=ry(d[0],d[1],p[0],p[1],A[0],A[1],y[0],y[1]);const x=(e,t)=>{h.push(e.lng);const i=Math.round((e.lng-f)/g*Nn),r=Math.round((e.lat-m)/_*Nn),o=u(t),s=G([],[o[0],o[1],1],v),a=Math.round(s[0]/s[2]*Nn),l=Math.round(s[1]/s[2]*Nn);n.emplaceBack(i,r,a,l)},b=i[3].x-i[0].x,w=i[3].y-i[0].y,T=i[2].x-i[1].x,E=i[2].y-i[1].y;for(let e=0;e<65;e++){const n=e/64,r=[i[0].x+n*b,i[0].y+n*w],o=[i[1].x+n*T,i[1].y+n*E],s=o[0]-r[0],a=o[1]-r[1];for(let e=0;e<65;e++){const i=e/64,n={x:r[0]+s*i,y:r[1]+a*i};x(t.projection.unproject(n.x,n.y),n)}}this.elevatedGlobeVertexBuffer=e.createVertexBuffer(n,iy.members)}{this.maxLongitudeTriangleSize=0;let t=[],i=new Fa;const n=(e,n,r)=>{i.emplaceBack(e,n,r);const o=h[e],s=h[n],a=h[r],l=Math.min(Math.min(o,s),a),c=Math.max(Math.max(o,s),a)-l;c>this.maxLongitudeTriangleSize&&(this.maxLongitudeTriangleSize=c),t.push(l+c/2)};for(let e=0;e<64;e++)for(let t=0;t<64;t++){const i=65*e+t,r=i+1,o=i+65,s=o+1;n(i,o,r),n(r,o,s)}[t,i]=function(e,t){const i=Array.from({length:e.length},(e,t)=>t);i.sort((t,i)=>e[t]-e[i]);const n=[],r=new Fa;for(let o=0;o{o.segments.push({vertexOffset:0,primitiveOffset:e,vertexLength:t.segments[0].vertexLength,primitiveLength:i,sortKey:void 0,vaos:{}})},a=.51*this.maxLongitudeTriangleSize;if(Math.abs(i[0]-n)<=a){const e=it(i,0,i.length,n+a);return e===i.length||s(e,tt(i,e+1,i.length,n+360-a)-e),o}nNn?n-Nn:n,new Te(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 by{constructor(e){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){}populate(e,t,i,n){this.tileToMeter=yc(i);const r=this.layers[0]._featureFilter.needGeometry;this.lookup=new Uint8Array(this.lookupDim*this.lookupDim);for(const{feature:o,id:s,index:a,sourceLayerIndex:l}of e){const e=null!=s?s:o.properties&&o.properties.hasOwnProperty("id")?o.properties.id:void 0,c=Ic(o,r);if(!this.layers[0]._featureFilter.filter(new Es(this.zoom,{worldview:this.worldview,activeFloors:t.activeFloors}),c,i))continue;const u={id:e,sourceLayerIndex:l,index:a,geometry:r?c.geometry:Bc(o,i,n),properties:o.properties,type:o.type,patterns:{}},h=this.addFeature(u,u.geometry,c);h&&t.featureIndex.insert(o,u.geometry,a,l,this.index,this.instancesPerModel[h].instancedDataArray.length,Nn/32)}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*F(r.aabb.max,r.aabb.min)*o.maxScale+o.maxXYTranslationDistance,t=Math.min(Nn,Math.max(e/this.tileToMeter,Nn/32));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)i.idToFeaturesIndex.hasOwnProperty(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,s=n.paint.get("model-rotation").evaluate(r,{},o),a=n.paint.get("model-scale").evaluate(r,{},o),l=n.paint.get("model-translation").evaluate(r,{},o);$(t.rotation,s)&&$(t.scale,a)&&$(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(jd(this.activeReplacements,r))return!1;this.activeReplacements=r;let o=!1;for(const t in this.instancesPerModel){const r=this.instancesPerModel[t],s=r.instancedDataArray;for(const t of r.features){const r=t.instancedDataOffset,a=t.instancedDataCount;for(let t=0;tNn;l=c?l-Nn:l;const u=Math.floor(l),h=Math.floor(s.float32[a+1]);let d=!1;for(const t of this.activeReplacements)if(!zd(t,i,_y.Model,n)&&!(t.min.x>u||u>t.max.x||t.min.y>h||h>t.max.y)&&(d=Wd(Zd(u,h,e.canonical,t.footprintTileId.canonical),t.footprint),d))break;s.float32[a]=d?l+Nn:l,o=o||d!==c}}}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,Of.members,!0,void 0,this.instanceCount))}this.uploaded=!0}destroy(){for(const e in this.instancesPerModel){const t=this.instancesPerModel[e];0!==t.instancedDataArray.length&&t.instancedDataBuffer&&t.instancedDataBuffer.destroy()}const e=this.layers[0].modelManager;if(e&&this.modelUris&&this.modelsRequested)for(const t of this.modelUris)e.removeModel(t,"",!0)}addFeature(e,t,i){const n=this.layers[0],r=n.layout.get("model-id").evaluate(i,{},this.canonical);if(!r)return Ze(`modelId is not evaluated for layer ${n.id} and it is not going to get rendered.`),r;(yy(r,!1)||void 0!==this.styleDefinedModelURLs[r])&&(this.modelUris.includes(r)||this.modelUris.push(r)),this.instancesPerModel[r]||(this.instancesPerModel[r]=new xy);const o=this.instancesPerModel[r],s=o.instancedDataArray,a=new vy(i,s.length);for(const e of t)for(const t of e){if(t.x<0||t.x>=Nn||t.y<0||t.y>=Nn)continue;if(0!==this.lookupDim){const e=(this.lookupDim-1)/Nn,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=s.length;s.resize(e+1),o.instancesEvaluatedElevation.push(0),s.float32[16*e]=t.x,s.float32[16*e+1]=t.y}return a.instancedDataCount=o.instancedDataArray.length-a.instancedDataOffset,a.instancedDataCount>0&&(e.id&&(o.idToFeaturesIndex[e.id]=o.features.length),o.features.push(a),this.evaluate(a,{},o,!1)),r}getModelUris(){return this.modelUris}evaluate(e,t,i,n){const r=this.layers[0],o=e.feature,s=this.canonical,a=e.rotation=r.paint.get("model-rotation").evaluate(o,t,s),l=e.scale=r.paint.get("model-scale").evaluate(o,t,s),c=e.translation=r.paint.get("model-translation").evaluate(o,t,s),u=Object.assign({},r.paint.get("model-color").evaluate(o,t,s));u.a=r.paint.get("model-color-mix-intensity").evaluate(o,t,s);const h=[];this.maxVerticalOffset0?Math.sqrt(d):0;i.maxScale=Math.max(Math.max(i.maxScale,l[0]),Math.max(l[1],l[2])),i.maxXYTranslationDistance=Math.max(i.maxXYTranslationDistance,p),this.maxScale=Math.max(Math.max(this.maxScale,l[0]),Math.max(l[1],l[2])),Qf(h,a,l);const f=Math.round(100*u.a)+u.b/1.05;for(let t=0;t10?this.tileToMeter:yc(s,d)),a[o+4]=c[0],a[o+5]=c[1],a[o+6]=c[2]+l,a[o+7]=h[0],a[o+8]=h[1],a[o+9]=h[2],a[o+10]=h[4],a[o+11]=h[5],a[o+12]=h[6],a[o+13]=h[8],a[o+14]=h[9],a[o+15]=h[10],i.instancesEvaluatedElevation[r]=c[2]}}}let wy,Ty;es(by,"ModelBucket",{omit:["layers"]}),es(xy,"PerModelAttributes"),es(vy,"ModelFeature");class Ey{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,s=1<e.fqid),this.stateDependentLayerIds=this.layers.filter(e=>e.isStateDependent()).map(e=>e.id),this.modelTraits|=Kf.CoordinateSpaceTile,this.uploaded=!1,this.hasPattern=!1,n&&(this.modelTraits|=Kf.HasMapboxMeshFeatures),r&&(this.modelTraits|=Kf.HasMeshoptCompression),this.zoom=-1,this.terrainExaggeration=1,this.projection={name:"mercator"},this.replacementUpdateTime=0,this.elevationReadFromZ=255,this.brightness=o,this.worldview=a,this.dirty=!0,this.needsUpload=!1,this.filter=null,this.nodesInfo=[];for(const e of t)this.nodesInfo.push(new Py(e)),Iy(e,s.featureIndexArray.length,s.grid),s.featureIndexArray.emplaceBack(this.nodesInfo.length-1,0,s.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){}update(e){const t=0!==Object.keys(e).length;if(t&&!this.stateDependentLayers.length)return;const i=t?this.stateDependentLayers:this.layers;if(!Ee(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):tm(t,e,!0)}for(const e of t)im(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);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||Ly(i.paint.get("model-color").value,o)||Ly(i.paint.get("model-color-mix-intensity").value,o)||Ly(i.paint.get("model-roughness").value,o)||Ly(i.paint.get("model-emissive-strength").value,o)||Ly(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(Ee(r,n.state))continue;n.state=structuredClone(r);const o=n.node.meshes&&n.node.meshes[0].featureData,s=n.evaluatedColor[2],a=n.evaluatedRMEA[2],l=this.id.canonical;if(n.hasTranslucentParts=!1,o){for(let t=0;t=e)continue;const h=Cy[c],d=Math.abs(h);d>a&&(s=h,a=d,l=r,u=t)}if(a>.1){const o=1-(e+.5*Math.abs(l*u))/c;let a=t._dem.get(n,i)+s*o;const h=t._dem.get(n+l,i+u),d=t._dem.get(n-l,i-u,!0);(a-h)*(a-d)>0&&(a=(h+d)/2),Cy[r]=t._dem.set(n,i,a),Sy[r]=e}}}}}s&&(t._demTile.needsDEMTextureUpload=!0,t._dem._timestamp=gt.now())}setFilter(e){this.filter=e?js(e):null}getNodesInfo(){return this.filter?this.nodesInfo.filter(e=>this.filter.filter(new Es(this.id.overscaledZ,{worldview:this.worldview}),e.feature,this.id.canonical)):this.nodesInfo}destroy(){const e=this.getNodesInfo();for(const t of e)im(t.node),nm(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.find(e=>e.footprint===t)}}getHeightAtTileCoord(e,t){const i=[],n=[0,0,0],r=c([]);for(const o of this.getNodesInfo()){const s=o.node.meshes[0],a=s.transformedAabb;if(ea.max[0]||t>a.max[1])continue;if(!0===o.node.hidden)return{height:1/0,maxHeight:o.feature.properties.height,hidden:!1,verticalScale:o.evaluatedScale[2]};u(r,o.node.globalMatrix),n[0]=e,n[1]=t,j(n,n,r);const l=(n[0]-s.aabb.min[0])/(s.aabb.max[0]-s.aabb.min[0])*qf|0,c=Math.min(63,(n[1]-s.aabb.min[1])/(s.aabb.max[1]-s.aabb.min[1])*qf|0)*qf+Math.min(63,l),h=s.heightmap[c];if(!(h<0&&o.node.footprint)){if(o.hiddenByReplacement)return;return{height:h,maxHeight:o.feature.properties.height,hidden:!1,verticalScale:o.evaluatedScale[2]}}if(o.node.footprint.grid.query(new Te(e,t),new Te(e,t),i),i.length>0)return{height:void 0,maxHeight:o.feature.properties.height,hidden:o.hiddenByReplacement,verticalScale:o.evaluatedScale[2]}}}}function Ly(e,t){return e instanceof Ho&&!e.isLightConstant&&t}function Fy(e,t,i,n,r,o,s,a){let l=(61440&t|(61440&t)>>4)>>8,c=(3840&t|(3840&t)>>4)>>4,u=240&t|(240&t)>>4;i[3]>0&&(l=di(l,255*i[0],i[3]),c=di(c,255*i[1],i[3]),u=di(u,255*i[2],i[3]));const h=l<<8|c,d=u<<8|Math.floor(255*n[3]),p=function(e){const t=Fe(e,0,2);return Math.min(Math.round(.5*t*255),255)}(n[2])<<8|15*n[0]<<4|15*n[1],f=Fe(r[0],0,1),m=Fe(r[1],0,1),g=Fe(r[2],0,1),_=Fe(r[3],0,1);let A,y,v,x;if(f!==m&&s!==o&&m!==f){const e=s-o;y=1/(e*(m-f)),v=-(o+e*f)/(e*(m-f));const t=Fe(r[4],-1,1);x=Math.pow(10,t),A=255*g<<8|255*_}else A=65535,y=0,v=1,x=1;if(e.emplaceBack(h,d,p,A,y,v,x),a){const e=a.length;a.clear();for(let t=0;t>16&65535,a=o?t>>16&65535:65535&t,l=(15&a)<8?15&a:0,c=e.evaluatedRMEA[l],u=e.evaluatedColor[l],h=e.emissionHeightBasedParams[l];let d;if(s&&2===l&&n.lights&&(d=new $a,d.resize(10*n.lights.length)),Fy(i.featureArray,r,u,c,h,i.aabb.min[2],i.aabb.max[2],d),d&&s){s=!1;const e=n.meshes[n.lightMeshIndex];e.featureArray=d,e.featureArray._trim()}}i.featureArray._trim(),r++}}es(Ry,"Tiled3dModelBucket",{omit:["layers"]}),es(Py,"Tiled3dModelFeature");const Dy=["id","tile","layer","source","sourceLayer","state"];class Oy{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 Oy(this._vectorTileFeature,this._z,this._x,this._y,this.id);return this.state&&(e.state=Object.assign({},this.state)),this.layer&&(e.layer=Object.assign({},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 Dy)void 0!==this[t]&&(e[t]=this[t]);return e}}class zy extends ni{constructor(e,t,i,n){super(),this.id=e,this.type="model",this.models=[],this._loaded=!1,this._options=t,this._modelsInfo=new Map}load(){const e=[];for(const t in this._options.models){const i=this._options.models[t],n=this._modelsInfo.get(t);if(n){const e=n.model;e.position=null!=i.position?new rc(i.position[0],i.position[1]):new rc(0,0),e.orientation=null!=i.orientation?i.orientation:[0,0,0],n.modelSpec=i,zy.applyModelSpecification(e,i),e.computeBoundsAndApplyParent(),this.models.push(e)}else{const n=Sf(this.map._requestManager.transformRequest(i.uri,kt.Model).url).then(e=>{if(!e)return;const n=hm(e),r=new Jf(t,i.uri,i.position,i.orientation,n);zy.applyModelSpecification(r,i),r.computeBoundsAndApplyParent(),this.models.push(r),this._modelsInfo.set(t,{modelSpec:i,model:r})}).catch(e=>{this.fire(new ei(new Error(`Could not load model ${t} from ${i.uri}: ${e.message}`)))});e.push(n)}}Promise.allSettled(e).then(()=>{this._loaded=!0,this.fire(new Yt("data",{dataType:"source",sourceDataType:"metadata"}))}).catch(e=>{this._loaded=!0,this.fire(new ei(new Error(`Could not load models: ${e.message}`)))})}static applyModelSpecification(e,t){t.nodeOverrides&&zy.convertNodeOverrides(e,t.nodeOverrides),t.materialOverrides&&zy.convertMaterialOverrides(e,t.materialOverrides),t.nodeOverrideNames&&(e.nodeOverrideNames=[...t.nodeOverrideNames]),t.materialOverrideNames&&(e.materialOverrideNames=[...t.materialOverrideNames]),t.featureProperties&&(e.featureProperties=t.featureProperties)}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]};if(i.hasOwnProperty("orientation")){const e=i.orientation;e&&(n.orientation=e)}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={color:new li(1,1,1),colorMix:0,emissionStrength:0,opacity:1},r=i["model-color"];void 0!==r&&(n.color.r=r[0],n.color.g=r[1],n.color.b=r[2]);const o=i["model-color-mix-intensity"];void 0!==o&&(n.colorMix=o);const s=i["model-emissive-strength"];void 0!==s&&(n.emissionStrength=s);const a=i["model-opacity"];void 0!==a&&(n.opacity=a),e.materialOverrides.set(t,n)})}onAdd(e){this.map=e,this.load()}hasTransition(){return!1}loaded(){return this._loaded}getModels(){return this.models}loadTile(e,t){}serialize(){return this._options}setProperty(e,t){return!1}reload(){const e=ta(this.id,this.scope);this.map.style.clearSource(e),this.models=[],this._modelsInfo.clear(),this._loaded=!1,this.load()}setModels(e){this.models=[];const t=new Map;for(const i in e){const n=e[i];if(this._modelsInfo.has(i)){const e=this._modelsInfo.get(i);e&&e.modelSpec.uri===n.uri&&t.set(i,e)}}this._modelsInfo=t,this._options.models=e,this._loaded=!1,this.load()}}function Uy(e,t,i,n){const r=1<e.polygon).flat());const g=p?a:null,[_,A]=Np(o,n,h,u,c,s,g,d,f,o.center.lat,e.tileID.canonical),y=e.queryGeometry;return Up(_,A,y.isPointQuery()?y.screenBounds:y.screenGeometry)}},building:class extends aa{constructor(e,t,i,n){super(e,{layout:Pm||(Pm=new Os({visibility:new Fs(zs.layout_building.visibility),"building-facade":new ks(zs.layout_building["building-facade"]),"building-facade-floors":new ks(zs.layout_building["building-facade-floors"]),"building-facade-unit-width":new ks(zs.layout_building["building-facade-unit-width"]),"building-facade-window":new ks(zs.layout_building["building-facade-window"]),"building-roof-shape":new ks(zs.layout_building["building-roof-shape"]),"building-height":new ks(zs.layout_building["building-height"]),"building-base":new ks(zs.layout_building["building-base"]),"building-flood-light-wall-radius":new ks(zs.layout_building["building-flood-light-wall-radius"]),"building-flood-light-ground-radius":new ks(zs.layout_building["building-flood-light-ground-radius"]),"building-flip-roof-orientation":new ks(zs.layout_building["building-flip-roof-orientation"])})),paint:Rm||(Rm=new Os({"building-opacity":new Fs(zs.paint_building["building-opacity"]),"building-ambient-occlusion-intensity":new Fs(zs.paint_building["building-ambient-occlusion-intensity"]),"building-ambient-occlusion-ground-intensity":new Fs(zs.paint_building["building-ambient-occlusion-ground-intensity"]),"building-ambient-occlusion-ground-radius":new Fs(zs.paint_building["building-ambient-occlusion-ground-radius"]),"building-ambient-occlusion-ground-attenuation":new Fs(zs.paint_building["building-ambient-occlusion-ground-attenuation"]),"building-vertical-scale":new Fs(zs.paint_building["building-vertical-scale"]),"building-cast-shadows":new Fs(zs.paint_building["building-cast-shadows"]),"building-color":new ks(zs.paint_building["building-color"]),"building-emissive-strength":new ks(zs.paint_building["building-emissive-strength"]),"building-facade-emissive-chance":new Fs(zs.paint_building["building-facade-emissive-chance"]),"building-cutoff-fade-range":new Fs(zs.paint_building["building-cutoff-fade-range"]),"building-flood-light-color":new Fs(zs.paint_building["building-flood-light-color"]),"building-flood-light-intensity":new Fs(zs.paint_building["building-flood-light-intensity"]),"building-flood-light-ground-attenuation":new Fs(zs.paint_building["building-flood-light-ground-attenuation"]),"building-color-use-theme":new ks({type:"string",default:"default","property-type":"data-driven"}),"building-flood-light-color-use-theme":new ks({type:"string",default:"default","property-type":"data-driven"})}))},t,i,n),this._stats={numRenderedVerticesInShadowPass:0,numRenderedVerticesInTransparentPass:0}}createBucket(e){return new Im(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,s,a,l){let c=this.layout.get("building-height").evaluate(t,i);const u=this.layout.get("building-base").evaluate(t,i),h=e.tile.getBucket(this).getFootprint(t);if(h){if(0!==h.hiddenFlags)return!1;c=h.height}const[d,p]=Np(o,n,u,c,new Te(0,0),s,null,[0,0],1,o.center.lat,e.tileID.canonical),f=e.queryGeometry;return Up(d,p,f.isPointQuery()?f.screenBounds:f.screenGeometry)}},line:class extends aa{constructor(e,t,i,n){const r=tg();super(e,r,t,i,n),r.layout&&(this.layout=new Ls(r.layout)),this.gradientVersion=0,this.hasElevatedBuckets=!1,this.hasNonElevatedBuckets=!1}_handleSpecialPaintPropertyUpdate(e){if("line-gradient"===e){const e=this._transitionablePaint._values["line-gradient"].value.expression;this.stepInterpolant=e._styleExpression&&e._styleExpression.expression instanceof Br,this.gradientVersion=(this.gradientVersion+1)%Number.MAX_SAFE_INTEGER}}gradientExpression(){return this._transitionablePaint._values["line-gradient"].value.expression}widthExpression(){return this._transitionablePaint._values["line-width"].value.expression}recalculate(e,t){super.recalculate(e,t),this.paint._values["line-floorwidth"]=(()=>{if(ng)return ng;const e=tg();return ng=new ig(e.paint.properties["line-width"].specification),ng.useIntegerZoom=!0,ng})().possiblyEvaluate(this._transitioningPaint._values["line-width"].value,e)}createBucket(e){return new Hm(e)}getProgramIds(){return[this.paint.get("line-pattern").constantOr(1)?"linePattern":"line"]}getDefaultProgramParams(e,t,i){const n=Jm(this);return{config:new Ul(this,{zoom:t,lut:i}),defines:n,overrideFog:!1}}queryRadius(e){const t=e,i=rg(vu("line-width",this,t),vu("line-gap-width",this,t)),n=vu("line-offset",this,t);return i/2+Math.abs(n)+xu(this.paint.get("line-translate"))}queryIntersectsFeature(e,t,i,n,r,o){if(e.queryGeometry.isAboveHorizon)return!1;const s=bu(e.tilespaceGeometry,this.paint.get("line-translate"),this.paint.get("line-translate-anchor"),o.angle,e.pixelToTileUnitsFactor),a=e.pixelToTileUnitsFactor/2*rg(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 Te(0,0);for(let r=0;r=3)for(let t=0;t>16&255)/255,(e>>8&255)/255,(255&e)/255,1)}function hv(e,t,i){1===e?(t.rgb_color=uv(i.readVarint()),t.paint="rgb_color"):2===e?(t.linear_gradient_idx=i.readVarint(),t.paint="linear_gradient_idx"):3===e?(t.radial_gradient_idx=i.readVarint(),t.paint="radial_gradient_idx"):5===e?i.readPackedFloat(t.dasharray):6===e?t.dashoffset=i.readFloat():7===e?t.miterlimit=i.readFloat():8===e?t.opacity=i.readVarint():9===e?t.width=i.readFloat():10===e?t.linecap=i.readVarint():11===e&&(t.linejoin=i.readVarint())}function dv(e,t,i){1===e?t.transform=sv(i,i.readVarint()+i.pos):2===e?t.spread_method=i.readVarint():3===e?t.stops.push(pv(i,i.readVarint()+i.pos)):4===e?t.x1=i.readFloat():5===e?t.y1=i.readFloat():6===e?t.x2=i.readFloat():7===e&&(t.y2=i.readFloat())}function pv(e,t){return e.readFields(fv,{offset:0,opacity:255,rgb_color:jy},t)}function fv(e,t,i){1===e?t.offset=i.readFloat():2===e?t.opacity=i.readVarint():3===e&&(t.rgb_color=uv(i.readVarint()))}function mv(e,t,i){1===e?t.transform=sv(i,i.readVarint()+i.pos):2===e?t.spread_method=i.readVarint():3===e?t.stops.push(pv(i,i.readVarint()+i.pos)):4===e?t.cx=i.readFloat():5===e?t.cy=i.readFloat():6===e?t.r=i.readFloat():7===e?t.fx=i.readFloat():8===e?t.fy=i.readFloat():9===e&&(t.fr=i.readFloat())}function gv(e,t,i){1===e?t.transform=sv(i,i.readVarint()+i.pos):2===e?t.clip_path_idx=i.readVarint():3===e&&t.children.push(nv(i,i.readVarint()+i.pos))}function _v(e,t,i){1===e?t.left=t.top=i.readFloat():2===e?t.width=t.height=i.readFloat():3===e?t.top=i.readFloat():4===e?t.height=i.readFloat():5===e?t.mask_type=i.readVarint():6===e?t.mask_idx=i.readVarint():7===e&&t.children.push(nv(i,i.readVarint()+i.pos))}class Av{static calculate(e={},t=[]){const i=new Map,n=new Map;if(0===Object.keys(e).length)return i;t.forEach(e=>{n.set(e.name,e.rgb_color||new li(0,0,0))});for(const[t,r]of Object.entries(e))n.has(t)?i.set(n.get(t).toString(),r):console.warn(`Ignoring unknown image variable "${t}"`);return i}}function yv(e,t=255,i){const n=t/255,r=e.toString(),o=i.has(r)?i.get(r).clone():e.clone();return o.a*=n,o.toString()}function vv(e,t){if(!mt()){const i=document.createElement("canvas");return i.width=e,i.height=t,i}return new OffscreenCanvas(e,t)}function xv(e,t){const i=Av.calculate(t.params,e.metadata?e.metadata.variables:[]),n=e.usvg_tree,r=n.width,o=n.height,s=t.transform?t.transform:new DOMMatrix,a=Math.max(1,Math.round(r*s.a)),l=Math.max(1,Math.round(o*s.d)),c=new DOMMatrix([a/r,0,0,l/o,0,0]),u=vv(a,l).getContext("2d");return bv(u,c,n,n,i),u.getImageData(0,0,a,l)}function bv(e,t,i,n,r){for(const o of n.children)wv(e,t,i,o,r)}function wv(e,t,i,n,r){n.group?(e.save(),function(e,t,i,n,r){const o=null!=n.mask_idx?i.masks[n.mask_idx]:null,s=null!=n.clip_path_idx?i.clip_paths[n.clip_path_idx]:null;if(n.transform&&(t=Rv(n.transform).preMultiplySelf(t)),!function(e,t,i){return 255!==e.opacity||t||i}(n,null!=s,null!=o))return void bv(e,t,i,n,r);const a=vv(e.canvas.width,e.canvas.height),l=a.getContext("2d");bv(l,t,i,n,r),s&&Mv(l,t,i,s),o&&Pv(l,t,i,o,r),e.globalAlpha=n.opacity/255,e.drawImage(a,0,0)}(e,t,i,n.group,r),e.restore()):n.path&&(e.save(),function(e,t,i,n,r){e.setTransform(t),n.paint_order===$y.PAINT_ORDER_FILL_AND_STROKE?(Tv(e,i,n,r),Cv(e,i,n,r)):(Cv(e,i,n,r),Tv(e,i,n,r))}(e,t,i,n.path,r),e.restore())}function Tv(e,t,i,n){const r=i.fill;if(!r)return;const o=r.opacity/255;switch(e.save(),e.beginPath(),Lv(i,e),r.paint){case"rgb_color":e.fillStyle=yv(r.rgb_color,r.opacity,n);break;case"linear_gradient_idx":{const i=t.linear_gradients[r.linear_gradient_idx];i.transform&&e.setTransform(Rv(i.transform).preMultiplySelf(e.getTransform())),e.fillStyle=Sv(e,i,o,n);break}case"radial_gradient_idx":{const i=t.radial_gradients[r.radial_gradient_idx];i.transform&&e.setTransform(Rv(i.transform).preMultiplySelf(e.getTransform())),e.fillStyle=Bv(e,i,o,n)}}e.fill(Ev(i)),e.restore()}function Ev(e){return e.rule===Gy.PATH_RULE_NON_ZERO?"nonzero":e.rule===Gy.PATH_RULE_EVEN_ODD?"evenodd":void 0}function Cv(e,t,i,n){const r=i.stroke;if(!r)return;const o=Fv(i);e.lineWidth=r.width,e.miterLimit=r.miterlimit,e.setLineDash(r.dasharray),e.lineDashOffset=r.dashoffset;const s=r.opacity/255;switch(r.paint){case"rgb_color":e.strokeStyle=yv(r.rgb_color,r.opacity,n);break;case"linear_gradient_idx":e.strokeStyle=Sv(e,t.linear_gradients[r.linear_gradient_idx],s,n,!0);break;case"radial_gradient_idx":e.strokeStyle=Bv(e,t.radial_gradients[r.radial_gradient_idx],s,n,!0)}switch(r.linejoin){case Qy.LINE_JOIN_MITER_CLIP:case Qy.LINE_JOIN_MITER:e.lineJoin="miter";break;case Qy.LINE_JOIN_ROUND:e.lineJoin="round";break;case Qy.LINE_JOIN_BEVEL:e.lineJoin="bevel"}switch(r.linecap){case Hy.LINE_CAP_BUTT:e.lineCap="butt";break;case Hy.LINE_CAP_ROUND:e.lineCap="round";break;case Hy.LINE_CAP_SQUARE:e.lineCap="square"}e.stroke(o)}function Sv(e,t,i,n,r=!1){if(1===t.stops.length){const e=t.stops[0];return yv(e.rgb_color,e.opacity*i,n)}const{x1:o,y1:s,x2:a,y2:l}=t;let c=new DOMPoint(o,s),u=new DOMPoint(a,l);if(r){const e=Rv(t.transform);c=e.transformPoint(c),u=e.transformPoint(u)}const h=e.createLinearGradient(c.x,c.y,u.x,u.y);for(const e of t.stops)h.addColorStop(e.offset,yv(e.rgb_color,e.opacity*i,n));return h}function Bv(e,t,i,n,r=!1){if(1===t.stops.length){const e=t.stops[0];return yv(e.rgb_color,e.opacity*i,n)}const o=Rv(t.transform),{fx:s,fy:a,fr:l,cx:c,cy:u,r:h}=t;let d=new DOMPoint(s,a),p=new DOMPoint(c,u),f=l,m=h;if(r){d=o.transformPoint(d),p=o.transformPoint(p);const e=(o.a+o.d)/2;f=l*e,m=t.r*e}const g=e.createRadialGradient(d.x,d.y,f,p.x,p.y,m);for(const e of t.stops)g.addColorStop(e.offset,yv(e.rgb_color,e.opacity*i,n));return g}function Iv(e,t,i,n){const r=n.transform?Rv(n.transform).preMultiplySelf(t):t,o=vv(e.canvas.width,e.canvas.height),s=o.getContext("2d");for(const e of n.children)if(e.group)Iv(s,r,i,e.group);else if(e.path){const t=e.path,i=new Path2D;i.addPath(Fv(t),r),s.fill(i,Ev(t))}const a=null!=n.clip_path_idx?i.clip_paths[n.clip_path_idx]:null;a&&Mv(s,r,i,a),e.globalCompositeOperation="source-over",e.drawImage(o,0,0)}function Mv(e,t,i,n){const r=vv(e.canvas.width,e.canvas.height);Iv(r.getContext("2d"),t,i,n),e.globalCompositeOperation="destination-in",e.drawImage(r,0,0)}function Pv(e,t,i,n,r){if(0===n.children.length)return;const o=null!=n.mask_idx?i.masks[n.mask_idx]:null;o&&Pv(e,t,i,o,r);const s=e.canvas.width,a=e.canvas.height,l=vv(s,a),c=l.getContext("2d"),u=n.width,h=n.height,d=n.left,p=n.top,f=new Path2D,m=new Path2D;m.rect(d,p,u,h),f.addPath(m,t),c.clip(f);for(const e of n.children)wv(c,t,i,e,r);const g=c.getImageData(0,0,s,a),_=g.data;if(n.mask_type===Wy.MASK_TYPE_LUMINANCE)for(let e=0;e<_.length;e+=4)_[e+3]=_[e+3]/255*(.2126*_[e]+.7152*_[e+1]+.0722*_[e+2]);c.putImageData(g,0,0),e.globalCompositeOperation="destination-in",e.drawImage(l,0,0)}function Rv(e){return e?new DOMMatrix([e.sx,e.ky,e.kx,e.sy,e.tx,e.ty]):new DOMMatrix}function Lv(e,t){const i=e.step;let n=e.diffs[0]*i,r=e.diffs[1]*i;t.moveTo(n,r);for(let o=0,s=2;ot[s])return null}else{const a=1/n[s];let l=(e[s]-i[s])*a,c=(t[s]-i[s])*a;if(l>c){const e=l;l=c,c=e}if(l>r&&(r=l),co)return null}return r}function Uv(e,t,i,n,r,o,s,a,l,c,u){const h=n-e,d=r-t,p=o-i,f=s-e,m=a-t,g=l-i,_=u[1]*g-u[2]*m,A=u[2]*f-u[0]*g,y=u[0]*m-u[1]*f,v=h*_+d*A+p*y;if(Math.abs(v)<1e-15)return null;const x=1/v,b=c[0]-e,w=c[1]-t,T=c[2]-i,E=(b*_+w*A+T*y)*x;if(E<0||E>1)return null;const C=w*p-T*d,S=T*h-b*p,B=b*d-w*h,I=(u[0]*C+u[1]*S+u[2]*B)*x;return I<0||E+I>1?null:(f*C+m*S+g*B)*x}function Nv(e,t,i){return(e-t)/(i-t)}function Vv(e,t,i,n,r,o,s,a,l){const c=1<{const o=n?1:0,s=(e+1)*i-o,a=t*i,l=(t+1)*i-o;r[0]=e*i,r[1]=a,r[2]=s,r[3]=l};let s=new Ov(n);const a=[];for(let t=0;t=1;n/=2){const e=i[i.length-1];s=new Ov(n);for(let t=0;t0;){const{idx:a,t:p,nodex:f,nodey:m,depth:g}=d.pop();if(this.leaves[a]){Vv(f,m,g,e,t,i,n,u,h);const a=1<=e[2])return p}continue}let _=0;for(let d=0;d=l[c[i]]&&(c.splice(i,0,d),t=!0);t||(c[_]=d),_++}}for(let e=0;e<_;e++){const t=c[e];d.push({idx:this.childOffsets[a]+t,t:l[t],nodex:(f<<1)+this._siblingOffset[t][0],nodey:(m<<1)+this._siblingOffset[t][1],depth:g+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,s=e[o];let a=0,l=0;for(let e=0;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=Wv.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 Th({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,s=i*this.dim+this.dim;switch(t){case-1:n=r-1;break;case 1:r=n+1}switch(i){case-1:o=s-1;break;case 1:s=o+1}const a=-t*this.dim,l=-i*this.dim;for(let t=o;t=1;n--){const r=1===n?1:0,o=2===n?1:0;for(let n=0;n>>1^-(1&e[t]);return e}function ox(e,t){switch(t){case"uint32":return e;case"uint16":for(let t=0;t>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>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}"`)}}es(Wv,"DEMData"),es(jv,"DemMinMaxQuadTree",{omit:["dem"]});var sx=Uint8Array,ax=Uint16Array,lx=Int32Array,cx=new sx([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]),ux=new sx([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]),hx=new sx([16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15]),dx=function(e,t){for(var i=new ax(31),n=0;n<31;++n)i[n]=t+=1<>1|(21845&Ax)<<1;_x[Ax]=((65280&(yx=(61680&(yx=(52428&yx)>>2|(13107&yx)<<2))>>4|(3855&yx)<<4))>>8|(255&yx)<<8)>>1}var vx=function(e,t,i){for(var n=e.length,r=0,o=new ax(t);r>l]=c;return s},xx=new sx(288);for(Ax=0;Ax<144;++Ax)xx[Ax]=8;for(Ax=144;Ax<256;++Ax)xx[Ax]=9;for(Ax=256;Ax<280;++Ax)xx[Ax]=7;for(Ax=280;Ax<288;++Ax)xx[Ax]=8;var bx=new sx(32);for(Ax=0;Ax<32;++Ax)bx[Ax]=5;var wx=vx(xx,9),Tx=vx(bx,5),Ex=function(e){for(var t=e[0],i=1;it&&(t=e[i]);return t},Cx=function(e,t,i){var n=t/8|0;return(e[n]|e[n+1]<<8)>>(7&t)&i},Sx=function(e,t){var i=t/8|0;return(e[i]|e[i+1]<<8|e[i+2]<<16)>>(7&t)},Bx=["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"],Ix=function(e,t,i){var n=new Error(t||Bx[e]);if(n.code=e,Error.captureStackTrace&&Error.captureStackTrace(n,Ix),!i)throw n;return n},Mx=new sx(0),Px="undefined"!=typeof TextDecoder&&new TextDecoder;try{Px.decode(Mx,{stream:!0})}catch(e){}const Rx={gzip_data:"gzip"};class Lx extends Error{constructor(e){super(e),this.name="MRTError"}}const Fx={0:"uint32",1:"uint32",2:"uint16",3:"uint8"},kx={uint32:1,uint16:2,uint8:4},Dx={uint32:Uint32Array,uint16:Uint16Array,uint8:Uint8Array};let Ox;class zx{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 Lx(`Layer '${e}' not found`);return t}getHeaderLength(e){const t=new Uint8Array(e),i=new DataView(e);if(13!==t[0])throw new Lx("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} but got buffer of length ${t.length}`);const n=new Ox(t.subarray(0,i)).readFields(qv,{headerLength:0,x:0,y:0,z:0,layers:[]},void 0);if(!isNaN(this.x)&&(this.x!==n.x||this.y!==n.y||this.z!==n.z))throw new Lx(`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 Ux(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,s=r.lastByte-e.firstByte;if(i._blocksInProgress.has(n))continue;const a={layerName:i.name,firstByte:o,lastByte:s,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(a)}return new Nx(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 Ux{constructor({version:e,name:t,units:i,tileSize:n,pixelFormat:r,buffer:o,dataIndex:s},a){if(this.version=e,1!==this.version)throw new Lx(`Cannot parse raster layer encoded with MRT version ${e}`);this.name=t,this.units=i,this.tileSize=n,this.buffer=o,this.pixelFormat=Fx[r],this.dataIndex=s,this.bandShape=[n+2*o,n+2*o,kx[this.pixelFormat]],this._decodedBlocks=new kv(a?a.cacheSize:5),this._blocksInProgress=new Set}get dimension(){return kx[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&&ethis.cacheSize)throw new Lx(`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 Lx(`Band not found: ${JSON.stringify(e)}`);const n=this._decodedBlocks.get(t.toString());if(!n)throw new Lx(`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),s=i*o,a=n.subarray(s,s+o);return{data:a,bytes:new Uint8Array(a.buffer).subarray(a.byteOffset,a.byteOffset+a.byteLength),tileSize:this.tileSize,buffer:this.buffer,pixelFormat:this.pixelFormat,dimension:this.dimension,offset:r.offset,scale:r.scale}}}zx.setPbf=function(e){Ox=e};class Nx{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)}}zx.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:s,blockIndex:a,filters:l,codec:c}=e,u=i.subarray(n,r+1),h=new Uint32Array(s[0]*s[1]*s[2]);let d;if("gzip_data"!==c)throw new Lx(`Unhandled codec: ${c}`);return d=function(e,t){if(!globalThis.DecompressionStream&&"gzip_data"===t)return Promise.resolve(((o=function(e){31==e[0]&&139==e[1]&&8==e[2]||Ix(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)}(r=e))+8>r.length&&Ix(6,"invalid gzip data"),function(e,t,i){var n=e.length;if(!n||t.f&&!t.l)return i||new sx(0);var r=!i,o=r||2!=t.i,s=t.i;r&&(i=new sx(3*n));var a,l,c=function(e){var t=i.length;if(e>t){var n=new sx(Math.max(2*t,e));n.set(i),i=n}},u=t.f||0,h=t.p||0,d=t.b||0,p=t.l,f=t.d,m=t.m,g=t.n,_=8*n;do{if(!p){u=Cx(e,h,1);var A=Cx(e,h+1,3);if(h+=3,!A){var y=e[(M=4+((h+7)/8|0))-4]|e[M-3]<<8,v=M+y;if(v>n){s&&Ix(0);break}o&&c(d+y),i.set(e.subarray(M,v),d),t.b=d+=y,t.p=h=8*v,t.f=u;continue}if(1==A)p=wx,f=Tx,m=9,g=5;else if(2==A){var x=Cx(e,h,31)+257,b=Cx(e,h+10,15)+4,w=x+Cx(e,h+5,31)+1;h+=14;for(var T=new sx(w),E=new sx(19),C=0;C>4)<16)T[C++]=M;else{var R=0,L=0;for(16==M?(L=3+Cx(e,h,3),h+=2,R=T[C-1]):17==M?(L=3+Cx(e,h,7),h+=3):18==M&&(L=11+Cx(e,h,127),h+=7);L--;)T[C++]=R}}var F=T.subarray(0,x),k=T.subarray(x);m=Ex(F),g=Ex(k),p=vx(F,m),f=vx(k,g)}else Ix(1);if(h>_){s&&Ix(0);break}}o&&c(d+131072);for(var D=(1<>4;if((h+=15&R)>_){s&&Ix(0);break}if(R||Ix(2),U<256)i[d++]=U;else{if(256==U){z=h,p=null;break}var N=U-254;U>264&&(N=Cx(e,h,(1<<(G=cx[C=U-257]))-1)+fx[C],h+=G);var V=f[Sx(e,h)&O],j=V>>4;if(V||Ix(3),h+=15&V,k=gx[j],j>3){var G=ux[j];k+=Sx(e,h)&(1<_){s&&Ix(0);break}o&&c(d+131072);var H=d+N;if(da.length)&&(l=a.length),new sx(a.subarray(0,l))):i.subarray(0,d)}(r.subarray(o,-8),{i:2},new sx(((i=r)[(n=i.length)-4]|i[n-3]<<8|i[n-2]<<16|i[n-1]<<24)>>>0))));var i,n,r,o;const s=Rx[t];if(!s)throw new Error(`Unhandled codec: ${t}`);const a=new globalThis.DecompressionStream(s);return new Response(new Blob([e]).stream().pipeThrough(a)).arrayBuffer().then(e=>new Uint8Array(e))}(u,c).then(e=>(function(e,t){e.readFields(tx,t)}(new Ox(e),h),new Dx[o](h.buffer))),d.then(e=>{for(let t=l.length-1;t>=0;t--)switch(l[t]){case"delta_filter":nx(e,s);break;case"zigzag_filter":rx(e);break;case"bitshuffle_filter":ox(e,o);break;default:throw new Lx(`Unhandled filter "${l[t]}"`)}return{layerName:t,blockIndex:a,data:e}}).catch(e=>{throw e})}))},es(Nx,"MRTDecodingBatch",{omit:["_onCancel","_onComplete"]}),es(zx,"MapboxRasterTile"),es(Ux,"MapboxRasterLayer",{omit:["_blocksInProgress"]});class Vx{constructor(e){this._stringToNumber={},this._numberToString=[];for(let t=0;t=0&&n[3]>=0&&l.insert(a,n[0],n[1],n[2],n[3])}}loadVTLayers(){if(!this.vtLayers){this.vtLayers=new kc(new wg(this.rawTileData)).layers,this.sourceLayerCoder=new Vx(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:s,worldview:a}=t;this.loadVTLayers(),this.serializedLayersCache.clear();const l=t.queryRadius?t.queryRadius:0,c=i.bufferedTilespaceBounds,u=this.grid.query(c.min.x,c.min.y,c.max.x,c.max.y,(e,t,n,r)=>gu(i.bufferedTilespaceGeometry,e-l,t-l,n+l,r+l));u.sort(Hx);let h=null;n.elevation&&u.length>0&&(h=Ey.create(n.elevation,this.tileID));const d={};let p;for(let t=0;t(f||(f=Bc(e,this.tileID.canonical,r)),t.queryIntersectsFeature(i,e,s,f,this.z,n,o,h,a)))}return d}loadMatchingFeature(e,t,i,n,r,o){const{featureIndex:s,bucketIndex:a,sourceLayerIndex:l,layoutVertexArrayOffset:c}=t,u=this.bucketLayerIDs[a],h=i.layers,d=Object.keys(h);if(d.length&&!Qe(d,u))return;const p=i.sourceCache,f=this.sourceLayerCoder.decode(l),m=this.vtLayers[f].feature(s),g=this.getId(m,f);for(let t=0;t`${e.key}: ${e.message}`).join(", ")}`);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 Gx(e,t,i,n,r){return je(e,(e,o)=>{const s=t instanceof Ls?t.get(o):null;return s&&s.evaluate?s.evaluate(i,n,void 0,r):s})}function Hx(e,t){return t-e}es(jx,"FeatureIndex",{omit:["rawTileData","sourceLayerCoder"]});const Qx=[Int8Array,Uint8Array,Uint8ClampedArray,Int16Array,Uint16Array,Int32Array,Uint32Array,Float32Array,Float64Array];class $x{static from(e){if(!(e instanceof ArrayBuffer))throw new Error("Data must be an instance of ArrayBuffer.");const[t,i]=new Uint8Array(e,0,2);if(219!==t)throw new Error("Data does not appear to be in a KDBush format.");const n=i>>4;if(1!==n)throw new Error(`Got v${n} data when expected v1.`);const r=Qx[15&i];if(!r)throw new Error("Unrecognized array type.");const[o]=new Uint16Array(e,2,1),[s]=new Uint32Array(e,4,1);return new $x(s,o,r,e)}constructor(e,t=64,i=Float64Array,n){if(isNaN(e)||e<0)throw new Error(`Unpexpected numItems value: ${e}.`);this.numItems=+e,this.nodeSize=Math.min(Math.max(+t,2),65535),this.ArrayType=i,this.IndexArrayType=e<65536?Uint16Array:Uint32Array;const r=Qx.indexOf(this.ArrayType),o=2*e*this.ArrayType.BYTES_PER_ELEMENT,s=e*this.IndexArrayType.BYTES_PER_ELEMENT,a=(8-s%8)%8;if(r<0)throw new Error(`Unexpected typed array class: ${i}.`);n&&n instanceof ArrayBuffer?(this.data=n,this.ids=new this.IndexArrayType(this.data,8,e),this.coords=new this.ArrayType(this.data,8+s+a,2*e),this._pos=2*e,this._finished=!0):(this.data=new ArrayBuffer(8+o+s+a),this.ids=new this.IndexArrayType(this.data,8,e),this.coords=new this.ArrayType(this.data,8+s+a,2*e),this._pos=0,this._finished=!1,new Uint8Array(this.data,0,2).set([219,16+r]),new Uint16Array(this.data,2,1)[0]=t,new Uint32Array(this.data,4,1)[0]=e)}add(e,t){const i=this._pos>>1;return this.ids[i]=i,this.coords[this._pos++]=e,this.coords[this._pos++]=t,i}finish(){const e=this._pos>>1;if(e!==this.numItems)throw new Error(`Added ${e} items when expected ${this.numItems}.`);return Zx(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:s}=this,a=[0,r.length-1,0],l=[];for(;a.length;){const c=a.pop()||0,u=a.pop()||0,h=a.pop()||0;if(u-h<=s){for(let s=h;s<=u;s++){const a=o[2*s],c=o[2*s+1];a>=e&&a<=i&&c>=t&&c<=n&&l.push(r[s])}continue}const d=h+u>>1,p=o[2*d],f=o[2*d+1];p>=e&&p<=i&&f>=t&&f<=n&&l.push(r[d]),(0===c?e<=p:t<=f)&&(a.push(h),a.push(d-1),a.push(1-c)),(0===c?i>=p:n>=f)&&(a.push(d+1),a.push(u),a.push(1-c))}return l}within(e,t,i){if(!this._finished)throw new Error("Data not yet indexed - call index.finish().");const{ids:n,coords:r,nodeSize:o}=this,s=[0,n.length-1,0],a=[],l=i*i;for(;s.length;){const c=s.pop()||0,u=s.pop()||0,h=s.pop()||0;if(u-h<=o){for(let i=h;i<=u;i++)Xx(r[2*i],r[2*i+1],e,t)<=l&&a.push(n[i]);continue}const d=h+u>>1,p=r[2*d],f=r[2*d+1];Xx(p,f,e,t)<=l&&a.push(n[d]),(0===c?e-i<=p:t-i<=f)&&(s.push(h),s.push(d-1),s.push(1-c)),(0===c?e+i>=p:t+i>=f)&&(s.push(d+1),s.push(u),s.push(1-c))}return a}}function Zx(e,t,i,n,r,o){if(r-n<=i)return;const s=n+r>>1;Wx(e,t,s,n,r,o),Zx(e,t,i,n,s-1,1-o),Zx(e,t,i,s+1,r,1-o)}function Wx(e,t,i,n,r,o){for(;r>n;){if(r-n>600){const s=r-n+1,a=i-n+1,l=Math.log(s),c=.5*Math.exp(2*l/3),u=.5*Math.sqrt(l*c*(s-c)/s)*(a-s/2<0?-1:1);Wx(e,t,i,Math.max(n,Math.floor(i-a*c/s+u)),Math.min(r,Math.floor(i+(s-a)*c/s+u)),o)}const s=t[2*i+o];let a=n,l=r;for(qx(e,t,n,i),t[2*r+o]>s&&qx(e,t,n,r);as;)l--}t[2*n+o]===s?qx(e,t,n,l):(l++,qx(e,t,l,r)),l<=i&&(n=l+1),i<=l&&(r=l-1)}}function qx(e,t,i,n){Kx(e,i,n),Kx(t,2*i,2*n),Kx(t,2*i+1,2*n+1)}function Kx(e,t,i){const n=e[t];e[t]=e[i],e[i]=n}function Xx(e,t,i,n){const r=e-i,o=t-n;return r*r+o*o}e.$=Yi,e.A=Oi,e.B=ta,e.C=2,e.D=Wp,e.E=ni,e.F=y_,e.G=__,e.H=Ki,e.I=ri,e.J=Us,e.K=qi,e.L=Ji,e.M=Ro,e.N=Io,e.O=Po,e.P=Te,e.Q=jo,e.R=kt,e.S=Ns,e.T=Mf,e.U=Go,e.V=Ay,e.W=$o,e.X=yr,e.Y=_r,e.Z=Ar,e._=on,e.a=function(e){return st.API_CDN_URL_REGEX.test(e)},e.a$=ma,e.a0=Xi,e.a1=ai,e.a2=Vs,e.a3=class extends Ay{},e.a4=Lo,e.a5=Mo,e.a6=zs,e.a7=function(e){const t=e.value;return t?Xi(t)?yy(t,!0)?[]:[new Ay(e.key,t,`invalid url "${t}"`)]:[new Ay(e.key,t,`string expected, "${qi(t)}" found`)]:[]},e.a8=Bs,e.a9=Os,e.aA=Fe,e.aB=h,e.aC=Y,e.aD=$l,e.aE=mu,e.aF=cc,e.aG=bc,e.aH=function(e,t){const i={};for(let n=0;n{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]))}}},e.aL=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",isSymbolTile:e.isSymbolTile,zoom:e.tileZoom},t=>{const n=Ut(e.request,(e,n,r)=>{e?t(e):n&&t(null,{vectorTile:i?void 0:new kc(new wg(n)),rawData:n,responseHeaders:new Map(r.entries())})});return()=>{n.cancel(),t()}},t)},e.aM=function(e){return e?{cacheControl:e.get("Cache-Control"),expires:e.get("Expires")}:{cacheControl:void 0,expires:void 0}},e.aN=function(e){St++,St>xt&&(e.getActor().send("enforceCacheSizeLimit",vt),St=0)},e.aO=function(e){return e<=1?1:Math.pow(2,Math.floor(Math.log2(e)))},e.aP=Iu,e.aQ=ly,e.aR=fy,e.aS=rc,e.aT=sy,e.aU=function(e,t){const i=document.createElement("video");i.muted=!0,i.onloadstart=function(){t(null,i)};for(let t=0;t{}}},e.aV=Pf,e.aW=zy,e.aX=Ve,e.aY=hA,e.aZ=dc,e.a_=pc,e.aa=Fs,e.ab=class{constructor(e){this.specification=e}possiblyEvaluate(e,t){return Ke(e.expression.evaluate(t))}interpolate(e,t,i){return{x:di(e.x,t.x,i),y:di(e.y,t.y,i),z:di(e.z,t.z,i),azimuthal:di(e.azimuthal,t.azimuthal,i),polar:di(e.polar,t.polar,i)}}},e.ac=Es,e.ad=Qo,e.ae=vc,e.af=j,e.ag=T,e.ah=ke,e.ai=Ls,e.aj=th,e.ak=di,e.al=Nn,e.am=pi,e.an=Be,e.ao=li,e.ap=class{constructor(e){this.specification=e}possiblyEvaluate(e,t){return function([e,t]){const i=Ke([1,e,t]);return{x:i.x,y:i.y,z:i.z}}(e.expression.evaluate(t))}interpolate(e,t,i){return{x:di(e.x,t.x,i),y:di(e.y,t.y,i),z:di(e.z,t.z,i)}}},e.aq=function(e,t,i=0,n=!0){const r=new Te(i,i),o=e.sub(r),s=t.add(r),a=[o,new Te(s.x,o.y),s,new Te(o.x,s.y)];return n&&a.push(o.clone()),a},e.ar=function(e,t){const i=[];for(let n=0;n1)return!1;const i=t.getSource().maxzoom,n=1<1)return t;const r=n.getSource().maxzoom,o=1<{const a=this.getAtTileOffset(e,r,o,s),l=n.upVector(e.canonical,r.x,r.y);return R(l,l,a*n.upVectorScale(e.canonical,t,i).metersToTile),l}}getForTilePoints(e,t,i,n){if(this.isUsingMockSource())return!1;const r=Ey.create(this,e,n);return!!r&&(t.forEach(e=>{e[2]=this.exaggeration()*r.getElevationAt(e[0],e[1],i)}),!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<0&&i[0]<=e.width&&i[1]>0&&i[1]<=e.height&&!nh(e,new rc(e.center.lat,90)),n[0]>0&&n[0]<=e.width&&n[1]>0&&n[1]<=e.height&&!nh(e,new rc(e.center.lat,-90))]},e.cM=function(e,t){const{scale:i}=e.tileTransform,n=i*Nn/(e.tileSize*Math.pow(2,t.zoom-e.tileID.overscaledZ+e.tileID.canonical.z));return function(e,t,i){var n=t[1],r=t[2],o=t[3],s=i[0],a=i[1];return e[0]=t[0]*s,e[1]=n*s,e[2]=r*a,e[3]=o*a,e}(new Float32Array(4),t.inverseAdjustmentMatrix,[n,n])},e.cN=Vf,e.cO=x,e.cP=Uf,e.cQ=function(e){const t=Uf(e,!0);return n([],[t[0],t[1],t[4],t[5]])},e.cR=p,e.cS=$c,e.cT=f,e.cU=function(e){const{x:t,y:i}=e.point,{lng:n,lat:r}=e._center;return eh(t,i,e.worldSize,n,r)},e.cV=I,e.cW=Ie,e.cX=Mu,e.cY=_u,e.cZ=Zl,e.c_=function(e,t,i){let n=0;for(let i=0;i<2;++i){const r=0;e[i]>r&&(n+=(e[i]-r)*(e[i]-r)),t[i]0?Math.acos(i/n)*Se:0;let o=0!==e||0!==t?Math.atan2(-t,-e)*Se+90:0;return o<0&&(o+=360),[n,o,r]},e.d4=E,e.d5=Ke,e.d6=yc,e.d7=S,e.d8=Jc,e.d9=B,e.dA=Cl,e.dB=class extends vl{constructor(e){super(e),this.current=Il}set(e,t,i){if(this.fetchUniformLocation(e,t))for(let e=0;e<9;e++)if(i[e]!==this.current[e]){this.current=i,this.gl.uniformMatrix3fv(this.location,!1,i);break}}},e.dC=Pe,e.dD=function(e,t,i){const n=th(i.zoom),r=e.style.map._antialias,o=e.terrain&&e.terrain.exaggeration()>0;return 0===n&&!r&&!o},e.dE=function(e){const t=e.pixelsPerMeter,i=t/hc(1,e.center.lat),n=c(new Float64Array(16));return d(n,n,[e.point.x,e.point.y,0]),p(n,n,[i,i,t]),Float32Array.from(n)},e.dF=Qu,e.dG=function(e){const t=mc-5;e=Fe(e,-t,t)/t*90;const i=Math.pow(Math.abs(Math.sin(Be(e))),3);return Math.round(i*(Xl.length-1))},e.dH=function(e,t,i,n){const r=t.getNorth(),o=t.getSouth(),a=t.getWest(),l=t.getEast(),c=1<0){const e=180/n;s(f,f,[e/u+1,0,0,0,e/h+1,0,-.5*e/d,.5*e/p,1])}return f[2]=c,f[5]=e.x,f[8]=e.y,f},e.dI=Vu,e.dJ=function(e,t,i){const n=c(new Float64Array(16)),r=(t/(1<({u_matrix:new Bl(e),u_texsize:new wl(e),u_pixels_to_tile_units:new Pl(e),u_device_pixel_ratio:new bl(e),u_width_scale:new bl(e),u_floor_width_scale:new bl(e),u_image:new xl(e),u_units_to_pixels:new wl(e),u_tile_units_to_pixels:new bl(e),u_alpha_discard_threshold:new bl(e),u_trim_offset:new wl(e),u_trim_fade_range:new wl(e),u_trim_color:new El(e),u_emissive_strength:new bl(e),u_zbias_factor:new bl(e),u_tile_to_meter:new bl(e),u_ground_shadow_factor:new Tl(e),u_pattern_transition:new bl(e)}),e.dW=e=>({u_matrix:new Bl(e),u_pixels_to_tile_units:new Pl(e),u_device_pixel_ratio:new bl(e),u_width_scale:new bl(e),u_floor_width_scale:new bl(e),u_units_to_pixels:new wl(e),u_dash_image:new xl(e),u_gradient_image:new xl(e),u_image_height:new bl(e),u_texsize:new wl(e),u_tile_units_to_pixels:new bl(e),u_alpha_discard_threshold:new bl(e),u_trim_offset:new wl(e),u_trim_fade_range:new wl(e),u_trim_color:new El(e),u_emissive_strength:new bl(e),u_zbias_factor:new bl(e),u_tile_to_meter:new bl(e),u_ground_shadow_factor:new Tl(e)}),e.dX=e=>({u_camera_to_center_distance:new bl(e),u_extrude_scale:new Pl(e),u_device_pixel_ratio:new bl(e),u_matrix:new Bl(e),u_inv_rot_matrix:new Bl(e),u_merc_center:new wl(e),u_tile_id:new Tl(e),u_zoom_transition:new bl(e),u_up_dir:new Tl(e),u_emissive_strength:new bl(e)}),e.dY=Ra,e.dZ=fg,e.d_=class{constructor(e,t,i,n){this.context=e,this.format=n,this.size=i,this.texture=e.gl.createTexture();const[r,o,s]=this.size,{gl:a}=e;a.bindTexture(a.TEXTURE_3D,this.texture),e.pixelStoreUnpackFlipY.set(!1),e.pixelStoreUnpack.set(1),e.pixelStoreUnpackPremultiplyAlpha.set(!1),"data"in t&&t.data&&a.texImage3D(a.TEXTURE_3D,0,this.format,r,o,s,0,Bf(this.format),If(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}},e.da=function(e){return[Math.pow(e[0],1/2.2),Math.pow(e[1],1/2.2),Math.pow(e[2],1/2.2)]},e.db=Sf,e.dc=hm,e.dd=Jf,e.de=yy,e.df=function(e,t){return e.readFields(qy,{icons:[]},t)},e.dg=Xp,e.dh=S_,e.di=C_,e.dj=Ot,e.dk=ys,e.dl=At,e.dm=Jt,e.dn=He,e.dp=function(e){const t=e.indexOf(ea);return t>=0?e.slice(0,t):e},e.dq=function(e){return e.indexOf(ea)>=0},e.dr=function(e){const t=e.lastIndexOf(ea);return t>=0?e.slice(t+1):""},e.ds=function(e){const t=[],i=e.id;return void 0===i&&t.push({message:`layers.${i}: missing required property "id"`}),void 0===e.render&&t.push({message:`layers.${i}: missing required method "render"`}),e.renderingMode&&"2d"!==e.renderingMode&&"3d"!==e.renderingMode&&t.push({message:`layers.${i}: property "renderingMode" must be either "2d" or "3d"`}),t},e.dt=function(e,t,i,n){return"custom"===e.type?new my(e,t):new Vy[e.type](e,t,i,n)},e.du=Ge,e.dv=function(e){const t=e.indexOf(ea);return t>=0?e.slice(t+1):""},e.dw=class extends Oy{constructor(e,t){super(e._vectorTileFeature,e._z,e._x,e._y,e.id),e.state&&(this.state=Object.assign({},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}},e.dx=xs,e.dy=zt,e.dz=function(e){return e({pluginStatus:_s,pluginURL:As}),xs.on("pluginStateChange",e),e},e.e=st,e.e$=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 rc(Ie(r),Ie(o))},e.e0=(e,t,i,n,r,o)=>{const s=e.transform,a="globe"===s.projection.name;let l;if("map"===o.paint.get("circle-pitch-alignment"))if(a){const e=Yu(s.zoom,t.canonical)*s._pixelsPerMercatorPixel;l=Float32Array.from([e,0,0,e])}else l=s.calculatePixelsToTileUnitsMatrix(i);else l=new Float32Array([s.pixelsToGLUnits[0],0,0,s.pixelsToGLUnits[1]]);const c={u_camera_to_center_distance:e.transform.getCameraToCenterDistance(s.projection),u_matrix:e.translatePosMatrix(t.projMatrix,i,o.paint.get("circle-translate"),o.paint.get("circle-translate-anchor")),u_device_pixel_ratio:gt.devicePixelRatio,u_extrude_scale:l,u_inv_rot_matrix:ah,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(a){c.u_inv_rot_matrix=n,c.u_merc_center=r,c.u_tile_id=[t.canonical.x,t.canonical.y,1<{const u=e.transform,h=u.pitch<15?qm(.07,.7,Fe((14-u.zoom)/5,0,1)):.07,d="none"===i.paint.get("line-trim-color-use-theme").constantOr("default");return{u_matrix:Xm(e,t,i,n),u_texsize:t.imageAtlasTexture?t.imageAtlasTexture.size:[0,0],u_pixels_to_tile_units:u.calculatePixelsToTileUnitsMatrix(t),u_device_pixel_ratio:r,u_width_scale:o,u_floor_width_scale:s,u_image:0,u_tile_units_to_pixels:Km(t,u),u_units_to_pixels:[1/u.pixelsToGLUnits[0],1/u.pixelsToGLUnits[1]],u_alpha_discard_threshold:0,u_trim_offset:a,u_trim_fade_range:i.paint.get("line-trim-fade-range"),u_trim_color:i.paint.get("line-trim-color").toPremultipliedRenderColor(d?null:i.lut).toArray01(),u_emissive_strength:i.paint.get("line-emissive-strength"),u_zbias_factor:h,u_tile_to_meter:yc(t.tileID.canonical,0),u_ground_shadow_factor:l,u_pattern_transition:c}},e.e4=(e,t,i,n,r,o,s,a,l,c)=>{const u=e.transform,h=u.calculatePixelsToTileUnitsMatrix(t),d="none"===i.paint.get("line-trim-color-use-theme").constantOr("default"),p=u.pitch<15?qm(.07,.7,Fe((14-u.zoom)/5,0,1)):.07;return{u_matrix:Xm(e,t,i,n),u_pixels_to_tile_units:h,u_device_pixel_ratio:o,u_width_scale:s,u_floor_width_scale:a,u_units_to_pixels:[1/u.pixelsToGLUnits[0],1/u.pixelsToGLUnits[1]],u_dash_image:0,u_gradient_image:1,u_image_height:r,u_texsize:Ym(i)&&t.lineAtlasTexture?t.lineAtlasTexture.size:[0,0],u_tile_units_to_pixels:Km(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_color:i.paint.get("line-trim-color").toPremultipliedRenderColor(d?null:i.lut).toArray01(),u_emissive_strength:i.paint.get("line-emissive-strength"),u_zbias_factor:p,u_tile_to_meter:yc(t.tileID.canonical,0),u_ground_shadow_factor:c}},e.e5=Ne,e.e6=Eh,e.e7=fc,e.e8=Pu,e.e9=_p,e.eA=Uy,e.eB=Xf,e.eC=Zf,e.eD=[1,1,1],e.eE=Ey,e.eF=K,e.eG=function(e,t,i,n){var r=t[0],o=t[1],s=t[2],a=t[3];return e[0]=r+n*(i[0]-r),e[1]=o+n*(i[1]-o),e[2]=s+n*(i[2]-s),e[3]=a+n*(i[3]-a),e},e.eH=Kf,e.eI=Ia,e.eJ=ja,e.eK=function(e,t,n,r,o,s,a,l,c,u,h,d,p,f,m,g){var _=new i(16);return _[0]=e,_[1]=t,_[2]=n,_[3]=r,_[4]=o,_[5]=s,_[6]=a,_[7]=l,_[8]=c,_[9]=u,_[10]=h,_[11]=d,_[12]=p,_[13]=f,_[14]=m,_[15]=g,_},e.eL=ic,e.eM=Va,e.eN=Na,e.eO=class{constructor(){this._updateTime=0,this._sourceIds=[],this._activeRegions=[],this._prevRegions=[],this._globalClipBounds={min:new Te(1/0,1/0),max:new Te(-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=Gd(new Te(0,0),new Te(Nn,Nn),e),n=[];if(t&&!Vd(i,this._globalClipBounds))return n;for(const t of this._activeRegions){if(t.hiddenByOverlap)continue;if(!Vd(i,t))continue;const r=Hd(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=Gd(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||Ud(e.min,t.min)||Ud(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||!Nd(i,n)||i.order!==n.order||i.clipMask!==n.clipMask||!Ee(i.clipScope,n.clipScope),this._activeRegions[t].hiddenByOverlap=n.hiddenByOverlap,++t}}if(e){++this._updateTime;for(const e of this._activeRegions)e.order!==Dd&&(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(;e1){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=0;t--)this._addSource(e[t]);this._computeReplacement()}},e.eP=Dd,e.eQ=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 pa,n=new Fa,r=[],o=e+1+2,s=t[0]+1,a=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;e0?(_=2*Math.sqrt(g+1),e[3]=.25*_,e[0]=(d-f)/_,e[1]=(p-c)/_,e[2]=(l-u)/_):a>h&&a>m?(_=2*Math.sqrt(1+a-h-m),e[3]=(d-f)/_,e[0]=.25*_,e[1]=(l+u)/_,e[2]=(p+c)/_):h>m?(_=2*Math.sqrt(1+h-a-m),e[3]=(p-c)/_,e[0]=(l+u)/_,e[1]=.25*_,e[2]=(d+f)/_):(_=2*Math.sqrt(1+m-a-h),e[3]=(l-u)/_,e[0]=(p+c)/_,e[1]=(d+f)/_,e[2]=.25*_),e},e.ez=function(e,i){var n=2*Math.acos(i[3]),r=Math.sin(n/2);return r>t?(e[0]=i[0]/r,e[1]=i[1]/r,e[2]=i[2]/r):(e[0]=1,e[1]=0,e[2]=0),n},e.f=function(e){return btoa(encodeURIComponent(e).replace(/%([0-9A-F]{2})/g,(e,t)=>String.fromCharCode(Number("0x"+t))))},e.f0=J,e.f1=Gf,e.f2=function(e){const t=e.navigator?e.navigator.userAgent:null;return!!function(e){if(null==Ye){const t=e.navigator?e.navigator.userAgent:null;Ye=!!e.safari||!(!t||!(/\b(iPad|iPhone|iPod)\b/.test(t)||t.match("Safari")&&!t.match("Chrome")))}return Ye}(e)&&!(!t||!(t.match("Version/15.4")||t.match("Version/15.5")||t.match(/CPU (OS|iPhone OS) (15_4|15_5) like Mac OS X/)))},e.f3=function(e,t){vt=e,xt=t},e.f4=nh,e.f5=ih,e.f6=function(e){const t=[0,0,0],i=c(new Float64Array(16));return h(i,e.pixelMatrix,e.globeMatrix),j(t,t,i),new Te(t[0],t[1])},e.f7=function(){const e=qp;e&&(e.isPreloaded()&&1===e.numActive()?(e.release($p),qp=null):console.warn("Could not clear WebWorkers since there are active Map instances that still reference it. The pre-warmed WebWorker pool can only be cleared when all map instances have been removed with map.remove()"))},e.f8=function(){Xp().acquire($p)},e.f9=bs,e.fA=Mc,e.fB=function(e){let t=0;if(new Uint32Array(e,0,1)[0]!==vf){const i=new Uint32Array(e,0,7),[,,n,r,o,s]=i;t=i.byteLength+r+o+s+o,(n!==e.byteLength||t>=e.byteLength)&&Ze("Invalid b3dm header information.")}return Cf(e,t)},e.fC=function(e,t){const i=hm(e);for(const e of i){for(const t of e.meshes)dm(t);e.lights&&(e.lightMeshIndex=e.meshes.length,e.meshes.push(fm(e.lights,t)))}return i},e.fD=Ry,e.fE=Xe,e.fF=Hp,e.fG=Ts,e.fH=ms,e.fI=function(e){Ct(),null!=wt&&wt.then(t=>{t.keys().then(i=>{for(let n=0;nZe(e.message))}).catch(e=>Ze(e.message))}).catch(e=>Ze(e.message))},e.fa=function(e,t,i=!1){if(_s===ms.deferred||_s===ms.loading||_s===ms.loaded)throw new Error("setRTLTextPlugin cannot be called multiple times.");As=gt.resolveURL(e),_s=ms.deferred,gs=t,vs(),i||ws()},e.fb=function(e){nf=gt.resolveURL(e),of||(of=new Wp(Xp(),new ni)),of.broadcast("setMeshoptUrl",nf)},e.fc=uf,e.fd=function(e){ef=gt.resolveURL(e),of||(of=new Wp(Xp(),new ni)),of.broadcast("setDracoUrl",ef)},e.fe=cf,e.ff=Qp,e.fg=function(e){const t=Et();if(!t)return;const i=t.delete(yt);e&&i.then(()=>e()).catch(e)},e.fh=Zp,e.fi=es,e.fj=bh,e.fk=E_,e.fl=Vx,e.fm=jx,e.fn=Nm,e.fo=Oc,e.fp="hd_road_elevation",e.fq=tu,e.fr=je,e.fs=ld,e.ft=v_,e.fu=A_,e.fv=function(e,t,i,n,r,o,s,a=1,l,c,u){e.createArrays(),e.tilePixelRatio=Nn/(512*e.overscaling),e.compareText={},e.iconsNeedLinear=!1;const h=e.layers[0].layout,d=e.layers[0]._unevaluatedLayout._values,p={};p.scaleFactor=a,p.textSizeScaleRange=h.get("text-size-scale-range"),p.iconSizeScaleRange=h.get("icon-size-scale-range");const[f,m]=p.textSizeScaleRange,[g,_]=p.iconSizeScaleRange;p.textScaleFactor=Fe(p.scaleFactor,f,m),p.iconScaleFactor=Fe(p.scaleFactor,g,_);const A=d["text-size"],y=d["icon-size"];if("composite"===e.textSizeData.kind){const{minZoom:t,maxZoom:i}=e.textSizeData;p.compositeTextSizes=[A.possiblyEvaluate(new Es(t,{worldview:u}),o),A.possiblyEvaluate(new Es(i,{worldview:u}),o)]}if("composite"===e.iconSizeData.kind){const{minZoom:t,maxZoom:i}=e.iconSizeData;p.compositeIconSizes=[y.possiblyEvaluate(new Es(t,{worldview:u}),o),y.possiblyEvaluate(new Es(i,{worldview:u}),o)]}p.layoutTextSize=A.possiblyEvaluate(new Es(s+1,{worldview:u}),o),p.layoutIconSize=y.possiblyEvaluate(new Es(s+1,{worldview:u}),o),p.textMaxSize=A.possiblyEvaluate(new Es(18,{worldview:u}),o);const v=h.get("symbol-placement"),x="map"===h.get("text-rotation-alignment")&&"point"!==v,b=h.get("text-size");let w=!1;const T=[];for(const s of e.features){const a=h.get("text-font").evaluate(s,{},o).join(","),f=b.evaluate(s,{},o)*p.textScaleFactor,m=p.layoutTextSize.evaluate(s,{},o)*p.textScaleFactor,g=p.layoutIconSize.evaluate(s,{},o)*p.iconScaleFactor,_={horizontal:{},vertical:void 0},A=s.text;let y,E=[0,0];if(A){const n=A.toString(),c=h.get("text-letter-spacing").evaluate(s,{},o)*mg,u=h.get("text-line-height").evaluate(s,{},o)*mg,d=as(n)?c:0,p=h.get("text-anchor").evaluate(s,{},o),g=h.get("text-variable-anchor");if(!g){const e=h.get("text-radial-offset").evaluate(s,{},o);if(e)E=Q_(p,[e*mg,j_]);else{const e=h.get("text-offset").evaluate(s,{},o);E=[e[0]*mg,e[1]*mg]}}let y=x?"center":h.get("text-justify").evaluate(s,{},o);const b="point"===v,w=b?h.get("text-max-width").evaluate(s,{},o)*mg:1/0,T=o=>{e.allowVerticalPlacement&&ss(n)&&(_.vertical=Gg(A,t,i,r,a,w,u,p,o,d,E,Ng.vertical,!0,m,f,l))};if(!x&&g){const e="auto"===y?g.map(e=>eA(e)):[y];let n=!1;for(let o=0;o=0||!ss(n)){const e=Gg(A,t,i,r,a,w,u,p,y,d,E,Ng.horizontal,!1,m,f,l);e&&(_.horizontal[y]=e)}T(b?"left":y)}}let C,S,B,I,M,P,R=!1;const L=h.get("icon-text-fit").evaluate(s,{},o);if(s.icon&&s.icon.hasPrimary()){const t=q_(s.icon,e.iconSizeData,d["icon-size"],o,e.zoom,s,l,p.iconScaleFactor,u);C=t.iconPrimary,B=t.iconSecondary;const i=C.toString();if(S=n.get(i),S&&(M=h.get("icon-offset").evaluate(s,{},o),P=h.get("icon-anchor").evaluate(s,{},o),y=e_(r.get(i),B?r.get(B.toString()):void 0,M,P),R=S.sdf,void 0===e.sdfIcons?e.sdfIcons=S.sdf:e.sdfIcons!==S.sdf&&Ze("Style sheet warning: Cannot mix SDF and non-SDF icons in one buffer"),(S.pixelRatio!==e.pixelRatio||0!==h.get("icon-rotate").constantOr(1))&&(e.iconsNeedLinear=!0)),B){const e=B.toString();I=n.get(e)}}w=w||!(!s.icon||!s.icon.hasSecondary());const F=sA(_.horizontal)||_.vertical;e.iconsInText||(e.iconsInText=!!F&&F.iconsInText);const k=m*p.textScaleFactor/mg,{defaultShapedIcon:D,verticallyShapedIcon:O}=tA(e,y,h,s,o,_,k,M,L);"none"!==L&&y&&(i_(y)||n_(y))&&(Z_(0,S,C,y,D,L,c,n,r),Z_(0,I,B,y,D,L,c,n,r),O&&(Z_(0,S,C,y,O,L,c,n,r),Z_(0,I,B,y,O,L,c,n,r))),y=D;const{iconBBox:z,iconVerticalBBox:U}=$_(e,y,O,h,s,o,g,M,p,r,P);T.push({feature:s,shapedTextOrientations:_,shapedText:F,shapedIcon:y,iconPrimary:C,iconSecondary:B,iconOffset:M,iconAnchor:P,verticallyShapedIcon:O,layoutTextSize:m,layoutIconSize:g,textOffset:E,isSDFIcon:R,iconTextFit:L,iconCollisionBounds:z,iconVerticalCollisionBounds:U})}return{featureData:T,sizes:p,hasAnySecondaryIcon:w,textAlongLine:x,symbolPlacement:v}},e.fw=x_,e.fx=function(e,t,i,n,r,o,s,a,l,c){e.iconAtlasPositions=c.iconPositions;const{featureData:u,hasAnySecondaryIcon:h,sizes:d,textAlongLine:p,symbolPlacement:f}=t;for(const t of u){const{shapedIcon:i,verticallyShapedIcon:o,feature:u,shapedTextOrientations:m,shapedText:g,layoutTextSize:_,textOffset:A,isSDFIcon:y,iconPrimary:v,iconSecondary:x,iconTextFit:b,iconOffset:w,iconCollisionBounds:T,iconVerticalCollisionBounds:E}=t;X_(i,c.iconPositions,v,x),X_(o,c.iconPositions,v,x),J_(m,c.iconPositions),K_(v,x,c.iconPositions),(g||i)&&iA(e,u,m,i,o,l,d,_,0,A,y,n,r,s,a,h,b,w,p,f,T,E)}i&&e.generateCollisionDebugBuffers(o,e.collisionBoxArray,d.textScaleFactor)},e.fy=kc,e.fz=Wv,e.g=function(e,t){return zt(Object.assign(e,{method:"GET"}),t)},e.h=function(e){return 0===e.indexOf("mapbox:")},e.i=function(e){return st.API_STYLE_REGEX.test(e)&&!lt(e)},e.j=at,e.k=Bt,e.l=function(e){return decodeURIComponent(atob(e).split("").map(e=>"%"+("00"+e.charCodeAt(0).toString(16)).slice(-2)).join(""))},e.m=function(e,t){return zt(Object.assign(e,{type:"json"}),t)},e.n=Ht,e.o=gt,e.p=function(e,t){return zt(Object.assign(e,{method:"POST"}),t)},e.q=wh,e.r=mt,e.s=function(e){try{const t=self[e];return t.setItem("_mapbox_test_",1),t.removeItem("_mapbox_test_"),!0}catch(e){return!1}},e.t=function(){return Kp||(Kp=new Zp),Kp},e.u=function(){return function e(t){return t?(t^Math.random()*(16>>t/4)).toString(16):([1e7]+-[1e3]+-4e3+-8e3+-1e11).replace(/[018]/g,e)}()},e.v=function(e){return!!e&&/^[0-9a-f]{8}-[0-9a-f]{4}-[4][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$/i.test(e)},e.w=Ze,e.x=Dv,e.y=ei,e.z=Yt}),n(["./shared"],function(e){function t(e){const t=e?e.url.toString():void 0;return t?performance.getEntriesByName(t):[]}function i(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 n of e)t+=`${i(n)},`;return`${t}]`}let t="{";for(const n of Object.keys(e).sort())t+=`${n}:${i(e[n])},`;return`${t}}`}function n(t){let n="";for(const r of e.bw)n+=`/${i(t[r])}`;return n}class r{constructor(e){this.keyCache={},this._layers={},this._layerConfigs={},e&&this.replace(e)}replace(e,t){this._layerConfigs={},this._layers={},this.update(e,[],t)}update(t,r,o){this._options=o;for(const i of t)this._layerConfigs[i.id]=i,(this._layers[i.id]=e.dt(i,this.scope,null,this._options)).compileFilter(o),this.keyCache[i.id]&&delete this.keyCache[i.id];for(const e of r)delete this.keyCache[e],delete this._layerConfigs[e],delete this._layers[e];this.familiesBySource={};const s=function(e,t){const r={};for(let o=0;othis._layers[e.id]),i=t[0];if("none"===i.visibility)continue;const n=i.source||"";let r=this.familiesBySource[n];r||(r=this.familiesBySource[n]={});const o=i.sourceLayer||"_geojsonTileLayer";let s=r[o];s||(s=r[o]=[]),s.push(t)}}}const o=1*e.fk;class s{constructor(t){const i={},n=[];for(const e in t){const r=t[e],s=i[e]={};for(const e in r.glyphs){const t=r.glyphs[+e];if(!t||0===t.bitmap.width||0===t.bitmap.height)continue;const i=t.metrics.localGlyph?o:1,a={x:0,y:0,w:t.bitmap.width+2*i,h:t.bitmap.height+2*i};n.push(a),s[e]=a}}const{w:r,h:s}=e.G(n),a=new e.fj({width:r||1,height:s||1});for(const n in t){const r=t[n];for(const t in r.glyphs){const s=r.glyphs[+t];if(!s||0===s.bitmap.width||0===s.bitmap.height)continue;const l=i[n][t],c=s.metrics.localGlyph?o:1;e.fj.copy(s.bitmap,a,{x:0,y:0},{x:l.x+c,y:l.y+c},s.bitmap)}}this.image=a,this.positions=i}}function a(e,t,i){e[t]?i&&(e[t].center=i):e[t]={floorIds:new Set,center:i||[0,0],floors:{}}}function l(e,t,i,n){for(const r of t)a(e,r),e[r].floors[i]=n,e[r].floorIds.add(i)}function c(e){return{id:e.properties.id.toString(),center:e.properties.center.toString().split(";").map(Number)}}function u(e){return{id:e.properties.id.toString(),isDefault:!!e.properties.is_default&&e.properties.is_default,connections:e.properties.connected_floor_ids?new Set(e.properties.connected_floor_ids.toString().split(";")):new Set,conflicts:e.properties.conflicted_floor_ids?new Set(e.properties.conflicted_floor_ids.toString().split(";")):new Set,buildings:e.properties.building_ids?new Set(e.properties.building_ids.toString().split(";")):new Set,name:e.properties.name.toString(),zIndex:e.properties.z_index}}function h(e,t){return t.every(t=>e.properties&&null!=e.properties[t])}function d(e){return h(e,["type","id","name"])&&"building"===e.properties.type}function p(e){return h(e,["type","id","name","z_index"])&&"floor"===e.properties.type}e.fi(s,"GlyphAtlas");class f{constructor(t){this.tileID=new e.aP(t.tileID.overscaledZ,t.tileID.wrap,t.tileID.canonical.z,t.tileID.canonical.x,t.tileID.canonical.y),this.tileZoom=t.tileZoom,this.uid=t.uid,this.zoom=t.zoom,this.lut=t.lut,this.canonical=t.tileID.canonical,this.pixelRatio=t.pixelRatio,this.tileSize=t.tileSize,this.source=t.source,this.scope=t.scope,this.overscaling=this.tileID.overscaleFactor(),this.showCollisionBoxes=t.showCollisionBoxes,this.collectResourceTiming=!!t.request&&t.request.collectResourceTiming,this.promoteId=t.promoteId,this.isSymbolTile=t.isSymbolTile,this.tileTransform=e.aY(t.tileID.canonical,t.projection),this.projection=t.projection,this.worldview=t.worldview,this.localizableLayerIds=t.localizableLayerIds,this.brightness=t.brightness,this.extraShadowCaster=!!t.extraShadowCaster,this.tessellationStep=t.tessellationStep,this.scaleFactor=t.scaleFactor,this.worldview=t.worldview,this.indoor=t.indoor}parse(t,i,n,r,o,h){this.status="parsing",this.data=t,this.collisionBoxArray=new e.b2;const f=new e.fl(Object.keys(t.layers).sort()),g=new e.fm(this.tileID,this.promoteId);g.bucketLayerIDs=[];const _={},A=new e.fn(256,256),y={featureIndex:g,iconDependencies:new Map,patternDependencies:new Map,glyphDependencies:{},lineAtlas:A,availableImages:n,brightness:this.brightness,scaleFactor:this.scaleFactor,elevationFeatures:void 0,activeFloors:void 0};if(this.indoor){const i=this.indoor.indoorState.activeFloorsVisible,n=function(t,i,n){const r=function(t,i){if(!t)return e.w("No source layers defined in indoor specification"),i;if(0===t.size)return i;const n=t.difference(i);for(const t of n)e.w(`Missing source layer required in indoor specification: ${t}`);return i.intersection(i)}(i.sourceLayers,new Set(Object.keys(t.layers))),o=i.indoorState,s=function(t,i,n,r){const o=new Set,s=new Set,h=new Set,f=new Map,m={},g=e=>{const t=f.get(e)||new Set;for(const i of o)if((f.get(i)||new Set).has(e)||t.has(i))return!0;return!1};for(const n of i){const i=t.layers[n];if(i)for(let e=0;e=i.maxzoom)continue;if("none"===i.visibility)continue;m(t,this.zoom,y.brightness,n,this.worldview);const o=_[i.id]=i.createBucket({index:g.bucketLayerIDs.length,layers:t,zoom:this.zoom,lut:this.lut,canonical:this.canonical,pixelRatio:this.pixelRatio,overscaling:this.overscaling,collisionBoxArray:this.collisionBoxArray,sourceLayerIndex:c,sourceID:this.source,projection:this.projection.spec,tessellationStep:this.tessellationStep,styleDefinedModelURLs:r,worldview:this.worldview});g.bucketLayerIDs.push(t.map(t=>e.B(t.id,t.scope)));let s=o.prepare?o.prepare():null;null!=s?(s=s.then(()=>o.populate(u,y,this.tileID.canonical,this.tileTransform)),v.push(s)):o.populate(u,y,this.tileID.canonical,this.tileTransform)}}const b=()=>{let i,r,a,l,c,u;A.trim();const d={type:"maybePrepare",isSymbolTile:this.isSymbolTile,zoom:this.zoom},p=()=>{if(i)return this.status="done",h(i);if(this.extraShadowCaster)this.status="done",h(null,{buckets:Object.values(_).filter(e=>!e.isEmpty()),featureIndex:g,collisionBoxArray:null,glyphAtlasImage:null,lineAtlas:null,imageAtlas:null,brightness:y.brightness,glyphMap:null,iconMap:null,glyphPositions:null});else if(r&&a&&l){const t=new s(r),i=new Map;for(const[t,n]of a.entries()){const{imagePosition:r}=e.ft(t,n,e.fu);i.set(t,r)}const h={};for(const o in _){const s=_[o];s instanceof e.b3&&(m(s.layers,this.zoom,y.brightness,n,this.worldview),h[o]=e.fv(s,r,t.positions,a,i,this.tileID.canonical,this.tileZoom,this.scaleFactor,this.pixelRatio,c,this.worldview))}const d={iconsPending:!0,patternsPending:!0};this.rasterizeIfNeeded(o,a,c,()=>{d.iconsPending=!1,v(h,t,d)}),this.rasterizeIfNeeded(o,l,u,()=>{d.patternsPending=!1,v(h,t,d)})}},v=(t,i,r,o)=>{if(r.iconsPending||r.patternsPending)return;const s=new e.fw(a,l,this.lut);for(const i in _){const r=_[i];if(i in t)e.fx(r,t[i],this.showCollisionBoxes,n,this.tileID.canonical,this.tileZoom,this.projection,this.brightness,a,s);else if(r.hasPattern&&(r instanceof e.b9||r instanceof e.ba||r instanceof e.e9)){m(r.layers,this.zoom,y.brightness,n,this.worldview);const e=Object.fromEntries(s.patternPositions);r.addFeatures(y,this.tileID.canonical,e,n,this.tileTransform,this.brightness)}}this.status="done",h(null,{buckets:Object.values(_).filter(e=>!e.isEmpty()),featureIndex:g,collisionBoxArray:this.collisionBoxArray,glyphAtlasImage:i.image,lineAtlas:A,imageAtlas:s,brightness:y.brightness})};if(!this.extraShadowCaster){const t=e.fr(y.glyphDependencies,e=>Object.keys(e).map(Number));Object.keys(t).length?o.send("getGlyphs",{uid:this.uid,stacks:t},(e,t)=>{i||(i=e,r=t,p())},void 0,!1,d):r={};const n=Array.from(y.iconDependencies.keys()).map(t=>e.I.parse(t));n.length?o.send("getImages",{images:n,source:this.source,scope:this.scope,tileID:this.tileID,type:"icons"},(e,t)=>{i||(i=e,a=new Map,c=this.updateImageMapAndGetImageTaskQueue(a,t,y.iconDependencies),p())},void 0,!1,d):(a=new Map,c=new Map);const s=Array.from(y.patternDependencies.keys()).map(t=>e.I.parse(t));s.length?o.send("getImages",{images:s,source:this.source,scope:this.scope,tileID:this.tileID,type:"patterns"},(e,t)=>{i||(i=e,l=new Map,u=this.updateImageMapAndGetImageTaskQueue(l,t,y.patternDependencies),p())},void 0,!1,d):(l=new Map,u=new Map)}if(y.elevationFeatures&&y.elevationFeatures.length>0){const i=[];for(const t of Object.values(_))if(t instanceof e.ba){const e=t.getUnevaluatedPortalGraph();e&&i.push(e)}const n=e.fs.evaluate(i);for(const i of Object.values(_))if(i instanceof e.ba){const e=t.layers[f.decode(i.sourceLayerIndex)];i.setEvaluatedPortalGraph(n,e,this.tileID.canonical,y.availableImages,y.brightness)}}p()};v.length>0?Promise.allSettled(v).then(b).catch(h):b()}updateParameters(t){this.scaleFactor=t.scaleFactor,this.showCollisionBoxes=t.showCollisionBoxes,this.projection=t.projection,this.brightness=t.brightness,this.tileTransform=e.aY(t.tileID.canonical,t.projection),this.extraShadowCaster=t.extraShadowCaster,this.lut=t.lut,this.worldview=t.worldview,this.indoor=t.indoor}rasterizeIfNeeded(e,t,i,n){Array.from(t.values()).some(e=>e.usvg)?this.rasterize(e,t,i,n):n()}updateImageMapAndGetImageTaskQueue(e,t,i){const n=new Map;for(const r of t.keys()){const o=i.get(r)||[];for(const i of o){const r=i.toString(),o=t.get(i.id.toString());o.usvg?n.has(r)||(n.set(r,i),e.set(r,Object.assign({},o))):e.set(r,o)}}return n}rasterize(e,t,i,n){this.rasterizeTask=e.send("rasterizeImages",{scope:this.scope,tasks:i},(e,i)=>{if(!e)for(const[e,n]of i.entries()){const i=Object.assign(t.get(e),{data:n});t.set(e,i)}n()})}cancelRasterize(){this.rasterizeTask&&this.rasterizeTask.cancel()}}function m(t,i,n,r,o){const s=new e.ac(i,{brightness:n,worldview:o});for(const e of t)e.recalculate(s,r)}class g extends e.E{constructor(t,i,n,r,o,s,a){super(),this.actor=t,this.layerIndex=i,this.availableImages=n,this.availableModels=r,this.loadVectorData=s||e.aL,this.loading={},this.loaded={},this.deduped=new e.aK(t.scheduler),this.isSpriteLoaded=o,this.scheduler=t.scheduler,this.brightness=a}loadTile(i,n){const r=i.uid,o=i&&i.request,s=o&&o.collectResourceTiming,a=this.loading[r]=new f(i);a.abort=this.loadVectorData(i,(l,c)=>{const u=!this.loading[r];if(delete this.loading[r],a.cancelRasterize(),u||l||!c)return a.status="done",u||(this.loaded[r]=a),n(l);const h=c.rawData,d={},p=e.aM(c.responseHeaders);p&&p.expires&&(d.expires=p.expires),p&&p.cacheControl&&(d.cacheControl=p.cacheControl),a.vectorTile=c.vectorTile||new e.fy(new e.bs(h));const f=()=>{a.parse(a.vectorTile,this.layerIndex,this.availableImages,this.availableModels,this.actor,(e,i)=>{if(e||!i)return n(e);const r={};if(s){const e=t(o);e.length>0&&(r.resourceTiming=JSON.parse(JSON.stringify(e)))}n(null,Object.assign({rawTileData:h.slice(0),responseHeaders:c.responseHeaders},i,d,r))})};this.isSpriteLoaded?f():this.once("isSpriteLoaded",()=>{this.scheduler?this.scheduler.add(f,{type:"parseTile",isSymbolTile:i.isSymbolTile,zoom:i.tileZoom}):f()}),this.loaded=this.loaded||{},this.loaded[r]=a})}reloadTile(e,t){const i=this.loaded,n=e.uid;if(i&&i[n]){const r=i[n];r.updateParameters(e);const o=(e,i)=>{const n=r.reloadCallback;n&&(delete r.reloadCallback,r.parse(r.vectorTile,this.layerIndex,this.availableImages,this.availableModels,this.actor,n)),t(e,i)};"parsing"===r.status?r.reloadCallback=o:"done"===r.status&&(r.vectorTile?r.parse(r.vectorTile,this.layerIndex,this.availableImages,this.availableModels,this.actor,o):o())}else t(null,void 0)}abortTile(e,t){const i=e.uid,n=this.loading[i];n&&(n.abort&&n.abort(),delete this.loading[i]),t()}removeTile(e,t){const i=this.loaded,n=e.uid;i&&i[n]&&delete i[n],t()}}class _{loadTile(t,i){const{uid:n,encoding:r,rawImageData:o,padding:s}=t,a=ImageBitmap&&o instanceof ImageBitmap?this.getImageData(o,s):o;i(null,new e.fz(n,a,r,s<1))}reloadTile(e,t){t(null,null)}abortTile(e,t){t()}removeTile(e,t){t()}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 i=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),i}}e.br.setPbf(e.bs);class A{constructor(t){this._mrt=new e.br(t.partial?30:1/0),this._isHeaderLoaded=!1,this.uid=t.uid,this.tileID=t.tileID,this.source=t.source}parse(t,i){const n=this._mrt;this.status="parsing",this._entireBuffer=t;try{n.parseHeader(t),this._isHeaderLoaded=!0;const r=[];for(const i in n.layers){const o=n.getLayer(i),s=o.getDataRange(o.getBandList()),a=n.createDecodingTask(s),l=t.slice(s.firstByte,s.lastByte+1),c=e.br.performDecoding(l,a).then(e=>a.complete(null,e)).catch(e=>a.complete(e,null));r.push(c)}Promise.allSettled(r).then(()=>i(null,n)).catch(e=>i(e))}catch(e){i(e)}}}class y{constructor(e){this.actor=e,this.loading={},this.loaded={}}loadTile(t,i){const n=t.uid,r=t.request,o=this.loading[n]=new A(t),{cancel:s}=e.bt(r,(e,t,r)=>{const s=!this.loading[n];if(delete this.loading[n],s||e||!t)return o.status="done",s||(this.loaded[n]=o),i(e);o.parse(t,(e,t)=>{if(e||!t)return i(e);i(null,t,r)}),this.loaded[n]=o});o.abort=s}reloadTile(e,t){t(null,void 0)}abortTile(e,t){const i=e.uid,n=this.loading[i];n&&(n.abort&&n.abort(),delete this.loading[i]),t()}removeTile(e,t){const i=e.uid;this.loaded[i]&&delete this.loaded[i],t()}decodeRasterArray(t,i){e.br.performDecoding(t.buffer,t.task).then(e=>i(null,e)).catch(e=>i(e))}}const v=e.fA.prototype.toGeoJSON;class x{constructor(t){this._feature=t,this.extent=e.al,this.type=t.type,this.properties=t.tags,"id"in t&&!isNaN(t.id)&&(this.id=parseInt(t.id,10))}loadGeometry(){if(1===this._feature.type){const t=[];for(const i of this._feature.geometry)t.push([new e.P(i[0],i[1])]);return t}{const t=[];for(const i of this._feature.geometry){const n=[];for(const t of i)n.push(new e.P(t[0],t[1]));t.push(n)}return t}}toGeoJSON(e,t,i){return v.call(this,e,t,i)}}class b{constructor(t,i){this.name=t,this.extent=e.al,this.length=i.length,this._jsonFeatures=i}feature(e){return new x(this._jsonFeatures[e])}}class w{constructor(t){this.layers={},this.extent=e.al;for(const e of Object.keys(t))this.layers[e]=new b(e,t[e])}}const T=64/4096,E=128;class C{constructor(){this.features=new Map}clear(){this.features.clear()}load(e=[],t){for(const i of e){const e=i.id;if(null==e)continue;let n=this.features.get(e);n&&this.updateCache(n,t),i.geometry?(n=B(i),this.updateCache(n,t),this.features.set(e,n)):this.features.delete(e),this.updateCache(n,t)}}updateCache(e,t){for(const{canonical:i,uid:n}of Object.values(t)){const{z:r,x:o,y:s}=i;S(e,Math.pow(2,r),o,s)&&delete t[n]}}getTile(e,t,i){const n=Math.pow(2,e),r=[];for(const e of this.features.values())S(e,n,t,i)&&r.push(R(e,n,t,i));return{features:r}}getFeatures(){return[...this.features.values()]}}function S({minX:e,minY:t,maxX:i,maxY:n},r,o,s){return e<(o+1+T)/r&&t<(s+1+T)/r&&i>(o-T)/r&&n>(s-T)/r}function B(e){const{id:t,geometry:i,properties:n}=e;if(!i)return;if("GeometryCollection"===i.type)throw new Error("GeometryCollection not supported in dynamic mode.");const{type:r,coordinates:o}=i,s={id:t,type:1,geometry:[],tags:n,minX:1/0,minY:1/0,maxX:-1/0,maxY:-1/0},a=s.geometry;if("Point"===r)I(o,a,s);else if("MultiPoint"===r)for(const e of o)I(e,a,s);else if("LineString"===r)s.type=2,M(o,a,s);else if("MultiLineString"===r)s.type=2,P(o,a,s);else if("Polygon"===r)s.type=3,P(o,a,s,!0);else{if("MultiPolygon"!==r)throw new Error("Input data is not a valid GeoJSON object.");s.type=3;for(const e of o)P(e,a,s,!0)}return s}function I([t,i],n,r){const o=e.aF(t);let s=e.aJ(i);s=s<0?0:s>1?1:s,n.push(o,s),r.minX=Math.min(r.minX,o),r.minY=Math.min(r.minY,s),r.maxX=Math.max(r.maxX,o),r.maxY=Math.max(r.maxY,s)}function M(e,t,i,n=!1,r=!1){const o=[];for(const t of e)I(t,o,i);t.push(o),n&&function(e,t){let i=0;for(let t=0,n=e.length,r=n-2;t0===t)for(let t=0,i=e.length;t=a&&d>=a||(u>=a?(h+=Math.round(m*((a-u)/f)),u=a):d>=a&&(p=h+Math.round(m*((a-u)/f)),d=a),h>=a&&p>=a||(h>=a?(u+=Math.round(f*((a-h)/m)),h=a):p>=a&&(d=u+Math.round(f*((a-h)/m)),p=a),l&&u===l[l.length-1][0]&&h===l[l.length-1][1]||(l=[[u,h]],o.push(l)),l.push([d,p])))))}}function F({name:t,features:i},n){n.writeStringField(1,t),n.writeVarintField(5,e.al);const r=new Map,o=new Map,s={keys:r,values:o,feature:null};for(const e of i)s.feature=e,n.writeMessage(2,k,s);for(const e of r.keys())n.writeStringField(3,e);for(const e of o.keys())n.writeMessage(4,N,e)}function k(e,t){const i=e.feature;void 0!==i.id&&Number.isSafeInteger(+i.id)&&t.writeVarintField(1,+i.id),i.tags&&t.writeMessage(2,D,e),t.writeVarintField(3,i.type),t.writeMessage(4,U,i)}function D({keys:e,values:t,feature:i},n){for(const r of Object.keys(i.tags)){let o=i.tags[r];if(null===o)continue;let s=e.get(r);void 0===s&&(s=e.size,e.set(r,s)),n.writeVarint(s);const a=typeof o;"string"!==a&&"boolean"!==a&&"number"!==a&&(o=JSON.stringify(o));let l=t.get(o);void 0===l&&(l=t.size,t.set(o,l)),n.writeVarint(l)}}function O(e,t){return(t<<3)+(7&e)}function z(e){return e<<1^e>>31}function U(e,t){const{geometry:i,type:n}=e;let r=0,o=0;if(1===n){t.writeVarint(O(1,i.length));for(const e of i){const i=e[0]-r,n=e[1]-o;t.writeVarint(z(i)),t.writeVarint(z(n)),r+=i,o+=n}}else for(const e of i){t.writeVarint(O(1,1));const i=e.length-(3===n?1:0);for(let n=0;ne},j=Math.fround||(G=new Float32Array(1),e=>(G[0]=+e,G[0]));var G;const H=3,Q=5,$=6;class Z{constructor(e){this.options=Object.assign(Object.create(V),e),this.trees=new Array(this.options.maxZoom+1),this.stride=this.options.reduce?7:6,this.clusterProps=[]}load(e){const{log:t,minZoom:i,maxZoom:n}=this.options;t&&console.time("total time");const r=`prepare ${e.length} points`;t&&console.time(r),this.points=e;const o=[];for(let t=0;t=i;e--){const i=+Date.now();s=this.trees[e]=this._createTree(this._cluster(s,e)),t&&console.log("z%d: %d clusters in %dms",e,s.numItems,+Date.now()-i)}return t&&console.timeEnd("total time"),this}getClusters(e,t){let i=((e[0]+180)%360+360)%360-180;const n=Math.max(-90,Math.min(90,e[1]));let r=180===e[2]?180:((e[2]+180)%360+360)%360-180;const o=Math.max(-90,Math.min(90,e[3]));if(e[2]-e[0]>=360)i=-180,r=180;else if(i>r){const e=this.getClusters([i,n,180,o],t),s=this.getClusters([-180,n,r,o],t);return e.concat(s)}const s=this.trees[this._limitZoom(t)],a=s.range(K(i),X(o),K(r),X(n)),l=s.data,c=[];for(const e of a){const t=this.stride*e;c.push(l[t+Q]>1?W(l,t,this.clusterProps):this.points[l[t+H]])}return c}getChildren(e){const t=this._getOriginId(e),i=this._getOriginZoom(e),n="No cluster with the specified id.",r=this.trees[i];if(!r)throw new Error(n);const o=r.data;if(t*this.stride>=o.length)throw new Error(n);const s=this.options.radius/(this.options.extent*Math.pow(2,i-1)),a=r.within(o[t*this.stride],o[t*this.stride+1],s),l=[];for(const t of a){const i=t*this.stride;o[i+4]===e&&l.push(o[i+Q]>1?W(o,i,this.clusterProps):this.points[o[i+H]])}if(0===l.length)throw new Error(n);return l}getLeaves(e,t,i){const n=[];return this._appendLeaves(n,e,t=t||10,i=i||0,0),n}getTile(e,t,i){const n=this.trees[this._limitZoom(e)],r=Math.pow(2,e),{extent:o,radius:s}=this.options,a=s/o,l=(i-a)/r,c=(i+1+a)/r,u={features:[]};return this._addTileFeatures(n.range((t-a)/r,l,(t+1+a)/r,c),n.data,t,i,r,u),0===t&&this._addTileFeatures(n.range(1-a/r,l,1,c),n.data,r,i,r,u),t===r-1&&this._addTileFeatures(n.range(0,l,a/r,c),n.data,-1,i,r,u),u.features.length?u:null}getClusterExpansionZoom(e){let t=this._getOriginZoom(e)-1;for(;t<=this.options.maxZoom;){const i=this.getChildren(e);if(t++,1!==i.length)break;e=i[0].properties.cluster_id}return t}_appendLeaves(e,t,i,n,r){const o=this.getChildren(t);for(const t of o){const o=t.properties;if(o&&o.cluster?r+o.point_count<=n?r+=o.point_count:r=this._appendLeaves(e,o.cluster_id,i,n,r):r1;let l,c,u;if(a)l=q(t,e,this.clusterProps),c=t[e],u=t[e+1];else{const i=this.points[t[e+H]];l=i.properties;const[n,r]=i.geometry.coordinates;c=K(n),u=X(r)}const h={type:1,geometry:[[Math.round(this.options.extent*(c*r-i)),Math.round(this.options.extent*(u*r-n))]],tags:l};let d;d=a||this.options.generateId?t[e+H]:this.points[t[e+H]].id,void 0!==d&&(h.id=d),o.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:i,extent:n,reduce:r,minPoints:o}=this.options,s=i/(n*Math.pow(2,t)),a=e.data,l=[],c=this.stride;for(let i=0;it&&(p+=a[i+Q])}if(p>d&&p>=o){let e,o=n*d,s=u*d,f=-1;const m=(i/c<<5)+(t+1)+this.points.length;for(const n of h){const l=n*c;if(a[l+2]<=t)continue;a[l+2]=t;const u=a[l+Q];o+=a[l]*u,s+=a[l+1]*u,a[l+4]=m,r&&(e||(e=this._map(a,i,!0),f=this.clusterProps.length,this.clusterProps.push(e)),r(e,this._map(a,l)))}a[i+4]=m,l.push(o/p,s/p,1/0,m,-1,p),r&&l.push(f)}else{for(let e=0;e1)for(const e of h){const i=e*c;if(!(a[i+2]<=t)){a[i+2]=t;for(let e=0;e>5}_getOriginZoom(e){return(e-this.points.length)%32}_map(e,t,i){if(e[t+Q]>1){const n=this.clusterProps[e[t+$]];return i?Object.assign({},n):n}const n=this.points[e[t+H]].properties,r=this.options.map(n);return i&&r===n?Object.assign({},r):r}}function W(e,t,i){return{type:"Feature",id:e[t+H],properties:q(e,t,i),geometry:{type:"Point",coordinates:[(n=e[t],360*(n-.5)),J(e[t+1])]}};var n}function q(e,t,i){const n=e[t+Q],r=n>=1e4?`${Math.round(n/1e3)}k`:n>=1e3?Math.round(n/100)/10+"k":n,o=e[t+$],s=-1===o?{}:Object.assign({},i[o]);return Object.assign(s,{cluster:!0,cluster_id:e[t+H],point_count:n,point_count_abbreviated:r})}function K(e){return e/360+.5}function X(e){const t=Math.sin(e*Math.PI/180),i=.5-.25*Math.log((1+t)/(1-t))/Math.PI;return i<0?0:i>1?1:i}function J(e){const t=(180-360*e)*Math.PI/180;return 360*Math.atan(Math.exp(t))/Math.PI-90}function Y(e,t,i,n){let r=n;const o=t+(i-t>>1);let s,a=i-t;const l=e[t],c=e[t+1],u=e[i],h=e[i+1];for(let n=t+3;nr)s=n,r=t;else if(t===r){const e=Math.abs(n-o);en&&(s-t>3&&Y(e,t,s,n),e[s+2]=r,i-s>3&&Y(e,s,i,n))}function ee(e,t,i,n,r,o){let s=r-i,a=o-n;if(0!==s||0!==a){const l=((e-i)*s+(t-n)*a)/(s*s+a*a);l>1?(i=r,n=o):l>0&&(i+=s*l,n+=a*l)}return s=e-i,a=t-n,s*s+a*a}function te(e,t,i,n){const r={id:e??null,type:t,geometry:i,tags:n,minX:1/0,minY:1/0,maxX:-1/0,maxY:-1/0};if("Point"===t||"MultiPoint"===t||"LineString"===t)ie(r,i);else if("Polygon"===t)ie(r,i[0]);else if("MultiLineString"===t)for(const e of i)ie(r,e);else if("MultiPolygon"===t)for(const e of i)ie(r,e[0]);return r}function ie(e,t){for(let i=0;i0&&(s+=n?(r*l-a*o)/2:Math.sqrt(Math.pow(a-r,2)+Math.pow(l-o,2))),r=a,o=l}const a=t.length-3;t[2]=1,Y(t,0,a,i),t[a+2]=1,t.size=Math.abs(s),t.start=0,t.end=t.size}function se(e,t,i,n){for(let r=0;r1?1:i}function ce(e,t,i,n,r,o,s,a){if(n/=t,o>=(i/=t)&&s=n)return null;const l=[];for(const t of e){const e=t.geometry;let o=t.type;const s=0===r?t.minX:t.minY,c=0===r?t.maxX:t.maxY;if(s>=i&&c=n)continue;let u=[];if("Point"===o||"MultiPoint"===o)ue(e,u,i,n,r);else if("LineString"===o)he(e,u,i,n,r,!1,a.lineMetrics);else if("MultiLineString"===o)pe(e,u,i,n,r,!1);else if("Polygon"===o)pe(e,u,i,n,r,!0);else if("MultiPolygon"===o)for(const t of e){const e=[];pe(t,e,i,n,r,!0),e.length&&u.push(e)}if(u.length){if(a.lineMetrics&&"LineString"===o){for(const e of u)l.push(te(t.id,o,e,t.tags));continue}"LineString"!==o&&"MultiLineString"!==o||(1===u.length?(o="LineString",u=u[0]):o="MultiLineString"),"Point"!==o&&"MultiPoint"!==o||(o=3===u.length?"Point":"MultiPoint"),l.push(te(t.id,o,u,t.tags))}}return l.length?l:null}function ue(e,t,i,n,r){for(let o=0;o=i&&s<=n&&fe(t,e[o],e[o+1],e[o+2])}}function he(e,t,i,n,r,o,s){let a=de(e);const l=0===r?me:ge;let c,u,h=e.start;for(let d=0;di&&(u=l(a,p,f,g,_,i),s&&(a.start=h+c*u)):A>n?y=i&&(u=l(a,p,f,g,_,i),v=!0),y>n&&A<=n&&(u=l(a,p,f,g,_,n),v=!0),!o&&v&&(s&&(a.end=h+c*u),t.push(a),a=de(e)),s&&(h+=c)}let d=e.length-3;const p=e[d],f=e[d+1],m=0===r?p:f;m>=i&&m<=n&&fe(a,p,f,e[d+2]),d=a.length-3,o&&d>=3&&(a[d]!==a[0]||a[d+1]!==a[1])&&fe(a,a[0],a[1],a[2]),a.length&&t.push(a)}function de(e){const t=[];return t.size=e.size,t.start=e.start,t.end=e.end,t}function pe(e,t,i,n,r,o){for(const s of e)he(s,t,i,n,r,o,!1)}function fe(e,t,i,n){e.push(t,i,n)}function me(e,t,i,n,r,o){const s=(o-t)/(n-t);return fe(e,o,i+(r-i)*s,1),s}function ge(e,t,i,n,r,o){const s=(o-i)/(r-i);return fe(e,t+(n-t)*s,o,1),s}function _e(e,t){const i=[];for(let n=0;n0&&t.size<(r?s:n))return void(i.numPoints+=t.length/3);const a=[];for(let e=0;es)&&(i.numSimplified++,a.push(t[e],t[e+1])),i.numPoints++;r&&function(e,t){let i=0;for(let t=0,n=e.length,r=n-2;t0===t)for(let t=0,i=e.length;t24)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 n=function(e,t){const i=[];if("FeatureCollection"===e.type)for(let n=0;n1&&console.time("creation"),d=this.tiles[h]=xe(e,t,i,n,l),this.tileCoords.push({z:t,x:i,y:n}),c)){c>1&&(console.log("tile z%d-%d-%d (features: %d, points: %d, simplified: %d)",t,i,n,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==r){if(t===l.indexMaxZoom||d.numPoints<=l.indexMaxPoints)continue}else{if(t===l.maxZoom||t===r)continue;if(null!=r){const e=r-t;if(i!==o>>e||n!==s>>e)continue}}if(d.source=null,0===e.length)continue;c>1&&console.time("clipping");const p=.5*l.buffer/l.extent,f=.5-p,m=.5+p,g=1+p;let _=null,A=null,y=null,v=null,x=ce(e,u,i-p,i+m,0,d.minX,d.maxX,l),b=ce(e,u,i+f,i+g,0,d.minX,d.maxX,l);e=null,x&&(_=ce(x,u,n-p,n+m,1,d.minY,d.maxY,l),A=ce(x,u,n+f,n+g,1,d.minY,d.maxY,l),x=null),b&&(y=ce(b,u,n-p,n+m,1,d.minY,d.maxY,l),v=ce(b,u,n+f,n+g,1,d.minY,d.maxY,l),b=null),c>1&&console.timeEnd("clipping"),a.push(_||[],t+1,2*i,2*n),a.push(A||[],t+1,2*i,2*n+1),a.push(y||[],t+1,2*i+1,2*n),a.push(v||[],t+1,2*i+1,2*n+1)}}getTile(e,t,i){e=+e,t=+t,i=+i;const n=this.options,{extent:r,debug:o}=n;if(e<0||e>24)return null;const s=1<1&&console.log("drilling down to z%d-%d-%d",e,t,i);let l,c=e,u=t,h=i;for(;!l&&c>0;)c--,u>>=1,h>>=1,l=this.tiles[Ce(c,u,h)];return l&&l.source?(o>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,i),o>1&&console.timeEnd("drilling down"),this.tiles[a]?ye(this.tiles[a],r):null):null}}function Ce(e,t,i){return 32*((1<e.tags&&"3d_elevation_id"in e.tags&&"source"in e.tags&&"elevation"===e.tags.source,s=r.features.filter(e=>o(e));let a={_geojsonTileLayer:r.features};s.length>0&&(a={_geojsonTileLayer:r.features.filter(e=>!o(e)),hd_road_elevation:s});const l=new w(a),c=function(t){const i=new e.bs;for(const e of Object.keys(t))i.writeMessage(3,F,{name:e,features:t[e]});return i.finish()}(a).buffer;i(null,{vectorTile:l,rawData:c})}class Be extends g{constructor(e,t,i,n,r,o,s){super(e,t,i,n,r,Se,s),o&&(this.loadGeoJSON=o),this._dynamicIndex=new C}loadData(i,n){const r=i&&i.request,o=r&&r.collectResourceTiming;this._geoJSONIndex=null,this.loadGeoJSON(i,(s,a)=>{if(s||!a)return n(s);if("object"!=typeof a)return n(new Error(`Input data given to '${i.source}' is not a valid GeoJSON object.`));{try{if(i.filter){const t=e.U(i.filter,{type:"boolean","property-type":"data-driven",overridable:!1,transition:!1});if("error"===t.result)throw new Error(t.value.map(e=>`${e.key}: ${e.message}`).join(", "));a.features=a.features.filter(e=>t.value.evaluate({zoom:0},e))}i.dynamic?("Feature"===a.type&&(a={type:"FeatureCollection",features:[a]}),i.append||(this._dynamicIndex.clear(),this.loaded={}),this._dynamicIndex.load(a.features,this.loaded),i.cluster&&(a.features=this._dynamicIndex.getFeatures())):this.loaded={},this._geoJSONIndex=i.cluster?new Z(function({superclusterOptions:t,clusterProperties:i}){if(!i||!t)return t;const n={},r={},o={accumulated:null,zoom:0},s={properties:null},a=Object.keys(i);for(const t of a){const[o,s]=i[t],a=e.U(s),l=e.U("string"==typeof o?[o,["accumulated"],["get",t]]:o);n[t]=a.value,r[t]=l.value}return t.map=e=>{s.properties=e;const t={};for(const e of a)t[e]=n[e].evaluate(o,s);return t},t.reduce=(e,t)=>{s.properties=t;for(const t of a)o.accumulated=e[t],e[t]=r[t].evaluate(o,s)},t}(i)).load(a.features):i.dynamic?this._dynamicIndex:function(e,t){return new Ee(e,t)}(a,i.geojsonVtOptions)}catch(e){return n(e)}const s={};if(o){const e=t(r);e&&(s.resourceTiming={},s.resourceTiming[i.source]=JSON.parse(JSON.stringify(e)))}n(null,s)}})}reloadTile(e,t){const i=this.loaded;return i&&i[e.uid]?e.partial?t(null,void 0):super.reloadTile(e,t):this.loadTile(e,t)}loadGeoJSON(t,i){if(t.request)e.m(t.request,i);else{if("string"!=typeof t.data)return i(new Error(`Input data given to '${t.source}' is not a valid GeoJSON object.`));setTimeout(()=>{try{return i(null,JSON.parse(t.data))}catch(e){return i(new Error(`Input data given to '${t.source}' is not a valid GeoJSON object.`))}},0)}}getClusterExpansionZoom(e,t){try{t(null,this._geoJSONIndex.getClusterExpansionZoom(e.clusterId))}catch(e){t(e)}}getClusterChildren(e,t){try{t(null,this._geoJSONIndex.getChildren(e.clusterId))}catch(e){t(e)}}getClusterLeaves(e,t){try{t(null,this._geoJSONIndex.getLeaves(e.clusterId,e.limit,e.offset))}catch(e){t(e)}}}class Ie{constructor(t,i,n){this.tileID=new e.aP(t.tileID.overscaledZ,t.tileID.wrap,t.tileID.canonical.z,t.tileID.canonical.x,t.tileID.canonical.y),this.tileZoom=t.tileZoom,this.uid=t.uid,this.zoom=t.zoom,this.canonical=t.tileID.canonical,this.pixelRatio=t.pixelRatio,this.tileSize=t.tileSize,this.source=t.source,this.overscaling=this.tileID.overscaleFactor(),this.projection=t.projection,this.brightness=i,this.worldview=n}parse(t,i,n,r){this.status="parsing";const o=new e.aP(n.tileID.overscaledZ,n.tileID.wrap,n.tileID.canonical.z,n.tileID.canonical.x,n.tileID.canonical.y),s=[],a=i.familiesBySource[n.source],l=new e.fm(o,n.promoteId);l.bucketLayerIDs=[],l.is3DTile=!0,e.fB(t).then(t=>{if(!t)return r(new Error("Could not parse tile"));const i=t.json.extensionsUsed&&t.json.extensionsUsed.includes("MAPBOX_mesh_features")||t.json.asset.extras&&t.json.asset.extras.MAPBOX_mesh_features,c=t.json.extensionsUsed&&t.json.extensionsUsed.includes("EXT_meshopt_compression"),u=new e.ac(this.zoom,{brightness:this.brightness,worldview:this.worldview});for(const r in a)for(const h of a[r]){const r=h[0];l.bucketLayerIDs.push(h.map(t=>e.B(t.id,t.scope))),r.recalculate(u,[]);const a=e.fC(t,1/e.d6(n.tileID.canonical)),d=new e.fD(h,a,o,i,c,this.brightness,l,this.worldview);i||(d.needsUpload=!0),s.push(d),d.evaluate(r)}this.status="done",r(null,{buckets:s,featureIndex:l,collisionBoxArray:null,glyphAtlasImage:null,lineAtlas:null,imageAtlas:null,brightness:null})}).catch(e=>r(new Error(e.message)))}}class Me{constructor(e,t,i,n,r,o,s,a){this.actor=e,this.layerIndex=t,this.availableImages=i,this.availableModels=n,this.brightness=s,this.loading={},this.loaded={},this.worldview=a}loadTile(t,i){const n=t.uid,r=this.loading[n]=new Ie(t,this.brightness,this.worldview);e.bt(t.request,(e,o)=>{const s=!this.loading[n];return delete this.loading[n],s||e?(r.status="done",s||(this.loaded[n]=r),i(e)):o&&0!==o.byteLength?void r.parse(o,this.layerIndex,t,(e,t)=>{r.status="done",this.loaded=this.loaded||{},this.loaded[n]=r,e||!t?i(e):i(null,t)}):(r.status="done",this.loaded[n]=r,i())})}reloadTile(e,t){const i=this.loaded,n=e.uid;if(i&&i[n]){const r=i[n];r.projection=e.projection,r.brightness=e.brightness;const o=(i,n)=>{r.reloadCallback&&(delete r.reloadCallback,this.loadTile(e,t)),t(i,n)};"parsing"===r.status?r.reloadCallback=o:"done"===r.status&&this.loadTile(e,t)}}abortTile(e,t){const i=e.uid;this.loading[i]&&delete this.loading[i],t()}removeTile(e,t){const i=this.loaded,n=e.uid;i&&i[n]&&delete i[n],t()}}class Pe{constructor(t){this.self=t,this.actor=new e.fF(t,this),this.layerIndexes={},this.availableImages={},this.availableModels={},this.isSpriteLoaded={},this.imageRasterizer=new e.x,this.rtlPluginParsingListeners=[],this.projections={},this.defaultProjection=e.cl({name:"mercator"}),this.workerSourceTypes={vector:g,geojson:Be,"raster-dem":_,"raster-array":y,"batched-model":Me},this.workerSources={},this.self.registerWorkerSource=(e,t)=>{if(this.workerSourceTypes[e])throw new Error(`Worker source with name "${e}" already registered.`);this.workerSourceTypes[e]=t},this.self.registerRTLTextPlugin=t=>{if(e.fG.isParsed())throw new Error("RTL text plugin already registered.");e.fG.setState({pluginStatus:e.fH.parsed,pluginURL:e.fG.getPluginURL()}),e.fG.applyArabicShaping=t.applyArabicShaping,e.fG.processBidirectionalText=t.processBidirectionalText,e.fG.processStyledBidirectionalText=t.processStyledBidirectionalText;for(const e of this.rtlPluginParsingListeners)e(null,!0);this.rtlPluginParsingListeners=[]}}clearCaches(e,t,i){delete this.layerIndexes[e],delete this.availableImages[e],delete this.availableModels[e],delete this.workerSources[e],i()}checkIfReady(e,t,i){i()}setReferrer(e,t){this.referrer=t}spriteLoaded(t,i){this.isSpriteLoaded[t]||(this.isSpriteLoaded[t]={});const{scope:n,isLoaded:r}=i;if(this.isSpriteLoaded[t][n]=r,this.workerSources[t]&&this.workerSources[t][n])for(const i in this.workerSources[t][n]){const o=this.workerSources[t][n][i];for(const t in o){const i=o[t];i instanceof g&&(i.isSpriteLoaded=r,i.fire(new e.z("isSpriteLoaded")))}}}setImages(e,t,i){this.availableImages[e]||(this.availableImages[e]={});const{scope:n,images:r}=t;if(this.availableImages[e][n]=r,this.workerSources[e]&&this.workerSources[e][n]){for(const t in this.workerSources[e][n]){const i=this.workerSources[e][n][t];for(const e in i)i[e].availableImages=r}i()}else i()}setModels(e,{scope:t,models:i},n){if(this.availableModels[e]||(this.availableModels[e]={}),this.availableModels[e][t]=i,this.workerSources[e]&&this.workerSources[e][t]){for(const n in this.workerSources[e][t]){const r=this.workerSources[e][t][n];for(const e in r)r[e].availableModels=i}n()}else n()}setProjection(t,i){this.projections[t]=e.cl(i)}setBrightness(e,t,i){this.brightness=t,i()}setWorldview(e,t,i){this.worldview=t,i()}setLayers(e,t,i){this.getLayerIndex(e,t.scope).replace(t.layers,t.options),i()}updateLayers(e,t,i){this.getLayerIndex(e,t.scope).update(t.layers,t.removedIds,t.options),i()}loadTile(e,t,i){t.projection=this.projections[e]||this.defaultProjection,this.getWorkerSource(e,t.type,t.source,t.scope).loadTile(t,i)}decodeRasterArray(e,t,i){this.getWorkerSource(e,t.type,t.source,t.scope).decodeRasterArray(t,i)}reloadTile(e,t,i){t.projection=this.projections[e]||this.defaultProjection,this.getWorkerSource(e,t.type,t.source,t.scope).reloadTile(t,i)}abortTile(e,t,i){this.getWorkerSource(e,t.type,t.source,t.scope).abortTile(t,i)}removeTile(e,t,i){this.getWorkerSource(e,t.type,t.source,t.scope).removeTile(t,i)}removeSource(e,t,i){if(!(this.workerSources[e]&&this.workerSources[e][t.scope]&&this.workerSources[e][t.scope][t.type]&&this.workerSources[e][t.scope][t.type][t.source]))return;const n=this.workerSources[e][t.scope][t.type][t.source];delete this.workerSources[e][t.scope][t.type][t.source],void 0!==n.removeSource?n.removeSource(t,i):i()}loadWorkerSource(e,t,i){try{this.self.importScripts(t.url),i()}catch(e){i(e.toString())}}syncRTLPluginState(t,i,n){if(e.fG.isParsed())n(null,!0);else if(e.fG.isParsing())this.rtlPluginParsingListeners.push(n);else try{e.fG.setState(i);const t=e.fG.getPluginURL();!e.fG.isLoaded()||e.fG.isParsed()||e.fG.isParsing()||null==t||(e.fG.setState({pluginStatus:e.fH.parsing,pluginURL:e.fG.getPluginURL()}),this.self.importScripts(t),e.fG.isParsed()?n(null,!0):this.rtlPluginParsingListeners.push(n))}catch(e){n(e.toString())}}setDracoUrl(e,t){this.dracoUrl=t}getAvailableImages(e,t){this.availableImages[e]||(this.availableImages[e]={});let i=this.availableImages[e][t];return i||(i=[]),i}getAvailableModels(e,t){this.availableModels[e]||(this.availableModels[e]={});let i=this.availableModels[e][t];return i||(i={}),i}getLayerIndex(e,t){this.layerIndexes[e]||(this.layerIndexes[e]={});let i=this.layerIndexes[e][t];return i||(i=this.layerIndexes[e][t]=new r,i.scope=t),i}getWorkerSource(e,t,i,n){const r=this.workerSources;return r[e]||(r[e]={}),r[e][n]||(r[e][n]={}),r[e][n][t]||(r[e][n][t]={}),this.isSpriteLoaded[e]||(this.isSpriteLoaded[e]={}),r[e][n][t][i]||(r[e][n][t][i]=new this.workerSourceTypes[t]({send:(t,i,n,r,o,s)=>this.actor.send(t,i,n,e,o,s),scheduler:this.actor.scheduler},this.getLayerIndex(e,n),this.getAvailableImages(e,n),this.getAvailableModels(e,n),this.isSpriteLoaded[e][n],void 0,this.brightness,this.worldview)),r[e][n][t][i]}rasterizeImagesWorker(e,t,i){const n=new Map;for(const[i,{image:r,imageVariant:o}]of t.tasks.entries()){const s=this.imageRasterizer.rasterize(o,r,t.scope,e);n.set(i,s)}i(void 0,n)}removeRasterizedImages(e,t,i){this.imageRasterizer.removeImagesFromCacheByIds(t.imageIds,t.scope,e),i()}enforceCacheSizeLimit(t,i){e.fI(i)}getWorkerPerformanceMetrics(e,t,i){i(void 0,void 0)}}return e.fE(self)&&(self.worker=new Pe(self)),Pe}),n(["./shared"],function(e){var t="3.16.0";const i={create:"create",load:"load",fullLoad:"fullLoad"},n={mark(e){performance.mark(e)},measure(e,t,i){performance.measure(e,t,i)}};function r(t){const i=t.name.split("?")[0];return e.a(i)&&i.includes("mapbox-gl.js")?"javascript":e.a(i)&&i.includes("mapbox-gl.css")?"css":e.b(i)?"fontRange":e.c(i)?"sprite":e.i(i)?"style":e.d(i)?"tilejson":"other"}var o,s={},a=function(){if(o)return s;function e(e){return!t(e)}function t(t){return"undefined"==typeof window||"undefined"==typeof document?"not a browser":function(){if(!("Worker"in window&&"Blob"in window&&"URL"in window))return!1;var e,t,i=new Blob([""],{type:"text/javascript"}),n=URL.createObjectURL(i);try{t=new Worker(n),e=!0}catch(t){e=!1}return t&&t.terminate(),URL.revokeObjectURL(n),e}()?function(){var e=document.createElement("canvas");e.width=e.height=1;var t=e.getContext("2d");if(!t)return!1;var i=t.getImageData(0,0,1,1);return i&&i.width===e.width}()?(void 0===i[n=t&&t.failIfMajorPerformanceCaveat]&&(i[n]=function(t){var i,n=function(t){var i=document.createElement("canvas"),n=Object.create(e.webGLContextAttributes);return n.failIfMajorPerformanceCaveat=t,i.getContext("webgl2",n)}(t);if(!n)return!1;try{i=n.createShader(n.VERTEX_SHADER)}catch(e){return!1}return!(!i||n.isContextLost())&&(n.shaderSource(i,"void main() {}"),n.compileShader(i),!0===n.getShaderParameter(i,n.COMPILE_STATUS))}(n)),i[n]?document.documentMode?"insufficient ECMAScript 6 support":void 0:"insufficient WebGL2 support"):"insufficient Canvas/getImageData support":"insufficient worker support";var n}o=1,s.supported=e,s.notSupportedReason=t;var i={};return e.webGLContextAttributes={antialias:!1,alpha:!0,stencil:!0,depth:!0},s}();function l(e,t,i){const n=document.createElement(e);return null!=t&&(n.className=t),i&&i.appendChild(n),n}function c(e,t,i){const n=document.createElementNS("http://www.w3.org/2000/svg",e);for(const e of Object.keys(t))n.setAttributeNS(null,e,String(t[e]));return i&&i.appendChild(n),n}const u="undefined"!=typeof document?document.documentElement&&document.documentElement.style:null,h=u&&void 0!==u.userSelect?"userSelect":"WebkitUserSelect";let d;function p(){u&&h&&(d=u[h],u[h]="none")}function f(){u&&h&&(u[h]=d)}function m(e){e.preventDefault(),e.stopPropagation(),window.removeEventListener("click",m,!0)}function g(){window.addEventListener("click",m,!0),window.setTimeout(()=>{window.removeEventListener("click",m,!0)},0)}function _(e,t){const i=e.getBoundingClientRect();return v(e,i,t)}function A(e,t){const i=e.getBoundingClientRect(),n=[];for(let r=0;rthis._skuTokenExpiresAt}transformRequest(e,t){return this._transformRequestFn&&this._transformRequestFn(e,t)||{url:e}}normalizeStyleURL(i,n){if(!e.h(i))return i;const r=E(i);return r.params.push(`sdk=js-${t}`),r.path=`/styles/v1${r.path}`,this._makeAPIURL(r,this._customAccessToken||n)}normalizeGlyphsURL(t,i){if(!e.h(t))return t;const n=E(t);return n.path=`/fonts/v1${n.path}`,this._makeAPIURL(n,this._customAccessToken||i)}normalizeModelURL(t,i){if(!e.h(t))return t;const n=E(t);return n.path=`/models/v1${n.path}`,this._makeAPIURL(n,this._customAccessToken||i)}normalizeSourceURL(t,i,n,r){if(!e.h(t))return t;const o=E(t);return o.path=`/v4/${o.authority}.json`,o.params.push("secure"),n&&o.params.push(`language=${n}`),r&&o.params.push(`worldview=${r}`),this._makeAPIURL(o,this._customAccessToken||i)}normalizeIconsetURL(t,i){const n=E(t);return e.h(t)?(n.path=`/styles/v1${n.path}/iconset.pbf`,this._makeAPIURL(n,this._customAccessToken||i)):C(n)}normalizeSpriteURL(t,i,n,r){const o=E(t);return e.h(t)?(o.path=`/styles/v1${o.path}/sprite${i}${n}`,this._makeAPIURL(o,this._customAccessToken||r)):(o.path+=`${i}${n}`,C(o))}normalizeTileURL(t,i,n){if(this._isSkuTokenExpired()&&this._createSkuToken(),t&&!e.h(t))return t;const r=E(t);r.path=r.path.replace(/(\.(png|jpg)\d*)(?=$)/,`${i||n&&"raster"!==r.authority&&512===n?"@2x":""}${e.k.supported?".webp":"$1"}`),"raster"===r.authority?r.path=`/${e.e.RASTER_URL_PREFIX}${r.path}`:"rasterarrays"===r.authority?r.path=`/${e.e.RASTERARRAYS_URL_PREFIX}${r.path}`:"3dtiles"===r.authority?r.path=`/${e.e.TILES3D_URL_PREFIX}${r.path}`:(r.path=r.path.replace(/^.+\/v4\//,"/"),r.path=`/${e.e.TILE_URL_VERSION}${r.path}`);const o=this._customAccessToken||function(e){for(const t of e){const e=t.match(/^access_token=(.*)$/);if(e)return e[1]}return null}(r.params)||e.e.ACCESS_TOKEN;return e.e.REQUIRE_ACCESS_TOKEN&&o&&this._skuToken&&r.params.push(`sku=${this._skuToken}`),this._makeAPIURL(r,o)}canonicalizeTileURL(t,i){const n=E(t);if(!n.path.match(/^(\/v4\/|\/(raster|rasterarrays)\/v1\/)/)||!n.path.match(/\.[\w]+$/))return t;let r="mapbox://";n.path.match(/^\/raster\/v1\//)?r+=`raster/${n.path.replace(`/${e.e.RASTER_URL_PREFIX}/`,"")}`:n.path.match(/^\/rasterarrays\/v1\//)?r+=`rasterarrays/${n.path.replace(`/${e.e.RASTERARRAYS_URL_PREFIX}/`,"")}`:r+=`tiles/${n.path.replace(`/${e.e.TILE_URL_VERSION}/`,"")}`;let o=n.params;return i&&(o=o.filter(e=>!e.match(/^access_token=/))),o.length&&(r+=`?${o.join("&")}`),r}canonicalizeTileset(t,i){const n=!!i&&e.h(i),r=[];for(const i of t.tiles||[])e.j(i)?r.push(this.canonicalizeTileURL(i,n)):r.push(i);return r}_makeAPIURL(t,i){const n="See https://docs.mapbox.com/api/overview/#access-tokens-and-token-scopes",r=E(e.e.API_URL);if(t.protocol=r.protocol,t.authority=r.authority,"http"===t.protocol){const e=t.params.indexOf("secure");e>=0&&t.params.splice(e,1)}if("/"!==r.path&&(t.path=`${r.path}${t.path}`),!e.e.REQUIRE_ACCESS_TOKEN)return C(t);if(i=i||e.e.ACCESS_TOKEN,!this._silenceAuthErrors){if(!i)throw new Error(`An API access token is required to use Mapbox GL. ${n}`);if("s"===i[0])throw new Error(`Use a public access token (pk.*) with Mapbox GL, not a secret access token (sk.*). ${n}`)}return t.params=t.params.filter(e=>-1===e.indexOf("access_token")),t.params.push(`access_token=${i||""}`),C(t)}}const T=/^(\w+):\/\/([^/?]*)(\/[^?]+)?\??(.+)?/;function E(e){const t=e.match(T);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 C(e){const t=e.params.length?`?${e.params.join("&")}`:"";return`${e.protocol}://${e.authority}${e.path}${t}`}const S="mapbox.eventData";function B(t){if(!t)return null;const i=t.split(".");if(!i||3!==i.length)return null;try{return JSON.parse(e.l(i[1]))}catch(e){return null}}class I{constructor(e){this.type=e,this.anonId=null,this.anonIdTimestamp=null,this.eventData={},this.queue=[],this.pendingRequest=null}getStorageKey(t){const i=B(e.e.ACCESS_TOKEN);let n="";return n=i&&i.u?e.f(i.u):e.e.ACCESS_TOKEN||"",t?`${S}.${t}:${n}`:`${S}:${n}`}fetchEventData(){const t=e.s("localStorage"),i=this.getStorageKey(),n=this.getStorageKey("uuid"),r=this.getStorageKey("uuidTimestamp");if(t)try{const e=localStorage.getItem(i);e&&(this.eventData=JSON.parse(e));const t=localStorage.getItem(n);t&&(this.anonId=t);const o=localStorage.getItem(r);o&&(this.anonIdTimestamp=Number(o));const s=Date.now()-864e5;(!this.anonIdTimestamp||this.anonIdTimestamp=1&&localStorage.setItem(i,JSON.stringify(this.eventData)),s&&localStorage.setItem(r,s.toString())}catch(t){e.w("Unable to write to LocalStorage")}}processRequests(e){}postEvent(t,i,n,r){if(!e.e.EVENTS_URL)return;const o=E(e.e.EVENTS_URL);o.params.push(`access_token=${r||e.e.ACCESS_TOKEN||""}`);const s={event:this.type,created:new Date(t).toISOString()},a=i?Object.assign(s,i):s,l={url:C(o),headers:{"Content-Type":"text/plain"},body:JSON.stringify([a])};this.pendingRequest=e.p(l,e=>{this.pendingRequest=null,n(e),this.saveEventData(),this.processRequests(r)})}queueRequest(e,t){this.queue.push(e),this.processRequests(t)}}const M=new class extends I{constructor(e){super("appUserTurnstile"),this._customAccessToken=e}postTurnstileEvent(t,i){e.e.EVENTS_URL&&e.e.ACCESS_TOKEN&&Array.isArray(t)&&t.some(t=>e.h(t)||e.j(t))&&this.queueRequest(Date.now(),i)}processRequests(i){if(this.pendingRequest||0===this.queue.length)return;this.anonId&&this.anonIdTimestamp&&this.eventData.lastSuccess&&this.eventData.tokenU||this.fetchEventData();const n=B(e.e.ACCESS_TOKEN),r=n?n.u:e.e.ACCESS_TOKEN;let o=r!==this.eventData.tokenU;e.v(this.anonId)||(this.refreshUUID(),o=!0);const s=this.queue.shift();if(this.eventData.lastSuccess){const e=new Date(this.eventData.lastSuccess),t=new Date(s),i=(s-this.eventData.lastSuccess)/864e5;o=o||i>=1||i<-1||e.getDate()!==t.getDate()}else o=!0;o?this.postEvent(s,{sdkIdentifier:"mapbox-gl-js",sdkVersion:t,skuId:x,"enabled.telemetry":!1,userId:this.anonId},e=>{e||(this.eventData.lastSuccess=s,this.eventData.tokenU=r)},i):this.processRequests()}},P=M.postTurnstileEvent.bind(M),R=new class extends I{constructor(){super("map.load"),this.success={},this.skuToken=""}postMapLoadEvent(t,i,n,r){this.skuToken=i,this.errorCb=r,e.e.EVENTS_URL&&(n||e.e.ACCESS_TOKEN?this.queueRequest({id:t,timestamp:Date.now()},n):this.errorCb(new Error(b)))}processRequests(i){if(this.pendingRequest||0===this.queue.length)return;const{id:n,timestamp:r}=this.queue.shift();n&&this.success[n]||(this.anonId&&this.anonIdTimestamp||this.fetchEventData(),e.v(this.anonId)||this.refreshUUID(),this.postEvent(r,{sdkIdentifier:"mapbox-gl-js",sdkVersion:t,skuId:x,skuToken:this.skuToken,userId:this.anonId},e=>{e?this.errorCb(e):n&&(this.success[n]=!0)},i))}remove(){this.errorCb=null}},L=R.postMapLoadEvent.bind(R),F=new class extends I{constructor(){super("style.load"),this.eventIdPerMapInstanceMap=new Map,this.mapInstanceIdMap=new WeakMap}getMapInstanceId(t){let i=this.mapInstanceIdMap.get(t);return i||(i=e.u(),this.mapInstanceIdMap.set(t,i)),i}getEventId(e){const t=this.eventIdPerMapInstanceMap.get(e)||0;return this.eventIdPerMapInstanceMap.set(e,t+1),t}postStyleLoadEvent(t,i){const{map:n,style:r,importedStyles:o}=i;if(!e.e.EVENTS_URL||!t&&!e.e.ACCESS_TOKEN)return;const s=this.getMapInstanceId(n),a={mapInstanceId:s,eventId:this.getEventId(s),style:r};o.length&&(a.importedStyles=o),this.queueRequest({timestamp:Date.now(),payload:a},t)}processRequests(e){if(this.pendingRequest||0===this.queue.length)return;const{timestamp:t,payload:i}=this.queue.shift();this.postEvent(t,i,()=>{},e)}},k=F.postStyleLoadEvent.bind(F),D=new class extends I{constructor(e){super("metrics"),e&&(this.data=e)}postMetricsEvent(t){if(!e.e.EVENTS_URL||!t&&!e.e.ACCESS_TOKEN)return;this.anonId||this.fetchEventData(),e.v(this.anonId)||this.refreshUUID();const i=Object.assign({},this.data,{sessionId:this.anonId});this.queueRequest({timestamp:Date.now(),payload:i},t)}processRequests(e){if(this.pendingRequest||0===this.queue.length)return;const{timestamp:t,payload:i}=this.queue.shift();this.postEvent(t,i,()=>{},e)}}({attributes:[{name:"maps/js/layer-animations/style-with-appearances"}]}),O=D.postMetricsEvent.bind(D),z=new class extends I{constructor(){super("gljs.performance")}postPerformanceEvent(t,i){e.e.EVENTS_URL&&(t||e.e.ACCESS_TOKEN)&&this.queueRequest({timestamp:Date.now(),performanceData:i},t)}processRequests(n){if(this.pendingRequest||0===this.queue.length)return;const{timestamp:o,performanceData:s}=this.queue.shift(),a=function(n){const o=performance.getEntriesByType("resource"),s=performance.getEntriesByType("mark"),a=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`,s=`${i}RequestCachedCount`;t[e]=Math.min(t[e]||1/0,n.startTime),t[r]=Math.max(t[r]||-1/0,n.responseEnd);const a=e=>{void 0===t[e]&&(t[e]=0),++t[e]};void 0!==n.transferSize&&0===n.transferSize&&a(s),a(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}(o,r)),l=window.devicePixelRatio,c=navigator.connection||navigator.mozConnection||navigator.webkitConnection,u=c?c.effectiveType:void 0,h={counters:[],metadata:[],attributes:[]},d=(e,t,i)=>{null!=i&&e.push({name:t,value:i.toString()})};for(const e in a)d(h.counters,e,a[e]);if(n.interactionRange[0]!==1/0&&n.interactionRange[1]!==-1/0&&(d(h.counters,"interactionRangeMin",n.interactionRange[0]),d(h.counters,"interactionRangeMax",n.interactionRange[1])),s)for(const e of Object.values(i)){const t=s.find(t=>t.name===e);t&&d(h.counters,e,t.startTime)}return d(h.counters,"visibilityHidden",n.visibilityHidden),d(h.attributes,"style",function(t){if(t)for(const i of t){const t=i.name.split("?")[0];if(e.i(t)){const e=t.split("/").slice(-2);if(2===e.length)return`mapbox://styles/${e[0]}/${e[1]}`}}}(o)),d(h.attributes,"terrainEnabled",n.terrainEnabled?"true":"false"),d(h.attributes,"fogEnabled",n.fogEnabled?"true":"false"),d(h.attributes,"projection",n.projection),d(h.attributes,"zoom",n.zoom),d(h.metadata,"devicePixelRatio",l),d(h.metadata,"connectionEffectiveType",u),d(h.metadata,"navigatorUserAgent",navigator.userAgent),d(h.metadata,"screenWidth",window.screen.width),d(h.metadata,"screenHeight",window.screen.height),d(h.metadata,"windowWidth",window.innerWidth),d(h.metadata,"windowHeight",window.innerHeight),d(h.metadata,"mapWidth",n.width/l),d(h.metadata,"mapHeight",n.height/l),d(h.metadata,"webglRenderer",n.renderer),d(h.metadata,"webglVendor",n.vendor),d(h.metadata,"sdkVersion",t),d(h.metadata,"sdkIdentifier","mapbox-gl-js"),h}(s);for(const e of a.metadata);for(const e of a.counters);for(const e of a.attributes);this.postEvent(o,a,()=>{},n)}},U=z.postPerformanceEvent.bind(z),N=new class extends I{constructor(){super("map.auth"),this.success={},this.skuToken=""}getSession(t,i,n,r){if(!e.e.API_URL||!e.e.SESSION_PATH)return;const o=E(e.e.API_URL+e.e.SESSION_PATH);o.params.push(`sku=${i||""}`),o.params.push(`access_token=${r||e.e.ACCESS_TOKEN||""}`);const s={url:C(o),headers:{"Content-Type":"text/plain"}};this.pendingRequest=e.g(s,e=>{this.pendingRequest=null,n(e),this.saveEventData(),this.processRequests(r)})}getSessionAPI(t,i,n,r){this.skuToken=i,this.errorCb=r,e.e.SESSION_PATH&&e.e.API_URL&&(n||e.e.ACCESS_TOKEN?this.queueRequest({id:t,timestamp:Date.now()},n):this.errorCb(new Error(b)))}processRequests(e){if(this.pendingRequest||0===this.queue.length)return;const{id:t,timestamp:i}=this.queue.shift();t&&this.success[t]||this.getSession(i,this.skuToken,e=>{e?this.errorCb(e):t&&(this.success[t]=!0)},e)}remove(){this.errorCb=null}},V=N.getSessionAPI.bind(N),j=new Set;function G(e,t){t?j.add(e):j.delete(e)}class H{constructor(){this._changed=!1,this._updatedLayers={},this._removedLayers={},this._updatedSourceCaches={},this._updatedPaintProps=new Set,this._updatedImages={}}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={},this._removedLayers={},this._updatedSourceCaches={},this._updatedPaintProps.clear(),this._updatedImages={}}}function Q(e){const{userImage:t}=e;return!!(t&&t.render&&t.render())&&(e.data.replace(new Uint8Array(t.data.buffer)),!0)}class $ extends e.E{constructor(t){super(),this.imageProviders=new Map,this.images=new Map,this.updatedImages=new Map,this.callbackDispatchedThisFrame=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.dirty=!0,this.spriteFormat=t,"raster"!==t&&e.r()&&(this.imageRasterizerDispatcher=new e.D(e.t(),this,"Image Rasterizer Worker",1))}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.patterns.set(t,new Map),this.atlasImage.set(t,new e.q({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.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}get imageRasterizer(){return this._imageRasterizer||(this._imageRasterizer=new e.x),this._imageRasterizer}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){this._validate(e,i)&&this.images.get(t).set(e.toString(),i)}_validate(t,i){let n=!0;return this._validateStretch(i.stretchX,i.data&&i.data.width)||(this.fire(new e.y(new Error(`Image "${t.name}" has invalid "stretchX" value`))),n=!1),this._validateStretch(i.stretchY,i.data&&i.data.height)||(this.fire(new e.y(new Error(`Image "${t.name}" has invalid "stretchY" value`))),n=!1),this._validateContent(i.content,i)||(this.fire(new e.y(new Error(`Image "${t.name}" has invalid "content" value`))),n=!1),n}_validateStretch(e,t){if(!e)return!0;let i=0;for(const n of e){if(n[0]e.I.from(t))}getImages(e,t,i){const n=[],r=[],o=this.imageProviders.get(t);for(const i of e){if(!i.iconsetId){n.push(i);continue}const e=o.get(i.iconsetId);e&&(this.getImage(i,t)?r.push(i):e.addPendingRequest(i))}if(0===n.length)return void this._notify(r,t,i);let s=!0;const a=!!this.loaded.get(t),l=this.images.get(t);if(!a)for(const e of n)l.has(e.toString())||(s=!1);a||s?this._notify(n,t,i):this.requestors.push({ids:n,scope:t,callback:i})}rasterizeImages(e,t){const i=new Map,{tasks:n,scope:r}=e;for(const[e,t]of n.entries()){const n=this.getImage(t.id,r);n&&i.set(e,{image:n,imageVariant:t})}this._rasterizeImages(r,i,t)}_rasterizeImages(t,i,n){if(e.r())this.imageRasterizerDispatcher.getActor().send("rasterizeImagesWorker",{tasks:i,scope:t},n);else{const e=new Map;for(const[n,{image:r,imageVariant:o}]of i.entries())e.set(n,this.imageRasterizer.rasterize(o,r,t,0));n(void 0,e)}}getUpdatedImages(e){return this.updatedImages.get(e)||new Set}_notify(t,i,n){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.z("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 n={data:t.usvg?null:t.data.clone(),pixelRatio:t.pixelRatio,sdf:t.sdf,usvg:t.usvg,version:t.version,stretchX:t.stretchX,stretchY:t.stretchY,content:t.content,hasRenderCallback:Boolean(t.userImage&&t.userImage.render)};t.usvg&&Object.assign(n,{width:t.icon.usvg_tree.width,height:t.icon.usvg_tree.height}),o.set(e.I.toString(i),n)}n(null,o)}getPixelSize(e){const{width:t,height:i}=this.atlasImage.get(e);return{width:t,height:i}}getPattern(t,i,n){const r=t.toString(),o=this.patterns.get(i),s=o.get(r),a=this.getImage(t,i);if(!a)return null;if(s){if(s.position.version===a.version)return s.position;s.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 s=new e.A(t).scaleSelf(e.o.devicePixelRatio),l=new Map([[s.toString(),{image:a,imageVariant:s}]]);return this._rasterizeImages(i,l,(e,t)=>this.storePatternImage(s,i,a,n,t)),null}this.storePattern(t,i,a)}return this._updatePatternAtlas(i,n),o.get(r).position}getPatternInFlightId(t,i){return e.B(t,i)}hasPatternsInFlight(){return 0!==this.patternsInFlight.size}storePatternImage(e,t,i,n,r){const o=e.toString(),s=r?r.get(o):void 0;s&&(i.data=s,this.storePattern(e.id,t,i),this._updatePatternAtlas(t,n),this.patternsInFlight.delete(this.getPatternInFlightId(e.id.toString(),t)))}storePattern(t,i,n){const r={w:n.data.width+2*e.C,h:n.data.height+2*e.C,x:0,y:0},o=new e.F(r,n,e.C);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 n=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),n.RGBA8),this.atlasTexture.set(i,r)),r.bind(n.LINEAR,n.CLAMP_TO_EDGE)}_updatePatternAtlas(t,i){const n=this.patterns.get(t),r=Array.from(n.values()).map(({bin:e})=>e),{w:o,h:s}=e.G(r),a=this.atlasImage.get(t);a.resize({width:o||1,height:s||1});const l=this.images.get(t);for(const[t,{bin:r,position:o}]of n.entries()){let n=o.padding;const s=r.x+n,c=r.y+n,u=l.get(t).data,h=u.width,d=u.height;n=n>1?n-1:n,e.q.copy(u,a,{x:0,y:0},{x:s,y:c},{width:h,height:d},i),e.q.copy(u,a,{x:0,y:d-n},{x:s,y:c-n},{width:h,height:n},i),e.q.copy(u,a,{x:0,y:0},{x:s,y:c+d},{width:h,height:n},i),e.q.copy(u,a,{x:h-n,y:0},{x:s-n,y:c},{width:n,height:d},i),e.q.copy(u,a,{x:0,y:0},{x:s+h,y:c},{width:n,height:d},i),e.q.copy(u,a,{x:h-n,y:d-n},{x:s-n,y:c-n},{width:n,height:n},i),e.q.copy(u,a,{x:0,y:d-n},{x:s+h,y:c-n},{width:n,height:n},i),e.q.copy(u,a,{x:0,y:0},{x:s+h,y:c+d},{width:n,height:n},i),e.q.copy(u,a,{x:h-n,y:0},{x:s-n,y:c+d},{width:n,height:n},i)}this.dirty=!0}beginFrame(){for(const e of this.images.keys())this.callbackDispatchedThisFrame.set(e,new Set)}dispatchRenderCallbacks(e,t){const i=this.images.get(t);for(const n of e){if(this.callbackDispatchedThisFrame.get(t).has(n.toString()))continue;this.callbackDispatchedThisFrame.get(t).add(n.toString());const e=i.get(n.toString());Q(e)&&this.updateImage(n,t,e)}}destroy(){this.imageRasterizerDispatcher&&this.imageRasterizerDispatcher.remove()}}function Z(t){const i=t.value,n=t.valueSpec,r=t.style,o=t.styleSpec,s=t.key,a=t.arrayElementValidator||me;if(!Array.isArray(i))return[new e.V(s,i,`array expected, ${e.K(i)} found`)];if(n.length&&i.length!==n.length)return[new e.V(s,i,`array length ${n.length} expected, length ${i.length} found`)];if(n["min-length"]&&i.lengtho)return[new e.V(i,n,`${n} is greater than the maximum value ${o}`)]}return[]}function q(t){const i=t.key,n=t.value;if(!e.H(n))return[new e.V(i,n,`object expected, ${e.K(n)} found`)];const r=t.valueSpec,o=e.J(n.type);let s,a,l,c={};const u="categorical"!==o&&void 0===n.property,h=!u,d=function(t){const i=t.stops;return Array.isArray(i)&&Array.isArray(i[0])&&e.H(i[0][0])}(n),p=ge({key:t.key,value:t.value,valueSpec:t.styleSpec.function,style:t.style,styleSpec:t.styleSpec,objectElementValidators:{stops:function(t){if("identity"===o)return[new e.V(t.key,t.value,'identity function may not have a "stops" property')];let i=[];const n=t.value;return i=i.concat(Z({key:t.key,value:n,valueSpec:t.valueSpec,style:t.style,styleSpec:t.styleSpec,arrayElementValidator:f})),Array.isArray(n)&&0===n.length&&i.push(new e.V(t.key,n,"array must have at least one stop")),i},default:function(e){return me({key:e.key,value:e.value,valueSpec:r,style:e.style,styleSpec:e.styleSpec})}}});return"identity"===o&&u&&p.push(new e.V(t.key,t.value,'missing required property "property"')),"identity"===o||n.stops||p.push(new e.V(t.key,t.value,'missing required property "stops"')),"exponential"===o&&r.expression&&!e.M(r)&&p.push(new e.V(t.key,t.value,"exponential functions not supported")),t.styleSpec.$version>=8&&(h&&!e.N(r)?p.push(new e.V(t.key,t.value,"property functions not supported")):u&&!e.O(r)&&p.push(new e.V(t.key,t.value,"zoom functions not supported"))),"categorical"!==o&&!d||void 0!==n.property||p.push(new e.V(t.key,t.value,'"property" property is required')),p;function f(t){let i=[];const n=t.value,o=t.key;if(!Array.isArray(n))return[new e.V(o,n,`array expected, ${e.K(n)} found`)];if(2!==n.length)return[new e.V(o,n,`array length 2 expected, length ${n.length} found`)];if(d){if(!e.H(n[0]))return[new e.V(o,n,`object expected, ${e.K(n[0])} found`)];const r=n[0];if(void 0===r.zoom)return[new e.V(o,n,"object stop key must have zoom")];if(void 0===r.value)return[new e.V(o,n,"object stop key must have value")];const s=e.J(r.zoom);if("number"!=typeof s)return[new e.V(o,r.zoom,"stop zoom values must be numbers")];if(l&&l>s)return[new e.V(o,r.zoom,"stop zoom values must appear in ascending order")];s!==l&&(l=s,a=void 0,c={}),i=i.concat(ge({key:`${o}[0]`,value:n[0],valueSpec:{zoom:{}},style:t.style,styleSpec:t.styleSpec,objectElementValidators:{zoom:W,value:m}}))}else i=i.concat(m({key:`${o}[0]`,value:n[0],style:t.style,styleSpec:t.styleSpec},n));return e.Q(e.S(n[1]))?i.concat([new e.V(`${o}[1]`,n[1],"expressions are not allowed in function stops.")]):i.concat(me({key:`${o}[1]`,value:n[1],valueSpec:r,style:t.style,styleSpec:t.styleSpec}))}function m(t,i){const n=e.K(t.value),l=e.J(t.value),u=null!==t.value?t.value:i;if(s){if(n!==s)return[new e.V(t.key,u,`${n} stop domain type must match previous stop domain type ${s}`)]}else s=n;if("number"!==n&&"string"!==n&&"boolean"!==n&&"number"!=typeof l&&"string"!=typeof l&&"boolean"!=typeof l)return[new e.V(t.key,u,"stop domain value must be a number, string, or boolean")];if("number"!==n&&"categorical"!==o){let i=`number expected, ${n} found`;return e.N(r)&&void 0===o&&(i+='\nIf you intended to use a categorical function, specify `"type": "categorical"`.'),[new e.V(t.key,u,i)]}return"categorical"!==o||"number"!==n||"number"==typeof l&&isFinite(l)&&Math.floor(l)===l?"categorical"!==o&&"number"===n&&"number"==typeof l&&"number"==typeof a&&void 0!==a&&lnew e.V(`${t.key}${i.key}`,t.value,i.message));const n=i.value.expression||i.value._styleExpression.expression;if("property"===t.expressionContext&&"text-font"===t.propertyKey&&!n.outputDefined())return[new e.V(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.Z(n))return[new e.V(t.key,t.value,'"feature-state" data expressions are not supported with layout properties.')];if("filter"===t.expressionContext)return X(n,t);if("appearance"===t.expressionContext)return J(n,t);if(t.expressionContext&&0===t.expressionContext.indexOf("cluster")){if(!e.X(n,["zoom","feature-state"]))return[new e.V(t.key,t.value,'"zoom" and "feature-state" expressions are not supported with cluster properties.')];if("cluster-initial"===t.expressionContext&&!e.Y(n))return[new e.V(t.key,t.value,"Feature data expressions are not supported with initial expression part of cluster properties.")]}return[]}function X(t,i){const n=new Set(["zoom","feature-state","pitch","distance-from-center"]);if(i.valueSpec&&i.valueSpec.expression)for(const e of i.valueSpec.expression.parameters)n.delete(e);if(0===n.size)return[];const r=[];return t instanceof e._&&n.has(t.name)?[new e.V(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(...X(e,i))}),r)}function J(t,i){const n=new Set;if(i.valueSpec&&i.valueSpec.expression)for(const e of i.valueSpec.expression.parameters)n.add(e);if(0===n.size)return[];const r=[];return t instanceof e._&&!n.has(t.name)?[new e.V(i.key,i.value,`["${t.name}"] is not an allowed parameter`)]:(t.eachChild(e=>{r.push(...J(e,i))}),r)}function Y(t){const i=t.key,n=t.value,r=t.valueSpec,o=[];return Array.isArray(r.values)?-1===r.values.indexOf(e.J(n))&&o.push(new e.V(i,n,`expected one of [${r.values.join(", ")}], ${JSON.stringify(n)} found`)):-1===Object.keys(r.values).indexOf(e.J(n))&&o.push(new e.V(i,n,`expected one of [${Object.keys(r.values).join(", ")}], ${JSON.stringify(n)} found`)),o}function ee(t){return e.a2(e.S(t.value))?K(Object.assign({},t,{expressionContext:"filter",valueSpec:t.styleSpec[`filter_${t.layerType||"fill"}`]})):te(t)}function te(t){const i=t.value,n=t.key;if(!Array.isArray(i))return[new e.V(n,i,`array expected, ${e.K(i)} found`)];if(i.length<1)return[new e.V(n,i,"filter array must have at least 1 element")];const r=t.styleSpec;let o=Y({key:`${n}[0]`,value:i[0],valueSpec:r.filter_operator});switch(e.J(i[0])){case"<":case"<=":case">":case">=":i.length>=2&&"$type"===e.J(i[1])&&o.push(new e.V(n,i,`"$type" cannot be use with operator "${i[0]}"`));case"==":case"!=":3!==i.length&&o.push(new e.V(n,i,`filter array for operator "${i[0]}" must have 3 elements`));case"in":case"!in":i.length>=2&&(e.a0(i[1])||o.push(new e.V(`${n}[1]`,i[1],`string expected, ${e.K(i[1])} found`)));for(let t=2;t{t in n&&i.push(new e.V(r,n[t],`"${t}" is prohibited for ref layers`))}),o.layers.forEach(i=>{e.J(i.id)===l&&(t=i)}),t?t.ref?i.push(new e.V(r,n.ref,"ref cannot reference another ref layer")):a=e.J(t.type):"string"==typeof l&&i.push(new e.V(r,n.ref,`ref layer "${l}" not found`))}else if("background"!==a&&"sky"!==a&&"slot"!==a)if(n.source)if(e.a0(n.source)){const t=o.sources&&o.sources[n.source],s=t&&e.J(t.type);t?"vector"===s&&"raster"===a?i.push(new e.V(r,n.source,`layer "${n.id}" requires a raster source`)):"raster"===s&&"raster"!==a?i.push(new e.V(r,n.source,`layer "${n.id}" requires a vector source`)):"vector"!==s||n["source-layer"]?"raster-dem"===s&&"hillshade"!==a?i.push(new e.V(r,n.source,"raster-dem source can only be used with layer type 'hillshade'.")):"raster-array"!==s||["raster","raster-particle"].includes(a)?"line"===a&&n.paint&&(n.paint["line-gradient"]||n.paint["line-trim-offset"])&&"geojson"===s&&!t.lineMetrics?i.push(new e.V(r,n,`layer "${n.id}" specifies a line-gradient, which requires the GeoJSON source to have \`lineMetrics\` enabled.`)):"raster-particle"===a&&"raster-array"!==s&&i.push(new e.V(r,n.source,`layer "${n.id}" requires a 'raster-array' source.`)):i.push(new e.V(r,n.source,"raster-array source can only be used with layer type 'raster'.")):i.push(new e.V(r,n,`layer "${n.id}" must specify a "source-layer"`)):i.push(new e.V(r,n.source,`source "${n.source}" not found`))}else i.push(new e.V(`${r}.source`,n.source,'"source" must be a string'));else i.push(new e.V(r,n,'missing required property "source"'));return i=i.concat(ge({key:r,value:n,valueSpec:s.layer,style:t.style,styleSpec:t.styleSpec,objectElementValidators:{"*":()=>[],type:()=>me({key:`${r}.type`,value:n.type,valueSpec:s.layer.type,style:t.style,styleSpec:t.styleSpec,object:n,objectKey:"type"}),filter:e=>ee(Object.assign({layerType:a},e)),layout:e=>ge({layer:n,key:e.key,value:e.value,valueSpec:{},style:e.style,styleSpec:e.styleSpec,objectElementValidators:{"*":e=>re(Object.assign({layerType:a},e))}}),paint:e=>ge({layer:n,key:e.key,value:e.value,valueSpec:{},style:e.style,styleSpec:e.styleSpec,objectElementValidators:{"*":e=>ne(Object.assign({layerType:a,layer:n},e))}}),appearances(t){const i=Z({key:t.key,value:t.value,valueSpec:t.valueSpec,style:t.style,styleSpec:t.styleSpec,arrayElementValidator:t=>function(t){const{key:i,layer:n,layerType:r}=t,o=e.J(t.value),s=e.J(o.name),a=e.J(o.condition),l=ge({key:i,value:o,valueSpec:t.styleSpec.appearance,style:t.style,styleSpec:t.styleSpec,objectElementValidators:{condition:t=>function(t){const i=[];return i.push(...K({key:t.key,value:t.object.condition,valueSpec:e.a6.appearance.condition,expressionContext:"appearance"})),i}(Object.assign({layer:n,layerType:r},t)),properties:t=>function(t){const i=[],{styleSpec:n,layer:r,layerType:o}=t,s=n[`paint_${o}`],a=n[`layout_${o}`],l=t.object[t.objectKey];for(const n in l){const c=n in s?"paint":n in a?"layout":void 0;if(!c){i.push(new e.V(t.key,n,`unknown property "${n}" for layer type "${o}"`));continue}const u=Object.assign({},t,{key:`${t.key}.${n}`,object:l,objectKey:n,layer:r,layerType:o,value:l[n],valueSpec:"paint"===c?s[n]:a[n]});i.push(...ie(u,c))}return i}(Object.assign({layer:n,layerType:r},t))}});return"hidden"!==s&&void 0===a&&l.push(new e.V(t.key,"name",'Appearance with name different than "hidden" must have a condition')),l}(Object.assign({layerType:a,layer:n},t))}),r=Array.isArray(t.value)?t.value:[],o=new Set;return r.forEach((r,s)=>{const a=e.J(r.name);if(a)if(o.has(a)){const r=e.J(n.id);i.push(new e.V(t.key,a,`Duplicated appearance name "${a}" for layer "${r}"`))}else o.add(a)}),i}}})),i}function se({key:t,value:i}){return e.a0(i)?[]:[new e.V(t,i,`string expected, ${e.K(i)} found`)]}const ae={promoteId:function t({key:i,value:n}){if(e.a0(n))return se({key:i,value:n});if(Array.isArray(n)){const t=[],r=e.S(n),o=e.U(r);return"error"===o.result&&o.value.forEach(n=>{t.push(new e.V(`${i}${n.key}`,null,`${n.message}`))}),e.X(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 e.V(`${i}`,null,"promoteId expression should be only feature dependent")),t}if(!e.H(n))return[new e.V(i,n,`string, expression or object expected, "${e.K(n)}" found`)];const r=[];for(const e in n)r.push(...t({key:`${i}.${e}`,value:n[e]}));return r}};function le(t){const i=t.value,n=t.key,r=t.styleSpec,o=t.style;if(!e.H(i))return[new e.V(n,i,`object expected, ${e.K(i)} found`)];if(!("type"in i))return[new e.V(n,i,'"type" is required')];const s=e.J(i.type);let a=[];switch(["vector","raster","raster-dem","raster-array"].includes(s)&&("url"in i||"tiles"in i||a.push(new e.a3(n,i,'Either "url" or "tiles" is required.'))),s){case"vector":case"raster":case"raster-dem":case"raster-array":return a=a.concat(ge({key:n,value:i,valueSpec:r[`source_${s.replace("-","_")}`],style:t.style,styleSpec:r,objectElementValidators:ae})),a;case"geojson":if(a=ge({key:n,value:i,valueSpec:r.source_geojson,style:o,styleSpec:r,objectElementValidators:ae}),"cluster"in i&&"clusterProperties"in i){if(!e.H(i.clusterProperties))return[new e.V(`${n}.clusterProperties`,i,`object expected, ${e.K(i)} found`)];for(const t in i.clusterProperties){const r=i.clusterProperties[t];if(!Array.isArray(r))return[new e.V(`${n}.clusterProperties.${t}`,r,"array expected")];const[o,s]=r,l="string"==typeof o?[o,["accumulated"],["get",t]]:o;a.push(...K({key:`${n}.${t}.map`,value:s,expressionContext:"cluster-map"})),a.push(...K({key:`${n}.${t}.reduce`,value:l,expressionContext:"cluster-reduce"}))}}return a;case"video":return ge({key:n,value:i,valueSpec:r.source_video,style:o,styleSpec:r});case"image":return ge({key:n,value:i,valueSpec:r.source_image,style:o,styleSpec:r});case"canvas":return[new e.V(n,null,"Please use runtime APIs to add canvas sources, rather than including them in stylesheets.","source.canvas")];default:return Y({key:`${n}.type`,value:i.type,valueSpec:{values:ce(r)}})}}function ce(e){return e.source.reduce((t,i)=>{const n=e[i];return"enum"===n.type.type&&(t=t.concat(Object.keys(n.type.values||{}))),t},[])}function ue(t){const i=t.value,n=t.styleSpec,r=n.light,o=t.style;if(void 0===i)return[];if(!e.H(i))return[new e.V("light",i,`object expected, ${e.K(i)} found`)];let s=[];for(const t in i){const a=t.match(/^(.*)-transition$/),l=t.match(/^(.*)-use-theme$/);s=s.concat(l&&r[l[1]]?me({key:t,value:i[t],valueSpec:{type:"string"},style:o,styleSpec:n}):a&&r[a[1]]&&r[a[1]].transition?me({key:t,value:i[t],valueSpec:n.transition,style:o,styleSpec:n}):r[t]?me({key:t,value:i[t],valueSpec:r[t],style:o,styleSpec:n}):[new e.V(t,i[t],`unknown property "${t}"`)])}return s}function he(t){const i=t.value;if(!i)return[];const n=t.key;if(!e.H(i))return[new e.V(n,i,`object expected, ${e.K(i)} found`)];let r=[];const o=t.styleSpec,s=o["light-3d"],a=t.style,l=t.style.lights;for(const t of["type","id"])if(!(t in i))return r=r.concat([new e.V(n,i,`missing property "${t}"`)]),r;if(!e.a0(i.type))return r=r.concat([new e.V(`${n}.type`,i.type,"string expected")]),r;if(l)for(let o=0;o[],array:Z,boolean:function(t){const i=t.value,n=t.key;return e.$(i)?[]:[new e.V(n,i,`boolean expected, ${e.K(i)} found`)]},number:W,color:function({key:t,value:i}){return e.a0(i)?null===e.a1.parseCSSColor(i)?[new e.V(t,i,`color expected, "${i}" found`)]:[]:[new e.V(t,i,`color expected, ${e.K(i)} found`)]},enum:Y,filter:ee,function:q,layer:oe,object:ge,source:le,model:e.a7,light:ue,"light-3d":he,terrain:de,fog:pe,string:se,formatted:function(e){return 0===se(e).length?[]:K(e)},resolvedImage:function(e){return 0===se(e).length?[]:K(e)},projection:function(t){const i=t.value,n=t.styleSpec,r=n.projection,o=t.style;if(e.H(i)){let e=[];for(const t in i)e=e.concat(me({key:t,value:i[t],valueSpec:r[t],style:o,styleSpec:n}));return e}return e.a0(i)?[]:[new e.V("projection",i,`object or string expected, ${e.K(i)} found`)]},import:function(t){const i=t.key,{value:n,styleSpec:r}=t;if(!e.H(n))return[new e.V(i,n,"import must be an object")];const{data:o,...s}=n;Object.defineProperty(s,"__line__",{value:n.__line__,enumerable:!1});let a=ge(Object.assign({},t,{value:s,valueSpec:r.import}));return""===e.J(s.id)&&a.push(new e.V(`${t.key}.id`,s,"import id can't be an empty string")),o&&(a=a.concat(Ae(o,r,{key:`${t.key}.data`}))),a},iconset:function(t){const i=t.value,n=t.key,r=t.styleSpec,o=t.style;if(!e.H(i))return[new e.V(n,i,"object expected")];if(!i.type)return[new e.V(n,i,'"type" is required')];const s=e.J(i.type);let a=[];if(a=a.concat(ge({key:n,value:i,valueSpec:r[`iconset_${s}`],style:o,styleSpec:r})),function(e,t){return!("source"!==e||!t.source)}(s,i)){const t=o.sources&&o.sources[i.source],r=t&&e.J(t.type);t?"raster-array"!==r&&a.push(new e.V(n,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 e.V(n,i.source,`source "${i.source}" not found`))}return a}};function me(t,i=!1){const n=t.value,r=t.valueSpec,o=t.styleSpec;if(r.expression){if(e.a4(e.J(n)))return q(t);if(e.Q(e.S(n)))return K(t)}if(r.type&&fe[r.type]){const e=fe[r.type](t);return!0===i&&e.length>0&&Array.isArray(t.value)?K(t):e}return ge(Object.assign({},t,{valueSpec:r.type?o[r.type]:r}))}function ge(t){const i=t.key,n=t.value,r=t.valueSpec||{},o=t.objectElementValidators||{},s=t.style,a=t.styleSpec;if(!e.H(n))return[new e.V(i,n,`object expected, ${e.K(n)} found`)];let l=[];for(const t in n){const c=t.split(".")[0];let u;o[c]?u=o[c]:r[c]?u=me:o["*"]?u=o["*"]:r["*"]&&(u=me),u?l=l.concat(u({key:(i?`${i}.`:i)+t,value:n[t],valueSpec:r[c]||r["*"],style:s,styleSpec:a,object:n,objectKey:t},n)):l.push(new e.a3(i,n[t],`unknown property "${t}"`))}for(const t in r){if(o[t])continue;const s=r[t];s.required&&void 0===s.default&&void 0===n[t]&&l.push(new e.V(i,n,`missing required property "${t}"`))}return l}function _e({key:t,value:i}){const n=se({key:t,value:i});if(n.length)return n;const r=i;return-1===r.indexOf("{fontstack}")&&n.push(new e.V(t,i,'"glyphs" url must include a "{fontstack}" token')),-1===r.indexOf("{range}")&&n.push(new e.V(t,i,'"glyphs" url must include a "{range}" token')),n}function Ae(t,i=e.a6,n={}){return ge({key:n.key||"",value:t,valueSpec:Object.assign(i.$root,{"*":{type:"*"}}),styleSpec:i,style:t,objectElementValidators:{glyphs:_e}})}function ye(t,i=e.a6){return Re(Ae(t,i))}const ve=e=>Re(le(e)),xe=e=>Re(ue(e)),be=e=>Re(he(e)),we=e=>Re(de(e)),Te=e=>Re(pe(e)),Ee=t=>Re(function(t){const i=t.value,n=t.style,r=t.styleSpec,o=r.snow;if(void 0===i)return[];if(!e.H(i))return[new e.V("snow",i,`object expected, ${e.K(i)} found`)];let s=[];for(const t in i){const a=t.match(/^(.*)-transition$/);s=s.concat(a&&o[a[1]]&&o[a[1]].transition?me({key:t,value:i[t],valueSpec:r.transition,style:n,styleSpec:r}):o[t]?me({key:t,value:i[t],valueSpec:o[t],style:n,styleSpec:r}):[new e.a3(t,i[t],`unknown property "${t}"`)])}return s}(t)),Ce=t=>Re(function(t){const i=t.value,n=t.style,r=t.styleSpec,o=r.rain;if(void 0===i)return[];if(!e.H(i))return[new e.V("rain",i,`object expected, ${e.K(i)} found`)];let s=[];for(const t in i){const a=t.match(/^(.*)-transition$/);s=s.concat(a&&o[a[1]]&&o[a[1]].transition?me({key:t,value:i[t],valueSpec:r.transition,style:n,styleSpec:r}):o[t]?me({key:t,value:i[t],valueSpec:o[t],style:n,styleSpec:r}):[new e.a3(t,i[t],`unknown property "${t}"`)])}return s}(t)),Se=e=>Re(oe(e)),Be=e=>Re(ee(e)),Ie=e=>Re(ne(e)),Me=e=>Re(re(e)),Pe=t=>Re(e.a7(t));function Re(e){return e.slice().sort((e,t)=>e.line&&t.line?e.line-t.line:0)}function Le(t,i){let n=!1;if(i&&i.length)for(const r of i)r instanceof e.a3?e.w(r.message):(t.fire(new e.y(new Error(r.message))),n=!0);return n}const Fe=e.a6.light;let ke;class De extends e.E{constructor(t,i="flat"){super(),this._transitionable=new e.a8(ke||(ke=new e.a9({anchor:new e.aa(Fe.anchor),position:new e.ab(Fe.position),color:new e.aa(Fe.color),intensity:new e.aa(Fe.intensity)}))),this.setLight(t,i),this._transitioning=this._transitionable.untransitioned()}getLight(){return this._transitionable.serialize()}setLight(e,t,i={}){this._validate(xe,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,n){return(!n||!1!==n.validate)&&Le(this,t.call(ye,Object.assign({value:i,style:{glyphs:!0,sprite:!0},styleSpec:e.a6})))}}const Oe=e.a6.terrain;let ze=class extends e.E{constructor(t,i,n,r,o){super(),this.scope=n,this._transitionable=new e.a8(new e.a9({source:new e.aa(Oe.source),exaggeration:new e.aa(Oe.exaggeration)}),n,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.ac(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 n=-1,r=-1,o=1;for(const t of i.zoomStops)o=i.evaluate(new e.ac(t,{worldview:this.worldview})),o>.01?(n=t,r=-1):r=t;return o<.01&&n>0&&r>n?[n,r]:null}isZoomDependent(){const t=this._transitionable._values.exaggeration;return null!=t&&null!=t.value&&null!=t.value.expression&&t.value.expression instanceof e.ad}};const Ue=45,Ne=65,Ve=.05;function je(t,i,n,r){const o=e.ah(Ue,Ne,n),[s,a]=Ge(t,r);let l=1-Math.min(1,Math.exp((i-s)/(a-s)*-6));return l*=l*l,l=Math.min(1,1.00747*l),l*o*t.alpha}function Ge(e,t){const i=.5/Math.tan(.5*t);return[e.range[0]+i,e.range[1]+i]}function He(t,i,n,r,o){const s=e.af([],[i,n,r],o.mercatorFogMatrix);return je(t,e.ag(s),o.pitch,o._fov)}function Qe(t,i,n,r,o,s,a){const l=[[n,r,0],[o,r,0],[o,s,0],[n,s,0]];let c=Number.MAX_VALUE,u=-Number.MAX_VALUE;for(const t of l){const n=e.af([],t,i),r=e.ag(n);c=Math.min(c,r),u=Math.max(u,r)}return[je(t,c,a.pitch,a._fov),je(t,u,a.pitch,a._fov)]}const $e=e.a6.fog;class Ze extends e.E{constructor(t,i,n,r){super();const o=new e.a9({range:new e.aa($e.range),color:new e.aa($e.color),"color-use-theme":new e.aa({type:"string","property-type":"data-constant",default:"default"}),"high-color":new e.aa($e["high-color"]),"high-color-use-theme":new e.aa({type:"string","property-type":"data-constant",default:"default"}),"space-color":new e.aa($e["space-color"]),"space-color-use-theme":new e.aa({type:"string","property-type":"data-constant",default:"default"}),"horizon-blend":new e.aa($e["horizon-blend"]),"star-intensity":new e.aa($e["star-intensity"]),"vertical-range":new e.aa($e["vertical-range"])});this._transitionable=new e.a8(o,n,new Map(r)),this.set(t,r),this._transitioning=this._transitionable.untransitioned(),this._transform=i,this.properties=new e.ai(o),this.scope=n}get state(){const t=this._transform,i="globe"===t.projection.name,n=e.aj(t.zoom),r=this.properties.get("range"),o=[.5,3];return{range:i?[e.ak(o[0],r[0],n),e.ak(o[1],r[1],n)]:r,horizonBlend:this.properties.get("horizon-blend"),alpha:this.properties.get("color").a}}get(){return this._transitionable.serialize()}set(e,t,i={}){if(this._validate(Te,e,i))return;const n=Object.assign({},e);for(const e of Object.keys($e))void 0===n[e]&&(n[e]=$e[e].default);this._options=n,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.ah(Ue,Ne,t))*i.a}getOpacityAtLatLng(t,i){return this._transform.projection.supportsFog?function(t,i,n){const r=e.ae.fromLngLat(i),o=n.elevation?n.elevation.getAtPointOrZero(r):0;return He(t,r.x,r.y,o,n)}(this.state,t,i):0}getOpacityForTile(t){if(!this._transform.projection.supportsFog)return[1,1];const i=this._transform.calculateFogTileMatrix(t.toUnwrapped());return Qe(this.state,i,0,0,e.al,e.al,this._transform)}getOpacityForBounds(e,t,i,n,r){return this._transform.projection.supportsFog?Qe(this.state,e,t,i,n,r,this._transform):[1,1]}getFovAdjustedRange(e){return this._transform.projection.supportsFog?Ge(this.state,e):[0,1]}isVisibleOnFrustum(t){if(!this._transform.projection.supportsFog)return!1;const i=[4,5,6,7];for(const n of i){const i=t.points[n];let r;if(i[2]>=0)r=i;else{const o=t.points[n-4];r=e.am(o,i,o[2]/(o[2]-i[2]))}if(He(this.state,r[0],r[1],0,this._transform)>=Ve)return!0}return!1}updateConfig(e){this._transitionable.setTransitionOrValue(this._options,new Map(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,n){return(!n||!1!==n.validate)&&Le(this,t.call(ye,Object.assign({value:i,style:{glyphs:!0,sprite:!0},styleSpec:e.a6})))}}let We,qe,Ke,Xe,Je=class extends e.E{constructor(t,i,n,r){super();const o=We||(We=new e.a9({density:new e.aa(e.a6.snow.density),intensity:new e.aa(e.a6.snow.intensity),color:new e.aa(e.a6.snow.color),opacity:new e.aa(e.a6.snow.opacity),vignette:new e.aa(e.a6.snow.vignette),"vignette-color":new e.aa(e.a6.snow["vignette-color"]),"center-thinning":new e.aa(e.a6.snow["center-thinning"]),direction:new e.aa(e.a6.snow.direction),"flake-size":new e.aa(e.a6.snow["flake-size"])}));this._transitionable=new e.a8(o,n,new Map(r)),this.set(t,r),this._transitioning=this._transitionable.untransitioned(),this.properties=new e.ai(o),this.scope=n}get state(){const t=this.properties.get("opacity"),i=this.properties.get("color"),n=this.properties.get("direction"),r=e.an(n[0]),o=-Math.max(e.an(n[1]),.01),s=[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");return l.a=a,{density:this.properties.get("density"),intensity:this.properties.get("intensity"),color:new e.ao(i.r,i.g,i.b,i.a*t),direction:s,centerThinning:this.properties.get("center-thinning"),flakeSize:this.properties.get("flake-size"),vignetteColor:l}}get(){return this._transitionable.serialize()}set(t,i,n={}){if(this._validate(Ee,t,n))return;const r=Object.assign({},t),o=e.a6.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,new Map(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,n){return(!n||!1!==n.validate)&&Le(this,t.call(ye,Object.assign({value:i,style:{glyphs:!0,sprite:!0},styleSpec:e.a6})))}},Ye=class extends e.E{constructor(t,i,n,r){super();const o=qe||(qe=new e.a9({density:new e.aa(e.a6.rain.density),intensity:new e.aa(e.a6.rain.intensity),color:new e.aa(e.a6.rain.color),opacity:new e.aa(e.a6.rain.opacity),vignette:new e.aa(e.a6.rain.vignette),"vignette-color":new e.aa(e.a6.rain["vignette-color"]),"center-thinning":new e.aa(e.a6.rain["center-thinning"]),direction:new e.aa(e.a6.rain.direction),"droplet-size":new e.aa(e.a6.rain["droplet-size"]),"distortion-strength":new e.aa(e.a6.rain["distortion-strength"])}));this._transitionable=new e.a8(o,n,new Map(r)),this.set(t,r),this._transitioning=this._transitionable.untransitioned(),this.properties=new e.ai(o),this.scope=n}get state(){const t=this.properties.get("opacity"),i=this.properties.get("color"),n=this.properties.get("direction"),r=e.an(n[0]),o=-Math.max(e.an(n[1]),.01),s=[Math.cos(r)*Math.cos(o),Math.sin(r)*Math.cos(o),Math.sin(o)],a=this.properties.get("vignette-color");return a.a=this.properties.get("vignette"),{density:this.properties.get("density"),intensity:this.properties.get("intensity"),color:new e.ao(i.r,i.g,i.b,i.a*t),direction:s,centerThinning:this.properties.get("center-thinning"),dropletSize:this.properties.get("droplet-size"),distortionStrength:this.properties.get("distortion-strength"),vignetteColor:a}}get(){return this._transitionable.serialize()}set(t,i,n={}){if(this._validate(Ce,t,n))return;const r=Object.assign({},t),o=e.a6.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,new Map(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,n){return(!n||!1!==n.validate)&&Le(this,t.call(ye,Object.assign({value:i,style:{glyphs:!0,sprite:!0},styleSpec:e.a6})))}};class et extends e.E{constructor(t,i,n,r){super(),this.scope=n,this._options=t,this.properties=new e.ai(i),this._transitionable=new e.a8(i,n,new Map(r)),this._transitionable.setTransitionOrValue(t.properties),this._transitioning=this._transitionable.untransitioned()}updateConfig(e){this._transitionable.setTransitionOrValue(this._options.properties,new Map(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")}}class tt{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 n,r;if(t instanceof e.P||"number"==typeof t[0]){const o=e.P.convert(t);n=[o],r=i.isPointAboveHorizon(o)}else{const o=e.P.convert(t[0]),s=e.P.convert(t[1]),a=o.add(s)._div(2);n=[o,s],r=e.aq(o,s).every(e=>i.isPointAboveHorizon(e))&&i.isPointAboveHorizon(a)}return new tt(n,r,i)}isPointQuery(){return 1===this.screenBounds.length}bufferedScreenGeometry(t){return e.aq(this.screenBounds[0],1===this.screenBounds.length?this.screenBounds[0]:this.screenBounds[1],t)}bufferedCameraGeometry(t){const i=this.screenBounds[0],n=1===this.screenBounds.length?this.screenBounds[0].add(new e.P(1,1)):this.screenBounds[1],r=e.aq(i,n,0,!1);return this.cameraPoint.y>n.y&&(this.cameraPoint.x>i.x&&this.cameraPoint.x=n.x?r[2]=this.cameraPoint:this.cameraPoint.x<=i.x&&(r[3]=this.cameraPoint)),e.ar(r,t)}bufferedCameraGeometryGlobe(t){const i=this.screenBounds[0],n=1===this.screenBounds.length?this.screenBounds[0].add(new e.P(1,1)):this.screenBounds[1],r=e.aq(i,n,t),o=this.cameraPoint.clone();switch(3*((o.y>i.y)+(o.y>n.y))+((o.x>i.x)+(o.x>n.x))){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,n,r=0){const o=Math.max(t.queryPadding,t.evaluateQueryRenderedFeaturePadding())/i._pixelsPerMercatorPixel+1,s=n?this._bufferedCameraMercator(o,i):this._bufferedScreenMercator(o,i);let a=t.tileID.wrap+(s.unwrapped?r:0);const l=s.polygon.map(i=>e.as(t.tileTransform,i,a));if(!e.at(l,0,0,e.al,e.al))return;a=t.tileID.wrap+(this.screenGeometryMercator.unwrapped?r:0);const c=this.screenGeometryMercator.polygon.map(i=>e.au(t.tileTransform,i,a)),u=c.map(t=>new e.P(t[0],t[1])),h=i.getFreeCameraOptions().position||new e.ae(0,0,0),d=e.au(t.tileTransform,h,a),p=c.map(t=>{const i=e.av(t,t,d);return e.aw(i,i),new e.ax(d,i)}),f=e.ay(t,1,i.zoom)*i._pixelsPerMercatorPixel;return{queryGeometry:this,tilespaceGeometry:u,tilespaceRays:p,bufferedTilespaceGeometry:l,bufferedTilespaceBounds:(m=e.az(l),m.min.x=e.aA(m.min.x,0,e.al),m.min.y=e.aA(m.min.y,0,e.al),m.max.x=e.aA(m.max.x,0,e.al),m.max.y=e.aA(m.max.y,0,e.al),m),tile:t,tileID:t.tileID,pixelToTileUnitsFactor:f};var m}_bufferedScreenMercator(e,t){const i=rt(e);if(this._screenRaycastCache[i])return this._screenRaycastCache[i];{let n;return n="globe"===t.projection.name?this._projectAndResample(this.bufferedScreenGeometry(e),t):{polygon:this.bufferedScreenGeometry(e).map(e=>t.pointCoordinate3D(e)),unwrapped:!0},this._screenRaycastCache[i]=n,n}}_bufferedCameraMercator(e,t){const i=rt(e);if(this._cameraRaycastCache[i])return this._cameraRaycastCache[i];{let n;return n="globe"===t.projection.name?this._projectAndResample(this.bufferedCameraGeometryGlobe(e),t):{polygon:this.bufferedCameraGeometry(e).map(e=>t.pointCoordinate3D(e)),unwrapped:!0},this._cameraRaycastCache[i]=n,n}}_projectAndResample(t,i){const n=function(t,i){const n=e.aB([],i.pixelMatrix,i.globeMatrix),r=[0,-e.aD,0,1],o=[0,e.aD,0,1],s=[0,0,0,1];e.aC(r,r,n),e.aC(o,o,n),e.aC(s,s,n);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.aE(t,a)&&r[3]1?it(t.slice(0,d),i):[],m=dnew e.P(nt(t.x),t.y)),m=m.map(t=>new e.P(nt(t.x),t.y));const g=[...f];0===g.length&&g.push(m[m.length-1]);const _=e.ak(g[g.length-1].y,(0===m.length?f[0]:m[0]).y,p);let A;return A=c?[new e.P(0,_),new e.P(0,0),new e.P(1,0),new e.P(1,_)]:[new e.P(1,_),new e.P(1,1),new e.P(0,1),new e.P(0,_)],g.push(...A),0===m.length?g.push(f[0]):g.push(...m),{polygon:g.map(t=>new e.ae(t.x,t.y)),unwrapped:!1}}(t,i);if(n)return n;const r=function(t,i){let n=!1,r=-1/0,o=0;for(let e=0;er&&(r=t[e].x,o=e);for(let e=0;e.5&&(r.x{e.x-=1}),{polygon:t,unwrapped:n}}(it(t,i).map(t=>new e.P(nt(t.x),t.y)),i);return{polygon:r.polygon.map(t=>new e.ae(t.x,t.y)),unwrapped:r.unwrapped}}}function it(t,i){return e.aG(t,e=>{const t=i.pointCoordinate3D(e);e.x=t.x,e.y=t.y},1/256)}function nt(e){return e<0?1+e%1:e%1}function rt(e){return 100*e|0}function ot(t,i,n,r,o){const s=function(n,r){if(n)return o(n);if(r){if(t.url&&r.tiles&&t.tiles&&delete t.tiles,r.variants){if(!Array.isArray(r.variants))return o(new Error("variants must be an array"));for(const e of r.variants){if(null==e||"object"!=typeof e||e.constructor!==Object)return o(new Error("variant must be an object"));if(!Array.isArray(e.capabilities))return o(new Error("capabilities must be an array"));if(1===e.capabilities.length&&"meshopt"===e.capabilities[0]){r=Object.assign(r,e);break}}}const n=e.aH(Object.assign({},r,t),["tilejson","tiles","minzoom","maxzoom","attribution","mapbox_logo","bounds","extra_bounds","scheme","tileSize","encoding","vector_layers","raster_layers","worldview_options","worldview_default","worldview"]);n.tiles=i.canonicalizeTileset(n,t.url),o(null,n)}},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),s=r.every(e=>e===i);return o&&s?e:t in(e.language_options||{})||i in(e.worldview_options||{})?null:e.language_options&&e.worldview_options?e:null}(t.data,n,r);return a?e.o.frame(()=>s(null,a)):t.url?e.m(i.transformRequest(i.normalizeSourceURL(t.url,null,n,r),e.R.Source),s):e.o.frame(()=>{const{data:e,...i}=t;s(null,i)})}function st(t,i){const n=Math.pow(2,i.z),r=Math.floor(e.aF(t.getWest())*n),o=Math.floor(e.aJ(t.getNorth())*n),s=Math.ceil(e.aF(t.getEast())*n),a=Math.ceil(e.aJ(t.getSouth())*n);return i.x>=r&&i.x=o&&i.ythis.maxzoom||e.z{if(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}`),n&&console.warn(`Requested worldview strings must be a valid ISO alpha-2 code. Found: ${n}`),this.fire(new e.y(r));else if(o){if(Object.assign(this,o),this.hasWorldviews=!!o.worldview_options,o.worldview_default&&(this.worldviewDefault=o.worldview_default),o.vector_layers){this.vectorLayers=o.vector_layers,this.vectorLayerIds=[],this.localizableLayerIds=new Set;for(const e of o.vector_layers)this.vectorLayerIds.push(e.id),o.worldview&&o.worldview[e.source]&&this.localizableLayerIds.add(e.id)}this.tileBounds=at.fromTileJSON(o),P(o.tiles,this.map._requestManager._customAccessToken),this.fire(new e.z("data",{dataType:"source",sourceDataType:"metadata"})),this.fire(new e.z("data",{dataType:"source",sourceDataType:"content"}))}t&&t(r)})}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.B(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 Object.assign({},this._options)}loadTile(t,i){const n=t.tileID.canonical.url(this.tiles,this.scheme),r=this.map._requestManager.normalizeTileURL(n),o=this.map._requestManager.transformRequest(r,e.R.Tile),s=this.map.style?this.map.style.getLut(this.scope):null,a=s?{image:s.image.clone()}:null,l={request:o,data:void 0,uid:t.uid,tileID:t.tileID,tileZoom:t.tileZoom,zoom:t.tileID.overscaledZ,maxZoom:this.maxzoom,lut:a,tileSize:this.tileSize*t.tileID.overscaleFactor(),type:this.type,source:this.id,scope:this.scope,pixelRatio:e.o.devicePixelRatio,showCollisionBoxes:this.map.showCollisionBoxes,promoteId:this.promoteId,isSymbolTile:t.isSymbolTile,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.indoor?this.map.indoor.getIndoorTileOptions(this.id,this.scope):null};if(this.hasWorldviews&&e.h(n)&&(l.localizableLayerIds=this.localizableLayerIds),l.request.collectResourceTiming=this._collectResourceTiming,t.actor&&"expired"!==t.state)"loading"===t.state?t.reloadCallback=i:t.request=t.actor.send("reloadTile",l,c.bind(this));else if(t.actor=this._tileWorkers[r]=this._tileWorkers[r]||this.dispatcher.getActor(),this.dispatcher.ready)t.request=t.actor.send("loadTile",l,c.bind(this),void 0,!0);else{const i=e.aL.call({deduped:this._deduped},l,(i,n)=>{if(i||!n)c.call(this,i);else{const i=e.aM(n.responseHeaders);l.data={cacheControl:i.cacheControl,expires:i.expires,rawData:n.rawData.slice(0)},t.actor&&t.actor.send("loadTile",l,c.bind(this),void 0,!0)}},!0);t.request={cancel:i}}function c(n,r){return delete t.request,t.aborted?i(null):n&&404!==n.status?i(n):(r&&r.resourceTiming&&(t.resourceTiming=r.resourceTiming),this.map._refreshExpiredTiles&&r&&t.setExpiryData(r),t.loadVectorData(r,this.map.painter),e.aN(this.dispatcher),i(null,r),void(t.reloadCallback&&(this.loadTile(t,t.reloadCallback),t.reloadCallback=null)))}}abortTile(e){e.request&&(e.request.cancel(),delete e.request),e.actor&&e.actor.send("abortTile",{uid:e.uid,type:this.type,source:this.id,scope:this.scope})}unloadTile(e,t){e.actor&&e.actor.send("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 ct extends e.E{constructor(t,i,n,r){super(),this.id=t,this.dispatcher=n,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=Object.assign({type:"raster"},i),Object.assign(this,e.aH(i,["url","scheme","tileSize"]))}load(t){this._loaded=!1,this.fire(new e.z("dataloading",{dataType:"source"}));const i=this.map.getWorldview();this._tileJSONRequest=ot(this._options,this.map._requestManager,null,i,(i,n)=>{this._tileJSONRequest=null,this._loaded=!0,i?this.fire(new e.y(i)):n&&(Object.assign(this,n),n.raster_layers&&(this.rasterLayers=n.raster_layers,this.rasterLayerIds=this.rasterLayers.map(e=>e.id)),this.tileBounds=at.fromTileJSON(n),P(n.tiles),this.fire(new e.z("data",{dataType:"source",sourceDataType:"metadata"})),this.fire(new e.z("data",{dataType:"source",sourceDataType:"content"}))),t&&t(i)})}loaded(){return this._loaded}onAdd(e){this.map=e,this.load()}reload(){this.cancelTileJSONRequest();const t=e.B(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 Object.assign({},this._options)}hasTile(e){return!this.tileBounds||this.tileBounds.contains(e.canonical)}loadTile(t,i){const n=e.o.devicePixelRatio>=2,r=this.map._requestManager.normalizeTileURL(t.tileID.canonical.url(this.tiles,this.scheme),n,this.tileSize);t.request=e.n(this.map._requestManager.transformRequest(r,e.R.Tile),(n,r,o)=>{if(delete t.request,t.aborted)return t.state="unloaded",i(null);if(n)return t.state="errored",i(n);if(!r)return i(null);const s=e.aM(o);this.map._refreshExpiredTiles&&t.setExpiryData(s),t.setTexture(r,this.map.painter),t.state="loaded",e.aN(this.dispatcher),i(null)})}abortTile(e,t){e.request&&(e.request.cancel(),delete e.request),t&&t()}unloadTile(t,i){t.texture&&t.texture instanceof e.T?(t.destroy(!0),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 ut([t,i],n,r,{scaled:o=!0}={}){const{tileSize:s,buffer:a}=r,{x:l,y:c,z:u}=n;if(!isFinite(l)||!isFinite(c)||!isFinite(u))throw new Error("Invalid MRT header");const h=2**u,d=h*e.aF(t),p=h*e.aJ(i);return function([e,t],i,{scaled:n=!0}={}){if(!i)throw new Error("bandView is undefined");const{data:r,tileSize:o,buffer:s,offset:a,scale:l,dimension:c}=i;if(e<-s||e>o+s||t<-s||t>o+s)throw new Error(`Point (${e}, ${t}) out of bounds for tileSize=${o}, buffer=${s}`);const u=(t+s)*(o+2*s)+(e+s);if(4294967295===new Uint32Array(r.buffer)[u])return null;let h=[];h=n?[]:new i.data.constructor(c);for(let e=0;e{if(delete t.request,t.aborted)return t.state="unloaded",i(null);if(n){if("AbortError"===n.name)return;return t.state="errored",i(n)}if(this.map._refreshExpiredTiles&&r){const i=e.aM(o);t.setExpiryData(i)}if(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)};t.request=this.partial?t.fetchHeader(void 0,s.bind(this)):t.actor.send("loadTile",o,s.bind(this),void 0,!0)}abortTile(e){e.request&&(e.request.cancel(),delete e.request),e.actor&&e.actor.send("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(!0);for(const e of i.values())this.map.painter.saveTileTexture(e)}else e.destroy()}prepareTile(t,i,n,r){t._isHeaderLoaded&&("empty"!==t.state&&(t.state="reloading"),t.fetchBandForRender(i,n,r,(i,r)=>{if(i)return t.state="errored",this.fire(new e.y(i)),void this.triggerRepaint(t);r&&(t._isHeaderLoaded=!0,t.setTexturePerLayer(n,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,n=i&&i.bands&&i.bands;return n?n[0]:0}getTextureDescriptor(t,i,n){if(!t)return;const r=i.sourceLayer||this.rasterLayerIds&&this.rasterLayerIds[0];if(!r)return;let o=null;i instanceof e.aQ?o=i.paint.get("raster-array-band"):i instanceof e.aR&&(o=i.paint.get("raster-particle-array-band"));const s=o||this.getInitialBand(r);if(null==s)return;if(!t.textureDescriptorPerLayer.get(i.id))return void this.prepareTile(t,r,i.id,s);if(t.updateNeeded(i.id,s)&&!n)return;const a=t.textureDescriptorPerLayer.get(i.id);return Object.assign({},a,{texture:t.texturePerLayer.get(i.id)})}getImages(t,i){const n=new Map;for(const r of t)for(const t of i){const[i,o]=t.split("/"),s=r.getLayer(i);if(!s)continue;if(!s.hasBand(o)||!s.hasDataForBand(o))continue;const{bytes:a,tileSize:l,buffer:c}=s.getBandView(o),u=l+2*c,h={data:new e.q({width:u,height:u},a),pixelRatio:2,sdf:!1,usvg:!1,version:0};n.set(t,h)}return n}queryRasterArrayValueByBandId(t,i,n){const r=i._mrt;return new Promise(o=>{const s={},a=new Set;for(const[l,c]of Object.entries(r.layers)){if(n.layerName&&l!==n.layerName)continue;const u={};s[l]=u;for(const{bands:h}of c.dataIndex)for(const d of h)n.bands&&!n.bands.includes(d)||(a.add(e.B(l,d)),i.fetchBand(l,null,d,i=>{e.o.frame(()=>{u[d]=i?null:ut([t.lng,t.lat],r,c.getBandView(d)),a.delete(e.B(l,d)),0===a.size&&o(s)})},!1))}0===a.size&&o(s)})}_loadTileForQuery(t,i){if(this._loadTileLoaded[t.uid])return void i(null,t._mrt);if(this._loadTilePending[t.uid])return void this._loadTilePending[t.uid].push(i);this._loadTilePending[t.uid]=[i];const n=this.map._requestManager.normalizeTileURL(t.tileID.canonical.url(this.tiles,this.scheme),!1,this.tileSize),r=this.map._requestManager.transformRequest(n,e.R.Tile);t.actor.send("loadTile",{request:r,uid:t.uid,tileID:t.tileID,type:this.type,source:this.id,scope:this.scope,partial:!1},(i,n,r)=>{if(i)return this._loadTilePending[t.uid].forEach(e=>e(i,null)),void delete this._loadTilePending[t.uid];if(!n)return this._loadTilePending[t.uid].forEach(e=>e(null,null)),void delete this._loadTilePending[t.uid];if(this.map._refreshExpiredTiles&&n){const i=e.aM(r);t.setExpiryData(i)}t._mrt=n,t._isHeaderLoaded=!0,t.state="loaded",this._loadTilePending[t.uid].forEach(e=>e(null,n)),this._loadTileLoaded[t.uid]=!0,delete this._loadTilePending[t.uid]},void 0,!0)}queryRasterArrayValueByAllBands(e,t,i){return new Promise((n,r)=>{this._loadTileForQuery(t,(o,s)=>{o?r(o):n(s?this.queryRasterArrayValueByBandId(e,t,i):null)})})}queryRasterArrayValue(t,i){const n=e.aS.convert(t),r=this.findLoadedParent(n);return r&&r._mrt?i.bands||!this.partial?this.queryRasterArrayValueByBandId(n,r,i):this.queryRasterArrayValueByAllBands(n,r,i):Promise.resolve(null)}findLoadedParent(t){const i=e.ae.fromLngLat(t,this.map.transform.tileSize),n=this.maxzoom+1,r=1<0&&(l[new e.aP(t.overscaledZ,o,i.z,r,i.y-1).key]={backfilled:!1},l[new e.aP(t.overscaledZ,t.wrap,i.z,i.x,i.y-1).key]={backfilled:!1},l[new e.aP(t.overscaledZ,a,i.z,s,i.y-1).key]={backfilled:!1}),i.y+1{if(this._loaded=!0,this._pendingLoad=null,i)this.fire(new e.y(i));else{const i={dataType:"source",sourceDataType:this._metadataFired?"content":"metadata"};this._collectResourceTiming&&n&&n.resourceTiming&&n.resourceTiming[this.id]&&(i.resourceTiming=n.resourceTiming[this.id]),t&&(this._partialReload=!0),this.fire(new e.z("data",i)),this._partialReload=!1,this._metadataFired=!0}this._coalesce&&(this._updateWorkerData(t),this._coalesce=!1)})}loaded(){return this._loaded}reload(){const t=e.B(this.id,this.scope);this.map.style.clearSource(t),this._updateWorkerData()}loadTile(t,i){const n=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,s=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.o.devicePixelRatio,showCollisionBoxes:this.map.showCollisionBoxes,promoteId:this.promoteId,brightness:this.map.style&&this.map.style.getBrightness()||0,extraShadowCaster:t.isExtraShadowCaster,scaleFactor:this.map.getScaleFactor(),partial:s,worldview:this.map.getWorldview(),indoor:this.map.indoor?this.map.indoor.getIndoorTileOptions(this.id,this.scope):null};t.request=this.actor.send(n,a,(e,r)=>s&&!r?(t.state="loaded",i(null)):(delete t.request,t.destroy(),t.aborted?i(null):e?i(e):(t.loadVectorData(r,this.map.painter,"reloadTile"===n),i(null))),void 0,"loadTile"===n)}abortTile(e){e.request&&(e.request.cancel(),delete e.request),e.aborted=!0}unloadTile(e,t){this.actor.send("removeTile",{uid:e.uid,type:this.type,source:this.id,scope:this.scope}),e.destroy()}onRemove(e){this._pendingLoad&&this._pendingLoad.cancel()}serialize(){return Object.assign({},this._options,{type:this.type,data:this._data})}hasTransition(){return!1}},video:class extends e.aT{constructor(e,t,i,n){super(e,t,i,n),this.roundZoom=!0,this.type="video",this.options=t}load(){this._loaded=!1;const t=this.options;this.urls=[];for(const i of t.urls)this.urls.push(this.map._requestManager.transformRequest(i,e.R.Source).url);e.aU(this.urls,(t,i)=>{this._loaded=!0,t?this.fire(new e.y(t)):i&&(this.video=i,this.video.loop=!0,this.video.setAttribute("playsinline",""),this.video.addEventListener("playing",()=>{this.map.triggerRepaint()}),this.map&&this.video.play(),this._finishLoading())})}pause(){this.video&&this.video.pause()}play(){this.video&&this.video.play()}seek(t){if(this.video){const i=this.video.seekable;ti.end(0)?this.fire(new e.y(new e.V(`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.urls,coordinates:this.coordinates}}hasTransition(){return this.video&&!this.video.paused}},image:e.aT,model:e.aW,"batched-model":class extends e.E{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 t=e.B(this.id,this.scope);this.load(()=>this.map.style.clearSource(t))}cancelTileJSONRequest(){this._tileJSONRequest&&(this._tileJSONRequest.cancel(),this._tileJSONRequest=null)}load(t){this._loaded=!1,this.fire(new e.z("dataloading",{dataType:"source"}));const i=Array.isArray(this.map._language)?this.map._language.join():this.map._language,n=this.map.getWorldview();this._tileJSONRequest=ot(this._options,this.map._requestManager,i,n,(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}`),n&&2!==n.length&&console.warn(`Requested worldview strings must be a valid ISO alpha-2 code. Found: ${n}`),this.fire(new e.y(r))):o&&(Object.assign(this,o),o.bounds&&(this.tileBounds=new at(o.bounds,this.minzoom,this.maxzoom)),P(o.tiles,this.map._requestManager._customAccessToken),this.fire(new e.z("data",{dataType:"source",sourceDataType:"metadata"})),this.fire(new e.z("data",{dataType:"source",sourceDataType:"content"}))),t&&t(r)})}hasTransition(){return!1}hasTile(e){return!this.tileBounds||this.tileBounds.contains(e.canonical)}loaded(){return this._loaded}loadTile(t,i){const n=this.map._requestManager.normalizeTileURL(t.tileID.canonical.url(this.tiles,this.scheme)),r={request:this.map._requestManager.transformRequest(n,e.R.Tile),data:void 0,uid:t.uid,tileID:t.tileID,tileZoom:t.tileZoom,zoom:t.tileID.overscaledZ,tileSize:this.tileSize*t.tileID.overscaleFactor(),type:this.type,source:this.id,scope:this.scope,showCollisionBoxes:this.map.showCollisionBoxes,isSymbolTile:t.isSymbolTile,brightness:this.map.style&&this.map.style.getBrightness()||0,pixelRatio:e.o.devicePixelRatio,promoteId:this.promoteId};if(t.actor&&"expired"!==t.state)if("loading"===t.state)t.reloadCallback=i;else{if(t.buckets){const e=Object.values(t.buckets);for(const t of e)t.dirty=!0;return void(t.state="loaded")}t.request=t.actor.send("reloadTile",r,o.bind(this))}else t.actor=this.dispatcher.getActor(),t.request=t.actor.send("loadTile",r,o.bind(this),void 0,!0);function o(e,n){return t.aborted?i(null):e&&404!==e.status?i(e):(this.map._refreshExpiredTiles&&n&&t.setExpiryData(n),t.loadModelData(n,this.map.painter),t.state="loaded",void i(null))}}serialize(){return Object.assign({},this._options)}},canvas:class extends e.aT{constructor(t,i,n,r){super(t,i,n,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.y(new e.V(`sources.${t}`,null,'"coordinates" property must be an array of 4 longitude/latitude array pairs'))):this.fire(new e.y(new e.V(`sources.${t}`,null,'missing required property "coordinates"'))),i.animate&&"boolean"!=typeof i.animate&&this.fire(new e.y(new e.V(`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.y(new e.V(`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.y(new e.V(`sources.${t}`,null,'missing required property "canvas"'))),this.options=i,this.animate=void 0===i.animate||i.animate}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.y(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.aV||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,n,r){super(),this.id=t,this.type="custom",this._dataType="raster",this._dispatcher=n,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.y(new Error(`Missing implementation for ${this.id} custom source`))),this._implementation.loadTile||this.fire(new e.y(new Error(`Missing loadTile implementation for ${this.id} custom source`))),this._implementation.bounds&&(this.tileBounds=new at(this._implementation.bounds,this.minzoom,this.maxzoom)),i.update=this._update.bind(this),i.clearTiles=this._clearTiles.bind(this),i.coveringTiles=this._coveringTiles.bind(this),Object.assign(this,e.aH(i,["dataType","scheme","minzoom","maxzoom","tileSize","attribution","minTileCacheSize","maxTileCacheSize"]))}serialize(){return e.aH(this,["type","scheme","minzoom","maxzoom","tileSize","attribution"])}load(){this._loaded=!0,this.fire(new e.z("data",{dataType:"source",sourceDataType:"metadata"})),this.fire(new e.z("data",{dataType:"source",sourceDataType:"content"}))}loaded(){return this._loaded}onAdd(t){this.map=t,this._loaded=!1,this.fire(new e.z("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:n}=e.canonical;return this._implementation.hasTile({x:t,y:i,z:n})}return!this.tileBounds||this.tileBounds.contains(e.canonical)}loadTile(e,t){const{x:i,y:n,z:r}=e.tileID.canonical,o=new AbortController;e.request=Promise.resolve(this._implementation.loadTile({x:i,y:n,z:r},{signal:o.signal})).then(function(i){return delete e.request,e.aborted?(e.state="unloaded",t(null)):void 0===i?(e.state="errored",t(null)):null===i?(this.loadTileData(e,{width:this.tileSize,height:this.tileSize,data:null}),e.state="loaded",t(null)):function(e){return e instanceof ImageData||e instanceof HTMLCanvasElement||e instanceof ImageBitmap||e instanceof HTMLImageElement}(i)?(this.loadTileData(e,i),e.state="loaded",void t(null)):(e.state="errored",t(new Error(`Can't infer data type for ${this.id}, only raster data supported at the moment`)))}.bind(this)).catch(i=>{"AbortError"!==i.name&&(e.state="errored",t(i))}),e.request.cancel=()=>o.abort()}loadTileData(e,t){e.setTexture(t,this.map.painter)}unloadTile(t,i){if(t.texture&&t.texture instanceof e.T?(t.destroy(!0),t.texture&&t.texture instanceof e.T&&this.map.painter.saveTileTexture(t.texture)):t.destroy(),this._implementation.unloadTile){const{x:e,y:i,z:n}=t.tileID.canonical;this._implementation.unloadTile({x:e,y:i,z:n})}i&&i()}abortTile(e,t){e.request&&e.request.cancel&&(e.request.cancel(),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.B(this.id,this.scope);this.map.style.clearSource(t)}_update(){this.fire(new e.z("data",{dataType:"source",sourceDataType:"content"}))}}},pt=function(t,i,n,r){const o=new dt[i.type](t,i,n,r);if(o.id!==t)throw new Error(`Expected Source id to be ${t} instead of ${o.id}`);return e.aX(["load","abort","unload","serialize","prepare"],o),o};function ft(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 mt(e,t,i,n=""){if(e.uniqueFeatureID){const r=ft(e,t,n);if(i.has(r))return!0;i.add(r)}return!1}function gt(e,t,i,n,r=!1){const o=t.sourceCache.transform,s=t.sourceCache.tilesIn(e,t.has3DLayers,r);s.sort(yt);const a=[];for(const e of s){const s=e.tile.queryRenderedFeatures(t,e,i,n,o,r);Object.keys(s).length&&a.push({wrappedTileID:e.tile.tileID.wrapped().key,queryResults:s})}for(const i in t.layers){const r=t.layers[i];if(r.styleLayer){const i=r.styleLayer.queryRenderedFeatures(e,t.sourceCache,n);Object.keys(i).length&&a.push({wrappedTileID:0,queryResults:i})}}return 0===a.length?{}:function(e){const t={},i={};for(const n of e){const e=n.queryResults,r=n.wrappedTileID,o=i[r]=i[r]||{};for(const i in e){const n=e[i],r=o[i]=o[i]||{},s=t[i]=t[i]||[];for(const e of n)r[e.featureIndex]||(r[e.featureIndex]=!0,s.push(e))}}return t}(a)}function _t(e,t,i,n,r,o){const s={},a=n.queryRenderedSymbols(e),l=[];for(const e of Object.keys(a).map(Number))l.push(r[e]);l.sort(yt);for(const e of l){const n=e.featureIndex.lookupSymbolFeatures(a[e.bucketInstanceId],e.bucketIndex,e.sourceLayerIndex,t,i,o);for(const t in n){const i=s[t]=s[t]||[],r=n[t];r.sort((t,i)=>{const n=e.featureSortOrder;if(n){const e=n.indexOf(t.featureIndex);return n.indexOf(i.featureIndex)-e}return i.featureIndex-t.featureIndex});for(const e of r)i.push(e)}}return s}function At(e,t){const i=e.getRenderableIds().map(t=>e.getTileByID(t)),n=[],r={};for(let e=0;et.getLayer(e)).filter(Boolean);if(0!==e.length){n.layers=e,n.stateDependentLayerIds&&(n.stateDependentLayers=n.stateDependentLayerIds.map(t=>e.filter(e=>e.id===t)[0]));for(const t of e)i[t.fqid]=n}}return i}const xt=32,bt=33,wt=new Uint16Array(8184);for(let e=0;e<2046;e++){let t=e+2,i=0,n=0,r=0,o=0,s=0,a=0;for(1&t?r=o=s=xt:i=n=a=xt;(t>>=1)>1;){const e=i+r>>1,l=n+o>>1;1&t?(r=i,o=n,i=s,n=a):(i=r,n=o,r=s,o=a),s=e,a=l}const l=4*e;wt[l+0]=i,wt[l+1]=n,wt[l+2]=r,wt[l+3]=o}const Tt=new Uint16Array(2178),Et=new Uint8Array(1089),Ct=new Uint16Array(1089);function St(e){return 0===e?-.03125:32===e?.03125:0}const Bt={type:2,extent:e.al,loadGeometry:()=>[[new e.P(0,0),new e.P(e.al+1,0),new e.P(e.al+1,e.al+1),new e.P(0,e.al+1),new e.P(0,0)]]};class It{constructor(t,i,n,r,o,s){this.tileID=t,this.uid=e.b1(),this.uses=0,this.tileSize=i,this.tileZoom=n,this.buckets={},this.expirationTime=null,this.queryPadding=0,this.hasSymbolBuckets=!1,this.hasRTLText=!1,this.dependencies={},this.isRaster=o,r&&r.style&&(this._lastUpdatedBrightness=r.style.getBrightness()),this.expiredRequestCount=0,this.state="loading",r&&r.transform&&(this.projection=r.transform.projection),this.worldview=s,this._hasAppearances=null}registerFadeDuration(t){const i=t+this.timeAdded;ie)t=!1;else if(i)if(this.expirationTimee.appearances&&e.appearances.length>0))return!0;return!1}updateBuckets(t,i){if(!this.latestFeatureIndex)return;if(!t.style)return;const n=this.latestFeatureIndex.loadVTLayers(),r=t.style.listImages(),o=t.style.getBrightness();for(const s in this.buckets){if(!t.style.hasLayer(s))continue;const a=this.buckets[s],l=a.layers[0],c=l.sourceLayer||"_geojsonTileLayer",u=n[c],h=t.style.getLayerSourceCache(l);let d={};h&&(d=h._state.getState(c,void 0));const p=this.imageAtlas?Object.fromEntries(this.imageAtlas.patternPositions):{},f=Object.keys(d).length>0&&!i;if(a.hasAppearances=a.layers.some(e=>e.appearances&&e.appearances.length>0),(f&&0!==a.stateDependentLayers.length||i)&&a.update(d,u,r,p,f?a.stateDependentLayers:a.layers,i,o),f&&0!==a.stateDependentLayers.length||i||a.hasAppearances){const e={zoom:t.transform.zoom,pitch:t.transform.pitch,brightness:t.style.getBrightness()||0,worldview:t.worldview};a.updateAppearances(this.tileID.canonical,d,r,e)}(a instanceof e.b9||a instanceof e.ba)&&t._terrain&&t._terrain.enabled&&h&&a.uploadPending()&&t._terrain._clearRenderCacheForTile(h.id,this.tileID);const m=t&&t.style&&t.style.getOwnLayer(s);m&&(this.queryPadding=Math.max(this.queryPadding,m.queryRadius(a)))}}holdingForFade(){return void 0!==this.symbolFadeHoldUntil}symbolFadeFinished(){return!this.symbolFadeHoldUntil||this.symbolFadeHoldUntil=0;e--){const t=4*e,i=wt[t+0],n=wt[t+1],r=wt[t+2],o=wt[t+3],s=i+r>>1,a=n+o>>1,l=s+a-n,c=a+i-s,u=n*bt+i,h=o*bt+r,d=a*bt+s,p=Math.hypot((Tt[2*u+0]+Tt[2*h+0])/2-Tt[2*d+0],(Tt[2*u+1]+Tt[2*h+1])/2-Tt[2*d+1])>=16;Et[d]=Et[d]||(p?1:0),e<1022&&(Et[d]=Et[d]||Et[(n+c>>1)*bt+(i+l>>1)]||Et[(o+c>>1)*bt+(r+l>>1)])}const o=new e.a$,s=new e.b0;let a=0;function l(t,i){const n=i*bt+t;return 0===Ct[n]&&(o.emplaceBack(Tt[2*n+0],Tt[2*n+1],t*e.al/xt,i*e.al/xt),Ct[n]=++a),Ct[n]-1}function c(e,t,i,n,r,o){const a=e+i>>1,u=t+n>>1;if(Math.abs(e-r)+Math.abs(t-o)>1&&Et[u*bt+a])c(r,o,e,t,a,u),c(i,n,r,o,a,u);else{const a=l(e,t),c=l(i,n),u=l(r,o);s.emplaceBack(a,c,u)}}return c(0,0,xt,xt,xt,0),c(xt,xt,0,0,0,xt),{vertices:o,indices:s}}(this.tileID.canonical,i);r=t.vertices,o=t.indices}else{r=new e.a$,o=new e.b0;for(const{x:e,y:t}of n)r.emplaceBack(e,t,0,0);const t=e.bg(r.int16.subarray(0,4*r.length),void 0,4);for(let e=0;e0&&(l=e.bk(new Float64Array(16),i.globeMatrix)),this._makeGlobeTileDebugBorderBuffer(t,r,i,s,l,a),this._makeGlobeTileDebugTextBuffer(t,r,i,s,l,a)}_globePoint(t,i,n,r,o,s,a){let l=e.bl(t,i,n);if(s){const o=1<.5?d=-1:h<-.5&&(d=1);let p=(t/e.al+n.x)/o+d,f=(i/e.al+n.y)/o;p=(p-c)*r._pixelsPerMercatorPixel+c,f=(f-u)*r._pixelsPerMercatorPixel+u;const m=[p*r.worldSize,f*r.worldSize,0];e.af(m,m,s),l=e.bm(l,m,a)}return e.af(l,l,o)}_makeGlobeTileDebugBorderBuffer(t,i,n,r,o,s){const a=new e.bc,l=new e.bd,c=new e.bn,u=(e,t,u,h,d)=>{const p=(u-e)/(d-1),f=(h-t)/(d-1),m=a.length;for(let u=0;uh*e+t;for(let e=0;e{if(e)i(e);else try{const e=n.getHeaderLength(r);if(e>t)return void(this.request=this.fetchHeader(e,i));n.parseHeader(r),this._isHeaderLoaded=!0;let s=0;for(const e of Object.values(n.layers))s=Math.max(s,e.dataIndex[e.dataIndex.length-1].lastByte);r.byteLength>=s&&(this.entireBuffer=r),i(null,this.entireBuffer||r,o)}catch(e){i(e)}}),this.request}fetchBandForRender(e,t,i,n){this.fetchBand(e,t,i,r=>{if(r)return void n(r);this.updateTextureDescriptor(e,t,i);const o=this.textureDescriptorPerLayer.get(t);n(null,o?o.img:null)})}fetchBand(t,i,n,r,o=!0){const s=this._mrt;if(!this._isHeaderLoaded||!s)return void r(new Error("Tile header is not ready"));const a=this.actor;if(!a)return void r(new Error("Can't fetch tile band without an actor"));let l;const c=e.B(String(n),e.B(this.tileID.key,t));let u=this._taskQueue.get(c);u?u.add(r):(u=new Set,u.add(r),this._taskQueue.set(c,u));const h=(e,t)=>{l.complete(e,t),e?r(e):(u.values().forEach(e=>e(null,t)),this._taskQueue.delete(c))},d=(e,t)=>{if(e)return r(e);const n=a.send("decodeRasterArray",{type:"raster-array",source:this.source,scope:this.scope,tileID:this.tileID,uid:this.uid,buffer:t,task:l},h,void 0,!0);if(null!==i){const e=this._workQueuePerLayer.get(i)||[];e.push(()=>{n&&n.cancel(),l.cancel()}),this._workQueuePerLayer.has(i)||this._workQueuePerLayer.set(i,e)}};let p;try{p=s.getLayer(t)}catch(e){if("reloading"===this.state)return;throw e}if(!p)return void r(new Error(`Unknown sourceLayer "${t}"`));if(p.hasDataForBand(n))return u.values().forEach(e=>e(null,null)),void this._taskQueue.delete(c);const f=p.getDataRange([n]);if(l=s.createDecodingTask(f),!l||l.tasks.length)if(null!==i&&this.flushQueues(i),this.entireBuffer)d(null,this.entireBuffer.slice(f.firstByte,f.lastByte+1));else{const t=Object.assign({},this.requestParams,{headers:{Range:`bytes=${f.firstByte}-${f.lastByte}`}}),n=e.bt(t,d);if(null!==i){const e=this._fetchQueuePerLayer.get(i)||[];e.push(()=>{n.cancel(),l.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,n){if(!this._mrt)return;const r=this._mrt.getLayer(t);if(!r||!r.hasBand(n)||!r.hasDataForBand(n))return;const{bytes:o,tileSize:s,buffer:a,offset:l,scale:c}=r.getBandView(n),u=s+2*a,h=new e.q({width:u,height:u},o),d=this.texturePerLayer.get(i);d&&d instanceof e.T&&d.update(h,{premultiply:!1}),this.textureDescriptorPerLayer.set(i,{layer:t,band:n,img:h,buffer:a,offset:l,tileSize:s,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}}class Pt{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 n=e.wrapped().key;void 0===this.data[n]&&(this.data[n]=[]);const r={value:t,timeout:void 0};if(void 0!==i&&(r.timeout=setTimeout(()=>{this.remove(e,r)},i)),this.data[n].push(r),this.order.push(n),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,n=void 0===t?0:this.data[i].indexOf(t),r=this.data[i][n];return this.data[i].splice(n,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 n of this.data[i])e(n.value)||t.push(n);for(const e of t)this.remove(e.value.tileID,e)}}class Rt{constructor(){this.state={},this.stateChanges={},this.deletedStates={}}updateState(e,t,i){const n=String(t);if(this.stateChanges[e]=this.stateChanges[e]||{},this.stateChanges[e][n]=this.stateChanges[e][n]||{},Object.assign(this.stateChanges[e][n],i),null===this.deletedStates[e]){this.deletedStates[e]={};for(const t in this.state[e])t!==n&&(this.deletedStates[e][t]=null)}else if(this.deletedStates[e]&&null===this.deletedStates[e][n]){this.deletedStates[e][n]={};for(const t in this.state[e][n])i[t]||(this.deletedStates[e][n][t]=null)}else for(const t in i)this.deletedStates[e]&&this.deletedStates[e][n]&&null===this.deletedStates[e][n][t]&&delete this.deletedStates[e][n][t]}removeFeatureState(e,t,i){if(null===this.deletedStates[e])return;const n=String(t);if(this.deletedStates[e]=this.deletedStates[e]||{},i&&void 0!==t)null!==this.deletedStates[e][n]&&(this.deletedStates[e][n]=this.deletedStates[e][n]||{},this.deletedStates[e][n][i]=null);else if(void 0!==t)if(this.stateChanges[e]&&this.stateChanges[e][n])for(i in this.deletedStates[e][n]={},this.stateChanges[e][n])this.deletedStates[e][n][i]=null;else this.deletedStates[e][n]=null;else this.deletedStates[e]=null}getState(e,t){const i=this.state[e]||{},n=this.stateChanges[e]||{},r=this.deletedStates[e];if(null===r)return{};if(void 0!==t){const e=String(t),o=Object.assign({},i[e],n[e]);if(r){const e=r[t];if(null===e)return{};for(const t in e)delete o[t]}return o}const o=Object.assign({},i,n);if(r)for(const e in r)delete o[e];return o}initializeTileState(e,t){e.refreshFeatureState(t)}coalesceChanges(e,t){const i={};for(const e in this.stateChanges){this.state[e]=this.state[e]||{};const t={};for(const i in this.stateChanges[e])this.state[e][i]||(this.state[e][i]={}),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]||{};const t={};if(null===this.deletedStates[e])for(const i in this.state[e])t[i]={},this.state[e][i]={};else for(const i in this.deletedStates[e]){if(null===this.deletedStates[e][i])this.state[e][i]={};else 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.assign(i[e],t)}if(this.stateChanges={},this.deletedStates={},0!==Object.keys(i).length)for(const i in e)e[i].refreshFeatureState(t)}}class Lt extends e.E{constructor(e,t,i){super(),this.id=e,this._onlySymbols=i,t.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))}),t.on("error",()=>{this._sourceErrored=!0}),this._source=t,this._tiles={},this._cache=new Pt(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 Rt,this._isRaster="raster"===this._source.type||"raster-dem"===this._source.type||"raster-array"===this._source.type||"custom"===this._source.type&&"raster"===this._source._dataType}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}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)}_loadTile(e,t){return e.isSymbolTile=this._onlySymbols,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(Ft).map(e=>e.key)}getRenderableIds(t,i){const n=[];for(const e in this._tiles)this._isIdRenderable(+e,t,i)&&n.push(this._tiles[e]);return t?n.sort((t,i)=>{const n=t.tileID,r=i.tileID,o=new e.P(n.canonical.x,n.canonical.y)._rotate(this.transform.angle),s=new e.P(r.canonical.x,r.canonical.y)._rotate(this.transform.angle);return n.overscaledZ-r.overscaledZ||s.y-o.y||s.x-o.x}).map(e=>e.tileID.key):n.map(e=>e.tileID).sort(Ft).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,n,r,o){if(r){if(t.state="errored",404!==r.status)this._source.fire(new e.y(r,{tile:t}));else{if(this._source.fire(new e.z("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)}return}t.timeAdded=e.o.now(),"expired"===n&&(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 s=new Map;o&&o.responseHeaders&&(s=o.responseHeaders),this._source.fire(new e.z("data",{dataType:"source",tile:t,coord:t.tileID,sourceCacheId:this.id,responseHeaders:s}))}_backfillDEM(e){const t=this.getRenderableIds();for(let n=0;n1||(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,n),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,n){for(const r in this._tiles){let o=this._tiles[r];if(n[r]||!o.hasData()||o.tileID.overscaledZ<=t||o.tileID.overscaledZ>i)continue;let s=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()&&(s=e)}let a=s;for(;a.overscaledZ>t;)if(a=a.scaledTo(a.overscaledZ-1),e[a.key]){n[s.key]=s;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),n=this._getLoadedTile(t);if(n)return n}}_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,n=Math.ceil(e.height/t)+1,r=Math.floor(i*n*5),o="number"==typeof this._minTileCacheSize?Math.max(this._minTileCacheSize,r):r,s="number"==typeof this._maxTileCacheSize?Math.min(this._maxTileCacheSize,o):o;this._cache.setMaxSize(s)}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 n=this._tiles[i];n.tileID=n.tileID.unwrapTo(n.tileID.wrap+t),e[n.tileID.key]=n}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,n,r,o){if(this.transform=t,!this._sourceLoaded||this._paused||this.transform.freezeTileCoverage)return;if(this.usedForTerrain&&!n)return;this.updateCacheSize(t,i),"globe"!==this.transform.projection.name&&this.handleWrapJump(this.transform.center.lng),this._shadowCasterTiles={},this._coveredTiles={};const s="batched-model"===this._source.type;let a,l=this._source.maxzoom;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)}if(this.used||this.usedForTerrain){if(this._source.tileID)a=t.getVisibleUnwrappedCoordinates(this._source.tileID).map(t=>new e.aP(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&&!n,reparseOverscaled:this._source.reparseOverscaled,isTerrainDEM:this.usedForTerrain,calculateQuadrantVisibility:s}),this._source.minzoom<=1&&"globe"===t.projection.name&&(a.push(new e.aP(1,0,1,0,0)),a.push(new e.aP(1,0,1,1,0)),a.push(new e.aP(1,0,1,0,1)),a.push(new e.aP(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&&!n,reparseOverscaled:this._source.reparseOverscaled,isTerrainDEM:this.usedForTerrain,calculateQuadrantVisibility:s}),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&&!kt(this._source.type)){const e=t.coveringZoomLevel({tileSize:i||this._source.tileSize,roundZoom:this._source.roundZoom&&!n}),l=Math.min(e,this._source.maxzoom);if(s){const e=t.extendTileCover(a,l);for(const t of e)a.push(t)}else if(o){const e=t.extendTileCoverToNearPlane(a,this.transform.getFrustum(l),l);for(const t of e)a.push(t)}else if(this.castsShadows&&r){const e=t.extendTileCover(a,l,r);for(const t of e)this._shadowCasterTiles[t.key]=!0,a.push(t)}}const u=this._updateRetainedTiles(a);if(kt(this._source.type)&&0!==a.length){const t={},i={},n=Object.keys(u);for(const r of n){const n=u[r],o=this._tiles[r];if(!o||o.fadeEndTime&&o.fadeEndTime<=e.o.now())continue;const s=this.findLoadedParent(n,Math.max(n.overscaledZ-Lt.maxOverzooming,this._source.minzoom));s&&(this._addTile(s.tileID),t[s.tileID.key]=s.tileID),i[r]=n}const r=a[a.length-1].overscaledZ;for(const e in this._tiles){const t=this._tiles[e];if(u[e]||!t.hasData())continue;let n=t.tileID;for(;n.overscaledZ>r;){n=n.scaledTo(n.overscaledZ-1);const r=this._tiles[n.key];if(r&&r.hasData()&&i[n.key]){u[e]=t.tileID;break}}}for(const e in t)u[e]||(this._coveredTiles[e]=!0,u[e]=t[e])}for(const e in u)this._tiles[e].clearFadeHold();const h=e.bu(this._tiles,u);for(const e of h){const t=this._tiles[e];t.hasSymbolBuckets&&!t.holdingForFade()?t.setHoldDuration(this.map._fadeDuration):t.hasSymbolBuckets&&!t.symbolFadeFinished()||this._removeTile(+e)}this._updateLoadedParentTileCache(),this._onlySymbols&&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={},n=e.reduce((e,t)=>Math.min(e,t.overscaledZ),1/0),r=e[0].overscaledZ,o=Math.max(r-Lt.maxOverzooming,this._source.minzoom),s=Math.max(r+Lt.maxUnderzooming,this._source.minzoom),a={};for(const i of e){const e=this._addTile(i);t[i.key]=i,e.hasData()||n=this._source.maxzoom){const e=n.children(this._source.maxzoom)[0],i=this.getTile(e);if(i&&i.hasData()){t[e.key]=e;continue}}else{const e=n.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 s=n.overscaledZ-1;s>=o;--s){const o=n.scaledTo(s);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,r=e.wasRequested(),e.hasData()))break}}return t}_updateLoadedParentTileCache(){this._loadedParentTiles={};for(const e in this._tiles){const t=[];let i,n=this._tiles[e].tileID;for(;n.overscaledZ>0;){if(n.key in this._loadedParentTiles){i=this._loadedParentTiles[n.key];break}t.push(n.key);const e=n.scaledTo(n.overscaledZ-1);if(i=this._getLoadedTile(e),i)break;n=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 n=Boolean(i);if(!n){const e=this.map?this.map.painter:null,n=this._source.tileSize*t.overscaleFactor();i="raster-array"===this._source.type?new Mt(t,n,this.transform.tileZoom,e,this._isRaster):new It(t,n,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,n||this._source.fire(new e.z("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,n){const r=[],o=this.transform;if(!o)return r;const s="globe"===o.projection.name,a=e.aF(o.center.lng);for(const l in this._tiles){const c=this._tiles[l];if(n&&c.clearQueryDebugViz(),c.holdingForFade())continue;let u;if(s){const t=c.tileID.canonical;if(0===t.z){const i=[Math.abs(e.aA(a,...Dt(t,-1))-a),Math.abs(e.aA(a,...Dt(t,1))-a)];u=[0,2*i.indexOf(Math.min(...i))-1]}else{const i=[Math.abs(e.aA(a,...Dt(t,-1))-a),Math.abs(e.aA(a,...Dt(t,0))-a),Math.abs(e.aA(a,...Dt(t,1))-a)];u=[i.indexOf(Math.min(...i))-1]}}else u=[0];for(const e of u){const n=t.containsTile(c,o,i,e);n&&r.push(n)}}return r}getShadowCasterCoordinates(){return this._getRenderableCoordinates(!1,!0)}getVisibleCoordinates(e){return this._getRenderableCoordinates(e)}_getRenderableCoordinates(e,t){const i=this.getRenderableIds(e,t).map(e=>this._tiles[e].tileID),n="globe"===this.transform.projection.name;for(const e of i)e.projMatrix=this.transform.calculateProjMatrix(e.toUnwrapped()),e.expandedProjMatrix=n?this.transform.calculateProjMatrix(e.toUnwrapped(),!1,!0):e.projMatrix;return i}sortCoordinatesByDistance(e){const t=e.slice(),i=this.transform._camera.position,n=this.transform._camera.forward(),r={};for(const e of t){const t=1/(1<r[e.key]-r[t.key]),t}hasTransition(){if(this._source.hasTransition())return!0;if(kt(this._source.type))for(const t in this._tiles){const i=this._tiles[t];if(void 0!==i.fadeEndTime&&i.fadeEndTime>=e.o.now())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 n=this._tiles[e];n&&n.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 n=new Map,r=Array.isArray(t)?t:[t],o=this.map.painter.terrain,s=this.usedForTerrain&&o?o.getScaledDemTileSize():this._source.tileSize;for(const e of r){const t=e.coveringTiles({tileSize:s,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)n.set(e.key,e);this.usedForTerrain&&e.updateElevation(!1)}const a=Array.from(n.values());e.bv(a,(e,t)=>{const i=new It(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 Ft(e,t){const i=Math.abs(2*e.wrap)-+(e.wrap<0),n=Math.abs(2*t.wrap)-+(t.wrap<0);return e.overscaledZ-t.overscaledZ||n-i||t.canonical.y-e.canonical.y||t.canonical.x-e.canonical.x}function kt(e){return"raster"===e||"image"===e||"video"===e||"custom"===e}function Dt(e,t){const i=1<0:"building"===i.type?n=!i.isHidden(e)&&i.paint.get("building-opacity")>0:"model"===i.type&&(n=!i.isHidden(e)&&i.paint.get("model-opacity").constantOr(1)>0),this.layersGotHidden=this.layersGotHidden||!n&&t.visible,t.visible=n}}updateZOffset(e,t){this.currentBuildingBuckets=[];for(const e of this.layers){const i=e.layer,n=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=n?n.getTile(t):null;if(!o&&n)for(const e in n._tiles){const i=n._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 n=0;n{e in i&&(n[e]=i[e])}),n}function Ut(e){e=e.slice();const t=Object.create(null);for(let i=0;i0?(r-s)/a:0;return this.points[o].mult(1-l).add(this.points[i].mult(l))}}class Jt{constructor(e,t,i){const n=this.boxCells=[],r=this.circleCells=[];this.xCellCount=Math.ceil(e/i),this.yCellCount=Math.ceil(t/i);for(let e=0;ethis.width||n<0||t>this.height)return!r&&[];const s=[];if(e<=0&&t<=0&&this.width<=i&&this.height<=n){if(r)return!0;for(let e=0;e0:s}_queryCircle(e,t,i,n,r){const o=e-i,s=e+i,a=t-i,l=t+i;if(s<0||o>this.width||l<0||a>this.height)return!n&&[];const c=[];return this._forEachCell(o,a,s,l,this._queryCellCircle,c,{hitTest:n,circle:{x:e,y:t,radius:i},seenUids:{box:{},circle:{}}},r),n?c.length>0:c}query(e,t,i,n,r){return this._query(e,t,i,n,!1,r)}hitTest(e,t,i,n,r){return this._query(e,t,i,n,!0,r)}hitTestCircle(e,t,i,n){return this._queryCircle(e,t,i,!0,n)}_queryCell(e,t,i,n,r,o,s,a){const l=s.seenUids,c=this.boxCells[r];if(null!==c){const r=this.bboxes;for(const u of c)if(!l.box[u]){l.box[u]=!0;const c=4*u;if(e<=r[c+2]&&t<=r[c+3]&&i>=r[c+0]&&n>=r[c+1]&&(!a||a(this.boxKeys[u]))){if(s.hitTest)return o.push(!0),!0;o.push({key:this.boxKeys[u],x1:r[c],y1:r[c+1],x2:r[c+2],y2:r[c+3]})}}}const u=this.circleCells[r];if(null!==u){const r=this.circles;for(const c of u)if(!l.circle[c]){l.circle[c]=!0;const u=3*c;if(this._circleAndRectCollide(r[u],r[u+1],r[u+2],e,t,i,n)&&(!a||a(this.circleKeys[c]))){if(s.hitTest)return o.push(!0),!0;{const e=r[u],t=r[u+1],i=r[u+2];o.push({key:this.circleKeys[c],x1:e-i,y1:t-i,x2:e+i,y2:t+i})}}}}}_queryCellCircle(e,t,i,n,r,o,s,a){const l=s.circle,c=s.seenUids,u=this.boxCells[r];if(null!==u){const e=this.bboxes;for(const t of u)if(!c.box[t]){c.box[t]=!0;const i=4*t;if(this._circleAndRectCollide(l.x,l.y,l.radius,e[i+0],e[i+1],e[i+2],e[i+3])&&(!a||a(this.boxKeys[t])))return o.push(!0),!0}}const h=this.circleCells[r];if(null!==h){const e=this.circles;for(const t of h)if(!c.circle[t]){c.circle[t]=!0;const i=3*t;if(this._circlesCollide(e[i],e[i+1],e[i+2],l.x,l.y,l.radius)&&(!a||a(this.circleKeys[t])))return o.push(!0),!0}}}_forEachCell(e,t,i,n,r,o,s,a){const l=this._convertToXCellCoord(e),c=this._convertToYCellCoord(t),u=this._convertToXCellCoord(i),h=this._convertToYCellCoord(n);for(let d=l;d<=u;d++)for(let l=c;l<=h;l++)if(r.call(this,e,t,i,n,this.xCellCount*l+d,o,s,a))return}_convertToXCellCoord(e){return Math.max(0,Math.min(this.xCellCount-1,Math.floor(e*this.xScale)))}_convertToYCellCoord(e){return Math.max(0,Math.min(this.yCellCount-1,Math.floor(e*this.yScale)))}_circlesCollide(e,t,i,n,r,o){const s=n-e,a=r-t,l=i+o;return l*l>s*s+a*a}_circleAndRectCollide(e,t,i,n,r,o,s){const a=(o-n)/2,l=Math.abs(e-(n+a));if(l>a+i)return!1;const c=(s-r)/2,u=Math.abs(t-(r+c));if(u>c+i)return!1;if(l<=a||u<=c)return!0;const h=l-a,d=u-c;return h*h+d*d<=i*i}}const Yt={unknown:0,flipRequired:1,flipNotRequired:2},ei=Math.tan(85*Math.PI/180);function ti(t,i,n,r,o,s,a){const l=e.bB();if(n)if("globe"===s.name){const t=e.bC(o,i);e.aB(l,l,t)}else{const t=e.bD([],a);l[0]=t[0],l[1]=t[1],l[4]=t[2],l[5]=t[3],r||e.bA(l,l,o.angle)}else e.aB(l,o.labelPlaneMatrix,t);return l}function ii(e,t,i,n,r,o,s){const a=ti(e,t,i,n,r,o,s);return"globe"===o.name&&i||(a[2]=a[6]=a[10]=a[14]=0),a}function ni(t,i,n,r,o,s,a){if(n){if("globe"===s.name){const l=ti(t,i,n,r,o,s,a);return e.bk(l,l),e.aB(l,t,l),l}{const i=e.by(t),n=e.bz([]);return n[0]=a[0],n[1]=a[1],n[4]=a[2],n[5]=a[3],e.aB(i,i,n),r||e.bA(i,i,-o.angle),i}}return o.glCoordMatrix}function ri(t,i,n,r){const o=[t,i,n,1];n?e.aC(o,o,r):mi(o,o,r);const s=o[3];return o[0]/=s,o[1]/=s,o[2]/=s,o}function oi(e,t){return Math.min(.5+e/t*.5,1.5)}function si(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 ai(t,i,n,r,o,s,a,l,c,u,h=1){const d=n.transform,p=r?t.textSizeData:t.iconSizeData,f=e.bJ(p,n.transform.zoom,h),m="globe"===d.projection.name,g=[256/n.width*2+1,256/n.height*2+1],_=r?t.text.dynamicLayoutVertexArray:t.icon.dynamicLayoutVertexArray;_.clear();let A=null;m&&(A=r?t.text.globeExtVertexArray:t.icon.globeExtVertexArray);const y=t.lineVertexArray,v=r?t.text.placedSymbolArray:t.icon.placedSymbolArray,x=n.transform.width/n.transform.height;let b,w=!1;for(let r=0;rMath.abs(n)?{useVertical:!0}:t===e.bK.vertical?r>0?{needsFlipping:!0}:null:i!==Yt.unknown&&function(e,t){return 0===e||Math.abs(t/e)>ei}(n,r)?i===Yt.flipRequired?{needsFlipping:!0}:null:n<0?{needsFlipping:!0}:null}function ui(t,i,n,r,o,s,a,l,c,u,h,d,p,f,m,g,_,A,y,v){const x=i/24,b=t.lineOffsetX*x,w=t.lineOffsetY*x,{lineStartIndex:T,glyphStartIndex:E,numGlyphs:C,segment:S,writingMode:B,flipState:I}=t,M=T+t.lineLength,P=t=>{if(h){const[i,n,r]=t.up,o=u.length;e.bM(h,o+0,i,n,r),e.bM(h,o+1,i,n,r),e.bM(h,o+2,i,n,r),e.bM(h,o+3,i,n,r)}const[i,n,r]=t.point;e.bN(u,i,n,r,t.angle)};if(C>1){const e=li(x,l,b,w,n,d,p,t,c,s,f,g,!1,_,A,y,v);if(!e)return{notEnoughRoom:!0};if(r&&!n){let[i,n,r]=e.first.point,[o,s,l]=e.last.point;[i,n]=ri(i,n,r,a),[o,s]=ri(o,s,l,a);const c=ci(B,I,(o-i)*m,s-n);if(t.flipState=c&&c.needsFlipping?Yt.flipRequired:Yt.flipNotRequired,c)return c}P(e.first);for(let e=E+1;e0?s:di(p,r,i,1,o,void 0,_,A.canonical),l=ci(B,I,(a[0]-i[0])*m,a[1]-i[1]);if(t.flipState=l&&l.needsFlipping?Yt.flipRequired:Yt.flipNotRequired,l)return l}const i=pi(x*l.getoffsetX(E),b,w,n,d,p,S,T,M,c,s,f,g,!1,!1,_,A,y,v);if(!i)return{notEnoughRoom:!0};P(i)}return{}}function hi(e,t,i,n,r){const{x:o,y:s,z:a}=n.projectTilePoint(e.x,e.y,t);if(!r)return ri(o,s,a,i);const[l,c,u]=r.getElevation(e,r.elevation,r.elevationFeature);return ri(o+l,s+c,a+u,i)}function di(t,i,n,r,o,s,a,l){const c=hi(t.sub(i)._unit()._add(t),l,o,a,s);return e.av(c,n,c),e.aw(c,c),e.bG(c,n,c,r)}function pi(t,i,n,r,o,s,a,l,c,u,h,d,p,f,m,g,_,A,y){const v=r?t-i:t+i;let x=v>0?1:-1,b=0;r&&(x*=-1,b=Math.PI),x<0&&(b+=Math.PI);let w=l+a+(x>0?0:1)|0,T=o,E=o,C=0,S=0;const B=Math.abs(v),I=[],M=[];let P=s,R=P,L=e.bE([]);const F=()=>di(R,P,E,B-C+1,h,p,g,_.canonical);for(;C+S<=B;){if(w+=x,w=c)return null;if(E=T,R=P,I.push(E),f&&M.push(R),P=new e.P(u.getx(w),u.gety(w)),T=d[w],!T){const e=hi(P,_.canonical,h,g,p);T=e[3]>0?d[w]=e:F()}C+=S;const t=e.av([],T,E),i=e.bF(E,T);if(n&&i>0&&S>0&&e.bI(L,t)/(S*i)0,y),w=c*b.perspectiveRatio,T=(n.x1*i+a.x-n.padding)*w+b.point.x,E=(n.y1*i+a.y-n.padding)*w+b.point.y,C=(n.x2*i+a.x+n.padding)*w+b.point.x,S=(n.y2*i+a.y+n.padding)*w+b.point.y,B=b.perspectiveRatio<=.55||b.occluded;return!this.isInsideGrid(T,E,C,S)||!l&&this.grid.hitTest(T,E,C,S,h)||B?{box:[],offscreen:!1,occluded:b.occluded}:{box:[T,E,C,S],offscreen:this.isOffscreen(T,E,C,S),occluded:!1}}placeCollisionCircles(t,i,n,r,o,s,a,l,c,u,h,d,p,f,m,g){const _=[],A=this.transform.elevation,y=t.getProjection(),v="road"===t.elevationType,x=!!A||v,b=e.bU.getAtTileOffsetFunc(g,this.transform.center.lat,this.transform.worldSize,y),w=new e.P(n.tileAnchorX,n.tileAnchorY),T=new e.P(n.tileAnchorX,n.tileAnchorY);let{x:E,y:C,z:S}=y.projectTilePoint(T.x,T.y,g.canonical),B=null;if(x){const e=v?t.getElevationFeatureForText(r):null;B={getElevation:b,elevation:A,elevationFeature:e};const[i,n,o]=b(w,A,e);E+=i,C+=n,S+=o}const I="globe"===y.name,M=this.projectAndGetPerspectiveRatio(l,E,C,S,g,I||!!A||this.transform.pitch>0,y),{perspectiveRatio:P}=M,R=(d?a/P:a*P)/e.bX,L=ri(E,C,S,c),F=n.lineOffsetX*R,k=n.lineOffsetY*R,D=e.an(t.layers[0].layout.get("text-max-angle")),O=Math.cos(D),z=M.signedDistanceFromCamera>0?li(R,s,F,k,v&&1===n.flipState,L,T,n,o,c,{},x&&!d?B:null,d&&x,y,g,d,O):null;let U=!1,N=!1,V=!0;if(z&&!M.occluded){const t=.5*f*P+m,n=new e.P(-100,-100),r=new e.P(this.screenRightBoundary,this.screenBottomBoundary),o=new Xt,{first:s,last:a}=z,l=s.path.length;let c=[];for(let e=l-1;e>=1;e--)c.push(s.path[e]);for(let e=1;e(x&&!I&&(i=b(ne[3]<=0)&&(c=[]));let g=[];if(c.length>0){let t=1/0,i=-1/0,o=1/0,s=-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]),s=Math.max(s,e[1]);i>=n.x&&t<=r.x&&s>=n.y&&o<=r.y&&(g=[c.map(t=>new e.P(t[0],t[1]))],(tr.x||or.y)&&(g=e.bV(g,n.x,n.y,r.x,r.y)))}for(const e of g){o.reset(e,.25*t);let n=0;n=o.length<=.5*t?1:Math.ceil(o.paddedLength/d)+1;for(let e=0;e0){if(e.aC(l,l,t),this.fogState&&o&&"globe"!==a.name){const t=function(t,i,n,r,o,s){const a=s.calculateFogTileMatrix(o),l=[i,n,r];return e.af(l,l,a),je(t,e.ag(l),s.pitch,s._fov)}(this.fogState,i,n,r,o.toUnwrapped(),this.transform);c=t>.9}}else mi(l,l,t);const u=l[3];return{point:new e.P((l[0]/u+1)/2*this.transform.width+gi,(-l[1]/u+1)/2*this.transform.height+gi),perspectiveRatio:Math.min(.5+this.transform.getCameraToCenterDistance(a)/u*.5,1.5),signedDistanceFromCamera:u,occluded:s&&l[2]>u||c}}isOffscreen(e,t,i,n){return i=this.screenRightBoundary||nthis.screenBottomBoundary}isInsideGrid(e,t,i,n){return i>=0&&e=0&&te.collisionGroupID===t}}return this.collisionGroups[e]}}function Ti(t,i,n,r,o){const{horizontalAlign:s,verticalAlign:a}=e.c0(t),l=-(s-.5)*i,c=-(a-.5)*n,u=e.c1(t,r);return new e.P(l+u[0]*o,c+u[1]*o)}function Ei(t,i,n,r,o){const s=new e.P(t,i);return n&&s._rotate(r?o:-o),s}class Ci{constructor(e,t,i,n,r,o){this.transform=e.clone(),this.projection=e.projection.name,this.collisionIndex=new _i(this.transform,r),this.buildingIndex=o,this.placements={},this.opacities={},this.variableOffsets={},this.stale=!1,this.commitTime=0,this.fadeDuration=t,this.retainedQueryData={},this.collisionGroups=new wi(i),this.collisionCircleArrays={},this.prevPlacement=n,n&&(n.prevPlacement=void 0),this.placedOrientations={}}getBucketParts(t,i,n,r,o=1){const s=n.getBucket(i),a=n.latestFeatureIndex;if(!s||!a||i.fqid!==s.layerIds[0])return;const l=s.layers[0].layout,c=s.layers[0].paint,u=n.collisionBoxArray,h=Math.pow(2,this.transform.zoom-n.tileID.overscaledZ),d=n.tileSize/e.al,p=n.tileID.toUnwrapped();this.transform.setProjection(s.projection);const f=(m=n.tileID,g=s.getProjection(),_=this.transform,g.name===this.projection?_.calculateProjMatrix(m.toUnwrapped()):Wt(_,g,m));var m,g,_;const A="map"===l.get("text-pitch-alignment"),y="map"===l.get("text-rotation-alignment");i.compileFilter(i.options);const v=i.dynamicFilter(),x=i.dynamicFilterNeedsFeature(),b=this.transform.calculatePixelsToTileUnitsMatrix(n),w=ii(f,n.tileID.canonical,A,y,this.transform,s.getProjection(),b);let T=null;const E=s.getProjection().createInversionMatrix(this.transform,n.tileID.canonical);if(A){const t=ni(f,n.tileID.canonical,A,y,this.transform,s.getProjection(),b);T=e.aB([],this.transform.labelPlaneMatrix,t)}let C=null;v&&n.latestFeatureIndex&&(C={unwrappedTileID:p,dynamicFilter:v,dynamicFilterNeedsFeature:x}),this.retainedQueryData[s.bucketInstanceId]=new bi(s.bucketInstanceId,a,s.sourceLayerIndex,s.index,n.tileID);const[S,B]=s.layers[0].layout.get("text-size-scale-range"),I=e.aA(o,S,B),[M,P]=l.get("icon-size-scale-range"),R=e.aA(o,M,P),L={bucket:s,layout:l,paint:c,posMatrix:f,invMatrix:E,mercatorCenter:[e.aF(this.transform.center.lng),e.aJ(this.transform.center.lat)],textLabelPlaneMatrix:w,labelToScreenMatrix:T,clippingData:C,scale:h,textPixelRatio:d,holdingForFade:n.holdingForFade(),collisionBoxArray:u,partiallyEvaluatedTextSize:e.bJ(s.textSizeData,this.transform.zoom,I),partiallyEvaluatedIconSize:e.bJ(s.iconSizeData,this.transform.zoom,R),collisionGroup:this.collisionGroups.get(s.sourceID),latestFeatureIndex:n.latestFeatureIndex};if(r)for(const e of s.sortKeyRanges){const{sortKey:i,symbolInstanceStart:n,symbolInstanceEnd:r}=e;t.push({sortKey:i,symbolInstanceStart:n,symbolInstanceEnd:r,parameters:L})}else t.push({symbolInstanceStart:0,symbolInstanceEnd:s.symbolInstances.length,parameters:L})}attemptAnchorPlacement(e,t,i,n,r,o,s,a,l,c,u,h,d,p,f,m,g,_,A,y,v){const{textOffset0:x,textOffset1:b,crossTileID:w}=f,T=[x,b],E=Ti(e,o,s,T,a),C=this.collisionIndex.placeCollisionBox(g,a,t,i,n,r,Ei(E.x,E.y,l,c,this.transform.angle),p,u,h,d.predicate);if(A){const e=g.getSymbolInstanceIconSize(v,this.transform.zoom,f.placedIconSymbolIndex);if(0===this.collisionIndex.placeCollisionBox(g,e,A,i,n,r,Ei(E.x,E.y,l,c,this.transform.angle),p,u,h,d.predicate).box.length)return}if(C.box.length>0){let t;return this.prevPlacement&&this.prevPlacement.variableOffsets[w]&&this.prevPlacement.placements[w]&&this.prevPlacement.placements[w].text&&(t=this.prevPlacement.variableOffsets[w].anchor),this.variableOffsets[w]={textOffset:T,width:o,height:s,anchor:e,textScale:a,prevAnchor:t},this.markUsedJustification(g,e,f,_),g.allowVerticalPlacement&&(this.markUsedOrientation(g,_,f),this.placedOrientations[w]=_),{shift:E,placedGlyphBoxes:C}}}placeLayerBucketPart(t,i,n,r,o=1){const{bucket:s,layout:a,paint:l,posMatrix:c,textLabelPlaneMatrix:u,labelToScreenMatrix:h,clippingData:d,textPixelRatio:p,mercatorCenter:f,invMatrix:m,holdingForFade:g,collisionBoxArray:_,partiallyEvaluatedTextSize:A,partiallyEvaluatedIconSize:y,collisionGroup:v,latestFeatureIndex:x}=t.parameters,b=a.get("text-optional"),w=a.get("icon-optional"),T=a.get("text-allow-overlap"),E=a.get("icon-allow-overlap"),C="map"===a.get("text-rotation-alignment"),S="map"===a.get("icon-rotation-alignment"),B="map"===a.get("text-pitch-alignment"),I=l.get("symbol-z-offset"),M="sea"===a.get("symbol-elevation-reference"),P=a.get("symbol-placement"),[R,L]=a.get("text-size-scale-range"),[F,k]=a.get("icon-size-scale-range"),D=e.aA(o,R,L),O=e.aA(o,F,k),z=a.get("text-variable-anchor"),U=C&&"point"!==P,N=S&&"point"!==P,V=z&&s.hasTextData(),j=s.hasIconTextFit()&&V&&s.hasIconData();this.transform.setProjection(s.projection);const G=V||U,H=N||j;let Q=T&&(E||!s.hasIconData()||w),$=E&&(T||!s.hasTextData()||b);const Z=!I.isConstant();!s.collisionArrays&&_&&s.deserializeCollisionBoxes(_),n&&r&&s.updateCollisionDebugBuffers(this.transform.zoom,_,D,O);const W=(t,r,o)=>{const{crossTileID:l,numVerticalGlyphVertices:_}=t;let S=null;if(d&&d.dynamicFilterNeedsFeature||Z){const e=this.retainedQueryData[s.bucketInstanceId];S=x.loadFeature({featureIndex:t.featureIndex,bucketIndex:e.bucketIndex,sourceLayerIndex:e.sourceLayerIndex,layoutVertexArrayOffset:0})}if(d&&!(0,d.dynamicFilter)({zoom:this.transform.zoom,pitch:this.transform.pitch,worldview:s.worldview},S,this.retainedQueryData[s.bucketInstanceId].tileID.canonical,new e.P(t.tileAnchorX,t.tileAnchorY),this.transform.calculateDistanceTileData(d.unwrappedTileID)))return this.placements[l]=new vi(!1,!1,!1,!0),void i.add(l);const P=I.evaluate(S,{});if(i.has(l))return;if(g)return void(this.placements[l]=new vi(!1,!1,!1));let R=!1,L=!1,F=!0,k=!1,D=!1,O=null,U={box:null,offscreen:null,occluded:null},N={box:null},V=null,j=null,W=null,q=0,K=0,X=0;o.textFeatureIndex?q=o.textFeatureIndex:t.useRuntimeCollisionCircles&&(q=t.featureIndex),o.verticalTextFeatureIndex&&(K=o.verticalTextFeatureIndex);const J=s.elevationFeatures?s.elevationFeatures[t.elevationFeatureIndex]:void 0,Y=i=>{i.tileID=this.retainedQueryData[s.bucketInstanceId].tileID;const n=this.transform.elevation;i.elevation=M?P:P+e.bU.getAtTileOffset(i.tileID,new e.P(i.tileAnchorX,i.tileAnchorY),n,J),i.elevation+=t.zOffset},ee=o.textBox;if(ee){Y(ee);const i=i=>{let n=e.bK.horizontal;if(s.allowVerticalPlacement&&!i&&this.prevPlacement){const e=this.prevPlacement.placedOrientations[l];e&&(this.placedOrientations[l]=e,n=e,this.markUsedOrientation(s,n,t))}return n},n=(t,i)=>{if(s.allowVerticalPlacement&&_>0&&o.verticalTextBox){for(const n of s.writingModes)if(n===e.bK.vertical?(U=i(),N=U):U=t(),U&&U.box&&U.box.length)break}else U=t()};if(z){let a=z;if(this.prevPlacement&&this.prevPlacement.variableOffsets[l]){const e=this.prevPlacement.variableOffsets[l];a.indexOf(e.anchor)>0&&(a=a.filter(t=>t!==e.anchor),a.unshift(e.anchor))}const u=(e,i,n)=>{const o=s.getSymbolInstanceTextSize(A,t,this.transform.zoom,r),l=(e.x2-e.x1)*o+2*e.padding,u=(e.y2-e.y1)*o+2*e.padding,h=t.hasIconTextFit&&!E?i:null;h&&Y(h);let d={box:[],offscreen:!1,occluded:!1};const g=T?2*a.length:a.length;for(let i=0;i=a.length,t,r,s,n,h,A,y);if(g&&(d=g.placedGlyphBoxes,d&&d.box&&d.box.length)){R=!0,O=g.shift;break}}return d};n(()=>u(ee,o.iconBox,e.bK.horizontal),()=>{const t=o.verticalTextBox;return t&&Y(t),s.allowVerticalPlacement&&!(U&&U.box&&U.box.length)&&_>0&&t?u(t,o.verticalIconBox,e.bK.vertical):{box:null,offscreen:null,occluded:null}}),U&&(R=U.box,F=U.offscreen,k=U.occluded);const h=i(!(!U||!U.box));if(!R&&this.prevPlacement){const e=this.prevPlacement.variableOffsets[l];e&&(this.variableOffsets[l]=e,this.markUsedJustification(s,e.anchor,t,h))}}else{const a=(i,n)=>{const o=s.getSymbolInstanceTextSize(A,t,this.transform.zoom,r),a=this.collisionIndex.placeCollisionBox(s,o,i,f,m,G,new e.P(0,0),T,p,c,v.predicate);return a&&a.box&&a.box.length&&(this.markUsedOrientation(s,n,t),this.placedOrientations[l]=n),a};n(()=>a(ee,e.bK.horizontal),()=>{const t=o.verticalTextBox;return s.allowVerticalPlacement&&_>0&&t?(Y(t),a(t,e.bK.vertical)):{box:null,offscreen:null,occluded:null}}),i(!!(U&&U.box&&U.box.length))}}if(V=U,R=V&&V.box&&V.box.length>0,F=V&&V.offscreen,k=V&&V.occluded,t.useRuntimeCollisionCircles){const i=t.centerJustifiedTextSymbolIndex>=0?t.centerJustifiedTextSymbolIndex:t.verticalPlacedTextSymbolIndex,r=s.text.placedSymbolArray.get(i),o=e.bL(s.textSizeData,A,r),l=a.get("text-padding");j=this.collisionIndex.placeCollisionCircles(s,T,r,i,s.lineVertexArray,s.glyphOffsetArray,o,c,u,h,n,B,v.predicate,t.collisionCircleDiameter*o/e.bX,l,this.retainedQueryData[s.bucketInstanceId].tileID),R=T||j.circles.length>0&&!j.collisionDetected,F=F&&j.offscreen,k=j.occluded}if(o.iconFeatureIndex&&(X=o.iconFeatureIndex),o.iconBox){const i=i=>{Y(i);const n=t.hasIconTextFit&&O?Ei(O.x,O.y,C,B,this.transform.angle):new e.P(0,0),r=s.getSymbolInstanceIconSize(y,this.transform.zoom,t.placedIconSymbolIndex);return this.collisionIndex.placeCollisionBox(s,r,i,f,m,H,n,E,p,c,v.predicate)};N&&N.box&&N.box.length&&o.verticalIconBox?(W=i(o.verticalIconBox),L=W.box.length>0):(W=i(o.iconBox),L=W.box.length>0),F=F&&W.offscreen,D=W.occluded}const te=b||0===t.numHorizontalGlyphVertices&&0===_,ie=w||0===t.numIconVertices;if(te||ie?ie?te||(L=L&&R):R=L&&R:L=R=L&&R,R&&V&&V.box&&this.collisionIndex.insertCollisionBox(V.box,a.get("text-ignore-placement"),s.bucketInstanceId,N&&N.box&&K?K:q,v.ID),L&&W&&this.collisionIndex.insertCollisionBox(W.box,a.get("icon-ignore-placement"),s.bucketInstanceId,X,v.ID),j&&(R&&this.collisionIndex.insertCollisionCircles(j.circles,a.get("text-ignore-placement"),s.bucketInstanceId,q,v.ID),n)){const e=s.bucketInstanceId;let t=this.collisionCircleArrays[e];void 0===t&&(t=this.collisionCircleArrays[e]=new xi);for(let e=0;e=0;--e){const i=t[e];W(s.symbolInstances.get(i),i,s.collisionArrays[i])}s.hasAnyZOffset&&e.w(`${s.layerIds[0]} layer symbol-z-elevate: symbols are not sorted by elevation if symbol-z-order is evaluated to viewport-y`)}else if(s.hasAnyZOffset){const e=s.getSortedIndexesByZOffset();for(let t=0;t=0&&(t.text.placedSymbolArray.get(o).crossTileID=h>=0&&o!==h?0:c),s>=0&&(t.text.placedSymbolArray.get(s).crossTileID=h>=0&&s!==h?0:c),a>=0&&(t.text.placedSymbolArray.get(a).crossTileID=h>=0&&a!==h?0:c),l>=0&&(t.text.placedSymbolArray.get(l).crossTileID=h>=0&&l!==h?0:c)}markUsedOrientation(t,i,n){const r=i===e.bK.horizontal||i===e.bK.horizontalOnly?i:0,o=i===e.bK.vertical?i:0,{leftJustifiedTextSymbolIndex:s,centerJustifiedTextSymbolIndex:a,rightJustifiedTextSymbolIndex:l,verticalPlacedTextSymbolIndex:c}=n,u=t.text.placedSymbolArray;s>=0&&(u.get(s).placedOrientation=r),a>=0&&(u.get(a).placedOrientation=r),l>=0&&(u.get(l).placedOrientation=r),c>=0&&(u.get(c).placedOrientation=o)}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 n=t?t.symbolFadeChange(e):1,r=t?t.opacities:{},o=t?t.variableOffsets:{},s=t?t.placedOrientations:{};for(const e in this.placements){const t=this.placements[e],o=r[e];o?(this.opacities[e]=new yi(o,n,t.text,t.icon,null,t.clipped),i=i||t.text!==o.text.placed||t.icon!==o.icon.placed):(this.opacities[e]=new yi(null,n,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 yi(t,n,!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 s)this.placedOrientations[e]||!this.opacities[e]||this.opacities[e].isHidden()||(this.placedOrientations[e]=s[e]);i?this.lastPlacementChangeTime=e:"number"!=typeof this.lastPlacementChangeTime&&(this.lastPlacementChangeTime=t?t.lastPlacementChangeTime:e)}updateLayerOpacities(e,t,i,n){const r=new Set;for(const o of t){const t=o.getBucket(e);t&&o.latestFeatureIndex&&e.fqid===t.layerIds[0]&&(this.updateBucketOpacities(t,r,o,o.collisionBoxArray,i,n,o.tileID,e.scope),"offset"===t.elevationType&&this.buildingIndex&&this.buildingIndex.updateZOffset(t,o.tileID),"road"===t.elevationType&&t.updateRoadElevation(o.tileID.canonical),t.updateZOffset())}}updateBucketOpacities(t,i,n,r,o,s,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,u=t.layers[0].paint,h=!!t.layers[0].dynamicFilter(),d=new yi(null,0,!1,!1,!0),p=c.get("text-allow-overlap"),f=c.get("icon-allow-overlap"),m=c.get("text-variable-anchor"),g="map"===c.get("text-rotation-alignment"),_="map"===c.get("text-pitch-alignment"),A=u.get("symbol-z-offset"),y="sea"===c.get("symbol-elevation-reference"),v=!A.isConstant(),x=new yi(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 b=(e,t,i)=>{for(let n=0;n0||p>0,L=T>0,F=this.placedOrientations[f],k=F===e.bK.vertical,D=F===e.bK.horizontal||F===e.bK.horizontalOnly;!R&&!L||P.isHidden()||w++;let O=!1;if((R||L)&&s)for(const i of t.activeReplacements){if(e.bY(i,o,e.bZ.Symbol,l))continue;if(i.min.x>E||E>i.max.x||i.min.y>C||C>i.max.y)continue;const t=e.b_(E,C,a.canonical,i.footprintTileId.canonical);if(O=e.b$(t,i.footprint),O)break}if(R){const e=O?Di:ki(P.text);b(t.text,u,k?Di:e),b(t.text,p,D?Di:e);const i=P.text.isHidden(),{leftJustifiedTextSymbolIndex:n,centerJustifiedTextSymbolIndex:r,rightJustifiedTextSymbolIndex:o,verticalPlacedTextSymbolIndex:s}=c,a=t.text.placedSymbolArray,l=i||k?1:0;n>=0&&(a.get(n).hidden=l),r>=0&&(a.get(r).hidden=l),o>=0&&(a.get(o).hidden=l),s>=0&&(a.get(s).hidden=i||D?1:0);const h=this.variableOffsets[f];h&&this.markUsedJustification(t,h.anchor,c,F);const d=this.placedOrientations[f];d&&(this.markUsedJustification(t,"left",c,d),this.markUsedOrientation(t,d,c))}if(L){const e=O?Di:ki(P.icon),{placedIconSymbolIndex:i,verticalPlacedIconSymbolIndex:n}=c,r=t.icon.placedSymbolArray,o=P.icon.isHidden()?1:0;i>=0&&(b(t.icon,T,k?Di:e),r.get(i).hidden=o),n>=0&&(b(t.icon,c.numVerticalIconVertices,D?Di:e),r.get(n).hidden=o)}if(t.hasIconCollisionBoxData()||t.hasTextCollisionBoxData()){const i=t.collisionArrays[r];if(i){let n=new e.P(0,0),r=!0;if(i.textBox||i.verticalTextBox){if(m){const e=this.variableOffsets[f];e?(n=Ti(e.anchor,e.width,e.height,e.textOffset,e.textScale),g&&n._rotate(_?this.transform.angle:-this.transform.angle)):r=!1}h&&(r=!P.clipped),i.textBox&&Si(t.textCollisionBox.collisionVertexArray,P.text.placed,!r||k,I,y,n.x,n.y),i.verticalTextBox&&Si(t.textCollisionBox.collisionVertexArray,P.text.placed,!r||D,I,y,n.x,n.y)}const o=r&&Boolean(!D&&i.verticalIconBox);i.iconBox&&Si(t.iconCollisionBox.collisionVertexArray,P.icon.placed,o,I,y,c.hasIconTextFit?n.x:0,c.hasIconTextFit?n.y:0),i.verticalIconBox&&Si(t.iconCollisionBox.collisionVertexArray,P.icon.placed,!o,I,y,c.hasIconTextFit?n.x:0,c.hasIconTextFit?n.y:0)}}}if(t.fullyClipped=0===w,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 this.stale||e-this.lastPlacementChangeTimee}setStale(){this.stale=!0}}function Si(e,t,i,n,r,o,s){e.emplaceBack(t?1:0,i?1:0,o||0,s||0,n,r?1:0),e.emplaceBack(t?1:0,i?1:0,o||0,s||0,n,r?1:0),e.emplaceBack(t?1:0,i?1:0,o||0,s||0,n,r?1:0),e.emplaceBack(t?1:0,i?1:0,o||0,s||0,n,r?1:0)}const Bi=Math.pow(2,25),Ii=Math.pow(2,24),Mi=Math.pow(2,17),Pi=Math.pow(2,16),Ri=Math.pow(2,9),Li=Math.pow(2,8),Fi=Math.pow(2,1);function ki(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*Bi+t*Ii+i*Mi+t*Pi+i*Ri+t*Li+i*Fi+t}const Di=0;class Oi{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,n,r,o){const s=this._bucketParts;for(;this._currentTileIndexe.sortKey-t.sortKey));this._currentPartIndex{const t=e.o.now()-s;return!this._forceFullPlacement&&t>2};for(;this._currentPlacementIndex>=0;){const s=i[t[this._currentPlacementIndex]],l=this.placement.collisionIndex.transform.zoom;if("symbol"===s.type&&(!s.minzoom||s.minzoom<=l)&&(!s.maxzoom||s.maxzoom>l)){const t=s,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"),u="viewport-y"===c||"auto"===c&&!("viewport-y"!==c&&l),h=t.layout.get("text-allow-overlap")||t.layout.get("icon-allow-overlap")||t.layout.get("text-ignore-placement")||t.layout.get("icon-ignore-placement"),d=u&&h,p=this._inProgressLayer=this._inProgressLayer||new Oi(t),f=e.B(s.source,s.scope);if(p.continuePlacement(i||d?r[f]:n[f],this.placement,this._showCollisionBoxes,s,a,o))return;delete this._inProgressLayer}this._currentPlacementIndex--}this._done=!0}commit(e){return this.placement.commit(e),this.placement}}const Ui=512/e.al/2;class Ni{constructor(t,i,n){this.tileID=t,this.bucketInstanceId=n,this.index=new e.c3(i.length,16,Int32Array),this.keys=[],this.crossTileIDs=[];const r=t.canonical.x*e.al,o=t.canonical.y*e.al;for(let e=0;ee-t);for(const e of p){const t=this.crossTileIDs[e];if(this.keys[e]===l&&!n.has(t)){n.add(t),i.crossTileID=t;break}}}}}class Vi{constructor(){this.maxCrossTileID=0}generate(){return++this.maxCrossTileID}}class ji{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],n={};for(const e in i){const r=i[e];r.tileID=r.tileID.unwrapTo(r.tileID.wrap+t),n[r.tileID.key]=r}this.indexes[e]=n}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;ee.overscaledZ)for(const i in r){const o=r[i];o.tileID.isChildOf(e)&&o.findMatches(t.symbolInstances,e,n)}else{const o=r[e.scaledTo(Number(i)).key];o&&o.findMatches(t.symbolInstances,e,n)}}for(let e=0;e{t[e]=!0});for(const e in this.layerIndexes)t[e]||delete this.layerIndexes[e]}}const Hi=771;class Qi{constructor(e,t,i,n){this.blendFunction=e,this.blendColor=t.toNonPremultipliedRenderColor(null),this.mask=i,this.blendEquation=n}}Qi.Replace=[1,0,1,0],Qi.disabled=new Qi(Qi.Replace,e.ao.transparent,[!1,!1,!1,!1]),Qi.unblended=new Qi(Qi.Replace,e.ao.transparent,[!0,!0,!0,!0]),Qi.alphaBlended=new Qi([1,Hi,1,Hi],e.ao.transparent,[!0,!0,!0,!0]),Qi.alphaBlendedNonPremultiplied=new Qi([770,Hi,770,Hi],e.ao.transparent,[!0,!0,!0,!0]),Qi.multiply=new Qi([774,0,774,0],e.ao.transparent,[!0,!0,!0,!0]),Qi.additive=new Qi([1,1,1,1],e.ao.transparent,[!0,!0,!0,!0]);class $i{constructor(e,t,i){this.func=e,this.mask=t,this.range=i}}$i.ReadOnly=!1,$i.ReadWrite=!0,$i.disabled=new $i(519,$i.ReadOnly,[0,1]);const Zi=7680;class Wi{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}}Wi.disabled=new Wi({func:519,mask:0},0,0,Zi,Zi,Zi);const qi=1029,Ki=2305;class Xi{constructor(e,t,i){this.enable=e,this.mode=t,this.frontFace=i}}function Ji(t,i){const n=e.c9(t,3);e.cb(t,i),e.cf(t,3,n)}function Yi(t,i){const n=e.c6([]);return e.c7(n,n,-i),e.c8(n,n,-t),n}function en(t,i){const n=[t[0],t[1],0],r=[i[0],i[1],0];if(e.ag(n)>=1e-15){const t=e.aw([],n);e.c4(r,t,e.bI(r,t)),i[0]=r[0],i[1]=r[1]}const o=e.bH([],i,t);if(e.c5(o)<1e-15)return null;const s=Math.atan2(-o[1],o[0]);return Yi(Math.atan2(Math.sqrt(t[0]*t[0]+t[1]*t[1]),-t[2]),s)}Xi.disabled=new Xi(!1,qi,Ki),Xi.backCCW=new Xi(!0,qi,Ki),Xi.backCW=new Xi(!0,qi,2304),Xi.frontCW=new Xi(!0,1028,2304),Xi.frontCCW=new Xi(!0,1028,Ki);class tn{constructor(e,t){this.position=e,this.orientation=t}get position(){return this._position}set position(t){if(t){const i=t instanceof e.ae?t:new e.ae(t[0],t[1],t[2]);this._renderWorldCopies&&(i.x=e.bS(i.x,0,1)),this._position=i}else this._position=null}lookAtPoint(t,i,n){if(this.orientation=null,!this.position)return;const r=this.position,o=n||(this._elevation?this._elevation.getAtPointOrZero(e.ae.fromLngLat(t)):0),s=e.ae.fromLngLat(t,o),a=[s.x-r.x,s.y-r.y,s.z-r.z];i||(i=[0,0,1]),i[2]=Math.abs(i[2]),this.orientation=en(a,i)}setPitchBearing(t,i){this.orientation=Yi(e.an(t),e.an(-i))}}class nn{constructor(t,i){this._transform=e.bz([]),this.orientation=i,this.position=t}get mercatorPosition(){const t=this.position;return new e.ae(t[0],t[1],t[2])}get position(){const t=e.c9(this._transform,3);return[t[0],t[1],t[2]]}set position(t){var i;t&&e.cf(this._transform,3,[(i=t)[0],i[1],i[2],1])}get orientation(){return this._orientation}set orientation(t){this._orientation=t||e.c6([]),t&&Ji(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=Yi(e,t),Ji(this._transform,this._orientation)}forward(){const t=e.c9(this._transform,2);return[-t[0],-t[1],-t[2]]}up(){const t=e.c9(this._transform,1);return[-t[0],-t[1],-t[2]]}right(){const t=e.c9(this._transform,0);return[t[0],t[1],t[2]]}getCameraToWorld(t,i){const n=new Float64Array(16);return e.bk(n,this.getWorldToCamera(t,i)),n}getCameraToWorldMercator(){return this._transform}getWorldToCameraPosition(t,i,n){const r=this.position;e.c4(r,r,-t);const o=new Float64Array(16);return e.bp(o,[n,n,n]),e.bq(o,o,r),o[10]*=i,o}getWorldToCamera(t,i){const n=new Float64Array(16),r=new Float64Array(4),o=this.position;return e.ca(r,this._orientation),e.c4(o,o,-t),e.cb(n,r),e.bq(n,n,o),n[1]*=-1,n[5]*=-1,n[9]*=-1,n[13]*=-1,n[8]*=i,n[9]*=i,n[10]*=i,n[11]*=i,n}getCameraToClipPerspective(t,i,n,r){const o=new Float64Array(16);return e.cc(o,t,i,n,r),o}getCameraToClipOrthographic(t,i,n,r,o,s){const a=new Float64Array(16);return e.cd(a,t,i,n,r,o,s),a}getDistanceToElevation(t,i=!1){const n=0===t?0:e.ce(t,i?e.a_(this.position[1]):this.position[1]),r=this.forward();return(n-this.position[2])/r[2]}clone(){return new nn([...this.position],[...this.orientation])}}const rn={BaseColor:5,MetallicRoughness:6,Normal:7,Occlusion:8,Emission:9,LUT:10,ShadowMap0:11};class on{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(t,i,n){return null!=i.top&&null!=t.top&&(this.top=e.ak(t.top,i.top,n)),null!=i.bottom&&null!=t.bottom&&(this.bottom=e.ak(t.bottom,i.bottom,n)),null!=i.left&&null!=t.left&&(this.left=e.ak(t.left,i.left,n)),null!=i.right&&null!=t.right&&(this.right=e.ak(t.right,i.right,n)),this}getCenter(t,i){const n=e.aA((this.left+t-this.right)/2,0,t),r=e.aA((this.top+i-this.bottom)/2,0,i);return new e.P(n,r)}equals(e){return this.top===e.top&&this.bottom===e.bottom&&this.left===e.left&&this.right===e.right}clone(){return new on(this.top,this.bottom,this.left,this.right)}toJSON(){return{top:this.top,bottom:this.bottom,left:this.left,right:this.right}}}const sn=15;class an{constructor(t,i,n,r,o,s,a){this.tileSize=512,this._renderWorldCopies=void 0===o||o,this._minZoom=t||0,this._maxZoom=i||22,this._minPitch=n??0,this._maxPitch=r??60,this.setProjection(s),this.setMaxBounds(a),this.width=0,this.height=0,this._center=new e.aS(0,0),this.zoom=0,this.angle=0,this._fov=.6435011087932844,this._pitch=0,this._nearZ=0,this._farZ=0,this._unmodified=!0,this._edgeInsets=new on,this._projMatrixCache={},this._alignedProjMatrixCache={},this._fogTileMatrixCache={},this._expandedProjMatrixCache={},this._distanceTileDataCache={},this._camera=new nn,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}clone(){const e=new an(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._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.pitch0&&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 t=this._elevation,i=[[.5,.2],[.3,.5],[.5,.5],[.7,.5],[.5,.8]],n=this.horizonLineFromTop();let r=0,o=0;for(let s=0;s{const l=e.cX(i,t,n,o,s);a.has(l)||(r.push(new e.aP(t,i,n,o,s)),a.add(l))};for(let e=0;e0,f=a.y+10,g=r.wrap-(p?0:1),_=r.wrap+(d?0:1),A=p?a.x-1:h-1,y=d?a.x+1:0;if(o)n[0]<0?(l(c,_,a.z,y,a.y),n[1]<0&&f&&(l(c,u,a.z,a.x,a.y+1),l(c,_,a.z,y,a.y+1)),n[1]>0&&m&&(l(c,u,a.z,a.x,a.y-1),l(c,_,a.z,y,a.y-1))):n[0]>0?(l(c,g,a.z,A,a.y),n[1]<0&&f&&(l(c,u,a.z,a.x,a.y+1),l(c,g,a.z,A,a.y+1)),n[1]>0&&m&&(l(c,u,a.z,a.x,a.y-1),l(c,g,a.z,A,a.y-1))):n[1]<0&&f?l(c,u,a.z,a.x,a.y+1):m&&l(c,u,a.z,a.x,a.y-1);else{const e=r.visibleQuadrants;1&e&&(l(c,g,a.z,A,a.y),m&&(l(c,u,a.z,a.x,a.y-1),l(c,g,a.z,A,a.y-1))),2&e&&(l(c,_,a.z,y,a.y),m&&(l(c,u,a.z,a.x,a.y-1),l(c,_,a.z,y,a.y-1))),4&e&&(l(c,g,a.z,A,a.y),f&&(l(c,u,a.z,a.x,a.y+1),l(c,g,a.z,A,a.y+1))),8&e&&(l(c,_,a.z,y,a.y),f&&(l(c,u,a.z,a.x,a.y+1),l(c,_,a.z,y,a.y+1)))}}const c=[];for(const e of r)r.some(t=>e.isChildOf(t))||c.push(e);if(r=c.filter(e=>!t.some(t=>!!(e.overscaledZ{const t=e.canonical.x+.5-n[0],i=e.canonical.y+.5-n[1];return t*t+i*i{const l=e.cX(i,t,n,s,a);o.has(l)||(r.push(new e.aP(t,i,n,s,a)),o.add(l))},a=t.reduce((e,t)=>Math.max(e,t.overscaledZ),n),l=1<{const r=Math.floor(t[0]),o=Math.floor(t[1]),d=(t[0]-r)*e.al,p=(t[1]-o)*e.al,f=Math.floor(i[0]),m=Math.floor(i[1]),g=(i[0]-f)*e.al,_=(i[1]-m)*e.al;for(let t=-1;t<=1;t++){const i=r+t;if(!(i<0||i>=l)){u.x=d-t*e.al,h.x=g-(i-f)*e.al;for(let t=-1;t<=1;t++){const r=o+t;u.y=p-t*e.al,h.y=_-(r-m)*e.al,e.cY(u,h,c)&&s(a,0,n,i,r)}}}},p=i.points,f=p[e.cu],m=p[e.cv],g=this._projectToGround(f,p[e.cw]),_=this._projectToGround(m,p[e.cx]);return d(f,g),d(m,_),r}_projectToGround(t,i){return e.cy(e.cz(),t,i,t[2]/(t[2]-i[2]))}coveringTiles(t){let i=this.coveringZoomLevel(t);const n=i,r=this.elevation&&this.elevation.exaggeration(),o=r&&!t.isTerrainDEM,s="mercator"===this.projection.name;if(void 0!==t.minzoom&&it.maxzoom&&(i=t.maxzoom);const a=this.locationCoordinate(this.center),l=this.center.lat,c=1<{const i=1/4e4,n=new e.ae(t.x+i,t.y,t.z),r=new e.ae(t.x,t.y+i,t.z),o=t.toLngLat(),s=n.toLngLat(),a=r.toLngLat(),l=this.locationCoordinate(o),c=this.locationCoordinate(s),u=this.locationCoordinate(a),h=Math.hypot(c.x-l.x,c.y-l.y),d=Math.hypot(u.x-l.x,u.y-l.y);return Math.sqrt(h*d)*w/i},E=t=>{const i=x,n=b;return{aabb:e.cE(this,c,0,0,0,t,n,i,this.projection),zoom:0,x:0,y:0,minZ:n,maxZ:i,wrap:t,fullyVisible:!1}},C=[];let S=[];const B=i,I=t.reparseOverscaled?n:i,M=(g-this._centerAltitude)*m,P=e=>{if(!this._elevation||!e.tileID||!s)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=L(e),e.shouldSplit||(i.min[2]=i.max[2]=i.center[2]=this._centerAltitude))},R=(e,t)=>{if(.707*t{if(t.zoom=.9)return!0}else if(o&&(a=t.aabb.distanceZ(_)*m),this.projection.isReprojectedInTileSpace&&n<=5){const i=Math.pow(2,t.zoom),n=T(new e.ae((t.x+.5)/i,(t.y+.5)/i));c=n>.85?1:n}if(!s&&!h){const e=Math.sqrt(i*i+r*r+a*a);let n=(1<0;){const n=C.pop(),r=n.x,a=n.y;let l=n.fullyVisible;const d=()=>"globe"===this.projection.name&&(0===n.y||n.y===(1<>1),d={aabb:s?n.aabb.quadrant(t):e.cE(this,c,n.zoom+1,i,u,n.wrap,n.minZ,n.maxZ,this.projection),zoom:n.zoom+1,x:i,y:u,wrap:n.wrap,fullyVisible:l,tileID:void 0,shouldSplit:void 0,minZ:n.minZ,maxZ:n.maxZ};o&&!h&&(d.tileID=new e.aP(n.zoom+1===B?I:n.zoom+1,n.wrap,n.zoom+1,i,u),P(d)),C.push(d)}else{const o=n.zoom===B?I:n.zoom;if(t.minzoom&&t.minzoom>o)continue;let s=0;if(!l){let i=A?n.aabb.intersectsPrecise(p):n.aabb.intersectsPreciseFlat(p);if(0===i&&d()){const t=new e.cC(n.zoom,r,a);i=e.cD(this,c,t,!0).intersectsPrecise(p)}if(0===i)continue;if(t.calculateQuadrantVisibility)if(p.containsPoint(n.aabb.center))s=15;else for(let e=0;e<4;e++)0!==n.aabb.quadrant(e).intersects(p)&&(s|=1<{const o=[0,0,0,1],s=[e.al,e.al,0,1],a=this.calculateFogTileMatrix(r.tileID.toUnwrapped());e.aC(o,o,a),e.aC(s,s,a);const l=e.cF([],o,s),c=e.cG([],o,s),u=e.c_(l,c);if(0===u)return!0;let h=!1;const d=this._elevation;if(d&&u>i&&0!==n){const i=this.calculateProjMatrix(r.tileID.toUnwrapped());let o;t.isTerrainDEM||(o=d.getMinMaxForTile(r.tileID)),o||(o={min:b,max:x});const s=e.cH(this.rotation),a=[s[0]*e.al,s[1]*e.al,o.max];e.af(a,a,i),h=(1-a[1])*this.height*.5e.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(t){const i=e.aA(t.lat,-e.cI,e.cI),n=this.projection.project(t.lng,i);return new e.P(n.x*this.worldSize,n.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/e.ce(1,this.center.lat)/this.worldSize}setLocationAtPoint(t,i){let n,r;const o=this.centerPoint;if("globe"===this.projection.name){const e=this.worldSize;n=(i.x-o.x)/e,r=(i.y-o.y)/e}else{const e=this.pointCoordinate(i),t=this.pointCoordinate(o);n=e.x-t.x,r=e.y-t.y}const s=this.locationCoordinate(t);this.setLocation(new e.ae(s.x-n,s.y-r))}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(t,i){const n=i?e.ce(i,t.lat):void 0,r=this.projection.project(t.lng,t.lat);return new e.ae(r.x,r.y,n)}coordinateLocation(e){return this.projection.unproject(e.x,e.y)}pointRayIntersection(t,i){const n=null!=i?i:this._centerAltitude,r=[t.x,t.y,0,1],o=[t.x,t.y,1,1];e.aC(r,r,this.pixelMatrixInverse),e.aC(o,o,this.pixelMatrixInverse);const s=o[3];e.cJ(r,r,1/r[3]),e.cJ(o,o,1/s);const a=r[2],l=o[2];return{p0:r,p1:o,t:a===l?0:(n-a)/(l-a)}}screenPointToMercatorRay(t){const i=[t.x,t.y,0,1],n=[t.x,t.y,1,1];return e.aC(i,i,this.pixelMatrixInverse),e.aC(n,n,this.pixelMatrixInverse),e.cJ(i,i,1/i[3]),e.cJ(n,n,1/n[3]),i[2]=e.ce(i[2],this._center.lat)*this.worldSize,n[2]=e.ce(n[2],this._center.lat)*this.worldSize,e.cJ(i,i,1/this.worldSize),e.cJ(n,n,1/this.worldSize),new e.ax([i[0],i[1],i[2]],e.aw([],e.av([],n,i)))}rayIntersectionCoordinate(t){const{p0:i,p1:n,t:r}=t,o=e.ce(i[2],this._center.lat),s=e.ce(n[2],this._center.lat);return new e.ae(e.ak(i[0],n[0],r)/this.worldSize,e.ak(i[1],n[1],r)/this.worldSize,e.ak(o,s,r))}pointCoordinate(e,t=this._centerAltitude){return this.projection.pointCoordinate(this,e.x,e.y,t)}pointCoordinate3D(t,i){if(!this.elevation)return this.pointCoordinate(t,i);let n=this.projection.pointCoordinate3D(this,t.x,t.y);if(n)return new e.ae(n[0],n[1],n[2]);let r=0,o=this.horizonLineFromTop();if(t.y>o)return this.pointCoordinate(t,i);const s=.02*o,a=t.clone();for(let t=0;t<10&&o-r>s;t++){a.y=e.ak(r,o,.66);const t=this.projection.pointCoordinate3D(this,a.x,a.y);t?(o=a.y,n=t):r=a.y}return n?new e.ae(n[0],n[1],n[2]):this.pointCoordinate(t)}isPointAboveHorizon(e){return this.projection.isPointAboveHorizon(this,e)}isPointOnSurface(t){if(t.y<0||t.y>this.height||t.x<0||t.x>this.width)return!1;if(this.elevation||this.zoom>=e.cK)return!this.isPointAboveHorizon(t);const i=this.pointCoordinate(t);return i.y>=0&&i.y<=1}_coordinatePoint(t,i){const n=i&&this.elevation?this.elevation.getAtPointOrZero(t,this._centerAltitude):this._centerAltitude,r=[t.x*this.worldSize,t.y*this.worldSize,n+t.toAltitude(),1];return e.aC(r,r,this.pixelMatrix),r[3]>0?new e.P(r[0]/r[3],r[1]/r[3]):new e.P(Number.MAX_VALUE,Number.MAX_VALUE)}_getBoundsNonRectangular(){const{top:t,left:i}=this._edgeInsets,n=this.height-this._edgeInsets.bottom,r=this.width-this._edgeInsets.right,o=this.pointLocation3D(new e.P(i,t)),s=this.pointLocation3D(new e.P(r,t)),a=this.pointLocation3D(new e.P(r,n)),l=this.pointLocation3D(new e.P(i,n));let c=Math.min(o.lng,s.lng,a.lng,l.lng),u=Math.max(o.lng,s.lng,a.lng,l.lng),h=Math.min(o.lat,s.lat,a.lat,l.lat),d=Math.max(o.lat,s.lat,a.lat,l.lat);const p=Math.pow(2,-this.zoom)/16*270,f="globe"===this.projection.name?1:4,m=(t,i,n,r,o)=>{const s=(t+n)/2,a=(i+r)/2,l=new e.P(s,a),{lng:g,lat:_}=this.pointLocation3D(l),A=Math.max(0,c-g,h-_,g-u,_-d);c=Math.min(c,g),u=Math.max(u,g),h=Math.min(h,_),d=Math.max(d,_),(op)&&(m(t,i,s,a,o+1),m(s,a,n,r,o+1))};if(m(i,t,r,t,1),m(r,t,r,n,1),m(r,n,i,n,1),m(i,n,i,t,1),"globe"===this.projection.name){const[t,i]=e.cL(this);t?(d=90,u=180,c=-180):i&&(h=-90,u=180,c=-180)}return new e.aI(new e.aS(c,h),new e.aS(u,d))}_getBoundsRectangular(t,i){const{top:n,left:r}=this._edgeInsets,o=this.height-this._edgeInsets.bottom,s=this.width-this._edgeInsets.right,a=new e.P(r,n),l=new e.P(s,n),c=new e.P(s,o),u=new e.P(r,o);let h=this.pointCoordinate(a,t),d=this.pointCoordinate(l,t);const p=this.pointCoordinate(c,i),f=this.pointCoordinate(u,i),m=(e,t)=>(t.y-e.y)/(t.x-e.x);return h.y>1&&d.y>=0?h=new e.ae((1-f.y)/m(f,h)+f.x,1):h.y<0&&d.y<=1&&(h=new e.ae(-f.y/m(f,h)+f.x,0)),d.y>1&&h.y>=0?d=new e.ae((1-p.y)/m(p,d)+p.x,1):d.y<0&&h.y<=1&&(d=new e.ae(-p.y/m(p,d)+p.x,0)),(new e.aI).extend(this.coordinateLocation(h)).extend(this.coordinateLocation(d)).extend(this.coordinateLocation(f)).extend(this.coordinateLocation(p))}_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(t){this.maxBounds=t,this.minLat=-e.cI,this.maxLat=e.cI,this.minLng=-180,this.maxLng=180,t&&(this.minLat=t.getSouth(),this.maxLat=t.getNorth(),this.minLng=t.getWest(),this.maxLng=t.getEast(),this.maxLngh&&(a=h-c),h-ut&&(s=t-l),t-e{for(let o=0;o<16;o++)t[o]=e.ak(i[o],n[o],r)})(a,a,l,e.c$(this.pitch>=sn?1:this.pitch/sn))}else a=l;const c=e.cO([],l,s);let u=e.cO([],a,s);if(this.projection.isReprojectedInTileSpace){const t=this.locationCoordinate(this.center),i=e.bz([]);e.bq(i,i,[t.x*this.worldSize,t.y*this.worldSize,0]),e.aB(i,i,e.cP(this)),e.bq(i,i,[-t.x*this.worldSize,-t.y*this.worldSize,0]),e.aB(u,u,i),e.aB(c,c,i),this.inverseAdjustmentMatrix=e.cQ(this)}else this.inverseAdjustmentMatrix=[1,0,0,1];if(this.mercatorMatrix=e.cR([],u,[this.worldSize,this.worldSize,this.worldSize/o,1]),this.projMatrix=u,this.invProjMatrix=e.bk(new Float64Array(16),this.projMatrix),i){const i=this._camera.getCameraToClipPerspective(this._fov,this.width/this.height,this._nearZ,1/0);i[8]=2*-t.x/this.width,i[9]=2*t.y/this.height,this.expandedFarZProjMatrix=e.cO([],i,s)}else this.expandedFarZProjMatrix=this.projMatrix;const h=e.bk([],a);this.frustumCorners=e.cS.fromInvProjectionMatrix(h,this.horizonLineFromTop(),this.height),this.cameraFrustum=e.cA.fromInvProjectionMatrix(this.invProjMatrix,this.worldSize,0,!i);const d=new Float32Array(16);e.bz(d),e.cR(d,d,[1,-1,1]),e.cT(d,d,this._pitch),e.bA(d,d,this.angle);const p=e.cc(new Float32Array(16),this._fov,this.width/this.height,this._nearZ,this._farZ);this.starsProjMatrix=e.by(p);const f=(Math.PI/2-this._pitch)*(this.height/this._fov)*this._horizonShift;p[8]=2*-t.x/this.width,p[9]=2*(t.y+f)/this.height,this.skyboxMatrix=e.aB(d,p,d);const m=this.point,g=m.x,_=m.y,A=this.width%2/2,y=this.height%2/2,v=Math.cos(this.angle),x=Math.sin(this.angle),b=g-Math.round(g)+v*A+x*y,w=_-Math.round(_)+v*y+x*A,T=new Float64Array(u);if(e.bq(T,T,[b>.5?b-1:b,w>.5?w-1:w,0]),this.alignedProjMatrix=T,u=e.bB(),e.cR(u,u,[this.width/2,-this.height/2,1]),e.bq(u,u,[1,-1,0]),this.labelPlaneMatrix=u,u=e.bB(),e.cR(u,u,[1,-1,1]),e.bq(u,u,[-1,-1,0]),e.cR(u,u,[2/this.width,2/this.height,1]),this.glCoordMatrix=u,this.pixelMatrix=e.aB(new Float64Array(16),this.labelPlaneMatrix,c),this._calcFogMatrices(),this._distanceTileDataCache={},u=e.bk(new Float64Array(16),this.pixelMatrix),!u)throw new Error("failed to invert matrix");if(this.pixelMatrixInverse=u,"globe"===this.projection.name||this.mercatorFromTransition){this.globeMatrix=e.cU(this);const t=[this.globeMatrix[12],this.globeMatrix[13],this.globeMatrix[14]];this.globeCenterInViewSpace=e.af(t,t,s),this.globeRadius=this.worldSize/2/Math.PI-1}else this.globeMatrix=u;this._projMatrixCache={},this._alignedProjMatrixCache={},this._pixelsToTileUnitsCache={},this._expandedProjMatrixCache={}}_calcFogMatrices(){this._fogTileMatrixCache={};const t=this.cameraWorldSizeForFog,i=this.cameraPixelsPerMeter,n=this._camera.position,r=1/this.height/this._pixelsPerMercatorPixel,o=[t,t,i];e.c4(o,o,r),e.c4(n,n,-1),e.cV(n,n,o);const s=e.bB();e.bq(s,s,n),e.cR(s,s,o),this.mercatorFogMatrix=s,this.worldToFogMatrix=this._camera.getWorldToCameraPosition(t,i,r)}_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(t){const i=this._maxCameraBoundsDistance()*Math.cos(this._pitch),n=this._camera.position[2],r=t[2];let o=1;this.projection.wrap&&(this.center=this.center.wrap()),r>0&&(o=Math.min((i-n)/r,1)),this._camera.position=e.bG([],this._camera.position,t,o),this._updateStateFromCamera()}_updateStateFromCamera(){const t=this._camera.position,i=this._camera.forward(),{pitch:n,bearing:r}=this._camera.getPitchBearing(),o=e.ce(this._centerAltitude,this.center.lat)*this._pixelsPerMercatorPixel,s=this._mercatorZfromZoom(this._maxZoom)*Math.cos(e.an(this._maxPitch)),a=Math.max((t[2]-o)/Math.cos(n),s),l=this._zoomFromMercatorZ(a);e.bG(t,t,i,a),this._pitch=e.aA(n,e.an(this.minPitch),e.an(this.maxPitch)),this.angle=e.bS(r,-Math.PI,Math.PI),this._setZoom(e.aA(l,this._minZoom,this._maxZoom)),this._updateSeaLevelZoom(),this._center=this.coordinateLocation(new e.ae(t[0],t[1],t[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(null!=this._seaLevelZoom?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(t){let i=0,n=e.cK,r=0,o=1/0;for(;n-i>1e-6&&n>i;){const e=i+.5*(n-i),s=this.tileSize*Math.pow(2,e),a=this.getCameraToCenterDistance(this.projection,e,s),l=this.scaleZoom(a/(Math.max(0,t)*this.tileSize)),c=Math.abs(e-l);cc||i.y>1)return!0}return!1}isHorizonVisible(){return this.pitch+e.cW(this.fovAboveCenter)>88||this.anyCornerOffEdge(new e.P(0,0),new e.P(this.width,this.height))}zoomDeltaToMovement(t,i){const n=e.ag(e.av([],this._camera.position,t)),r=this._zoomFromMercatorZ(n)+i;return n-this._mercatorZfromZoom(r)}getCameraPoint(){if("globe"===this.projection.name){const t=function([t,i,n],r){const o=[t,i,n,1];e.aC(o,o,r);const s=o[3]=Math.max(o[3],1e-6);return o[0]/=s,o[1]/=s,o[2]/=s,o}([this.globeMatrix[12],this.globeMatrix[13],this.globeMatrix[14]],this.pixelMatrix);return new e.P(t[0],t[1])}{const t=Math.tan(this._pitch)*(this.cameraToCenterDistance||1);return this.centerPoint.add(new e.P(0,t))}}getCameraToCenterDistance(t,i=this.zoom,n=this.worldSize){const r=e.cN(t,i,this.width,this.height,1024),o=t.pixelSpaceConversion(this.center.lat,n,r);let s=.5/Math.tan(.5*this._fov)*this.height*o;return this.isOrthographic&&(s=e.ak(1,s,e.c$(this.pitch>=sn?1:this.pitch/sn))),s}getWorldToCameraMatrix(){const t=this._camera.getWorldToCamera(this.worldSize,"meters"===this.projection.zAxisUnit?this.pixelsPerMeter:1);return"globe"===this.projection.name&&e.aB(t,t,this.globeMatrix),t}getFrustum(t){return e.cA.fromInvProjectionMatrix(this.invProjMatrix,this.worldSize,t,"meters"===this.projection.zAxisUnit)}}const ln=(t,i)=>{if(i>0&&t.terrain&&e.w("Cutoff is currently disabled on terrain"),i<=0||t.terrain)return{shouldRenderCutoff:!1,uniformValues:{u_cutoff_params:[0,0,0,1]}};const n=t.transform,r=Math.max(Math.abs(n._zoom-(t.minCutoffZoom-1)),1),o=n.isLODDisabled(!1)?e.ah(60,45,n.pitch):e.ah(30,15,n.pitch),s=n._farZ-n._nearZ,a=i*n.height,l=((1-(c=o))*n.cameraToCenterDistance+c*(n._farZ+a))*r;var c;return{shouldRenderCutoff:o<1,uniformValues:{u_cutoff_params:[n._nearZ,n._farZ,(l-n._nearZ)/s,(l-a-n._nearZ)/s]}}},cn={cascadeCount:2,normalOffset:3,shadowMapResolution:2048};class un{constructor(e,t){this.aabb=e,this.lastCascade=t}}class hn{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 un(t,null)}clear(){this.receivers={}}get(e){return this.receivers[e.key]}computeRequiredCascades(t,i,n){const r=e.d8.fromPoints(t.points);let o=0;for(const t in this.receivers){const s=this.receivers[t];if(!s)continue;if(!r.intersectsAabb(s.aabb))continue;s.aabb.min=r.closestPoint(s.aabb.min),s.aabb.max=r.closestPoint(s.aabb.max);const a=s.aabb.getCorners();for(let t=0;t1||s[1]<-1||s[1]>1){r=!1;break}}if(s.lastCascade=t,o=Math.max(o,t),r)break}}return o+1}}class dn{constructor(e){this.painter=e,this._enabled=!1,this._shadowLayerCount=0,this._numCascadesToRender=0,this._cascades=[],this._groundShadowTiles=[],this._receivers=new hn,this._depthMode=new $i(e.context.gl.LEQUAL,$i.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.useNormalOffset=!1,e.tp.registerParameter(this,["Shadows"],"_forceDisable",{label:"forceDisable"},()=>{this.painter.style.map.triggerRepaint()}),e.tp.registerParameter(cn,["Shadows"],"cascadeCount",{min:1,max:2,step:1}),e.tp.registerParameter(cn,["Shadows"],"normalOffset",{min:0,max:10,step:.05}),e.tp.registerParameter(cn,["Shadows"],"shadowMapResolution",{min:32,max:2048,step:32}),e.tp.registerBinding(this,["Shadows"],"_numCascadesToRender",{readonly:!0,label:"numCascadesToRender"})}destroy(){for(const e of this._cascades)e.texture.destroy(),e.framebuffer.destroy();this._cascades=[]}updateShadowParameters(t,i){const n=this.painter;if(this._enabled=!1,this._shadowLayerCount=0,this._receivers.clear(),!i||!i.properties)return;const r=i.properties.get("shadow-intensity");if(!i.shadowsEnabled()||r<=0)return;if(this._shadowLayerCount=n.style.order.reduce((e,i)=>{const r=n.style._mergedLayers[i];return e+(r.hasShadowPass()&&!r.isHidden(t.zoom)?1:0)},0),this._enabled=this._shadowLayerCount>0,!this.enabled)return;const o=n.context,s=cn.shadowMapResolution,a=cn.shadowMapResolution;if(0===this._cascades.length||cn.shadowMapResolution!==this._cascades[0].texture.size[0]){this._cascades=[];for(let t=0;te.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]&&(l=(i[1]-i[0])*e.exaggeration())}const c=1.5*t.cameraToCenterDistance,u=3*c,h=new Float64Array(16);for(let i=0;i=0)return{};const o=function(t,i,n){const r=n/(1<0&&(e.d7(o[1],o[1],[r[0]*s,0,0]),e.d7(o[2],o[2],[r[0]*s,0,0])),r[1]<0?(e.d7(o[0],o[0],[0,r[1]*s,0]),e.d7(o[1],o[1],[0,r[1]*s,0])):r[1]>0&&(e.d7(o[2],o[2],[0,r[1]*s,0]),e.d7(o[3],o[3],[0,r[1]*s,0]));const a={};return a.vertices=o,a.planes=[pn(o[1],o[0],o[4]),pn(o[2],o[1],o[5]),pn(o[3],o[2],o[6]),pn(o[0],o[3],o[7])],a}addShadowReceiver(t,i,n){this._receivers.add(t,e.d8.fromTileIdAndHeight(t,i,n))}getMaxCascadeForTile(e){const t=this._receivers.get(e);return t&&t.lastCascade?t.lastCascade:0}}function pn(t,i,n){const r=e.av([],n,i),o=e.av([],t,i),s=e.bH([],r,o),a=e.ag(s);return 0===a?[0,0,1,0]:(e.c4(s,s,1/a),[s[0],s[1],s[2],-e.bI(s,i)])}function fn(t){const i=t.properties.get("direction"),n=e.d3(i.x,i.y,i.z);n[2]=e.aA(n[2],0,75);const r=e.d5([n[0],n[1],n[2]]);return e.d4(r.x,r.y,r.z)}function mn(t,i,n){const r="none"===i.properties.get("color-use-theme"),o=i.properties.get("color"),s=i.properties.get("intensity"),a=i.properties.get("direction"),l=[a.x,a.y,a.z],c="none"===n.properties.get("color-use-theme"),u=n.properties.get("color"),h=n.properties.get("intensity"),d=Math.max(e.bI([0,0,1],l),0),p=[0,0,0];e.c4(p,u.toPremultipliedRenderColor(c?null:t.getLut(i.scope)).toArray01Linear().slice(0,3),h);const f=[0,0,0];return e.c4(f,o.toPremultipliedRenderColor(r?null:t.getLut(n.scope)).toArray01Linear().slice(0,3),d*s),e.da([p[0]>0?p[0]/(p[0]+f[0]):0,p[1]>0?p[1]/(p[1]+f[1]):0,p[2]>0?p[2]/(p[2]+f[2]):0])}function gn(t,i,n,r,o,s){const a=t.zoom,l=t.scale,c=t.worldSize,u=1/c,h=t.aspect,d=Math.sqrt(1+h*h)*Math.tan(.5*t.fovX),p=d*d,f=r-n,m=r+n;let g,_;p>f/m?(g=r,_=r*d):(g=.5*m*(1+p),_=.5*Math.sqrt(f*f+2*(r*r+n*n)*p+m*m*p*p));const A=t.projection.pixelsPerMeter(t.center.lat,c),y=t._camera.getCameraToWorldMercator(),v=[0,0,-g*u];e.af(v,v,y);let x=_*u;const b=t._edgeInsets;if(!(0===b.left&&0===b.top&&0===b.right&&0===b.bottom||b.left===b.right&&b.top===b.bottom)){const i=t._camera.getWorldToCamera(t.worldSize,"meters"===t.projection.zAxisUnit?A:1),o=t._camera.getCameraToClipPerspective(t._fov,t.width/t.height,n,r);o[8]=2*-t.centerOffset.x/t.width,o[9]=2*t.centerOffset.y/t.height;const s=new Float64Array(16);e.cO(s,o,i);const u=new Float64Array(16);e.bk(u,s);const h=e.cA.fromInvProjectionMatrix(u,c,a,!0);for(const i of h.points){const n=((w=i)[0]/=l,w[1]/=l,w[2]=e.ce(w[2],t._center.lat),w);x=Math.max(x,e.c5(e.d9([],v,n)))}}var w;x*=o/(o-1);const T=Math.acos(i[2]),E=Math.atan2(-i[0],-i[1]),C=new nn;C.position=v,C.setPitchBearing(T,E);const S=C.getWorldToCamera(c,A),B=x*c,I=Math.min(t._mercatorZfromZoom(17)*c*-2,-2*B),M=C.getCameraToClipOrthographic(-B,B,-B,B,I,(B+s*A)/i[2]),P=new Float64Array(16);e.aB(P,M,S);const R=e.d4(Math.floor(1e6*v[0])/1e6*c,Math.floor(1e6*v[1])/1e6*c,0),L=.5*o,F=[0,0,0];e.af(F,R,P),e.c4(F,F,L);const k=[Math.floor(F[0]),Math.floor(F[1]),Math.floor(F[2])],D=[0,0,0];e.av(D,F,k),e.c4(D,D,-1/L);const O=new Float64Array(16);return e.bz(O),e.bq(O,O,D),e.aB(P,O,P),[P,B]}class _n extends e.E{constructor(e){super(),this.requestManager=e,this.models={"":{}},this.modelUris={"":{}},this.modelByURL={},this.numModelsLoading={}}loadModel(t,i){return e.db(this.requestManager.transformRequest(i,e.R.Model).url).then(n=>{if(!n)return;const r=e.dc(n),o=new e.dd(t,i,void 0,void 0,r);return o.computeBoundsAndApplyParent(),o}).catch(n=>{if(n&&404===n.status)return null;this.fire(new e.y(new Error(`Could not load model ${t} from ${i}: ${n.message}`)))})}load(t,i,n={forceReload:!1}){this.models[i]||(this.models[i]={});const r=Object.keys(t),o=[],s=[];for(const e of r){const r=t[e];this.hasURLBeenRequested(r)&&!n.forceReload||(this.modelByURL[r]={modelId:e,scope:i},o.push(this.loadModel(e,r)),s.push(e)),this.models[i][e]||(this.models[i][e]={model:null,numReferences:1})}this.numModelsLoading[i]=(this.numModelsLoading[i]||0)+s.length,Promise.allSettled(o).then(t=>{for(let e=0;e{this.fire(new e.y(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]={}),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]||{}}addModel(e,t,i){this.models[i]||(this.models[i]={}),this.modelUris[i]||(this.modelUris[i]={});const n=this.requestManager.normalizeModelURL(t);if((this.hasModel(e,i,{exactIdMatch:!0})||this.hasModelBeenAdded(e,i))&&this.modelUris[i][e]===n)this.models[i][e].numReferences++;else if(this.hasURLBeenRequested(n)){const{scope:e,modelId:t}=this.modelByURL[n];this.models[e][t].numReferences++}else this.modelUris[i][e]=n,this.load({[e]:this.modelUris[i][e]},i)}addModelURLs(e,t){this.models[t]||(this.models[t]={}),this.modelUris[t]||(this.modelUris[t]={});const i=this.modelUris[t];for(const t in e)i[t]=this.requestManager.normalizeModelURL(e[t])}reloadModels(e){this.load(this.modelUris[e],e,{forceReload:!0})}addModelsFromBucket(t,i){this.models[i]||(this.models[i]={}),this.modelUris[i]||(this.modelUris[i]={});const n={};for(const r of t)this.hasModel(r,i,{exactIdMatch:!0})||this.hasURLBeenRequested(r)?this.models[i][r].numReferences++:this.modelUris[i][r]&&!this.hasURLBeenRequested(r)?n[r]=this.modelUris[i][r]:!this.hasURLBeenRequested(r)&&e.de(r,!1)&&(this.modelUris[i][r]=this.requestManager.normalizeModelURL(r),n[r]=this.modelUris[i][r]);this.load(n,i)}hasURLBeenRequested(e){return void 0!==this.modelByURL[e]}removeModel(e,t,i=!1,n=!1){if(this.models[t]&&this.models[t][e]&&(this.models[t][e].numReferences--,0===this.models[t][e].numReferences||n)){const n=this.modelUris[t][e];i||delete this.modelUris[t][e],delete this.modelByURL[n];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={"":{}},this.modelUris={"":{}},this.modelByURL={},this.numModelsLoading={}}listModels(e){return this.models[e]||(this.models[e]={}),Object.keys(this.models[e])}upload(e,t){this.models[t]||(this.models[t]={});for(const i in this.models[t])this.models[t][i].model&&this.models[t][i].model.upload(e.context)}}const An=e.a6.colorTheme,yn=new e.a9({data:new e.aa(An.data)});function vn(t){if(!t.metadata||!t.metadata.content_area)return;const i=e.o.devicePixelRatio,{left:n,top:r,width:o,height:s}=t.metadata.content_area,a=n*i,l=r*i;return[a,l,a+o*i,l+s*i]}function xn(t){if(t)return t.map(([t,i])=>[t*e.o.devicePixelRatio,i*e.o.devicePixelRatio])}class bn{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 n=this.sourceCache.getSource();if(!(n instanceof ht))return t;const r=i.map(e=>this.sourceCache.getTile(e)),o=n.getImages(r,Array.from(this.pendingRequests));for(const[i,n]of o)t.set(e.I.from({name:i,iconsetId:this.id}),n),this.pendingRequests.delete(i);for(const e of this.pendingRequests)this.missingRequests.add(e);return this.pendingRequests.clear(),t}}const wn=(e,t)=>Le(e,t&&t.filter(e=>"source.canvas"!==e.identifier)),Tn=e.aH(Nt,["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"]),En=e.aH(Nt,["setCenter","setZoom","setBearing","setPitch"]),Cn=new Set(["background","sky","slot","custom"]),Sn={version:8,layers:[],sources:{}},Bn={duration:300,delay:0};class In 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=Object.assign({},Bn),this._buildingIndex=new Ot(this),this.crossTileSymbolIndex=new Gi,this._mergedOrder=[],this._drapedFirstOrder=[],this._mergedLayers={},this._mergedIndoor={},this._mergedSourceCaches={},this._mergedOtherSourceCaches={},this._mergedSymbolSourceCaches={},this._clipLayerPresent=!1,this._hasAppearances=!1,this._has3DLayers=!1,this._hasCircleLayers=!1,this._hasSymbolLayers=!1,this._importedAsBasemap=!1,this._changes=i.styleChanges||new H,this.dispatcher=i.dispatcher?i.dispatcher:new e.D(e.dg(),this),i.imageManager?this.imageManager=i.imageManager:(this.imageManager=new $(this.map._spriteFormat),this.imageManager.setEventedParent(this)),this.imageManager.addScope(this.scope),this.glyphManager=i.glyphManager?i.glyphManager:new e.dh(t._requestManager,i.localFontFamily?e.di.all:i.localIdeographFontFamily?e.di.ideographs:e.di.none,i.localFontFamily||i.localIdeographFontFamily),i.modelManager?this.modelManager=i.modelManager:(this.modelManager=new _n(t._requestManager),this.modelManager.setEventedParent(this)),this._layers={},this._sourceCaches={},this._otherSourceCaches={},this._symbolSourceCaches={},this._loaded=!1,this._precompileDone=!1,this._shouldPrecompile=!1,this._availableImages=[],this._availableModels={},this._order=[],this._markersNeedUpdate=!1,this.options=i.configOptions?i.configOptions:new Map,this._configDependentLayers=i.configDependentLayers?i.configDependentLayers:new Set,this._indoorDependentLayers=i.indoorDependentLayers?i.indoorDependentLayers:new Set,this._config=i.config,this._styleColorTheme={lut:null,lutLoading:!1,lutLoadingCorrelationID:0,colorTheme:null,colorThemeOverride:i.colorThemeOverride},this._styleColorThemeForScope={},this._initialConfig=i.initialConfig,this.dispatcher.broadcast("setReferrer",e.dj());const n=this;this._rtlTextPluginCallback=In.registerForPluginStateChange(t=>{n.dispatcher.broadcast("syncRTLPluginState",{pluginStatus:t.pluginStatus,pluginURL:t.pluginURL},(t,i)=>{if(e.dk(t),i&&i.every(e=>e))for(const e in n._sourceCaches){const t=n._sourceCaches[e],i=t.getSource().type;"vector"!==i&&"geojson"!==i||t.reload()}})}),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.h(t))return t;const i=e.dl(t);if(!i.startsWith("http"))try{return new URL(i,location.href).toString()}catch(e){return i}return i}return`json://${e.dm(JSON.stringify(t))}`}_diffStyle(t,i,n){this.globalId=this._getGlobalId(t);const r=(e,t)=>{try{t(null,this.setState(e,n))}catch(e){t(e,!1)}};if("string"==typeof t){const n=this.map._requestManager.normalizeStyleURL(t),o=this.map._requestManager.transformRequest(n,e.R.Style);e.m(o,(t,n)=>{t?this.fire(new e.y(t)):n&&r(n,i)})}else"object"==typeof t&&r(t,i)}loadURL(t,i={}){this.fire(new e.z("dataloading",{dataType:"style"}));const n="boolean"==typeof i.validate?i.validate:!e.h(t);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 this._load(r,n);const o=this.map._requestManager.transformRequest(t,e.R.Style);this._request=e.m(o,(i,r)=>{if(this._request=null,i)this.fire(new e.y(i));else if(r)return this.importsCache.set(t,r),this._load(r,n)})}loadJSON(t,i={}){this.fire(new e.z("dataloading",{dataType:"style"})),this.globalId=this._getGlobalId(t),this._request=e.o.frame(()=>{this._request=null,this._load(t,!1!==i.validate)})}loadEmpty(){this.fire(new e.z("dataloading",{dataType:"style"})),this._load(Sn,!1)}_loadImports(t,i,n){if(this.importDepth>=4)return e.w("Style doesn't support nesting deeper than 5"),Promise.resolve();const r=[];for(const e of t){const t=this._createFragmentStyle(e),o=new Promise(e=>{t.once("style.import.load",e),t.once("error",e)}).then(()=>this.mergeAll());if(r.push(o),this.resolvedImports.has(e.url)){t.loadEmpty();continue}const s=e.data||this.importsCache.get(e.url);s?(t.loadJSON(s,{validate:i}),this._isInternalStyle(s)&&(t.globalId=null)):e.url?t.loadURL(e.url,{validate:i}):t.loadEmpty();const a={style:t,id:e.id,config:e.config};if(n){const e=this.fragments.findIndex(({id:e})=>e===n);this.fragments=this.fragments.slice(0,e).concat(a).concat(this.fragments.slice(e))}else this.fragments.push(a)}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.B(t.id,this.scope):t.id;let n;const r=this._initialConfig&&this._initialConfig[i];(t.config||r)&&(n=Object.assign({},t.config,r));const o=new In(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:n,configOptions:this.options,colorThemeOverride:t["color-theme"],configDependentLayers:this._configDependentLayers,indoorDependentLayers:this._indoorDependentLayers});return o.setEventedParent(this.map,{style:o}),o}_reloadImports(){this.mergeAll(),this._updateMapProjection(),this.updateConfigDependencies(),this._updateLayers(this._indoorDependentLayers),this.map._triggerCameraUpdate(this.camera),this.dispatcher.broadcast("setLayers",{layers:this._serializeLayers(this._order),scope:this.scope,options:this.options}),this._shouldPrecompile=this.map._precompilePrograms&&this.isRootStyle()}_isInternalStyle(e){return this.isRootStyle()&&(e.fragment||!!e.schema&&!1!==e.fragment)}_load(t,i){if(this._isInternalStyle(t)){const e=Object.assign({},Sn,{imports:[{id:"basemap",data:t,url:""}]},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(e,i)}if(this.updateConfig(this._config,t.schema),i&&wn(this,ye(t)))return;this._loaded=!0,this.stylesheet=e.dn(t);const n=()=>{for(const e in t.sources)this.addSource(e,t.sources[e],{validate:!1,isInitialLoad:!0});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,isLoaded:!0})),!this.glyphManager.url&&t.glyphs&&this.glyphManager.setURL(t.glyphs);const n=Ut(this.stylesheet.layers);if(this._order=n.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 De(e.properties,e.id)}else this.setLights(this.stylesheet.lights);this.light||(this.light=new De(this.stylesheet.light)),this._layers={};for(const t of n){const i=e.dt(t,this.scope,this._styleColorTheme.lut,this.options);0!==i.expressionDependencies.configDependencies.size&&this._configDependentLayers.add(i.fqid),i.expressionDependencies.isIndoorDependent&&this._indoorDependentLayers.add(i.fqid),this._hasAppearances=this._hasAppearances||0!==i.getAppearances().length,i.setEventedParent(this,{layer:{id:i.id}}),this._layers[i.id]=i;const n=this.getOwnLayerSourceCache(i),r=!!this.directionalLight&&this.directionalLight.shadowsEnabled();n&&i.canCastShadows()&&r&&(n.castsShadows=!0)}this.stylesheet.featuresets&&this.setFeaturesetSelectors(this.stylesheet.featuresets),this.stylesheet.models&&this.addModelURLs(this.stylesheet.models);const r=this.stylesheet.terrain;r&&(this.checkCanvasFingerprintNoise(),this.disableElevatedTerrain||this.terrainSetForDrapingOnly()||this._createTerrain(r,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.z("data",{dataType:"style"}));const o=this.isRootStyle();t.imports?this._loadImports(t.imports,i).then(()=>{this._reloadImports(),this.fire(new e.z(o?"style.load":"style.import.load"))}).catch(t=>{this.fire(new e.y(new Error("Failed to load imports",t))),this.fire(new e.z(o?"style.load":"style.import.load"))}):(this._reloadImports(),this.fire(new e.z(o?"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(()=>{n()}).catch(t=>{e.w(`Couldn't load color theme from the stylesheet: ${t}`),n()})}else this._styleColorTheme.lut=null,n()}isRootStyle(){return 0===this.importDepth}hasAppearances(){return this._hasAppearances}mergeAll(){let e,t,i,n,r,o,s,a,l,c;const u={};this.terrain&&this.terrain.scope!==this.scope&&delete this.terrain,this.forEachFragmentStyle(h=>{if(h.stylesheet){if(null!=h.light&&(e=h.light),h.stylesheet.lights)for(const e of h.stylesheet.lights)"ambient"===e.type&&null!=h.ambientLight&&(t=h.ambientLight),"directional"===e.type&&null!=h.directionalLight&&(i=h.directionalLight);n=this._prioritizeTerrain(n,h.terrain,h.stylesheet.terrain),h.stylesheet.fog&&null!=h.fog&&(r=h.fog),h.stylesheet.snow&&null!=h.snow&&(o=h.snow),h.stylesheet.rain&&null!=h.rain&&(s=h.rain),null!=h.stylesheet.camera&&(c=h.stylesheet.camera),null!=h.stylesheet.projection&&(a=h.stylesheet.projection),null!=h.stylesheet.transition&&(l=h.stylesheet.transition),u[h.scope]=h._styleColorTheme}}),this.light=e,this.ambientLight=t,this.directionalLight=i,this.fog=r,this.snow=o,this.rain=s,this._styleColorThemeForScope=u,null===n?delete this.terrain:this.terrain=n,this.camera=c||{"camera-projection":"perspective"},this.projection=a||{name:"mercator"},this.transition=Object.assign({},Bn,l),this.mergeSources(),this.mergeLayers(),this.mergeIndoor()}forEachFragmentStyle(e){const t=i=>{for(const e of i.fragments)t(e.style);e(i)};t(this)}_prioritizeTerrain(e,t,i){const n=e&&0===e.drapeRenderMode;return null===i?t&&0===t.drapeRenderMode?t:n?e:null:null!=t&&(!e||n||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}mergeProjection(){let e;this.forEachFragmentStyle(t=>{null!=t.stylesheet.projection&&(e=t.stylesheet.projection)}),this.projection=e||{name:"mercator"}}mergeSources(){const t={},i={},n={};this.forEachFragmentStyle(r=>{for(const i in r._sourceCaches){const n=e.B(i,r.scope);t[n]=r._sourceCaches[i]}for(const t in r._otherSourceCaches){const n=e.B(t,r.scope);i[n]=r._otherSourceCaches[t]}for(const t in r._symbolSourceCaches){const i=e.B(t,r.scope);n[i]=r._symbolSourceCaches[t]}}),this._mergedSourceCaches=t,this._mergedOtherSourceCaches=i,this._mergedSymbolSourceCaches=n}mergeIndoor(){this.forEachFragmentStyle(t=>{if(t.stylesheet&&t.stylesheet.indoor)for(const i of Object.values(t.stylesheet.indoor)){const n=i,r=e.B(n.sourceId,t.scope);this._mergedIndoor[r]=new Set(n.sourceLayers||[])}})}mergeLayers(){const t={},i=[],n={};this._mergedSlots=[],this._has3DLayers=!1,this._hasCircleLayers=!1,this._hasSymbolLayers=!1,this.forEachFragmentStyle(n=>{for(const r of n._order){const o=n._layers[r];if("slot"===o.type){const i=e.dp(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 s of i)if("slot"===s.type){const i=e.dp(s.id);t[i]&&o(t[i]),this._mergedSlots.push(i)}else{const t=e.B(s.id,s.scope);this._mergedOrder.push(t),n[t]=s,s.is3D(!!this.terrain)&&(this._has3DLayers=!0,r=this._mergedOrder.length-1),"circle"===s.type&&(this._hasCircleLayers=!0),"symbol"===s.type&&(this._hasSymbolLayers=!0),"clip"===s.type&&(this._clipLayerPresent=!0)}};if(o(i),this._has3DLayers){const e={};for(let t=0;te[t]-e[i])}this._mergedLayers=n,this.updateDrapeFirstLayers(),this._buildingIndex.processLayersChanged()}terrainSetForDrapingOnly(){return!!this.terrain&&0===this.terrain.drapeRenderMode}getCamera(){return this.stylesheet.camera}setCamera(e){return this.stylesheet.camera=Object.assign({},this.stylesheet.camera,e),this.camera=this.stylesheet.camera,this}_evaluateColorThemeData(t){return t.data?function(t,i,n){const r=Object.assign({},i);for(const e of Object.keys(An))void 0===r[e]&&(r[e]=An[e].default);const o=new e.a8(yn,t,new Map(n));return o.setTransitionOrValue(r,n),o.untransitioned().possiblyEvaluate(new e.ac(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((n,r)=>{const o="data:image/png;base64,";if(!t||0===t.length)return this._styleColorTheme.lut=null,this._styleColorTheme.lutLoading=!1,void n();let s=t;s.startsWith(o)||(s=o+s);const a=e.I.from("mapbox-reserved-lut"),l=new Image;l.src=s,l.onerror=()=>{this._styleColorTheme.lutLoading=!1,r(new Error("Failed to load image data"))},l.onload=()=>{if(this._styleColorTheme.lutLoadingCorrelationID!==i)return void n();this._styleColorTheme.lutLoading=!1;const{width:o,height:s,data:c}=e.o.getImageData(l);if(s>32)return void r(new Error("The height of the image must be less than or equal to 32 pixels."));if(o!==s*s)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.q({width:o,height:s},c),pixelRatio:1,sdf:!1,usvg:!1,version:0});const u=this.imageManager.getImage(a,this.scope);u?(this._styleColorTheme.lut={image:u.data,data:t},n()):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.getTerrain()||this.stylesheet.terrain)&&!this.disableElevatedTerrain||this.setTerrainForDraping():this.terrainSetForDrapingOnly()&&this.setTerrain(null,0))}_updateMapProjection(){this.isRootStyle()&&(this.map._useExplicitProjection?this.applyProjectionUpdate():this.map._prioritizeAndUpdateProjection(null,this.projection))}_loadSprite(t){this._spriteRequest=function(t,i,n){let r,o,s;const a=e.o.devicePixelRatio>1?"@2x":"";let l=e.m(i.transformRequest(i.normalizeSpriteURL(t,a,".json"),e.R.SpriteJSON),(e,t)=>{l=null,s||(s=e,r=t,u())}),c=e.n(i.transformRequest(i.normalizeSpriteURL(t,a,".png"),e.R.SpriteImage),(e,t)=>{c=null,s||(s=e,o=t,u())});function u(){if(s)n(s);else if(r&&o){const t=e.o.getImageData(o),i={};for(const n in r){const{width:o,height:s,x:a,y:l,sdf:c,pixelRatio:u,stretchX:h,stretchY:d,content:p}=r[n],f=new e.q({width:o,height:s});e.q.copy(t,f,{x:a,y:l},{x:0,y:0},{width:o,height:s},null),i[n]={data:f,pixelRatio:void 0!==u?u:1,sdf:void 0!==c&&c,stretchX:h,stretchY:d,content:p,usvg:!1,version:0}}n(null,i)}}return{cancel(){l&&(l.cancel(),l=null),c&&(c.cancel(),c=null)}}}(t,this.map._requestManager,(t,i)=>{if(this._spriteRequest=null,t)this.fire(new e.y(t));else if(i){const t=new Map;for(const n in i)t.set(e.I.from(n),i[n]);this.addImages(t)}this.imageManager.setLoaded(!0,this.scope),this.dispatcher.broadcast("spriteLoaded",{scope:this.scope,isLoaded:!0}),this.fire(new e.z("data",{dataType:"style"}))})}addIconset(t,i){if("sprite"===i.type)return void this._loadSprite(i.url);const n=this.getOwnSourceCache(i.source);if(!n)return void this.fire(new e.y(new Error(`Source "${i.source}" as specified by iconset "${t}" does not exist and cannot be used as an iconset source`)));const r=n.getSource();if("raster-array"!==r.type)return void this.fire(new e.y(new Error(`Source "${i.source}" as specified by iconset "${t}" is not a "raster-array" source and cannot be used as an iconset source`)));r.partial=!1;const o=new bn(t,this.scope,n);this.imageManager.addImageProvider(o,this.scope)}removeIconset(e){this.imageManager.removeImageProvider(e,this.scope)}_loadIconset(t){if(!e.h(t)&&"icon_set"!==this.map._spriteFormat||"raster"===this.map._spriteFormat)return void this._loadSprite(t);const i="auto"===this.map._spriteFormat;var n,r;this._spriteRequest=(r=(n,r)=>{if(this._spriteRequest=null,n)i?this._loadSprite(t):this.fire(new e.y(n));else if(r){const t=new Map;for(const i in r)t.set(e.I.from(i),r[i]);this.addImages(t)}this.imageManager.setLoaded(!0,this.scope),this.dispatcher.broadcast("spriteLoaded",{scope:this.scope,isLoaded:!0}),this.fire(new e.z("data",{dataType:"style"}))},e.bt((n=this.map._requestManager).transformRequest(n.normalizeIconsetURL(t),e.R.Iconset),(t,i)=>{if(t)return void r(t);const n={},o=e.df(new e.bs(i));for(const t of o.icons){const i={version:1,pixelRatio:e.o.devicePixelRatio,content:vn(t),stretchX:t.metadata?xn(t.metadata.stretch_x_areas):void 0,stretchY:t.metadata?xn(t.metadata.stretch_y_areas):void 0,sdf:!1,usvg:!0,icon:t};n[t.name]=i}r(null,n)}))}_validateLayer(t){const i=this.getOwnSource(t.source);if(!i)return;const n=t.sourceLayer;n&&("geojson"===i.type||i.vectorLayerIds&&-1===i.vectorLayerIds.indexOf(n))&&this.fire(new e.y(new Error(`Source layer "${n}" 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}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.y(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.y(new Error(`The source '${t}' does not exist in the map's style.`)))}precompilePrograms(e,t){const i=this.map.painter;if(i)for(let n=e.minzoom||0;n<(e.maxzoom||25.5);n++){const n=e.getProgramIds();if(n)for(const r of n){const n=e.getDefaultProgramParams(r,t.zoom,this._styleColorTheme.lut);n&&(i.style=this,this.fog&&(i._fogVisible=!0,n.overrideFog=!0,i.getOrCreateProgram(r,n)),i._fogVisible=!1,n.overrideFog=!1,i.getOrCreateProgram(r,n),(this.stylesheet.terrain||this.stylesheet.projection&&"globe"===this.stylesheet.projection.name)&&(n.overrideRtt=!0,i.getOrCreateProgram(r,n)))}}}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,i!==this._brightness&&(this._brightness=i,this.dispatcher.broadcast("setBrightness",i)),t.worldview!==this._worldview&&(this._worldview=t.worldview,this.dispatcher.broadcast("setWorldview",this._worldview));const n=this._changes.isDirty();let r=!1;if(this._changes.isDirty()){const e=this._changes.getLayerUpdatesByScope();for(const t in e){const{updatedIds:i,removedIds:n}=e[t];(i||n)&&(this._updateWorkerLayers(t,i,n),r=!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 o={};for(const e in this._mergedSourceCaches){const t=this._mergedSourceCaches[e];o[e]=t.used,t.used=!1,t.tileCoverLift=0}for(const e of this._mergedOrder){const i=this._mergedLayers[e];if(i.recalculate(t,this._availableImages),!i.isHidden(t.zoom)){const e=this.getLayerSourceCache(i);e&&(e.used=!0,e.tileCoverLift=Math.max(e.tileCoverLift,i.tileCoverLift()))}!this._precompileDone&&this._shouldPrecompile&&("requestIdleCallback"in window?requestIdleCallback(()=>{this.precompilePrograms(i,t)}):this.precompilePrograms(i,t))}this._shouldPrecompile&&(this._precompileDone=!0),this.terrain&&r&&this.mergeLayers();const s=this.imageManager.getPendingImageProviders();for(const e of s)e.sourceCache.used=!0;for(const t in o){const i=this._mergedSourceCaches[t];o[t]!==i.used&&i.getSource().fire(new e.z("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),n&&this.fire(new e.z("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 n=this.getFragmentStyle(e);n&&this.dispatcher.broadcast("updateLayers",{layers:t?n._serializeLayers(t):[],scope:e,removedIds:i||[],options:n.options})}setState(t,i){if(this._checkLoaded(),wn(this,ye(t)))return!1;(t=e.dn(t)).layers=Ut(t.layers);const n=function(t,i){if(!t)return[{command:Nt.setStyle,args:[i]}];let n=[];try{if(!e.bx(t.version,i.version))return[{command:Nt.setStyle,args:[i]}];if(e.bx(t.center,i.center)||n.push({command:Nt.setCenter,args:[i.center]}),e.bx(t.zoom,i.zoom)||n.push({command:Nt.setZoom,args:[i.zoom]}),e.bx(t.bearing,i.bearing)||n.push({command:Nt.setBearing,args:[i.bearing]}),e.bx(t.pitch,i.pitch)||n.push({command:Nt.setPitch,args:[i.pitch]}),e.bx(t.sprite,i.sprite)||n.push({command:Nt.setSprite,args:[i.sprite]}),e.bx(t.glyphs,i.glyphs)||n.push({command:Nt.setGlyphs,args:[i.glyphs]}),e.bx(t.imports,i.imports)||function(t=[],i=[],n){i=i||[];const r=(t=t||[]).map($t),o=i.map($t),s=t.reduce(Zt,{}),a=i.reduce(Zt,{}),l=r.slice();let c,u,h,d;for(c=0,u=0;c{e.source&&r[e.source]?n.push({command:Nt.removeLayer,args:[e.id]}):s.push(e)});let a=t.terrain;a&&r[a.source]&&(n.push({command:Nt.setTerrain,args:[void 0]}),a=void 0),n=n.concat(o),e.bx(a,i.terrain)||n.push({command:Nt.setTerrain,args:[i.terrain]}),function(t,i,n){i=i||[];const r=(t=t||[]).map($t),o=i.map($t),s=t.reduce(Zt,{}),a=i.reduce(Zt,{}),l=r.slice(),c=Object.create(null);let u,h,d,p,f,m,g;for(u=0,h=0;u!(e.command in En));if(0===n.length)return!1;const r=n.filter(e=>!(e.command in Tn));if(r.length>0)throw new Error(`Unimplemented: ${r.map(e=>e.command).join(", ")}.`);const o=[];return n.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(){this._availableImages=this.imageManager.listImages(this.scope),this.dispatcher.broadcast("setImages",{scope:this.scope,images:this._availableImages})}_updateWorkerModels(){this._availableModels=this.modelManager.getModelURIs(this.scope),this.dispatcher.broadcast("setModels",{scope:this.scope,models:this._availableModels})}addImages(t){if(0===t.size)return this;for(const[i,n]of t.entries()){if(this.getImage(i))return this.fire(new e.y(new Error(`An image with the name "${i.name}" already exists.`)));this.imageManager.addImage(i,this.scope,n),this._changes.updateImage(i,this.scope)}return this._updateWorkerImages(),this.fire(new e.z("data",{dataType:"style"})),this}addImage(t,i){return this.getImage(t)?this.fire(new e.y(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.z("data",{dataType:"style"})),this)}updateImage(t,i,n=!1){this.imageManager.updateImage(t,this.scope,i),n&&(this._changes.updateImage(t,this.scope),this._updateWorkerImages(),this.fire(new e.z("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.z("data",{dataType:"style"})),this):this.fire(new e.y(new Error("No image with this name exists.")))}listImages(){return this._checkLoaded(),this._availableImages.slice()}addModelURLs(t){return this.modelManager.addModelURLs(t,this.scope),this._updateWorkerModels(),this.fire(new e.z("data",{dataType:"style"})),this}addModel(t,i,n={}){return this._checkLoaded(),this._validate(Pe,`models.${t}`,i,null,n)||(this.modelManager.addModel(t,i,this.scope),this.fire(new e.z("data",{dataType:"style"}))),this}hasModel(e){return this.modelManager.hasModel(e,this.scope)}removeModel(t){return this.hasModel(t)?(this.modelManager.removeModel(t,this.scope,!1,!0),this.fire(new e.z("data",{dataType:"style"})),this):this.fire(new e.y(new Error("No model with this ID exists.")))}listModels(){return this._checkLoaded(),this.modelManager.listModels(this.scope)}addSource(t,i,n={}){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"].indexOf(i.type)>=0&&this._validate(ve,`sources.${t}`,i,null,n))return;this.map&&this.map._collectResourceTiming&&(i.collectResourceTiming=!0);const r=pt(t,i,this.dispatcher,this);r.scope=this.scope,r.setEventedParent(this,()=>({isSourceLoaded:this._isSourceCacheLoaded(r.id),source:r.serialize(),sourceId:r.id}));const o=t=>{const i=(t?"symbol:":"other:")+r.id,n=e.B(i,this.scope),o=this._sourceCaches[i]=new Lt(n,r,t);(t?this._symbolSourceCaches:this._otherSourceCaches)[r.id]=o,o.onAdd(this.map)};o(!1),"vector"!==i.type&&"geojson"!==i.type||o(!0),r.onAdd&&r.onAdd(this.map),n.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.y(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.y(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.y(new Error(`Source "${t}" cannot be removed while iconset "${i[0]}" is using it.`)))}const n=this.getOwnSourceCaches(t);for(const t of n){const i=e.dp(t.id);delete this._sourceCaches[i],this._changes.discardSourceCacheUpdate(t.id),t.fire(new e.z("data",{sourceDataType:"metadata",dataType:"source",sourceId:t.getSource().id})),t.setEventedParent(null),t.clearTiles()}return delete this._otherSourceCaches[t],delete this._symbolSourceCaches[t],this.mergeSources(),i.setEventedParent(null),i.onRemove&&i.onRemove(this.map),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(),!t)return delete this.ambientLight,void delete this.directionalLight;const i=this._getTransitionParameters();for(const n of t){if(this._validate(be,"lights",n))return;switch(n.type){case"ambient":if(this.ambientLight){const e=this.ambientLight;e.set(n),e.updateTransitions(i)}else this.ambientLight=new et(n,Ke||(Ke=new e.a9({color:new e.aa(e.a6.properties_light_ambient.color),"color-use-theme":new e.aa({type:"string",default:"default","property-type":"data-constant"}),intensity:new e.aa(e.a6.properties_light_ambient.intensity)})),this.scope,this.options);break;case"directional":if(this.directionalLight){const e=this.directionalLight;e.set(n),e.updateTransitions(i)}else this.directionalLight=new et(n,Xe||(Xe=new e.a9({direction:new e.ap(e.a6.properties_light_directional.direction),color:new e.aa(e.a6.properties_light_directional.color),"color-use-theme":new e.aa({type:"string",default:"default","property-type":"data-constant"}),intensity:new e.aa(e.a6.properties_light_directional.intensity),"cast-shadows":new e.aa(e.a6.properties_light_directional["cast-shadows"]),"shadow-quality":new e.aa(e.a6.properties_light_directional["shadow-quality"]),"shadow-intensity":new e.aa(e.a6.properties_light_directional["shadow-intensity"])})),this.scope,this.options)}}const n=Object.assign(i,{worldview:this.map.getWorldview()}),r=new e.ac(this.z||0,n);this.ambientLight&&this.ambientLight.recalculate(r),this.directionalLight&&this.directionalLight.recalculate(r),this._brightness=this.calculateLightsBrightness(),this.dispatcher.broadcast("setBrightness",this._brightness)}calculateLightsBrightness(){const t=this.directionalLight,i=this.ambientLight;if(!t||!i)return;const n=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"),s=t.properties.get("direction"),a=1-e.d3(s.x,s.y,s.z)[2]/90,l=n(r)*o*a,c=i.properties.get("color").toNonPremultipliedRenderColor(null).toArray01(),u=i.properties.get("intensity"),h=n(c)*u;return Number(((l+h)/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.dq(t)){const i=e.dr(t),n=this.fragments.find(({id:e})=>e===i);if(!n)return;const r=e.dp(t);return n.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={},n=(e,t="")=>`${e}::${t}`;this._featuresetSelectors={};for(const r in t){const o=this._featuresetSelectors[r]=[];for(const s of t[r].selectors){if(s.featureNamespace){const t=this.getOwnLayer(s.layer);if(!t){e.w(`Layer is undefined for selector: ${s.layer}`);continue}const o=n(t.source,t.sourceLayer);if(o in i&&i[o]!==s.featureNamespace){e.w(`"featureNamespace ${s.featureNamespace} of featureset ${r}'s selector is not associated to the same source, skip this selector`);continue}i[o]=s.featureNamespace}let t;if(s.properties)for(const i in s.properties){const n=e.U(s.properties[i]);"success"===n.result&&(t=t||{},t[i]=n.value)}o.push({layerId:s.layer,namespace:s.featureNamespace,properties:t,uniqueFeatureID:s._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 n=this.getFragmentStyle(i),r=n.stylesheet.featuresets;if(!r||!r[t])return this.fire(new e.y(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=n.getOwnLayer(e.layer);t&&o.push(t)}return o}getConfigProperty(t,i){const n=this.getFragmentStyle(t);if(!n)return null;const r=e.B(i,n.scope),o=n.options.get(r),s=o?o.value||o.default:null;return s?s.serialize():null}isIndoorEnabled(){return Object.keys(this._mergedIndoor).length>0}getIndoorSourceLayers(t,i){const n=e.B(t,i);return this._mergedIndoor[n]}setIndoorData(e,t){this.map.indoor.setIndoorData(t)}updateIndoorDependentLayers(){this._updateLayers(this._indoorDependentLayers),this.map._styleDirty=!0,this.map.triggerRepaint()}setConfigProperty(t,i,n){const r=this.getFragmentStyle(t);if(!r)return;const o=r.stylesheet.schema;if(!o||!o[i])return;const s=e.U(n);if("success"!==s.result)return void wn(this,s.value);const a=s.value.expression,l=e.B(i,r.scope),c=r.options.get(l);if(!c)return;let u;const{minValue:h,maxValue:d,stepValue:p,type:f,values:m}=o[i],g=e.U(o[i].default);"success"===g.result&&(u=g.value.expression),u?(this.options.set(l,Object.assign({},c,{value:a,default:u,minValue:h,maxValue:d,stepValue:p,type:f,values:m})),this.updateConfigDependencies(i)):this.fire(new e.y(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 n=i.stylesheet.schema;if(!n)return null;const r={};for(const t in n){const n=e.B(t,i.scope),o=i.options.get(n),s=o?o.value||o.default:null;r[t]=s?s.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 n in i){let r,o;const s=e.U(i[n].default);if("success"===s.result&&(r=s.value.expression),t&&void 0!==t[n]){const i=e.U(t[n]);"success"===i.result&&(o=i.value.expression)}const{minValue:a,maxValue:l,stepValue:c,type:u,values:h}=i[n];if(r){const t=e.B(n,this.scope);this.options.set(t,{default:r,value:o,minValue:a,maxValue:l,stepValue:c,type:u,values:h})}else this.fire(new e.y(new Error(`No schema defined for config option "${n}".`)))}else this.fire(new e.y(new Error("Attempting to set config for a style without schema.")))}_updateLayers(e,t=()=>!0){for(const i of e){const e=this.getLayer(i);e&&t(e)&&(e.possiblyEvaluateVisibility(),this._updateLayer(e),this._changes.setDirty())}}updateConfigDependencies(e){this._updateLayers(this._configDependentLayers,t=>!e||t.expressionDependencies.configDependencies.has(e)),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._changes.setDirty()}addLayer(t,i,n={}){this._checkLoaded();const r=t.id;if(this._layers[r])return void this.fire(new e.y(new Error(`Layer with id "${r}" already exists on this map`)));let o;if("custom"===t.type){if(wn(this,e.ds(t)))return;o=e.dt(t,this.scope,this._styleColorTheme.lut,this.options)}else{if("object"==typeof t.source&&(this.addSource(r,t.source),t=e.dn(t),t=Object.assign(t,{source:r})),this._validate(Se,`layers.${r}`,t,{arrayIndex:-1},n))return;o=e.dt(t,this.scope,this._styleColorTheme.lut,this.options),this._validateLayer(o),o.setEventedParent(this,{layer:{id:r}})}const s=e.B(o.source,o.scope);0!==o.expressionDependencies.configDependencies.size&&this._configDependentLayers.add(s),o.expressionDependencies.isIndoorDependent&&this._indoorDependentLayers.add(s);let a=this._order.length;if(i){const t=this._order.indexOf(i);if(-1===t)return void this.fire(new e.y(new Error(`Layer with id "${i}" does not exist on this map.`)));o.slot===this._layers[i].slot?a=t:e.w(`Layer with id "${i}" has a different slot. Layers can only be rearranged within the same slot.`)}this._order.splice(a,0,r),this._layerOrderChanged=!0,this._layers[r]=o;const l=this.getOwnLayerSourceCache(o),c=!!this.directionalLight&&this.directionalLight.shadowsEnabled();l&&o.canCastShadows()&&c&&(l.castsShadows=!0);const u=this._changes.getRemovedLayer(o);if(u&&o.source&&l&&"custom"!==o.type){this._changes.discardLayerRemoval(o);const t=e.B(o.source,o.scope);u.type!==o.type?this._changes.updateSourceCache(t,"clear"):(this._changes.updateSourceCache(t,"reload"),l.pause())}this._updateLayer(o),o.onAdd&&o.onAdd(this.map),o.scope=this.scope,this.mergeLayers()}moveLayer(t,i){this._checkLoaded();const n=this._checkLayer(t);if(!n)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.y(new Error(`Layer with id "${i}" does not exist on this map.`)));n.slot===this._layers[i].slot?o=t:e.w(`Layer with id "${i}" has a different slot. Layers can only be rearranged within the same slot.`)}this._order.splice(o,0,t),this._changes.setDirty(),this._layerOrderChanged=!0,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._layerOrderChanged=!0,this._configDependentLayers.delete(t.fqid),this._indoorDependentLayers.delete(t.fqid),this._changes.removeLayer(t);const n=this.getOwnLayerSourceCache(t);if(n&&n.castsShadows){let e=!1;for(const i in this._layers)if(this._layers[i].source===t.source&&this._layers[i].canCastShadows()){e=!0;break}n.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 n=this._checkLayer(e);n&&(n.minzoom===t&&n.maxzoom===i||(null!=t&&(n.minzoom=t),null!=i&&(n.maxzoom=i),this._updateLayer(n)))}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,n={}){this._checkLoaded();const r=this._checkLayer(t);if(r&&!e.bx(r.filter,i))return null==i?(r.filter=void 0,void this._updateLayer(r)):void(this._validate(Be,`layers.${r.id}.filter`,i,{layerType:r.type},n)||(r.filter=e.dn(i),this._updateLayer(r)))}getFilter(t){const i=this._checkLayer(t);if(i)return e.dn(i.filter)}setLayoutProperty(t,i,n,r={}){this._checkLoaded();const o=this._checkLayer(t);if(o&&!e.bx(o.getLayoutProperty(i),n)){if(null!=n&&(!r||!1!==r.validate)&&wn(o,Me.call(ye,{key:`layers.${t}.layout.${i}`,layerType:o.type,objectKey:i,value:n,styleSpec:e.a6,style:{glyphs:!0,sprite:!0}})))return;o.setLayoutProperty(i,n),0!==o.expressionDependencies.configDependencies.size&&this._configDependentLayers.add(o.fqid),o.expressionDependencies.isIndoorDependent&&this._indoorDependentLayers.add(o.fqid),this._updateLayer(o)}}setLayerProperty(e,t,i,n={}){this._checkLoaded();const r=this._checkLayer(e);r&&("appearances"===t?(r.setAppearances(i),this._changes.setDirty()):r.isPaintProperty(t)?this.setPaintProperty(e,t,i,n):this.setLayoutProperty(e,t,i,n))}getLayoutProperty(e,t){const i=this._checkLayer(e);if(i)return i.getLayoutProperty(t)}setPaintProperty(t,i,n,r={}){this._checkLoaded();const o=this._checkLayer(t);if(!o)return;if(e.bx(o.getPaintProperty(i),n))return;if(null!=n&&(!r||!1!==r.validate)&&wn(o,Ie.call(ye,{key:`layers.${t}.paint.${i}`,layerType:o.type,objectKey:i,value:n,styleSpec:e.a6})))return;const s=o.setPaintProperty(i,n);0!==o.expressionDependencies.configDependencies.size&&this._configDependentLayers.add(o.fqid),o.expressionDependencies.isIndoorDependent&&this._indoorDependentLayers.add(o.fqid),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:n}=t.target,r=this.getFragmentStyle(n),o=r.getFeaturesetLayers(e);for(const{source:e,sourceLayer:n}of o)r.setFeatureState({id:t.id,source:e,sourceLayer:n},i)}else if("layerId"in t.target){const{layerId:e}=t.target,n=this.getLayer(e);this.setFeatureState({id:t.id,source:n.source,sourceLayer:n.sourceLayer},i)}return}const n=t.source,r=t.sourceLayer,o=this._checkSource(n);if(!o)return;const s=o.type;if("geojson"===s&&r)return void this.fire(new e.y(new Error("GeoJSON sources cannot have a sourceLayer parameter.")));if("vector"===s&&!r)return void this.fire(new e.y(new Error("The sourceLayer parameter must be provided for vector source types.")));void 0===t.id&&this.fire(new e.y(new Error("The feature id parameter must be provided.")));const a=this.getOwnSourceCaches(n);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:n}=t.target,r=this.getFragmentStyle(n),o=r.getFeaturesetLayers(e);for(const{source:e,sourceLayer:n}of o)r.removeFeatureState({id:t.id,source:e,sourceLayer:n},i)}else if("layerId"in t.target){const{layerId:e}=t.target,n=this.getLayer(e);this.removeFeatureState({id:t.id,source:n.source,sourceLayer:n.sourceLayer},i)}return}const n=t.source,r=this._checkSource(n);if(!r)return;const o=r.type,s="vector"===o?t.sourceLayer:void 0;if("vector"===o&&!s)return void this.fire(new e.y(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.y(new Error("A feature id is required to remove its specific state property.")));const a=this.getOwnSourceCaches(n);for(const e of a)e.removeFeatureState(s,t.id,i)}getFeatureState(t){if(this._checkLoaded(),"target"in t){let i;if("featuresetId"in t.target){const{featuresetId:n,importId:r}=t.target,o=this.getFragmentStyle(r),s=o.getFeaturesetLayers(n);for(const{source:n,sourceLayer:r}of s){const s=o.getFeatureState({id:t.id,source:n,sourceLayer:r});if(s&&!i)i=s;else if(!e.bx(i,s))return void this.fire(new e.y(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{layerId:e}=t.target,n=this.getLayer(e);i=this.getFeatureState({id:t.id,source:n.source,sourceLayer:n.sourceLayer})}return i}const i=t.source,n=t.sourceLayer,r=this._checkSource(i);if(r){if("vector"!==r.type||n)return void 0===t.id&&this.fire(new e.y(new Error("The feature id parameter must be provided."))),this.getOwnSourceCaches(i)[0].getFeatureState(n,t.id);this.fire(new e.y(new Error("The sourceLayer parameter must be provided for vector source types.")))}}setTransition(e){return this.stylesheet.transition=Object.assign({},this.stylesheet.transition,e),this.transition=this.stylesheet.transition,this}getTransition(){return Object.assign({},this.stylesheet.transition)}serialize(){this._checkLoaded();const t=this.getTerrain(),i=t&&this.terrain&&this.terrain.scope===this.scope?t:this.stylesheet.terrain;return e.du({version:this.stylesheet.version,name:this.stylesheet.name,metadata:this.stylesheet.metadata,fragment:this.stylesheet.fragment,iconsets:this.stylesheet.iconsets,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,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),n=e.B(t.source,t.scope),r=this._changes.getUpdatedSourceCaches();t.source&&!r[n]&&i&&"raster"!==i.getSource().type&&(this._changes.updateSourceCache(n,"reload"),i.pause()),t.invalidateCompiledFilter()}_flattenAndSortRenderedFeatures(e){const t=e=>this._mergedLayers[e].is3D(!!this.terrain),i=this.order,n={},r=[];for(let o=i.length-1;o>=0;o--){const s=i[o];if(t(s)){n[s]=o;for(const t of e){const e=t[s];if(e)for(const t of e)r.push(t)}}}r.sort((e,t)=>t.intersectionZ-e.intersectionZ);const o=[];for(let s=i.length-1;s>=0;s--){const a=i[s];if(t(a))for(let e=r.length-1;e>=0;e--){const t=r[e].feature;if(t.layer&&n[t.layer.id]{if(Cn.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.y(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.y(new Error(`The layer '${t}' does not exist in the map's style and cannot be queried for features.`))),[];s(i)}}else for(const e in this._layers)s(this._layers[e]);const a=this._queryRenderedFeatures(t,o,n),l=this._flattenAndSortRenderedFeatures(a),c=[];for(const t of l)e.dv(t.layer.id)===this.scope&&c.push(t);return c}queryRenderedFeatureset(t,i,n){let r;i&&!Array.isArray(i)&&i.filter&&(this._validate(Be,"queryRenderedFeatures.filter",i.filter,null,i),r=e.b5(i.filter));const o="mock",s=[];if(i&&i.target)s.push(Object.assign({},i,{targetId:o,filter:r}));else{const e=this.getFeaturesetDescriptors();for(const t of e)s.push({targetId:o,filter:r,target:t});for(const{style:e}of this.fragments){const t=e.getFeaturesetDescriptors();for(const e of t)s.push({targetId:o,filter:r,target:e})}}const a=this.queryRenderedTargets(t,s,n),l=[],c=new Set;for(const t of a)for(const i of t.variants[o])mt(i,t,c)||l.push(new e.dw(t,i));return l}queryRenderedTargets(t,i,n){const r={},o=(e,t,i,n)=>{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),!n)return i.uniqueFeatureID=!1,void o.layers[e.fqid].targets.push(i);o.layers[e.fqid].targets.push(Object.assign({},i,{namespace:n.namespace,properties:n.properties,uniqueFeatureID:n.uniqueFeatureID}))};for(const t of i)if("featuresetId"in t.target){const{featuresetId:i,importId:n}=t.target,r=this.getFragmentStyle(n);if(!r||!r._featuresetSelectors)continue;const s=r._featuresetSelectors[i];if(!s){this.fire(new e.y(new Error(`The featureset '${i}' does not exist in the map's style and cannot be queried for features.`)));continue}for(const e of s){const i=r.getOwnLayer(e.layerId);i&&!Cn.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||Cn.has(i.type))continue;o(i,this.getLayerSourceCache(i),t)}const s=this._queryRenderedFeatures(t,r,n);return this._flattenAndSortRenderedFeatures(s)}_queryRenderedFeatures(e,t,i){const n=[],r=!!this.map._showQueryGeometry,o=tt.createFromScreenPoints(e,i);for(const e in t){const s=gt(o,t[e],this._availableImages,i,r);Object.keys(s).length&&n.push(s)}if(this.placement)for(const e in t){if(!t[e].sourceCache._onlySymbols)continue;const i=_t(o.screenGeometry,t[e],this._availableImages,this.placement.collisionIndex,this.placement.retainedQueryData,this.map.getWorldview());Object.keys(i).length&&n.push(i)}return n}querySourceFeatures(e,t){const i=t&&t.filter;i&&this._validate(Be,"querySourceFeatures.filter",i,null,t);let n=[];const r=this.getOwnSourceCaches(e);for(const e of r)n=n.concat(At(e,t));return n}addSourceType(e,t,i){return In.getSourceType(e)?i(new Error(`A source type called "${e}" already exists.`)):(In.setSourceType(e,t),t.workerSourceURL?void this.dispatcher.broadcast("loadWorkerSource",{name:e,url:t.workerSourceURL},i):i(null,null))}getFlatLight(){return this.light.getLight()}setFlatLight(t,i,n={}){this._checkLoaded();const r=this.light.getLight();let o=!1;for(const i in t)if(!e.bx(t[i],r[i])){o=!0;break}if(!o)return;const s=this._getTransitionParameters();this.light.setLight(t,i,n),this.light.updateTransitions(s)}getTerrain(){return this.terrain&&1===this.terrain.drapeRenderMode?this.terrain.get():null}setTerrainForDraping(){this.setTerrain({source:"",exaggeration:0},0)}checkCanvasFingerprintNoise(){void 0===this.disableElevatedTerrain&&(this.disableElevatedTerrain=e.o.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 n=t;const r=null==t.source;if(1===i){if(this.disableElevatedTerrain)return;if("object"==typeof n.source){const t="terrain-dem-src";this.addSource(t,n.source),n=e.dn(n),n=Object.assign(n,{source:t})}const t=Object.assign({},n),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(we,"terrain",t,i))return}if(!this.terrain||this.terrain.scope!==this.scope&&!r||this.terrain&&i!==this.terrain.drapeRenderMode){if(!n)return;this._createTerrain(n,i),this.fire(new e.z("data",{dataType:"style"}))}else{const i=this.terrain,r=i.get();for(const t of Object.keys(e.a6.terrain))!n.hasOwnProperty(t)&&e.a6.terrain[t].default&&(n[t]=e.a6.terrain[t].default);for(const n in t)if(!e.bx(t[n],r[n])){i.set(t,this.options),this.stylesheet.terrain=t;const n=this._getTransitionParameters({duration:0});i.updateTransitions(n),this.fire(new e.z("data",{dataType:"style"}));break}}this.mergeTerrain(),this.updateDrapeFirstLayers(),this._markersNeedUpdate=!0}_createFog(e){const t=this.fog=new Ze(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 Je(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 Ye(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)return delete this.fog,delete this.stylesheet.fog,void(this._markersNeedUpdate=!0);if(this.fog){const i=this.fog;if(!e.bx(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);this._markersNeedUpdate=!0}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.bx(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.bx(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 n=this._evaluateColorThemeData(i);this._loadColorTheme(n).then(()=>{this.fire(new e.z("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.o.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 ze(e,t,this.scope,this.options,this.map.getWorldview());1===t&&(this.stylesheet.terrain=e),this.mergeTerrain(),this.updateDrapeFirstLayers(),this._force3DLayerUpdate();const n=this._getTransitionParameters({duration:0});i.updateTransitions(n)}_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,n,r,o={}){if(o&&!1===o.validate)return!1;const s=Object.assign({},this.serialize());return wn(this,t.call(ye,Object.assign({key:i,style:s,value:n,styleSpec:e.a6},r)))}_remove(){this._request&&(this._request.cancel(),this._request=null),this._spriteRequest&&(this._spriteRequest.cancel(),this._spriteRequest=null),e.dx.off("pluginStateChange",this._rtlTextPluginCallback);for(const e in this._mergedLayers)this._mergedLayers[e].setEventedParent(null);for(const e in this._mergedSourceCaches)this._mergedSourceCaches[e].clearTiles(),this._mergedSourceCaches[e].setEventedParent(null);this.imageManager.removeScope(this.scope),this.setEventedParent(null),delete this.fog,delete this.snow,delete this.rain,delete this.terrain,delete this.ambientLight,delete this.directionalLight,this.isRootStyle()&&(this.imageManager.setEventedParent(null),this.imageManager.destroy(),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(e){let t;this.directionalLight&&(t=fn(this.directionalLight));const i=new Set;for(const e in this._mergedLayers){const t=this._mergedLayers[e];t.hasElevation()&&!i.has(t.source)&&i.add(t.source)}for(const n in this._mergedSourceCaches){const r=this._mergedSourceCaches[n],o=i.has(r._source.id);r.update(e,void 0,void 0,t,o)}}_generateCollisionBoxes(){for(const e in this._sourceCaches){const t=this._sourceCaches[e];t.resume(),t.reload()}}_updatePlacement(t,i,n,r,o,s,a=!1){let l=!1,c=!1;const u={},h={};for(const t of this._mergedOrder){const n=this._mergedLayers[t];if("symbol"!==n.type)continue;const r=e.B(n.source,n.scope);let o=u[r];if(!o){const e=this.getLayerSourceCache(n);if(!e)continue;const t=e.getRenderableIds(!0).map(t=>e.getTileByID(t));h[r]=t.slice(),o=u[r]=t.sort((e,t)=>t.tileID.overscaledZ-e.tileID.overscaledZ||(e.tileID.isLessThan(t.tileID)?-1:1))}const s=this.crossTileSymbolIndex.addLayer(n,o,i.center.lng,i.projection);l=l||s}if(this.crossTileSymbolIndex.pruneUnusedLayers(this._mergedOrder),a=a||this._layerOrderChanged||0===r,this._layerOrderChanged&&this.fire(new e.z("neworder")),(a||!this.pauseablePlacement||this.pauseablePlacement.isDone()&&!this.placement.stillRecent(e.o.now(),i.zoom))&&(this.pauseablePlacement=new zi(i,this._mergedOrder,a,n,r,o,this.placement,this.fog&&i.projection.supportsFog?this.fog.state:null,this._buildingIndex),this._layerOrderChanged=!1),this.pauseablePlacement.isDone()?this.placement.setStale():(this.pauseablePlacement.continuePlacement(this._mergedOrder,this._mergedLayers,u,h,this.map.painter.scaleFactor),this.pauseablePlacement.isDone()&&(this.placement=this.pauseablePlacement.commit(e.o.now()),c=!0),l&&this.pauseablePlacement.placement.setStale()),c||l){this._buildingIndex.onNewFrame(i.zoom);for(let t=0;te===t.id))return void this.fire(new e.y(new Error(`Import with id '${t.id}' already exists in the map's style.`)));if(!i)return n.push(t),this._loadImports([t],!0);const r=n.findIndex(({id:e})=>e===i);return-1===r&&this.fire(new e.y(new Error(`Import with id "${i}" does not exist on this map.`))),this.stylesheet.imports=n.slice(0,r).concat(t).concat(n.slice(r)),this._loadImports([t],!0,i)}updateImport(t,i){this._checkLoaded();const n=this.stylesheet.imports||[],r=this.getImportIndex(t);return-1===r?this:"string"==typeof i?(this.setImportUrl(t,i),this):(i.url&&i.url!==n[r].url&&this.setImportUrl(t,i.url),e.bx(i.config,n[r].config)||this.setImportConfig(t,i.config,i.data.schema),e.bx(i.data,n[r].data)||this.setImportData(t,i.data),this)}moveImport(e,t){this._checkLoaded();let i=this.stylesheet.imports||[];const n=this.getImportIndex(e);if(-1===n)return this;const r=this.getImportIndex(t);if(-1===r)return this;const o=i[n],s=this.fragments[n];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(s).concat(this.fragments.slice(r)),this.mergeLayers(),this}setImportUrl(e,t){this._checkLoaded();const i=this.stylesheet.imports||[],n=this.getImportIndex(e);if(-1===n)return this;i[n].url=t;const r=this.fragments[n];return r.style=this._createFragmentStyle(i[n]),r.style.on("style.import.load",()=>this.mergeAll()),r.style.loadURL(t),this}setImportData(e,t){this._checkLoaded();const i=this.getImportIndex(e),n=this.stylesheet.imports||[];return-1===i?this:t?(this.fragments[i].style.setState(t),this._reloadImports(),this):(delete n[i].data,this.setImportUrl(e,n[i].url))}setImportConfig(e,t,i){this._checkLoaded();const n=this.getImportIndex(e),r=this.stylesheet.imports||[];if(-1===n)return this;t?r[n].config=t:delete r[n].config;const o=this.fragments[n];i&&o.style.stylesheet&&(o.style.stylesheet.schema=i);const s=o.style.stylesheet&&o.style.stylesheet.schema;return o.config=t,o.style.updateConfig(t,s),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.y(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 n=e.B(t,i);return this._mergedOtherSourceCaches[n]}getLayerSourceCache(t){const i=e.B(t.source,t.scope);return"symbol"===t.type?this._mergedSymbolSourceCaches[i]:this._mergedOtherSourceCaches[i]}getSourceCaches(e){if(null==e)return Object.values(this._mergedSourceCaches);const t=[];return this._mergedOtherSourceCaches[e]&&t.push(this._mergedOtherSourceCaches[e]),this._mergedSymbolSourceCaches[e]&&t.push(this._mergedSymbolSourceCaches[e]),t}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)}getImages(t,i,n){this.imageManager.getImages(i.images,i.scope,n),this._updateTilesForChangedImages();const r=t=>{if(t){const n=i.images.map(t=>e.I.toString(t));t.setDependencies(i.tileID.key,i.type,n)}},o=e.B(i.source,i.scope);r(this._mergedOtherSourceCaches[o]),r(this._mergedSymbolSourceCaches[o]),i.images.some(e=>e.iconsetId)&&this.fire(new e.z("data",{dataType:"style"}))}rasterizeImages(e,t,i){this.imageManager.rasterizeImages(t,i)}getGlyphs(e,t,i){this.glyphManager.getGlyphs(t.stacks,i)}getResource(t,i,n){return e.dy(i,n)}getOwnSourceCache(e){return this._otherSourceCaches[e]}getOwnLayerSourceCache(e){return"symbol"===e.type?this._symbolSourceCaches[e.source]:this._otherSourceCaches[e.source]}getOwnSourceCaches(e){const t=[];return this._otherSourceCaches[e]&&t.push(this._otherSourceCaches[e]),this._symbolSourceCaches[e]&&t.push(this._symbolSourceCaches[e]),t}_isSourceCacheLoaded(t){const i=this.getOwnSourceCaches(t);return 0===i.length?(this.fire(new e.y(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),n="building"===e.type;if(e.is3D(!!this.terrain)){if(i||n||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")}destroy(){this._clearWorkerCaches(),this.fragments.forEach(e=>{e.style._remove()}),this.terrainSetForDrapingOnly()&&(delete this.terrain,delete this.stylesheet.terrain)}}In.getSourceType=function(e){return dt[e]},In.setSourceType=function(e,t){dt[e]=t},In.registerForPluginStateChange=e.dz;class Mn extends e.E{constructor(t){super(),this._style=t,this._buildings={},this._activeFloors=new Set,this._activeFloorsVisible=!0,this._indoorState={selectedFloorId:null,lastActiveFloors:null,activeFloorsVisible:!0},e.aX(["_updateUI"],this)}destroy(){this._buildings={},this._activeFloors=new Set,this._indoorState=null}selectFloor(e){e===this._selectedFloorId&&this._activeFloorsVisible||(this._selectedFloorId=e,this._activeFloorsVisible=!0,this._updateActiveFloors())}setActiveFloorsVisibility(e){this._activeFloorsVisible=e,this._updateActiveFloors(),this._updateIndoorSelector()}setIndoorData(e){for(const[t,i]of Object.entries(e.buildings))if(this._buildings[t])for(const e of i.floorIds)this._buildings[t].floors[e]||(this._buildings[t].floors[e]=i.floors[e]);else this._buildings[t]=i;for(const t of e.activeFloors)this._activeFloors.add(t);this._updateIndoorSelector()}getIndoorTileOptions(e,t){const i=this._style.getIndoorSourceLayers(e,t);return i&&this._indoorState?{sourceLayers:i,indoorState:this._indoorState}:null}_updateUI(t,i,n){const r=function(t,i,n,r){let o=null,s=Number.MAX_SAFE_INTEGER;if(r<16)return null;for(const[r,a]of Object.entries(t)){const t=a.center;if(t){const a=i.distanceTo(e.aS.convert(t));a({id:e,name:n.floors[e].name,zIndex:n.floors[e].zIndex})).sort((e,t)=>t.zIndex-e.zIndex);this.fire(new e.z("selector-update",{selectedFloorId:r,activeFloorsVisible:this._activeFloorsVisible,floors:o}))}_updateActiveFloors(){const e=this._activeFloors;this._activeFloors=new Set,this._indoorState={selectedFloorId:this._selectedFloorId,lastActiveFloors:e,activeFloorsVisible:this._activeFloorsVisible},this._style.updateIndoorDependentLayers()}}var Pn="\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",Rn="\nout vec4 glFragColor;highp 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) {highp float depth=ndc_z*0.5+0.5;const 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;}\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}\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 applyLUT(highp sampler3D lut,vec4 col) {vec3 size=vec3(textureSize(lut,0));vec3 uvw=(col.rbg*float(size-1.0)+0.5)/size;return vec4(texture(lut,uvw).rgb*col.a,col.a);}vec3 applyLUT(highp sampler3D lut,vec3 col) {return applyLUT(lut,vec4(col,1.0)).rgb;}",Ln="\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);}vec2 unpack_opacity(const float packedOpacity) {int intOpacity=int(packedOpacity)/2;return vec2(float(intOpacity)/127.0,mod(packedOpacity,2.0));}vec4 decode_color(const vec2 encodedColor) {return vec4(\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(vec2 posWithComposedSkirt)\n{float skirt=float(posWithComposedSkirt.x >=skirtOffset);vec2 pos=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",Fn="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;}",kn="\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;vec3 elevationVector(vec2 pos) {vec2 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\nvec3 elevationVector(vec2 pos) { return vec3(0,0,1); }\n#endif\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}\n#ifdef TERRAIN_VERTEX_MORPHING\nfloat elevation(vec2 apos) {\n#ifdef ZERO_EXAGGERATION\nreturn 0.0;\n#endif\nfloat nextElevation=currentElevation(apos);float prevElevation=prevElevation(apos);return mix(prevElevation,nextElevation,u_dem_lerp);}\n#else\nfloat elevation(vec2 apos) {\n#ifdef ZERO_EXAGGERATION\nreturn 0.0;\n#endif\nreturn currentElevation(apos);}\n#endif\nvec4 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#else\nfloat elevation(vec2 pos) { return 0.0; }\n#endif\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//DEPTH_OCCLUSION",Dn="#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",On="#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;\n#ifdef FLIP_Y\nuv.y=1.0-uv.y;\n#endif\nhighp 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",zn="#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",Un="#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;}",Nn="#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//RENDER_SHADOWS",Vn="#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;float shadow_sample(sampler2DShadow shadowmap,highp vec3 pos,highp float bias) {\n#ifdef CLIP_ZERO_TO_ONE\nhighp vec3 coord=vec3(pos.xy*0.5+0.5,pos.z-bias);\n#else\nhighp vec3 coord=vec3(pos.xy*0.5+0.5,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=light_view_pos0.xyz/light_view_pos0.w*0.5+0.5;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 jn=[];Wn(Pn,jn),Wn(Ln,jn),Wn(Rn,jn);const Gn={"_prelude_fog.vertex.glsl":Dn,"_prelude_terrain.vertex.glsl":kn,"_prelude_shadow.vertex.glsl":Nn,"_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":On,"_prelude_shadow.fragment.glsl":Vn,"_prelude_lighting.glsl":"\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//LIGHTING_3D_MODE","_prelude_raster_array.glsl":zn,"_prelude_raster_particle.glsl":Un},Hn={};qn("",kn),qn(On,Dn),qn(Vn,Nn),qn(zn,""),qn(Un,"");const Qn=qn(Rn,Ln),$n=Pn;var Zn={background:qn('#include "_prelude_fog.fragment.glsl"\n#include "_prelude_lighting.glsl"\nuniform vec4 u_color;uniform float u_opacity;\n#ifdef LIGHTING_3D_MODE\nin vec4 v_color;\n#endif\nvoid main() {vec4 out_color;\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\nglFragColor=out_color*u_opacity;\n#ifdef OVERDRAW_INSPECTOR\nglFragColor=vec4(1.0);\n#endif\nHANDLE_WIREFRAME_DEBUG;}','#include "_prelude_fog.vertex.glsl"\n#include "_prelude_lighting.glsl"\nin vec2 a_pos;uniform mat4 u_matrix;\n#ifdef LIGHTING_3D_MODE\nuniform mediump vec4 u_color;out vec4 v_color;uniform float u_emissive_strength;\n#endif\nvoid main() {gl_Position=u_matrix*vec4(a_pos,0,1);\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(a_pos);\n#endif\n}'),backgroundPattern:qn('#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 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 vec2 a_pos;out highp vec2 v_pos;void main() {gl_Position=u_matrix*vec4(a_pos,0,1);v_pos=get_pattern_pos(u_pixel_coord_upper,u_pixel_coord_lower,u_pattern_size,u_pattern_units_to_pixels,a_pos);\n#ifdef FOG\nv_fog_pos=fog_position(a_pos);\n#endif\n}'),building:qn('#include "_prelude_fog.fragment.glsl"\n#include "_prelude_shadow.fragment.glsl"\n#include "_prelude_lighting.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 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;in float v_depth_shadows;\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\nfloat hash12(in vec2 p) {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);}vec2 get_uv_mask_id(in vec2 q,out float mask,out vec2 id) {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;vec2 uv=modf(p/v_faux_facade_floor,id);vec4 d=(v_faux_facade_floor.xyxy+vec4(-v_faux_facade_window,v_faux_facade_window))*0.5;vec4 edge=d/v_faux_facade_floor.xyxy;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;}float ray_unit_box(in vec3 ray_o,in vec3 ray_d,in vec3 bmin,in vec3 bmax) {vec3 planes=mix(bmin,bmax,step(0.0,ray_d));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 vec3 v,in vec3 v_normalized,in vec3 color,in vec2 id,in mat3 tbn,inout vec3 out_normal,inout float out_emissive) {vec3 out_color=color;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) {mat3 tbn=mat3(v_tbn_0,v_tbn_1,v_tbn_2);vec3 v=vec3(v_pos.xy,v_pos.z/u_tile_to_meter)-u_camera_pos;vec3 view_tangent=transpose(tbn)*v;vec2 q=vec2(v_faux_facade_ed,v_pos.z);float mask=0.0;vec2 id=vec2(0.0);vec2 uv=get_uv_mask_id(q,mask,id);uv*=v_faux_facade_window;vec3 bmin=vec3(0.0,0.0,-window_depth);vec3 bmax=bmin+vec3(v_faux_facade_window,window_depth);vec3 ray_o=vec3(uv,0.0);vec3 ray_d=normalize(view_tangent);float t_min=ray_unit_box(ray_o,ray_d,bmin,bmax);vec3 hit=ray_o+t_min*ray_d;vec3 r=vec3(v_faux_facade_window,-window_depth);hit-=r*0.5;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\nshadowed_lighting_factor=shadowed_light_factor_normal(xy_flipped_normal,v_pos_light_view_0,v_pos_light_view_1,v_depth_shadows);\n#else\nshadowed_lighting_factor=dot(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\ncolor=applyCutout(color,v_pos.z);\n#endif\n#ifdef FEATURE_CUTOUT\ncolor=apply_feature_cutout(color,gl_FragCoord);\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 vec3 a_normal_3;in vec3 a_centroid_3;in float a_flood_light_wall_radius_1i16;in vec4 a_faux_facade_data;in vec2 a_faux_facade_vertical_range;uniform mat4 u_matrix;uniform mat4 u_normal_matrix;uniform highp float u_tile_to_meter;out 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;out float v_depth_shadows;\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 vec2 part_color_emissive\n#pragma mapbox: define-attribute-vertex-shader-only highp vec2 faux_facade_color_emissive\nvoid main() {\n#pragma mapbox: initialize-attribute-custom highp vec2 part_color_emissive\n#pragma mapbox: initialize-attribute-custom highp vec2 faux_facade_color_emissive\n#ifdef FLOOD_LIGHT\nv_flood_radius=(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(part_color_emissive);v_color=vec4(sRGBToLinear(color_emissive.rgb),color_emissive.a);vec3 a_normal_3f=a_normal_3/MAX_INT_16;v_normal=vec3(u_normal_matrix*vec4(a_normal_3f,0.0));float hidden=0.0;\n#ifdef BUILDING_FAUX_FACADE\nv_faux_facade=a_faux_facade_data.x;if (v_faux_facade > 0.0) {v_faux_facade_ed=a_faux_facade_data.x *u_tile_to_meter;float window_x_perc=floor(a_faux_facade_data.y/TWO_POW_8);float window_y_perc=a_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=(a_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=(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(faux_facade_color_emissive);v_faux_color_emissive.rgb=sRGBToLinear(v_faux_color_emissive.rgb);}\n#endif\nv_pos=a_pos_3f;\n#ifdef RENDER_CUTOFF\nvec4 ground=u_matrix*vec4(a_centroid_3,1.0);v_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);v_depth_shadows=gl_Position.w;\n#endif\n#ifdef FOG\nv_fog_pos=fog_position(v_pos);\n#endif\ngl_Position=mix(u_matrix*vec4(v_pos,1),AWAY,hidden);}'),buildingBloom:qn("in vec4 v_color_emissive;\n#pragma mapbox: define-attribute highp vec4 bloom_attenuation\n#pragma mapbox: initialize-attribute highp vec4 bloom_attenuation\nfloat saturate(float val) {return clamp(val,0.0,1.0);}void main() {float 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\nglFragColor=vec4(v_color_emissive.rgb,1.0)*opacity;}","in vec3 a_pos_3f;\n#pragma mapbox: define-attribute-vertex-shader-only highp vec2 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 vec2 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(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);}"),buildingDepth:qn("in highp float v_depth;void main() {\n#ifndef DEPTH_TEXTURE\nglFragColor=pack_depth(v_depth);\n#endif\n}","in vec3 a_pos_3f;uniform mat4 u_matrix;out highp float v_depth;void main() {gl_Position=u_matrix*vec4(a_pos_3f,1.0);v_depth=gl_Position.z/gl_Position.w;}"),circle:qn('#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 vec2 a_pos;\n#ifdef PROJECTION_GLOBE_VIEW\nin vec3 a_pos_3;in vec3 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,-1),radius,stroke_width,view_scale);vec2 c2=pos+calc_offset(vec2(1,-1),radius,stroke_width,view_scale);vec2 c3=pos+calc_offset(vec2(1,1),radius,stroke_width,view_scale);vec2 c4=pos+calc_offset(vec2(-1,1),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 extrude=vec2(mod(a_pos,2.0)*2.0-1.0);vec2 circle_center=floor(a_pos*0.5);vec4 world_center;mat3 surface_vectors;\n#ifdef PROJECTION_GLOBE_VIEW\nvec3 pos_normal_3=a_pos_normal_3/16384.0;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(circle_center)*circle_elevation(circle_center);vec3 globe_pos=a_pos_3+surface_extrusion+globe_elevation;vec3 mercator_elevation=u_up_dir*u_tile_up_scale*circle_elevation(circle_center);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);float height=circle_elevation(circle_center);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:qn("void main() {glFragColor=vec4(1.0);}","in vec2 a_pos;uniform mat4 u_matrix;void main() {gl_Position=u_matrix*vec4(a_pos,0,1);}"),heatmap:qn('#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_opacity;uniform float u_intensity;in vec2 a_pos;\n#ifdef PROJECTION_GLOBE_VIEW\nin vec3 a_pos_3;in vec3 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(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(a_pos*0.5);vec3 pos;\n#ifdef PROJECTION_GLOBE_VIEW\nvec3 pos_normal_3=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=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:qn("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 vec2 a_pos;out vec2 v_pos;void main() {gl_Position=vec4(a_pos,0,1);v_pos=a_pos*0.5+0.5;}"),collisionBox:qn("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 vec3 a_pos;in vec2 a_anchor_pos;in vec2 a_extrude;in vec2 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() {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(a_anchor_pos));vec3 proj_pos=a_pos+elevationVector(a_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,a_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+=(a_extrude*a_size_scale+a_shift+a_padding)*u_extrude_scale*gl_Position.w*collision_perspective_ratio;v_placed=a_placed.x;v_notUsed=a_placed.y;}'),collisionCircle:qn("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 vec2 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;float collision=a_flags.x;float vertexIdx=a_flags.y;vec2 quadVertexOffset=vec2(\nmix(-1.0,1.0,float(vertexIdx >=2.0)),mix(-1.0,1.0,float(vertexIdx >=1.0 && vertexIdx <=2.0)));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=collision;gl_Position=vec4(clipPos.xyz/clipPos.w,1.0)+vec4(quadVertexExtent*padding_factor/u_viewport_size*2.0,0.0,0.0);}"),debug:qn("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 vec2 a_pos;\n#ifdef PROJECTION_GLOBE_VIEW\nin vec3 a_pos_3;\n#endif\nout vec2 v_uv;uniform mat4 u_matrix;uniform float u_overlay_scale;void main() {float h=elevation(a_pos);v_uv=a_pos/8192.0;\n#ifdef PROJECTION_GLOBE_VIEW\ngl_Position=u_matrix*vec4(a_pos_3+elevationVector(a_pos)*h,1);\n#else\ngl_Position=u_matrix*vec4(a_pos*u_overlay_scale,h,1);\n#endif\n}'),elevatedStructuresDepth:qn("void main() {\n#ifndef DEPTH_TEXTURE\nglFragColor=vec4(0.);\n#endif\n}","in vec2 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;}"),elevatedStructuresDepthReconstruct:qn("#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);\n#endif\n#endif\nglFragColor=vec4(1.0,0.0,0.0,1.0);}","in vec2 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;}"),elevatedStructures:qn('#include "_prelude_fog.fragment.glsl"\n#include "_prelude_lighting.glsl"\n#include "_prelude_shadow.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;\n#pragma mapbox: define highp vec4 structure_color\nvoid main() {\n#pragma mapbox: initialize highp vec4 structure_color\nvec3 color=structure_color.xyz;\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 shadowed_lighting_factor=shadowed_light_factor_normal(transformed_normal,v_pos_light_view_0,v_pos_light_view_1,v_depth);color.rgb=apply_lighting(color.rgb,transformed_normal,shadowed_lighting_factor);\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);\n#endif\nglFragColor=out_color;HANDLE_WIREFRAME_DEBUG;}','#include "_prelude_fog.vertex.glsl"\n#include "_prelude_shadow.vertex.glsl"\nin vec2 a_pos;in float a_height;in vec3 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=a_pos_normal_3/16384.0;v_height=a_height;vec3 pos=vec3(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(a_pos);\n#endif\n}'),fill:qn('#include "_prelude_fog.fragment.glsl"\n#include "_prelude_lighting.glsl"\n#include "_prelude_shadow.fragment.glsl"\n#pragma mapbox: define highp vec4 color\n#pragma mapbox: define lowp float opacity\nuniform float u_emissive_strength;\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\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);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;\n#ifdef INDICATOR_CUTOUT\nif (v_z_offset >=0.0) {out_color=applyCutout(out_color,v_z_offset);}\n#endif\n#ifdef FEATURE_CUTOUT\nout_color=apply_feature_cutout(out_color,gl_FragCoord);\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_shadow.vertex.glsl"\nin vec2 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;\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(a_pos);\n#endif\n#ifdef INDICATOR_CUTOUT\nv_z_offset=z_offset;\n#endif\n}'),fillOutline:qn('#include "_prelude_fog.fragment.glsl"\n#include "_prelude_lighting.glsl"\n#include "_prelude_shadow.fragment.glsl"\nin highp vec2 v_pos;uniform float u_emissive_strength;\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;\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);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\nout_color=apply_feature_cutout(out_color,gl_FragCoord);\n#endif\nglFragColor=out_color*(alpha*opacity);\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 vec2 a_pos;\n#ifdef ELEVATED_ROADS\nin float a_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;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;\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(a_pos);\n#endif\n}'),fillOutlinePattern:qn('#include "_prelude_fog.fragment.glsl"\n#include "_prelude_lighting.glsl"\n#include "_prelude_shadow.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;\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\nin highp vec2 v_pos;in highp vec2 v_pos_world;\n#pragma mapbox: define lowp float opacity\n#pragma mapbox: define lowp vec4 pattern\n#ifdef FILL_PATTERN_TRANSITION\n#pragma mapbox: define mediump vec4 pattern_b\n#endif\nvoid main() {\n#pragma mapbox: initialize lowp float opacity\n#pragma mapbox: initialize mediump vec4 pattern\n#ifdef FILL_PATTERN_TRANSITION\n#pragma mapbox: initialize mediump vec4 pattern_b\n#endif\nvec2 pattern_tl=pattern.xy;vec2 pattern_br=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=pattern_b.xy;vec2 pattern_b_br=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_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);out_color.rgb*=mix(u_ground_shadow_factor,vec3(1.0),light);\n#endif\n#endif\n#ifdef FEATURE_CUTOUT\nout_color=apply_feature_cutout(out_color,gl_FragCoord);\n#endif\n#ifdef FOG\nout_color=fog_dither(fog_apply_premultiplied(out_color,v_fog_pos));\n#endif\nglFragColor=out_color*(alpha*opacity);\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 vec2 u_pixel_coord_upper;uniform vec2 u_pixel_coord_lower;uniform float u_tile_units_to_pixels;in vec2 a_pos;\n#ifdef ELEVATED_ROADS\nin float a_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 vec4 pattern\n#ifdef FILL_PATTERN_TRANSITION\n#pragma mapbox: define mediump vec4 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 vec4 pattern\n#ifdef FILL_PATTERN_TRANSITION\n#pragma mapbox: initialize mediump vec4 pattern_b\n#endif\n#pragma mapbox: initialize lowp float pixel_ratio\n#pragma mapbox: initialize highp float z_offset\nvec2 pattern_tl=pattern.xy;vec2 pattern_br=pattern.zw;\n#ifdef ELEVATED_ROADS\nz_offset+=a_road_z_offset;\n#endif\nfloat hidden=float(opacity==0.0);gl_Position=mix(u_matrix*vec4(a_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,a_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(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(a_pos);\n#endif\n}'),fillPattern:qn('#include "_prelude_fog.fragment.glsl"\n#include "_prelude_lighting.glsl"\n#include "_prelude_shadow.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;\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 vec4 pattern\n#ifdef FILL_PATTERN_TRANSITION\n#pragma mapbox: define mediump vec4 pattern_b\n#endif\nvoid main() {\n#pragma mapbox: initialize lowp float opacity\n#pragma mapbox: initialize mediump vec4 pattern\n#ifdef FILL_PATTERN_TRANSITION\n#pragma mapbox: initialize mediump vec4 pattern_b\n#endif\nvec2 pattern_tl=pattern.xy;vec2 pattern_br=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=pattern_b.xy;vec2 pattern_b_br=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_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);\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\nout_color=apply_feature_cutout(out_color,gl_FragCoord);\n#endif\n#ifdef FOG\nout_color=fog_dither(fog_apply_premultiplied(out_color,v_fog_pos));\n#endif\nglFragColor=out_color*opacity;\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_pixel_coord_upper;uniform vec2 u_pixel_coord_lower;uniform float u_tile_units_to_pixels;in vec2 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 vec4 pattern\n#ifdef FILL_PATTERN_TRANSITION\n#pragma mapbox: define mediump vec4 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 vec4 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 vec4 pattern_b\n#endif\nvec2 pattern_tl=pattern.xy;vec2 pattern_br=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);gl_Position=mix(u_matrix*vec4(a_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,a_pos);\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(a_pos);\n#endif\n}'),fillExtrusion:qn('#include "_prelude_fog.fragment.glsl"\n#include "_prelude_shadow.fragment.glsl"\n#include "_prelude_lighting.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 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\ncolor=applyCutout(color,h);\n#endif\n#ifdef FEATURE_CUTOUT\ncolor=apply_feature_cutout(color,gl_FragCoord);\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;uniform vec3 u_lightcolor;uniform lowp vec3 u_lightpos;uniform lowp float u_lightintensity;uniform float u_vertical_gradient;uniform lowp float u_opacity;uniform float u_edge_radius;uniform float u_width_scale;in vec4 a_pos_normal_ed;in vec2 a_centroid_pos;\n#ifdef RENDER_WALL_MODE\nin vec3 a_join_normal_inside;\n#endif\n#ifdef PROJECTION_GLOBE_VIEW\nin vec3 a_pos_3;in vec3 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;out 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;vec3 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 pos_nx=floor(a_pos_normal_ed*0.5);vec4 top_up_ny_start=a_pos_normal_ed-2.0*pos_nx;vec3 top_up_ny=top_up_ny_start.xyz;float x_normal=pos_nx.z/8192.0;vec3 normal=top_up_ny.y==1.0 ? vec3(0.0,0.0,1.0) : normalize(vec3(x_normal,(2.0*top_up_ny.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.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=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);c_ele=is_flat_height || is_flat_base ? (centroid_pos.y==0.0 ? 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;pos=vec3(pos_nx.xy,h);\n#else\nh=t > 0.0 ? height : base;pos=vec3(pos_nx.xy,h);\n#endif\n#ifdef PROJECTION_GLOBE_VIEW\nfloat lift=float((t+base) > 0.0)*u_height_lift;h+=lift;vec3 globe_normal=normalize(mix(a_pos_normal_3/16384.0,u_up_dir,u_zoom_transition));vec3 globe_pos=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#ifdef RENDER_CUTOFF\nvec3 centroid_random=vec3(centroid_pos.xy,centroid_pos.x+centroid_pos.y+1.0);vec3 ground_pos=centroid_pos.x==0.0 ? pos.xyz : (centroid_random/8.0);vec4 ground=u_matrix*vec4(ground_pos.xy,ele,1.0);\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 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_WALL_MODE\nvec2 wall_offset=u_width_scale*line_width*(a_join_normal_inside.xy/EXTENT);scaled_pos.xy+=(1.0-a_join_normal_inside.z)*wall_offset*0.5;scaled_pos.xy-=a_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.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.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}'),fillExtrusionDepth:qn("in highp float v_depth;void main() {\n#ifndef DEPTH_TEXTURE\nglFragColor=pack_depth(v_depth);\n#endif\n}",'#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 vec4 a_pos_normal_ed;in vec2 a_centroid_pos;\n#ifdef RENDER_WALL_MODE\nin vec3 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\nout highp float v_depth;void 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 pos_nx=floor(a_pos_normal_ed.xyz*0.5);mediump vec3 top_up_ny=a_pos_normal_ed.xyz-2.0*pos_nx;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=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);float c_ele=is_flat_height || is_flat_base ? (centroid_pos.y==0.0 ? 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\nvec2 wall_offset=u_width_scale*line_width*(a_join_normal_inside.xy/EXTENT);pos.xy+=(1.0-a_join_normal_inside.z)*wall_offset*0.5;pos.xy-=a_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);v_depth=gl_Position.z/gl_Position.w;}'),fillExtrusionPattern:qn('#include "_prelude_fog.fragment.glsl"\n#include "_prelude_lighting.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 vec4 pattern\n#ifdef FILL_EXTRUSION_PATTERN_TRANSITION\n#pragma mapbox: define mediump vec4 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 vec4 pattern\n#ifdef FILL_EXTRUSION_PATTERN_TRANSITION\n#pragma mapbox: initialize mediump vec4 pattern_b\n#endif\n#pragma mapbox: initialize highp float pixel_ratio\nvec2 pattern_tl=pattern.xy;vec2 pattern_br=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=pattern_b.xy;vec2 pattern_b_br=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;uniform vec3 u_lightcolor;uniform lowp vec3 u_lightpos;uniform lowp float u_lightintensity;in vec4 a_pos_normal_ed;in vec2 a_centroid_pos;\n#ifdef RENDER_WALL_MODE\nin vec3 a_join_normal_inside;\n#endif\n#ifdef PROJECTION_GLOBE_VIEW\nin vec3 a_pos_3;in vec3 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 vec4 pattern\n#ifdef FILL_EXTRUSION_PATTERN_TRANSITION\n#pragma mapbox: define mediump vec4 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 vec4 pattern\n#ifdef FILL_EXTRUSION_PATTERN_TRANSITION\n#pragma mapbox: initialize mediump vec4 pattern_b\n#endif\n#pragma mapbox: initialize highp float pixel_ratio\n#pragma mapbox: initialize highp float line_width\nvec2 pattern_tl=pattern.xy;vec2 pattern_br=pattern.zw;vec4 pos_nx=floor(a_pos_normal_ed*0.5);mediump vec4 top_up_ny_start=a_pos_normal_ed-2.0*pos_nx;mediump vec3 top_up_ny=top_up_ny_start.xyz;float x_normal=pos_nx.z/8192.0;vec3 normal=top_up_ny.y==1.0 ? vec3(0.0,0.0,1.0) : normalize(vec3(x_normal,(2.0*top_up_ny.z-1.0)*(1.0-abs(x_normal)),0.0));float edgedistance=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.x;float z=t > 0.0 ? height : base;vec2 centroid_pos=vec2(0.0);\n#if defined(HAS_CENTROID) || defined(TERRAIN)\ncentroid_pos=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);c_ele=is_flat_height || is_flat_base ? (centroid_pos.y==0.0 ? 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(a_pos_normal_3/16384.0,u_up_dir,u_zoom_transition));vec3 globe_pos=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\nvec2 wall_offset=u_width_scale*line_width*(a_join_normal_inside.xy/EXTENT);p.xy+=(1.0-a_join_normal_inside.z)*wall_offset*0.5;p.xy-=a_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.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}'),groundShadow:qn('#include "_prelude_shadow.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\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 vec2 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(a_pos);v_fog_opacity=fog(v_fog_pos);\n#endif\n}'),fillExtrusionGroundEffect:qn("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\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\nHANDLE_WIREFRAME_DEBUG;\n#endif\n}",'#include "_prelude_fog.vertex.glsl"\nin highp vec4 a_pos_end;in highp float a_angular_offset_factor;in highp float 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\nvec2 p=a_pos_end.xy;vec2 q=floor(a_pos_end.zw*0.5);vec2 start_bottom=a_pos_end.zw-q*2.0;float fl_ground_radius=flood_light_ground_radius;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=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=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}'),hillshadePrepare:qn("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 vec2 a_pos;in vec2 a_texture_pos;out vec2 v_pos;void main() {gl_Position=u_matrix*vec4(a_pos,0,1);highp vec2 epsilon=1.0/u_dimension;float scale=(u_dimension.x-2.0)/u_dimension.x;v_pos=(a_texture_pos/8192.0)*scale+epsilon;}"),hillshade:qn('#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 OVERDRAW_INSPECTOR\nglFragColor=vec4(1.0);\n#endif\nHANDLE_WIREFRAME_DEBUG;}','#include "_prelude_fog.vertex.glsl"\nuniform mat4 u_matrix;in vec2 a_pos;in vec2 a_texture_pos;out vec2 v_pos;void main() {gl_Position=u_matrix*vec4(a_pos,0,1);v_pos=a_texture_pos/8192.0;\n#ifdef FOG\nv_fog_pos=fog_position(a_pos);\n#endif\n}'),line:qn('#include "_prelude_fog.fragment.glsl"\n#include "_prelude_lighting.glsl"\n#include "_prelude_shadow.fragment.glsl"\nuniform lowp float u_device_pixel_ratio;uniform highp float u_width_scale;uniform highp float u_floor_width_scale;uniform float u_alpha_discard_threshold;uniform highp vec2 u_trim_offset;uniform highp vec2 u_trim_fade_range;uniform lowp vec4 u_trim_color;in vec2 v_width2;in vec2 v_normal;in float v_gamma_scale;in highp vec3 v_uv;\n#ifdef ELEVATED_ROADS\nin highp float v_road_z_offset;\n#endif\n#ifdef RENDER_LINE_DASH\nuniform sampler2D u_dash_image;in vec2 v_tex;\n#endif\n#ifdef RENDER_LINE_GRADIENT\nuniform sampler2D u_gradient_image;\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\nfloat luminance(vec3 c) {return (c.r+c.r+c.b+c.g+c.g+c.g)*0.1667;}uniform float u_emissive_strength;\n#pragma mapbox: define highp vec4 color\n#pragma mapbox: define lowp float floorwidth\n#pragma mapbox: define lowp vec4 dash\n#pragma mapbox: define lowp float blur\n#pragma mapbox: define lowp float opacity\n#pragma mapbox: define lowp float border_width\n#pragma mapbox: define lowp vec4 border_color\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 lowp vec4 dash\n#pragma mapbox: initialize lowp float blur\n#pragma mapbox: initialize lowp float opacity\n#pragma mapbox: initialize lowp float border_width\n#pragma mapbox: initialize lowp vec4 border_color\nfloat 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);\n#ifdef RENDER_LINE_DASH\nfloat sdfdist=texture(u_dash_image,v_tex).r;float sdfgamma=1.0/(2.0*u_device_pixel_ratio)/dash.z;float scaled_floorwidth=(floorwidth*u_floor_width_scale);alpha*=linearstep(0.5-sdfgamma/scaled_floorwidth,0.5+sdfgamma/scaled_floorwidth,sdfdist);\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);out_color=mix(out_color,u_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\nfloat edgeBlur=((border_width*u_width_scale)+1.0/u_device_pixel_ratio);float alpha2=clamp(min(dist-(v_width2.t-edgeBlur),v_width2.s-dist)/edgeBlur,0.0,1.0);if (alpha2 < 1.) {float smoothAlpha=smoothstep(0.6,1.0,alpha2);if (border_color.a==0.0) {float 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-smoothAlpha));} else {out_color.rgb*=(0.6 +0.4*smoothAlpha);}} else {out_color=mix(border_color*trim_alpha,out_color,smoothAlpha);}}\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);\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*opacity);\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);\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_shadow.vertex.glsl"\n#include "_prelude_terrain.vertex.glsl"\n#define EXTRUDE_SCALE 0.015873016\nin vec2 a_pos_normal;in vec4 a_data;\n#if defined(ELEVATED) || defined(ELEVATED_ROADS) || defined(VARIABLE_LINE_WIDTH)\nin vec3 a_z_offset_width;\n#endif\n#if defined(RENDER_LINE_GRADIENT) || defined(RENDER_LINE_TRIM_OFFSET)\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 highp 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 float v_gamma_scale;out highp vec3 v_uv;\n#ifdef ELEVATED_ROADS\nout highp float v_road_z_offset;\n#endif\n#ifdef RENDER_LINE_DASH\nuniform vec2 u_texsize;uniform float u_tile_units_to_pixels;out vec2 v_tex;\n#endif\n#ifdef RENDER_LINE_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 lowp vec4 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 lowp float border_width\n#pragma mapbox: define lowp vec4 border_color\nvoid main() {\n#pragma mapbox: initialize highp vec4 color\n#pragma mapbox: initialize lowp float floorwidth\n#pragma mapbox: initialize lowp vec4 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 lowp float border_width\n#pragma mapbox: initialize lowp vec4 border_color\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=a_data.xy-128.0;float a_direction=mod(a_data.z,4.0)-1.0;vec2 pos=floor(a_pos_normal*0.5);mediump vec2 normal=a_pos_normal-2.0*pos;normal.y=normal.y*2.0-1.0;v_normal=normal;gapwidth=gapwidth/2.0;float halfwidth;\n#ifdef VARIABLE_LINE_WIDTH\nfloat left=a_pos_normal.y-2.0*floor(a_pos_normal.y*0.5);halfwidth=(u_width_scale*(left==1.0 ? a_z_offset_width.y : a_z_offset_width.z))/2.0;\n#else\nhalfwidth=(u_width_scale*width)/2.0;\n#endif\noffset=-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);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;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;\n#ifdef CROSS_SLOPE_VERTICAL\nfloat top=a_pos_normal.y-2.0*floor(a_pos_normal.y*0.5);float line_height=2.0*u_tile_to_meter*outset*top*u_pixels_to_tile_units[1][1]+a_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+a_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+a_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 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_TRIM_OFFSET)\nhighp float a_uv_x=a_packed[0];float a_split_index=a_packed[1];highp float line_progress=a_packed[2];\n#ifdef RENDER_LINE_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\nfloat scale=dash.z==0.0 ? 0.0 : u_tile_units_to_pixels/dash.z;float height=dash.y;v_tex=vec2(a_linesofar*scale/(floorwidth*u_floor_width_scale),(-normal.y*height+dash.x+0.5)/u_texsize.y);\n#endif\nv_width2=vec2(outset,inset);\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:qn('#include "_prelude_fog.fragment.glsl"\n#include "_prelude_lighting.glsl"\n#include "_prelude_shadow.fragment.glsl"\nuniform highp float u_device_pixel_ratio;uniform highp float u_width_scale;uniform highp float u_alpha_discard_threshold;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\nuniform float u_emissive_strength;\n#pragma mapbox: define mediump vec4 pattern\n#ifdef LINE_PATTERN_TRANSITION\n#pragma mapbox: define mediump vec4 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\nvoid main() {\n#pragma mapbox: initialize mediump vec4 pattern\n#ifdef LINE_PATTERN_TRANSITION\n#pragma mapbox: initialize mediump vec4 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\nvec2 pattern_tl=pattern.xy;vec2 pattern_br=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=pattern_b.xy;vec2 pattern_b_br=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,u_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);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 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 vec2 a_pos_normal;in vec4 a_data;\n#if defined(ELEVATED) || defined(ELEVATED_ROADS)\nin vec3 a_z_offset_width;\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 vec4 pattern\n#ifdef LINE_PATTERN_TRANSITION\n#pragma mapbox: define mediump vec4 pattern_b\n#endif\n#pragma mapbox: define mediump float pixel_ratio\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 vec4 pattern\n#ifdef LINE_PATTERN_TRANSITION\n#pragma mapbox: initialize mediump vec4 pattern_b\n#endif\n#pragma mapbox: initialize mediump float pixel_ratio\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=a_data.xy-128.0;float a_direction=mod(a_data.z,4.0)-1.0;vec2 pos=floor(a_pos_normal*0.5);vec2 normal=a_pos_normal-2.0*pos;normal.y=normal.y*2.0-1.0;v_normal=normal;gapwidth=gapwidth/2.0;float halfwidth=(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;\n#ifdef CROSS_SLOPE_VERTICAL\nfloat top=a_pos_normal.y-2.0*floor(a_pos_normal.y*0.5);float line_height=2.0*u_tile_to_meter*outset*top*u_pixels_to_tile_units[1][1]+a_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+a_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+a_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/((pattern.w-pattern.y)*pixel_ratio_inverse);highp float subt_multiple=(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:qn('#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;\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#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\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 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#define GLOBE_UPSCALE GLOBE_RADIUS/6371008.8\n#ifdef GLOBE_POLES\nin vec3 a_globe_pos;in vec2 a_uv;\n#else\nin vec2 a_pos;in vec2 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;globe_pos+=normalize(globe_pos)*u_raster_elevation*GLOBE_UPSCALE;gl_Position=u_matrix*u_globe_matrix*vec4(globe_pos ,1.0);uv=a_uv;\n#ifdef FOG\nv_fog_pos=fog_position((u_normalize_matrix*vec4(a_globe_pos,1.0)).xyz);\n#endif\n#else\nfloat w=1.0+dot(a_texture_pos,u_perspective_transform);uv=a_texture_pos/8192.0;\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);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);float mercatorY=mercatorYfromLat(latLng[0]);float mercatorX=mercatorXfromLng(latLng[1]); \nv_split_fade=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;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)));}float 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);}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\ngl_Position=u_matrix*vec4(a_pos*w,u_raster_elevation*w,w);\n#ifdef FOG\nv_fog_pos=fog_position(a_pos);\n#endif\n#endif\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 RENDER_CUTOFF\nv_depth=gl_Position.z;\n#endif\n}'),rasterParticle:qn('#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 vec2 a_pos;in vec2 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=a_texture_pos/8192.0;gl_Position=u_matrix*vec4(a_pos*w,u_raster_elevation*w,w);\n#ifdef FOG\nv_fog_pos=fog_position(a_pos);\n#endif\n#endif\nv_pos0=uv;v_pos1=(v_pos0*u_scale_parent)+u_tl_parent;}'),rasterParticleDraw:qn("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 float 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(a_index,u_particle_texture_side_len),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:qn("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 vec2 a_pos;out vec2 v_tex_pos;void main() {vec2 uv=0.5*a_pos+vec2(0.5);v_tex_pos=uv;gl_Position=vec4(a_pos,0.0,1.0);}"),rasterParticleUpdate:qn('#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 vec2 a_pos;out vec2 v_tex_coord;void main() {v_tex_coord=0.5*(a_pos+vec2(1.0));gl_Position=vec4(a_pos,0.0,1.0);}"),symbol:qn('#include "_prelude_lighting.glsl"\n#include "_prelude_shadow.fragment.glsl"\n#define SDF_PX 8.0\n#define SDF 1.0\n#define ICON 0.0\nuniform sampler2D u_texture;uniform sampler2D u_texture_icon;uniform highp float u_gamma_scale;uniform lowp float u_device_pixel_ratio;uniform bool u_is_text;uniform bool u_is_halo;uniform lowp float u_scale_factor;\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\n#pragma mapbox: define highp vec4 fill_color\n#pragma mapbox: define highp vec4 halo_color\n#pragma mapbox: define lowp float opacity\n#pragma mapbox: define lowp float halo_width\n#pragma mapbox: define lowp float halo_blur\n#pragma mapbox: define lowp float emissive_strength\nvoid main() {\n#pragma mapbox: initialize highp vec4 fill_color\n#pragma mapbox: initialize highp vec4 halo_color\n#pragma mapbox: initialize lowp float opacity\n#pragma mapbox: initialize lowp float halo_width\n#pragma mapbox: initialize lowp float halo_blur\n#pragma mapbox: initialize lowp float emissive_strength\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;glFragColor=texture(u_texture_icon,tex_icon)*alpha;\n#ifdef OVERDRAW_INSPECTOR\nglFragColor=vec4(1.0);\n#endif\nreturn;}\n#endif\n#ifdef RENDER_SDF\nfloat 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;\n#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#endif\nout_color*=opacity*fade_opacity;\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);\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);\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 APPEARANCE_ICON 1.0\nin vec4 a_pos_offset;in vec4 a_tex_size;in vec4 a_pixeloffset;in vec4 a_projected_pos;in float a_fade_opacity;\n#ifdef Z_OFFSET\nin float a_auto_z_offset;\n#endif\n#ifdef PROJECTION_GLOBE_VIEW\nin vec3 a_globe_anchor;in vec3 a_globe_normal;\n#endif\n#ifdef ICON_TRANSITION\nin vec2 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;uniform mat4 u_inv_matrix;uniform 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;uniform vec3 u_up_vector;uniform vec2 u_texsize_icon;uniform 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#pragma mapbox: define highp vec4 fill_color\n#pragma mapbox: define highp vec4 halo_color\n#pragma mapbox: define lowp float opacity\n#pragma mapbox: define lowp float halo_width\n#pragma mapbox: define lowp float halo_blur\n#pragma mapbox: define lowp float emissive_strength\n#pragma mapbox: define lowp float occlusion_opacity\n#pragma mapbox: define lowp float z_offset\nvoid main() {\n#pragma mapbox: initialize highp vec4 fill_color\n#pragma mapbox: initialize highp vec4 halo_color\n#pragma mapbox: initialize lowp float opacity\n#pragma mapbox: initialize lowp float halo_width\n#pragma mapbox: initialize lowp float halo_blur\n#pragma mapbox: initialize lowp float emissive_strength\n#pragma mapbox: initialize lowp float occlusion_opacity\n#pragma mapbox: initialize lowp float z_offset\nvec2 a_pos=a_pos_offset.xy;vec2 a_offset=a_pos_offset.zw;vec2 a_tex=a_tex_size.xy;vec2 a_size=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_icon=a_size[1]-2.0*a_size_max;vec2 a_pxoffset=a_pixeloffset.xy;vec2 a_min_font_scale=a_pixeloffset.zw/256.0;highp float segment_angle=-a_projected_pos[3];float size;if (a_apperance_icon==APPEARANCE_ICON) {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=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(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);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=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:qn('#include "_prelude_fog.fragment.glsl"\n#include "_prelude_shadow.fragment.glsl"\n#include "_prelude_lighting.glsl"\nuniform sampler2D u_image0;in 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\nvec3 unlit_base=image_color.rgb*(1.0-image_color.a);vec3 emissive_base=image_color.rgb*image_color.a;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\ncolor.rgb=mix(color.rgb,image_color.rgb,image_color.a);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 vec2 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;gl_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:qn("precision highp float;in float v_depth;void main() {glFragColor=pack_depth(v_depth);}",'#include "_prelude_terrain.vertex.glsl"\nuniform mat4 u_matrix;in vec2 a_pos;out float v_depth;void main() {float elevation=elevation(a_pos);gl_Position=u_matrix*vec4(a_pos,elevation,1.0);v_depth=gl_Position.z/gl_Position.w;}'),skybox:qn('#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}',Fn),skyboxGradient:qn('#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}',Fn),skyboxCapture:qn("\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;v_position.y*=-1.0;v_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:qn('#include "_prelude_fog.fragment.glsl"\n#include "_prelude_lighting.glsl"\nuniform sampler2D u_image0;uniform 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;\n#ifdef FLIP_Y\nuv.y=1.0-uv.y;\n#endif\nhighp 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\nraster=apply_lighting_with_emission_ground(raster,raster.a);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\ncolor=apply_lighting_with_emission_ground(color,color.a);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;uniform mat4 u_merc_matrix;uniform float u_zoom_transition;uniform vec2 u_merc_center;uniform mat3 u_grid_matrix;uniform float u_skirt_height;\n#ifdef GLOBE_POLES\nin vec3 a_globe_pos;in vec2 a_uv;\n#else\nin vec2 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;vec2 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:qn('#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);}"),model:qn('#include "_prelude_fog.fragment.glsl"\n#include "_prelude_shadow.fragment.glsl"\n#include "_prelude_lighting.glsl"\nuniform float u_opacity;uniform vec3 u_lightcolor;uniform vec3 u_lightpos;uniform float u_lightintensity;uniform 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 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\nif(texColor.w > 0.0) {texColor.rgb/=texColor.w;}texColor.w=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=u_lightpos;vec3 lightColor=u_lightcolor;\n#ifdef LIGHTING_3D_MODE\nlightDir=u_lighting_directional_dir;lightDir.xy=-lightDir.xy;lightColor=u_lighting_directional_color;\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 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\nfinalColor=apply_feature_cutout(finalColor,gl_FragCoord);\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"\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 vec4 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 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 vec4 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\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#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(pbr.xy);vec2 e_r_m=unpack_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(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:qn("in highp float v_depth;void main() {\n#ifndef DEPTH_TEXTURE\nglFragColor=pack_depth(v_depth);\n#endif\n}","in vec3 a_pos_3f;uniform mat4 u_matrix;out highp float v_depth;\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\nv_depth=gl_Position.z/gl_Position.w;}"),stars:qn("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_fade_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_fade_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);}"),snowParticle:qn("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:qn("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:qn("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);}"),occlusion:qn("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 Wn(e,t){const i=e.replace(/\s*\/\/[^\n]*\n/g,"\n").split("\n");for(let e of i)if(e=e.trim(),"#"===e[0]&&e.includes("if")&&!e.includes("endif")){e=e.replace("#","").replace(/ifdef|ifndef|elif|if/g,"").replace(/!|defined|\(|\)|\|\||&&/g,"").replace(/\s+/g," ").trim();const i=e.split(" ");for(const e of i)t.includes(e)||t.push(e)}}function qn(e,t){const i=/#include\s+"([^"]+)"/g,n=/#pragma mapbox: ([\w\-]+) ([\w]+) ([\w]+) ([\w]+)/g,r={},o=[],s=[];if(e=e.replace(i,(e,t)=>(s.push(t),"")),(t=t.replace(i,(e,t)=>(o.push(t),""))).includes("flat out"))return void console.error('The usage of "flat" qualifier is disallowed, see: https://bugs.webkit.org/show_bug.cgi?id=268071');let a=[...jn];Wn(e,a),Wn(t,a);for(const e of[...o,...s])Gn[e]||console.error(`Undefined include: ${e}`),Hn[e]||(Hn[e]=[],Wn(Gn[e],Hn[e])),a=[...a,...Hn[e]];return{fragmentSource:e=e.replace(n,(e,t,i,n,o)=>(r[o]=!0,"define"===t?`\n#ifndef HAS_UNIFORM_u_${o}\nin ${i} ${n} ${o};\n#else\nuniform ${i} ${n} u_${o};\n#endif\n`:"initialize"===t?`\n#ifdef HAS_UNIFORM_u_${o}\n ${i} ${n} ${o} = u_${o};\n#endif\n`:"define-attribute"===t?`\n#ifdef HAS_ATTRIBUTE_a_${o}\n in ${i} ${n} ${o};\n#endif\n`:"initialize-attribute"===t?"":void 0)),vertexSource:t=t.replace(n,(e,t,i,n,o)=>{const s=`MATERIAL_ATTRIBUTE_OFFSET_${o}`,a="float"===n?"vec2":n,l=`GET_ATTRIBUTE_${a}(a_${o}, materialInfo, ${s})`,c=o.match(/color/)?"color":a;return"define-attribute-vertex-shader-only"===t?`\n#ifdef HAS_ATTRIBUTE_a_${o}\nin ${i} ${n} a_${o};\n#endif\n`:r[o]?"define"===t?`\n#ifndef HAS_UNIFORM_u_${o}\nuniform lowp float u_${o}_t;\n #if !defined(${s})\n in ${i} ${a} a_${o};\n #endif\nout ${i} ${n} ${o};\n#else\nuniform ${i} ${n} u_${o};\n#endif\n`:"initialize"===t?"vec4"===c?`\n#ifndef HAS_UNIFORM_u_${o}\n ${o} = a_${o};\n#else\n ${i} ${n} ${o} = u_${o};\n#endif\n`:`\n#if !defined(HAS_UNIFORM_u_${o}) \n #ifdef ${s}\n ${o} = unpack_mix_${c}(${l}, u_${o}_t);\n #else\n ${o} = unpack_mix_${c}(a_${o}, u_${o}_t);\n #endif\n#else\n ${i} ${n} ${o} = u_${o};\n#endif\n`:"define-attribute"===t?`\n#ifdef HAS_ATTRIBUTE_a_${o}\n in ${i} ${n} a_${o};\n out ${i} ${n} ${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(${s})\n in ${i} ${a} a_${o};\n #endif \n#else\nuniform ${i} ${n} u_${o};\n#endif\n`:"define-instanced"===t?"mat4"===c?`\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 ${i} ${n} u_${o};\n#endif\n`:`\n#ifdef INSTANCED_ARRAYS\nin ${i} ${a} a_${o};\n#else\nuniform ${i} ${n} u_${o};\n#endif\n`:"initialize-attribute-custom"===t?`\n#ifdef HAS_ATTRIBUTE_a_${o}\n ${i} ${n} ${o} = a_${o};\n#endif\n`:"vec4"===c?`\n#ifndef HAS_UNIFORM_u_${o}\n #ifdef ${s}\n ${i} ${n} ${o} = ${l};\n #else\n ${i} ${n} ${o} = a_${o};\n #endif\n#else\n ${i} ${n} ${o} = u_${o};\n#endif\n`:`\n#ifndef HAS_UNIFORM_u_${o}\n #ifdef ${s}\n ${i} ${n} ${o} = unpack_mix_${c}(${l}, u_${o}_t);\n #else\n ${i} ${n} ${o} = unpack_mix_${c}(a_${o}, u_${o}_t);\n #endif\n#else\n ${i} ${n} ${o} = u_${o};\n#endif\n`}),usedDefines:a,vertexIncludes:o,fragmentIncludes:s}}class Kn{constructor(){this.boundProgram=null,this.boundLayoutVertexBuffer=null,this.boundPaintVertexBuffers=[],this.boundIndexBuffer=null,this.boundVertexOffset=null,this.boundDynamicVertexBuffers=[],this.vao=null}bind(e,t,i,n,r,o,s,a){this.context=e;let l=this.boundPaintVertexBuffers.length!==n.length;for(let e=0;!l&&e{const o=n.paint.get("hillshade-shadow-color"),s="none"===n.paint.get("hillshade-shadow-color-use-theme").constantOr("default"),a=n.paint.get("hillshade-highlight-color"),l="none"===n.paint.get("hillshade-highlight-color-use-theme").constantOr("default"),c=n.paint.get("hillshade-accent-color"),u="none"===n.paint.get("hillshade-accent-color-use-theme").constantOr("default"),h=n.paint.get("hillshade-emissive-strength");let d=e.an(n.paint.get("hillshade-illumination-direction"));if("viewport"===n.paint.get("hillshade-illumination-anchor"))d-=t.transform.angle;else if(t.style&&t.style.enable3dLights()&&t.style.directionalLight){const i=t.style.directionalLight.properties.get("direction"),n=e.d3(i.x,i.y,i.z);d=e.an(n[1])}const p=!t.options.moving;return{u_matrix:r||t.transform.calculateProjMatrix(i.tileID.toUnwrapped(),p),u_image:0,u_latrange:Xn(0,i.tileID),u_light:[n.paint.get("hillshade-exaggeration"),d],u_shadow:o.toPremultipliedRenderColor(s?null:n.lut),u_highlight:a.toPremultipliedRenderColor(l?null:n.lut),u_emissive_strength:h,u_accent:c.toPremultipliedRenderColor(u?null:n.lut)}})(t,n,r,t.terrain?i.projMatrix:null);t.uploadCommonUniforms(l,d,i.toUnwrapped());const{tileBoundsBuffer:f,tileBoundsIndexBuffer:m,tileBoundsSegments:g}=t.getTileBoundsBuffers(n);d.draw(t,c.TRIANGLES,o,s,a,Xi.disabled,p,r.id,f,m,g)}function Yn(t,i,n){if(!i.needsDEMTextureUpload)return;const r=t.context,o=r.gl;r.pixelStoreUnpackPremultiplyAlpha.set(!1),i.demTexture=i.demTexture||t.getTileTexture(n.stride);const s=n.getPixels();i.demTexture?i.demTexture.update(s,{premultiply:!1}):i.demTexture=new e.T(r,s,o.R32F,{premultiply:!1}),i.needsDEMTextureUpload=!1}function er(t,i,n){const r=t.context,o=r.gl;if(!i.dem)return;const s=i.dem;if(r.activeTexture.set(o.TEXTURE1),Yn(t,i,s),!i.demTexture)return;i.demTexture.bind(o.NEAREST,o.CLAMP_TO_EDGE);const a=s.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,!0,"renderbuffer"),l.colorAttachment.set(t.texture)}r.bindFramebuffer.set(l.framebuffer),r.viewport.set([0,0,a,a]);const{tileBoundsBuffer:c,tileBoundsIndexBuffer:u,tileBoundsSegments:h}=t.getMercatorTileBoundsBuffers(),d=[];t.linearFloatFilteringSupported()&&d.push("TERRAIN_DEM_FLOAT_FORMAT"),t.getOrCreateProgram("hillshadePrepare",{defines:d}).draw(t,o.TRIANGLES,$i.disabled,Wi.disabled,Qi.unblended,Xi.disabled,((t,i)=>{const n=i.stride,r=e.bB();return e.cd(r,0,e.al,-e.al,0,0,1),e.bq(r,r,[0,-e.al,0]),{u_matrix:r,u_image:1,u_dimension:[n,n],u_zoom:t.overscaledZ}})(i.tileID,s),n.id,c,u,h),i.needsHillshadePrepare=!1}class tr{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 ir extends tr{getDefault(){return e.ao.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 nr extends tr{getDefault(){return 1}set(e){(e!==this.current||this.dirty)&&(this.gl.clearDepth(e),this.current=e,this.dirty=!1)}}class rr extends tr{getDefault(){return 0}set(e){(e!==this.current||this.dirty)&&(this.gl.clearStencil(e),this.current=e,this.dirty=!1)}}class or extends tr{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 sr extends tr{getDefault(){return!0}set(e){(e!==this.current||this.dirty)&&(this.gl.depthMask(e),this.current=e,this.dirty=!1)}}class ar extends tr{getDefault(){return 255}set(e){(e!==this.current||this.dirty)&&(this.gl.stencilMask(e),this.current=e,this.dirty=!1)}}class lr extends tr{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 cr extends tr{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 ur extends tr{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 hr extends tr{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 dr extends tr{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 pr extends tr{getDefault(){return this.gl.LESS}set(e){(e!==this.current||this.dirty)&&(this.gl.depthFunc(e),this.current=e,this.dirty=!1)}}class fr extends tr{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 mr extends tr{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 gr extends tr{getDefault(){return e.ao.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 _r extends tr{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 Ar extends tr{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 yr extends tr{getDefault(){return this.gl.BACK}set(e){(e!==this.current||this.dirty)&&(this.gl.cullFace(e),this.current=e,this.dirty=!1)}}class vr extends tr{getDefault(){return this.gl.CCW}set(e){(e!==this.current||this.dirty)&&(this.gl.frontFace(e),this.current=e,this.dirty=!1)}}let xr=class extends tr{getDefault(){return null}set(e){(e!==this.current||this.dirty)&&(this.gl.useProgram(e),this.current=e,this.dirty=!1)}};class br extends tr{getDefault(){return this.gl.TEXTURE0}set(e){(e!==this.current||this.dirty)&&(this.gl.activeTexture(e),this.current=e,this.dirty=!1)}}class wr extends tr{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 Tr extends tr{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 Er extends tr{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 Cr extends tr{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 Sr extends tr{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 Br extends tr{getDefault(){return null}set(e){const t=this.gl;t.bindBuffer(t.ELEMENT_ARRAY_BUFFER,e),this.current=e,this.dirty=!1}}class Ir extends tr{getDefault(){return null}set(e){this.gl&&(e!==this.current||this.dirty)&&(this.gl.bindVertexArray(e),this.current=e,this.dirty=!1)}}class Mr extends tr{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 Pr extends tr{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 Rr extends tr{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 Lr extends tr{constructor(e,t){super(e),this.context=e,this.parent=t}getDefault(){return null}}class Fr extends Lr{setDirty(){this.dirty=!0}set(e){if(e===this.current&&!this.dirty)return;this.context.bindFramebuffer.set(this.parent);const t=this.gl;t.framebufferTexture2D(t.FRAMEBUFFER,t.COLOR_ATTACHMENT0,t.TEXTURE_2D,e,0),this.current=e,this.dirty=!1}}class kr extends Lr{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 Dr extends Lr{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 Or extends kr{attachment(){return this.gl.DEPTH_STENCIL_ATTACHMENT}}const zr=(e,t,i)=>({u_matrix:e,u_image0:0,u_skirt_height:t,u_ground_shadow_factor:i}),Ur=(e,t,i,n,r,o,s,a,l,c,u,h,d,p,f,m)=>({u_proj_matrix:Float32Array.from(e),u_globe_matrix:t,u_normalize_matrix:Float32Array.from(n),u_merc_matrix:i,u_zoom_transition:r,u_merc_center:o,u_image0:0,u_frustum_tl:s,u_frustum_tr:a,u_frustum_br:l,u_frustum_bl:c,u_globe_pos:u,u_globe_radius:h,u_viewport:d,u_grid_matrix:m?Float32Array.from(m):new Float32Array(9),u_skirt_height:p,u_far_z_cutoff:f});function Nr(e,t){return null!=e&&null!=t&&!(!e.hasData()||!t.hasData())&&null!=e.demTexture&&null!=t.demTexture&&e.tileID.key!==t.tileID.key}const Vr=new class{constructor(){this.operations={}}newMorphing(e,t,i,n,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:n,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()}},jr={0:null,1:"TERRAIN_VERTEX_MORPHING"};function Gr(e,t,i){if(0===t)return 0;const n=t<1&&514===i?.25/t:1;return 6*Math.pow(1.5,22-e)*Math.max(t,1)*n}function Hr(e,t){const i=1<({u_matrix:e});function $r(t,i,n,r,o){if(o>0){const s=e.o.now(),a=(s-t.timeAdded)/o,l=i?(s-i.timeAdded)/o:-1,c=n.getSource(),u=r.coveringZoomLevel({tileSize:c.tileSize,roundZoom:c.roundZoom}),h=!i||Math.abs(i.tileID.overscaledZ-u)>Math.abs(t.tileID.overscaledZ-u),d=h&&t.refreshedUponExpiration?1:e.aA(h?a:1-l,0,1);return i?{opacity:1,mix:1-d,isFading:a<1}:{opacity:d,mix:0,isFading:a<1}}return{opacity:1,mix:0,isFading:!1}}class Zr extends Lt{constructor(e){const t=pt("mock-dem",{type:"raster-dem",maxzoom:e.transform.maxZoom},e.style.dispatcher,e.style);super("mock-dem",t,!1),t.setEventedParent(this),this._sourceLoaded=!0}_loadTile(e,t){e.state="loaded",t(null)}}class Wr extends Lt{constructor(e){const t=pt("proxy",{type:"geojson",maxzoom:e.transform.maxZoom},e.style.dispatcher,e.style);super("proxy",t,!1),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 n=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 It(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 n||(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 qr extends e.aP{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 Kr extends e.bU{constructor(t,i){super(),this._debugParams={sortTilesHiZFirst:!0,disableRenderCache:!1},t.tp.registerParameter(this._debugParams,["Terrain"],"sortTilesHiZFirst",{},()=>{this._style.map.triggerRepaint()}),t.tp.registerParameter(this._debugParams,["Terrain"],"disableRenderCache",{},()=>{this._style.map.triggerRepaint()}),t.tp.registerButton(["Terrain"],"Invalidate Render Cache",()=>{this.invalidateRenderCache=!0,this._style.map.triggerRepaint()}),this.painter=t,this.terrainTileForTile={},this.prevTerrainTileForTile={};const[n,r,o]=function(){const t=new e.bc,i=new e.b0,n=131;t.reserve(17161),i.reserve(33800);const r=e.al/128,o=e.al+r/2,s=o+r;for(let i=-r;io||i<0||i>o?24575:0,s=e.aA(Math.round(n),0,e.al),a=e.aA(Math.round(i),0,e.al);t.emplaceBack(s+r,a)}const a=(e,t)=>{const r=t*n+e;i.emplaceBack(r+1,r,r+n),i.emplaceBack(r+n,r+n+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]}(),s=t.context;this.gridBuffer=s.createVertexBuffer(n,e.be.members),this.gridIndexBuffer=s.createIndexBuffer(r),this.gridSegments=e.bf.simpleSegment(0,0,n.length,r.length),this.gridNoSkirtSegments=e.bf.simpleSegment(0,0,n.length,o),this.proxyCoords=[],this.proxiedCoords={},this._visibleDemTiles=[],this._drapedRenderBatches=[],this._sourceTilesOverlap={},this.proxySourceCache=new Wr(i.map),this.orthoMatrix=e.bB(),e.cd(this.orthoMatrix,"globe"===this.painter.transform.projection.name?.015:0,e.al,0,e.al,0,1);const a=s.gl;this._overlapStencilMode=new Wi({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 Zr(i.map),this._pendingGroundEffectLayers=[]}set style(e){e.on("data",this._onStyleDataEvent.bind(this)),this._style=e,this._style.map.on("moveend",()=>{this._clearLineLayersFromRenderCache()})}update(t,i,n){if(t&&t.terrain){this._style!==t&&(this.style=t,this._evaluationZoom=void 0);const r=t.terrain.properties,o=0===t.terrain.drapeRenderMode,s=t.terrain.isZoomDependent();this._previousUpdateTimestamp=this.enabled?this._updateTimestamp:void 0,this._updateTimestamp=e.o.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=s?this.calculateExaggeration(i):r.get("exaggeration"),!i.projection.requiresDraping&&s&&0===this._exaggeration)return void this._disable();this.enabled=!0;const u=()=>{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,u(),this._initializing=!0),u(),i.updateElevation(!0,n),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,n=t.getFreeCameraOptions().position.z/t.pixelsPerMeter*t.worldSize;this._previousCameraAltitude=n;const r=null!=i?n-i:Number.MAX_VALUE;if(Math.abs(r)<2)return this._exaggeration;const o=t.zoom,s=this._style.terrain;if(!this._previousUpdateTimestamp)return s.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 u=s.getExaggeration(c),h=u===s.getExaggeration(Math.max(0,c-.1));if(h&&Math.abs(u-this._exaggeration)<.01)return u;let d=Math.min(.1,.00375*(this._updateTimestamp-l));return(h||u<.1||Math.abs(a)<1e-4)&&(d=Math.min(.2,4*d)),e.ak(this._exaggeration,u,d)}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,n=this.painter.transform;this._initializing&&(this._initializing=0===n._centerAltitude&&-1===this.getAtPointOrZero(e.ae.fromLngLat(n.center),-1),this._emptyDEMTextureDirty=!this._initializing);const r=this.proxyCoords=i.getIds().map(e=>{const t=i.getTileByID(e).tileID;return t.projMatrix=n.calculateProjMatrix(t.toUnwrapped()),t});!function(t,i){const n=i.transform.pointCoordinate(i.transform.getCameraPoint()),r=new e.P(n.x,n.y);t.sort((t,i)=>{if(i.overscaledZ-t.overscaledZ)return i.overscaledZ-t.overscaledZ;const n=new e.P(t.canonical.x+(1<{this.proxyToSource[e.key]={}}),this.terrainTileForTile={};const s=this._style._mergedSourceCaches;for(const e in s){const i=s[e];if(!i.used)continue;if(i!==this.sourceCache&&this.resetTileLookupCache(i.id),this._setupProxiedCoordsForOrtho(i,t[e],o),i.usedForTerrain)continue;const n=t[e];i.getSource().reparseOverscaled&&this._assignTerrainTiles(n)}this.proxiedCoords[i.id]=r.map(e=>new qr(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 n=this.terrainTileForTile[i],r=n.dem;!r||n.demTexture&&!n.needsDEMTextureUpload||(e.activeTexture.set(t.TEXTURE1),Yn(this.painter,n,r))}}_prepareDemTileUniforms(e,t,i,n){if(!t||null==t.demTexture)return!1;const r=e.tileID.canonical,o=Math.pow(2,t.tileID.canonical.z-r.z),s=n||"";return i[`u_dem_tl${s}`]=[r.x*o%1,r.y*o%1],i[`u_dem_scale${s}`]=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 n=i.dem.tree.minimums[0];return n>0&&e++,t+n},0);return e?t/e:0}_updateEmptyDEMTexture(){const t=this.painter.context,i=t.gl;t.activeTexture.set(i.TEXTURE2);const n=this._getLoadedAreaMinimum(),r=new e.dK({width:1,height:1},new Float32Array([n]));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,n){const r=this.painter.context,o=r.gl,s={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.u_exaggeration=this.exaggeration();let a=null,l=null,c=1;if(n&&n.morphing&&this._useVertexMorphing){const e=n.morphing.srcDemTile,i=n.morphing.dstDemTile;c=n.morphing.phase,e&&i&&(this._prepareDemTileUniforms(t,e,s,"_prev")&&(l=e),this._prepareDemTileUniforms(t,i,s)&&(a=i))}const u=e=>e&&e.demTexture&&this.painter.linearFloatFilteringSupported()?o.LINEAR:o.NEAREST;let h=null;var d;if(this.enabled?l&&a?(h=a.demTexture,r.activeTexture.set(o.TEXTURE4),l.demTexture.bind(u(l),o.CLAMP_TO_EDGE),s.u_dem_lerp=c):(a=this.terrainTileForTile[t.tileID.key],h=this._prepareDemTileUniforms(t,a,s)?a.demTexture:this.emptyDEMTexture):h=this.emptyDEMTexture,r.activeTexture.set(o.TEXTURE2),h&&(s.u_dem_size=1===(d=h).size[0]?1:d.size[0]-2,h.bind(u(a),o.CLAMP_TO_EDGE)),this.painter.setupDepthForOcclusion(n&&n.useDepthForOcclusion,i,s),n&&n.useMeterToDem&&a){const t=(1<{if(c===i)return;const n=[jr[i],"PROJECTION_GLOBE_VIEW"];h&&n.push("CUSTOM_ANTIALIASING");const r=t.isTileAffectedByFog(e);l=t.getOrCreateProgram("globeRaster",{defines:n,overrideFog:r}),c=i},p=t.colorModeForRenderPass(),f=new $i(a.LEQUAL,$i.ReadWrite,t.depthRangeFor3D);Vr.update(o);const m=e.dE(u),g=[e.aF(u.center.lng),e.aJ(u.center.lat)],_=t.globeSharedBuffers,A=[u.width*e.o.devicePixelRatio,u.height*e.o.devicePixelRatio],y=Float32Array.from(u.globeMatrix),v={useDenormalizedUpVectorScale:!0};{const u=t.transform,h=Gr(u.zoom,i.exaggeration(),i.sourceCache._source.tileSize);c=-1;const x=a.TRIANGLES;for(const c of r){const r=n.getTile(c),b=Wi.disabled,w=i.prevTerrainTileForTile[c.key],T=i.terrainTileForTile[c.key];Nr(w,T)&&Vr.newMorphing(c.key,w,T,o,250),s.activeTexture.set(a.TEXTURE0),r.texture&&r.texture.bind(a.LINEAR,a.CLAMP_TO_EDGE);const E=Vr.getMorphValuesForProxy(c.key),C=E?1:0;E&&Object.assign(v,{morphing:{srcDemTile:E.from,dstDemTile:E.to,phase:e.dC(E.phase)}});const S=e.dF(c.canonical),B=e.dG(S.getCenter().lat),I=e.dH(c.canonical,S,B,u.worldSize/u._pixelsPerMercatorPixel),M=e.bj(e.dI(c.canonical)),P=Ur(u.expandedFarZProjMatrix,y,m,M,e.aj(u.zoom),g,u.frustumCorners.TL,u.frustumCorners.TR,u.frustumCorners.BR,u.frustumCorners.BL,u.globeCenterInViewSpace,u.globeRadius,A,h,u._farZ,I);if(d(c,C),l&&(i.setupElevationDraw(r,l,v),t.uploadCommonUniforms(s,l,c.toUnwrapped()),_)){const[e,i,n]=_.getGridBuffers(B,0!==h);l.draw(t,x,f,b,p,Xi.backCCW,P,"globe_raster",e,i,n)}}}if(_&&(t.renderDefaultNorthPole||t.renderDefaultSouthPole)){const o=["GLOBE_POLES","PROJECTION_GLOBE_VIEW"];h&&o.push("CUSTOM_ANTIALIASING"),l=t.getOrCreateProgram("globeRaster",{defines:o});for(const o of r){const{x:r,y:c,z:h}=o.canonical,d=0===c,m=c===(1<e.draw(t,a.TRIANGLES,f,Wi.disabled,p,Xi.disabled,Ur(u.expandedFarZProjMatrix,_,_,T,0,g,u.frustumCorners.TL,u.frustumCorners.TR,u.frustumCorners.BR,u.frustumCorners.BL,u.globeCenterInViewSpace,u.globeRadius,A,0,u._farZ),"globe_pole_raster",i,b,w);i.setupElevationDraw(c,l,v),t.uploadCommonUniforms(s,l,o.toUnwrapped()),d&&t.renderDefaultNorthPole&&E(l,y),m&&t.renderDefaultSouthPole&&(_=e.cR(e.bB(),_,[1,-1,1]),E(l,x))}}}}(t,i,n,r,o);else{const s=t.context,a=s.gl;let l,c;const u=t.shadowRenderer,h=ln(t,t.longestCutoffRange),d=e=>{if(c===e)return;const i=[];i.push(jr[e]),h.shouldRenderCutoff&&i.push("RENDER_CUTOFF"),u&&(i.push("RENDER_SHADOWS","DEPTH_TEXTURE"),u.useNormalOffset&&i.push("NORMAL_OFFSET")),l=t.getOrCreateProgram("terrainRaster",{defines:i}),c=e},p=t.colorModeForRenderPass(),f=new $i(a.LEQUAL,$i.ReadWrite,t.depthRangeFor3D);Vr.update(o);const m=t.transform,g=Gr(m.zoom,i.exaggeration(),i.sourceCache._source.tileSize);let _=[0,0,0];if(u){const e=t.style.directionalLight,i=t.style.ambientLight;e&&i&&(_=mn(t.style,e,i))}{c=-1;const A=a.TRIANGLES,[y,v]=[i.gridIndexBuffer,i.gridSegments];for(const c of r){const r=n.getTile(c),x=Wi.disabled,b=i.prevTerrainTileForTile[c.key],w=i.terrainTileForTile[c.key];Nr(b,w)&&Vr.newMorphing(c.key,b,w,o,250),s.activeTexture.set(a.TEXTURE0),r.texture&&r.texture.bind(a.LINEAR,a.CLAMP_TO_EDGE);const T=Vr.getMorphValuesForProxy(c.key),E=T?1:0;let C;T&&(C={morphing:{srcDemTile:T.from,dstDemTile:T.to,phase:e.dC(T.phase)}});const S=zr(c.projMatrix,Hr(c.canonical,m.renderWorldCopies)?g/10:g,_);if(d(E),!l)continue;i.setupElevationDraw(r,l,C);const B=c.toUnwrapped();u&&u.setupShadows(B,l),t.uploadCommonUniforms(s,l,B,null,h),l.draw(t,A,f,x,p,Xi.backCCW,S,"terrain_raster",i.gridBuffer,y,v)}}}}(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,n=this.painter.context,r=this.proxySourceCache,o=this.proxiedCoords[r.id],s=this._drapedRenderBatches.shift(),a=i.style.order,l=[];let c=0;for(const u of o){const o=r.getTileByID(u.proxyTileKey),h=r.proxyCachedFBO[u.key]?r.proxyCachedFBO[u.key][t]:void 0,d=void 0!==h?r.renderCache[h]:this.pool[c++],p=void 0!==h;if(o.texture=d.tex,p&&!d.dirty){l.push(o.tileID);continue}let f;n.bindFramebuffer.set(d.fb.framebuffer),this.renderedToTile=!1,d.dirty&&(n.clear({color:e.ao.transparent,stencil:0}),d.dirty=!1);for(let e=s.start;e<=s.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[u.key][r.id]:[u];if(!o)continue;const s=o;n.viewport.set([0,0,d.fb.width,d.fb.height]),f!==(r?r.id:null)&&(this._setupStencil(d,o,t,r),f=r?r.id:null),i.renderLayer(i,r,t,s)}if(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[u.key][r.id]:[u];if(!o)continue;const s=o;n.viewport.set([0,0,d.fb.width,d.fb.height]),f!==(r?r.id:null)&&(this._setupStencil(d,o,t,r),f=r?r.id:null),i.renderLayer(i,r,t,s)}this.renderedToTile?(d.dirty=!0,l.push(o.tileID)):p||--c,5===c&&(c=0,this.renderToBackBuffer(l))}return this.renderToBackBuffer(l),this.renderingToTexture=!1,n.bindFramebuffer.set(null),n.viewport.set([0,0,i.width,i.height]),s.end+1}postRender(){}isLayerOrderingCorrect(e){const t=e.order.length;let i=-1,n=t;for(let r=0;ri}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 n=this._visibleDemTiles.filter(e=>e.dem).map(n=>{const r=n.tileID,o=1<(null!==e.t?e.t:Number.MAX_VALUE)-(null!==t.t?t.t:Number.MAX_VALUE));for(const r of n){if(null==r.t)return null;const n=r.tile.dem.tree.raycast(r.minx,r.miny,r.maxx,r.maxy,e,t,i);if(null!=n)return n}return null}_createFBO(){const t=this.painter.context,i=t.gl,n=this.drapeBufferSize;t.activeTexture.set(i.TEXTURE0);const r=new e.T(t,{width:n[0],height:n[1],data:null},i.RGBA8);r.bind(i.LINEAR,i.CLAMP_TO_EDGE);const o=t.createFramebuffer(n[0],n[1],!0,null);return o.colorAttachment.set(r.texture),o.depthAttachment=new Or(t,o.framebuffer),void 0===this._sharedDepthStencil?(this._sharedDepthStencil=t.createRenderbuffer(t.gl.DEPTH_STENCIL,n[0],n[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,dirty:!1}}_initFBOPool(){for(;this.pool.length{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 lt){t=!0;break}if(!t)return;const i={};for(let t=0;te>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=n}_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=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 s=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]||n[e]&&n[e].hasOwnProperty(t.key))){s=-1;break}++s}for(const e in t.proxyCachedFBO[o.key])t.renderCache[t.proxyCachedFBO[o.key][e]].dirty=s<0||s!==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 n of i){if(t.proxyCachedFBO[n.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[n.key]={},t.proxyCachedFBO[n.key][e.start]=i,t.renderCache[i].dirty=!0)}this._tilesDirty={}}_setupStencil(e,t,i,n){if(!n||!this._sourceTilesOverlap[n.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 s;if(i.isTileClipped())s=t.length,this._overlapStencilMode.test={func:o.EQUAL,mask:255},this._overlapStencilType="Clip";else{if(!(t[0].overscaledZ>t[t.length-1].overscaledZ))return void(this._overlapStencilType=!1);s=1,this._overlapStencilMode.test={func:o.GREATER,mask:255},this._overlapStencilType="Mask"}this._stencilRef+s>255&&(r.clear({stencil:0}),this._stencilRef=0),this._stencilRef+=s,this._overlapStencilMode.ref=this._stencilRef,i.isTileClipped()&&this._renderTileClippingMasks(t,this._overlapStencilMode.ref)}clipOrMaskOverlapStencilType(){return"Clip"===this._overlapStencilType||"Mask"===this._overlapStencilType}stencilModeForRTTOverlap(e){return this.renderingToTexture&&this._overlapStencilType?("Clip"===this._overlapStencilType&&(this._overlapStencilMode.ref=this.painter._tileClippingMaskIDs[e.key]),this._overlapStencilMode):Wi.disabled}_renderTileClippingMasks(e,t){const i=this.painter,n=this.painter.context,r=n.gl;i._tileClippingMaskIDs={},n.setColorMode(Qi.disabled),n.setDepthMode($i.disabled);const o=i.getOrCreateProgram("clippingMask");for(const n of e){const e=i._tileClippingMaskIDs[n.key]=--t;o.draw(i,r.TRIANGLES,$i.disabled,new Wi({func:r.ALWAYS,mask:0},e,255,r.KEEP,r.KEEP,r.REPLACE),Qi.disabled,Xi.disabled,Qr(n.projMatrix),"$clipping",i.tileExtentBuffer,i.quadTriangleIndexBuffer,i.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 n=[t.x,t.y,1,1];e.aC(n,n,i.pixelMatrixInverse),e.cJ(n,n,1/n[3]),n[0]/=i.worldSize,n[1]/=i.worldSize;const r=i._camera.position,o=e.ce(1,i.center.lat),s=[r[0],r[1],r[2]/o,0],a=e.d9([],n.slice(0,3),s);e.aw(a,a);const l=this.raycast(s,a,this._exaggeration);return null!==l&&l?(e.bG(s,s,a,l),s[3]=s[2],s[2]*=o,s):null}_setupProxiedCoordsForOrtho(t,i,n){if(t.getSource()instanceof e.aT)return this._setupProxiedCoordsForImageSource(t,i,n);this._findCoveringTileCache[t.id]=this._findCoveringTileCache[t.id]||{};const r=this.proxiedCoords[t.id]=[],o=this.proxyCoords;for(let e=0;et.overscaledZ-e.overscaledZ)}_setupProxiedCoordsForImageSource(t,i,n){if(!t.getSource().loaded())return;const r=this.proxiedCoords[t.id]=[],o=this.proxyCoords,s=t.getSource(),a=s.tileID;if(!a)return;const l=new e.P(a.x,a.y)._div(1<(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)}),u=(t,i)=>{const n=t.wrap+t.canonical.x/(1<s+c.max.x||r+oa+c.max.y};for(let e=0;ee.key===i.tileID.key);if(e)return e}if(i.tileID.key!==t.key){const n=t.canonical.z-i.tileID.canonical.z;let o,s,a;r=e.bB();const l=i.tileID.wrap-t.wrap<0?(o=e.al>>n,s=o*((i.tileID.canonical.x<=r){const n=t.canonical.z-r;i.getSource().reparseOverscaled?(a=Math.max(t.canonical.z+2,i.transform.tileZoom),s=new e.aP(a,t.wrap,r,t.canonical.x>>n,t.canonical.y>>n)):0!==n&&(a=r,s=new e.aP(a,t.wrap,r,t.canonical.x>>n,t.canonical.y>>n))}s.key!==t.key&&(c.push(s.key),n=i.getTile(s))}const u=e=>{c.forEach(t=>{r[t]=e}),c.length=0};for(a-=1;a>=l&&(!n||!n.hasData());a--){n&&u(n.tileID.key);const e=s.calculateScaledKey(a);if(n=i.getTileByID(e),n&&n.hasData())break;const t=r[e];if(null===t)break;void 0===t?c.push(e):n=i.getTileByID(t)}return u(n?n.tileID.key:null),n&&n.hasData()?n: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 Xr(t,i,n){const r=function(t,i,n){const r=e.bI(i,t),o=e.bI(n,[.2126,.7152,.0722]),s=(e,t,i)=>(1-i)*e+i*t,a=s(1-.3*Math.min(o,1),1,Math.min(r+1,1));return s(.92,1,Math.asin(e.aA(i[2],-1,1))/Math.PI+.5)*a}(t,[0,0,1],i),o=[0,0,0];e.c4(o,n.slice(0,3),r);const s=[0,0,0];e.c4(s,i.slice(0,3),t[2]);const a=[0,0,0];return e.d7(a,o,s),e.da(a)}const Jr=["fill","fillOutline","fillPattern","line","linePattern","background","backgroundPattern","hillshade","raster"],Yr=["stars","rainParticle","snowParticle","fillExtrusion","fillExtrusionGroundEffect","elevatedStructures","model","symbol"];class eo{static cacheKey(e,t,i,n){let r=`${t}${n?n.cacheKey:""}`;for(const t of i)e.usedDefines.includes(t)&&(r+=`/${t}`);return r}constructor(t,i,n,r,o,s){const a=t.gl;this.program=a.createProgram(),this.configuration=r,this.name=i,this.fixedDefines=[...s];let l=r?r.defines():[];l=l.concat(s.map(e=>`#define ${e}`));const c="#version 300 es\n";let u=c+l.concat("precision mediump float;",$n,Qn.fragmentSource).join("\n");for(const e of n.fragmentIncludes)u+=`\n${Gn[e]}`;u+=`\n${n.fragmentSource}`;let h=c+l.concat("precision highp float;",$n,Qn.vertexSource).join("\n");for(const e of n.vertexIncludes)h+=`\n${Gn[e]}`;this.forceManualRenderingForInstanceIDShaders=t.forceManualRenderingForInstanceIDShaders&&-1!==n.vertexSource.indexOf("gl_InstanceID"),this.forceManualRenderingForInstanceIDShaders&&(h+="\nuniform int u_instanceID;\n"),h+=`\n${n.vertexSource}`,this.forceManualRenderingForInstanceIDShaders&&(h=h.replaceAll("gl_InstanceID","u_instanceID"));const d=a.createShader(a.FRAGMENT_SHADER);if(a.isContextLost())return void(this.failedToCreate=!0);a.shaderSource(d,u),a.compileShader(d),a.attachShader(this.program,d);const p=a.createShader(a.VERTEX_SHADER);a.isContextLost()?this.failedToCreate=!0:(a.shaderSource(p,h),a.compileShader(p),a.attachShader(this.program,p),this.attributes={},a.linkProgram(this.program),a.deleteShader(p),a.deleteShader(d),this.fixedUniforms=o(t),this.binderUniforms=r?r.getUniforms(t):[],this.forceManualRenderingForInstanceIDShaders&&(this.instancingUniforms=(t=>({u_instanceID:new e.cg(t)}))(t)),(s.includes("TERRAIN")||-1!==i.indexOf("symbol")||-1!==i.indexOf("circle"))&&(this.terrainUniforms=(t=>({u_dem:new e.cg(t),u_dem_prev:new e.cg(t),u_dem_tl:new e.cj(t),u_dem_scale:new e.ci(t),u_dem_tl_prev:new e.cj(t),u_dem_scale_prev:new e.ci(t),u_dem_size:new e.ci(t),u_dem_lerp:new e.ci(t),u_exaggeration:new e.ci(t),u_depth:new e.cg(t),u_depth_size_inv:new e.cj(t),u_depth_range_unpack:new e.cj(t),u_occluder_half_size:new e.ci(t),u_occlusion_depth_offset:new e.ci(t),u_meter_to_dem:new e.ci(t),u_label_plane_matrix_inv:new e.ck(t)}))(t)),s.includes("GLOBE")&&(this.globeUniforms=(t=>({u_tile_tl_up:new e.ch(t),u_tile_tr_up:new e.ch(t),u_tile_br_up:new e.ch(t),u_tile_bl_up:new e.ch(t),u_tile_up_scale:new e.ci(t)}))(t)),s.includes("FOG")&&(this.fogUniforms=(t=>({u_fog_matrix:new e.ck(t),u_fog_range:new e.cj(t),u_fog_color:new e.d2(t),u_fog_horizon_blend:new e.ci(t),u_fog_vertical_limit:new e.cj(t),u_fog_temporal_offset:new e.ci(t),u_frustum_tl:new e.ch(t),u_frustum_tr:new e.ch(t),u_frustum_br:new e.ch(t),u_frustum_bl:new e.ch(t),u_globe_pos:new e.ch(t),u_globe_radius:new e.ci(t),u_globe_transition:new e.ci(t),u_is_globe:new e.cg(t),u_viewport:new e.cj(t)}))(t)),s.includes("RENDER_CUTOFF")&&(this.cutoffUniforms=(t=>({u_cutoff_params:new e.d2(t)}))(t)),s.includes("LIGHTING_3D_MODE")&&(this.lightsUniforms=(t=>({u_lighting_ambient_color:new e.ch(t),u_lighting_directional_dir:new e.ch(t),u_lighting_directional_color:new e.ch(t),u_ground_radiance:new e.ch(t)}))(t)),s.includes("RENDER_SHADOWS")&&(this.shadowUniforms=(t=>({u_light_matrix_0:new e.ck(t),u_light_matrix_1:new e.ck(t),u_fade_range:new e.cj(t),u_shadow_normal_offset:new e.ch(t),u_shadow_intensity:new e.ci(t),u_shadow_texel_size:new e.ci(t),u_shadow_map_resolution:new e.ci(t),u_shadow_direction:new e.ch(t),u_shadow_bias:new e.ch(t),u_shadowmap_0:new e.cg(t),u_shadowmap_1:new e.cg(t)}))(t)))}getAttributeLocation(e,t){let i=this.attributes[t];return void 0===i&&(i=this.attributes[t]=e.getAttribLocation(this.program,t)),i}setTerrainUniformValues(e,t){if(!this.terrainUniforms)return;const i=this.terrainUniforms;if(!this.failedToCreate){e.program.set(this.program);for(const e in t)i[e]&&i[e].set(this.program,e,t[e])}}setGlobeUniformValues(e,t){if(!this.globeUniforms)return;const i=this.globeUniforms;if(!this.failedToCreate){e.program.set(this.program);for(const e in t)i[e]&&i[e].set(this.program,e,t[e])}}setFogUniformValues(e,t){if(!this.fogUniforms)return;const i=this.fogUniforms;if(!this.failedToCreate){e.program.set(this.program);for(const e in t)i[e].set(this.program,e,t[e])}}setCutoffUniformValues(e,t){if(!this.cutoffUniforms)return;const i=this.cutoffUniforms;if(!this.failedToCreate){e.program.set(this.program);for(const e in t)i[e].set(this.program,e,t[e])}}setLightsUniformValues(e,t){if(!this.lightsUniforms)return;const i=this.lightsUniforms;if(!this.failedToCreate){e.program.set(this.program);for(const e in t)i[e].set(this.program,e,t[e])}}setShadowUniformValues(e,t){if(this.failedToCreate||!this.shadowUniforms)return;const i=this.shadowUniforms;e.program.set(this.program);for(const e in t)i[e].set(this.program,e,t[e])}_drawDebugWireframe(t,i,n,r,o,s,a,l,c,u){const h=t.options.wireframe;if(!1===h.terrain&&!1===h.layers2D&&!1===h.layers3D)return;const d=t.context;if(!(()=>!(!h.terrain||"terrainRaster"!==this.name&&"globeRaster"!==this.name)||!(!h.layers2D||t._terrain&&t._terrain.renderingToTexture||!Jr.includes(this.name))||!(!h.layers3D||!Yr.includes(this.name)))())return;const p=d.gl,f=t.wireframeDebugCache.getLinesFromTrianglesBuffer(t.frameCounter,o,d);if(!f)return;const m=[...this.fixedDefines];m.push("DEBUG_WIREFRAME");const g=t.getOrCreateProgram(this.name,{config:this.configuration,defines:m});d.program.set(g.program);const _=(e,t,i)=>{if(t[e]&&i[e])for(const n in t[e])i[e][n]&&i[e][n].set(i.program,n,t[e][n].current)};c&&c.setUniforms(g.program,d,g.binderUniforms,a,{zoom:l}),_("fixedUniforms",this,g),_("terrainUniforms",this,g),_("globeUniforms",this,g),_("fogUniforms",this,g),_("lightsUniforms",this,g),_("shadowUniforms",this,g),f.bind(),d.setColorMode(new Qi([p.ONE,p.ONE_MINUS_SRC_ALPHA,p.ZERO,p.ONE],e.ao.transparent,[!0,!0,!0,!1])),d.setDepthMode(new $i(i.func===p.LESS?p.LEQUAL:i.func,$i.ReadOnly,i.range)),d.setStencilMode(Wi.disabled);const A=3*s.primitiveLength*2,y=3*s.primitiveOffset*2*2;if(this.forceManualRenderingForInstanceIDShaders){const e=u||1;for(let t=0;t1?p.drawElementsInstanced(p.LINES,A,p.UNSIGNED_SHORT,y,u):p.drawElements(p.LINES,A,p.UNSIGNED_SHORT,y);o.bind(),d.program.set(this.program),d.setDepthMode(i),d.setStencilMode(n),d.setColorMode(r)}checkUniforms(e,t,i){if(this.fixedDefines.includes(t))for(const n of Object.keys(i))if(!i[n].initialized)throw new Error(`Program '${this.name}', from draw '${e}': uniform ${n} not set but required by ${t} being defined`)}draw(e,t,i,n,r,o,s,a,l,c,u,h,d,p,f,m){const g=e.context,_=g.gl;if(this.failedToCreate)return;g.program.set(this.program),g.setDepthMode(i),g.setStencilMode(n),g.setColorMode(r),g.setCullFace(o);for(const e of Object.keys(this.fixedUniforms))this.fixedUniforms[e].set(this.program,e,s[e]);p&&p.setUniforms(this.program,g,this.binderUniforms,h,{zoom:d});const A={[_.POINTS]:1,[_.LINES]:2,[_.TRIANGLES]:3,[_.LINE_STRIP]:1}[t];this.checkUniforms(a,"RENDER_SHADOWS",this.shadowUniforms);const y=m&&m>0?1:void 0;for(const o of u.get()){const s=o.vaos||(o.vaos={});if((s[a]||(s[a]=new Kn)).bind(g,this,l,p?p.getPaintVertexBuffers():[],c,o.vertexOffset,f||[],y),this.forceManualRenderingForInstanceIDShaders){const e=m||1;for(let i=0;i1?_.drawElementsInstanced(t,o.primitiveLength*A,_.UNSIGNED_SHORT,o.primitiveOffset*A*2,m):c?_.drawElements(t,o.primitiveLength*A,_.UNSIGNED_SHORT,o.primitiveOffset*A*2):_.drawArrays(t,o.vertexOffset,o.vertexLength);t===_.TRIANGLES&&c&&this._drawDebugWireframe(e,i,n,r,c,o,h,d,p,m)}}}function to(t,i,n=0){const r=Math.pow(2,i.tileID.overscaledZ),o=i.tileSize*Math.pow(2,t.transform.tileZoom)/r,s=o*(i.tileID.canonical.x+i.tileID.wrap*r),a=o*i.tileID.canonical.y;return{u_image:0,u_texsize:i.imageAtlasTexture?i.imageAtlasTexture.size:[0,0],u_tile_units_to_pixels:1/e.ay(i,1,t.transform.tileZoom),u_pixel_coord_upper:[s>>16,a>>16],u_pixel_coord_lower:[65535&s,65535&a],u_pattern_transition:n}}const io={terrain:0,flat:1},no=e.bB(),ro=(t,i,n,r,o,s,a,l,c,u,h,d,p,f,m,g,_,A)=>{const y=i.style.light,v=y.properties.get("position"),x=[v.x,v.y,v.z],b=e.dN();"viewport"===y.properties.get("anchor")&&(e.dO(b,-i.transform.angle),e.dP(x,x,b));const w=y.properties.get("color").toPremultipliedRenderColor(null),T=i.transform,E={u_matrix:t,u_lightpos:x,u_lightintensity:y.properties.get("intensity"),u_lightcolor:[w.r,w.g,w.b],u_vertical_gradient:+n,u_opacity:r,u_tile_id:[0,0,0],u_zoom_transition:0,u_inv_rot_matrix:no,u_merc_center:[0,0],u_up_dir:[0,0,0],u_height_lift:0,u_height_type:io[u],u_base_type:io[h],u_ao:o,u_edge_radius:s,u_width_scale:a,u_flood_light_color:m,u_vertical_scale:g,u_flood_light_intensity:_,u_ground_shadow_factor:A};return"globe"===T.projection.name&&(E.u_tile_id=[l.canonical.x,l.canonical.y,1<({u_matrix:e,u_edge_radius:t,u_width_scale:i,u_vertical_scale:n,u_height_type:io[r],u_base_type:io[o]}),so=(e,t,i,n,r,o,s,a,l,c,u,h,d,p,f,m,g,_)=>{const A=ro(e,t,i,n,r,o,s,a,c,u,h,d,p,f,m,g,1,[0,0,0]),y={u_height_factor:-Math.pow(2,a.overscaledZ)/l.tileSize/8};return Object.assign(A,to(t,l,_),y)},ao=(e,t,i,n,r,o,s,a,l,c,u)=>({u_matrix:t,u_opacity:i,u_ao_pass:n?1:0,u_meter_to_tile:r,u_ao:o,u_flood_light_intensity:s,u_flood_light_color:a,u_attenuation:l,u_edge_radius:c,u_fb:0,u_fb_size:u,u_dynamic_offset:1}),lo=(e,t,i)=>({u_matrix:e,u_emissive_strength:t,u_ground_shadow_factor:i}),co=(e,t,i,n,r,o=0)=>Object.assign(lo(e,t,r),to(i,n,o)),uo=(e,t,i,n)=>({u_matrix:e,u_world:i,u_emissive_strength:t,u_ground_shadow_factor:n}),ho=(e,t,i,n,r,o,s=0)=>Object.assign(co(e,t,i,n,o,s),{u_world:r}),po=(e,t)=>({u_matrix:e,u_ground_shadow_factor:t}),fo=(e,t,i,n,r)=>({u_matrix:e,u_camera_pos:[t[0],t[1],t[2]],u_depth_bias:i,u_height_scale:n,u_reset_depth:r}),mo=(e,t,i,n,r,o,s,a,l)=>({u_matrix:e,u_normal_matrix:t,u_opacity:i,u_faux_facade_ao_intensity:n,u_camera_pos:r,u_tile_to_meter:o,u_facade_emissive_chance:s,u_flood_light_color:a,u_flood_light_intensity:l}),go=e=>({u_matrix:e}),_o=e=>({u_matrix:e}),Ao=(t,i,n,r,o,s,a,l)=>{const c=e.al/s.tileSize;return{u_matrix:t,u_inv_rot_matrix:i,u_camera_to_center_distance:n.getCameraToCenterDistance(l),u_extrude_scale:[n.pixelsToGLUnits[0]/c,n.pixelsToGLUnits[1]/c],u_zoom_transition:r,u_tile_id:a,u_merc_center:o}},yo=(e,t,i=1)=>({u_matrix:e,u_color:t,u_overlay:0,u_overlay_scale:i}),vo=e.bB(),xo=(t,i,n,r,o,s,a)=>{const l=t.transform,c="globe"===l.projection.name,u=c?e.dQ(l.zoom,i.canonical)*l._pixelsPerMercatorPixel:e.ay(n,1,s),h={u_matrix:i.projMatrix,u_extrude_scale:u,u_intensity:a,u_inv_rot_matrix:vo,u_merc_center:[0,0],u_tile_id:[0,0,0],u_zoom_transition:0,u_up_dir:[0,0,0]};if(c){h.u_inv_rot_matrix=r,h.u_merc_center=o,h.u_tile_id=[i.canonical.x,i.canonical.y,1<({u_matrix:t,u_normalize_matrix:i,u_globe_matrix:n,u_merc_matrix:r,u_grid_matrix:o,u_tl_parent:s,u_scale_parent:u,u_fade_t:h.mix,u_opacity:h.opacity*d.paint.get("raster-opacity"),u_image0:0,u_image1:1,u_brightness_low:d.paint.get("raster-brightness-min"),u_brightness_high:d.paint.get("raster-brightness-max"),u_saturation_factor:e.dS(d.paint.get("raster-saturation")),u_contrast_factor:e.dR(d.paint.get("raster-contrast")),u_spin_weights:Eo(d.paint.get("raster-hue-rotate")),u_perspective_transform:p,u_raster_elevation:f,u_zoom_transition:a,u_merc_center:l,u_cutoff_params:c,u_colorization_mix:bo(e.dT,g,A),u_colorization_offset:wo(e.dT,_,A),u_color_ramp:m,u_texture_offset:[v/(y+2*v),y/(y+2*v)],u_texture_res:[y+2*v,y+2*v],u_emissive_strength:x});function Eo(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 Co=.05,So=(e,t,i,n,r,o,s,a,l,c,u,h)=>({u_matrix:e,u_normalize_matrix:t,u_globe_matrix:i,u_merc_matrix:n,u_grid_matrix:r,u_tl_parent:o,u_scale_parent:c,u_fade_t:u.mix,u_opacity:u.opacity,u_image0:0,u_image1:1,u_raster_elevation:h,u_zoom_transition:s,u_merc_center:a,u_cutoff_params:l}),Bo=(e,t,i,n,r,o,s,a,l,c)=>({u_particle_texture:e,u_particle_texture_side_len:t,u_tile_offset:i,u_velocity:n,u_color_ramp:o,u_velocity_res:r,u_max_speed:s,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:[Co,Co]}),Io=(e,t,i,n,r,o,s,a,l,c)=>({u_particle_texture:e,u_particle_texture_side_len:t,u_velocity:i,u_velocity_res:n,u_max_speed:r,u_speed_factor:o,u_reset_rate:s,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:[Co,Co]}),Mo=e.bB(),Po=(t,i,n,r,o,s,a,l,c,u,h,d,p,f,m,g,_,A,y,v,x,b,w,T)=>{const E=o.transform,C={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(y),u_rotate_symbol:+n,u_aspect_ratio:E.width/E.height,u_fade_change:o.options.fadeDuration?o.symbolFadeChange:1,u_matrix:s,u_label_plane_matrix:a,u_coord_matrix:l,u_is_text:+u,u_elevation_from_sea:c?1:0,u_pitch_with_map:+r,u_texsize:h,u_texsize_icon:d,u_texture:0,u_texture_icon:1,u_tile_id:[0,0,0],u_zoom_transition:0,u_inv_rot_matrix:Mo,u_merc_center:[0,0],u_camera_forward:[0,0,0],u_ecef_origin:[0,0,0],u_tile_matrix:Mo,u_up_vector:[0,-1,0],u_color_adj_mat:b,u_icon_transition:w||0,u_gamma_scale:r?o.transform.getCameraToCenterDistance(y)*Math.cos(o.terrain?0:o.transform._pitch):1,u_device_pixel_ratio:e.o.devicePixelRatio,u_is_halo:1,u_scale_factor:T||1,u_ground_shadow_factor:v,u_inv_matrix:e.bk(e.bB(),a),u_normal_scale:x,u_lutTexture:rn.LUT};return"globe"===y.name&&(C.u_tile_id=[f.canonical.x,f.canonical.y,1<({u_matrix:e,u_emissive_strength:t,u_opacity:i,u_color:n}),Lo=(t,i,n,r,o,s,a,l,c)=>Object.assign(function(t,i,n,r,o,s){const{width:a,height:l}=r.imageManager.getPixelSize(i),c=Math.pow(2,s.tileID.overscaledZ),u=s.tileSize*Math.pow(2,r.transform.tileZoom)/c,h=u*(s.tileID.canonical.x+s.tileID.wrap*c),d=u*s.tileID.canonical.y;return{u_image:0,u_pattern_tl:n.tl,u_pattern_br:n.br,u_texsize:[a,l],u_pattern_size:n.displaySize,u_pattern_units_to_pixels:o?[r.transform.width,-1*r.transform.height]:[1/e.ay(s,1,r.transform.tileZoom),1/e.ay(s,1,r.transform.tileZoom)],u_pixel_coord_upper:[h>>16,d>>16],u_pixel_coord_lower:[65535&h,65535&d]}}(0,s,a,r,l,c),{u_matrix:t,u_emissive_strength:i,u_opacity:n}),Fo=new Float32Array(e.bz([])),ko=(t,i,n,r,o,s,a,l,c,u,h,d,p,f=[0,0,0],m,g,_)=>{const A=o.style.light,y=A.properties.get("position"),v=[-y.x,-y.y,y.z],x=e.dN();"viewport"===A.properties.get("anchor")&&(e.dO(x,-o.transform.angle),e.dP(v,v,x));const b="MASK"===h.alphaMode,w=A.properties.get("color").toNonPremultipliedRenderColor(null),T=p.paint.get("model-ambient-occlusion-intensity"),E=p.paint.get("model-color").constantOr(e.ao.white).toNonPremultipliedRenderColor(null);return E.a=p.paint.get("model-color-mix-intensity").constantOr(0),_&&(E.r=_[0],E.g=_[1],E.b=_[2],E.a=_[3]),g&&(E.r=g.color.r,E.g=g.color.g,E.b=g.color.b,E.a=g.colorMix,d=g.emissionStrength,s=g.opacity),{u_matrix:t,u_lighting_matrix:i,u_normal_matrix:n,u_node_matrix:r||Fo,u_lightpos:v,u_lightintensity:A.properties.get("intensity"),u_lightcolor:[w.r,w.g,w.b],u_camera_pos:f,u_opacity:s,u_baseTextureIsAlpha:0,u_alphaMask:+b,u_alphaCutoff:h.alphaCutoff,u_baseColorFactor:a.toNonPremultipliedRenderColor(null).toArray01(),u_emissiveFactor:l.toNonPremultipliedRenderColor(null).toArray01(),u_metallicFactor:c,u_roughnessFactor:u,u_baseColorTexture:rn.BaseColor,u_metallicRoughnessTexture:rn.MetallicRoughness,u_normalTexture:rn.Normal,u_occlusionTexture:rn.Occlusion,u_emissionTexture:rn.Emission,u_lutTexture:rn.LUT,u_color_mix:E.toArray01(),u_aoIntensity:T,u_emissive_strength:d,u_occlusionTextureTransform:m||[0,0,0,0]}},Do=(e,t=Fo,i=Fo)=>({u_matrix:e,u_instance:t,u_node_matrix:i}),Oo={fillExtrusion:t=>({u_matrix:new e.ck(t),u_lightpos:new e.ch(t),u_lightintensity:new e.ci(t),u_lightcolor:new e.ch(t),u_vertical_gradient:new e.ci(t),u_opacity:new e.ci(t),u_edge_radius:new e.ci(t),u_width_scale:new e.ci(t),u_ao:new e.cj(t),u_height_type:new e.cg(t),u_base_type:new e.cg(t),u_tile_id:new e.ch(t),u_zoom_transition:new e.ci(t),u_inv_rot_matrix:new e.ck(t),u_merc_center:new e.cj(t),u_up_dir:new e.ch(t),u_height_lift:new e.ci(t),u_flood_light_color:new e.ch(t),u_vertical_scale:new e.ci(t),u_flood_light_intensity:new e.ci(t),u_ground_shadow_factor:new e.ch(t)}),fillExtrusionDepth:t=>({u_matrix:new e.ck(t),u_edge_radius:new e.ci(t),u_width_scale:new e.ci(t),u_vertical_scale:new e.ci(t),u_height_type:new e.cg(t),u_base_type:new e.cg(t)}),fillExtrusionPattern:t=>({u_matrix:new e.ck(t),u_lightpos:new e.ch(t),u_lightintensity:new e.ci(t),u_lightcolor:new e.ch(t),u_vertical_gradient:new e.ci(t),u_height_factor:new e.ci(t),u_edge_radius:new e.ci(t),u_width_scale:new e.ci(t),u_ao:new e.cj(t),u_height_type:new e.cg(t),u_base_type:new e.cg(t),u_tile_id:new e.ch(t),u_zoom_transition:new e.ci(t),u_inv_rot_matrix:new e.ck(t),u_merc_center:new e.cj(t),u_up_dir:new e.ch(t),u_height_lift:new e.ci(t),u_image:new e.cg(t),u_texsize:new e.cj(t),u_pixel_coord_upper:new e.cj(t),u_pixel_coord_lower:new e.cj(t),u_tile_units_to_pixels:new e.ci(t),u_opacity:new e.ci(t),u_pattern_transition:new e.ci(t)}),fillExtrusionGroundEffect:t=>({u_matrix:new e.ck(t),u_opacity:new e.ci(t),u_ao_pass:new e.ci(t),u_meter_to_tile:new e.ci(t),u_ao:new e.cj(t),u_flood_light_intensity:new e.ci(t),u_flood_light_color:new e.ch(t),u_attenuation:new e.ci(t),u_edge_radius:new e.ci(t),u_fb:new e.cg(t),u_fb_size:new e.ci(t),u_dynamic_offset:new e.ci(t)}),fill:t=>({u_matrix:new e.ck(t),u_emissive_strength:new e.ci(t),u_ground_shadow_factor:new e.ch(t)}),fillPattern:t=>({u_matrix:new e.ck(t),u_emissive_strength:new e.ci(t),u_image:new e.cg(t),u_texsize:new e.cj(t),u_pixel_coord_upper:new e.cj(t),u_pixel_coord_lower:new e.cj(t),u_tile_units_to_pixels:new e.ci(t),u_ground_shadow_factor:new e.ch(t),u_pattern_transition:new e.ci(t)}),fillOutline:t=>({u_matrix:new e.ck(t),u_emissive_strength:new e.ci(t),u_world:new e.cj(t),u_ground_shadow_factor:new e.ch(t)}),fillOutlinePattern:t=>({u_matrix:new e.ck(t),u_emissive_strength:new e.ci(t),u_world:new e.cj(t),u_image:new e.cg(t),u_texsize:new e.cj(t),u_pixel_coord_upper:new e.cj(t),u_pixel_coord_lower:new e.cj(t),u_tile_units_to_pixels:new e.ci(t),u_ground_shadow_factor:new e.ch(t),u_pattern_transition:new e.ci(t)}),building:t=>({u_matrix:new e.ck(t),u_normal_matrix:new e.ck(t),u_opacity:new e.ci(t),u_faux_facade_ao_intensity:new e.ci(t),u_camera_pos:new e.ch(t),u_tile_to_meter:new e.ci(t),u_facade_emissive_chance:new e.ci(t),u_flood_light_color:new e.ch(t),u_flood_light_intensity:new e.ci(t)}),buildingBloom:t=>({u_matrix:new e.ck(t)}),buildingDepth:t=>({u_matrix:new e.ck(t)}),elevatedStructuresDepth:t=>({u_matrix:new e.ck(t),u_depth_bias:new e.ci(t)}),elevatedStructures:t=>({u_matrix:new e.ck(t),u_ground_shadow_factor:new e.ch(t)}),elevatedStructuresDepthReconstruct:t=>({u_matrix:new e.ck(t),u_camera_pos:new e.ch(t),u_depth_bias:new e.ci(t),u_height_scale:new e.ci(t),u_reset_depth:new e.ci(t)}),circle:e.dX,collisionBox:t=>({u_matrix:new e.ck(t),u_inv_rot_matrix:new e.ck(t),u_camera_to_center_distance:new e.ci(t),u_extrude_scale:new e.cj(t),u_zoom_transition:new e.ci(t),u_merc_center:new e.cj(t),u_tile_id:new e.ch(t)}),collisionCircle:t=>({u_matrix:new e.ck(t),u_inv_matrix:new e.ck(t),u_camera_to_center_distance:new e.ci(t),u_viewport_size:new e.cj(t)}),debug:t=>({u_color:new e.dA(t),u_matrix:new e.ck(t),u_overlay:new e.cg(t),u_overlay_scale:new e.ci(t)}),clippingMask:t=>({u_matrix:new e.ck(t)}),heatmap:t=>({u_extrude_scale:new e.ci(t),u_intensity:new e.ci(t),u_matrix:new e.ck(t),u_inv_rot_matrix:new e.ck(t),u_merc_center:new e.cj(t),u_tile_id:new e.ch(t),u_zoom_transition:new e.ci(t),u_up_dir:new e.ch(t)}),heatmapTexture:t=>({u_image:new e.cg(t),u_color_ramp:new e.cg(t),u_opacity:new e.ci(t)}),hillshade:t=>({u_matrix:new e.ck(t),u_image:new e.cg(t),u_latrange:new e.cj(t),u_light:new e.cj(t),u_shadow:new e.dA(t),u_highlight:new e.dA(t),u_emissive_strength:new e.ci(t),u_accent:new e.dA(t)}),hillshadePrepare:t=>({u_matrix:new e.ck(t),u_image:new e.cg(t),u_dimension:new e.cj(t),u_zoom:new e.ci(t)}),line:e.dW,linePattern:e.dV,raster:t=>({u_matrix:new e.ck(t),u_normalize_matrix:new e.ck(t),u_globe_matrix:new e.ck(t),u_merc_matrix:new e.ck(t),u_grid_matrix:new e.dB(t),u_tl_parent:new e.cj(t),u_scale_parent:new e.ci(t),u_fade_t:new e.ci(t),u_opacity:new e.ci(t),u_image0:new e.cg(t),u_image1:new e.cg(t),u_brightness_low:new e.ci(t),u_brightness_high:new e.ci(t),u_saturation_factor:new e.ci(t),u_contrast_factor:new e.ci(t),u_spin_weights:new e.ch(t),u_perspective_transform:new e.cj(t),u_raster_elevation:new e.ci(t),u_zoom_transition:new e.ci(t),u_merc_center:new e.cj(t),u_cutoff_params:new e.d2(t),u_colorization_mix:new e.d2(t),u_colorization_offset:new e.ci(t),u_color_ramp:new e.cg(t),u_texture_offset:new e.cj(t),u_texture_res:new e.cj(t),u_emissive_strength:new e.ci(t)}),rasterParticle:t=>({u_matrix:new e.ck(t),u_normalize_matrix:new e.ck(t),u_globe_matrix:new e.ck(t),u_merc_matrix:new e.ck(t),u_grid_matrix:new e.dB(t),u_tl_parent:new e.cj(t),u_scale_parent:new e.ci(t),u_fade_t:new e.ci(t),u_opacity:new e.ci(t),u_image0:new e.cg(t),u_image1:new e.cg(t),u_raster_elevation:new e.ci(t),u_zoom_transition:new e.ci(t),u_merc_center:new e.cj(t),u_cutoff_params:new e.d2(t)}),rasterParticleTexture:t=>({u_texture:new e.cg(t),u_opacity:new e.ci(t)}),rasterParticleDraw:t=>({u_particle_texture:new e.cg(t),u_particle_texture_side_len:new e.ci(t),u_tile_offset:new e.cj(t),u_velocity:new e.cg(t),u_color_ramp:new e.cg(t),u_velocity_res:new e.cj(t),u_max_speed:new e.ci(t),u_uv_offset:new e.cj(t),u_data_scale:new e.cj(t),u_data_offset:new e.ci(t),u_particle_pos_scale:new e.ci(t),u_particle_pos_offset:new e.cj(t)}),rasterParticleUpdate:t=>({u_particle_texture:new e.cg(t),u_particle_texture_side_len:new e.ci(t),u_velocity:new e.cg(t),u_velocity_res:new e.cj(t),u_max_speed:new e.ci(t),u_speed_factor:new e.ci(t),u_reset_rate:new e.ci(t),u_rand_seed:new e.ci(t),u_uv_offset:new e.cj(t),u_data_scale:new e.cj(t),u_data_offset:new e.ci(t),u_particle_pos_scale:new e.ci(t),u_particle_pos_offset:new e.cj(t)}),symbol:t=>({u_is_size_zoom_constant:new e.cg(t),u_is_size_feature_constant:new e.cg(t),u_size_t:new e.ci(t),u_size:new e.ci(t),u_camera_to_center_distance:new e.ci(t),u_rotate_symbol:new e.cg(t),u_aspect_ratio:new e.ci(t),u_fade_change:new e.ci(t),u_matrix:new e.ck(t),u_label_plane_matrix:new e.ck(t),u_coord_matrix:new e.ck(t),u_is_text:new e.cg(t),u_elevation_from_sea:new e.cg(t),u_pitch_with_map:new e.cg(t),u_texsize:new e.cj(t),u_texsize_icon:new e.cj(t),u_texture:new e.cg(t),u_texture_icon:new e.cg(t),u_gamma_scale:new e.ci(t),u_device_pixel_ratio:new e.ci(t),u_tile_id:new e.ch(t),u_zoom_transition:new e.ci(t),u_inv_rot_matrix:new e.ck(t),u_merc_center:new e.cj(t),u_camera_forward:new e.ch(t),u_tile_matrix:new e.ck(t),u_up_vector:new e.ch(t),u_ecef_origin:new e.ch(t),u_is_halo:new e.cg(t),u_icon_transition:new e.ci(t),u_color_adj_mat:new e.ck(t),u_scale_factor:new e.ci(t),u_ground_shadow_factor:new e.ch(t),u_inv_matrix:new e.ck(t),u_normal_scale:new e.ci(t),u_lutTexture:new e.cg(t)}),background:t=>({u_matrix:new e.ck(t),u_emissive_strength:new e.ci(t),u_opacity:new e.ci(t),u_color:new e.dA(t)}),backgroundPattern:t=>({u_matrix:new e.ck(t),u_emissive_strength:new e.ci(t),u_opacity:new e.ci(t),u_image:new e.cg(t),u_pattern_tl:new e.cj(t),u_pattern_br:new e.cj(t),u_texsize:new e.cj(t),u_pattern_size:new e.cj(t),u_pixel_coord_upper:new e.cj(t),u_pixel_coord_lower:new e.cj(t),u_pattern_units_to_pixels:new e.cj(t)}),terrainRaster:t=>({u_matrix:new e.ck(t),u_image0:new e.cg(t),u_skirt_height:new e.ci(t),u_ground_shadow_factor:new e.ch(t)}),skybox:t=>({u_matrix:new e.ck(t),u_sun_direction:new e.ch(t),u_cubemap:new e.cg(t),u_opacity:new e.ci(t),u_temporal_offset:new e.ci(t)}),skyboxGradient:t=>({u_matrix:new e.ck(t),u_color_ramp:new e.cg(t),u_center_direction:new e.ch(t),u_radius:new e.ci(t),u_opacity:new e.ci(t),u_temporal_offset:new e.ci(t)}),skyboxCapture:t=>({u_matrix_3f:new e.dB(t),u_sun_direction:new e.ch(t),u_sun_intensity:new e.ci(t),u_color_tint_r:new e.d2(t),u_color_tint_m:new e.d2(t),u_luminance:new e.ci(t)}),globeRaster:t=>({u_proj_matrix:new e.ck(t),u_globe_matrix:new e.ck(t),u_normalize_matrix:new e.ck(t),u_merc_matrix:new e.ck(t),u_zoom_transition:new e.ci(t),u_merc_center:new e.cj(t),u_image0:new e.cg(t),u_grid_matrix:new e.dB(t),u_skirt_height:new e.ci(t),u_far_z_cutoff:new e.ci(t),u_frustum_tl:new e.ch(t),u_frustum_tr:new e.ch(t),u_frustum_br:new e.ch(t),u_frustum_bl:new e.ch(t),u_globe_pos:new e.ch(t),u_globe_radius:new e.ci(t),u_viewport:new e.cj(t)}),globeAtmosphere:t=>({u_frustum_tl:new e.ch(t),u_frustum_tr:new e.ch(t),u_frustum_br:new e.ch(t),u_frustum_bl:new e.ch(t),u_horizon:new e.ci(t),u_transition:new e.ci(t),u_fadeout_range:new e.ci(t),u_atmosphere_fog_color:new e.d2(t),u_high_color:new e.d2(t),u_space_color:new e.d2(t),u_temporal_offset:new e.ci(t),u_horizon_angle:new e.ci(t)}),model:t=>({u_matrix:new e.ck(t),u_lighting_matrix:new e.ck(t),u_normal_matrix:new e.ck(t),u_node_matrix:new e.ck(t),u_lightpos:new e.ch(t),u_lightintensity:new e.ci(t),u_lightcolor:new e.ch(t),u_camera_pos:new e.ch(t),u_opacity:new e.ci(t),u_baseColorFactor:new e.d2(t),u_emissiveFactor:new e.d2(t),u_metallicFactor:new e.ci(t),u_roughnessFactor:new e.ci(t),u_baseTextureIsAlpha:new e.cg(t),u_alphaMask:new e.cg(t),u_alphaCutoff:new e.ci(t),u_baseColorTexture:new e.cg(t),u_metallicRoughnessTexture:new e.cg(t),u_normalTexture:new e.cg(t),u_occlusionTexture:new e.cg(t),u_emissionTexture:new e.cg(t),u_lutTexture:new e.cg(t),u_color_mix:new e.d2(t),u_aoIntensity:new e.ci(t),u_emissive_strength:new e.ci(t),u_occlusionTextureTransform:new e.d2(t)}),modelDepth:t=>({u_matrix:new e.ck(t),u_instance:new e.ck(t),u_node_matrix:new e.ck(t)}),groundShadow:t=>({u_matrix:new e.ck(t),u_ground_shadow_factor:new e.ch(t)}),stars:t=>({u_matrix:new e.ck(t),u_up:new e.ch(t),u_right:new e.ch(t),u_intensity_multiplier:new e.ci(t)}),snowParticle:t=>({u_modelview:new e.ck(t),u_projection:new e.ck(t),u_time:new e.ci(t),u_cam_pos:new e.ch(t),u_velocityConeAperture:new e.ci(t),u_velocity:new e.ci(t),u_horizontalOscillationRadius:new e.ci(t),u_horizontalOscillationRate:new e.ci(t),u_boxSize:new e.ci(t),u_billboardSize:new e.ci(t),u_simpleShapeParameters:new e.cj(t),u_screenSize:new e.cj(t),u_thinningCenterPos:new e.cj(t),u_thinningShape:new e.ch(t),u_thinningAffectedRatio:new e.ci(t),u_thinningParticleOffset:new e.ci(t),u_particleColor:new e.d2(t),u_direction:new e.ch(t)}),rainParticle:t=>({u_modelview:new e.ck(t),u_projection:new e.ck(t),u_time:new e.ci(t),u_cam_pos:new e.ch(t),u_texScreen:new e.cg(t),u_velocityConeAperture:new e.ci(t),u_velocity:new e.ci(t),u_boxSize:new e.ci(t),u_rainDropletSize:new e.cj(t),u_distortionStrength:new e.ci(t),u_rainDirection:new e.ch(t),u_color:new e.d2(t),u_screenSize:new e.cj(t),u_thinningCenterPos:new e.cj(t),u_thinningShape:new e.ch(t),u_thinningAffectedRatio:new e.ci(t),u_thinningParticleOffset:new e.ci(t),u_shapeDirectionalPower:new e.ci(t),u_shapeNormalPower:new e.ci(t),u_mode:new e.ci(t)}),vignette:t=>({u_vignetteShape:new e.ch(t),u_vignetteColor:new e.d2(t)}),occlusion:t=>({u_matrix:new e.ck(t),u_anchorPos:new e.ch(t),u_screenSizePx:new e.cj(t),u_occluderSizePx:new e.cj(t),u_color:new e.d2(t)})};class zo{constructor(e,t,i,n){this.id=zo.uniqueIdxCounter,zo.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||n||t.destroy()}bind(){this.context.bindElementBuffer.set(this.buffer)}updateData(e){this.id=zo.uniqueIdxCounter,zo.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)}}zo.uniqueIdxCounter=0;const Uo={Int8:"BYTE",Uint8:"UNSIGNED_BYTE",Int16:"SHORT",Uint16:"UNSIGNED_SHORT",Int32:"INT",Uint32:"UNSIGNED_INT",Float32:"FLOAT"};class No{constructor(e,t,i,n,r,o){this.length=t.length,this.attributes=i,this.itemSize=t.bytesPerElement,this.dynamicDraw=n,this.instanceCount=o,this.context=e;const s=e.gl;this.buffer=s.createBuffer(),e.bindVertexBuffer.set(this.buffer),s.bufferData(s.ARRAY_BUFFER,t.arrayBuffer,this.dynamicDraw?s.DYNAMIC_DRAW:s.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(let i=0;i0&&e.vertexAttribDivisor(r,i)}}destroy(){this.buffer&&(this.context.gl.deleteBuffer(this.buffer),delete this.buffer)}}class Vo{constructor(e,t,i,n,r){this.context=e,this.width=t,this.height=i;const o=this.framebuffer=e.gl.createFramebuffer();n&&(this.colorAttachment=new Fr(e,o)),r&&(this.depthAttachmentType=r,this.depthAttachment="renderbuffer"===r?new kr(e,o):new Dr(e,o))}destroy(){const e=this.context.gl;if(this.colorAttachment){const t=this.colorAttachment.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)}e.deleteFramebuffer(this.framebuffer)}}class jo{constructor(e,t){this.gl=e,this.clearColor=new ir(this),this.clearDepth=new nr(this),this.clearStencil=new rr(this),this.colorMask=new or(this),this.depthMask=new sr(this),this.stencilMask=new ar(this),this.stencilFunc=new lr(this),this.stencilOp=new cr(this),this.stencilTest=new ur(this),this.depthRange=new hr(this),this.depthTest=new dr(this),this.depthFunc=new pr(this),this.blend=new fr(this),this.blendFunc=new mr(this),this.blendColor=new gr(this),this.blendEquation=new _r(this),this.cullFace=new Ar(this),this.cullFaceSide=new yr(this),this.frontFace=new vr(this),this.program=new xr(this),this.activeTexture=new br(this),this.viewport=new wr(this),this.bindFramebuffer=new Tr(this),this.bindRenderbuffer=new Er(this),this.bindTexture=new Cr(this),this.bindVertexBuffer=new Sr(this),this.bindElementBuffer=new Br(this),this.bindVertexArrayOES=new Ir(this),this.pixelStoreUnpack=new Mr(this),this.pixelStoreUnpackPremultiplyAlpha=new Pr(this),this.pixelStoreUnpackFlipY=new Rr(this),this.options=t?Object.assign({},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&&-1!==this.renderer.indexOf("PowerVR"),this.options.extTextureFloatLinearForceOff||(this.extTextureFloatLinear=e.getExtension("OES_texture_float_linear")),this.extRenderToTextureHalfFloat=e.getExtension("EXT_color_buffer_half_float"),this.extTimerQuery=e.getExtension("EXT_disjoint_timer_query_webgl2"),this.maxTextureSize=e.getParameter(e.MAX_TEXTURE_SIZE),this.maxPointSize=e.getParameter(e.ALIASED_POINT_SIZE_RANGE)[1]}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 zo(this,e,t,i)}createVertexBuffer(e,t,i,n,r){return new No(this,e,t,i,n,r)}createRenderbuffer(e,t,i){const n=this.gl,r=n.createRenderbuffer();return this.bindRenderbuffer.set(r),n.renderbufferStorage(n.RENDERBUFFER,e,t,i),this.bindRenderbuffer.set(null),r}createFramebuffer(e,t,i,n){return new Vo(this,e,t,i,n)}clear({color:e,depth:t,stencil:i,colorMask:n}){const r=this.gl;let o=0;e&&(o|=r.COLOR_BUFFER_BIT,this.clearColor.set(e.toNonPremultipliedRenderColor(null)),this.colorMask.set(n||[!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.bx(t.blendFunction,Qi.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)}}let Go;function Ho(t,i,n,r,o,s,a){const l=t.context,c=l.gl,u=t.transform,h=[e.aF(u.center.lng),e.aJ(u.center.lat)],d=n.layout.get("symbol-placement"),p=n.layout.get("text-variable-anchor"),f="map"===n.layout.get("icon-rotation-alignment"),m="map"===n.layout.get("text-rotation-alignment"),g="point"!==d,_=[];let A=0,y=0;for(let l=0;l0){const t=e.bB(),i=L;e.cO(t,x.placementInvProjMatrix,u.glCoordMatrix),e.cO(t,t,x.placementViewportMatrix),_.push({circleArray:k,circleOffset:y,transform:i,invTransform:t,projection:x.getProjection()}),A+=k.length/4,y=A}if(!F)continue;t.terrain&&t.terrain.setupElevationDraw(v,R);const D=M?[d.canonical.x,d.canonical.y,1<=0&&(f[y.associatedIconIndex]={x:C,y:S,z:B,angle:L})}else fi(b,d)}if(u){p.clear();const i=t.icon.placedSymbolArray;for(let t=0;t{let i=[0,0,0];if(e){const e=t.style.directionalLight,n=t.style.ambientLight;e&&n&&(i=mn(t.style,e,n))}return i},Q=e=>{C.depthOcclusionForSymbolsAndCircles&&(n.hasOcclusionOpacityProperties||t.terrain)&&(e.push("DEPTH_D24"),e.push("DEPTH_OCCLUSION"))},$=i=>{n.lut&&!w&&(n.lut.texture||(n.lut.texture=new e.d_(t.context,n.lut.image,[n.lut.image.height,n.lut.image.height,n.lut.image.height],T.gl.RGBA8)),T.activeTexture.set(T.gl.TEXTURE0+rn.LUT),n.lut.texture&&n.lut.texture.bind(T.gl.LINEAR,T.gl.CLAMP_TO_EDGE),i.push("APPLY_LUT_ON_GPU"))},Z=()=>{const i=S&&"point"!==n.layout.get("symbol-placement"),a=[];Q(a),$(a);const c=i||V,h="road"===s.elevationType,_=t.shadowRenderer,w=h&&I&&!!_&&_.enabled,T=H(w),B=h&&I&&!t.terrain?F:L,M=n.paint.get("icon-image-cross-fade");t.terrainRenderModeElevated()&&I&&a.push("PITCH_WITH_MAP_TERRAIN"),d&&(a.push("PROJECTION_GLOBE_VIEW"),c&&a.push("PROJECTED_POS_ON_VIEWPORT")),M>0&&s.hasAnySecondaryIcon&&a.push("ICON_TRANSITION"),!s.icon.zOffsetVertexBuffer||h&&t.terrain||a.push("Z_OFFSET"),0===A&&0===y&&0===v&&1===x||a.push("COLOR_ADJUSTMENT"),s.sdfIcons&&a.push("RENDER_SDF"),w&&a.push("RENDER_SHADOWS","DEPTH_TEXTURE","NORMAL_OFFSET"),h&&I&&!t.terrain&&s.icon.orientationVertexBuffer&&a.push("ELEVATED_ROADS");const P=s.icon.programConfigurations.get(n.id),R=t.getOrCreateProgram("symbol",{config:P,defines:a}),D=r.imageAtlasTexture?r.imageAtlasTexture.size:[0,0],z=s.iconSizeData,N=e.bJ(z,C.zoom),Z=I||!C.isOrthographic,W=ti(f,r.tileID.canonical,I,S,C,s.getProjection(),m),q=ni(f,r.tileID.canonical,I,S,C,s.getProjection(),m),K=t.translatePosMatrix(q,r,l,u,!0),X=t.translatePosMatrix(f,r,l,u),J=c?Qo:W,Y=S&&!I&&!i;let ee=U;!O&&!C.mercatorFromTransition||S||(ee=$o(C));const te=d?ee:U,ie=n.getColorAdjustmentMatrix(A,y,v,x),ne=Po(z.kind,N,Y,I,t,X,J,K,b,!1,D,[0,0],0,o,p,k,j,te,s.getProjection(),T,G,ie,M,null),re=r.imageAtlasTexture?r.imageAtlasTexture:null,oe=1!==n.layout.get("icon-size").constantOr(0)||s.iconsNeedLinear,se=s.sdfIcons||t.options.rotating||t.options.zooming||oe||Z?E.LINEAR:E.NEAREST,ae=s.sdfIcons&&0!==n.paint.get("icon-halo-width").constantOr(1),le=t.terrain&&I&&i?e.bk(e.bB(),W):Qo;if(i&&s.icon){const i=e.bU.getAtTileOffsetFunc(o,C.center.lat,C.worldSize,s.getProjection()),a=ii(f,r.tileID.canonical,I,S,C,s.getProjection(),m),l=n.layout.get("icon-size-scale-range"),c=e.aA(t.scaleFactor,l[0],l[1]);ai(s,f,t,!1,a,q,I,g,i,o,c)}return{program:R,buffers:s.icon,uniformValues:ne,atlasTexture:re,atlasTextureIcon:null,atlasInterpolation:se,atlasInterpolationIcon:null,isSDF:s.sdfIcons,hasHalo:ae,depthMode:B,tile:r,renderWithShadows:w,labelPlaneMatrixInv:le}},W=()=>{const i=B&&"point"!==n.layout.get("symbol-placement"),a=[],l=i||D||V,u="road"===s.elevationType,g=t.shadowRenderer,A=u&&M&&!!g&&g.enabled,y=H(A),v=u&&M&&!t.terrain?F:L;t.terrainRenderModeElevated()&&M&&a.push("PITCH_WITH_MAP_TERRAIN"),d&&(a.push("PROJECTION_GLOBE_VIEW"),l&&a.push("PROJECTED_POS_ON_VIEWPORT")),!s.text.zOffsetVertexBuffer||u&&t.terrain||a.push("Z_OFFSET"),s.iconsInText&&a.push("RENDER_TEXT_AND_SYMBOL"),a.push("RENDER_SDF"),A&&a.push("RENDER_SHADOWS","DEPTH_TEXTURE","NORMAL_OFFSET"),u&&M&&!t.terrain&&s.text.orientationVertexBuffer&&a.push("ELEVATED_ROADS"),Q(a);const x=s.text.programConfigurations.get(n.id),w=t.getOrCreateProgram("symbol",{config:x,defines:a});let T,S=[0,0],I=null;const P=s.textSizeData;s.iconsInText&&(S=r.imageAtlasTexture?r.imageAtlasTexture.size:[0,0],I=r.imageAtlasTexture?r.imageAtlasTexture:null,T=M||!C.isOrthographic||t.options.rotating||t.options.zooming||"composite"===P.kind||"camera"===P.kind?E.LINEAR:E.NEAREST);const R=r.glyphAtlasTexture?r.glyphAtlasTexture.size:[0,0],z=n.layout.get("text-size-scale-range"),N=e.aA(t.scaleFactor,z[0],z[1]),$=e.bJ(P,C.zoom,N),Z=ti(f,r.tileID.canonical,M,B,C,s.getProjection(),m),W=ni(f,r.tileID.canonical,M,B,C,s.getProjection(),m),q=t.translatePosMatrix(W,r,c,h,!0),K=t.translatePosMatrix(f,r,c,h),X=l?Qo:Z,J=B&&!M&&!i;let Y=U;!O&&!C.mercatorFromTransition||B||(Y=$o(C));const ee=Po(P.kind,$,J,M,t,K,X,q,b,!0,R,S,0,o,p,k,j,d?Y:U,s.getProjection(),y,G,null,null,N),te=r.glyphAtlasTexture?r.glyphAtlasTexture:null,ie=E.LINEAR,ne=0!==n.paint.get("text-halo-width").constantOr(1),re=t.terrain&&M&&i?e.bk(e.bB(),Z):Qo;if(i&&s.text){const i=e.bU.getAtTileOffsetFunc(o,C.center.lat,C.worldSize,s.getProjection()),n=ii(f,r.tileID.canonical,M,B,C,s.getProjection(),m);ai(s,f,t,!0,n,W,M,_,i,o,N)}return{program:w,buffers:s.text,uniformValues:ee,atlasTexture:te,atlasTextureIcon:I,atlasInterpolation:ie,atlasInterpolationIcon:T,isSDF:!0,hasHalo:ne,depthMode:v,tile:r,renderWithShadows:A,labelPlaneMatrixInv:re}},q=s.icon.segments.get().length,K=s.text.segments.get().length,X=q&&!a.onlyText?Z():null,J=K&&!a.onlyIcons?W():null,Y=n.paint.get("icon-opacity").constantOr(1),ee=n.paint.get("text-opacity").constantOr(1);if(P&&s.canOverlap){R=!0;const t=Y&&!a.onlyText?s.icon.segments.get():[],i=ee&&!a.onlyIcons?s.text.segments.get():[];for(const i of t)z.push({segments:new e.bf([i]),sortKey:i.sortKey,state:X});for(const t of i)z.push({segments:new e.bf([t]),sortKey:t.sortKey,state:J})}else a.onlyText||z.push({segments:Y?s.icon.segments:new e.bf([]),sortKey:0,state:X}),a.onlyIcons||z.push({segments:ee?s.text.segments:new e.bf([]),sortKey:0,state:J})}R&&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:C.depthOcclusionForSymbolsAndCircles,labelPlaneMatrixInv:i.labelPlaneMatrixInv}):t.setupDepthForOcclusion(C.depthOcclusionForSymbolsAndCircles,i.program),T.activeTexture.set(E.TEXTURE0),i.atlasTexture&&i.atlasTexture.bind(i.atlasInterpolation,E.CLAMP_TO_EDGE,!0),i.atlasTextureIcon&&(T.activeTexture.set(E.TEXTURE1),i.atlasTextureIcon&&i.atlasTextureIcon.bind(i.atlasInterpolationIcon,E.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,Ko(i.buffers,e.segments,n,t,i.program,i.depthMode,o,s,r,2),r.u_is_halo=0}else{if(i.isSDF){const r=i.uniformValues;i.hasHalo&&(r.u_is_halo=1,Ko(i.buffers,e.segments,n,t,i.program,i.depthMode,o,s,r,1)),r.u_is_halo=0}Ko(i.buffers,e.segments,n,t,i.program,i.depthMode,o,s,i.uniformValues,1)}}}function Ko(e,t,i,n,r,o,s,a,l,c){const u=[e.dynamicLayoutVertexBuffer,e.opacityVertexBuffer,e.iconTransitioningVertexBuffer,e.globeExtVertexBuffer,e.zOffsetVertexBuffer,e.orientationVertexBuffer];r.draw(n,n.context.gl.TRIANGLES,o,s,a,Xi.disabled,l,i.id,e.layoutVertexBuffer,e.indexBuffer,t,i.paint,n.transform.zoom,e.programConfigurations.get(i.id),u,c)}function Xo(t,i){const n=1<=sn?1:t.pitch/sn))),2*i}(t.transform),u=t.transform.getFreeCameraOptions().position,h="elevatedStructuresDepthReconstruct",d=t.getOrCreateProgram(h,{defines:["DEPTH_RECONSTRUCTION"]}),p=t.getOrCreateProgram(h);for(const e of r){const r=i.getTile(e),h=r.getBucket(n);if(!h)continue;const f=h.elevatedStructures;if(!f)continue;const m=h.elevationBufferData.heightRange,g=Xo(e.toUnwrapped(),u),_=t.translatePosMatrix(e.projMatrix,r,n.paint.get("fill-translate"),n.paint.get("fill-translate-anchor"));let A,y,v,x;if("initialize"===o){if(!m||m.min>=1||0===f.depthSegments.segments[0].primitiveLength)continue;A=fo(_,g,c,1,0),y=a,v=f.depthSegments,x=d}else if("reset"===o){if(!m||m.min>=0||0===f.maskSegments.segments[0].primitiveLength)continue;A=fo(_,g,0,0,1),y=l,v=f.maskSegments,x=d}else if("geometry"===o){if(0===f.depthSegments.segments[0].primitiveLength)continue;A=fo(_,g,c,1,0),y=a,v=f.depthSegments,x=p}x.draw(t,s.TRIANGLES,y,Wi.disabled,Qi.disabled,Xi.disabled,A,n.id,f.vertexBuffer,f.indexBuffer,v,n.paint,t.transform.zoom)}}function Yo(t,i,n){const{painter:r,sourceCache:o,layer:s,coords:a,colorMode:l,elevationType:c,terrainEnabled:u,pass:h}=t,d=r.context.gl,p=s.paint.get("fill-pattern"),f=s.paint.get("fill-pattern-cross-fade"),m=p.constantOr(null);let g=c;"road"!==c||i&&!u||(g="none");const _="road"===g,A=t.painter.shadowRenderer,y=_&&!!A&&A.enabled,v=new $i(r.context.gl.LEQUAL,$i.ReadOnly,r.depthRangeFor3D);let x=[0,0,0];if(y){const e=r.style.directionalLight,t=r.style.ambientLight;e&&t&&(x=mn(r.style,e,t))}const b=p&&p.constantOr(1),w=(t,h)=>{let p,g,w,T,E;h?(p=b&&!s.getPaintProperty("fill-outline-color")?"fillOutlinePattern":"fillOutline",w=d.LINES):(p=b?"fillPattern":"fill",w=d.TRIANGLES);for(const C of a){const a=o.getTile(C);if(b&&!a.patternsLoaded())continue;const S=a.getBucket(s);if(!S)continue;const B=i?S.elevationBufferData:S.bufferData;if(B.isEmpty())continue;r.prepareDrawTile();const I=B.programConfigurations.get(s.id),M=r.isTileAffectedByFog(C),P=[],R=[];_&&(P.push("ELEVATED_ROADS"),R.push(B.elevatedLayoutVertexBuffer)),y&&P.push("RENDER_SHADOWS","DEPTH_TEXTURE","NORMAL_OFFSET"),b&&(r.context.activeTexture.set(d.TEXTURE0),a.imageAtlasTexture&&a.imageAtlasTexture.bind(d.LINEAR,d.CLAMP_TO_EDGE),I.updatePaintBuffers());let L=!1;if(m&&a.imageAtlas){const t=a.imageAtlas,i=e.e2.from(m),n=i.getPrimary().scaleSelf(e.o.devicePixelRatio).toString(),r=i.getSecondary(),o=t.patternPositions.get(n),s=r?t.patternPositions.get(r.scaleSelf(e.o.devicePixelRatio).toString()):null;L=!!o&&!!s,o&&I.setConstantPatternPositions(o,s)}f>0&&(L||I.getPatternTransitionVertexBuffer("fill-pattern"))&&P.push("FILL_PATTERN_TRANSITION");const F=r.getOrCreateProgram(p,{config:I,overrideFog:M,defines:P}),k=r.translatePosMatrix(C.projMatrix,a,s.paint.get("fill-translate"),s.paint.get("fill-translate-anchor"));y&&A.setupShadows(a.tileID.toUnwrapped(),F,"vector-tile");const D=s.paint.get("fill-emissive-strength");if(h){T=B.lineIndexBuffer,E=B.lineSegments;const e=r.terrain&&r.terrain.renderingToTexture?r.terrain.drapeBufferSize:[d.drawingBufferWidth,d.drawingBufferHeight];g="fillOutlinePattern"===p&&b?ho(k,D,r,a,e,x,f):uo(k,D,e,x)}else T=B.indexBuffer,E=B.triangleSegments,g=b?co(k,D,r,a,x,f):lo(k,D,x);r.uploadCommonUniforms(r.context,F,C.toUnwrapped());let O=t;("road"===c&&!u||"offset"===c)&&(O=v),F.draw(r,w,O,n||r.stencilModeForClipping(C),l,Xi.disabled,g,s.id,B.layoutVertexBuffer,T,E,s.paint,r.transform.zoom,I,R)}};r.renderPass===h&&w(r.depthModeForSublayer(1,"opaque"===r.renderPass?$i.ReadWrite:$i.ReadOnly),!1),"none"===g&&"translucent"===r.renderPass&&s.paint.get("fill-antialias")&&w(r.depthModeForSublayer(s.getPaintProperty("fill-outline-color")?2:0,$i.ReadOnly),!0)}function es(t,i,n,r,o,s,a,l){n.resetLayerRenderingStats(t);const c=t.context,u=c.gl,h=t.transform,d=n.paint.get("fill-extrusion-pattern"),p=n.paint.get("fill-extrusion-pattern-cross-fade"),f=d.constantOr(null),m=d.constantOr(1),g=n.paint.get("fill-extrusion-opacity"),_=t.style.enable3dLights(),A=n.paint.get(_&&!m?"fill-extrusion-ambient-occlusion-wall-radius":"fill-extrusion-ambient-occlusion-radius"),y=[n.paint.get("fill-extrusion-ambient-occlusion-intensity"),A],v=n.layout.get("fill-extrusion-edge-radius"),x=v>0&&!n.paint.get("fill-extrusion-rounded-roof"),b=x?0:v,w="globe"===h.projection.name?e.ea():0,T="globe"===h.projection.name,E=T?e.aj(h.zoom):0,C=[e.aF(h.center.lng),e.aJ(h.center.lat)],S="none"===n.paint.get("fill-extrusion-flood-light-color-use-theme").constantOr("default"),B=n.paint.get("fill-extrusion-flood-light-color").toNonPremultipliedRenderColor(S?null:n.lut).toArray01().slice(0,3),I=n.paint.get("fill-extrusion-flood-light-intensity"),M=n.paint.get("fill-extrusion-vertical-scale"),P=0!==n.paint.get("fill-extrusion-line-width").constantOr(1),R=n.paint.get("fill-extrusion-height-alignment"),L=n.paint.get("fill-extrusion-base-alignment"),F=ln(t,n.paint.get("fill-extrusion-cutoff-fade-range")),k=[];let D;T&&k.push("PROJECTION_GLOBE_VIEW"),y[0]>0&&k.push("FAUX_AO"),x&&k.push("ZERO_ROOF_RADIUS"),l&&k.push("HAS_CENTROID"),I>0&&k.push("FLOOD_LIGHT"),F.shouldRenderCutoff&&k.push("RENDER_CUTOFF"),P&&k.push("RENDER_WALL_MODE");const O="shadow"===t.renderPass,z=t.shadowRenderer,U=O&&!!z,N=O?Xi.disabled:Xi.backCCW;t.shadowRenderer&&(t.shadowRenderer.useNormalOffset=!0);let V=[0,0,0];if(z){const e=t.style.directionalLight,i=t.style.ambientLight;e&&i&&(V=mn(t.style,e,i)),O||(k.push("RENDER_SHADOWS","DEPTH_TEXTURE"),z.useNormalOffset&&k.push("NORMAL_OFFSET")),D=k.concat(["SHADOWS_SINGLE_CASCADE"])}const j=U?"fillExtrusionDepth":m?"fillExtrusionPattern":"fillExtrusion",G=n.getLayerRenderingStats();for(const d of r){const r=i.getTile(d),_=r.getBucket(n);if(!_||_.projection.name!==h.projection.name)continue;let A=!1;z&&(A=0===z.getMaxCascadeForTile(d.toUnwrapped()));const v=t.isTileAffectedByFog(d),x=_.programConfigurations.get(n.id);let S=!1;if(f&&r.imageAtlas){const t=r.imageAtlas,i=e.e2.from(f),n=i.getPrimary().scaleSelf(e.o.devicePixelRatio).toString(),o=i.getSecondary(),s=t.patternPositions.get(n),a=o?t.patternPositions.get(o.scaleSelf(e.o.devicePixelRatio).toString()):null;S=!!s&&!!a,s&&x.setConstantPatternPositions(s,a)}p>0&&(S||x.getPatternTransitionVertexBuffer("fill-extrusion-pattern"))&&k.push("FILL_EXTRUSION_PATTERN_TRANSITION");const U=t.getOrCreateProgram(j,{config:x,defines:A?D:k,overrideFog:v});if(t.terrain&&t.terrain.setupElevationDraw(r,U,{useMeterToDem:!0}),!_.centroidVertexBuffer){const e=U.getAttributeLocation(u,"a_centroid_pos");-1!==e&&u.vertexAttrib2f(e,0,0)}!O&&z&&z.setupShadows(r.tileID.toUnwrapped(),U,"vector-tile"),m&&(t.context.activeTexture.set(u.TEXTURE0),r.imageAtlasTexture&&r.imageAtlasTexture.bind(u.LINEAR,u.CLAMP_TO_EDGE),x.updatePaintBuffers());const H=n.paint.get("fill-extrusion-vertical-gradient"),Q=1/_.tileToMeter;let $;if(O&&z){if(as(r.tileID,_.maxHeight,t))continue;const e=z.calculateShadowPassMatrixFromTile(r.tileID.toUnwrapped());$=oo(e,b,Q,M,R,L)}else{const e=t.translatePosMatrix(d.expandedProjMatrix,r,n.paint.get("fill-extrusion-translate"),n.paint.get("fill-extrusion-translate-anchor")),i=h.projection.createInversionMatrix(h,d.canonical);$=m?so(e,t,H,g,y,b,Q,d,r,w,R,L,E,C,i,B,M,p):ro(e,t,H,g,y,b,Q,d,w,R,L,E,C,i,B,M,I,V)}t.uploadCommonUniforms(c,U,d.toUnwrapped(),null,F);let Z=_.segments;if("mercator"===h.projection.name&&!O&&(Z=_.getVisibleSegments(r.tileID,t.terrain,t.transform.getFrustum(0)),!Z.get().length))continue;if(G)if(O)for(const e of Z.get())G.numRenderedVerticesInShadowPass+=e.primitiveLength;else for(const e of Z.get())G.numRenderedVerticesInTransparentPass+=e.primitiveLength;const W=[];(t.terrain||l)&&W.push(_.centroidVertexBuffer),T&&W.push(_.layoutVertexExtBuffer),P&&W.push(_.wallVertexBuffer),U.draw(t,c.gl.TRIANGLES,o,s,a,N,$,n.id,_.layoutVertexBuffer,_.indexBuffer,Z,n.paint,t.transform.zoom,x,W)}t.shadowRenderer&&(t.shadowRenderer.useNormalOffset=!1)}class ts{constructor(){this.translate=[0,0],this.translateAnchor="map",this.edgeRadius=0,this.cutoffFadeRange=0}}function is(t,i,n,r,o,s,a,l,c,u,h,d,p,f,m,g,_,A,y,v){const x=i.context,b=x.gl,w=i.transform,T=i.transform.zoom,E=[],C=t.translate,S=t.translateAnchor,B=t.edgeRadius,I=ln(i,t.cutoffFadeRange);"clear"===h?(E.push("CLEAR_SUBPASS"),v&&(E.push("CLEAR_FROM_TEXTURE"),x.activeTexture.set(b.TEXTURE0),v.bind(b.LINEAR,b.CLAMP_TO_EDGE))):"sdf"===h&&E.push("SDF_SUBPASS"),A&&E.push("HAS_CENTROID"),I.shouldRenderCutoff&&E.push("RENDER_CUTOFF");const M=(e,t,n,o,h)=>{let y=E;null!=t.groundRadiusBuffer&&(y=E.concat("HAS_ATTRIBUTE_a_flood_light_ground_radius"));const b=t.programConfigurations.get(r.id),w=i.isTileAffectedByFog(e),C=i.getOrCreateProgram("fillExtrusionGroundEffect",{config:b,defines:y,overrideFog:w}),S=ao(i,o,d,u,h,[p,f*h],m,g,_,T>=17?0:B*h,v?v.size[0]:0),M=[];A&&M.push(t.hiddenByLandmarkVertexBuffer),null!=t.groundRadiusBuffer&&M.push(t.groundRadiusBuffer),i.uploadCommonUniforms(x,C,e.toUnwrapped(),null,I),C.draw(i,x.gl.TRIANGLES,s,a,l,c,S,r.id,t.vertexBuffer,t.indexBuffer,n,r.paint,T,b,M)};for(const t of o){const o=n.getTile(t),s=o.getBucket(r);if(!s||s.projection.name!==w.projection.name||!s.groundEffect||s.groundEffect&&!s.groundEffect.hasData())continue;const a=s.groundEffect,l=1/s.tileToMeter;{const e=i.translatePosMatrix(t.projMatrix,o,C,S),n=a.getDefaultSegment();M(t,a,n,e,l)}if(y)for(let s=0;s<4;s++){const a=e.e8[s](t),c=n.getTile(a);if(!c)continue;const u=c.getBucket(r);if(!u||u.projection.name!==w.projection.name||!u.groundEffect||u.groundEffect&&!u.groundEffect.hasData())continue;const h=u.groundEffect;let d,p;0===s?(d=[-e.al,0,0],p=1):1===s?(d=[e.al,0,0],p=0):2===s?(d=[0,-e.al,0],p=3):(d=[0,e.al,0],p=2);const f=h.regionSegments[p];if(!f)continue;const m=new Float32Array(16);e.bq(m,t.projMatrix,d),M(t,h,f,i.translatePosMatrix(m,o,C,S),l)}}}function ns(t,i,n,r,o,s,a){0===r.centroidVertexArray.length&&r.createCentroidsBuffer();const l=s?s.findDEMTileFor(n):null;if(!(l&&l.dem||a))return;s&&l&&l.dem&&r.selfDEMTileTimestamp!==l.dem._timestamp&&(r.borderDoneWithNeighborZ=[-1,-1,-1,-1],r.selfDEMTileTimestamp=l.dem._timestamp);const c=t=>new e.P(Math.ceil((t+e.ec)*e.ed),0),u=e=>{const t=i.getSource().minzoom,n=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(h[0]=Math.min(t.min.y,i.min.y),h[1]=Math.max(t.max.y,i.max.y),h[2]=e.al-i.min.x>t.max.x?i.min.x-e.al:t.max.x,h),p=(t,i)=>(h[0]=Math.min(t.min.x,i.min.x),h[1]=Math.max(t.max.x,i.max.x),h[2]=e.al-i.min.y>t.max.y?i.min.y-e.al:t.max.y,h),f=[(e,t)=>d(e,t),(e,t)=>d(t,e),(e,t)=>p(e,t),(e,t)=>p(t,e)],m=(t,i,r,o,a,c,u)=>{if(!s)return 0;const h=[[c?r:t,c?t:r,0],[c?r:i,c?i:r,0]],d=u<0?e.al+u:u,p=[c?d:(t+i)/2,c?(t+i)/2:d,0];return 0===r&&u<0||0!==r&&u>0?s.getForTilePoints(a,[p],!0,o):h.push(p),s.getForTilePoints(n,h,!0,l),Math.max(h[0][2],h[1][2],p[2])/s.exaggeration()};for(let t=0;t<4;t++){const i=r.borderFeatureIndices[t];if(0===i.length)continue;const o=e.e8[t](n),l=u(o);if(!(l&&l instanceof e.e9))continue;const h=s?s.findDEMTileFor(o):null;if(!(h&&h.dem||a))continue;if(s&&h&&h.dem&&r.borderDEMTileTimestamp[t]!==h.dem._timestamp&&(r.borderDoneWithNeighborZ[t]=-1,r.borderDEMTileTimestamp[t]=h.dem._timestamp),r.borderDoneWithNeighborZ[t]===l.canonical.z)continue;0===l.centroidVertexArray.length&&l.createCentroidsBuffer();const d=(t<2?1:5)-t,p=l.borderDoneWithNeighborZ[d]!==r.canonical.z,A=l.borderFeatureIndices[d];let y=0;if(r.canonical.z!==l.canonical.z){for(const e of i)r.showCentroid(r.featuresOnBorder[e]);if(p)for(const e of A)l.showCentroid(l.featuresOnBorder[e]);r.borderDoneWithNeighborZ[t]=l.canonical.z,l.borderDoneWithNeighborZ[d]=r.canonical.z}for(const n of i){const i=r.featuresOnBorder[n],s=r.centroidData[i.centroidDataIndex],u=i.borders[t];let p;for(;yu[0]+3||e[0]>u[0]-3)break;l.showCentroid(p),y++}if(p&&yu[1]-3)&&(v++,++y!==A.length);)p=l.featuresOnBorder[A[y]];p=l.featuresOnBorder[A[n]];let x=!1;if(v>=1){const e=p.borders[d];Math.abs(u[0]-e[0])<3&&Math.abs(u[1]-e[1])<3&&(v=1,x=!0,y=n+1)}else if(0===v){r.showCentroid(i);continue}const b=l.centroidData[p.centroidDataIndex];a&&x&&(((g=s).flags|(_=b).flags)&e.eb?(g.flags|=e.eb,_.flags|=e.eb):(g.flags&=~e.eb,_.flags&=~e.eb));const w=i.intersectsCount()>1||p.intersectsCount()>1;if(v>1)y=n,s.centroidXY=b.centroidXY=new e.P(0,0);else if(h&&h.dem&&!w){const i=f[t](s,b),n=t%2?e.al-1:0,r=m(i[0],Math.min(e.al-1,i[1]),n,h,o,t<2,i[2]);s.centroidXY=b.centroidXY=c(r)}else w?s.centroidXY=b.centroidXY=new e.P(0,0):(s.centroidXY=r.encodeBorderCentroid(i),b.centroidXY=l.encodeBorderCentroid(p));r.writeCentroidToBuffer(s),l.writeCentroidToBuffer(b)}else r.showCentroid(i)}r.borderDoneWithNeighborZ[t]=l.canonical.z,l.borderDoneWithNeighborZ[d]=r.canonical.z}var g,_;(r.needsCentroidUpdate||!r.centroidVertexBuffer&&0!==r.centroidVertexArray.length)&&r.uploadCentroid(t)}const rs=[1,0,0],os=[0,1,0],ss=[0,0,1];function as(t,i,n){const r=n.transform,o=n.shadowRenderer;if(!o)return!0;const s=t.toUnwrapped(),a=r.tileSize*o._cascades[n.currentShadowCascade].scale;let l=i;if(r.elevation){const e=r.elevation.getMinMaxForTile(t);e&&(l+=e.max)}const c=[...o.shadowDirection];c[2]=-c[2];const u=o.computeSimplifiedTileShadowVolume(s,l,a,c);if(!u)return!1;const h=[rs,os,ss,c,[c[0],0,c[2]],[0,c[1],c[2]]],d="globe"===r.projection.name,p=r.scaleZoom(a),f=e.cA.fromInvProjectionMatrix(r.invProjMatrix,r.worldSize,p,!d),m=o.getCurrentCascadeFrustum();return 0===f.intersectsPrecise(u.vertices,u.planes,h)||0===m.intersectsPrecise(u.vertices,u.planes,h)}function ls(t){const{painter:i,source:n,layer:r,coords:o}=t;let s=t.defines;const a=i.context,l="shadow"===i.renderPass,c="light-beam"===i.renderPass,u=i.shadowRenderer,h=e.ee(i.transform.center.lat,i.transform.zoom),d=ln(i,r.paint.get("building-cutoff-fade-range"));d.shouldRenderCutoff&&(s=s.concat("RENDER_CUTOFF")),t.floodLightIntensity>0&&(s=s.concat("FLOOD_LIGHT"));for(const p of o){const o=n.getTile(p),f=o.getBucket(r);if(!f)continue;u&&0===u.getMaxCascadeForTile(p.toUnwrapped())&&(s=s.concat("SHADOWS_SINGLE_CASCADE"));const m=f.programConfigurations.get(r.id);let g,_,A,y=i.translatePosMatrix(p.expandedProjMatrix,o,[0,0],"map");if(y=e.cR(e.bB(),y,[1,1,t.verticalScale]),l&&u){if(as(o.tileID,f.maxHeight*h,i))continue;let n=u.calculateShadowPassMatrixFromTile(o.tileID.toUnwrapped());n=e.cR(e.bB(),n,[1,1,t.verticalScale]),A=_o(n),g=_=i.getOrCreateProgram("buildingDepth",{config:m,defines:s,overrideFog:!1})}else if(c)g=_=i.getOrCreateProgram("buildingBloom",{config:m,defines:s,overrideFog:!1}),A=go(y);else{const n=i.transform.calculatePosMatrix(p.toUnwrapped(),i.transform.worldSize);e.cR(n,n,[1,1,t.verticalScale]);const r=e.bB();e.cR(r,n,[1,-1,1/h]),e.bk(r,r),e.ef(r,r);const o=i.transform.getFreeCameraOptions().position,a=1<{if(c){const o=e.entranceBloom;n.draw(i,a.gl.TRIANGLES,t.depthMode,Wi.disabled,t.blendMode,Xi.disabled,A,r.id,o.layoutVertexBuffer,o.indexBuffer,o.segmentsBucket,r.paint,i.transform.zoom,m,[o.layoutAttenuationBuffer,o.layoutColorBuffer])}else{const o=e.segmentsBucket;let s=[e.layoutNormalBuffer,e.layoutCentroidBuffer,e.layoutColorBuffer,e.layoutFloodLightDataBuffer];e.layoutFacadePaintBuffer&&(s=s.concat([e.layoutFacadeDataBuffer,e.layoutFacadeVerticalRangeBuffer,e.layoutFacadePaintBuffer])),n.draw(i,a.gl.TRIANGLES,t.depthMode,Wi.disabled,t.blendMode,l?Xi.disabled:Xi.backCW,A,r.id,e.layoutVertexBuffer,e.indexBuffer,o,r.paint,i.transform.zoom,m,s)}};i.uploadCommonUniforms(a,_,p.toUnwrapped(),null,d),f.buildingWithoutFacade&&v(f.buildingWithoutFacade,_),f.buildingWithFacade&&(g!==_&&i.uploadCommonUniforms(a,g,p.toUnwrapped(),null,d),v(f.buildingWithFacade,g))}}function cs(t,i,n,r,o,s,a,l,c,u,h,d,p){const f=t.context.gl,m=t.depthModeForSublayer(1,$i.ReadOnly,f.LEQUAL,!0),g=.1*(1-(_=h))+3*_;var _;const A=t._showOverdrawInspector,y=d,v=new ts;A||is(v,t,i,n,r,m,new Wi({func:f.ALWAYS,mask:255},255,255,f.KEEP,f.KEEP,f.REPLACE),new Qi([f.ONE,f.ONE,f.ONE,f.ONE],e.ao.transparent,[!1,!1,!1,!0],f.MIN),Xi.disabled,o,"sdf",s,a,l,c,u,g,y,!1);{const h=A?Wi.disabled:new Wi({func:f.EQUAL,mask:255},255,255,f.KEEP,f.DECR,f.DECR),d=A?t.colorModeForRenderPass():new Qi([f.ONE_MINUS_DST_ALPHA,f.DST_ALPHA,f.ONE,f.ONE],e.ao.transparent,[!0,!0,!0,!0]);is(v,t,i,n,r,m,h,d,Xi.disabled,o,"color",s,a,l,c,u,g,y,!1)}}function us(t){return[t[0]*e.eg,t[1]*e.eg,t[2]*e.eg,0]}function hs(t,i,n,r,o,s,a,l,c){const u=r.getSource(),h=n.globeSharedBuffers;if(!h)return;let d,p,f;if(i&&(d=r.getTile(i)),u instanceof e.aT?(p=u.texture,f=e.dJ(0,0,n.transform)):d&&i&&(p=d.texture,f=e.dJ(i.canonical.z,i.canonical.x,n.transform)),!p||!f)return;t||(f=e.cR(e.bB(),f,[1,-1,1]));const m=n.context,g=m.gl,_="nearest"===o.paint.get("raster-resampling")?g.NEAREST:g.LINEAR,A=n.colorModeForDrapableLayerRenderPass(s),y=a.defines;y.push("GLOBE_POLES");const v=new $i(g.LEQUAL,$i.ReadWrite,n.depthRangeFor3D),x=Float32Array.from(n.transform.expandedFarZProjMatrix),b=Float32Array.from(e.bj(e.dI(new e.cC(0,0,0))));n.terrain&&n.terrain.prepareDrawTile(),m.activeTexture.set(g.TEXTURE0),p.bind(_,g.CLAMP_TO_EDGE),m.activeTexture.set(g.TEXTURE1),p.bind(_,g.CLAMP_TO_EDGE),"useMipmap"in p&&m.extTextureFilterAnisotropic&&n.transform.pitch>20&&g.texParameterf(g.TEXTURE_2D,m.extTextureFilterAnisotropic.TEXTURE_MAX_ANISOTROPY_EXT,m.extTextureFilterAnisotropicMax);const[w,T,E,C]=i?h.getPoleBuffers(i.canonical.z,!1):h.getPoleBuffers(0,!0),S=o.paint.get("raster-elevation");let B;t?(B=w,n.renderDefaultNorthPole=0!==S):(B=T,n.renderDefaultSouthPole=0!==S);const I=us(a.mix),M=((e,t,i,n,r,o,s,a,l,c,u,h,d)=>To(e,t,i,new Float32Array(16),new Float32Array(9),[0,0],n,[0,0],[0,0,0,0],1,{opacity:1,mix:0},o,[0,0]||[0,0],a,2,c,u,h,1,0,d))(x,b,f,e.aj(n.transform.zoom),0,o,0,S,0,I,a.offset,a.range,s),P=n.getOrCreateProgram("raster",{defines:y});n.uploadCommonUniforms(m,P,null),P.draw(n,g.TRIANGLES,v,c,A,l,M,o.id,B,E,C)}function ds(e){const t=e._nearZ,i=e.projection.farthestPixelDistance(e),n=i-t,r=.2*e.height,o=t+r;return[t,i,(o-r-t)/n,(o-t)/n]}function ps(e,t,i,n){if(e)return t instanceof ht&&e instanceof Mt?t.getTextureDescriptor(e,i,!0):{texture:e.texture,mix:us(n.mix),offset:n.offset,buffer:0,tileSize:1}}var fs=e.eh([{name:"a_index",type:"Int16",components:1}]);class ms{constructor(t,i,n,r){const o={width:n[0],height:n[1],data:null},s=t.gl;this.targetColorTexture=new e.T(t,o,s.RGBA8,{useMipmap:!1}),this.backgroundColorTexture=new e.T(t,o,s.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 n=this.context.gl,r=i.width*i.height;this.particleTexture0=new e.T(this.context,i,n.RGBA8,{premultiply:!1,useMipmap:!1}),this.particleTexture1=new e.T(this.context,i,n.RGBA8,{premultiply:!1,useMipmap:!1});const o=new e.ei;o.reserve(r);for(let e=0;e0){const t=e.bi(n.canonical,c),i=e.ek(t);p=e.aB(new Float32Array(16),c.globeMatrix,i),e.aB(p,c.projMatrix,p)}const f=e.bB();f[12]+=2*o/(e.o.devicePixelRatio*c.width),f[13]+=2*s/(e.o.devicePixelRatio*c.height),e.aB(p,f,p);const m=t.getOrCreateProgram("debug",{defines:d}),g=i.getTileByID(n.key);t.terrain&&t.terrain.setupElevationDraw(g,m);const _=$i.disabled,A=Wi.disabled,y=t.colorModeForRenderPass(),v="$debug";l.activeTexture.set(u.TEXTURE0),t.emptyTexture.bind(u.LINEAR,u.CLAMP_TO_EDGE),h?g._makeGlobeTileDebugBuffers(t.context,c):g._makeDebugTileBoundsBuffers(t.context,c.projection);const x=g._tileDebugBuffer||t.debugBuffer,b=g._tileDebugIndexBuffer||t.debugIndexBuffer,w=g._tileDebugSegments||t.debugSegments;if(m.draw(t,u.LINE_STRIP,_,A,y,Xi.disabled,yo(p,r.toPremultipliedRenderColor(null)),v,x,b,w,null,null,null,[g._globeTileDebugBorderBuffer]),a){const e=g.latestRawTileData,i=Math.floor((e&&e.byteLength||0)/1024);let r=n.canonical.toString();n.overscaledZ!==n.canonical.z&&(r+=` => ${n.overscaledZ}`),r+=` ${g.state}`,r+=` ${i}kb`,function(e,t){e.initDebugOverlayCanvas();const i=e.debugOverlayCanvas,n=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(n.LINEAR,n.CLAMP_TO_EDGE)}(t,r)}const T=i.getTile(n).tileSize,E=512/Math.min(T,512)*(n.overscaledZ/c.zoom)*.5,C=g._tileDebugTextBuffer||t.debugBuffer,S=g._tileDebugTextIndexBuffer||t.quadTriangleIndexBuffer,B=g._tileDebugTextSegments||t.debugSegments;m.draw(t,u.TRIANGLES,_,A,Qi.alphaBlended,Xi.disabled,yo(p,e.ao.transparent.toPremultipliedRenderColor(null),E),v,C,S,B,null,null,null,[g._globeTileDebugTextBuffer])}function Es(e,t,i,n){Ss(e,0,t+i/2,e.transform.width,i,n)}function Cs(e,t,i,n){Ss(e,t-i/2,0,i,e.transform.height,n)}function Ss(t,i,n,r,o,s){const a=t.context,l=a.gl;l.enable(l.SCISSOR_TEST),l.scissor(i*e.o.devicePixelRatio,n*e.o.devicePixelRatio,r*e.o.devicePixelRatio,o*e.o.devicePixelRatio),a.clear({color:s}),l.disable(l.SCISSOR_TEST)}const Bs=e.eh([{name:"a_pos_3f",components:3,type:"Float32"}]),{members:Is}=Bs;function Ms(e,t,i,n){e.emplaceBack(t,i,n)}class Ps{constructor(t){this.vertexArray=new e.el,this.indices=new e.b0,Ms(this.vertexArray,-1,-1,1),Ms(this.vertexArray,1,-1,1),Ms(this.vertexArray,-1,1,1),Ms(this.vertexArray,1,1,1),Ms(this.vertexArray,-1,-1,-1),Ms(this.vertexArray,1,-1,-1),Ms(this.vertexArray,-1,1,-1),Ms(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,Is),this.indexBuffer=t.createIndexBuffer(this.indices),this.segment=e.bf.simpleSegment(0,0,36,12)}}function Rs(t,i,n,r,o,s){const a=t.context.gl,l=i.paint.get("sky-atmosphere-color"),c=i.paint.get("sky-atmosphere-halo-color"),u=i.paint.get("sky-atmosphere-sun-intensity"),h=((e,t,i,n,r)=>({u_matrix_3f:e,u_sun_direction:t,u_sun_intensity:i,u_color_tint_r:[n.r,n.g,n.b,n.a],u_color_tint_m:[r.r,r.g,r.b,r.a],u_luminance:5e-5}))(e.en(e.dN(),r),o,u,l.toPremultipliedRenderColor(null),c.toPremultipliedRenderColor(null));a.framebufferTexture2D(a.FRAMEBUFFER,a.COLOR_ATTACHMENT0,a.TEXTURE_CUBE_MAP_POSITIVE_X+s,i.skyboxTexture,0),n.draw(t,a.TRIANGLES,$i.disabled,Wi.disabled,Qi.unblended,Xi.frontCW,h,"skyboxCapture",i.skyboxGeometry.vertexBuffer,i.skyboxGeometry.indexBuffer,i.skyboxGeometry.segment)}const Ls=e.eh([{type:"Float32",name:"a_pos",components:3},{type:"Float32",name:"a_uv",components:2}]);class Fs{constructor(t){const i=new e.eo;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 n=new e.b0;n.emplaceBack(0,1,2),n.emplaceBack(2,3,0),this.vertexBuffer=t.createVertexBuffer(i,Ls.members),this.indexBuffer=t.createIndexBuffer(n),this.segments=e.bf.simpleSegment(0,0,4,2)}destroy(){this.vertexBuffer.destroy(),this.indexBuffer.destroy(),this.segments.destroy()}}const ks=e.eh([{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_fade_opacity",components:1}]);class Ds{constructor(){this.starsCount=16e3,this.sizeMultiplier=.15,this.sizeRange=100,this.intensityRange=200}}class Os{constructor(t){this.colorModeAlphaBlendedWriteRGB=new Qi([1,Hi,1,Hi],e.ao.transparent,[!0,!0,!0,!1]),this.colorModeWriteAlpha=new Qi([1,0,1,0],e.ao.transparent,[!1,!1,!1,!0]),this.params=new Ds,this.updateNeeded=!0,t.tp.registerParameter(this.params,["Stars"],"starsCount",{min:100,max:16e3,step:1},()=>{this.updateNeeded=!0}),t.tp.registerParameter(this.params,["Stars"],"sizeMultiplier",{min:.01,max:2,step:.01}),t.tp.registerParameter(this.params,["Stars"],"sizeRange",{min:0,max:200,step:1},()=>{this.updateNeeded=!0}),t.tp.registerParameter(this.params,["Stars"],"intensityRange",{min:0,max:200,step:1},()=>{this.updateNeeded=!0})}update(t){const i=t.context;if(!this.atmosphereBuffer||this.updateNeeded){this.updateNeeded=!1,this.atmosphereBuffer=new Fs(i);const t=this.params.sizeRange,n=this.params.intensityRange,r=function(t){const i=e.eq(30),n=[];for(let r=0;r{const i="globe"===o.projection.name?["PROJECTION_GLOBE_VIEW","FOG"]:["FOG"];e&&i.push("ALPHA_PASS");const l=t.getOrCreateProgram("globeAtmosphere",{defines:i}),c=((e,t,i,n,r,o,s,a,l,c,u,h)=>({u_frustum_tl:e,u_frustum_tr:t,u_frustum_br:i,u_frustum_bl:n,u_horizon:r,u_transition:o,u_fadeout_range:s,u_atmosphere_fog_color:a.toArray01(),u_high_color:l.toArray01(),u_space_color:c.toArray01(),u_temporal_offset:u,u_horizon_angle:h}))(o.frustumCorners.TL,o.frustumCorners.TR,o.frustumCorners.BR,o.frustumCorners.BL,o.frustumCorners.horizon,a,g,u,d,f,A,x);t.uploadCommonUniforms(n,l);const h=this.atmosphereBuffer;h&&l.draw(t,r.TRIANGLES,s,Wi.disabled,e?this.colorModeWriteAlpha:this.colorModeAlphaBlendedWriteRGB,Xi.backCW,c,e?"atmosphere_glow_alpha":"atmosphere_glow",h.vertexBuffer,h.indexBuffer,h.segments)};b(!1),b(!0)}drawStars(t,i){const n=e.aA(i.properties.get("star-intensity"),0,1);if(0===n)return;const r=t.context,o=r.gl,s=t.transform,a=t.getOrCreateProgram("stars"),l=e.c6([]);e.c8(l,l,-s._pitch),e.c7(l,l,-s.angle),e.c8(l,l,e.an(s._center.lat)),e.es(l,l,-e.an(s._center.lng));const c=e.cb(new Float32Array(16),l),u=e.aB([],s.starsProjMatrix,c),h=e.en([],c),d=e.et([],h),p=[0,1,0];e.dP(p,p,d),e.c4(p,p,this.params.sizeMultiplier);const f=[1,0,0];e.dP(f,f,d),e.c4(f,f,this.params.sizeMultiplier);const m=(g=p,_=f,A=n,{u_matrix:Float32Array.from(u),u_up:g,u_right:_,u_intensity_multiplier:A});var g,_,A;t.uploadCommonUniforms(r,a),this.starsVx&&this.starsIdx&&a.draw(t,o.TRIANGLES,$i.disabled,Wi.disabled,this.colorModeAlphaBlendedWriteRGB,Xi.disabled,m,"atmosphere_stars",this.starsVx,this.starsIdx,this.starsSegments)}}class zs{constructor(){this.visibleTiles=[]}updateBorders(t,i){const n=[],r=[],o=t._getRenderableCoordinates(!1,!0);for(const e of o){const o=t.getTile(e);if(!o.hasData())continue;const s=o.getBucket(i);s&&(s.isEmpty()||(n.push(e.key),r.push({bucket:s,tileID:e.canonical})))}let s=n.length!==this.visibleTiles.length;if(!s){n.sort();for(let e=0;ee.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,n=new Array,r=t.bucket;for(const e of r.featuresOnBorder)a.has(e.featureId)?n.push(e.footprintIndex):(a.add(e.featureId),i.push(e.footprintIndex));r.updateFootprintHiddenFlags(i,e.eu,!1),r.updateFootprintHiddenFlags(n,e.eu,!0)}}}function Us(t,i){const n=[...t],r=i.cameraWorldSizeForFog/i.worldSize,o=e.bz([]);return e.cR(o,o,[r,r,1]),e.aB(n,o,n),e.aB(n,i.worldToFogMatrix,n),n}function Ns(t,i,n,r,o){const s=n.material,a=r.context,{baseColorTexture:l,metallicRoughnessTexture:c}=s.pbrMetallicRoughness,{normalTexture:u,occlusionTexture:h,emissionTexture:d}=s;function p(e,i,n){if(e&&(t.push(i),a.activeTexture.set(a.gl.TEXTURE0+n),e.gfxTexture)){const{minFilter:t,magFilter:i,wrapS:n,wrapT:r}=e.sampler;e.gfxTexture.bindExtraParam(t,i,n,r)}}p(l,"HAS_TEXTURE_u_baseColorTexture",rn.BaseColor),p(c,"HAS_TEXTURE_u_metallicRoughnessTexture",rn.MetallicRoughness),p(u,"HAS_TEXTURE_u_normalTexture",rn.Normal),p(h,"HAS_TEXTURE_u_occlusionTexture",rn.Occlusion),p(d,"HAS_TEXTURE_u_emissionTexture",rn.Emission),o&&(o.texture||(o.texture=new e.d_(r.context,o.image,[o.image.height,o.image.height,o.image.height],a.gl.RGBA8)),a.activeTexture.set(a.gl.TEXTURE0+rn.LUT),o.texture&&o.texture.bind(a.gl.LINEAR,a.gl.CLAMP_TO_EDGE),t.push("APPLY_LUT_ON_GPU")),n.texcoordBuffer&&(t.push("HAS_ATTRIBUTE_a_uv_2f"),i.push(n.texcoordBuffer)),n.colorBuffer&&(t.push(12===n.colorBuffer.itemSize?"HAS_ATTRIBUTE_a_color_3f":"HAS_ATTRIBUTE_a_color_4f"),i.push(n.colorBuffer)),n.normalBuffer&&(t.push("HAS_ATTRIBUTE_a_normal_3f"),i.push(n.normalBuffer)),n.pbrBuffer&&(t.push("HAS_ATTRIBUTE_a_pbr"),t.push("HAS_ATTRIBUTE_a_heightBasedEmissiveStrength"),i.push(n.pbrBuffer)),"OPAQUE"!==s.alphaMode&&"MASK"!==s.alphaMode||t.push("UNPREMULT_TEXTURE_IN_SHADER"),s.defined||t.push("DIFFUSE_SHADED");const f=r.shadowRenderer;f&&(t.push("RENDER_SHADOWS","DEPTH_TEXTURE"),f.useNormalOffset&&t.push("NORMAL_OFFSET"))}function Vs(t,i,n,r,o,s){const a=n.paint.get("model-opacity").constantOr(1),l=i.context,c=new $i(i.context.gl.LEQUAL,t.isLightMesh?$i.ReadOnly:$i.ReadWrite,i.depthRangeFor3D),u=i.transform,h=t.mesh,d=h.material,p=d.pbrMetallicRoughness,f=i.style.fog;let m;m="pixels"===i.transform.projection.zAxisUnit?[...t.nodeModelMatrix]:e.aB([],r.zScaleMatrix,t.nodeModelMatrix),e.aB(m,r.negCameraPosMatrix,m);const g=e.bk([],m);e.ef(g,g);const _="none"===n.paint.get("model-color-use-theme").constantOr("default"),A=n.paint.get("model-emissive-strength").constantOr(0),y=ko(new Float32Array(t.worldViewProjection),new Float32Array(m),new Float32Array(g),null,i,a,p.baseColorFactor,d.emissiveFactor,p.metallicFactor,p.roughnessFactor,d,A,n,void 0,void 0,t.materialOverride,t.modelColor),v={defines:[]},x=[],b=i.shadowRenderer;b&&(b.useNormalOffset=!1),Ns(v.defines,x,h,i,_?null:n.lut);let w=null;if(f){const e=Us(t.nodeModelMatrix,i.transform);if(w=new Float32Array(e),"globe"!==u.projection.name){const t=h.aabb.min,i=h.aabb.max,[n,r]=f.getOpacityForBounds(e,t[0],t[1],i[0],i[1]);v.overrideFog=n>=Ve||r>=Ve}}const T=ln(i,n.paint.get("model-cutoff-fade-range"));T.shouldRenderCutoff&&v.defines.push("RENDER_CUTOFF");const E=i.getOrCreateProgram("model",v);i.uploadCommonUniforms(l,E,null,w,T),"shadow"!==i.renderPass&&b&&b.setupShadowsFromMatrix(t.nodeModelMatrix,E),E.draw(i,l.gl.TRIANGLES,c,o,s,h.material.doubleSided?Xi.disabled:Xi.backCCW,y,n.id,h.vertexBuffer,h.indexBuffer,h.segments,n.paint,i.transform.zoom,void 0,x)}function js(e,t,i){return"vector"===e.type?t.scope:i?"basemap":""}function Gs(t,i,n,r,o,s,a,l,c){const u=t.transform,h=!!i.isGeometryBloom&&i.isGeometryBloom;if(h&&"shadow"===t.renderPass)return;const d="globe"===u.projection.name?e.eC(n,u):[...n];e.aB(d,d,i.globalMatrix);const p=e.aB([],r,d);if(i.meshes)for(const t of i.meshes){const i=l.get(t.material.name);if(i&&i.opacity<=0)continue;if("BLEND"!==t.material.alphaMode){a.push({mesh:t,depth:0,modelIndex:o,worldViewProjection:p,nodeModelMatrix:d,isLightMesh:h,materialOverride:i,modelColor:c});continue}const n=e.af([],t.centroid,p);!u.isOrthographic&&n[2]<=0||s.push({mesh:t,depth:n[2],modelIndex:o,worldViewProjection:p,nodeModelMatrix:d,isLightMesh:h,materialOverride:i,modelColor:c})}if(i.children)for(const e of i.children)Gs(t,e,n,r,o,s,a,l,c)}function Hs(e,t,i,n){const r=i.shadowRenderer;if(!r)return;const o=r.getShadowPassDepthMode(),s=r.getShadowPassColorMode(),a=r.calculateShadowPassMatrixFromMatrix(t),l=Do(a);i.getOrCreateProgram("modelDepth",{defines:i._shadowMapDebug?[]:["DEPTH_TEXTURE"]}).draw(i,i.context.gl.TRIANGLES,o,Wi.disabled,s,Xi.disabled,l,n.id,e.vertexBuffer,e.indexBuffer,e.segments,n.paint,i.transform.zoom,void 0,void 0)}function Qs(e,t,i,n,r,o){for(const s of r){const r=Object.assign({},n);r.part=s;const a={type:"Unknown",id:t,properties:r},l={orientation:e.paint.get("model-rotation").evaluate(a,i)};o.set(s,l)}}function $s(e,t,i,n,r,o){for(const s of r){const r=Object.assign({},n);r.part=s;const a={type:"Unknown",id:t,properties:r},l={color:e.paint.get("model-color").evaluate(a,i),colorMix:e.paint.get("model-color-mix-intensity").evaluate(a,i),opacity:e.paint.get("model-opacity").evaluate(a,i),emissionStrength:e.paint.get("model-emissive-strength").evaluate(a,i)};o.set(s,l)}}function Zs(e,t,i,n,r,o){if(1===i)for(const i of r)Vs(i,e,t,o[i.modelIndex],Wi.disabled,e.colorModeForRenderPass());else{for(const i of r)Vs(i,e,t,o[i.modelIndex],Wi.disabled,Qi.disabled);for(const i of r)Vs(i,e,t,o[i.modelIndex],e.stencilModeFor3D(),e.colorModeForRenderPass());e.resetStencilClippingMasks()}const s=Qi.additive;for(const i of n)Vs(i,e,t,o[i.modelIndex],Wi.disabled,i.isLightMesh?s:e.colorModeForRenderPass())}function Ws(t,i,n){const r=i.updateZoomBasedPaintProperties(),o=function(t,i,n){let r,o,s,a=t.terrain?t.terrain.exaggeration():0;if(t.terrain&&a>0){const i=t.terrain,o=i.findDEMTileFor(n);o&&o.dem?r=e.eE.create(i,n,o):a=0}if(0===a&&(i.terrainElevationMin=0,i.terrainElevationMax=0),a===i.validForExaggeration&&(0===a||r&&r._demTile&&r._demTile.tileID===i.validForDEMTile.id&&r._dem._timestamp===i.validForDEMTile.timestamp))return!1;for(const e in i.instancesPerModel){const t=i.instancesPerModel[e];for(let e=0;eu&&(u=e.max)}const h=e.aA(r.x,s,a)-r.x,d=e.aA(r.y,l,c)-r.y,p=e.ce(u,i.center.lat)-r.z;return i._zoomFromMercatorZ(Math.sqrt(h*h+d*d+p*p))}function Xs(e,t,i,n,r,o,s){const a=e.context,l="shadow"===e.renderPass,c=e.shadowRenderer,u=l&&c?c.getShadowPassDepthMode():new $i(a.gl.LEQUAL,$i.ReadWrite,e.depthRangeFor3D),h=e.isTileAffectedByFog(o),d="globe"===e.transform.projection.name;if(i.meshes)for(const p of i.meshes){const f=d?[]:["MODEL_POSITION_ON_GPU"],m=[];let g,_,A;const y=!d&&n.instancedDataArray.length>20;y&&f.push("INSTANCED_ARRAYS");const v=ln(e,t.paint.get("model-cutoff-fade-range"));if(v.shouldRenderCutoff&&f.push("RENDER_CUTOFF"),l&&c)g=e.getOrCreateProgram("modelDepth",{defines:f}),_=Do(s.shadowTileMatrix,s.shadowTileMatrix,Float32Array.from(i.globalMatrix)),A=c.getShadowPassColorMode();else{Ns(f,m,p,e,"none"===t.paint.get("model-color-use-theme").constantOr("default")?null:t.lut),g=e.getOrCreateProgram("model",{defines:f,overrideFog:h});const n=p.material,l=n.pbrMetallicRoughness,u=t.paint.get("model-opacity").constantOr(1),d=t.paint.get("model-emissive-strength").constantOr(0);_=ko(o.expandedProjMatrix,Float32Array.from(i.globalMatrix),new Float32Array(16),null,e,u,l.baseColorFactor,n.emissiveFactor,l.metallicFactor,l.roughnessFactor,n,d,t,r),c&&(s.shadowUniformsInitialized?g.setShadowUniformValues(a,c.getShadowUniformValues()):(c.setupShadows(o.toUnwrapped(),g,"model-tile"),s.shadowUniformsInitialized=!0)),A=v.shouldRenderCutoff||u<1||"OPAQUE"!==n.alphaMode?Qi.alphaBlended:Qi.unblended}e.uploadCommonUniforms(a,g,o.toUnwrapped(),null,v);const x=p.material.doubleSided?Xi.disabled:Xi.backCCW;if(y)m.push(n.instancedDataBuffer),g.draw(e,a.gl.TRIANGLES,u,Wi.disabled,A,x,_,t.id,p.vertexBuffer,p.indexBuffer,p.segments,t.paint,e.transform.zoom,void 0,m,n.instancedDataArray.length);else{const i=l?"u_instance":"u_normal_matrix";for(let r=0;rc[1]?a:c,s[0]=n.max[0],a=e.aC(e.eF(),s,o),l=a[1]c[1]?a:c,s[1]=n.min[1],a=e.aC(e.eF(),s,o),l=a[1]c[1]?a:c;const u=e.aA(r[0],0,1),h=100*i.pixelsPerMeter*e.aA(r[1],0,1),d=e.aA(r[2],0,1),p=e.eG(e.eF(),l,c,u),f=Math.tan(.5*i.fovX),m=-p[2]*f;if(0===h)return p[1]<-Math.abs(m)?d:1;const g=(-Math.abs(m)-p[1])/h,_=(e,t,i)=>(1-i)*e+i*t,A=e.aA(_(1,d,g),d,1);return _(1,A,e.aA((i.pitch-20)/20,0,1))}class ia{}class na{constructor(){this._storage=new Map}getLinesFromTrianglesBuffer(t,i,n){{const e=this._storage.get(i.id);if(e)return e.lastUsedFrameIdx=t,e.buf}const r=n.gl,o=r.getBufferParameter(r.ELEMENT_ARRAY_BUFFER,r.BUFFER_SIZE),s=new ArrayBuffer(o),a=new Int16Array(s);r.getBufferSubData(r.ELEMENT_ARRAY_BUFFER,0,new Int16Array(s));const l=new e.eI;for(let e=0;e30&&(i.buf.destroy(),this._storage.delete(t))}destroy(){for(const[e,t]of this._storage)t.buf.destroy(),this._storage.delete(e)}}class ra{constructor(e){this.occluderSize=30,this.depthOffset=-1e-4,e.registerParameter(this,["Occlusion"],"occluderSize",{min:1,max:100,step:1}),e.registerParameter(this,["Occlusion"],"depthOffset",{min:-.05,max:0,step:1e-5})}}const oa=e.eh([{type:"Float32",name:"a_pos_3f",components:3},{type:"Float32",name:"a_uv",components:2},{type:"Float32",name:"a_rainParticleData",components:4}]);class sa{registerParameter(){}registerButton(){}registerBinding(){}refreshUI(){}}class aa{constructor(e,t){this.revealStart=11,this.revealRange=2,e.registerParameter(this,[...t,"Reveal"],"revealStart",{min:0,max:17,step:.05}),e.registerParameter(this,[...t,"Reveal"],"revealRange",{min:.1,max:5.1,step:.05})}}const la=e.eh([{type:"Float32",name:"a_pos_2f",components:2}]);class ca{destroy(){this.vignetteVx&&this.vignetteVx.destroy(),this.vignetteIdx&&this.vignetteIdx.destroy()}draw(t,i){const n=t.getOrCreateProgram("vignette");if(!this.vignetteVx||!this.vignetteIdx){const i=new e.eJ,n=new e.b0;i.emplaceBack(-1,-1),i.emplaceBack(1,-1),i.emplaceBack(1,1),i.emplaceBack(-1,1),n.emplaceBack(0,1,2),n.emplaceBack(0,2,3),this.vignetteVx=t.context.createVertexBuffer(i,la.members),this.vignetteIdx=t.context.createIndexBuffer(n)}const r=e.bf.simpleSegment(0,0,4,6);if(this.vignetteVx&&this.vignetteIdx){t.uploadCommonUniforms(t.context,n);const e={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};n.draw(t,t.context.gl.TRIANGLES,$i.disabled,Wi.disabled,Qi.alphaBlended,Xi.disabled,e,"vignette",this.vignetteVx,this.vignetteIdx,r)}var o}}class ua{constructor(){this._accumulatedOffsetX=0,this._accumulatedOffsetY=0,this._accumulatedElevation=0}update(t,i){const n=t.getFreeCameraOptions().position,r=n.toAltitude(),o=n.toLngLat(),s=e.an(o.lng),a=e.an(o.lat),l=t.pixelsPerMeter/i,c=s*e.eL,u=e.eL*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+u,t=-this._elevationPrev+r;this._accumulatedOffsetX+=(-this._offsetXPrev+c)*l,this._accumulatedOffsetY+=e*l,this._accumulatedElevation+=t*l,this._offsetXPrev=c,this._offsetYPrev=u,this._elevationPrev=r}}getPosition(){return[this._accumulatedOffsetX,this._accumulatedOffsetY,this._accumulatedElevation]}}function ha(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 da(t){const i=e.eq(1323123451230),n=[];for(let r=0;rn)return;const r=pa(0,1,i.revealStart,i.revealStart+i.revealRange,n);if(!this.particlesVx||!this.particlesIdx)return;const o=structuredClone(this._params);let s=[-o.direction.x,o.direction.y,-100];e.aw(s,s);const a=structuredClone(this._vignetteParams);a.strength*=r,o.overrideStyleParameters||(o.intensity=t.style.rain.state.density,o.timeFactor=t.style.rain.state.intensity,o.color=structuredClone(t.style.rain.state.color),s=structuredClone(t.style.rain.state.direction),o.screenThinning.intensity=t.style.rain.state.centerThinning,o.dropletSizeX=t.style.rain.state.dropletSize[0],o.dropletSizeYScale=t.style.rain.state.dropletSize[1]/t.style.rain.state.dropletSize[0],o.distortionStrength=100*t.style.rain.state.distortionStrength,a.strength=1,a.color=structuredClone(t.style.rain.state.vignetteColor));const l=this.updateOnRender(t,o.timeFactor),c=t.context,u=c.gl,h=t.transform;this.screenTexture&&this.screenTexture.size[0]===t.width&&this.screenTexture.size[1]===t.height||(this.screenTexture=new e.T(c,{width:t.width,height:t.height,data:null},u.RGBA8)),o.distortionStrength>0&&(c.activeTexture.set(u.TEXTURE0),this.screenTexture.bind(u.LINEAR,u.CLAMP_TO_EDGE),u.copyTexSubImage2D(u.TEXTURE_2D,0,0,0,0,0,t.width,t.height));const d=t.getOrCreateProgram("rainParticle");t.uploadCommonUniforms(c,d),c.activeTexture.set(u.TEXTURE0),this.screenTexture.bind(u.LINEAR,u.CLAMP_TO_EDGE);const p=[o.color.r,o.color.g,o.color.b,o.color.a],f=(i,n)=>{const r=ha(this._movement.getPosition(),i),a=o.dropletSizeX,c=o.dropletSizeX*o.dropletSizeYScale,f=t.width/2,m=t.height/2,g=pa(0,o.screenThinning.start,0,1,o.screenThinning.intensity),_=pa(.001,o.screenThinning.range,0,1,o.screenThinning.intensity),A=pa(0,o.screenThinning.particleOffset,0,1,o.screenThinning.intensity),y=(v={modelview:l.modelviewMatrix,projection:l.projectionMatrix,time:this._accumulatedTimeFromStart,camPos:r,velocityConeAperture:o.velocityConeAperture,velocity:o.velocity,boxSize:i,rainDropletSize:[a,c],distortionStrength:o.distortionStrength,rainDirection:s,color:p,screenSize:[h.width,h.height],thinningCenterPos:[f,m],thinningShape:[g,_,Math.pow(10,o.screenThinning.fadePower)],thinningAffectedRatio:o.screenThinning.affectedRatio,thinningParticleOffset:A,shapeDirectionalPower:o.shapeDirPower,shapeNormalPower:o.shapeNormalPower,mode:n?0:1},{u_modelview:Float32Array.from(v.modelview),u_projection:Float32Array.from(v.projection),u_time:v.time,u_cam_pos:v.camPos,u_texScreen:0,u_velocityConeAperture:v.velocityConeAperture,u_velocity:v.velocity,u_boxSize:v.boxSize,u_rainDropletSize:v.rainDropletSize,u_distortionStrength:v.distortionStrength,u_rainDirection:v.rainDirection,u_color:v.color,u_screenSize:v.screenSize,u_thinningCenterPos:v.thinningCenterPos,u_thinningShape:v.thinningShape,u_thinningAffectedRatio:v.thinningAffectedRatio,u_thinningParticleOffset:v.thinningParticleOffset,u_shapeDirectionalPower:v.shapeDirectionalPower,u_shapeNormalPower:v.shapeNormalPower,u_mode:v.mode});var v;const x=Math.round(o.intensity*this.particlesCount),b=e.bf.simpleSegment(0,0,4*x,2*x);d.draw(t,u.TRIANGLES,$i.disabled,Wi.disabled,Qi.alphaBlended,Xi.disabled,y,"rain_particles",this.particlesVx,this.particlesIdx,b)};o.distortionStrength>0&&f(o.boxSize,!0),f(o.boxSize,!1),this._vignette.draw(t,a)}}const ga=e.eh([{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}]);class _a extends fa{constructor(e){super(2.25),this._params={overrideStyleParameters:!1,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._revealParams=new aa(e.tp,["Precipitation","Snow"]),this._vignetteParams={strength:.3,start:.78,range:.46,fadePower:.2,color:{r:1,g:1,b:1,a:1}},this.particlesCount=16e3}update(t){const i=t.context;if(!this.particlesVx){const t=da(this.particlesCount),n=new e.eN,r=new e.b0;let o=0;const s=e.eq(1323123451230);for(let e=0;es)return;const a=pa(0,1,o.revealStart,o.revealStart+o.revealRange,s);r.strength*=a,i.overrideStyleParameters||(i.intensity=t.style.snow.state.density,i.timeFactor=t.style.snow.state.intensity,i.color=structuredClone(t.style.snow.state.color),n=structuredClone(t.style.snow.state.direction),i.screenThinning.intensity=t.style.snow.state.centerThinning,i.billboardSize=2.79*t.style.snow.state.flakeSize,r.strength=1,r.color=structuredClone(t.style.snow.state.vignetteColor));const l=this.updateOnRender(t,i.timeFactor);if(!this.particlesVx||!this.particlesIdx)return;const c=t.context,u=c.gl,h=t.transform,d=t.getOrCreateProgram("snowParticle");t.uploadCommonUniforms(c,d),((i,r,o)=>{const s=ha(this._movement.getPosition(),i),a=h.width/2,c=h.height/2,p=pa(0,o.screenThinning.start,0,1,o.screenThinning.intensity),f=pa(.001,o.screenThinning.range,0,1,o.screenThinning.intensity),m=pa(0,o.screenThinning.particleOffset,0,1,o.screenThinning.intensity),g=(_={modelview:l.modelviewMatrix,projection:l.projectionMatrix,time:this._accumulatedTimeFromStart,camPos:s,velocityConeAperture:o.velocityConeAperture,velocity:o.velocity,horizontalOscillationRadius:o.horizontalOscillationRadius,horizontalOscillationRate:o.horizontalOscillationRate,boxSize:i,billboardSize:1*o.billboardSize,simpleShapeParameters:[o.shapeFadeStart,o.shapeFadePower],screenSize:[h.width,h.height],thinningCenterPos:[a,c],thinningShape:[p,f,Math.pow(10,o.screenThinning.fadePower)],thinningAffectedRatio:o.screenThinning.affectedRatio,thinningParticleOffset:m,color:[o.color.r,o.color.g,o.color.b,o.color.a],direction:n},{u_modelview:Float32Array.from(_.modelview),u_projection:Float32Array.from(_.projection),u_time:_.time,u_cam_pos:_.camPos,u_velocityConeAperture:_.velocityConeAperture,u_velocity:_.velocity,u_horizontalOscillationRadius:_.horizontalOscillationRadius,u_horizontalOscillationRate:_.horizontalOscillationRate,u_boxSize:_.boxSize,u_billboardSize:_.billboardSize,u_simpleShapeParameters:_.simpleShapeParameters,u_screenSize:_.screenSize,u_thinningCenterPos:_.thinningCenterPos,u_thinningShape:_.thinningShape,u_thinningAffectedRatio:_.thinningAffectedRatio,u_thinningParticleOffset:_.thinningParticleOffset,u_particleColor:_.color,u_direction:_.direction});var _;const A=Math.round(o.intensity*this.particlesCount),y=e.bf.simpleSegment(0,0,4*A,2*A);this.particlesVx&&this.particlesIdx&&d.draw(t,u.TRIANGLES,$i.disabled,Wi.disabled,Qi.alphaBlended,Xi.disabled,g,"snow_particles",this.particlesVx,this.particlesIdx,y)})(i.boxSize,0,i),this._vignette.draw(t,r)}}const Aa={symbol:function(t,i,n,r,o){if("translucent"!==t.renderPass)return;const s=Wi.disabled,a=t.colorModeForRenderPass(),l=n.layout.get("text-variable-anchor"),c=n.layout.get("text-size-scale-range"),u=e.aA(t.scaleFactor,c[0],c[1]);l&&function(t,i,n,r,o,s,a,l){const c=i.transform,u="map"===o,h="map"===s;for(const i of t){const t=r.getTile(i),o=t.getBucket(n);if(!o||!o.text||!o.text.segments.get().length)continue;const s=e.bJ(o.textSizeData,c.zoom,l),d=Kt(i,o.getProjection(),c),p=c.calculatePixelsToTileUnitsMatrix(t),f=ti(d,t.tileID.canonical,h,u,c,o.getProjection(),p),m=o.hasIconTextFit()&&o.hasIconData();s&&Wo(o,u,h,a,c,f,i,Math.pow(2,c.zoom-t.tileID.overscaledZ),s,m)}}(r,t,n,i,n.layout.get("text-rotation-alignment"),n.layout.get("text-pitch-alignment"),o,u);const h=0!==n.paint.get("icon-opacity").constantOr(1),d=0!==n.paint.get("text-opacity").constantOr(1);void 0!==n.layout.get("symbol-sort-key").constantOr(1)&&(h||d)?qo(t,i,n,r,s,a):(h&&qo(t,i,n,r,s,a,{onlyIcons:!0}),d&&qo(t,i,n,r,s,a,{onlyText:!0})),i.map.showCollisionBoxes&&(Ho(t,i,n,r,n.paint.get("text-translate"),n.paint.get("text-translate-anchor"),!0),Ho(t,i,n,r,n.paint.get("icon-translate"),n.paint.get("icon-translate-anchor"),!1))},circle:function(t,i,n,r){if("translucent"!==t.renderPass)return;const o=n.paint.get("circle-opacity"),s=n.paint.get("circle-stroke-width"),a=n.paint.get("circle-stroke-opacity"),l=void 0!==n.layout.get("circle-sort-key").constantOr(1),c=n.paint.get("circle-emissive-strength");if(0===o.constantOr(1)&&(0===s.constantOr(1)||0===a.constantOr(1)))return;const u=t.context,h=u.gl,d=t.transform,p=!(!t.terrain||!t.terrain.enabled),f=n.layout.get("circle-elevation-reference"),m=t.depthModeForSublayer(0,$i.ReadOnly),g=new $i(t.context.gl.LEQUAL,$i.ReadOnly,t.depthRangeFor3D),_="none"===f||p?m:g,A=Wi.disabled,y=t.colorModeForDrapableLayerRenderPass(c),v="globe"===d.projection.name,x=[e.aF(d.center.lng),e.aJ(d.center.lat)],b=[];for(let o=0;oe.sortKey-t.sortKey);const w={useDepthForOcclusion:d.depthOcclusionForSymbolsAndCircles};for(const e of b){const{programConfiguration:i,program:r,layoutVertexBuffer:o,dynamicBuffers:s,indexBuffer:a,uniformValues:l,tile:c}=e.state,p=e.segments;t.terrain&&t.terrain.setupElevationDraw(c,r,w),t.uploadCommonUniforms(u,r,c.tileID.toUnwrapped()),r.draw(t,h.TRIANGLES,_,A,y,Xi.disabled,l,n.id,o,a,p,n.paint,d.zoom,i,s)}},heatmap:function(t,i,n,r){if(0!==n.paint.get("heatmap-opacity"))if("offscreen"===t.renderPass){const o=t.context,s=o.gl,a=Wi.disabled,l=new Qi([s.ONE,s.ONE,s.ONE,s.ONE],e.ao.transparent,[!0,!0,!0,!0]);!function(e,t,i,n){const r=e.gl,o=t.width*n,s=t.height*n;e.activeTexture.set(r.TEXTURE1),e.viewport.set([0,0,o,s]);let a=i.heatmapFbo;if(!a||a&&(a.width!==o||a.height!==s)){a&&a.destroy();const t=r.createTexture();r.bindTexture(r.TEXTURE_2D,t),r.texParameteri(r.TEXTURE_2D,r.TEXTURE_WRAP_S,r.CLAMP_TO_EDGE),r.texParameteri(r.TEXTURE_2D,r.TEXTURE_WRAP_T,r.CLAMP_TO_EDGE),r.texParameteri(r.TEXTURE_2D,r.TEXTURE_MIN_FILTER,r.LINEAR),r.texParameteri(r.TEXTURE_2D,r.TEXTURE_MAG_FILTER,r.LINEAR),a=i.heatmapFbo=e.createFramebuffer(o,s,!0,null),function(e,t,i,n,r,o){const s=e.gl;s.texImage2D(s.TEXTURE_2D,0,e.extRenderToTextureHalfFloat?s.RGBA16F:s.RGBA,r,o,0,s.RGBA,e.extRenderToTextureHalfFloat?s.HALF_FLOAT:s.UNSIGNED_BYTE,null),n.colorAttachment.set(i)}(e,0,t,a,o,s)}else r.bindTexture(r.TEXTURE_2D,a.colorAttachment.get()),e.bindFramebuffer.set(a.framebuffer)}(o,t,n,"globe"===t.transform.projection.name?.5:.25),o.clear({color:e.ao.transparent});const c=t.transform,u="globe"===c.projection.name,h=u?["PROJECTION_GLOBE_VIEW"]:[],d=u?Xi.frontCCW:Xi.disabled,p=[e.aF(c.center.lng),e.aJ(c.center.lat)];for(let e=0;e({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,n))},line:function(t,i,n,r){if("translucent"!==t.renderPass)return;const o=n.paint.get("line-opacity"),s=n.paint.get("line-width");if(0===o.constantOr(1)||0===s.constantOr(1))return;const a=n.paint.get("line-emissive-strength"),l=n.paint.get("line-occlusion-opacity"),c=n.layout.get("line-elevation-reference"),u="meters"===n.layout.get("line-width-unit"),h="sea"===c,d=!(!t.terrain||!t.terrain.enabled),p=t.context,f=p.gl;if(n.hasElevatedBuckets&&"globe"===t.transform.projection.name)return;const m=n.layout.get("line-cross-slope"),g=void 0!==m,_=m<1,A=t.colorModeForDrapableLayerRenderPass(a),y=t.terrain&&t.terrain.renderingToTexture,v=y?1:e.o.devicePixelRatio,x=n.paint.get("line-dasharray"),b=x.constantOr(1),w=n.layout.get("line-cap"),T=x.constantOr(null),E=w.constantOr(null),C=n.paint.get("line-pattern"),S=C.constantOr(1),B=n.paint.get("line-pattern-cross-fade"),I=C.constantOr(null),M=n.paint.get("line-opacity").constantOr(1);let P=!S&&1!==M||t.depthOcclusion&&l>0&&l<1;const R=n.paint.get("line-gradient"),L=S?"linePattern":"line",F=e.e1(n);let k;if(y&&t.terrain&&t.terrain.clipOrMaskOverlapStencilType()&&(P=!1),0!==l&&t.depthOcclusion){const t=n.paint._values["line-opacity"];t&&t.value&&"constant"===t.value.kind?k=t.value:e.w(`Occlusion opacity for layer ${n.id} is supported only when line-opacity isn't data-driven.`)}"constant"!==s.value.kind&&!1===s.value.isLineProgressConstant&&F.push("VARIABLE_LINE_WIDTH");const D=(r,o,s,a,c,d)=>{for(const m of r){const r=i.getTile(m);if(S&&!r.patternsLoaded())continue;const g=r.getBucket(n);if(!g)continue;if("none"!==g.elevationType&&!c||"none"===g.elevationType&&c)continue;t.prepareDrawTile();const _=[...o],x=t.shadowRenderer,w="road"===g.elevationType&&!!x&&x.enabled;let C=[0,0,0];if(w){const e=t.style.directionalLight,i=t.style.ambientLight;e&&i&&(C=mn(t.style,e,i)),_.push("RENDER_SHADOWS","DEPTH_TEXTURE","NORMAL_OFFSET")}const F=g.programConfigurations.get(n.id);let D=!1;if(I&&r.imageAtlas){const t=e.e2.from(I),i=t.getPrimary().scaleSelf(v).toString(),n=r.imageAtlas.patternPositions.get(i),o=t.getSecondary(),s=o?r.imageAtlas.patternPositions.get(o.scaleSelf(v).toString()):null;D=!!n&&!!s,n&&F.setConstantPatternPositions(n,s)}B>0&&(D||F.getPatternTransitionVertexBuffer("line-pattern"))&&_.push("LINE_PATTERN_TRANSITION");const O=t.isTileAffectedByFog(m),z=t.getOrCreateProgram(L,{config:F,defines:_,overrideFog:O});if(!S&&T&&E&&r.lineAtlas){const e=r.lineAtlas.getDash(T,E);e&&F.setConstantPatternPositions(e)}w&&x.setupShadows(r.tileID.toUnwrapped(),z,"vector-tile");let[U,N]=n.paint.get("line-trim-offset");if("round"===E||"square"===E){const e=1;U!==N&&(0===U&&(U-=e),1===N&&(N+=e))}const V=y?m.projMatrix:null,j=u?1/g.tileToMeter/e.ay(r,1,t.transform.zoom):1,G=u?1/g.tileToMeter/e.ay(r,1,Math.floor(t.transform.zoom)):1,H=S?e.e3(t,r,n,V,v,j,G,[U,N],C,B):e.e4(t,r,n,V,g.lineClipsArray.length,v,j,G,[U,N],C);if(R){const r=g.gradients[n.id];let o=r.texture;if(n.gradientVersion!==r.version){let s=256;if(n.stepInterpolant){const n=i.getSource().maxzoom,r=m.canonical.z===n?Math.ceil(1<{null!=k&&(k.value=M*l),z.draw(t,f.TRIANGLES,s,e,A,Xi.disabled,H,n.id,g.layoutVertexBuffer,g.indexBuffer,g.segments,n.paint,t.transform.zoom,F,[g.layoutVertexBuffer2,g.patternVertexBuffer,g.zOffsetVertexBuffer]),null!=k&&(k.value=M)};if(P&&!c){const e=t.stencilModeForClipping(m).ref;0===e&&y&&p.clear({stencil:0});const i={func:f.EQUAL,mask:255};H.u_alpha_discard_threshold=.8,Q(new Wi(i,e,255,f.KEEP,f.KEEP,f.INVERT)),H.u_alpha_discard_threshold=0,Q(new Wi(i,e,255,f.KEEP,f.KEEP,f.KEEP))}else H.u_alpha_discard_threshold=P&&c&&d?.8:0,Q(c?a:t.stencilModeForClipping(m))}};let O=t.depthModeForSublayer(0,$i.ReadOnly);const z=new $i(t.depthOcclusion?f.GREATER:f.LEQUAL,$i.ReadOnly,t.depthRangeFor3D);if(n.hasNonElevatedBuckets){const i=!y&&t.terrain;0!==l&&i?e.w(`Occlusion opacity for layer ${n.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: ${n.id}.`):D(r,F,O,Wi.disabled,!1,!0)}if(n.hasElevatedBuckets){"hd-road-markup"===c?d||(O=z,F.push("ELEVATED_ROADS")):(F.push("ELEVATED"),O=z,g&&F.push(_?"CROSS_SLOPE_HORIZONTAL":"CROSS_SLOPE_VERTICAL"),h&&F.push("ELEVATION_REFERENCE_SEA"));const e=P?t.stencilModeFor3D():Wi.disabled;t.forceTerrainMode=!0,D(r,F,O,e,!0,!0),P&&D(r,F,O,e,!0,!1),t.forceTerrainMode=!1}P&&(t.resetStencilClippingMasks(),y&&p.clear({stencil:0})),0===l||t.depthOcclusion||y||t.layersWithOcclusionOpacity.push(t.currentLayer)},fill:function(t,i,n,r){const o=n.paint.get("fill-color"),s=n.paint.get("fill-opacity");if(0===s.constantOr(1))return;const a=n.paint.get("fill-emissive-strength"),l=t.colorModeForDrapableLayerRenderPass(a),c=n.paint.get("fill-pattern"),u=t.opaquePassEnabledForLayer()&&!c.constantOr(1)&&1===o.constantOr(e.ao.transparent).a&&1===s.constantOr(0)?"opaque":"translucent";let h="none";"none"!==n.layout.get("fill-elevation-reference")?h="road":0!==n.paint.get("fill-z-offset").constantOr(1)&&(h="offset");const d=!(!t.terrain||!t.terrain.enabled),p={painter:t,sourceCache:i,layer:n,coords:r,colorMode:l,elevationType:h,terrainEnabled:d,pass:u};if("shadow"!==t.renderPass)if("offset"!==h){if(Yo(p,!1),"road"===h){const e=!d&&"translucent"===t.renderPass;e&&Jo(t,i,n,r,"geometry"),Yo(p,!0,Wi.disabled),e&&function(e){const{painter:t,sourceCache:i,layer:n,coords:r,colorMode:o}=e,s=t.context.gl,a=e.painter.shadowRenderer,l=!!a&&a.enabled,c=new $i(t.context.gl.LEQUAL,$i.ReadOnly,t.depthRangeFor3D);let u=[0,0,0];if(l){const e=t.style.directionalLight,i=t.style.ambientLight;e&&i&&(u=mn(t.style,e,i))}const h=e=>{for(const h of r){const r=i.getTile(h),d=r.getBucket(n);if(!d)continue;const p=d.elevatedStructures;if(!p)continue;let f,m;if(e?(f=p.renderableBridgeSegments,m=p.bridgeProgramConfigurations.get(n.id)):(f=p.renderableTunnelSegments,m=p.tunnelProgramConfigurations.get(n.id)),!f||0===f.segments[0].primitiveLength)continue;m.updatePaintBuffers(),t.prepareDrawTile();const g=t.isTileAffectedByFog(h),_=[];l&&_.push("RENDER_SHADOWS","DEPTH_TEXTURE","NORMAL_OFFSET");const A=t.getOrCreateProgram("elevatedStructures",{config:m,overrideFog:g,defines:_}),y=t.translatePosMatrix(h.projMatrix,r,n.paint.get("fill-translate"),n.paint.get("fill-translate-anchor"));l&&a.setupShadows(r.tileID.toUnwrapped(),A,"vector-tile");const v=po(y,u);t.uploadCommonUniforms(t.context,A,h.toUnwrapped()),A.draw(t,s.TRIANGLES,c,Wi.disabled,o,Xi.backCCW,v,n.id,p.vertexBuffer,p.indexBuffer,f,n.paint,t.transform.zoom,m,[p.vertexBufferNormal])}};h(!0),h(!1)}(p)}}else Yo(p,!1,t.stencilModeFor3D());else t.shadowRenderer&&"road"===h&&!d&&function(e){const{painter:t,sourceCache:i,layer:n,coords:r}=e,o=t.context.gl,s=e.painter.shadowRenderer;for(const e of r){const r=i.getTile(e),a=r.getBucket(n);if(!a)continue;const l=a.elevatedStructures;if(!l)continue;if(!l.shadowCasterSegments||0===l.shadowCasterSegments.segments[0].primitiveLength)continue;t.prepareDrawTile();const c=a.bufferData.programConfigurations.get(n.id),u=t.isTileAffectedByFog(e),h=t.getOrCreateProgram("elevatedStructuresDepth",{config:c,overrideFog:u}),d=s.calculateShadowPassMatrixFromTile(r.tileID.toUnwrapped());t.uploadCommonUniforms(t.context,h,e.toUnwrapped());const p={u_matrix:d,u_depth_bias:0};h.draw(t,o.TRIANGLES,s.getShadowPassDepthMode(),Wi.disabled,s.getShadowPassColorMode(),Xi.disabled,p,n.id,l.vertexBuffer,l.indexBuffer,l.shadowCasterSegments,n.paint,t.transform.zoom,c)}}(p)},"fill-extrusion":function(t,i,n,r){const o=n.paint.get("fill-extrusion-opacity"),s=t.context,a=s.gl,l=t.terrain,c=l&&l.renderingToTexture;if(0===o)return;const u=t.conflationActive&&t.style.isLayerClipped(n,i.getSource()),h=t.style.order.indexOf(n.fqid);if(u&&function(e,t,i,n,r){for(const o of n){const n=t.getTile(o).getBucket(i);n&&(n.updateReplacement(o,e.replacementSource,r),n.uploadCentroid(e.context))}}(t,i,n,r,h),l||u)for(const e of r){const r=i.getTile(e).getBucket(n);r&&ns(t.context,i,e,r,n,l,u)}if("shadow"===t.renderPass&&t.shadowRenderer){const s=t.shadowRenderer;if(l&&o<.65&&n._transitionablePaint._values["fill-extrusion-opacity"].value.expression instanceof e.ad)return;const a=s.getShadowPassDepthMode(),c=s.getShadowPassColorMode();es(t,i,n,r,a,Wi.disabled,c,u)}else if("translucent"===t.renderPass){const h=!n.paint.get("fill-extrusion-pattern").constantOr(1),d=n.paint.get("fill-extrusion-color").constantOr(e.ao.white);if(!c&&0!==d.a){const e=new $i(t.context.gl.LEQUAL,$i.ReadWrite,t.depthRangeFor3D);1===o&&h?es(t,i,n,r,e,Wi.disabled,Qi.unblended,u):(es(t,i,n,r,e,Wi.disabled,Qi.disabled,u),es(t,i,n,r,e,t.stencilModeFor3D(),t.colorModeForRenderPass(),u),t.resetStencilClippingMasks())}if(t.style.enable3dLights()&&h&&(!l&&"globe"!==t.transform.projection.name||c)){const o=n.paint.get("fill-extrusion-opacity"),h=n.paint.get("fill-extrusion-ambient-occlusion-intensity"),d=n.paint.get("fill-extrusion-ambient-occlusion-ground-radius"),p=n.paint.get("fill-extrusion-flood-light-intensity"),f="none"===n.paint.get("fill-extrusion-flood-light-color-use-theme").constantOr("default"),m=n.paint.get("fill-extrusion-flood-light-color").toNonPremultipliedRenderColor(f?null:n.lut).toArray01().slice(0,3),g=h>0&&d>0,_=p>0,A=(e,t,i)=>(1-i)*e+i*t,y=new ts;y.translate=n.paint.get("fill-extrusion-translate"),y.translateAnchor=n.paint.get("fill-extrusion-translate-anchor"),y.edgeRadius=n.layout.get("fill-extrusion-edge-radius"),y.cutoffFadeRange=n.paint.get("fill-extrusion-cutoff-fade-range");const v=s=>{const l=t.depthModeForSublayer(1,$i.ReadOnly,a.LEQUAL,!0),c=n.paint.get(s?"fill-extrusion-ambient-occlusion-ground-attenuation":"fill-extrusion-flood-light-ground-attenuation"),f=A(.1,3,c),g=t._showOverdrawInspector;if(!g){const c=new Wi({func:a.ALWAYS,mask:255},255,255,a.KEEP,a.KEEP,a.REPLACE),g=new Qi([a.ONE,a.ONE,a.ONE,a.ONE],e.ao.transparent,[!1,!1,!1,!0],a.MIN);is(y,t,i,n,r,l,c,g,Xi.disabled,s,"sdf",o,h,d,p,m,f,u,!1)}{const c=g?Wi.disabled:new Wi({func:a.EQUAL,mask:255},255,255,a.KEEP,a.DECR,a.DECR),_=g?t.colorModeForRenderPass():new Qi([a.ONE_MINUS_DST_ALPHA,a.DST_ALPHA,a.ONE,a.ONE],e.ao.transparent,[!0,!0,!0,!0]);is(y,t,i,n,r,l,c,_,Xi.disabled,s,"color",o,h,d,p,m,f,u,!1)}};if(c){const c=(s,l,c)=>{const f=t.depthModeForSublayer(1,$i.ReadOnly,a.LEQUAL,!1),g=n.paint.get(s?"fill-extrusion-ambient-occlusion-ground-attenuation":"fill-extrusion-flood-light-ground-attenuation"),_=A(.1,3,g);{const c=new Qi([a.ONE,a.ONE,a.ONE,a.ONE],e.ao.transparent,[!1,!1,!1,!0]);is(y,t,i,n,r,f,Wi.disabled,c,Xi.disabled,s,"clear",o,h,d,p,m,_,u,l)}{const c=new Wi({func:a.ALWAYS,mask:255},255,255,a.KEEP,a.KEEP,a.REPLACE),g=new Qi([a.ONE,a.ONE,a.ONE,a.ONE],e.ao.transparent,[!1,!1,!1,!0],a.MIN);is(y,t,i,n,r,f,c,g,Xi.disabled,s,"sdf",o,h,d,p,m,_,u,l)}{const c=s?a.ZERO:a.ONE_MINUS_DST_ALPHA,g=new Wi({func:a.EQUAL,mask:255},255,255,a.KEEP,a.DECR,a.DECR),A=new Qi([c,a.DST_ALPHA,a.ONE_MINUS_DST_ALPHA,a.ZERO],e.ao.transparent,[!0,!0,!0,!0]);is(y,t,i,n,r,f,g,A,Xi.disabled,s,"color",o,h,d,p,m,_,u,l)}{const g=new Qi([a.ONE,a.ONE,a.ONE,s?a.ZERO:a.ONE],e.ao.transparent,[!1,!1,!1,!0],s?a.FUNC_ADD:a.MAX);is(y,t,i,n,r,f,Wi.disabled,g,Xi.disabled,s,"clear",o,h,d,p,m,_,u,l,c)}};if(g||_){let i;if(t.prepareDrawTile(),l){const t=l.drapeBufferSize[0],n=l.drapeBufferSize[1];i=l.framebufferCopyTexture,i&&(!i||i.size[0]===t&&i.size[1]===n)||(i&&i.destroy(),i=l.framebufferCopyTexture=new e.T(s,new e.q({width:t,height:n}),a.RGBA8)),i.bind(a.LINEAR,a.CLAMP_TO_EDGE),a.copyTexSubImage2D(a.TEXTURE_2D,0,0,0,0,0,t,n)}g&&c(!0,!1,i),_&&c(!1,!0,i)}}else g&&v(!0),_&&v(!1),(g||_)&&t.resetStencilClippingMasks()}}},building:function(e,t,i,n){e.currentLayer0&&o>0,c=!0;const u=i.paint.get("building-vertical-scale");if(u<=0)return;(!e.shadowRenderer||u<1)&&(c=!1);const h=e.conflationActive&&e.style.isLayerClipped(i,t.getSource()),d=e.style.order.indexOf(i.fqid);if(function(e,t,i,n,r,o){for(const s of o){const o=t.getTile(s).getBucket(i);o&&(r&&o.updateReplacement(s,e.replacementSource,n),o.uploadUpdatedIndexBuffer(e.context))}}(e,t,i,d,h,n),function(e,t,i,n){for(const r of n){const n=t.getTile(r).getBucket(i);n&&n.needsEvaluation()&&n.uploadUpdatedColorBuffer(e.context)}}(e,t,i,n),i.resetLayerRenderingStats(e),e.shadowRenderer&&(e.shadowRenderer.useNormalOffset=!0),"shadow"===e.renderPass&&e.shadowRenderer){const r=e.shadowRenderer,o=[],s=r.getShadowPassDepthMode();ls({painter:e,source:t,layer:i,coords:n,defines:o,blendMode:r.getShadowPassColorMode(),depthMode:s,opacity:a,verticalScale:u,facadeEmissiveChance:0,facadeAOIntensity:0,floodLightIntensity:0,floodLightColor:[0,0,0]})}else if("translucent"===e.renderPass){let d=["HAS_ATTRIBUTE_a_part_color_emissive","LIGHTING_3D_MODE"];c&&(d=d.concat("RENDER_SHADOWS","DEPTH_TEXTURE")),e.shadowRenderer&&e.shadowRenderer.useNormalOffset&&(d=d.concat("NORMAL_OFFSET"));const p=i.paint.get("building-facade-emissive-chance"),f=i.paint.get("building-ambient-occlusion-intensity"),m=i.paint.get("building-flood-light-intensity"),g="none"===i.paint.get("building-flood-light-color-use-theme").constantOr("default"),_=i.paint.get("building-flood-light-color").toNonPremultipliedRenderColor(g?null:i.lut).toArray01().slice(0,3),A=i.paint.get("building-flood-light-ground-attenuation"),y=m>0,v=new $i(e.context.gl.LEQUAL,$i.ReadWrite,e.depthRangeFor3D);a<1&&ls({painter:e,source:t,layer:i,coords:n,defines:d,blendMode:Qi.disabled,depthMode:v,opacity:a,verticalScale:u,facadeEmissiveChance:p,facadeAOIntensity:f,floodLightIntensity:m,floodLightColor:_,depthOnly:!0});const x=e.colorModeForRenderPass();ls({painter:e,source:t,layer:i,coords:n,defines:d,blendMode:x,depthMode:v,opacity:a,verticalScale:u,facadeEmissiveChance:p,facadeAOIntensity:f,floodLightIntensity:m,floodLightColor:_}),l&&cs(e,t,i,n,!0,a,r,o,m,_,s,h),y&&cs(e,t,i,n,!1,a,r,o,m,_,A,h)}else if("light-beam"===e.renderPass){const r=["HAS_ATTRIBUTE_a_part_color_emissive","HAS_ATTRIBUTE_a_bloom_attenuation"],o=new $i(e.context.gl.LEQUAL,$i.ReadOnly,e.depthRangeFor3D);ls({painter:e,source:t,layer:i,coords:n,defines:r,blendMode:Qi.alphaBlended,depthMode:o,opacity:a,verticalScale:u,facadeEmissiveChance:0,facadeAOIntensity:0,floodLightIntensity:0,floodLightColor:[0,0,0]})}e.shadowRenderer&&(e.shadowRenderer.useNormalOffset=!1),e.resetStencilClippingMasks()},hillshade:function(e,t,i,n){if("offscreen"!==e.renderPass&&"translucent"!==e.renderPass)return;if(e.style.disableElevatedTerrain)return;const r=e.context,o=e.terrain&&e.terrain.renderingToTexture,[s,a]="translucent"!==e.renderPass||o?[{},n]:e.stencilConfigForOverlap(n);for(const n of a){const r=t.getTile(n);if(r.needsHillshadePrepare&&"offscreen"===e.renderPass)er(e,r,i);else if("translucent"===e.renderPass){const t=e.depthModeForSublayer(0,$i.ReadOnly),a=i.paint.get("hillshade-emissive-strength"),l=e.colorModeForDrapableLayerRenderPass(a),c=o&&e.terrain?e.terrain.stencilModeForRTTOverlap(n):s[n.overscaledZ];Jn(e,n,r,i,t,c,l)}}r.viewport.set([0,0,e.width,e.height]),e.resetStencilClippingMasks()},raster:function(t,i,n,r,o,s){if("translucent"!==t.renderPass)return;if(0===n.paint.get("raster-opacity"))return;const a="globe"===t.transform.projection.name,l=0!==n.paint.get("raster-elevation"),c=l&&a;if(t.renderElevatedRasterBackface&&!c)return;const u=t.context,h=u.gl,d=i.getSource(),p=function(t,i,n,r){const o=i.paint.get("raster-color"),s="raster-array"===t.type,a=[],l=i.paint.get("raster-resampling"),c=i.paint.get("raster-color-mix");let u=i.paint.get("raster-color-range");const h=[c[0],c[1],c[2],0],d=c[3];let p="nearest"===l?r.NEAREST:r.LINEAR;if(s&&(a.push("RASTER_ARRAY"),o||a.push("RASTER_COLOR"),"linear"===l&&a.push("RASTER_ARRAY_LINEAR"),p=r.NEAREST,!u&&t.rasterLayers)){const e=t.rasterLayers.find(({id:e})=>e===i.sourceLayer);e&&e.fields&&e.fields.range&&(u=e.fields.range)}if(u=u||[0,1],o){a.push("RASTER_COLOR"),n.activeTexture.set(r.TEXTURE2),i.updateColorRamp(u);let t=i.colorRampTexture;t||(t=i.colorRampTexture=new e.T(n,i.colorRamp,r.RGBA8)),t.bind(r.LINEAR,r.CLAMP_TO_EDGE)}return{mix:h,range:u,offset:d,defines:a,resampling:p}}(d,n,u,h);if(d instanceof e.aT&&!r.length&&!a)return;const f=n.paint.get("raster-emissive-strength"),m=t.colorModeForDrapableLayerRenderPass(f),g=t.terrain&&t.terrain.renderingToTexture,_=!t.options.moving,A="nearest"===n.paint.get("raster-resampling")?h.NEAREST:h.LINEAR;if(d instanceof e.aT&&!r.length&&(d.onNorthPole||d.onSouthPole)){const e=l?t.stencilModeFor3D():Wi.disabled;return void hs(!!d.onNorthPole,null,t,i,n,f,p,Xi.disabled,e)}if(!r.length)return;const[y,v]=d instanceof e.aT||g?[{},r]:t.stencilConfigForOverlap(r),x=v[v.length-1].overscaledZ;c&&p.defines.push("PROJECTION_GLOBE_VIEW"),l&&p.defines.push("RENDER_CUTOFF");const b=(r,o,v)=>{for(const b of r){const r=b.toUnwrapped(),w=i.getTile(b);if(g&&(!w||!w.hasData()))continue;u.activeTexture.set(h.TEXTURE0);const T=ps(w,d,n,p);if(!T||!T.texture)continue;const{texture:E,mix:C,offset:S,tileSize:B,buffer:I}=T;let M,P;g?(M=$i.disabled,P=b.projMatrix):l?(M=new $i(h.LEQUAL,$i.ReadWrite,t.depthRangeFor3D),P=a?Float32Array.from(t.transform.expandedFarZProjMatrix):t.transform.calculateProjMatrix(r,_)):(M=t.depthModeForSublayer(b.overscaledZ-x,1===n.paint.get("raster-opacity")?$i.ReadWrite:$i.ReadOnly,h.LESS),P=t.transform.calculateProjMatrix(r,_));const R=t.terrain&&g?t.terrain.stencilModeForRTTOverlap(b):y[b.overscaledZ],L=s?0:n.paint.get("raster-fade-duration");w.registerFadeDuration(L);const F=i.findLoadedParent(b,0),k=$r(w,F,i,t.transform,L);let D,O;!k.isFading&&w.refreshedUponExpiration&&(w.refreshedUponExpiration=!1),t.terrain&&t.terrain.prepareDrawTile(),u.activeTexture.set(h.TEXTURE0),E.bind(A,h.CLAMP_TO_EDGE),u.activeTexture.set(h.TEXTURE1),F?(F.texture&&F.texture.bind(A,h.CLAMP_TO_EDGE),D=Math.pow(2,F.tileID.overscaledZ-w.tileID.overscaledZ),O=[w.tileID.canonical.x*D%1,w.tileID.canonical.y*D%1]):E.bind(A,h.CLAMP_TO_EDGE),"useMipmap"in E&&u.extTextureFilterAnisotropic&&t.transform.pitch>20&&h.texParameterf(h.TEXTURE_2D,u.extTextureFilterAnisotropic.TEXTURE_MAX_ANISOTROPY_EXT,u.extTextureFilterAnisotropicMax);const z=t.transform;let U;const N=l?ds(z):[0,0,0,0];let V,j,G,H,Q,$=0;if(c&&d instanceof e.aT&&d.coordinates.length>3)V=Float32Array.from(e.bj(e.dI(new e.cC(0,0,0)))),j=Float32Array.from(z.globeMatrix),G=Float32Array.from(e.dE(z)),H=[e.aF(z.center.lng),e.aJ(z.center.lat)],U=d.elevatedGlobePerspectiveTransform,Q=d.elevatedGlobeGridMatrix||new Float32Array(9);else if(c){const t=e.dF(b.canonical);$=e.dG(t.getCenter().lat),V=Float32Array.from(e.bj(e.dI(b.canonical))),j=Float32Array.from(z.globeMatrix),G=Float32Array.from(e.dE(z)),H=[e.aF(z.center.lng),e.aJ(z.center.lat)],U=[0,0],Q=Float32Array.from(e.dH(b.canonical,t,$,z.worldSize/z._pixelsPerMercatorPixel))}else U=d instanceof e.aT?d.perspectiveTransform:[0,0],V=new Float32Array(16),j=new Float32Array(9),G=new Float32Array(16),H=[0,0],Q=new Float32Array(9);const Z=To(P,V,j,G,Q,O||[0,0],e.aj(t.transform.zoom),H,N,D||1,k,n,U,l?n.paint.get("raster-elevation"):0,2,C,S,p.range,B,I,f),W=t.isTileAffectedByFog(b),q=t.getOrCreateProgram("raster",{defines:p.defines,overrideFog:W});if(t.uploadCommonUniforms(u,q,r),d instanceof e.aT){const i=d.elevatedGlobeVertexBuffer,r=d.elevatedGlobeIndexBuffer;if(g||!a)d.boundsBuffer&&d.boundsSegments&&q.draw(t,h.TRIANGLES,M,Wi.disabled,m,Xi.disabled,Z,n.id,d.boundsBuffer,t.quadTriangleIndexBuffer,d.boundsSegments);else if(i&&r){const s=z.zoom<=e.cZ?d.elevatedGlobeSegments:d.getSegmentsForLongitude(z.center.lng);s&&q.draw(t,h.TRIANGLES,M,Wi.disabled,m,o,Z,n.id,i,r,s)}}else if(c){M=new $i(h.LEQUAL,$i.ReadOnly,t.depthRangeFor3D);const e=t.globeSharedBuffers;if(e){const[i,r,s]=e.getGridBuffers($,!1);q.draw(t,h.TRIANGLES,M,v||R,t.colorModeForRenderPass(),o,Z,n.id,i,r,s)}}else{const{tileBoundsBuffer:e,tileBoundsIndexBuffer:i,tileBoundsSegments:r}=t.getTileBoundsBuffers(w);q.draw(t,h.TRIANGLES,M,R,m,Xi.disabled,Z,n.id,e,i,r)}}if(!(d instanceof e.aT)&&c)for(const e of r){const r=e.canonical.y===(1<>>16,2654435769),((e=Math.imul(e^e>>>16,2654435769))>>>0)/4294967296},r=1/1.1;for(let e=0;ee.e8[t](r));f.push(r);const m=r.canonical.x,g=r.canonical.y;for(const e of f){const o=i.getTile(l?e.wrapped():e);if(!o)continue;const a=o.rasterParticleState;if(!a)continue;const u=e.canonical.x+(1<e.tileID)),f&&(u.activeTexture.set(h.TEXTURE0),t.imageManager.bind(t.context,n.scope)),c){const i=t.getOrCreateProgram(v,{overrideFog:!1,overrideRtt:!0}),r=new Float32Array(e.bz([])),u=new e.aP(0,0,0,0,0),d=f?Lo(r,l,a,t,0,n.scope,m,c,{tileID:u,tileSize:p}):Ro(r,l,a,o.toPremultipliedRenderColor(s?null:n.lut));i.draw(t,h.TRIANGLES,A,_,y,Xi.disabled,d,n.id,t.viewportBuffer,t.quadTriangleIndexBuffer,t.viewportSegments)}else for(const e of b){const g=t.isTileAffectedByFog(e),b=t.getOrCreateProgram(v,{overrideFog:g}),w=e.toUnwrapped(),T=r?e.projMatrix:t.transform.calculateProjMatrix(w);t.prepareDrawTile();const E=i?i.getTile(e):x?x[e.key]:new It(e,p,d.zoom,t),C=f?Lo(T,l,a,t,0,n.scope,m,c,{tileID:e,tileSize:p}):Ro(T,l,a,o.toPremultipliedRenderColor(s?null:n.lut));t.uploadCommonUniforms(u,b,w);const{tileBoundsBuffer:S,tileBoundsIndexBuffer:B,tileBoundsSegments:I}=t.getTileBoundsBuffers(E);b.draw(t,h.TRIANGLES,A,_,y,Xi.disabled,C,n.id,S,B,I)}},sky:function(t,i,n){const r=t._atmosphere?e.aj(t.transform.zoom):1,o=n.paint.get("sky-opacity")*r;if(0===o)return;const s=t.context,a=n.paint.get("sky-type"),l=new $i(s.gl.LEQUAL,$i.ReadOnly,[0,1]),c=t.frameCounter/1e3%1;"atmosphere"===a?"offscreen"===t.renderPass?n.needsSkyboxCapture(t)&&(function(t,i){const n=t.context,r=n.gl;let o=i.skyboxFbo;if(!o){o=i.skyboxFbo=n.createFramebuffer(32,32,!0,null),i.skyboxGeometry=new Ps(n),i.skyboxTexture=n.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)}n.bindFramebuffer.set(o.framebuffer),n.viewport.set([0,0,32,32]);const s=i.getCenter(t,!0),a=t.getOrCreateProgram("skyboxCapture"),l=new Float64Array(16);e.bz(l),e.em(l,l,.5*-Math.PI),Rs(t,i,a,l,s,0),e.bz(l),e.em(l,l,.5*Math.PI),Rs(t,i,a,l,s,1),e.bz(l),e.cT(l,l,.5*-Math.PI),Rs(t,i,a,l,s,2),e.bz(l),e.cT(l,l,.5*Math.PI),Rs(t,i,a,l,s,3),e.bz(l),Rs(t,i,a,l,s,4),e.bz(l),e.em(l,l,Math.PI),Rs(t,i,a,l,s,5),n.viewport.set([0,0,t.width,t.height])}(t,n),n.markSkyboxValid(t)):"sky"===t.renderPass&&function(e,t,i,n,r){const o=e.context,s=o.gl,a=e.transform,l=e.getOrCreateProgram("skybox");o.activeTexture.set(s.TEXTURE0),s.bindTexture(s.TEXTURE_CUBE_MAP,t.skyboxTexture);const c=((e,t,i,n,r)=>({u_matrix:e,u_sun_direction:t,u_cubemap:0,u_opacity:n,u_temporal_offset:r}))(a.skyboxMatrix,t.getCenter(e,!1),0,n,r);e.uploadCommonUniforms(o,l),l.draw(e,s.TRIANGLES,i,Wi.disabled,e.colorModeForRenderPass(),Xi.backCW,c,"skybox",t.skyboxGeometry.vertexBuffer,t.skyboxGeometry.indexBuffer,t.skyboxGeometry.segment)}(t,n,l,o,c):"gradient"===a&&"sky"===t.renderPass&&function(t,i,n,r,o){const s=t.context,a=s.gl,l=t.transform,c=t.getOrCreateProgram("skyboxGradient");i.skyboxGeometry||(i.skyboxGeometry=new Ps(s)),s.activeTexture.set(a.TEXTURE0);let u=i.colorRampTexture;u||(u=i.colorRampTexture=new e.T(s,i.colorRamp,a.RGBA8)),u.bind(a.LINEAR,a.CLAMP_TO_EDGE);const h=((t,i,n,r,o)=>({u_matrix:t,u_color_ramp:0,u_center_direction:i,u_radius:e.an(n),u_opacity:r,u_temporal_offset:o}))(l.skyboxMatrix,i.getCenter(t,!1),i.paint.get("sky-gradient-radius"),r,o);t.uploadCommonUniforms(s,c),c.draw(t,a.TRIANGLES,n,Wi.disabled,t.colorModeForRenderPass(),Xi.backCW,h,"skyboxGradient",i.skyboxGeometry.vertexBuffer,i.skyboxGeometry.indexBuffer,i.skyboxGeometry.segment)}(t,n,l,o,c)},custom:function(t,i,n,r){const o=t.context,s=n.implementation;if(!t.transform.projection.unsupportedLayers||!t.transform.projection.unsupportedLayers.includes("custom")||t.terrain&&(t.terrain.renderingToTexture||"offscreen"===t.renderPass)&&n.isDraped(i)){if("offscreen"===t.renderPass){const i=s.prerender;if(i){if(t.setCustomLayerDefaults(),o.setColorMode(t.colorModeForRenderPass()),"globe"===t.transform.projection.name){const n=t.transform.pointMerc;i.call(s,o.gl,t.transform.customLayerMatrix(),t.transform.getProjection(),t.transform.globeToMercatorMatrix(),e.aj(t.transform.zoom),[n.x,n.y],t.transform.pixelsPerMeterRatio)}else i.call(s,o.gl,t.transform.customLayerMatrix());o.setDirty(),t.setBaseState()}}else if("translucent"===t.renderPass){if(t.terrain&&t.terrain.renderingToTexture){const e=s.renderToTile;if(e){const i=r[0].canonical,n={x:i.x+r[0].wrap*(s.wrapTileId?0:1<{u&&(u.useNormalOffset=!0,h||(u.enabled=!0))},p=i.getSource();if("light-beam"===t.renderPass&&"batched-model"!==p.type)return;if("vector"===p.type||"geojson"===p.type)return function(t,i,n,r,o){const s=t.transform,a="globe"===s.projection.name,l=s.getFreeCameraOptions().position;if(!t.modelManager)return;const c=t.modelManager;n.modelManager=c;const u=t.shadowRenderer;if(!n._unevaluatedLayout._values.hasOwnProperty("model-id"))return;const h=n._unevaluatedLayout._values["model-id"],d=Object.assign({},n.layout.get("model-id").parameters),p=t.style.order.indexOf(n.fqid);for(const f of r){const r=i.getTile(f).getBucket(n);if(!r||r.projection.name!==s.projection.name)continue;const m=r.getModelUris();if(m&&!r.modelsRequested&&(c.addModelsFromBucket(m,o),r.modelsRequested=!0),a)d.zoom=f.overscaledZ;else{const e=Ks(f,s);d.zoom=e}const g=h.possiblyEvaluate(d);if(Ws(t,r,f),qs.shadowUniformsInitialized=!1,qs.useSingleShadowCascade=!!u&&0===u.getMaxCascadeForTile(f.toUnwrapped()),"shadow"===t.renderPass&&u){if(1===t.currentShadowCascade&&r.isInsideFirstShadowMapFrustum)continue;const i=s.calculatePosMatrix(f.toUnwrapped(),s.worldSize);if(qs.tileMatrix.set(i),qs.shadowTileMatrix=Float32Array.from(u.calculateShadowPassMatrixFromMatrix(i)),qs.aabb.min=[0,0,0],qs.aabb.max[0]=qs.aabb.max[1]=e.al,qs.aabb.max[2]=0,Ys(r,qs,t,n.scope))continue}const _=1<0&&t.style.isLayerClipped(n,i.getSource())&&r.updateReplacement(f,t.replacementSource,p,o)&&(r.uploaded=!1,r.upload(t.context));let y=0;const v=new Array,x=new Array,b=new Array;for(let i in r.instancesPerModel){const s=r.instancesPerModel[i];s.features.length>0&&!a&&(i=g.evaluate(s.features[0].feature,{}));const u=c.getModel(i,o);if(u||c.hasURLBeenRequested(i)||r.modelUris.includes(i)||(r.modelUris.push(i),r.modelsRequested=!1),u&&u.uploaded)if(a){const i=e.c4([],[l.x,l.y,l.z],t.transform.worldSize);e.ev(i,i);for(let n=0;n0&&n.elevationUpdate(e.terrain,r,s,i.source),n.needsReEvaluation(e,o,i)&&n.evaluate(i))}})(t,i,n,r),function(){let c,h,E;b?(c=r.length-1,h=-1,E=-1):(c=0,h=r.length,E=1);const C=new Float64Array(16),S=e.cz(),B=new e.P(0,0);for(let I=c;I!==h;I+=E){const c=r[I],h=i.getTile(c).getBucket(n);if(!h||!h.uploaded)continue;let E=!1;l&&(E=0===l.getMaxCascadeForTile(c.toUnwrapped()));const M=s.calculatePosMatrix(c.toUnwrapped(),s.worldSize),P=h.modelTraits;!y&&b&&(e.bk(C,M),e.af(S,u,C),B.x=S[0],B.y=S[1]);const R=[];h.setFilter(n.filter);for(const i of h.getNodesInfo()){if(i.hiddenByReplacement)continue;if(!i.node.meshes)continue;const n=i.node;let r=0;t.terrain&&n.elevation&&(r=n.elevation*t.terrain.exaggeration());const o=(()=>{const t=i.aabb;return A.min=[...t.min],A.max=[...t.max],A.min[2]+=r,A.max[2]+=r,e.af(A.min,A.min,M),e.af(A.max,A.max,M),A})(),a=i.evaluatedScale;if(a[0]<=1&&a[1]<=1&&a[2]<=1&&0===o.intersects(v))continue;if(!y&&b){const t=1/6;i.cameraCollisionOpacity=u[0]>o.min[0]&&u[0]o.min[1]&&u[1]!b||1===e.opacity&&1===t.opacity?e.deptht.depth?-1:1);for(const i of R){const r=i.nodeInfo,c=r.node;let u=e.aB([],f,i.tileModelMatrix);e.aB(u,d,u);const h=e.bk([],u);e.ef(h,h),e.cR(h,h,Js),u=e.aB(u,u,c.globalMatrix);const p="light-beam"===t.renderPass,m="none"===n.paint.get("model-color-use-theme").constantOr("default"),A=P&e.eH.HasMapboxMeshFeatures,v=A?0:r.evaluatedRMEA[0][2];for(let e=0;e=Ve||r>=Ve}}const S=d.material;let B;S.occlusionTexture&&S.occlusionTexture.offsetScale&&(B=S.occlusionTexture.offsetScale,b.defines.push("OCCLUSION_TEXTURE_TRANSFORM"));const I=t.getOrCreateProgram("model",b);!y&&l&&l.setupShadowsFromMatrix(i.tileModelMatrix,I,l.useNormalOffset),t.uploadCommonUniforms(o,I,null,C);const M=S.pbrMetallicRoughness;M.metallicFactor=.9,M.roughnessFactor=.5;const P=ko(new Float32Array(x),new Float32Array(u),new Float32Array(h),new Float32Array(c.globalMatrix),t,i.opacity,M.baseColorFactor,S.emissiveFactor,M.metallicFactor,M.roughnessFactor,S,v,n,[0,0,0],B);!f&&(r.hasTranslucentParts||i.opacity<1)&&I.draw(t,o.gl.TRIANGLES,g,Wi.disabled,Qi.disabled,Xi.backCCW,P,n.id,d.vertexBuffer,d.indexBuffer,d.segments,n.paint,t.transform.zoom,void 0,w),I.draw(t,o.gl.TRIANGLES,f?_:g,Wi.disabled,f||i.opacity<1||r.hasTranslucentParts?Qi.alphaBlended:Qi.unblended,Xi.backCCW,P,n.id,d.vertexBuffer,d.indexBuffer,d.segments,n.paint,t.transform.zoom,void 0,w)}}}}()}(t,i,n,r),void d();if("model"!==p.type)return;const f=p.getModels(),m=[],g=t.transform.getFreeCameraOptions().position,_=e.c4([],[g.x,g.y,g.z],t.transform.worldSize);e.ev(_,_);const A=[],y=[];let v=0;for(const r of f){const o=i.getFeatureState("",r.id),s={type:"Unknown",id:r.id,properties:r.featureProperties},c=n.paint.get("model-rotation").evaluate(s,o),u=n.paint.get("model-scale").evaluate(s,o),h=n.paint.get("model-translation").evaluate(s,o);Qs(n,r.id,o,r.featureProperties,r.nodeOverrideNames,r.nodeOverrides),$s(n,r.id,o,r.featureProperties,r.materialOverrideNames,r.materialOverrides),r.nodeOverrides.size>0&&r.computeBoundsAndApplyParent(),r.computeModelMatrix(t,c,u,h,l,a,!1);const d=e.bz([]),p=e.ee(r.position.lat,t.transform.zoom),f=e.bp([],[1,1,1/p]);e.bq(d,d,_),m.push({zScaleMatrix:f,negCameraPosMatrix:d});for(const e of r.nodes)Gs(t,e,r.matrix,t.transform.expandedFarZProjMatrix,v,A,y,r.materialOverrides);v++}if(A.sort((e,t)=>t.depth-e.depth),"shadow"!==t.renderPass)Zs(t,n,o,A,y,m),d();else{for(const e of y)Hs(e.mesh,e.nodeModelMatrix,t,n);for(const e of A)Hs(e.mesh,e.nodeModelMatrix,t,n);d()}}},ya={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 n of i){const i=t.getTile(n).getBucket(e);if(i&&("none"!==i.elevationType?e.hasElevatedBuckets=!0:e.hasNonElevatedBuckets=!0,e.hasElevatedBuckets&&e.hasNonElevatedBuckets))break}}}else e.hasNonElevatedBuckets=!0},model:function(e,t,i){const n=t.getSource();if(!n.loaded())return;if("vector"===n.type||"geojson"===n.type){const t=js(n,e,i.style._importedAsBasemap);return void(i.modelManager&&i.modelManager.upload(i,t))}if("batched-model"===n.type)return;if("model"!==n.type)return;const r=n.getModels();for(const e of r)e.upload(i.context)},raster:function(e,t,i){const n=t.getSource();if(!(n instanceof ht&&n.loaded()))return;const r=e.sourceLayer||n.rasterLayerIds&&n.rasterLayerIds[0];if(!r)return;const o=e.paint.get("raster-array-band")||n.getInitialBand(r);if(null==o)return;const s=t.getIds().map(e=>t.getTileByID(e));for(const t of s)t.updateNeeded(e.id,o)&&n.prepareTile(t,r,e.id,o)},"raster-particle":function(e,t,i){const n=t.getSource();if(!(n instanceof ht&&n.loaded()))return;const r=e.sourceLayer||n.rasterLayerIds&&n.rasterLayerIds[0];if(!r)return;const o=e.paint.get("raster-particle-array-band")||n.getInitialBand(r);if(null==o)return;const s=t.getIds().map(e=>t.getTileByID(e));for(const t of s)t.updateNeeded(e.id,o)&&n.prepareTile(t,r,e.id,o)}},va={fill:Jo},xa={fill:function(e,t,i,n){if(!i.layout||"none"===i.layout.get("fill-elevation-reference")||0===i.paint.get("fill-opacity").constantOr(1))return;const r=e.context.gl,o=new $i(r.LEQUAL,$i.ReadOnly,e.depthRangeFor3D),s=new Wi({func:r.ALWAYS,mask:255},255,255,r.KEEP,r.KEEP,r.REPLACE),a=e.transform.getFreeCameraOptions().position,l=e.getOrCreateProgram("elevatedStructuresDepthReconstruct");for(const c of n){const n=t.getTile(c),u=n.getBucket(i);if(!u)continue;const h=u.elevatedStructures;if(!h||0===h.depthSegments.segments[0].primitiveLength)continue;const d=Xo(c.toUnwrapped(),a),p=e.translatePosMatrix(c.projMatrix,n,i.paint.get("fill-translate"),i.paint.get("fill-translate-anchor")),f=fo(p,d,0,1,0);l.draw(e,r.TRIANGLES,o,s,Qi.disabled,Xi.disabled,f,i.id,h.vertexBuffer,h.indexBuffer,h.depthSegments,i.paint,e.transform.zoom)}}};class ba{constructor(t,i,n,r,o,s){this.context=new jo(t,i),this.transform=n,this._tileTextures={},this.frameCopies=[],this.loadTimeStamps=[],this.tp=o,this._timeStamp=e.o.now(),this._averageFPS=0,this._fpsHistory=[],this._dt=0,this._debugParams={forceEnablePrecipitation:!1,showTerrainProxyTiles:!1,fpsWindow:30,continousRedraw:!1,enabledLayers:{}};const a=["fill","line","symbol","circle","heatmap","fill-extrusion","building","raster","raster-particle","hillshade","model","background","sky"];for(const e of a)this._debugParams.enabledLayers[e]=!0;o.registerParameter(this._debugParams,["Terrain"],"showTerrainProxyTiles",{},()=>{this.style.map.triggerRepaint()}),o.registerParameter(this._debugParams,["Precipitation"],"forceEnablePrecipitation"),o.registerParameter(this._debugParams,["FPS"],"fpsWindow",{min:1,max:100,step:1}),o.registerBinding(this._debugParams,["FPS"],"continousRedraw",{readonly:!0,label:"continuous redraw"}),o.registerBinding(this,["FPS"],"_averageFPS",{readonly:!0,label:"value"}),o.registerBinding(this,["FPS"],"_averageFPS",{readonly:!0,label:"graph",view:"graph",min:0,max:200});for(const e of a)o.registerParameter(this._debugParams.enabledLayers,["Debug","Layers"],e);this.occlusionParams=new ra(o),this.setup(),this.numSublayers=Lt.maxUnderzooming+Lt.maxOverzooming+1,this.depthEpsilon=1/Math.pow(2,16),this.deferredRenderGpuTimeQueries=[],this.gpuTimers={},this.frameCounter=0,this._backgroundTiles={},this.conflationActive=!1,this.replacementSource=new e.eO,this.longestCutoffRange=0,this.minCutoffZoom=0,this._fogVisible=!1,this._cachedTileFogOpacities={},this._shadowRenderer=new dn(this),this._wireframeDebugCache=new na,this.renderDefaultNorthPole=!0,this.renderDefaultSouthPole=!0,this.layersWithOcclusionOpacity=[];const l=new e.q({width:1,height:1},Uint8Array.of(0,0,0,0));this.emptyDepthTexture=new e.T(this.context,l,t.RGBA8),this._clippingActiveLastFrame=!1,this.scaleFactor=r,this.worldview=s}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 Kr(this,e));const n=this._terrain;this.transform.elevation=i?n:null,n.update(e,this.transform,t),this.transform.elevation&&!n.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,n]=t.getFovAdjustedRange(this.transform._fov);if(i>n)return void(this.transform.fogCullDistSq=null);const r=i+.78*(n-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 Kr(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.o.devicePixelRatio,this.height=i*e.o.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.al,0),i.emplaceBack(0,e.al),i.emplaceBack(e.al,e.al),this.tileExtentBuffer=t.createVertexBuffer(i,e.be.members),this.tileExtentSegments=e.bf.simpleSegment(0,0,4,2);const n=new e.bc;n.emplaceBack(0,0),n.emplaceBack(e.al,0),n.emplaceBack(0,e.al),n.emplaceBack(e.al,e.al),this.debugBuffer=t.createVertexBuffer(n,e.be.members),this.debugSegments=e.bf.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.bf.simpleSegment(0,0,4,2);const o=new e.a$;o.emplaceBack(0,0,0,0),o.emplaceBack(e.al,0,e.al,0),o.emplaceBack(0,e.al,0,e.al),o.emplaceBack(e.al,e.al,e.al,e.al),this.mercatorBoundsBuffer=t.createVertexBuffer(o,e.bh.members),this.mercatorBoundsSegments=e.bf.simpleSegment(0,0,4,2);const s=new e.b0;s.emplaceBack(0,1,2),s.emplaceBack(2,1,3),this.quadTriangleIndexBuffer=t.createIndexBuffer(s);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.q({width:1,height:1},Uint8Array.of(0,0,0,0)),t.gl.RGBA8),this.identityMat=e.bB();const l=this.context.gl;this.stencilClearMode=new Wi({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 e=this.context.gl;this.nextStencilID=1,this.currentStencilSource=void 0,this._tileClippingMaskIDs={},this.getOrCreateProgram("clippingMask").draw(this,e.TRIANGLES,$i.disabled,this.stencilClearMode,Qi.disabled,Xi.disabled,Qr(this.identityMat),"$clipping",this.viewportBuffer,this.quadTriangleIndexBuffer,this.viewportSegments)}resetStencilClippingMasks(){this.terrain||(this.currentStencilSource=void 0,this._tileClippingMaskIDs={})}_renderTileClippingMasks(e,t,i){if(!t||this.currentStencilSource===t.id||!e.isTileClipped()||!i||0===i.length)return;if(this._tileClippingMaskIDs&&!this.terrain){let e=!1;for(const t of i)if(void 0===this._tileClippingMaskIDs[t.key]){e=!0;break}if(!e)return}this.currentStencilSource=t.id;const n=this.context,r=n.gl;this.nextStencilID+i.length>256&&this.clearStencil(),n.setColorMode(Qi.disabled),n.setDepthMode($i.disabled);const o=this.getOrCreateProgram("clippingMask");this._tileClippingMaskIDs={};for(const e of i){const i=t.getTile(e),n=this._tileClippingMaskIDs[e.key]=this.nextStencilID++,{tileBoundsBuffer:s,tileBoundsIndexBuffer:a,tileBoundsSegments:l}=this.getTileBoundsBuffers(i);o.draw(this,r.TRIANGLES,$i.disabled,new Wi({func:r.ALWAYS,mask:0},n,255,r.KEEP,r.KEEP,r.REPLACE),Qi.disabled,Xi.disabled,Qr(e.projMatrix),"$clipping",s,a,l)}}stencilModeFor3D(){this.currentStencilSource=void 0,this.nextStencilID+1>256&&this.clearStencil();const e=this.nextStencilID++,t=this.context.gl;return new Wi({func:t.NOTEQUAL,mask:255},e,255,t.KEEP,t.KEEP,t.REPLACE)}stencilModeForClipping(e){if(this.terrain)return this.terrain.stencilModeForRTTOverlap(e);const t=this.context.gl;return new Wi({func:t.EQUAL,mask:255},this._tileClippingMaskIDs[e.key],0,t.KEEP,t.KEEP,t.REPLACE)}stencilConfigForOverlap(e){const t=this.context.gl,i=e.sort((e,t)=>t.overscaledZ-e.overscaledZ),n=i[i.length-1].overscaledZ,r=i[0].overscaledZ-n+1;if(r>1){this.currentStencilSource=void 0,this.nextStencilID+r>256&&this.clearStencil();const e={};for(let i=0;ithis.style&&this.style.enable3dLights()&&this.terrain&&this.terrain.renderingToTexture)()&&"translucent"===this.renderPass?new Qi([i.ONE,i.ONE_MINUS_SRC_ALPHA,i.CONSTANT_ALPHA,i.ONE_MINUS_SRC_ALPHA],new e.ao(0,0,0,void 0===t?0:t),[!0,!0,!0,!0]):this.colorModeForRenderPass()}depthModeForSublayer(e,t,i,n=!1){if(this.depthOcclusion)return new $i(this.context.gl.GREATER,$i.ReadOnly,this.depthRangeFor3D);if(!this.opaquePassEnabledForLayer()&&!n)return $i.disabled;const r=1-((1+this.currentLayer)*this.numSublayers+e)*this.depthEpsilon;return new $i(i||this.context.gl.LEQUAL,t,[r,r])}opaquePassEnabledForLayer(){return this.currentLayerthis._debugParams.fpsWindow&&this._fpsHistory.splice(0,this._fpsHistory.length-this._debugParams.fpsWindow),this._averageFPS=Math.round(this._fpsHistory.reduce((e,t)=>e+t/this._fpsHistory.length,0))}render(t,i){const n=e.o.now();this._dt=n-this._timeStamp,this._timeStamp=n,this._wireframeDebugCache.update(this.frameCounter),this._debugParams.continousRedraw=t.map.repaint,this.style=t,this.options=i;const r=this.style._mergedLayers,o=!(!this.terrain||!this.terrain.enabled),s=()=>this.style._getOrder(o).filter(e=>{const t=r[e];return!(t.type in this._debugParams.enabledLayers)||this._debugParams.enabledLayers[t.type]});let a=s(),l=!1,c=!1,u=null;for(const e of a){const t=r[e];"circle"===t.type?l=!0:"building"===t.type?u=t:"symbol"===t.type&&(t.hasOcclusionOpacityProperties?c=!0:l=!0)}let h=a.map(e=>r[e]);const d=this.style._mergedSourceCaches;this.imageManager=t.imageManager,this.modelManager=t.modelManager,this.symbolFadeChange=t.placement.symbolFadeChange(e.o.now()),this.imageManager.beginFrame();let p=0,f=!1;for(const e in d){const t=d[e];t.used&&(t.prepare(this.context),t.getSource().usedInConflation&&++p)}let m=!1;for(const e of h)e.isHidden(this.transform.zoom)||("clip"===e.type&&(m=!0),this.prepareLayer(e));const g={},_={},A={},y={},v={};for(const e in d){const t=d[e];g[e]=t.getVisibleCoordinates(),_[e]=g[e].slice().reverse(),A[e]=t.getVisibleCoordinates(!0).reverse(),y[e]=t.getShadowCasterCoordinates(),v[e]=t.sortCoordinatesByDistance(g[e])}const x=e=>{const t=this.style.getLayerSourceCache(e);return t&&t.used?t.getSource():null};if(p||m||this._clippingActiveLastFrame){const t=[],i=[];let n=0;for(const e of h)this.isSourceForClippingOrConflation(e,x(e))&&(t.push(e),i.push(n)),n++;if(t&&(m||t.length>1)||this._clippingActiveLastFrame){m=!1;const n=[];for(let r=0;r0){const e=x(t);e&&(this.minCutoffZoom=Math.max(e.minzoom,this.minCutoffZoom)),t.minzoom&&(this.minCutoffZoom=Math.max(t.minzoom,this.minCutoffZoom))}t.is3D(o)&&(this.opaquePassCutoff===1/0&&(this.opaquePassCutoff=e),this._lastOcclusionLayer=e)}const b=this.style&&this.style.fog;b?(this._fogVisible=0!==b.getOpacity(this.transform.pitch),this._fogVisible&&"globe"!==this.transform.projection.name&&(this._fogVisible=b.isVisibleOnFrustum(this.transform.cameraFrustum))):this._fogVisible=!1,this._cachedTileFogOpacities={},this.terrain&&(this.terrain.updateTileBinding(A),this.opaquePassCutoff=0,a=s(),h=a.map(e=>r[e]));const w=this._shadowRenderer;if(w){w.updateShadowParameters(this.transform,this.style.directionalLight);for(const e in d)for(const t of g[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.eQ(this.context)),this.style.fog&&this.transform.projection.supportsFog?(this._atmosphere||(this._atmosphere=new Os(this)),this._atmosphere.update(this)):this._atmosphere&&(this._atmosphere.destroy(),this._atmosphere=void 0);const T=this._debugParams.forceEnablePrecipitation||!(!this.style||!this.style.snow),E=this._debugParams.forceEnablePrecipitation||!(!this.style||!this.style.rain);if(T&&!this._snow&&(this._snow=new _a(this)),!T&&this._snow&&(this._snow.destroy(),delete this._snow),E&&!this._rain&&(this._rain=new ma(this)),!E&&this._rain&&(this._rain.destroy(),delete this._rain),this._snow&&this._snow.update(this),this._rain&&this._rain.update(this),u){this.buildingTileBorderManager||(this.buildingTileBorderManager=new zs);const e=this.style.getLayerSourceCache(u);this.buildingTileBorderManager.updateBorders(e,u)}if(!j.has(this.context.gl))return;this.renderPass="offscreen";for(const e of h){const i=t.getLayerSourceCache(e);if(!e.hasOffscreenPass()||e.isHidden(this.transform.zoom))continue;const n=i?_[i.id]:void 0;("custom"===e.type||"raster"===e.type||"raster-particle"===e.type||e.isSky()||n&&n.length)&&this.renderLayer(this,i,e,n)}this.depthRangeFor3D=[0,1-(h.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(),S=(()=>{if(i.showOverdrawInspector)return e.ao.black;const t=this.style.fog;if(t&&this.transform.projection.supportsFog){const i=this.style.getLut(t.scope);if(!C){const n="none"===t.properties.get("color-use-theme"),r=t.properties.get("color").toNonPremultipliedRenderColor(n?null:i).toArray01();return new e.ao(...r)}if(C){const n="none"===t.properties.get("space-color-use-theme"),r=t.properties.get("space-color").toNonPremultipliedRenderColor(n?null:i).toArray01();return new e.ao(...r)}}return e.ao.transparent})();if(this.context.clear({color:S,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=a.length-1;this.currentLayer>=0;this.currentLayer--){const e=h[this.currentLayer],i=t.getLayerSourceCache(e);if(e.isSky())continue;const n=i?(e.is3D(o)?v:_)[i.id]:void 0;this._renderTileClippingMasks(e,i,n),this.renderLayer(this,i,e,n)}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.aj(this.transform.zoom)>0)&&("globe"===this.transform.projection.name||this.transform.isHorizonVisible()))for(this.currentLayer=0;this.currentLayer{for(this.currentLayer=0;this.currentLayer0&&e.hasShadowPass()&&0==--I){{this.clearStencil(),this.resetStencilClippingMasks();const e=this.currentLayer;for(this.currentLayer=0;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=h[this.currentLayer],n=t.getLayerSourceCache(i),r=n?_[n.id]:void 0;this.terrain||this._renderTileClippingMasks(i,n,n?g[n.id]:void 0),this.renderLayer(this,n,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;h.forEach(e=>{const n=t.getLayerSourceCache(e);n&&!e.isHidden(this.transform.zoom)&&n.getVisibleCoordinates().length&&(!i||i.getSource().maxzoom0?t.pop():null}terrainRenderModeElevated(){return this.style&&!!this.style.getTerrain()&&!!this.terrain&&!this.terrain.renderingToTexture||this.forceTerrainMode}linearFloatFilteringSupported(){return null!=this.context.extTextureFloatLinear}currentGlobalDefines(e,t,i){const n=void 0===i?this.terrain&&this.terrain.renderingToTexture:i,r=[];return this.style&&this.style.enable3dLights()&&("globeRaster"===e||"terrainRaster"===e?(r.push("LIGHTING_3D_MODE"),r.push("LIGHTING_3D_ALPHA_EMISSIVENESS")):n||r.push("LIGHTING_3D_MODE")),"shadow"===this.renderPass&&(this._shadowMapDebug||r.push("DEPTH_TEXTURE")),this.terrainRenderModeElevated()&&(r.push("TERRAIN"),this.linearFloatFilteringSupported()&&r.push("TERRAIN_DEM_FLOAT_FORMAT")),"globe"===this.transform.projection.name&&r.push("GLOBE"),!this._fogVisible||n||void 0!==t&&!t||r.push("FOG","FOG_DITHERING"),n&&r.push("RENDER_TO_TEXTURE"),this._showOverdrawInspector&&r.push("OVERDRAW_INSPECTOR"),r}getOrCreateProgram(e,t){this.cache=this.cache||{};const i=t&&t.defines||[],n=t&&t.config,r=this.currentGlobalDefines(e,t&&t.overrideFog,t&&t.overrideRtt).concat(i),o=eo.cacheKey(Zn[e],e,r,n);return this.cache[o]||(this.cache[o]=new eo(this.context,e,Zn[e],n,Oo[e],r)),this.cache[o]}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()}prepareDrawTile(){this.terrain&&this.terrain.prepareDrawTile()}uploadCommonLightUniforms(t,i){if(this.style.enable3dLights()){const n=this.style.directionalLight,r=this.style.ambientLight;if(n&&r){const o=((t,i,n)=>{const r=t.properties.get("direction"),o="none"===t.properties.get("color-use-theme"),s=t.properties.get("color").toNonPremultipliedRenderColor(o?null:n.getLut(t.scope)).toArray01(),a=t.properties.get("intensity"),l="none"===i.properties.get("color-use-theme"),c=i.properties.get("color").toNonPremultipliedRenderColor(l?null:n.getLut(i.scope)).toArray01(),u=i.properties.get("intensity"),h=[r.x,r.y,r.z],d=e.dM(c,u),p=e.dM(s,a);return{u_lighting_ambient_color:d,u_lighting_directional_dir:h,u_lighting_directional_color:p,u_ground_radiance:Xr(h,p,d)}})(n,r,this.style);i.setLightsUniformValues(t,o)}}}uploadCommonUniforms(t,i,n,r,o){if(this.uploadCommonLightUniforms(t,i),this.terrain&&this.terrain.renderingToTexture)return;const s=this.style.fog;if(s){const o=s.getOpacity(this.transform.pitch),a=((t,i,n,r,o,s,a,l,c,u,h,d)=>{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 g=t.frameCounter/1e3%1,[_,A]=i.properties.get("vertical-range");return{u_fog_matrix:n?p.calculateFogTileMatrix(n):d||t.identityMat,u_fog_range:i.getFovAdjustedRange(p._fov),u_fog_color:m,u_fog_horizon_blend:i.properties.get("horizon-blend"),u_fog_vertical_limit:[Math.min(_,A),A],u_fog_temporal_offset:g,u_frustum_tl:o,u_frustum_tr:s,u_frustum_br:a,u_frustum_bl:l,u_globe_pos:c,u_globe_radius:u,u_viewport:h,u_globe_transition:e.aj(p.zoom),u_is_globe:+("globe"===p.projection.name)}})(this,s,n,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.o.devicePixelRatio,this.transform.height*e.o.devicePixelRatio],r);i.setFogUniformValues(t,a)}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 n of i)t[n.key]=e[n.key]||new It(n,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(e){if(!this.style||!this.style.fog)return!1;if("globe"===this.transform.projection.name)return!0;let t=this._cachedTileFogOpacities[e.key];return t||(this._cachedTileFogOpacities[e.key]=t=this.style.fog.getOpacityForTile(e)),t[0]>=Ve||t[1]>=Ve}setupDepthForOcclusion(e,t,i){const n=this.context,r=n.gl,o=!!i;var s;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}),n.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/((s=this.depthRangeFor3D)[1]-s[0]),-1-2*s[0]/(s[1]-s[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),n.activeTexture.set(r.TEXTURE0),o||t.setTerrainUniformValues(n,i)}}function wa(e,t){let i=!1,n=null;const r=()=>{n=null,i&&(e(),n=setTimeout(r,t),i=!1)};return()=>(i=!0,n||r(),n)}class Ta{constructor(t){this._hashName=t&&encodeURIComponent(t),e.aX(["_getCurrentHash","_onHashChange","_updateHash"],this),this._updateHash=wa(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=Ea(e);if(this._hashName){const e=this._hashName;let i=!1;const n=location.hash.slice(1).split("&").map(n=>{const r=n.split("=")[0];return r===e?(i=!0,`${r}=${t}`):n}).filter(e=>e);return i||n.push(`${e}=${t}`),`#${n.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(/(#.+)?$/,this.getHashString()))}}function Ea(e,t){const i=e.getCenter(),n=Math.round(100*e.getZoom())/100,r=Math.ceil((n*Math.LN2+Math.log(512/360/.5))/Math.LN10),o=Math.pow(10,r),s=Math.round(i.lng*o)/o,a=Math.round(i.lat*o)/o,l=e.getBearing(),c=e.getPitch();let u=t?`/${s}/${a}/${n}`:`${n}/${a}/${s}`;return(l||c)&&(u+="/"+Math.round(10*l)/10),c&&(u+=`/${Math.round(c)}`),u}const Ca={linearity:.3,easing:e.eS(0,0,.3,1)},Sa=Object.assign({deceleration:2500,maxSpeed:1400},Ca),Ba=Object.assign({deceleration:20,maxSpeed:1400},Ca),Ia=Object.assign({deceleration:1e3,maxSpeed:360},Ca),Ma=Object.assign({deceleration:1e3,maxSpeed:90},Ca);class Pa{constructor(e){this._map=e,this.clear()}clear(){this._inertiaBuffer=[]}record(t){this._drainInertiaBuffer(),this._inertiaBuffer.push({time:e.o.now(),settings:t})}_drainInertiaBuffer(){const t=this._inertiaBuffer,i=e.o.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 n=this._inertiaBuffer[this._inertiaBuffer.length-1].time-this._inertiaBuffer[0].time,r={};if(i.pan.mag()){const e=La(i.pan.mag(),n,Object.assign({},Sa,t||{}));r.offset=i.pan.mult(e.amount/i.pan.mag()),r.center=this._map.transform.center,Ra(r,e)}if(i.zoom){const e=La(i.zoom,n,Ba);r.zoom=this._map.transform.zoom+e.amount,Ra(r,e)}if(i.bearing){const t=La(i.bearing,n,Ia);r.bearing=this._map.transform.bearing+e.aA(t.amount,-179,179),Ra(r,t)}if(i.pitch){const e=La(i.pitch,n,Ma);r.pitch=this._map.transform.pitch+e.amount,Ra(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 Ra(e,t){(!e.duration||e.durationi.unproject(e)),a=o.reduce((e,t,i,n)=>e.add(t.div(n.length)),new e.P(0,0));super(t,{points:o,point:a,lngLats:s,lngLat:i.unproject(a),originalEvent:n}),this._defaultPrevented=!1}}class Da extends e.z{preventDefault(){this._defaultPrevented=!0}get defaultPrevented(){return this._defaultPrevented}constructor(e,t){super("wheel",{originalEvent:t}),this._defaultPrevented=!1}}class Oa{constructor(e,t){this._map=e,this._clickTolerance=t.clickTolerance}reset(){this._mousedownPos=void 0}wheel(e){return this._firePreventable(new Da(this._map,e))}mousedown(e,t){return this._mousedownPos=t,this._firePreventable(new Fa(e.type,this._map,e))}mouseup(e){this._map.fire(new Fa(e.type,this._map,e))}preclick(e){const t=new MouseEvent("preclick",e);this._map.fire(new Fa(t.type,this._map,t))}click(e,t){this._mousedownPos&&this._mousedownPos.dist(t)>=this._clickTolerance||(this.preclick(e),this._map.fire(new Fa(e.type,this._map,e)))}dblclick(e){return this._firePreventable(new Fa(e.type,this._map,e))}mouseover(e){this._map.fire(new Fa(e.type,this._map,e))}mouseout(e){this._map.fire(new Fa(e.type,this._map,e))}touchstart(e){return this._firePreventable(new ka(e.type,this._map,e))}touchmove(e){this._map.fire(new ka(e.type,this._map,e))}touchend(e){this._map.fire(new ka(e.type,this._map,e))}touchcancel(e){this._map.fire(new ka(e.type,this._map,e))}_firePreventable(e){if(this._map.fire(e),e.defaultPrevented)return{}}isEnabled(){return!0}isActive(){return!1}enable(){}disable(){}}class za{constructor(e){this._map=e}reset(){this._delayContextMenu=!1,this._contextMenuEvent=void 0}mousemove(e){this._map.fire(new Fa(e.type,this._map,e))}mousedown(){this._delayContextMenu=!0}mouseup(){this._delayContextMenu=!1,this._contextMenuEvent&&(this._map.fire(new Fa("contextmenu",this._map,this._contextMenuEvent)),delete this._contextMenuEvent)}contextmenu(e){this._delayContextMenu?this._contextMenuEvent=e:this._map.fire(new Fa(e.type,this._map,e)),this._map.listens("contextmenu")&&e.preventDefault()}isEnabled(){return!0}isActive(){return!1}enable(){}disable(){}}class Ua{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&&(p(),this._startPos=this._lastPos=t,this._active=!0)}mousemoveWindow(e,t){if(!this._active)return;const i=t,n=this._startPos,r=this._lastPos;if(!n||!r||r.equals(i)||!this._box&&i.dist(n){this._box&&(this._box.style.transform=`translate(${o}px,${a}px)`,this._box.style.width=s-o+"px",this._box.style.height=c-a+"px")})}mouseupWindow(t,i){if(!this._active)return;const n=this._startPos,r=i;if(n&&0===t.button){if(this.reset(),g(),n.x!==r.x||n.y!==r.y)return this._map.fire(new e.z("boxzoomend",{originalEvent:t})),{cameraAnimation:e=>e.fitScreenCoordinates(n,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),f(),delete this._startPos,delete this._lastPos}_fireEvent(t,i){return this._map.fire(new e.z(t,{originalEvent:i}))}}function Na(e,t){const i={};for(let n=0;nthis.numTouches)&&(this.aborted=!0),this.aborted||(0===this.startTime&&(this.startTime=t.timeStamp),n.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=Na(n,i)))}touchmove(e,t,i){if(this.aborted||!this.centroid)return;const n=Na(i,t);for(const e in this.touches){const t=n[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 ja{constructor(e){this.singleTap=new Va(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 n=this.singleTap.touchend(e,t,i);if(n){const t=e.timeStamp-this.lastTime<500,i=!this.lastTap||this.lastTap.dist(n)<30;if(t&&i||this.reset(),this.count++,this.lastTime=e.timeStamp,this.lastTap=n,this.count===this.numTaps)return this.reset(),n}}}class Ga{constructor(){this._zoomIn=new ja({numTouches:1,numTaps:2}),this._zoomOut=new ja({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 n=this._zoomIn.touchend(e,t,i),r=this._zoomOut.touchend(e,t,i);return n?(this._active=!0,e.preventDefault(),setTimeout(()=>this.reset(),0),{cameraAnimation:t=>t.easeTo({duration:300,zoom:t.getZoom()+1,around:t.unproject(n)},{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 Ha={0:1,2:2},Qa={Control:"ctrlKey",Alt:"altKey",Shift:"shiftKey",Meta:"metaKey"};class $a{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=Ha[t];return void 0===e.buttons||(e.buttons&i)!==i}(e,this._eventButton))this.reset();else if(this._moved||!(t.dist(i)0&&(this._active=!0);const r=Na(n,i),o=new e.P(0,0),s=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),s._add(t.sub(i)),a++,r[e]=t)}if(this._touches=r,a{this._alertContainer.classList.remove("mapboxgl-touch-pan-blocker-show"),this._alertContainer.removeAttribute("role")},500)}}class Xa{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 n=this._firstTwoTouches;if(!n)return;e.preventDefault();const[r,o]=n,s=Ja(i,t,r),a=Ja(i,t,o);if(!s||!a)return;const l=this._aroundCenter?null:s.add(a).div(2);return this._move([s,a],l,e)}touchend(e,t,i){if(!this._firstTwoTouches)return;const[n,r]=this._firstTwoTouches,o=Ja(i,t,n),s=Ja(i,t,r);o&&s||(this._active&&g(),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 Ja(e,t,i){for(let n=0;nMath.abs(e.x)}class rl extends Xa{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,nl(e[0].sub(e[1]))&&(this._valid=!1)}_move(t,i,n){const r=this._lastPoints;if(!r)return;const o=t[0].sub(r[0]),s=t[1].sub(r[1]);return this._map._cooperativeGestures&&!e.eT()&&n.touches.length<3||(this._valid=this.gestureBeginsVertically(o,s,n.timeStamp),!this._valid)?void 0:(this._lastPoints=t,this._active=!0,{pitchDelta:(o.y+s.y)/2*-.5})}gestureBeginsVertically(e,t,i){if(void 0!==this._valid)return this._valid;const n=e.mag()>=2,r=t.mag()>=2;if(!n&&!r)return;if(!n||!r)return null==this._firstMove&&(this._firstMove=i),i-this._firstMove<100&&void 0;const o=e.y>0==t.y>0;return nl(e)&&nl(t)&&o}}const ol={panStep:100,bearingStep:15,pitchStep:10};class sl{constructor(){const e=ol;this._panStep=e.panStep,this._bearingStep=e.bearingStep,this._pitchStep=e.pitchStep,this._rotationDisabled=!1}blur(){this.reset()}reset(){this._active=!1}keydown(e){if(e.altKey||e.ctrlKey||e.metaKey)return;let t=0,i=0,n=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?n=1:(e.preventDefault(),o=-1);break;case 40:e.shiftKey?n=-1:(e.preventDefault(),o=1);break;default:return}return this._rotationDisabled&&(i=0,n=0),{cameraAnimation:s=>{const a=s.getZoom();s.easeTo({duration:300,easeId:"keyboardHandler",easing:al,zoom:t?Math.round(a)+t*(e.shiftKey?2:1):a,bearing:s.getBearing()+i*this._bearingStep,pitch:s.getPitch()+n*this._pitchStep,offset:[-r*this._panStep,-o*this._panStep],center:s.getCenter()},{originalEvent:e})}}}enable(){this._enabled=!0}disable(){this._enabled=!1,this.reset()}isEnabled(){return this._enabled}isActive(){return this._active}disableRotation(){this._rotationDisabled=!0}enableRotation(){this._rotationDisabled=!1}}function al(e){return e*(2-e)}const ll=4.000244140625,cl=1/450;class ul{constructor(t,i){this._map=t,this._el=t.getCanvasContainer(),this._handler=i,this._delta=0,this._lastDelta=0,this._defaultZoomRate=.01,this._wheelZoomRate=cl,e.aX(["_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.eT()))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 n=e.o.now(),r=n-(this._lastWheelEventTime||0);this._lastWheelEventTime=n,0!==i&&i%ll==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)>ll?this._wheelZoomRate:this._defaultZoomRate;let n=2/(1+Math.exp(-Math.abs(this._delta*e)));this._delta<0&&0!==n&&(n=1/n);const r=i(),o=Math.pow(2,r),s="number"==typeof this._targetZoom?t.zoomScale(this._targetZoom):o;this._targetZoom=Math.min(t.maxZoom,Math.max(t.minZoom,t.scaleZoom(s*n))),"wheel"===this._type&&(this._startZoom=r,this._easing=this._smoothOutEasing(200)),this._lastDelta=this._delta,this._delta=0}const n="number"==typeof this._targetZoom?this._targetZoom:i(),r=this._startZoom,o=this._easing;let s,a=!1;if("wheel"===this._type&&r&&o){const t=Math.min((e.o.now()-this._lastWheelEventTime)/200,1),i=o(t);s=e.ak(r,n,i),t<1?this._frameId||(this._frameId=!0):a=!0}else s=n,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=s-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.eU;if(this._prevEase){const t=this._prevEase,n=(e.o.now()-t.start)/t.duration,r=t.easing(n+.01)-t.easing(n),o=.27/Math.sqrt(r*r+1e-4)*.01,s=Math.sqrt(.0729-o*o);i=e.eS(o,s,.25,1)}return this._prevEase={start:e.o.now(),duration:t,easing:i},i}blur(){this.reset()}reset(){this._active=!1}_addScrollZoomBlocker(){this._map&&!this._alertContainer&&(this._alertContainer=l("div","mapboxgl-scroll-zoom-blocker",this._map._container),this._alertContainer.textContent=/(Mac|iPad)/i.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 hl{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 dl{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 pl{constructor(){this._tap=new ja({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 n=t[0],r=n.y-this._swipePoint.y;return this._swipePoint=n,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 fl{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 ml{constructor(e,t,i){this._pitchWithRotate=e.pitchWithRotate,this._mouseRotate=t,this._mousePitch=i}enable(){this._mouseRotate.enable(),this._pitchWithRotate&&this._mousePitch.enable()}disable(){this._mouseRotate.disable(),this._mousePitch.disable()}isEnabled(){return this._mouseRotate.isEnabled()&&(!this._pitchWithRotate||this._mousePitch.isEnabled())}isActive(){return this._mouseRotate.isActive()||this._mousePitch.isActive()}}class gl{constructor(e,t,i,n){this._el=e,this._touchZoom=t,this._touchRotate=i,this._tapDragZoom=n,this._rotationDisabled=!1,this._enabled=!0}enable(e){this._touchZoom.enable(e),this._rotationDisabled||this._touchRotate.enable(e),this._tapDragZoom.enable(),this._el.classList.add("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._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()}}const _l=e=>e.zoom||e.drag||e.pitch||e.rotate;class Al extends e.z{}class yl{constructor(){this.constants=[1,1,.01],this.radius=0}setup(t,i){const n=e.av([],i,t);this.radius=e.ag(n[2]<0?e.eW([],n,this.constants):[n[0],n[1],0])}projectRay(t){e.eW(t,t,this.constants),e.aw(t,t),e.eX(t,t,this.constants);const i=e.c4([],t,this.radius);if(i[2]>0){const t=e.c4([],[0,0,1],e.bI(i,[0,0,1])),n=e.c4([],e.aw([],[i[0],i[1],0]),this.radius),r=e.d7([],i,e.c4([],e.av([],e.d7([],n,t),i),2));i[0]=r[0],i[1]=r[1]}return i}}function vl(e){return e.panDelta&&e.panDelta.mag()||e.zoomDelta||e.bearingDelta||e.pitchDelta}class xl{constructor(t,i){this._map=t,this._el=this._map.getCanvasContainer(),this._handlers=[],this._handlersById={},this._changes=[],this._inertia=new Pa(t),this._bearingSnap=i.bearingSnap,this._previousActiveHandlers={},this._trackingEllipsoid=new yl,this._dragOrigin=null,this._eventsInProgress={},this._addDefaultHandlers(i),e.aX(["handleEvent","handleWindowEvent"],this);const n=this._el;this._listeners=[[n,"touchstart",{passive:!0}],[n,"touchmove",{passive:!1}],[n,"touchend",void 0],[n,"touchcancel",void 0],[n,"mousedown",void 0],[n,"mousemove",void 0],[n,"mouseup",void 0],[document,"mousemove",{capture:!0}],[document,"mouseup",void 0],[n,"mouseover",void 0],[n,"mouseout",void 0],[n,"dblclick",void 0],[n,"click",void 0],[n,"keydown",{capture:!1}],[n,"keyup",void 0],[n,"wheel",{passive:!1}],[n,"contextmenu",void 0],[window,"blur",void 0]];for(const[e,t,i]of this._listeners){const n=e===document?this.handleWindowEvent:this.handleEvent;e.addEventListener(t,n,i)}}destroy(){for(const[e,t,i]of this._listeners){const n=e===document?this.handleWindowEvent:this.handleEvent;e.removeEventListener(t,n,i)}}_addDefaultHandlers(e){const t=this._map,i=t.getCanvasContainer();this._add("mapEvent",new Oa(t,e));const n=t.boxZoom=new Ua(t,e);this._add("boxZoom",n);const r=new Ga,o=new dl;t.doubleClickZoom=new hl(o,r),this._add("tapZoom",r),this._add("clickZoom",o);const s=new pl;this._add("tapDragZoom",s);const a=t.touchPitch=new rl(t);this._add("touchPitch",a);const l=new Wa(e),c=new qa(e);t.dragRotate=new ml(e,l,c),this._add("mouseRotate",l,["mousePitch"]),this._add("mousePitch",c,["mouseRotate"]);const u=new Za(e),h=new Ka(t,e);t.dragPan=new fl(i,u,h),this._add("mousePan",u),this._add("touchPan",h,["touchZoom","touchRotate"]);const d=new il,p=new el;t.touchZoomRotate=new gl(i,p,d,s),this._add("touchRotate",d,["touchPan","touchZoom"]),this._add("touchZoom",p,["touchPan","touchRotate"]),this._add("blockableMapEvent",new za(t));const f=t.scrollZoom=new ul(t,this);this._add("scrollZoom",f,["mousePan"]);const m=t.keyboard=new sl;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){if(!this._updatingCamera){for(const{handler:e}of this._handlers)e.reset();this._inertia.clear(),this._fireEvents({},{},e),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!!_l(this._eventsInProgress)||this.isZooming()}_isDragging(){return!!this._eventsInProgress.drag}_blockedByActive(e,t,i){for(const n in e)if(n!==i&&(!t||t.indexOf(n)<0))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}handleEvent(e,t){this._updatingCamera=!0;const i="renderFrame"===e.type,n=i?void 0:e,r={needsRenderFrame:!1},o={},s={},a=e.touches?this._getMapTouches(e.touches):void 0,l=a?A(this._el,a):i?void 0:_(this._el,e);for(const{handlerName:i,handler:c,allowed:u}of this._handlers){if(!c.isEnabled())continue;let h;this._blockedByActive(s,u,i)?c.reset():c[t||e.type]&&(h=c[t||e.type](e,l,a),this.mergeHandlerResult(r,o,h,i,n),h&&h.needsRenderFrame&&this._triggerRenderFrame()),(h||c.isActive())&&(s[i]=c)}const c={};for(const e in this._previousActiveHandlers)s[e]||(c[e]=n);this._previousActiveHandlers=s,(Object.keys(c).length||vl(r))&&(this._changes.push([r,o,c]),this._triggerRenderFrame()),(Object.keys(s).length||vl(r))&&this._map._stop(!0),this._updatingCamera=!1;const{cameraAnimation:u}=r;u&&(this._inertia.clear(),this._fireEvents({},{},!0),this._changes=[],u(this._map))}mergeHandlerResult(e,t,i,n,r){if(!i)return;Object.assign(e,i);const o={handlerName:n,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={},n={};for(const[r,o,s]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(n,s);this._updateMapTransform(t,i,n),this._changes=[]}_updateMapTransform(t,i,n){const r=this._map,o=r.transform,s=e=>[e.x,e.y,e.z];if((()=>{const e=this._eventsInProgress.drag;return e&&!this._handlersById[e.handlerName].isActive()})()&&!vl(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(!0),!vl(t))return void this._fireEvents(i,n,!0);let{panDelta:a,zoomDelta:l,bearingDelta:c,pitchDelta:u,around:h,aroundCoord:d,pinchAround:p}=t;o._isCameraConstrained&&(l>0&&(l=0),o._isCameraConstrained=!1),void 0!==p&&(h=p),(l||(e=>i[e]&&!this._eventsInProgress[e])("drag"))&&h&&(this._dragOrigin=s(o.pointCoordinate3D(h)),this._originalZoom=o.zoom,this._trackingEllipsoid.setup(o._camera.position,this._dragOrigin)),o.cameraElevationReference="sea",r._stop(!0),h=h||r.transform.centerPoint,c&&(o.bearing+=c),u&&(o.pitch+=u),o._updateCameraState();const f=[0,0,0];if(a)if("mercator"===o.projection.name){const e=this._trackingEllipsoid.projectRay(o.screenPointToMercatorRay(h).dir),t=this._trackingEllipsoid.projectRay(o.screenPointToMercatorRay(h.sub(a)).dir);f[0]=t[0]-e[0],f[1]=t[1]-e[1]}else{const t=o.pointCoordinate(h);if("globe"===o.projection.name){a=a.rotate(-o.angle);const i=o._pixelsPerMercatorPixel/o.worldSize;f[0]=-a.x*e.eV(e.a_(t.y))*i,f[1]=-a.y*e.eV(o.center.lat)*i}else{const e=o.pointCoordinate(h.sub(a));t&&e&&(f[0]=e.x-t.x,f[1]=e.y-t.y)}}const m=o.zoom,g=[0,0,0];if(l){const t=s(d||o.pointCoordinate3D(h)),i={dir:e.aw([],e.av([],t,o._camera.position))};if(i.dir[2]<0){const n=o.zoomDeltaToMovement(t,l);e.c4(g,i.dir,n)}}const _=e.d7(f,f,g);o._translateCameraConstrained(_),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,n,!0)}_fireEvents(t,i,n){const r=_l(this._eventsInProgress),o=_l(t),s={};for(const e in t){const{originalEvent:i}=t[e];this._eventsInProgress[e]||(s[`${e}start`]=i),this._eventsInProgress[e]=t[e]}!r&&o&&this._fireEvent("movestart",o.originalEvent);for(const e in s)this._fireEvent(e,s[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:n}=this._eventsInProgress[e];this._handlersById[t].isActive()||(delete this._eventsInProgress[e],l=i[t]||n,a[`${e}end`]=l)}for(const e in a)this._fireEvent(e,a[e]);const c=_l(this._eventsInProgress);if(n&&(r||o)&&!c){this._updatingCamera=!0;const t=this._inertia._onMoveEnd(this._map.dragPan._inertiaOptions),i=e=>0!==e&&-this._bearingSnap{this._frameId=void 0,this.handleEvent(new Al("renderFrame",{timeStamp:e})),this._applyChanges()})}_triggerRenderFrame(){void 0===this._frameId&&(this._frameId=this._requestFrame())}}const bl="map.setFreeCameraOptions(...) and map.getFreeCameraOptions() are not yet supported for non-mercator projections.";class wl 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.aX(["_renderFrameCallback"],this)}getCenter(){return new e.aS(this.transform.center.lng,this.transform.center.lat)}setCenter(e,t){return this.jumpTo({center:e},t)}panBy(t,i,n){return t=e.P.convert(t).mult(-1),this.panTo(this.transform.center,Object.assign({offset:t},i),n)}panTo(e,t,i){return this.easeTo(Object.assign({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(Object.assign({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(Object.assign({bearing:e},t),i)}resetNorth(e,t){return this.rotateTo(0,Object.assign({duration:1e3},e),t),this}resetNorthPitch(e,t){return this.easeTo(Object.assign({bearing:0,pitch:0,duration:1e3},e),t),this}snapToNorth(e,t){return Math.abs(this.getBearing())e.aspect?i/(2*Math.tan(.5*e.fovX)*e.aspect):n/(2*Math.tan(.5*e.fovY)*e.aspect)}_cameraForBoundsOnGlobe(t,i,n,r,o,s){const a=t.clone(),l=this._extendCameraOptions(s);a.bearing=r,a.pitch=o;const c=e.aS.convert(i),u=e.aS.convert(n),h=.5*(c.lat+u.lat),d=.5*(c.lng+u.lng),p=e.eY(h,d),f=e.aw([],p),m=e.aw([],e.bH([],f,[0,1,0])),g=e.bH([],m,f),_=[m[0],m[1],m[2],0,g[0],g[1],g[2],0,f[0],f[1],f[2],0,0,0,0,1],A=[p,e.eY(c.lat,c.lng),e.eY(u.lat,c.lng),e.eY(u.lat,u.lng),e.eY(c.lat,u.lng),e.eY(h,c.lng),e.eY(h,u.lng),e.eY(c.lat,d),e.eY(u.lat,d)];let y=e.d8.fromPoints(A.map(t=>[e.bI(m,t),e.bI(g,t),e.bI(f,t)]));const v=e.af([],y.center,_);0===e.eZ(v)&&e.e_(v,0,0,1),e.aw(v,v),e.c4(v,v,e.aD),a.center=e.e$(v);const x=a.getWorldToCameraMatrix(),b=e.bk(new Float64Array(16),x);y=e.d8.applyTransform(y,e.aB([],x,_));const w=this._extendAABB(y,a,l,r);if(!w)return void e.w("Map cannot fit within canvas with the given bounds, padding, and/or offset.");y=w,e.af(v,v,x);const T=.5*(y.max[2]-y.min[2]),E=this._minimumAABBFrustumDistance(a,y),C=e.c4([],[0,0,1],T),S=e.d7(C,v,C),B=E+(0===a.pitch?0:e.bF(v,S)),I=a.globeCenterInViewSpace,M=e.av([],v,[I[0],I[1],I[2]]);e.aw(M,M),e.c4(M,M,B);const P=e.d7([],v,M);e.af(P,P,b);const R=e.eL/e.aD,L=e.ag(P),F=e.ce(Math.max(L*R-e.eL,Number.EPSILON),0),k=Math.min(a.zoomFromMercatorZAdjusted(F),l.maxZoom);return k>.5*(e.cZ+e.cK)?(a.setProjection({name:"mercator"}),a.zoom=k,this._cameraForBounds(a,i,n,r,o,s)):{center:a.center,zoom:k,bearing:r,pitch:o}}_extendAABB(t,i,n,r){const o=.5*((n.padding.left||0)+(n.padding.right||0)),s=.5*((n.padding.top||0)+(n.padding.bottom||0)),a=s,l=o,c=o,u=s,h=i.width-(l+c),d=i.height-(a+u),p=e.av([],t.max,t.min),f=Math.min(h/p[0],d/p[1]),m=Math.min(i.scaleZoom(i.scale*f),n.maxZoom);if(isNaN(m))return null;const g=i.scale/i.zoomScale(m),_=new e.d8([t.min[0]-l*g,t.min[1]-u*g,t.min[2]],[t.max[0]+c*g,t.max[1]+a*g,t.max[2]]),A=("number"==typeof n.offset.x&&"number"==typeof n.offset.y?new e.P(n.offset.x,n.offset.y):e.P.convert(n.offset)).rotate(-e.an(r));return _.center[0]-=A.x*g,_.center[1]+=A.y*g,_}queryTerrainElevation(t,i){const n=this.transform.elevation;return n?(i=Object.assign({},{exaggerated:!0},i),n.getAtPoint(e.ae.fromLngLat(t),null,i.exaggerated)):null}_cameraForBounds(t,i,n,r,o,s){if("globe"===t.projection.name)return this._cameraForBoundsOnGlobe(t,i,n,r,o,s);const a=t.clone(),l=this._extendCameraOptions(s);a.bearing=r,a.pitch=o;const c=e.aS.convert(i),u=e.aS.convert(n),h=new e.aS(c.lng,u.lat),d=new e.aS(u.lng,c.lat),p=a.project(c),f=a.project(u),m=this.queryTerrainElevation(c),g=this.queryTerrainElevation(u),_=this.queryTerrainElevation(h),A=this.queryTerrainElevation(d),y=[[p.x,p.y,Math.min(m||0,g||0,_||0,A||0)],[f.x,f.y,Math.max(m||0,g||0,_||0,A||0)]];let v=e.d8.fromPoints(y);const x=a.getWorldToCameraMatrix(),b=e.bk(new Float64Array(16),x);v=e.d8.applyTransform(v,x);const w=this._extendAABB(v,a,l,r);if(!w)return void e.w("Map cannot fit within canvas with the given bounds, padding, and/or offset.");v=w;const T=.5*e.av([],v.max,v.min)[2],E=this._minimumAABBFrustumDistance(a,v),C=[0,0,1,0];e.aC(C,C,x),e.f0(C,C);const S=e.c4([],C,E+T),B=e.d7([],v.center,S);e.af(v.center,v.center,b),e.af(B,B,b);const I=a.unproject(new e.P(v.center[0],v.center[1])),M=e.f1(a.projection,I),P=Math.pow(2,M),R=Math.min(a._zoomFromMercatorZ(B[2]*a.pixelsPerMeter*P/a.worldSize),l.maxZoom);return a.mercatorFromTransition&&R<.5*(e.cZ+e.cK)?(a.setProjection({name:"globe"}),a.zoom=R,this._cameraForBounds(a,i,n,r,o,s)):{center:I,zoom:R,bearing:r,pitch:o}}fitBounds(e,t,i){const n=this.cameraForBounds(e,t);return this._fitInternal(n,t,i)}fitScreenCoordinates(t,i,n,r,o){const s=e.P.convert(t),a=e.P.convert(i),l=new e.P(Math.min(s.x,a.x),Math.min(s.y,a.y)),c=new e.P(Math.max(s.x,a.x),Math.max(s.y,a.y));if("mercator"===this.transform.projection.name&&this.transform.anyCornerOffEdge(s,a))return this;const u=this.transform.pointLocation3D(l),h=this.transform.pointLocation3D(c),d=this.transform.pointLocation3D(new e.P(l.x,c.y)),p=this.transform.pointLocation3D(new e.P(c.x,l.y)),f=[Math.min(u.lng,h.lng,d.lng,p.lng),Math.min(u.lat,h.lat,d.lat,p.lat)],m=[Math.max(u.lng,h.lng,d.lng,p.lng),Math.max(u.lat,h.lat,d.lat,p.lat)],g=r&&r.pitch?r.pitch:this.getPitch(),_=this._cameraForBounds(this.transform,f,m,n,g,r);return this._fitInternal(_,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();const n=t.preloadOnly?this.transform.clone():this.transform;let r=!1,o=!1,s=!1;"zoom"in t&&n.zoom!==+t.zoom&&(r=!0,n.zoom=+t.zoom),void 0!==t.center&&(n.center=e.aS.convert(t.center)),"bearing"in t&&n.bearing!==+t.bearing&&(o=!0,n.bearing=+t.bearing),"pitch"in t&&n.pitch!==+t.pitch&&(s=!0,n.pitch=+t.pitch);const a="number"==typeof t.padding?this._extendPadding(t.padding):t.padding;if(null!=t.padding&&!n.isPaddingEqual(a))if(!1===t.retainPadding){const e=n.clone();e.padding=a,n.setLocationAtPoint(n.center,e.centerPoint)}else n.padding=a;return t.preloadOnly?(this._preloadTiles(n),this):(this.fire(new e.z("movestart",i)).fire(new e.z("move",i)),r&&this.fire(new e.z("zoomstart",i)).fire(new e.z("zoom",i)).fire(new e.z("zoomend",i)),o&&this.fire(new e.z("rotatestart",i)).fire(new e.z("rotate",i)).fire(new e.z("rotateend",i)),s&&this.fire(new e.z("pitchstart",i)).fire(new e.z("pitch",i)).fire(new e.z("pitchend",i)),this.fire(new e.z("moveend",i)))}getFreeCameraOptions(){return this.transform.projection.supportsFreeCamera||e.w(bl),this.transform.getFreeCameraOptions()}setFreeCameraOptions(t,i){const n=this.transform;if(!n.projection.supportsFreeCamera)return e.w(bl),this;this.stop();const r=n.zoom,o=n.pitch,s=n.bearing;n.setFreeCameraOptions(t);const a=r!==n.zoom,l=o!==n.pitch,c=s!==n.bearing;return this.fire(new e.z("movestart",i)).fire(new e.z("move",i)),a&&this.fire(new e.z("zoomstart",i)).fire(new e.z("zoom",i)).fire(new e.z("zoomend",i)),c&&this.fire(new e.z("rotatestart",i)).fire(new e.z("rotate",i)).fire(new e.z("rotateend",i)),l&&this.fire(new e.z("pitchstart",i)).fire(new e.z("pitch",i)).fire(new e.z("pitchend",i)),this.fire(new e.z("moveend",i)),this}easeTo(t,i){this._stop(!1,t.easeId),(!1===(t=Object.assign({offset:[0,0],duration:500,easing:e.eU},t)).animate||this._prefersReducedMotion(t))&&(t.duration=0);const n=this.transform,r=this.getZoom(),o=this.getBearing(),s=this.getPitch(),a=this.getPadding(),l="zoom"in t?+t.zoom:r,c="bearing"in t?this._normalizeBearing(t.bearing,o):o,u="pitch"in t?+t.pitch:s,h=this._extendPadding(t.padding),d=e.P.convert(t.offset);let p,f,m;if("globe"===n.projection.name){const i=e.ae.fromLngLat(n.center),r=d.rotate(-n.angle);i.x+=r.x/n.worldSize,i.y+=r.y/n.worldSize;const o=i.toLngLat(),s=e.aS.convert(t.center||o);this._normalizeCenter(s),p=n.centerPoint.add(r),f=new e.P(i.x,i.y).mult(n.worldSize),m=new e.P(e.aF(s.lng),e.aJ(s.lat)).mult(n.worldSize).sub(f)}else{p=n.centerPoint.add(d);const i=n.pointLocation(p),r=e.aS.convert(t.center||i);this._normalizeCenter(r),f=n.project(i),m=n.project(r).sub(f)}const g=n.zoomScale(l-r);let _,A;t.around&&(_=e.aS.convert(t.around),A=n.locationPoint(_));const y=this._zooming||l!==r,v=this._rotating||o!==c,x=this._pitching||u!==s,b=!n.isPaddingEqual(h),w=!1===t.retainPadding?n.clone():n,T=n=>T=>{if(y&&(n.zoom=e.ak(r,l,T)),v&&(n.bearing=e.ak(o,c,T)),x&&(n.pitch=e.ak(s,u,T)),b&&(w.interpolatePadding(a,h,T),p=w.centerPoint.add(d)),_)n.setLocationAtPoint(_,A);else{const e=n.zoomScale(n.zoom-r),t=l>r?Math.min(2,g):Math.max(.5,g),i=Math.pow(t,1-T),o=n.unproject(f.add(m.mult(T*i)).mult(e));n.setLocationAtPoint(n.renderWorldCopies?o.wrap():o,p)}return t.preloadOnly||this._fireMoveEvents(i),n};if(t.preloadOnly){const e=this._emulate(T,t.duration,n);return this._preloadTiles(e),this}const E={moving:this._moving,zooming:this._zooming,rotating:this._rotating,pitching:this._pitching};return this._zooming=y,this._rotating=v,this._pitching=x,this._padding=b,this._easeId=t.easeId,this._prepareEase(i,t.noMoveStart,E),this._ease(T(n),e=>{"sea"===n.cameraElevationReference&&n.recenterOnTerrain(),this._afterEase(i,e)},t),this}_prepareEase(t,i,n={}){this._moving=!0,this.transform.cameraElevationReference="sea",this.transform._orthographicProjectionAtLowPitch&&0===this.transform.pitch&&"globe"!==this.transform.projection.name&&(this.transform.cameraElevationReference="ground"),i||n.moving||this.fire(new e.z("movestart",t)),this._zooming&&!n.zooming&&this.fire(new e.z("zoomstart",t)),this._rotating&&!n.rotating&&this.fire(new e.z("rotatestart",t)),this._pitching&&!n.pitching&&this.fire(new e.z("pitchstart",t))}_fireMoveEvents(t){this.fire(new e.z("move",t)),this._zooming&&this.fire(new e.z("zoom",t)),this._rotating&&this.fire(new e.z("rotate",t)),this._pitching&&this.fire(new e.z("pitch",t))}_afterEase(t,i){if(this._easeId&&i&&this._easeId===i)return;this._easeId=void 0,this.transform.cameraElevationReference="ground";const n=this._zooming,r=this._rotating,o=this._pitching;this._moving=!1,this._zooming=!1,this._rotating=!1,this._pitching=!1,this._padding=!1,n&&this.fire(new e.z("zoomend",t)),r&&this.fire(new e.z("rotateend",t)),o&&this.fire(new e.z("pitchend",t)),this.fire(new e.z("moveend",t))}flyTo(t,i){if(this._prefersReducedMotion(t)){const n=e.aH(t,["center","zoom","bearing","pitch","around","padding","retainPadding"]);return this.jumpTo(n,i)}this.stop(),t=Object.assign({offset:[0,0],speed:1.2,curve:1.42,easing:e.eU},t);const n=this.transform,r=this.getZoom(),o=this.getBearing(),s=this.getPitch(),a=this.getPadding(),l="zoom"in t?e.aA(+t.zoom,n.minZoom,n.maxZoom):r,c="bearing"in t?this._normalizeBearing(t.bearing,o):o,u="pitch"in t?+t.pitch:s,h=this._extendPadding(t.padding),d=n.zoomScale(l-r),p=e.P.convert(t.offset);let f=n.centerPoint.add(p);const m=n.pointLocation(f),g=e.aS.convert(t.center||m);this._normalizeCenter(g);const _=n.project(m),A=n.project(g).sub(_);let y=t.curve;const v=Math.max(n.width,n.height),x=v/d,b=A.mag();if("minZoom"in t){const i=e.aA(Math.min(t.minZoom,r,l),n.minZoom,n.maxZoom),o=v/n.zoomScale(i-r);y=Math.sqrt(o/b*2)}const w=y*y;function T(e){const t=(x*x-v*v+(e?-1:1)*w*w*b*b)/(2*(e?x:v)*w*b);return Math.log(Math.sqrt(t*t+1)-t)}function E(e){return(Math.exp(e)-Math.exp(-e))/2}function C(e){return(Math.exp(e)+Math.exp(-e))/2}const S=T(0);let B=function(e){return C(S)/C(S+y*e)},I=function(e){return v*((C(S)*(E(t=S+y*e)/C(t))-E(S))/w)/b;var t},M=(T(1)-S)/y;if(Math.abs(b)<1e-6||!isFinite(M)){if(Math.abs(v-x)<1e-6)return this.easeTo(t,i);const e=xt.maxDuration&&(t.duration=0);const P=o!==c,R=u!==s,L=!n.isPaddingEqual(h),F=!1===t.retainPadding?n.clone():n,k=n=>d=>{const m=d*M,y=1/B(m);n.zoom=1===d?l:r+n.scaleZoom(y),P&&(n.bearing=e.ak(o,c,d)),R&&(n.pitch=e.ak(s,u,d)),L&&(F.interpolatePadding(a,h,d),f=F.centerPoint.add(p));const v=1===d?g:n.unproject(_.add(A.mult(I(m))).mult(y));return n.setLocationAtPoint(n.renderWorldCopies?v.wrap():v,f),n._updateCameraOnTerrain(),t.preloadOnly||this._fireMoveEvents(i),n};if(t.preloadOnly){const e=this._emulate(k,t.duration,n);return this._preloadTiles(e),this}return this._zooming=!0,this._rotating=P,this._pitching=R,this._padding=L,this._prepareEase(i,!1),this._ease(k(n),()=>this._afterEase(i),t),this}isEasing(){return!!this._easeFrameId}stop(){return this._stop()}_requestRenderFrame(e){}_cancelRenderFrame(e){}_stop(e,t){if(this._easeFrameId&&(this._cancelRenderFrame(this._easeFrameId),this._easeFrameId=void 0,this._onEaseFrame=void 0),this._onEaseEnd){const e=this._onEaseEnd;this._onEaseEnd=void 0,e.call(this,t)}if(!e){const e=this.handlers;e&&e.stop(!1)}return this}_ease(t,i,n){!1===n.animate||0===n.duration?(t(1),i()):(this._easeStart=e.o.now(),this._easeOptions=n,this._onEaseFrame=t,this._onEaseEnd=i,this._easeFrameId=this._requestRenderFrame(this._renderFrameCallback))}_renderFrameCallback(){const t=Math.min((e.o.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.bS(t,-180,180);const n=Math.abs(t-i);return Math.abs(t-360-i)180?-360:i<-180?360:0}_prefersReducedMotion(t){return this._respectPrefersReducedMotion&&e.o.prefersReducedMotion&&!(t&&t.essential)}_emulate(e,t,i){const n=Math.ceil(15*t/1e3),r=[],o=e(i.clone());for(let e=0;e<=n;e++){const t=o(e/n);r.push(t.clone())}return r}_preloadTiles(e,t){}}class Tl{constructor(t={}){this.options=t,e.aX(["_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=l("div","mapboxgl-ctrl mapboxgl-ctrl-attrib"),this._compactButton=l("button","mapboxgl-ctrl-attrib-button",this._container),this._compactButton.type="button",this._compactButton.addEventListener("click",this._toggleAttribution),this._compactButton.setAttribute("aria-label",i);const n=l("span","mapboxgl-ctrl-icon",this._compactButton);return n.setAttribute("aria-hidden","true"),n.setAttribute("title",i),this._innerContainer=l("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.e.ACCESS_TOKEN}];if(t){const n=i.reduce((e,t,n)=>(t.value&&(e+=`${t.key}=${t.value}${ne.length-t.length),e=e.filter((t,i)=>{for(let n=i+1;n=0)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.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 El{constructor(){e.aX(["_updateLogo","_updateCompact"],this)}onAdd(e){this._map=e,this._container=l("div","mapboxgl-ctrl");const t=l("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(i.hasOwnProperty("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 Cl{constructor(){e.aX(["_onIndoorUpdate"],this)}onAdd(e){return this._map=e,this._container=l("div","mapboxgl-ctrl mapboxgl-ctrl-group"),this._map.indoor.on("selector-update",e=>this._onIndoorUpdate(e)),this._container}_createButton(e,t){const i=l("button",e,this._container);return i.type="button",i.addEventListener("click",t),i}_createSeparator(){return l("div","mapboxgl-ctrl-separator",this._container)}_setButtonTitle(e,t){this._map&&(e.setAttribute("aria-label",t),e.textContent=t)}onRemove(){this._container&&this._container.remove(),this._map&&this._map.indoor&&(this._map.indoor.off("selector-update",this._onIndoorUpdate),this._map=null)}getDefaultPosition(){return"right"}_onIndoorUpdate(e){if(!e||!e.floors)return this._model=e,void(this._container.style.display="none");const t=this._model;this._model=e,this._container.style.display="inline-block",this._container.style.borderRadius="8px",t&&Array.from(this._container.children).forEach(e=>e.remove()),e.floors.length>0&&(this.addBuildingsToggleButton(),this.addCurrentFloors(e.floors,e.activeFloorsVisible),this._updateBuildingsButtonState())}addBuildingsToggleButton(){const e=this._createButton("mapboxgl-ctrl-buildings-toggle",()=>{const e=this._map;this._model&&e&&e._setIndoorActiveFloorsVisibility(!this._model.activeFloorsVisible)});l("span","mapboxgl-ctrl-icon",e).setAttribute("aria-hidden","true"),e.classList.add("mapboxgl-ctrl-level-button","mapboxgl-ctrl-buildings-toggle"),this._model&&!this._model.activeFloorsVisible&&e.classList.add("mapboxgl-ctrl-level-button-selected"),this._container.append(e),this._createSeparator()}_updateBuildingsButtonState(){const e=this._container.querySelector(".mapboxgl-ctrl-buildings-toggle");e&&this._model&&(this._model.activeFloorsVisible?e.classList.remove("mapboxgl-ctrl-level-button-selected"):e.classList.add("mapboxgl-ctrl-level-button-selected"))}addCurrentFloors(e,t){for(let i=0;i{this._map._selectIndoorFloor(n.id)});this._setButtonTitle(r,n.zIndex.toString()),this._model&&n.id===this._model.selectedFloorId&&t&&r.classList.add("mapboxgl-ctrl-level-button-selected"),this._container.append(r),i=this._endTime)return this._end;const i=e.dC((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 Il={"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 Ml extends e.z{constructor(e,t,i,n){const{point:r,lngLat:o,originalEvent:s,target:a}=e;super(e.type,{point:r,lngLat:o,originalEvent:s,target:a}),this.preventDefault=()=>{e.preventDefault()},this.id=t,this.interaction=i,this.feature=n}}class Pl{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 n=i.filter;let r=i.type;n&&this.filters.set(t,e.b5(n)),"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,n]of t)n.target&&i.push({targetId:e,target:n.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 n="mouseenter"===t.type;if(n&&!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 s=!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 u of r){if(mt(u,l,a,i))continue;const r=new e.dw(l,u),h=ft(u,l,i);o&&void 0!==r.id&&(r.state=this.map.getFeatureState(r));const d=n?this.prevHoveredFeatures.get(h):null,p=new Ml(t,i,c,r),f=d?d.stop:c.handler(p);if(n&&this.hoveredFeatures.set(h,{feature:l,stop:f}),!1!==f){s=!0;break}}if(s)break}}if(s)break}if(!s)for(const[e,i]of r){const{handler:n,target:r}=i;if(!r&&!1!==n(new Ml(t,e,i,null)))break}}}function Rl(t,i){if(Array.isArray(t)&&Array.isArray(i)){const e=new Set(t),n=new Set(i);return e.size===n.size&&t.every(e=>n.has(e))}return e.bx(t,i)}const Ll={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,transformRequest:null,accessToken:null,fadeDuration:300,respectPrefersReducedMotion:!0,crossSourceCollisions:!0,collectResourceTiming:!1,testMode:!1,precompilePrograms:!0,scaleFactor:1,spriteFormat:"auto"},Fl={showCompass:!0,showZoom:!0,visualizePitch:!1};class kl{constructor(t,i,n=!1){this._clickTolerance=10,this.element=i,this.mouseRotate=new Wa({clickTolerance:t.dragRotate._mouseRotate._clickTolerance}),this.map=t,n&&(this.mousePitch=new qa({clickTolerance:t.dragRotate._mousePitch._clickTolerance})),e.aX(["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),p()}move(e,t){const i=this.map,n=this.mouseRotate.mousemoveWindow(e,t),r=n&&n.bearingDelta;if(r&&i.setBearing(i.getBearing()+r),this.mousePitch){const n=this.mousePitch.mousemoveWindow(e,t),r=n&&n.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(){f(),window.removeEventListener("mousemove",this.mousemove),window.removeEventListener("mouseup",this.mouseup)}mousedown(e){this.down(Object.assign({},e,{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=A(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=A(this.element,e.targetTouches)[0],this.move({preventDefault:()=>e.preventDefault()},this._lastPos))}touchend(e){0===e.targetTouches.length&&this._startPos&&this._lastPos&&this._startPos.dist(this._lastPos)n.width||i.y>n.height;n.locationPoint3D(r).distSqr(i)180;){const e=n.locationPoint3D(t);if(e.x>=0&&e.y>=0&&e.x<=n.width&&e.y<=n.height)break;t.lng>n.center.lng?t.lng-=360:t.lng+=360}return t}const Ol={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%)"},zl={rotation:0,rotationAlignment:"auto",pitchAlignment:"auto",occludedOpacity:.2,altitude:0};class Ul extends e.E{constructor(t,i){super(),(t instanceof HTMLElement||i)&&(t=Object.assign({element:t},i)),e.aX(["_update","_onMove","_onUp","_addDragHandler","_onMapClick","_onKeyPress","_clearFadeTimer"],this);const{anchor:n="center",color:r="#3FB1CE",scale:o=1,draggable:s=!1,clickTolerance:a=0,rotation:l=zl.rotation,rotationAlignment:c=zl.rotationAlignment,pitchAlignment:u=zl.pitchAlignment,occludedOpacity:h=zl.occludedOpacity,altitude:d=zl.altitude}=t||{};this._anchor=n,this._color=r,this._scale=o,this._draggable=s,this._clickTolerance=a,this._rotation=l,this._rotationAlignment=c,this._pitchAlignment=u,this._occludedOpacity=h,this._altitude=d,this._state="inactive",this._isDragging=!1,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 Ol)p.remove(`mapboxgl-marker-anchor-${e}`);p.add(`mapboxgl-marker-anchor-${this._anchor}`);const f=t&&t.className?t.className.trim().split(/\s+/):[];p.add(...f),this._popup=null}_createDefaultMarker(){const e=l("div"),t=c("svg",{display:"block",height:41*this._scale+"px",width:27*this._scale+"px",viewBox:"0 0 27 41"},e);if(0===this._altitude){const e=c("radialGradient",{id:"shadowGradient"},c("defs",{},t));c("stop",{offset:"10%","stop-opacity":.4},e),c("stop",{offset:"100%","stop-opacity":.05},e),c("ellipse",{cx:13.5,cy:34.8,rx:10.5,ry:5.25,fill:"url(#shadowGradient)"},t)}return c("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),c("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),c("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.aS.convert(t),this._pos=null,this._popup&&this._popup.setLngLat(this._lngLat),this._update(!0),this}setAltitude(e){return e===this._altitude||(this._defaultMarker&&(0===this._altitude&&0!==e||0!==this._altitude&&0===e)&&(this._element=this._createDefaultMarker()),this._altitude=e||zl.altitude,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,n=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":[n,-1*(t-i+n)],"bottom-right":[-n,-1*(t-i+n)],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),n=e.getFreeCameraOptions();if(!n.position)return!1;const r=n.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 n=t.unproject(i,this._altitude);let r;t._showingGlobe()&&e.f4(t.transform,this._lngLat)?r=0:(r=1-t._queryFogOpacity(n),t.transform._terrainEnabled()&&t.getTerrain()&&this._behindTerrain()&&(r*=this._occludedOpacity)),this._element.style.opacity=`${r}`,this._element.style.pointerEvents=r>0?"auto":"none",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 ${Ol[this._anchor]}\n ${this._calculateXYTransform()} ${this._calculateZTransform()}\n translate(${t.x}px,${t.y}px)\n `}_calculateXYTransform(){const t=this._pos,i=this._map,n=this.getPitchAlignment();if(!i||!t||"map"!==n)return"";if(!i._showingGlobe()){const e=i.getPitch();return e?`rotateX(${e}deg)`:""}const r=e.cW(e.f5(i.transform,this._lngLat)),o=t.sub(e.f6(i.transform)),s=Math.abs(o.x)+Math.abs(o.y);if(0===s)return"";const a=r/s;return`rotateX(${-o.y*a}deg) rotateY(${o.x*a}deg)`}_calculateZTransform(){const t=this._pos,i=this._map;if(!i||!t)return"";let n=0;const r=this.getRotationAlignment();if("map"===r)if(i._showingGlobe()){const t=i.project(new e.aS(this._lngLat.lng,this._lngLat.lat+.001),this._altitude),r=i.project(new e.aS(this._lngLat.lng,this._lngLat.lat-.001),this._altitude).sub(t);n=e.cW(Math.atan2(r.y,r.x))-90}else n=-i.getBearing();else if("horizon"===r){const r=e.ah(4,6,i.getZoom()),o=e.f6(i.transform);o.y+=r*i.transform.height;const s=t.sub(o),a=e.cW(Math.atan2(s.y,s.x));n=(a>90?a-270:a+90)*(1-r)}return n+=this._rotation,n?`rotateZ(${n}deg)`:""}_update(e){cancelAnimationFrame(this._updateFrameId);const t=this._map;t&&(t.transform.renderWorldCopies&&(this._lngLat=Dl(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.getTerrain()||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 n=this._pointerdownPos,r=this._positionDelta;if(n&&r){if(!this._isDragging){const e=this._clickTolerance||i._clickTolerance;if(t.point.dist(n)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");if(t.antialias&&e.f2(window)&&(t.antialias=!1,e.w("Antialiasing is disabled for this WebGL context to avoid browser bug: https://github.com/mapbox/mapbox-gl-js/issues/11609")),super(new an(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._isInitialLoad=!0,this._crossSourceCollisions=t.crossSourceCollisions,this._collectResourceTiming=t.collectResourceTiming,this._language=this._parseLanguage(t.language),this._worldview=t.worldview,this._renderTaskQueue=new Sl,this._domRenderTaskQueue=new Sl,this._controls=[],this._markers=[],this._popups=[],this._mapId=e.b1(),this._locale=Object.assign({},Il,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._scaleFactorChanged=!1,this._averageElevationLastSampledAt=-1/0,this._averageElevationExaggeration=0,this._averageElevation=new Bl(0),this._interactionRange=[1/0,-1/0],this._visibilityHidden=0,this._useExplicitProjection=!1,this._frameId=0,this._scaleFactor=t.scaleFactor,this._requestManager=new w(t.transformRequest,t.accessToken,t.testMode),this._silenceAuthErrors=!!t.testMode,this._contextCreateOptions=t.contextCreateOptions?Object.assign({},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=t.spriteFormat,e.aX(["_onWindowOnline","_onWindowResize","_onVisibilityChange","_onMapScroll","_contextLost","_contextRestored"],this),this._setupContainer(),this._tp||(this._tp=new sa),this._tp.registerParameter(this,["Debug"],"showOverdrawInspector"),this._tp.registerParameter(this,["Debug"],"showTileBoundaries"),this._tp.registerParameter(this,["Debug"],"showParseStatus"),this._tp.registerParameter(this,["Debug"],"repaint"),this._tp.registerParameter(this,["Debug"],"showTileAABBs"),this._tp.registerParameter(this,["Debug"],"showPadding"),this._tp.registerParameter(this,["Debug"],"showCollisionBoxes",{noSave:!0}),this._tp.registerParameter(this.transform,["Debug"],"freezeTileCoverage",{noSave:!0},()=>{this._update()}),this._tp.registerParameter(this,["Debug","Wireframe"],"showTerrainWireframe"),this._tp.registerParameter(this,["Debug","Wireframe"],"showLayers2DWireframe"),this._tp.registerParameter(this,["Debug","Wireframe"],"showLayers3DWireframe"),this._tp.registerParameter(this,["Scaling"],"_scaleFactor",{min:.1,max:10,step:.1},()=>{this.setScaleFactor(this._scaleFactor)}),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 xl(this,t),this._localFontFamily=t.localFontFamily,this._localIdeographFontFamily=t.localIdeographFontFamily,(t.style||!t.testMode)&&this.setStyle(t.style||e.e.DEFAULT_STYLE,{config:t.config,localFontFamily:this._localFontFamily,localIdeographFontFamily:this._localIdeographFontFamily}),t.projection&&this.setProjection(t.projection),t.hash&&(this._hash=new Ta("string"==typeof t.hash&&t.hash||void 0).addTo(this)),!this._hash||!this._hash._onHashChange()){null==r.center&&null==r.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,Object.assign({},t.fitBoundsOptions,{duration:0})))}this.resize(),t.attributionControl&&this.addControl(new Tl({customAttribution:t.customAttribution})),this._logoControl=new El,this.addControl(this._logoControl,t.logoPosition),this.on("style.load",()=>{this.transform.unmodified&&this.jumpTo(this.style.stylesheet),this._postStyleLoadEvent(),this._postStyleWithAppearanceEvent(),this._setupIndoor()}),this.on("data",t=>{this._update("style"===t.dataType),this.fire(new e.z(`${t.dataType}data`,t))}),this.on("dataloading",t=>{this.fire(new e.z(`${t.dataType}dataloading`,t))}),this._interactions=new Pl(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.y(new Error("Invalid argument to map.addControl(). Argument must be a control with onAdd and onRemove methods.")));const n=t.onAdd(this);this._controls.push(t);const r=this._controlPositions[i];return-1!==i.indexOf("bottom")?r.insertBefore(n,r.firstChild):r.appendChild(n),this}removeControl(t){if(!t||!t.onRemove)return this.fire(new e.y(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.indexOf(e)>-1}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.z("movestart",t)).fire(new e.z("move",t)),this.fire(new e.z("resize",t)),i&&this.fire(new e.z("moveend",t)),this}getBounds(){return this.transform.getBounds()}getMaxBounds(){return this.transform.getMaxBounds()||null}setMaxBounds(t){return this.transform.setMaxBounds(e.aI.convert(t)),this._update()}setMinZoom(t){if((t=t??-2)>=-2&&t<=this.transform.maxZoom)return this.transform.minZoom=t,this._update(),this.getZoom()=this.transform.minZoom)return this.transform.maxZoom=t,this._update(),this.getZoom()>t?this.setZoom(t):this.fire(new e.z("zoomstart")).fire(new e.z("zoom")).fire(new e.z("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()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.z("pitchstart")).fire(new e.z("pitch")).fire(new e.z("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._tp.refreshUI(),this._scaleFactorChanged=!0,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.reloadSources(),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 n;"globe"===i&&t.zoom>=e.cK?(t.setMercatorFromTransition(),n=!0):"mercator"===i&&t.zoom=e.cK?this.transform.setMercatorFromTransition():this.transform.setProjection(t),this.style.applyProjectionUpdate();const r="mercator"===this.transform.getProjection().name&&n!==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.aS.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 n=e=>{let i=[];if(Array.isArray(t)){const n=t.filter(e=>this.getLayer(e));i=n.length?this.queryRenderedFeatures(e,{layers:n}):[]}else i=this.queryRenderedFeatures(e,{target:t});return i};if("mouseenter"===e||"mouseover"===e){let r=!1;const o=t=>{const o=n(t.point);o.length?r||(r=!0,i.call(this,new Fa(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=>{n(t.point).length?r=!0:r&&(r=!1,i.call(this,new Fa(e,this,t.originalEvent)))},s=t=>{r&&(r=!1,i.call(this,new Fa(e,this,t.originalEvent)))};return{listener:i,targets:t,delegates:{mousemove:o,mouseout:s}}}{const r=e=>{const t=n(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 n=this._createDelegatedListener(e,t,i);this._delegatedListeners=this._delegatedListeners||{},this._delegatedListeners[e]=this._delegatedListeners[e]||[],this._delegatedListeners[e].push(n);for(const e in n.delegates)this.on(e,n.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 n=this._createDelegatedListener(e,t,i);for(const e in n.delegates)this.once(e,n.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 n=this._delegatedListeners?this._delegatedListeners[e]:void 0;return n&&(e=>{for(let n=0;n{if(n){const r="string"==typeof n?n:n instanceof Error?n.message:n.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._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=Object.assign({},t);t&&t.config&&(i.initialConfig=t.config,delete i.config),this.style=new In(this,i).load(e),this.style.setEventedParent(this,{style:this.style})}return this._updateTerrain(),this}_lazyInitEmptyStyle(){this.style||(this.style=new In(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.y(new Error("IDs can't be empty."))),!1):!e.dq(t)||(this.fire(new e.y(new Error(`IDs can't contain special symbols: "${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()}addSourceType(e,t,i){this._lazyInitEmptyStyle(),this.style.addSourceType(e,t,i)}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:n=1,sdf:r=!1,stretchX:o,stretchY:s,content:a}={}){this._lazyInitEmptyStyle();const l=e.I.from(t);if(i instanceof HTMLImageElement||ImageBitmap&&i instanceof ImageBitmap){const{width:t,height:c,data:u}=e.o.getImageData(i);this.style.addImage(l,{data:new e.q({width:t,height:c},u),pixelRatio:n,stretchX:o,stretchY:s,content:a,sdf:r,version:0,usvg:!1})}else if(void 0===i.width||void 0===i.height)this.fire(new e.y(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:u}=i,h=i;this.style.addImage(l,{data:new e.q({width:c,height:u},new Uint8Array(h.data)),pixelRatio:n,stretchX:o,stretchY:s,content:a,sdf:r,usvg:!1,version:0,userImage:h}),h.onAdd&&h.onAdd(this,t)}}updateImage(t,i){this._lazyInitEmptyStyle();const n=e.I.from(t),r=this.style.getImage(n);if(!r)return void this.fire(new e.y(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.o.getImageData(i):i,{width:s,height:a,data:l}=o;if(void 0===s||void 0===a)return void this.fire(new e.y(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(s!==(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.y(new Error(`The width and height of the updated image (${s}, ${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 u=!1;r.usvg?(r.data=new e.q({width:s,height:a},new Uint8Array(l)),r.usvg=!1,r.icon=void 0,u=!0):r.data.replace(l,c),this.style.updateImage(n,r,u)}hasImage(t){return t?!!this.style&&!!this.style.getImage(e.I.from(t)):(this.fire(new e.y(new Error("Missing required image id"))),!1)}removeImage(t){this.style.removeImage(e.I.from(t))}loadImage(t,i){e.n(this._requestManager.transformRequest(t,e.R.Image),(t,n)=>{i(t,n instanceof HTMLImageElement?e.o.getImageData(n):n)})}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.y(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.style.addImport(t,i).catch(t=>this.fire(new e.y(new Error("Failed to add import",t)))),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,n={}){return this._isValidId(e)?(this.style.setPaintProperty(e,t,i,n),this._update(!0)):this}getPaintProperty(e,t){return this._isValidId(e)?this.style.getPaintProperty(e,t):null}setLayoutProperty(e,t,i,n={}){return this._isValidId(e)?(this.style.setLayoutProperty(e,t,i,n),this._update(!0)):this}getLayoutProperty(e,t){return this._isValidId(e)?this.style.getLayoutProperty(e,t):null}setLayerProperty(e,t,i,n={}){return this._isValidId(e)?(this.style.setLayerProperty(e,t,i,n),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)}_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.aS.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)}_selectIndoorFloor(e){this.indoor.selectFloor(e)}_setIndoorActiveFloorsVisibility(e){this.indoor.setActiveFloorsVisibility(e)}_addIndoorControl(){this._indoorControl||(this._indoorControl=new Cl),this.addControl(this._indoorControl,"right")}_removeIndoorControl(){this._indoorControl&&this.removeControl(this._indoorControl)}_updateContainerDimensions(){if(!this._container)return;const e=this._container.getBoundingClientRect().width||400,t=this._container.getBoundingClientRect().height||300;let i,n,r,o=this._container;for(;o&&(!n||!r);){const e=window.getComputedStyle(o).transform;e&&"none"!==e&&(i=e.match(/matrix.*\((.+)\)/)[1].split(", "),i[0]&&"0"!==i[0]&&"1"!==i[0]&&(n=i[0]),i[3]&&"0"!==i[3]&&"1"!==i[3]&&(r=i[3])),o=o.parentElement}this._containerWidth=n?Math.abs(e/n):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/.")}_setupIndoor(){this.style.isIndoorEnabled()&&(this.indoor=new Mn(this.style),this.on("load",()=>{this._addIndoorControl(),this.indoor._updateUI(this.transform.zoom,this.transform.center,this.transform.getBounds()),this.on("move",()=>{this.indoor._updateUI(this.transform.zoom,this.transform.center,this.transform.getBounds())}),this.on("idle",()=>{this.indoor._updateUI(this.transform.zoom,this.transform.center,this.transform.getBounds())})}))}_setupContainer(){const e=this._container;e.classList.add("mapboxgl-map"),(this._missingCSSCanary=l("div","mapboxgl-canary",e)).style.visibility="hidden",this._detectMissingCSS();const t=this._canvasContainer=l("div","mapboxgl-canvas-container",e);this._canvas=l("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=l("div","mapboxgl-control-container",e),n=this._controlPositions={};["top-left","top","top-right","right","bottom-right","bottom","bottom-left","left"].forEach(e=>{n[e]=l("div",`mapboxgl-ctrl-${e}`,i)}),this._container.addEventListener("scroll",this._onMapScroll,!1)}_resizeCanvas(t,i){const n=e.o.devicePixelRatio||1;this._canvas.width=n*Math.ceil(t),this._canvas.height=n*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 t=Object.assign({},a.supported.webGLContextAttributes,{failIfMajorPerformanceCaveat:this._failIfMajorPerformanceCaveat,preserveDrawingBuffer:this._preserveDrawingBuffer,antialias:this._antialias||!1}),i=this._canvas.getContext("webgl2",t);i?(G(i,!0),this.painter=new ba(i,this._contextCreateOptions,this.transform,this._scaleFactor,this._tp,this._worldview),this.on("data",e=>{"source"===e.dataType&&this.painter.setTileLoadedFlag(!0)}),e.k.testSupport(i)):this.fire(new e.y(new Error("Failed to initialize WebGL")))}_contextLost(t){t.preventDefault(),this._frame&&(this._frame.cancel(),this._frame=null),this.fire(new e.z("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.reloadModels(),this.style.clearSources()),this._update(),this.fire(new e.z("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 r;this.fire(new e.z("renderstart")),++this._frameId;const o=this.painter.context.extTimerQuery,s=e.o.now(),a=this.painter.context.gl;if(this.listens("gpu-timing-frame")&&(r=a.createQuery(),a.beginQuery(o.TIME_ELAPSED_EXT,r)),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 l=this._isInitialLoad?0:this._fadeDuration;if(this.style&&this._styleDirty){this._styleDirty=!1;const t=this.transform.zoom,i=this.transform.pitch,n=e.o.now(),r=new e.ac(t,{now:n,fadeDuration:l,pitch:i,transition:this.style.transition,worldview:this._worldview});this.style.update(r)}this.style&&this.style.hasFogTransition()&&(this.style._markersNeedUpdate=!0,this._sourcesDirty=!0);let c=!1;this.style&&this._sourcesDirty?(this._sourcesDirty=!1,this.painter._updateFog(this.style),this._updateTerrain(),c=this._updateAverageElevation(s),this.style.updateSources(this.transform),this.style.updateImageProviders(),this.isMoving()||this._forceMarkerAndPopupUpdate()):c=this._updateAverageElevation(s);const u=this.style&&this.style._updatePlacement(this.painter,this.painter.transform,this.showCollisionBoxes,l,this._crossSourceCollisions,this.painter.replacementSource,this._scaleFactorChanged);if(this._scaleFactorChanged&&(this._scaleFactorChanged=!1),u&&(this._placementDirty=u.needsRerender),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:l,isInitialLoad:this._isInitialLoad,showPadding:this.showPadding,gpuTiming:!!this.listens("gpu-timing-layer"),gpuTimingDeferredRender:!!this.listens("gpu-timing-deferred-render"),speedIndexTiming:this.speedIndexTiming}),this.fire(new e.z("render")),this.loaded()&&!this._loaded&&(this._loaded=!0,n.mark(i.load),this.fire(new e.z("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.style.modelManager.isLoaded()&&(this._styleDirty=!0),this.style&&!this._placementDirty&&this.style._releaseSymbolFadeTiles(),r){const t=e.o.now()-s;a.endQuery(o.TIME_ELAPSED_EXT),setTimeout(()=>{const i=a.getQueryParameter(r,a.QUERY_RESULT)/1e6;a.deleteQuery(r),this.fire(new e.z("gpu-timing-frame",{cpuTime:t,gpuTime:i}))},50)}if(this.listens("gpu-timing-layer")){const t=this.painter.collectGpuTimers();setTimeout(()=>{const i=this.painter.queryGpuTimers(t);this.fire(new e.z("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.z("gpu-timing-deferred-render",{gpuTime:i}))},50)}const h=this._sourcesDirty||this._styleDirty||this._placementDirty||c;if(h||this._repaint)this.triggerRepaint();else{const t=this.idle();if(t&&(c=this._updateAverageElevation(s,!0)),c)this.triggerRepaint();else if(this._triggerFrame(!1),t&&(this.fire(new e.z("idle")),this._isInitialLoad=!1,this.speedIndexTiming)){const t=this._calculateSpeedIndex();this.fire(new e.z("speedindexcompleted",{speedIndex:t})),this.speedIndexTiming=!1}}!this._loaded||this._fullyLoaded||h||(this._fullyLoaded=!0,n.mark(i.fullLoad),this._performanceMetricsCollection&&U(this._requestManager._customAccessToken,{width:this.painter.width,height:this.painter.height,interactionRange:this._interactionRange,visibilityHidden:this._visibilityHidden,terrainEnabled:!!this.painter.style.getTerrain(),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 n=this.transform.elevation&&this.transform.elevation.exaggeration()!==this._averageElevationExaggeration;if(n||(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||n)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))}_authenticate(){V(this._getMapId(),this._requestManager._skuToken,this._requestManager._customAccessToken,t=>{if(t&&(t.message===b||401===t.status)){const t=this.painter.context.gl;G(t,!1),this._logoControl instanceof El&&this._logoControl._updateLogo(),t&&t.clear(t.DEPTH_BUFFER_BIT|t.COLOR_BUFFER_BIT|t.STENCIL_BUFFER_BIT),this._silenceAuthErrors||this.fire(new e.y(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/")))}}),L(this._getMapId(),this._requestManager._skuToken,this._requestManager._customAccessToken,()=>{})}_postStyleLoadEvent(){this.style.globalId&&k(this._requestManager._customAccessToken,{map:this,style:this.style.globalId,importedStyles:this.style.getImportGlobalIds()})}_postStyleWithAppearanceEvent(){this.style.globalId&&this.style.hasAppearances()&&O(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,n=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,n),this._canvasPixelComparison(r(e),t.canvasCopies.map(r),t.timeStamps)}_canvasPixelComparison(e,t,i){let n=i[1]-i[0];const r=e.length/4;for(let o=0;o{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.bv(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,this._tp.refreshUI(),this._update())}get showParseStatus(){return!!this._showParseStatus}set showParseStatus(e){this._showParseStatus!==e&&(this._showParseStatus=e,this._tp.refreshUI(),this._update())}get showTerrainWireframe(){return!!this._showTerrainWireframe}set showTerrainWireframe(e){this._showTerrainWireframe!==e&&(this._showTerrainWireframe=e,this._tp.refreshUI(),this._update())}get showLayers2DWireframe(){return!!this._showLayers2DWireframe}set showLayers2DWireframe(e){this._showLayers2DWireframe!==e&&(this._showLayers2DWireframe=e,this._tp.refreshUI(),this._update())}get showLayers3DWireframe(){return!!this._showLayers3DWireframe}set showLayers3DWireframe(e){this._showLayers3DWireframe!==e&&(this._showLayers3DWireframe=e,this._tp.refreshUI(),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,this._tp.refreshUI(),this._update())}get showCollisionBoxes(){return!!this._showCollisionBoxes}set showCollisionBoxes(e){this._showCollisionBoxes!==e&&(this._showCollisionBoxes=e,this._tp.refreshUI(),e?this.style._generateCollisionBoxes():this._update())}get showOverdrawInspector(){return!!this._showOverdrawInspector}set showOverdrawInspector(e){this._showOverdrawInspector!==e&&(this._showOverdrawInspector=e,this._tp.refreshUI(),this._update())}get repaint(){return!!this._repaint}set repaint(e){this._repaint!==e&&(this._repaint=e,this._tp.refreshUI(),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,this._tp.refreshUI(),e&&this._update())}_setCacheLimits(t,i){e.f3(t,i)}get version(){return t}},NavigationControl:class{constructor(t={}){this.options=Object.assign({},Fl,t),this._container=l("div","mapboxgl-ctrl mapboxgl-ctrl-group"),this._container.addEventListener("contextmenu",e=>e.preventDefault()),this.options.showZoom&&(e.aX(["_setButtonTitle","_updateZoomButtons"],this),this._zoomInButton=this._createButton("mapboxgl-ctrl-zoom-in",e=>{this._map&&this._map.zoomIn({},{originalEvent:e})}),l("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})}),l("span","mapboxgl-ctrl-icon",this._zoomOutButton).setAttribute("aria-hidden","true")),this.options.showCompass&&(e.aX(["_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=l("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(),n=t===e.getMinZoom();this._zoomInButton.disabled=i,this._zoomOutButton.disabled=n,this._zoomInButton.setAttribute("aria-disabled",i.toString()),this._zoomOutButton.setAttribute("aria-disabled",n.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 kl(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=l("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=Object.assign({geolocation:i},Nl,t),e.aX(["_onSuccess","_onError","_onZoom","_finish","_setupUI","_updateCamera","_updateMarker","_updateMarkerRotation","_onDeviceOrientation"],this),this._updateMarkerRotationThrottled=wa(this._updateMarkerRotation,20),this._numberOfWatches=0}onAdd(e){return this._map=e,this._container=l("div","mapboxgl-ctrl mapboxgl-ctrl-group"),this._checkGeolocationSupport(this._setupUI),this._container}onRemove(){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.longitudet.getEast()||i.latitudet.getNorth())}_setErrorState(){switch(this._watchState){case"WAITING_ACTIVE":this._watchState="ACTIVE_ERROR",this._geolocateButton.classList.remove("mapboxgl-ctrl-geolocate-active"),this._geolocateButton.classList.add("mapboxgl-ctrl-geolocate-active-error");break;case"ACTIVE_LOCK":this._watchState="ACTIVE_ERROR",this._geolocateButton.classList.remove("mapboxgl-ctrl-geolocate-active"),this._geolocateButton.classList.add("mapboxgl-ctrl-geolocate-active-error"),this._geolocateButton.classList.add("mapboxgl-ctrl-geolocate-waiting");break;case"BACKGROUND":this._watchState="BACKGROUND_ERROR",this._geolocateButton.classList.remove("mapboxgl-ctrl-geolocate-background"),this._geolocateButton.classList.add("mapboxgl-ctrl-geolocate-background-error"),this._geolocateButton.classList.add("mapboxgl-ctrl-geolocate-waiting")}}_onSuccess(t){if(this._map){if(this._isOutOfMapMaxBounds(t))return this._setErrorState(),this.fire(new e.z("outofmaxbounds",t)),this._updateMarker(),void this._finish();if(this.options.trackUserLocation)switch(this._lastKnownPosition=t,this._watchState){case"WAITING_ACTIVE":case"ACTIVE_LOCK":case"ACTIVE_ERROR":this._watchState="ACTIVE_LOCK",this._geolocateButton.classList.remove("mapboxgl-ctrl-geolocate-waiting"),this._geolocateButton.classList.remove("mapboxgl-ctrl-geolocate-active-error"),this._geolocateButton.classList.add("mapboxgl-ctrl-geolocate-active");break;case"BACKGROUND":case"BACKGROUND_ERROR":this._watchState="BACKGROUND",this._geolocateButton.classList.remove("mapboxgl-ctrl-geolocate-waiting"),this._geolocateButton.classList.remove("mapboxgl-ctrl-geolocate-background-error"),this._geolocateButton.classList.add("mapboxgl-ctrl-geolocate-background")}this.options.showUserLocation&&"OFF"!==this._watchState&&this._updateMarker(t),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.z("geolocate",Object.assign({coords:t.coords,timestamp:t.timestamp},t.toJSON?{toJSON:t.toJSON.bind(t)}:{}))),this._finish()}}_updateCamera(t){const i=new e.aS(t.coords.longitude,t.coords.latitude),n=t.coords.accuracy,r=this._map.getBearing(),o=Object.assign({bearing:r},this.options.fitBoundsOptions);this._map.fitBounds(i.toBounds(n),o,{geolocateSource:!0})}_updateMarker(t){if(t){const i=new e.aS(t.coords.longitude,t.coords.latitude);this._accuracyCircleMarker.setLngLat(i).addTo(this._map),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.ce(1,t._center.lat)*t.worldSize,n=Math.ceil(2*this._accuracy*i);this._circleElement.style.width=`${n}px`,this._circleElement.style.height=`${n}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.options.trackUserLocation)if(1===t.code){this._watchState="OFF",this._geolocateButton.classList.remove("mapboxgl-ctrl-geolocate-waiting"),this._geolocateButton.classList.remove("mapboxgl-ctrl-geolocate-active"),this._geolocateButton.classList.remove("mapboxgl-ctrl-geolocate-active-error"),this._geolocateButton.classList.remove("mapboxgl-ctrl-geolocate-background"),this._geolocateButton.classList.remove("mapboxgl-ctrl-geolocate-background-error"),this._geolocateButton.disabled=!0;const e=this._map._getUIString("GeolocateControl.LocationNotAvailable");this._geolocateButton.setAttribute("aria-label",e),this._geolocateButton.firstElementChild&&this._geolocateButton.firstElementChild.setAttribute("title",e),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.z("error",t)),this._finish()}}_finish(){this._timeoutId&&clearTimeout(this._timeoutId),this._timeoutId=void 0}_setupUI(t){if(void 0!==this._map){if(this._container.addEventListener("contextmenu",e=>e.preventDefault()),this._geolocateButton=l("button","mapboxgl-ctrl-geolocate",this._container),l("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.");const t=this._map._getUIString("GeolocateControl.LocationNotAvailable");this._geolocateButton.disabled=!0,this._geolocateButton.setAttribute("aria-label",t),this._geolocateButton.firstElementChild&&this._geolocateButton.firstElementChild.setAttribute("title",t)}else{const e=this._map._getUIString("GeolocateControl.FindMyLocation");this._geolocateButton.setAttribute("aria-label",e),this._geolocateButton.firstElementChild&&this._geolocateButton.firstElementChild.setAttribute("title",e)}this.options.trackUserLocation&&(this._geolocateButton.setAttribute("aria-pressed","false"),this._watchState="OFF"),this.options.showUserLocation&&(this._dotElement=l("div","mapboxgl-user-location"),this._dotElement.appendChild(l("div","mapboxgl-user-location-dot")),this._dotElement.appendChild(l("div","mapboxgl-user-location-heading")),this._userLocationDotMarker=new Ul({element:this._dotElement,rotationAlignment:"map",pitchAlignment:"map"}),this._circleElement=l("div","mapboxgl-user-location-accuracy-circle"),this._accuracyCircleMarker=new Ul({element:this._circleElement,pitchAlignment:"map"}),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.trackUserLocation&&this._map.on("movestart",t=>{t.geolocateSource||"ACTIVE_LOCK"!==this._watchState||t.originalEvent&&"resize"===t.originalEvent.type||(this._watchState="BACKGROUND",this._geolocateButton.classList.add("mapboxgl-ctrl-geolocate-background"),this._geolocateButton.classList.remove("mapboxgl-ctrl-geolocate-active"),this.fire(new e.z("trackuserlocationend")))})}}_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._watchState="WAITING_ACTIVE",this.fire(new e.z("trackuserlocationstart"));break;case"WAITING_ACTIVE":case"ACTIVE_LOCK":case"ACTIVE_ERROR":case"BACKGROUND_ERROR":this._numberOfWatches--,this._noTimeout=!1,this._watchState="OFF",this._geolocateButton.classList.remove("mapboxgl-ctrl-geolocate-waiting"),this._geolocateButton.classList.remove("mapboxgl-ctrl-geolocate-active"),this._geolocateButton.classList.remove("mapboxgl-ctrl-geolocate-active-error"),this._geolocateButton.classList.remove("mapboxgl-ctrl-geolocate-background"),this._geolocateButton.classList.remove("mapboxgl-ctrl-geolocate-background-error"),this.fire(new e.z("trackuserlocationend"));break;case"BACKGROUND":this._watchState="ACTIVE_LOCK",this._geolocateButton.classList.remove("mapboxgl-ctrl-geolocate-background"),this._lastKnownPosition&&this._updateCamera(this._lastKnownPosition),this.fire(new e.z("trackuserlocationstart"))}switch(this._watchState){case"WAITING_ACTIVE":this._geolocateButton.classList.add("mapboxgl-ctrl-geolocate-waiting"),this._geolocateButton.classList.add("mapboxgl-ctrl-geolocate-active");break;case"ACTIVE_LOCK":this._geolocateButton.classList.add("mapboxgl-ctrl-geolocate-active");break;case"ACTIVE_ERROR":this._geolocateButton.classList.add("mapboxgl-ctrl-geolocate-waiting"),this._geolocateButton.classList.add("mapboxgl-ctrl-geolocate-active-error");break;case"BACKGROUND":this._geolocateButton.classList.add("mapboxgl-ctrl-geolocate-background");break;case"BACKGROUND_ERROR":this._geolocateButton.classList.add("mapboxgl-ctrl-geolocate-waiting"),this._geolocateButton.classList.add("mapboxgl-ctrl-geolocate-background-error")}if("OFF"===this._watchState&&void 0!==this._geolocationWatchID)this._clearWatch();else if(void 0===this._geolocationWatchID){let e;this._geolocateButton.classList.add("mapboxgl-ctrl-geolocate-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.options.showUserHeading&&this._addDeviceOrientationListener()}}else this.options.geolocation.getCurrentPosition(this._onSuccess,this._onError,this.options.positionOptions),this._timeoutId=window.setTimeout(this._finish,1e4);return!0}_addDeviceOrientationListener(){const e=()=>{"ondeviceorientationabsolute"in window?window.addEventListener("deviceorientationabsolute",this._onDeviceOrientation):window.addEventListener("deviceorientation",this._onDeviceOrientation)};"undefined"!=typeof DeviceMotionEvent&&"function"==typeof DeviceMotionEvent.requestPermission?DeviceOrientationEvent.requestPermission().then(t=>{"granted"===t&&e()}).catch(console.error):e()}_clearWatch(){this.options.geolocation.clearWatch(this._geolocationWatchID),window.removeEventListener("deviceorientation",this._onDeviceOrientation),window.removeEventListener("deviceorientationabsolute",this._onDeviceOrientation),this._geolocationWatchID=void 0,this._geolocateButton.classList.remove("mapboxgl-ctrl-geolocate-waiting"),this._geolocateButton.setAttribute("aria-pressed","false"),this.options.showUserLocation&&this._updateMarker(null)}},AttributionControl:Tl,ScaleControl:class{constructor(t={}){this.options=Object.assign({},Vl,t),this._isNumberFormatSupported=function(){try{return new Intl.NumberFormat("en",{style:"unit",unitDisplay:"short",unit:"meter"}),!0}catch(e){return!1}}(),e.aX(["_update","_setScale","setUnit"],this)}getDefaultPosition(){return"bottom-left"}_update(){const e=this.options.maxWidth||100,t=this._map,i=t._containerHeight/2,n=t._containerWidth/2-e/2,r=t.unproject([n,i]),o=t.unproject([n+e,i]),s=r.distanceTo(o);if("imperial"===this.options.unit){const t=3.2808*s;t>5280?this._setScale(e,t/5280,"mile"):this._setScale(e,t,"foot")}else"nautical"===this.options.unit?this._setScale(e,s/1852,"nautical-mile"):s>=1e3?this._setScale(e,s/1e3,"kilometer"):this._setScale(e,s,"meter")}_setScale(e,t,i){this._map._requestDomTask(()=>{const n=function(e){const t=Math.pow(10,`${Math.floor(e)}`.length-1);let i=e/t;return i=i>=10?10:i>=5?5:i>=3?3:i>=2?2:i>=1?1:function(e){const t=Math.pow(10,Math.ceil(-Math.log(e)/Math.LN10));return Math.round(e*t)/t}(i),t*i}(t),r=n/t;this._container.innerHTML=this._isNumberFormatSupported&&"nautical-mile"!==i?new Intl.NumberFormat(this._language,{style:"unit",unitDisplay:"short",unit:i}).format(n):`${n} ${jl[i]}`,this._container.style.width=e*r+"px"})}onAdd(e){return this._map=e,this._language=e.getLanguage(),this._container=l("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.aX(["_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=l("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=l("button","mapboxgl-ctrl-fullscreen",this._controlContainer);l("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:Cl,Popup:class extends e.E{constructor(t){super(),this.options=Object.assign(Object.create(Gl),t),this._altitude=this.options.altitude,e.aX(["_update","_onClose","remove","_onMouseEvent"],this),this._classList=new Set(t&&t.className?t.className.trim().split(/\s+/):[])}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.z("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.z("close")),this}getLngLat(){return this._lngLat}setLngLat(t){this._lngLat=e.aS.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 n;for(i.innerHTML=e;n=i.firstChild,n;)t.appendChild(n);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=l("div","mapboxgl-popup-content",this._container||void 0);if(t.appendChild(e),this.options.closeButton){const e=this._closeButton=l("button","mapboxgl-popup-close-button",t);e.type="button",e.setAttribute("aria-label","Close popup"),e.innerHTML='',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,n=this._pos;if(!t||!i||!n)return"bottom";const r=i.offsetWidth,o=i.offsetHeight,s=n.xt.transform.width-r/2;if(n.y+et.transform.height-o){if(s)return"bottom-left";if(a)return"bottom-right"}return s?"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,n=this._content;if(!i||!this._lngLat&&!this._trackPointer||!n)return;let r=this._container;if(r||(r=this._container=l("div","mapboxgl-popup",i.getContainer()),this._tip=l("div","mapboxgl-popup-tip",r),r.appendChild(n)),this.options.maxWidth&&r.style.maxWidth!==this.options.maxWidth&&(r.style.maxWidth=this.options.maxWidth),i.transform.renderWorldCopies&&!this._trackPointer&&(this._lngLat=Dl(this._lngLat,this._pos,i.transform)),!this._trackPointer||t){const n=this._pos=this._trackPointer&&t instanceof e.P?t:i.project(this._lngLat,this._altitude),r=Ql(this.options.offset),o=this._anchor=this._getAnchor(r.y),s=Ql(this.options.offset,o),a=n.add(s).round();i._requestDomTask(()=>{this._container&&o&&(this._container.style.transform=`${Ol[o]} translate(${a.x}px,${a.y}px)`)})}if(!this._marker&&i._showingGlobe()){const t=e.f4(i.transform,this._lngLat)?0:1;this._setOpacity(t)}this._updateClassList()}_focusFirstElement(){if(!this.options.focusAfterOpen||!this._container)return;const e=this._container.querySelector(Hl);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:Ul,Style:In,LngLat:e.aS,LngLatBounds:e.aI,Point:e.P,MercatorCoordinate:e.ae,FreeCameraOptions:tn,Evented:e.E,config:e.e,prewarm:e.f8,clearPrewarmedResources:e.f7,get accessToken(){return e.e.ACCESS_TOKEN},set accessToken(t){e.e.ACCESS_TOKEN=t},get baseApiUrl(){return e.e.API_URL},set baseApiUrl(t){e.e.API_URL=t},get workerCount(){return e.fh.workerCount},set workerCount(t){e.fh.workerCount=t},get maxParallelImageRequests(){return e.e.MAX_PARALLEL_IMAGE_REQUESTS},set maxParallelImageRequests(t){e.e.MAX_PARALLEL_IMAGE_REQUESTS=t},clearStorage(t){e.fg(t)},get workerUrl(){return e.ff.workerUrl},set workerUrl(t){e.ff.workerUrl=t},get workerClass(){return e.ff.workerClass},set workerClass(t){e.ff.workerClass=t},get workerParams(){return e.ff.workerParams},set workerParams(t){e.ff.workerParams=t},get dracoUrl(){return e.fe()},set dracoUrl(t){e.fd(t)},get meshoptUrl(){return e.fc()},set meshoptUrl(t){e.fb(t)},setNow:e.o.setNow,restoreNow:e.o.restoreNow};return $l});var r=i;return r}();var Ze=He($e.exports),We=e({__proto__:null,default:Ze},[$e.exports]),qe={exports:{}};qe.exports=function(){var e={},t={};function i(i,n,r){if(t[i]=r,"index"===i){var o="var sharedModule = {}; ("+t.shared+")(sharedModule); ("+t.worker+")(sharedModule);",s={};return t.shared(s),t.index(e,s),"undefined"!=typeof window&&e.setWorkerUrl(window.URL.createObjectURL(new Blob([o],{type:"text/javascript"}))),e}}i("shared",["exports"],function(e){function t(e,t,i,n){return new(i||(i=Promise))(function(r,o){function s(e){try{l(n.next(e))}catch(e){o(e)}}function a(e){try{l(n.throw(e))}catch(e){o(e)}}function l(e){var t;e.done?r(e.value):(t=e.value,t instanceof i?t:new i(function(e){e(t)})).then(s,a)}l((n=n.apply(e,t||[])).next())})}function i(e,t){this.x=e,this.y=t}function n(e){return e&&e.__esModule&&Object.prototype.hasOwnProperty.call(e,"default")?e.default:e}var r,o;"function"==typeof SuppressedError&&SuppressedError,i.prototype={clone(){return new i(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:i},i.convert=function(e){if(e instanceof i)return e;if(Array.isArray(e))return new i(+e[0],+e[1]);if(void 0!==e.x&&void 0!==e.y)return new i(+e.x,+e.y);throw new Error("Expected [x, y] or {x, y} point format")};var s=function(){if(o)return r;function e(e,t,i,n){this.cx=3*e,this.bx=3*(i-e)-this.cx,this.ax=1-this.cx-this.bx,this.cy=3*t,this.by=3*(n-t)-this.cy,this.ay=1-this.cy-this.by,this.p1x=e,this.p1y=t,this.p2x=i,this.p2y=n}return o=1,r=e,e.prototype={sampleCurveX:function(e){return((this.ax*e+this.bx)*e+this.cx)*e},sampleCurveY:function(e){return((this.ay*e+this.by)*e+this.cy)*e},sampleCurveDerivativeX:function(e){return(3*this.ax*e+2*this.bx)*e+this.cx},solveCurveX:function(e,t){if(void 0===t&&(t=1e-6),e<0)return 0;if(e>1)return 1;for(var i=e,n=0;n<8;n++){var r=this.sampleCurveX(i)-e;if(Math.abs(r)r?s=i:a=i,i=.5*(a-s)+s;return i},solve:function(e,t){return this.sampleCurveY(this.solveCurveX(e,t))}},r}(),a=n(s);let l,c;function u(){return null==l&&(l="undefined"!=typeof OffscreenCanvas&&new OffscreenCanvas(1,1).getContext("2d")&&"function"==typeof createImageBitmap),l}function h(){if(null==c&&(c=!1,u())){const e=5,t=new OffscreenCanvas(e,e).getContext("2d",{willReadFrequently:!0});if(t){for(let i=0;i4&&void 0!==arguments[4]?arguments[4]:"zyx",o=Math.PI/360;t*=o,n*=o,i*=o;var s=Math.sin(t),a=Math.cos(t),l=Math.sin(i),c=Math.cos(i),u=Math.sin(n),h=Math.cos(n);switch(r){case"xyz":e[0]=s*c*h+a*l*u,e[1]=a*l*h-s*c*u,e[2]=a*c*u+s*l*h,e[3]=a*c*h-s*l*u;break;case"xzy":e[0]=s*c*h-a*l*u,e[1]=a*l*h-s*c*u,e[2]=a*c*u+s*l*h,e[3]=a*c*h+s*l*u;break;case"yxz":e[0]=s*c*h+a*l*u,e[1]=a*l*h-s*c*u,e[2]=a*c*u-s*l*h,e[3]=a*c*h+s*l*u;break;case"yzx":e[0]=s*c*h+a*l*u,e[1]=a*l*h+s*c*u,e[2]=a*c*u-s*l*h,e[3]=a*c*h-s*l*u;break;case"zxy":e[0]=s*c*h-a*l*u,e[1]=a*l*h+s*c*u,e[2]=a*c*u+s*l*h,e[3]=a*c*h-s*l*u;break;case"zyx":e[0]=s*c*h-a*l*u,e[1]=a*l*h+s*c*u,e[2]=a*c*u-s*l*h,e[3]=a*c*h+s*l*u;break;default:throw new Error("Unknown angle order "+r)}return e}function S(){var e=new p(2);return p!=Float32Array&&(e[0]=0,e[1]=0),e}function B(e,t){var i=new p(2);return i[0]=e,i[1]=t,i}g(),b=new p(4),p!=Float32Array&&(b[0]=0,b[1]=0,b[2]=0,b[3]=0),g(),A(1,0,0),A(0,1,0),E(),E(),f(),S();const I=8192;function M(e,t,i){return t*(I/(e.tileSize*Math.pow(2,i-e.tileID.overscaledZ)))}function P(e,t){return(e%t+t)%t}function R(e,t,i){return e*(1-i)+t*i}function L(e){if(e<=0)return 0;if(e>=1)return 1;const t=e*e,i=t*e;return 4*(e<.5?i:3*(e-t)+i-.75)}function F(e,t,i,n){const r=new a(e,t,i,n);return e=>r.solve(e)}const k=F(.25,.1,.25,1);function D(e,t,i){return Math.min(i,Math.max(t,e))}function O(e,t,i){const n=i-t,r=((e-t)%n+n)%n+t;return r===t?i:r}function z(e,...t){for(const i of t)for(const t in i)e[t]=i[t];return e}let U=1;function N(e,t,i){const n={};for(const i in e)n[i]=t.call(this,e[i],i,e);return n}function V(e,t,i){const n={};for(const i in e)t.call(this,e[i],i,e)&&(n[i]=e[i]);return n}function j(e){return Array.isArray(e)?e.map(j):"object"==typeof e&&e?N(e,j):e}const G={};function H(e){G[e]||("undefined"!=typeof console&&console.warn(e),G[e]=!0)}function Q(e,t,i){return(i.y-e.y)*(t.x-e.x)>(t.y-e.y)*(i.x-e.x)}function $(e){return"undefined"!=typeof WorkerGlobalScope&&void 0!==e&&e instanceof WorkerGlobalScope}let Z=null;function W(e){return"undefined"!=typeof ImageBitmap&&e instanceof ImageBitmap}const q="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAYAAAAfFcSJAAAAC0lEQVQYV2NgAAIAAAUAAarVyFEAAAAASUVORK5CYII=";function K(e,i,n,r,o){return t(this,void 0,void 0,function*(){if("undefined"==typeof VideoFrame)throw new Error("VideoFrame not supported");const t=new VideoFrame(e,{timestamp:0});try{const s=null==t?void 0:t.format;if(!s||!s.startsWith("BGR")&&!s.startsWith("RGB"))throw new Error(`Unrecognized format ${s}`);const a=s.startsWith("BGR"),l=new Uint8ClampedArray(r*o*4);if(yield t.copyTo(l,function(e,t,i,n,r){const o=4*Math.max(-t,0),s=(Math.max(0,i)-i)*n*4+o,a=4*n,l=Math.max(0,t),c=Math.max(0,i);return{rect:{x:l,y:c,width:Math.min(e.width,t+n)-l,height:Math.min(e.height,i+r)-c},layout:[{offset:s,stride:a}]}}(e,i,n,r,o)),a)for(let e=0;e{e.removeEventListener(t,i,n)}}}function ee(e){return e*Math.PI/180}function te(e){return e/Math.PI*180}const ie={touchstart:!0,touchmove:!0,touchmoveWindow:!0,touchend:!0,touchcancel:!0},ne={dblclick:!0,click:!0,mouseover:!0,mouseout:!0,mousedown:!0,mousemove:!0,mousemoveWindow:!0,mouseup:!0,mouseupWindow:!0,contextmenu:!0,wheel:!0},re="AbortError";function oe(){return new Error(re)}const se={MAX_PARALLEL_IMAGE_REQUESTS:16,MAX_PARALLEL_IMAGE_REQUESTS_PER_FRAME:8,MAX_TILE_CACHE_ZOOM_LEVELS:5,REGISTERED_PROTOCOLS:{},WORKER_URL:""};function ae(e){return se.REGISTERED_PROTOCOLS[e.substring(0,e.indexOf("://"))]}const le="global-dispatcher";class ce extends Error{constructor(e,t,i,n){super(`AJAXError: ${t} (${e}): ${i}`),this.status=e,this.statusText=t,this.url=i,this.body=n}}const ue=()=>$(self)?self.worker&&self.worker.referrer:("blob:"===window.location.protocol?window.parent:window).location.href,he=function(e,i){if(/:\/\//.test(e.url)&&!/^https?:|^file:/.test(e.url)){const t=ae(e.url);if(t)return t(e,i);if($(self)&&self.worker&&self.worker.actor)return self.worker.actor.sendAsync({type:"GR",data:e,targetMapId:le},i)}if(!(/^file:/.test(n=e.url)||/^file:/.test(ue())&&!/^\w+:/.test(n))){if(fetch&&Request&&AbortController&&Object.prototype.hasOwnProperty.call(Request.prototype,"signal"))return function(e,i){return t(this,void 0,void 0,function*(){const t=new Request(e.url,{method:e.method||"GET",body:e.body,credentials:e.credentials,headers:e.headers,cache:e.cache,referrer:ue(),signal:i.signal});let n,r;"json"!==e.type||t.headers.has("Accept")||t.headers.set("Accept","application/json");try{n=yield fetch(t)}catch(t){throw new ce(0,t.message,e.url,new Blob)}if(!n.ok){const t=yield n.blob();throw new ce(n.status,n.statusText,e.url,t)}r="arrayBuffer"===e.type||"image"===e.type?n.arrayBuffer():"json"===e.type?n.json():n.text();const o=yield r;if(i.signal.aborted)throw oe();return{data:o,cacheControl:n.headers.get("Cache-Control"),expires:n.headers.get("Expires")}})}(e,i);if($(self)&&self.worker&&self.worker.actor)return self.worker.actor.sendAsync({type:"GR",data:e,mustQueue:!0,targetMapId:le},i)}var n;return function(e,t){return new Promise((i,n)=>{var r;const o=new XMLHttpRequest;o.open(e.method||"GET",e.url,!0),"arrayBuffer"!==e.type&&"image"!==e.type||(o.responseType="arraybuffer");for(const t in e.headers)o.setRequestHeader(t,e.headers[t]);"json"===e.type&&(o.responseType="text",(null===(r=e.headers)||void 0===r?void 0:r.Accept)||o.setRequestHeader("Accept","application/json")),o.withCredentials="include"===e.credentials,o.onerror=()=>{n(new Error(o.statusText))},o.onload=()=>{if(!t.signal.aborted)if((o.status>=200&&o.status<300||0===o.status)&&null!==o.response){let t=o.response;if("json"===e.type)try{t=JSON.parse(o.response)}catch(e){return void n(e)}i({data:t,cacheControl:o.getResponseHeader("Cache-Control"),expires:o.getResponseHeader("Expires")})}else{const t=new Blob([o.response],{type:o.getResponseHeader("Content-Type")});n(new ce(o.status,o.statusText,e.url,t))}},t.signal.addEventListener("abort",()=>{o.abort(),n(oe())}),o.send(e.body)})}(e,i)};function de(e){if(!e||e.indexOf("://")<=0||0===e.indexOf("data:image/")||0===e.indexOf("blob:"))return!0;const t=new URL(e),i=window.location;return t.protocol===i.protocol&&t.host===i.host}function pe(e,t,i){i[e]&&-1!==i[e].indexOf(t)||(i[e]=i[e]||[],i[e].push(t))}function fe(e,t,i){if(i&&i[e]){const n=i[e].indexOf(t);-1!==n&&i[e].splice(n,1)}}class me{constructor(e,t={}){z(this,t),this.type=e}}class ge extends me{constructor(e,t={}){super("error",z({error:e},t))}}class _e{on(e,t){return this._listeners=this._listeners||{},pe(e,t,this._listeners),{unsubscribe:()=>{this.off(e,t)}}}off(e,t){return fe(e,t,this._listeners),fe(e,t,this._oneTimeListeners),this}once(e,t){return t?(this._oneTimeListeners=this._oneTimeListeners||{},pe(e,t,this._oneTimeListeners),this):new Promise(t=>this.once(e,t))}fire(e,t){"string"==typeof e&&(e=new me(e,t||{}));const i=e.type;if(this.listens(i)){e.target=this;const t=this._listeners&&this._listeners[i]?this._listeners[i].slice():[];for(const i of t)i.call(this,e);const n=this._oneTimeListeners&&this._oneTimeListeners[i]?this._oneTimeListeners[i].slice():[];for(const t of n)fe(i,t,this._oneTimeListeners),t.call(this,e);const r=this._eventedParent;r&&(z(e,"function"==typeof this._eventedParentData?this._eventedParentData():this._eventedParentData),r.fire(e))}else e instanceof ge&&console.error(e.error);return this}listens(e){return this._listeners&&this._listeners[e]&&this._listeners[e].length>0||this._oneTimeListeners&&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}}var Ae={$version:8,$root:{version:{required:!0,type:"enum",values:[8]},name:{type:"string"},metadata:{type:"*"},center:{type:"array",value:"number"},centerAltitude:{type:"number"},zoom:{type:"number"},bearing:{type:"number",default:0,period:360,units:"degrees"},pitch:{type:"number",default:0,units:"degrees"},roll:{type:"number",default:0,units:"degrees"},state:{type:"state",default:{}},light:{type:"light"},sky:{type:"sky"},projection:{type:"projection"},terrain:{type:"terrain"},sources:{required:!0,type:"sources"},sprite:{type:"sprite"},glyphs:{type:"string"},"font-faces":{type:"array",value:"fontFaces"},transition:{type:"transition"},layers:{required:!0,type:"array",value:"layer"}},sources:{"*":{type:"source"}},source:["source_vector","source_raster","source_raster_dem","source_geojson","source_video","source_image"],source_vector:{type:{required:!0,type:"enum",values:{vector:{}}},url:{type:"string"},tiles:{type:"array",value:"string"},bounds:{type:"array",value:"number",length:4,default:[-180,-85.051129,180,85.051129]},scheme:{type:"enum",values:{xyz:{},tms:{}},default:"xyz"},minzoom:{type:"number",default:0},maxzoom:{type:"number",default:22},attribution:{type:"string"},promoteId:{type:"promoteId"},volatile:{type:"boolean",default:!1},encoding:{type:"enum",values:{mvt:{},mlt:{}},default:"mvt"},"*":{type:"*"}},source_raster:{type:{required:!0,type:"enum",values:{raster:{}}},url:{type:"string"},tiles:{type:"array",value:"string"},bounds:{type:"array",value:"number",length:4,default:[-180,-85.051129,180,85.051129]},minzoom:{type:"number",default:0},maxzoom:{type:"number",default:22},tileSize:{type:"number",default:512,units:"pixels"},scheme:{type:"enum",values:{xyz:{},tms:{}},default:"xyz"},attribution:{type:"string"},volatile:{type:"boolean",default:!1},"*":{type:"*"}},source_raster_dem:{type:{required:!0,type:"enum",values:{"raster-dem":{}}},url:{type:"string"},tiles:{type:"array",value:"string"},bounds:{type:"array",value:"number",length:4,default:[-180,-85.051129,180,85.051129]},minzoom:{type:"number",default:0},maxzoom:{type:"number",default:22},tileSize:{type:"number",default:512,units:"pixels"},attribution:{type:"string"},encoding:{type:"enum",values:{terrarium:{},mapbox:{},custom:{}},default:"mapbox"},redFactor:{type:"number",default:1},blueFactor:{type:"number",default:1},greenFactor:{type:"number",default:1},baseShift:{type:"number",default:0},volatile:{type:"boolean",default:!1},"*":{type:"*"}},source_geojson:{type:{required:!0,type:"enum",values:{geojson:{}}},data:{required:!0,type:"*"},maxzoom:{type:"number",default:18},attribution:{type:"string"},buffer:{type:"number",default:128,maximum:512,minimum:0},filter:{type:"*"},tolerance:{type:"number",default:.375},cluster:{type:"boolean",default:!1},clusterRadius:{type:"number",default:50,minimum:0},clusterMaxZoom:{type:"number"},clusterMinPoints:{type:"number"},clusterProperties:{type:"*"},lineMetrics:{type:"boolean",default:!1},generateId:{type:"boolean",default:!1},promoteId:{type:"promoteId"}},source_video:{type:{required:!0,type:"enum",values:{video:{}}},urls:{required:!0,type:"array",value:"string"},coordinates:{required:!0,type:"array",length:4,value:{type:"array",length:2,value:"number"}}},source_image:{type:{required:!0,type:"enum",values:{image:{}}},url:{required:!0,type:"string"},coordinates:{required:!0,type:"array",length:4,value:{type:"array",length:2,value:"number"}}},layer:{id:{type:"string",required:!0},type:{type:"enum",values:{fill:{},line:{},symbol:{},circle:{},heatmap:{},"fill-extrusion":{},raster:{},hillshade:{},"color-relief":{},background:{}},required:!0},metadata:{type:"*"},source:{type:"string"},"source-layer":{type:"string"},minzoom:{type:"number",minimum:0,maximum:24},maxzoom:{type:"number",minimum:0,maximum:24},filter:{type:"filter"},layout:{type:"layout"},paint:{type:"paint"}},layout:["layout_fill","layout_line","layout_circle","layout_heatmap","layout_fill-extrusion","layout_symbol","layout_raster","layout_hillshade","layout_color-relief","layout_background"],layout_background:{visibility:{type:"enum",values:{visible:{},none:{}},default:"visible","property-type":"constant"}},layout_fill:{"fill-sort-key":{type:"number",expression:{interpolated:!1,parameters:["zoom","feature"]},"property-type":"data-driven"},visibility:{type:"enum",values:{visible:{},none:{}},default:"visible","property-type":"constant"}},layout_circle:{"circle-sort-key":{type:"number",expression:{interpolated:!1,parameters:["zoom","feature"]},"property-type":"data-driven"},visibility:{type:"enum",values:{visible:{},none:{}},default:"visible","property-type":"constant"}},layout_heatmap:{visibility:{type:"enum",values:{visible:{},none:{}},default:"visible","property-type":"constant"}},"layout_fill-extrusion":{visibility:{type:"enum",values:{visible:{},none:{}},default:"visible","property-type":"constant"}},layout_line:{"line-cap":{type:"enum",values:{butt:{},round:{},square:{}},default:"butt",expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"},"line-join":{type:"enum",values:{bevel:{},round:{},miter:{}},default:"miter",expression:{interpolated:!1,parameters:["zoom","feature"]},"property-type":"data-driven"},"line-miter-limit":{type:"number",default:2,requires:[{"line-join":"miter"}],expression:{interpolated:!0,parameters:["zoom"]},"property-type":"data-constant"},"line-round-limit":{type:"number",default:1.05,requires:[{"line-join":"round"}],expression:{interpolated:!0,parameters:["zoom"]},"property-type":"data-constant"},"line-sort-key":{type:"number",expression:{interpolated:!1,parameters:["zoom","feature"]},"property-type":"data-driven"},visibility:{type:"enum",values:{visible:{},none:{}},default:"visible","property-type":"constant"}},layout_symbol:{"symbol-placement":{type:"enum",values:{point:{},line:{},"line-center":{}},default:"point",expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"},"symbol-spacing":{type:"number",default:250,minimum:1,units:"pixels",requires:[{"symbol-placement":"line"}],expression:{interpolated:!0,parameters:["zoom"]},"property-type":"data-constant"},"symbol-avoid-edges":{type:"boolean",default:!1,expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"},"symbol-sort-key":{type:"number",expression:{interpolated:!1,parameters:["zoom","feature"]},"property-type":"data-driven"},"symbol-z-order":{type:"enum",values:{auto:{},"viewport-y":{},source:{}},default:"auto",expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"},"icon-allow-overlap":{type:"boolean",default:!1,requires:["icon-image",{"!":"icon-overlap"}],expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"},"icon-overlap":{type:"enum",values:{never:{},always:{},cooperative:{}},requires:["icon-image"],expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"},"icon-ignore-placement":{type:"boolean",default:!1,requires:["icon-image"],expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"},"icon-optional":{type:"boolean",default:!1,requires:["icon-image","text-field"],expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"},"icon-rotation-alignment":{type:"enum",values:{map:{},viewport:{},auto:{}},default:"auto",requires:["icon-image"],expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"},"icon-size":{type:"number",default:1,minimum:0,units:"factor of the original icon size",requires:["icon-image"],expression:{interpolated:!0,parameters:["zoom","feature"]},"property-type":"data-driven"},"icon-text-fit":{type:"enum",values:{none:{},width:{},height:{},both:{}},default:"none",requires:["icon-image","text-field"],expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"},"icon-text-fit-padding":{type:"array",value:"number",length:4,default:[0,0,0,0],units:"pixels",requires:["icon-image","text-field",{"icon-text-fit":["both","width","height"]}],expression:{interpolated:!0,parameters:["zoom"]},"property-type":"data-constant"},"icon-image":{type:"resolvedImage",tokens:!0,expression:{interpolated:!1,parameters:["zoom","feature"]},"property-type":"data-driven"},"icon-rotate":{type:"number",default:0,period:360,units:"degrees",requires:["icon-image"],expression:{interpolated:!0,parameters:["zoom","feature"]},"property-type":"data-driven"},"icon-padding":{type:"padding",default:[2],units:"pixels",requires:["icon-image"],expression:{interpolated:!0,parameters:["zoom","feature"]},"property-type":"data-driven"},"icon-keep-upright":{type:"boolean",default:!1,requires:["icon-image",{"icon-rotation-alignment":"map"},{"symbol-placement":["line","line-center"]}],expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"},"icon-offset":{type:"array",value:"number",length:2,default:[0,0],requires:["icon-image"],expression:{interpolated:!0,parameters:["zoom","feature"]},"property-type":"data-driven"},"icon-anchor":{type:"enum",values:{center:{},left:{},right:{},top:{},bottom:{},"top-left":{},"top-right":{},"bottom-left":{},"bottom-right":{}},default:"center",requires:["icon-image"],expression:{interpolated:!1,parameters:["zoom","feature"]},"property-type":"data-driven"},"icon-pitch-alignment":{type:"enum",values:{map:{},viewport:{},auto:{}},default:"auto",requires:["icon-image"],expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"},"text-pitch-alignment":{type:"enum",values:{map:{},viewport:{},auto:{}},default:"auto",requires:["text-field"],expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"},"text-rotation-alignment":{type:"enum",values:{map:{},viewport:{},"viewport-glyph":{},auto:{}},default:"auto",requires:["text-field"],expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"},"text-field":{type:"formatted",default:"",tokens:!0,expression:{interpolated:!1,parameters:["zoom","feature"]},"property-type":"data-driven"},"text-font":{type:"array",value:"string",default:["Open Sans Regular","Arial Unicode MS Regular"],requires:["text-field"],expression:{interpolated:!1,parameters:["zoom","feature"]},"property-type":"data-driven"},"text-size":{type:"number",default:16,minimum:0,units:"pixels",requires:["text-field"],expression:{interpolated:!0,parameters:["zoom","feature"]},"property-type":"data-driven"},"text-max-width":{type:"number",default:10,minimum:0,units:"ems",requires:["text-field"],expression:{interpolated:!0,parameters:["zoom","feature"]},"property-type":"data-driven"},"text-line-height":{type:"number",default:1.2,units:"ems",requires:["text-field"],expression:{interpolated:!0,parameters:["zoom"]},"property-type":"data-constant"},"text-letter-spacing":{type:"number",default:0,units:"ems",requires:["text-field"],expression:{interpolated:!0,parameters:["zoom","feature"]},"property-type":"data-driven"},"text-justify":{type:"enum",values:{auto:{},left:{},center:{},right:{}},default:"center",requires:["text-field"],expression:{interpolated:!1,parameters:["zoom","feature"]},"property-type":"data-driven"},"text-radial-offset":{type:"number",units:"ems",default:0,requires:["text-field"],"property-type":"data-driven",expression:{interpolated:!0,parameters:["zoom","feature"]}},"text-variable-anchor":{type:"array",value:"enum",values:{center:{},left:{},right:{},top:{},bottom:{},"top-left":{},"top-right":{},"bottom-left":{},"bottom-right":{}},requires:["text-field",{"symbol-placement":["point"]}],expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"},"text-variable-anchor-offset":{type:"variableAnchorOffsetCollection",requires:["text-field",{"symbol-placement":["point"]}],expression:{interpolated:!0,parameters:["zoom","feature"]},"property-type":"data-driven"},"text-anchor":{type:"enum",values:{center:{},left:{},right:{},top:{},bottom:{},"top-left":{},"top-right":{},"bottom-left":{},"bottom-right":{}},default:"center",requires:["text-field",{"!":"text-variable-anchor"}],expression:{interpolated:!1,parameters:["zoom","feature"]},"property-type":"data-driven"},"text-max-angle":{type:"number",default:45,units:"degrees",requires:["text-field",{"symbol-placement":["line","line-center"]}],expression:{interpolated:!0,parameters:["zoom"]},"property-type":"data-constant"},"text-writing-mode":{type:"array",value:"enum",values:{horizontal:{},vertical:{}},requires:["text-field",{"symbol-placement":["point"]}],expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"},"text-rotate":{type:"number",default:0,period:360,units:"degrees",requires:["text-field"],expression:{interpolated:!0,parameters:["zoom","feature"]},"property-type":"data-driven"},"text-padding":{type:"number",default:2,minimum:0,units:"pixels",requires:["text-field"],expression:{interpolated:!0,parameters:["zoom"]},"property-type":"data-constant"},"text-keep-upright":{type:"boolean",default:!0,requires:["text-field",{"text-rotation-alignment":"map"},{"symbol-placement":["line","line-center"]}],expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"},"text-transform":{type:"enum",values:{none:{},uppercase:{},lowercase:{}},default:"none",requires:["text-field"],expression:{interpolated:!1,parameters:["zoom","feature"]},"property-type":"data-driven"},"text-offset":{type:"array",value:"number",units:"ems",length:2,default:[0,0],requires:["text-field",{"!":"text-radial-offset"}],expression:{interpolated:!0,parameters:["zoom","feature"]},"property-type":"data-driven"},"text-allow-overlap":{type:"boolean",default:!1,requires:["text-field",{"!":"text-overlap"}],expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"},"text-overlap":{type:"enum",values:{never:{},always:{},cooperative:{}},requires:["text-field"],expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"},"text-ignore-placement":{type:"boolean",default:!1,requires:["text-field"],expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"},"text-optional":{type:"boolean",default:!1,requires:["text-field","icon-image"],expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"},visibility:{type:"enum",values:{visible:{},none:{}},default:"visible","property-type":"constant"}},layout_raster:{visibility:{type:"enum",values:{visible:{},none:{}},default:"visible","property-type":"constant"}},layout_hillshade:{visibility:{type:"enum",values:{visible:{},none:{}},default:"visible","property-type":"constant"}},"layout_color-relief":{visibility:{type:"enum",values:{visible:{},none:{}},default:"visible","property-type":"constant"}},filter:{type:"array",value:"*"},filter_operator:{type:"enum",values:{"==":{},"!=":{},">":{},">=":{},"<":{},"<=":{},in:{},"!in":{},all:{},any:{},none:{},has:{},"!has":{}}},geometry_type:{type:"enum",values:{Point:{},LineString:{},Polygon:{}}},function:{expression:{type:"expression"},stops:{type:"array",value:"function_stop"},base:{type:"number",default:1,minimum:0},property:{type:"string",default:"$zoom"},type:{type:"enum",values:{identity:{},exponential:{},interval:{},categorical:{}},default:"exponential"},colorSpace:{type:"enum",values:{rgb:{},lab:{},hcl:{}},default:"rgb"},default:{type:"*",required:!1}},function_stop:{type:"array",minimum:0,maximum:24,value:["number","color"],length:2},expression:{type:"array",value:"*",minimum:1},light:{anchor:{type:"enum",default:"viewport",values:{map:{},viewport:{}},"property-type":"data-constant",transition:!1,expression:{interpolated:!1,parameters:["zoom"]}},position:{type:"array",default:[1.15,210,30],length:3,value:"number","property-type":"data-constant",transition:!0,expression:{interpolated:!0,parameters:["zoom"]}},color:{type:"color","property-type":"data-constant",default:"#ffffff",expression:{interpolated:!0,parameters:["zoom"]},transition:!0},intensity:{type:"number","property-type":"data-constant",default:.5,minimum:0,maximum:1,expression:{interpolated:!0,parameters:["zoom"]},transition:!0}},sky:{"sky-color":{type:"color","property-type":"data-constant",default:"#88C6FC",expression:{interpolated:!0,parameters:["zoom"]},transition:!0},"horizon-color":{type:"color","property-type":"data-constant",default:"#ffffff",expression:{interpolated:!0,parameters:["zoom"]},transition:!0},"fog-color":{type:"color","property-type":"data-constant",default:"#ffffff",expression:{interpolated:!0,parameters:["zoom"]},transition:!0},"fog-ground-blend":{type:"number","property-type":"data-constant",default:.5,minimum:0,maximum:1,expression:{interpolated:!0,parameters:["zoom"]},transition:!0},"horizon-fog-blend":{type:"number","property-type":"data-constant",default:.8,minimum:0,maximum:1,expression:{interpolated:!0,parameters:["zoom"]},transition:!0},"sky-horizon-blend":{type:"number","property-type":"data-constant",default:.8,minimum:0,maximum:1,expression:{interpolated:!0,parameters:["zoom"]},transition:!0},"atmosphere-blend":{type:"number","property-type":"data-constant",default:.8,minimum:0,maximum:1,expression:{interpolated:!0,parameters:["zoom"]},transition:!0}},terrain:{source:{type:"string",required:!0},exaggeration:{type:"number",minimum:0,default:1}},projection:{type:{type:"projectionDefinition",default:"mercator","property-type":"data-constant",transition:!1,expression:{interpolated:!0,parameters:["zoom"]}}},paint:["paint_fill","paint_line","paint_circle","paint_heatmap","paint_fill-extrusion","paint_symbol","paint_raster","paint_hillshade","paint_color-relief","paint_background"],paint_fill:{"fill-antialias":{type:"boolean",default:!0,expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"},"fill-opacity":{type:"number",default:1,minimum:0,maximum:1,transition:!0,expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"},"fill-color":{type:"color",default:"#000000",transition:!0,requires:[{"!":"fill-pattern"}],expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"},"fill-outline-color":{type:"color",transition:!0,requires:[{"!":"fill-pattern"},{"fill-antialias":!0}],expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"},"fill-translate":{type:"array",value:"number",length:2,default:[0,0],transition:!0,units:"pixels",expression:{interpolated:!0,parameters:["zoom"]},"property-type":"data-constant"},"fill-translate-anchor":{type:"enum",values:{map:{},viewport:{}},default:"map",requires:["fill-translate"],expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"},"fill-pattern":{type:"resolvedImage",transition:!0,expression:{interpolated:!1,parameters:["zoom","feature"]},"property-type":"cross-faded-data-driven"}},"paint_fill-extrusion":{"fill-extrusion-opacity":{type:"number",default:1,minimum:0,maximum:1,transition:!0,expression:{interpolated:!0,parameters:["zoom"]},"property-type":"data-constant"},"fill-extrusion-color":{type:"color",default:"#000000",transition:!0,requires:[{"!":"fill-extrusion-pattern"}],expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"},"fill-extrusion-translate":{type:"array",value:"number",length:2,default:[0,0],transition:!0,units:"pixels",expression:{interpolated:!0,parameters:["zoom"]},"property-type":"data-constant"},"fill-extrusion-translate-anchor":{type:"enum",values:{map:{},viewport:{}},default:"map",requires:["fill-extrusion-translate"],expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"},"fill-extrusion-pattern":{type:"resolvedImage",transition:!0,expression:{interpolated:!1,parameters:["zoom","feature"]},"property-type":"cross-faded-data-driven"},"fill-extrusion-height":{type:"number",default:0,minimum:0,units:"meters",transition:!0,expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"},"fill-extrusion-base":{type:"number",default:0,minimum:0,units:"meters",transition:!0,requires:["fill-extrusion-height"],expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"},"fill-extrusion-vertical-gradient":{type:"boolean",default:!0,transition:!1,expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"}},paint_line:{"line-opacity":{type:"number",default:1,minimum:0,maximum:1,transition:!0,expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"},"line-color":{type:"color",default:"#000000",transition:!0,requires:[{"!":"line-pattern"}],expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"},"line-translate":{type:"array",value:"number",length:2,default:[0,0],transition:!0,units:"pixels",expression:{interpolated:!0,parameters:["zoom"]},"property-type":"data-constant"},"line-translate-anchor":{type:"enum",values:{map:{},viewport:{}},default:"map",requires:["line-translate"],expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"},"line-width":{type:"number",default:1,minimum:0,transition:!0,units:"pixels",expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"},"line-gap-width":{type:"number",default:0,minimum:0,transition:!0,units:"pixels",expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"},"line-offset":{type:"number",default:0,transition:!0,units:"pixels",expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"},"line-blur":{type:"number",default:0,minimum:0,transition:!0,units:"pixels",expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"},"line-dasharray":{type:"array",value:"number",minimum:0,transition:!0,units:"line widths",requires:[{"!":"line-pattern"}],expression:{interpolated:!1,parameters:["zoom","feature"]},"property-type":"cross-faded-data-driven"},"line-pattern":{type:"resolvedImage",transition:!0,expression:{interpolated:!1,parameters:["zoom","feature"]},"property-type":"cross-faded-data-driven"},"line-gradient":{type:"color",transition:!1,requires:[{"!":"line-dasharray"},{"!":"line-pattern"},{source:"geojson",has:{lineMetrics:!0}}],expression:{interpolated:!0,parameters:["line-progress"]},"property-type":"color-ramp"}},paint_circle:{"circle-radius":{type:"number",default:5,minimum:0,transition:!0,units:"pixels",expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"},"circle-color":{type:"color",default:"#000000",transition:!0,expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"},"circle-blur":{type:"number",default:0,transition:!0,expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"},"circle-opacity":{type:"number",default:1,minimum:0,maximum:1,transition:!0,expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"},"circle-translate":{type:"array",value:"number",length:2,default:[0,0],transition:!0,units:"pixels",expression:{interpolated:!0,parameters:["zoom"]},"property-type":"data-constant"},"circle-translate-anchor":{type:"enum",values:{map:{},viewport:{}},default:"map",requires:["circle-translate"],expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"},"circle-pitch-scale":{type:"enum",values:{map:{},viewport:{}},default:"map",expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"},"circle-pitch-alignment":{type:"enum",values:{map:{},viewport:{}},default:"viewport",expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"},"circle-stroke-width":{type:"number",default:0,minimum:0,transition:!0,units:"pixels",expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"},"circle-stroke-color":{type:"color",default:"#000000",transition:!0,expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"},"circle-stroke-opacity":{type:"number",default:1,minimum:0,maximum:1,transition:!0,expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"}},paint_heatmap:{"heatmap-radius":{type:"number",default:30,minimum:1,transition:!0,units:"pixels",expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"},"heatmap-weight":{type:"number",default:1,minimum:0,transition:!1,expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"},"heatmap-intensity":{type:"number",default:1,minimum:0,transition:!0,expression:{interpolated:!0,parameters:["zoom"]},"property-type":"data-constant"},"heatmap-color":{type:"color",default:["interpolate",["linear"],["heatmap-density"],0,"rgba(0, 0, 255, 0)",.1,"royalblue",.3,"cyan",.5,"lime",.7,"yellow",1,"red"],transition:!1,expression:{interpolated:!0,parameters:["heatmap-density"]},"property-type":"color-ramp"},"heatmap-opacity":{type:"number",default:1,minimum:0,maximum:1,transition:!0,expression:{interpolated:!0,parameters:["zoom"]},"property-type":"data-constant"}},paint_symbol:{"icon-opacity":{type:"number",default:1,minimum:0,maximum:1,transition:!0,requires:["icon-image"],expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"},"icon-color":{type:"color",default:"#000000",transition:!0,requires:["icon-image"],expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"},"icon-halo-color":{type:"color",default:"rgba(0, 0, 0, 0)",transition:!0,requires:["icon-image"],expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"},"icon-halo-width":{type:"number",default:0,minimum:0,transition:!0,units:"pixels",requires:["icon-image"],expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"},"icon-halo-blur":{type:"number",default:0,minimum:0,transition:!0,units:"pixels",requires:["icon-image"],expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"},"icon-translate":{type:"array",value:"number",length:2,default:[0,0],transition:!0,units:"pixels",requires:["icon-image"],expression:{interpolated:!0,parameters:["zoom"]},"property-type":"data-constant"},"icon-translate-anchor":{type:"enum",values:{map:{},viewport:{}},default:"map",requires:["icon-image","icon-translate"],expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"},"text-opacity":{type:"number",default:1,minimum:0,maximum:1,transition:!0,requires:["text-field"],expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"},"text-color":{type:"color",default:"#000000",transition:!0,overridable:!0,requires:["text-field"],expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"},"text-halo-color":{type:"color",default:"rgba(0, 0, 0, 0)",transition:!0,requires:["text-field"],expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"},"text-halo-width":{type:"number",default:0,minimum:0,transition:!0,units:"pixels",requires:["text-field"],expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"},"text-halo-blur":{type:"number",default:0,minimum:0,transition:!0,units:"pixels",requires:["text-field"],expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"},"text-translate":{type:"array",value:"number",length:2,default:[0,0],transition:!0,units:"pixels",requires:["text-field"],expression:{interpolated:!0,parameters:["zoom"]},"property-type":"data-constant"},"text-translate-anchor":{type:"enum",values:{map:{},viewport:{}},default:"map",requires:["text-field","text-translate"],expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"}},paint_raster:{"raster-opacity":{type:"number",default:1,minimum:0,maximum:1,transition:!0,expression:{interpolated:!0,parameters:["zoom"]},"property-type":"data-constant"},"raster-hue-rotate":{type:"number",default:0,period:360,transition:!0,units:"degrees",expression:{interpolated:!0,parameters:["zoom"]},"property-type":"data-constant"},"raster-brightness-min":{type:"number",default:0,minimum:0,maximum:1,transition:!0,expression:{interpolated:!0,parameters:["zoom"]},"property-type":"data-constant"},"raster-brightness-max":{type:"number",default:1,minimum:0,maximum:1,transition:!0,expression:{interpolated:!0,parameters:["zoom"]},"property-type":"data-constant"},"raster-saturation":{type:"number",default:0,minimum:-1,maximum:1,transition:!0,expression:{interpolated:!0,parameters:["zoom"]},"property-type":"data-constant"},"raster-contrast":{type:"number",default:0,minimum:-1,maximum:1,transition:!0,expression:{interpolated:!0,parameters:["zoom"]},"property-type":"data-constant"},"raster-resampling":{type:"enum",values:{linear:{},nearest:{}},default:"linear",expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"},"raster-fade-duration":{type:"number",default:300,minimum:0,transition:!1,units:"milliseconds",expression:{interpolated:!0,parameters:["zoom"]},"property-type":"data-constant"}},paint_hillshade:{"hillshade-illumination-direction":{type:"numberArray",default:335,minimum:0,maximum:359,transition:!1,expression:{interpolated:!0,parameters:["zoom"]},"property-type":"data-constant"},"hillshade-illumination-altitude":{type:"numberArray",default:45,minimum:0,maximum:90,transition:!1,expression:{interpolated:!0,parameters:["zoom"]},"property-type":"data-constant"},"hillshade-illumination-anchor":{type:"enum",values:{map:{},viewport:{}},default:"viewport",expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"},"hillshade-exaggeration":{type:"number",default:.5,minimum:0,maximum:1,transition:!0,expression:{interpolated:!0,parameters:["zoom"]},"property-type":"data-constant"},"hillshade-shadow-color":{type:"colorArray",default:"#000000",transition:!0,expression:{interpolated:!0,parameters:["zoom"]},"property-type":"data-constant"},"hillshade-highlight-color":{type:"colorArray",default:"#FFFFFF",transition:!0,expression:{interpolated:!0,parameters:["zoom"]},"property-type":"data-constant"},"hillshade-accent-color":{type:"color",default:"#000000",transition:!0,expression:{interpolated:!0,parameters:["zoom"]},"property-type":"data-constant"},"hillshade-method":{type:"enum",values:{standard:{},basic:{},combined:{},igor:{},multidirectional:{}},default:"standard",expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"}},"paint_color-relief":{"color-relief-opacity":{type:"number",default:1,minimum:0,maximum:1,transition:!0,expression:{interpolated:!0,parameters:["zoom"]},"property-type":"data-constant"},"color-relief-color":{type:"color",transition:!1,expression:{interpolated:!0,parameters:["elevation"]},"property-type":"color-ramp"}},paint_background:{"background-color":{type:"color",default:"#000000",transition:!0,requires:[{"!":"background-pattern"}],expression:{interpolated:!0,parameters:["zoom"]},"property-type":"data-constant"},"background-pattern":{type:"resolvedImage",transition:!0,expression:{interpolated:!1,parameters:["zoom"]},"property-type":"cross-faded"},"background-opacity":{type:"number",default:1,minimum:0,maximum:1,transition:!0,expression:{interpolated:!0,parameters:["zoom"]},"property-type":"data-constant"}},transition:{duration:{type:"number",default:300,minimum:0,units:"milliseconds"},delay:{type:"number",default:0,minimum:0,units:"milliseconds"}},"property-type":{"data-driven":{type:"property-type"},"cross-faded":{type:"property-type"},"cross-faded-data-driven":{type:"property-type"},"color-ramp":{type:"property-type"},"data-constant":{type:"property-type"},constant:{type:"property-type"}},promoteId:{"*":{type:"string"}}};const ye=["type","source","source-layer","minzoom","maxzoom","filter","layout"];function ve(e,t){const i={};for(const t in e)"ref"!==t&&(i[t]=e[t]);return ye.forEach(e=>{e in t&&(i[e]=t[e])}),i}function xe(e,t){if(Array.isArray(e)){if(!Array.isArray(t)||e.length!==t.length)return!1;for(let i=0;i`:"value"===e.itemType.kind?"array":`array<${t}>`}return e.kind}const Xe=[Fe,ke,De,Oe,ze,Ue,Ge,Ne,qe(Ve),He,$e,Qe,Ze,We];function Je(e,t){if("error"===t.kind)return null;if("array"===e.kind){if("array"===t.kind&&(0===t.N&&"value"===t.itemType.kind||!Je(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 Xe)if(!Je(e,t))return null}return`Expected ${Ke(e)} but found ${Ke(t)} instead.`}function Ye(e,t){return t.some(t=>t.kind===e.kind)}function et(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 tt(e,t){return"array"===e.kind&&"array"===t.kind?e.itemType.kind===t.itemType.kind&&"number"==typeof e.N:e.kind===t.kind}const it=.96422,nt=.82521,rt=4/29,ot=6/29,st=3*ot*ot,at=ot*ot*ot,lt=Math.PI/180,ct=180/Math.PI;function ut(e){return(e%=360)<0&&(e+=360),e}function ht([e,t,i,n]){let r,o;const s=pt((.2225045*(e=dt(e))+.7168786*(t=dt(t))+.0606169*(i=dt(i)))/1);e===t&&t===i?r=o=s:(r=pt((.4360747*e+.3850649*t+.1430804*i)/it),o=pt((.0139322*e+.0971045*t+.7141733*i)/nt));const a=116*s-16;return[a<0?0:a,500*(r-s),200*(s-o),n]}function dt(e){return e<=.04045?e/12.92:Math.pow((e+.055)/1.055,2.4)}function pt(e){return e>at?Math.pow(e,1/3):e/st+rt}function ft([e,t,i,n]){let r=(e+16)/116,o=isNaN(t)?r:r+t/500,s=isNaN(i)?r:r-i/200;return r=1*gt(r),o=it*gt(o),s=nt*gt(s),[mt(3.1338561*o-1.6168667*r-.4906146*s),mt(-.9787684*o+1.9161415*r+.033454*s),mt(.0719453*o-.2289914*r+1.4052427*s),n]}function mt(e){return(e=e<=.00304?12.92*e:1.055*Math.pow(e,1/2.4)-.055)<0?0:e>1?1:e}function gt(e){return e>ot?e*e*e:st*(e-rt)}const _t=Object.hasOwn||function(e,t){return Object.prototype.hasOwnProperty.call(e,t)};function At(e,t){return _t(e,t)?e[t]:void 0}function yt(e){return parseInt(e.padEnd(2,e),16)/255}function vt(e,t){return xt(t?e/100:e,0,1)}function xt(e,t,i){return Math.min(Math.max(t,e),i)}function bt(e){return!e.some(Number.isNaN)}const wt={aliceblue:[240,248,255],antiquewhite:[250,235,215],aqua:[0,255,255],aquamarine:[127,255,212],azure:[240,255,255],beige:[245,245,220],bisque:[255,228,196],black:[0,0,0],blanchedalmond:[255,235,205],blue:[0,0,255],blueviolet:[138,43,226],brown:[165,42,42],burlywood:[222,184,135],cadetblue:[95,158,160],chartreuse:[127,255,0],chocolate:[210,105,30],coral:[255,127,80],cornflowerblue:[100,149,237],cornsilk:[255,248,220],crimson:[220,20,60],cyan:[0,255,255],darkblue:[0,0,139],darkcyan:[0,139,139],darkgoldenrod:[184,134,11],darkgray:[169,169,169],darkgreen:[0,100,0],darkgrey:[169,169,169],darkkhaki:[189,183,107],darkmagenta:[139,0,139],darkolivegreen:[85,107,47],darkorange:[255,140,0],darkorchid:[153,50,204],darkred:[139,0,0],darksalmon:[233,150,122],darkseagreen:[143,188,143],darkslateblue:[72,61,139],darkslategray:[47,79,79],darkslategrey:[47,79,79],darkturquoise:[0,206,209],darkviolet:[148,0,211],deeppink:[255,20,147],deepskyblue:[0,191,255],dimgray:[105,105,105],dimgrey:[105,105,105],dodgerblue:[30,144,255],firebrick:[178,34,34],floralwhite:[255,250,240],forestgreen:[34,139,34],fuchsia:[255,0,255],gainsboro:[220,220,220],ghostwhite:[248,248,255],gold:[255,215,0],goldenrod:[218,165,32],gray:[128,128,128],green:[0,128,0],greenyellow:[173,255,47],grey:[128,128,128],honeydew:[240,255,240],hotpink:[255,105,180],indianred:[205,92,92],indigo:[75,0,130],ivory:[255,255,240],khaki:[240,230,140],lavender:[230,230,250],lavenderblush:[255,240,245],lawngreen:[124,252,0],lemonchiffon:[255,250,205],lightblue:[173,216,230],lightcoral:[240,128,128],lightcyan:[224,255,255],lightgoldenrodyellow:[250,250,210],lightgray:[211,211,211],lightgreen:[144,238,144],lightgrey:[211,211,211],lightpink:[255,182,193],lightsalmon:[255,160,122],lightseagreen:[32,178,170],lightskyblue:[135,206,250],lightslategray:[119,136,153],lightslategrey:[119,136,153],lightsteelblue:[176,196,222],lightyellow:[255,255,224],lime:[0,255,0],limegreen:[50,205,50],linen:[250,240,230],magenta:[255,0,255],maroon:[128,0,0],mediumaquamarine:[102,205,170],mediumblue:[0,0,205],mediumorchid:[186,85,211],mediumpurple:[147,112,219],mediumseagreen:[60,179,113],mediumslateblue:[123,104,238],mediumspringgreen:[0,250,154],mediumturquoise:[72,209,204],mediumvioletred:[199,21,133],midnightblue:[25,25,112],mintcream:[245,255,250],mistyrose:[255,228,225],moccasin:[255,228,181],navajowhite:[255,222,173],navy:[0,0,128],oldlace:[253,245,230],olive:[128,128,0],olivedrab:[107,142,35],orange:[255,165,0],orangered:[255,69,0],orchid:[218,112,214],palegoldenrod:[238,232,170],palegreen:[152,251,152],paleturquoise:[175,238,238],palevioletred:[219,112,147],papayawhip:[255,239,213],peachpuff:[255,218,185],peru:[205,133,63],pink:[255,192,203],plum:[221,160,221],powderblue:[176,224,230],purple:[128,0,128],rebeccapurple:[102,51,153],red:[255,0,0],rosybrown:[188,143,143],royalblue:[65,105,225],saddlebrown:[139,69,19],salmon:[250,128,114],sandybrown:[244,164,96],seagreen:[46,139,87],seashell:[255,245,238],sienna:[160,82,45],silver:[192,192,192],skyblue:[135,206,235],slateblue:[106,90,205],slategray:[112,128,144],slategrey:[112,128,144],snow:[255,250,250],springgreen:[0,255,127],steelblue:[70,130,180],tan:[210,180,140],teal:[0,128,128],thistle:[216,191,216],tomato:[255,99,71],turquoise:[64,224,208],violet:[238,130,238],wheat:[245,222,179],white:[255,255,255],whitesmoke:[245,245,245],yellow:[255,255,0],yellowgreen:[154,205,50]};function Tt(e,t,i){return e+i*(t-e)}function Et(e,t,i){return e.map((e,n)=>Tt(e,t[n],i))}class Ct{constructor(e,t,i,n=1,r=!0){this.r=e,this.g=t,this.b=i,this.a=n,r||(this.r*=n,this.g*=n,this.b*=n,n||this.overwriteGetter("rgb",[e,t,i,n]))}static parse(e){if(e instanceof Ct)return e;if("string"!=typeof e)return;const t=function(e){if("transparent"===(e=e.toLowerCase().trim()))return[0,0,0,0];const t=At(wt,e);if(t){const[e,i,n]=t;return[e/255,i/255,n/255,1]}if(e.startsWith("#")&&/^#(?:[0-9a-f]{3,4}|[0-9a-f]{6}|[0-9a-f]{8})$/.test(e)){const t=e.length<6?1:2;let i=1;return[yt(e.slice(i,i+=t)),yt(e.slice(i,i+=t)),yt(e.slice(i,i+=t)),yt(e.slice(i,i+t)||"ff")]}if(e.startsWith("rgb")){const t=e.match(/^rgba?\(\s*([\de.+-]+)(%)?(?:\s+|\s*(,)\s*)([\de.+-]+)(%)?(?:\s+|\s*(,)\s*)([\de.+-]+)(%)?(?:\s*([,\/])\s*([\de.+-]+)(%)?)?\s*\)$/);if(t){const[e,i,n,r,o,s,a,l,c,u,h,d]=t,p=[r||" ",a||" ",u].join("");if(" "===p||" /"===p||",,"===p||",,,"===p){const e=[n,s,c].join(""),t="%%%"===e?100:""===e?255:0;if(t){const e=[xt(+i/t,0,1),xt(+o/t,0,1),xt(+l/t,0,1),h?vt(+h,d):1];if(bt(e))return e}}return}}const i=e.match(/^hsla?\(\s*([\de.+-]+)(?:deg)?(?:\s+|\s*(,)\s*)([\de.+-]+)%(?:\s+|\s*(,)\s*)([\de.+-]+)%(?:\s*([,\/])\s*([\de.+-]+)(%)?)?\s*\)$/);if(i){const[e,t,n,r,o,s,a,l,c]=i,u=[n||" ",o||" ",a].join("");if(" "===u||" /"===u||",,"===u||",,,"===u){const e=[+t,xt(+r,0,100),xt(+s,0,100),l?vt(+l,c):1];if(bt(e))return function([e,t,i,n]){function r(n){const r=(n+e/30)%12,o=t*Math.min(i,1-i);return i-o*Math.max(-1,Math.min(r-3,9-r,1))}return e=ut(e),t/=100,i/=100,[r(0),r(8),r(4),n]}(e)}}}(e);return t?new Ct(...t,!1):void 0}get rgb(){const{r:e,g:t,b:i,a:n}=this,r=n||1/0;return this.overwriteGetter("rgb",[e/r,t/r,i/r,n])}get hcl(){return this.overwriteGetter("hcl",function(e){const[t,i,n,r]=ht(e),o=Math.sqrt(i*i+n*n);return[Math.round(1e4*o)?ut(Math.atan2(n,i)*ct):NaN,o,t,r]}(this.rgb))}get lab(){return this.overwriteGetter("lab",ht(this.rgb))}overwriteGetter(e,t){return Object.defineProperty(this,e,{value:t}),t}toString(){const[e,t,i,n]=this.rgb;return`rgba(${[e,t,i].map(e=>Math.round(255*e)).join(",")},${n})`}static interpolate(e,t,i,n="rgb"){switch(n){case"rgb":{const[n,r,o,s]=Et(e.rgb,t.rgb,i);return new Ct(n,r,o,s,!1)}case"hcl":{const[n,r,o,s]=e.hcl,[a,l,c,u]=t.hcl;let h,d;if(isNaN(n)||isNaN(a))isNaN(n)?isNaN(a)?h=NaN:(h=a,1!==o&&0!==o||(d=l)):(h=n,1!==c&&0!==c||(d=r));else{let e=a-n;a>n&&e>180?e-=360:a180&&(e+=360),h=n+i*e}const[p,f,m,g]=function([e,t,i,n]){return e=isNaN(e)?0:e*lt,ft([i,Math.cos(e)*t,Math.sin(e)*t,n])}([h,null!=d?d:Tt(r,l,i),Tt(o,c,i),Tt(s,u,i)]);return new Ct(p,f,m,g,!1)}case"lab":{const[n,r,o,s]=ft(Et(e.lab,t.lab,i));return new Ct(n,r,o,s,!1)}}}}Ct.black=new Ct(0,0,0,1),Ct.white=new Ct(1,1,1,1),Ct.transparent=new Ct(0,0,0,0),Ct.red=new Ct(1,0,0,1);class St{constructor(e,t,i){this.sensitivity=e?t?"variant":"case":t?"accent":"base",this.locale=i,this.collator=new Intl.Collator(this.locale?this.locale:[],{sensitivity:this.sensitivity,usage:"search"})}compare(e,t){return this.collator.compare(e,t)}resolvedLocale(){return new Intl.Collator(this.locale?this.locale:[]).resolvedOptions().locale}}const Bt=["bottom","center","top"];class It{constructor(e,t,i,n,r,o){this.text=e,this.image=t,this.scale=i,this.fontStack=n,this.textColor=r,this.verticalAlign=o}}class Mt{constructor(e){this.sections=e}static fromString(e){return new Mt([new It(e,null,null,null,null,null)])}isEmpty(){return 0===this.sections.length||!this.sections.some(e=>0!==e.text.length||e.image&&0!==e.image.name.length)}static factory(e){return e instanceof Mt?e:Mt.fromString(e)}toString(){return 0===this.sections.length?"":this.sections.map(e=>e.text).join("")}}class Pt{constructor(e){this.values=e.slice()}static parse(e){if(e instanceof Pt)return e;if("number"==typeof e)return new Pt([e,e,e,e]);if(Array.isArray(e)&&!(e.length<1||e.length>4)){for(const t of e)if("number"!=typeof t)return;switch(e.length){case 1:e=[e[0],e[0],e[0],e[0]];break;case 2:e=[e[0],e[1],e[0],e[1]];break;case 3:e=[e[0],e[1],e[2],e[1]]}return new Pt(e)}}toString(){return JSON.stringify(this.values)}static interpolate(e,t,i){return new Pt(Et(e.values,t.values,i))}}class Rt{constructor(e){this.values=e.slice()}static parse(e){if(e instanceof Rt)return e;if("number"==typeof e)return new Rt([e]);if(Array.isArray(e)){for(const t of e)if("number"!=typeof t)return;return new Rt(e)}}toString(){return JSON.stringify(this.values)}static interpolate(e,t,i){return new Rt(Et(e.values,t.values,i))}}class Lt{constructor(e){this.values=e.slice()}static parse(e){if(e instanceof Lt)return e;if("string"==typeof e){const t=Ct.parse(e);if(!t)return;return new Lt([t])}if(!Array.isArray(e))return;const t=[];for(const i of e){if("string"!=typeof i)return;const e=Ct.parse(i);if(!e)return;t.push(e)}return new Lt(t)}toString(){return JSON.stringify(this.values)}static interpolate(e,t,i,n="rgb"){const r=[];if(e.values.length!=t.values.length)throw new Error(`colorArray: Arrays have mismatched length (${e.values.length} vs. ${t.values.length}), cannot interpolate.`);for(let o=0;o=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 Nt(e){if(null===e||"string"==typeof e||"boolean"==typeof e||"number"==typeof e||e instanceof zt||e instanceof Ct||e instanceof St||e instanceof Mt||e instanceof Pt||e instanceof Rt||e instanceof Lt||e instanceof Dt||e instanceof Ot)return!0;if(Array.isArray(e)){for(const t of e)if(!Nt(t))return!1;return!0}if("object"==typeof e){for(const t in e)if(!Nt(e[t]))return!1;return!0}return!1}function Vt(e){if(null===e)return Fe;if("string"==typeof e)return De;if("boolean"==typeof e)return Oe;if("number"==typeof e)return ke;if(e instanceof Ct)return ze;if(e instanceof zt)return Ue;if(e instanceof St)return je;if(e instanceof Mt)return Ge;if(e instanceof Pt)return He;if(e instanceof Rt)return $e;if(e instanceof Lt)return Qe;if(e instanceof Dt)return We;if(e instanceof Ot)return Ze;if(Array.isArray(e)){const t=e.length;let i;for(const t of e){const e=Vt(t);if(i){if(i===e)continue;i=Ve;break}i=e}return qe(i||Ve,t)}return Ne}function jt(e){const t=typeof e;return null===e?"":"string"===t||"number"===t||"boolean"===t?String(e):e instanceof Ct||e instanceof zt||e instanceof Mt||e instanceof Pt||e instanceof Rt||e instanceof Lt||e instanceof Dt||e instanceof Ot?e.toString():JSON.stringify(e)}class Gt{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(!Nt(e[1]))return t.error("invalid value");const i=e[1];let n=Vt(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 Gt(n,i)}evaluate(){return this.value}eachChild(){}outputDefined(){return!0}}const Ht={string:De,number:ke,boolean:Oe,object:Ne};class Qt{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 Ht)||"object"===i)return t.error('The item type argument of "array" must be one of string, number, boolean',1);r=Ht[i],n++}else r=Ve;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=qe(r,o)}else{if(!Ht[r])throw new Error(`Types doesn't contain name = ${r}`);i=Ht[r]}const o=[];for(;ne.outputDefined())}}const $t={"to-boolean":Oe,"to-color":ze,"to-number":ke,"to-string":De};class Zt{constructor(e,t){this.type=e,this.args=t}static parse(e,t){if(e.length<2)return t.error("Expected at least one argument.");const i=e[0];if(!$t[i])throw new Error(`Can't parse ${i} as it is not part of the known types`);if(("to-boolean"===i||"to-string"===i)&&2!==e.length)return t.error("Expected one argument.");const n=$t[i],r=[];for(let i=1;i4?`Invalid rgba value ${JSON.stringify(t)}: expected an array containing either three or four numeric values.`:Ut(t[0],t[1],t[2],t[3]),!i))return new Ct(t[0]/255,t[1]/255,t[2]/255,t[3])}throw new Ft(i||`Could not parse color from value '${"string"==typeof t?t:JSON.stringify(t)}'`)}case"padding":{let t;for(const i of this.args){t=i.evaluate(e);const n=Pt.parse(t);if(n)return n}throw new Ft(`Could not parse padding from value '${"string"==typeof t?t:JSON.stringify(t)}'`)}case"numberArray":{let t;for(const i of this.args){t=i.evaluate(e);const n=Rt.parse(t);if(n)return n}throw new Ft(`Could not parse numberArray from value '${"string"==typeof t?t:JSON.stringify(t)}'`)}case"colorArray":{let t;for(const i of this.args){t=i.evaluate(e);const n=Lt.parse(t);if(n)return n}throw new Ft(`Could not parse colorArray from value '${"string"==typeof t?t:JSON.stringify(t)}'`)}case"variableAnchorOffsetCollection":{let t;for(const i of this.args){t=i.evaluate(e);const n=Dt.parse(t);if(n)return n}throw new Ft(`Could not parse variableAnchorOffsetCollection from value '${"string"==typeof t?t:JSON.stringify(t)}'`)}case"number":{let t=null;for(const i of this.args){if(t=i.evaluate(e),null===t)return 0;const n=Number(t);if(!isNaN(n))return n}throw new Ft(`Could not convert ${JSON.stringify(t)} to number.`)}case"formatted":return Mt.fromString(jt(this.args[0].evaluate(e)));case"resolvedImage":return Ot.fromString(jt(this.args[0].evaluate(e)));case"projectionDefinition":return this.args[0].evaluate(e);default:return jt(this.args[0].evaluate(e))}}eachChild(e){this.args.forEach(e)}outputDefined(){return this.args.every(e=>e.outputDefined())}}const Wt=["Unknown","Point","LineString","Polygon"];class qt{constructor(){this.globals=null,this.feature=null,this.featureState=null,this.formattedSection=null,this._parseColorCache=new Map,this.availableImages=null,this.canonical=null}id(){return this.feature&&"id"in this.feature?this.feature.id:null}geometryType(){return this.feature?"number"==typeof this.feature.type?Wt[this.feature.type]:this.feature.type:null}geometry(){return this.feature&&"geometry"in this.feature?this.feature.geometry:null}canonicalID(){return this.canonical}properties(){return this.feature&&this.feature.properties||{}}parseColor(e){let t=this._parseColorCache.get(e);return t||(t=Ct.parse(e),this._parseColorCache.set(e,t)),t}}class Kt{constructor(e,t,i=[],n,r=new Le,o=[]){this.registry=e,this.path=i,this.key=i.map(e=>`[${e}]`).join(""),this.scope=r,this.errors=o,this.expectedType=n,this._isConstant=t}parse(e,t,i,n,r={}){return t?this.concat(t,i,n)._parse(e,r):this._parse(e,r)}_parse(e,t){function i(e,t,i){return"assert"===i?new Qt(t,[e]):"coerce"===i?new Zt(t,[e]):e}if(null!==e&&"string"!=typeof e&&"boolean"!=typeof e&&"number"!=typeof e||(e=["literal",e]),Array.isArray(e)){if(0===e.length)return this.error('Expected an array with at least one element. If you wanted a literal array, use ["literal", []].');const n=e[0];if("string"!=typeof n)return this.error(`Expression name must be a string, but found ${typeof n} instead. If you wanted a literal array, use ["literal", [...]].`,0),null;const r=this.registry[n];if(r){let n=r.parse(e,this);if(!n)return null;if(this.expectedType){const e=this.expectedType,r=n.type;if("string"!==e.kind&&"number"!==e.kind&&"boolean"!==e.kind&&"object"!==e.kind&&"array"!==e.kind||"value"!==r.kind){if("projectionDefinition"===e.kind&&["string","array"].includes(r.kind)||["color","formatted","resolvedImage"].includes(e.kind)&&["value","string"].includes(r.kind)||["padding","numberArray"].includes(e.kind)&&["value","number","array"].includes(r.kind)||"colorArray"===e.kind&&["value","string","array"].includes(r.kind)||"variableAnchorOffsetCollection"===e.kind&&["value","array"].includes(r.kind))n=i(n,e,t.typeAnnotation||"coerce");else if(this.checkSubtype(e,r))return null}else n=i(n,e,t.typeAnnotation||"assert")}if(!(n instanceof Gt)&&"resolvedImage"!==n.type.kind&&this._isConstant(n)){const t=new qt;try{n=new Gt(n.type,n.evaluate(t))}catch(e){return this.error(e.message),null}}return n}return this.error(`Unknown expression "${n}". If you wanted a literal array, use ["literal", [...]].`,0)}return this.error(void 0===e?"'undefined' value invalid. Use null instead.":"object"==typeof e?'Bare objects invalid. Use ["literal", {...}] instead.':`Expected an array, but found ${typeof e} instead.`)}concat(e,t,i){const n="number"==typeof e?this.path.concat(e):this.path,r=i?this.scope.concat(i):this.scope;return new Kt(this.registry,this._isConstant,n,t||null,r,this.errors)}error(e,...t){const i=`${this.key}${t.map(e=>`[${e}]`).join("")}`;this.errors.push(new Re(i,e))}checkSubtype(e,t){const i=Je(e,t);return i&&this.error(i),i}}class Xt{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=i.length)throw new Ft(`Array index out of bounds: ${t} > ${i.length-1}.`);if(t!==Math.floor(t))throw new Ft(`Array index must be an integer, but found ${t} instead.`);return i[t]}eachChild(e){e(this.index),e(this.input)}outputDefined(){return!1}}class ei{constructor(e,t){this.type=Oe,this.needle=e,this.haystack=t}static parse(e,t){if(3!==e.length)return t.error(`Expected 2 arguments, but found ${e.length-1} instead.`);const i=t.parse(e[1],1,Ve),n=t.parse(e[2],2,Ve);return i&&n?Ye(i.type,[Oe,De,ke,Fe,Ve])?new ei(i,n):t.error(`Expected first argument to be of type boolean, string, number or null, but found ${Ke(i.type)} instead`):null}evaluate(e){const t=this.needle.evaluate(e),i=this.haystack.evaluate(e);if(!i)return!1;if(!et(t,["boolean","string","number","null"]))throw new Ft(`Expected first argument to be of type boolean, string, number or null, but found ${Ke(Vt(t))} instead.`);if(!et(i,["string","array"]))throw new Ft(`Expected second argument to be of type array or string, but found ${Ke(Vt(i))} instead.`);return i.indexOf(t)>=0}eachChild(e){e(this.needle),e(this.haystack)}outputDefined(){return!0}}class ti{constructor(e,t,i){this.type=ke,this.needle=e,this.haystack=t,this.fromIndex=i}static parse(e,t){if(e.length<=2||e.length>=5)return t.error(`Expected 2 or 3 arguments, but found ${e.length-1} instead.`);const i=t.parse(e[1],1,Ve),n=t.parse(e[2],2,Ve);if(!i||!n)return null;if(!Ye(i.type,[Oe,De,ke,Fe,Ve]))return t.error(`Expected first argument to be of type boolean, string, number or null, but found ${Ke(i.type)} instead`);if(4===e.length){const r=t.parse(e[3],3,ke);return r?new ti(i,n,r):null}return new ti(i,n)}evaluate(e){const t=this.needle.evaluate(e),i=this.haystack.evaluate(e);if(!et(t,["boolean","string","number","null"]))throw new Ft(`Expected first argument to be of type boolean, string, number or null, but found ${Ke(Vt(t))} instead.`);let n;if(this.fromIndex&&(n=this.fromIndex.evaluate(e)),et(i,["string"])){const e=i.indexOf(t,n);return-1===e?-1:[...i.slice(0,e)].length}if(et(i,["array"]))return i.indexOf(t,n);throw new Ft(`Expected second argument to be of type array or string, but found ${Ke(Vt(i))} instead.`)}eachChild(e){e(this.needle),e(this.haystack),this.fromIndex&&e(this.fromIndex)}outputDefined(){return!1}}class ii{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 s=2;sNumber.MAX_SAFE_INTEGER)return c.error(`Branch labels must be integers no larger than ${Number.MAX_SAFE_INTEGER}.`);if("number"==typeof e&&Math.floor(e)!==e)return c.error("Numeric branch labels must be integer values.");if(i){if(c.checkSubtype(i,Vt(e)))return null}else i=Vt(e);if(void 0!==r[String(e)])return c.error("Branch labels must be unique.");r[String(e)]=o.length}const u=t.parse(l,s,n);if(!u)return null;n=n||u.type,o.push(u)}const s=t.parse(e[1],1,Ve);if(!s)return null;const a=t.parse(e[e.length-1],e.length-1,n);return a?"value"!==s.type.kind&&t.concat(1).checkSubtype(i,s.type)?null:new ii(i,n,s,r,o,a):null}evaluate(e){const t=this.input.evaluate(e);return(Vt(t)===this.inputType&&this.outputs[this.cases[t]]||this.otherwise).evaluate(e)}eachChild(e){e(this.input),this.outputs.forEach(e),e(this.otherwise)}outputDefined(){return this.outputs.every(e=>e.outputDefined())&&this.otherwise.outputDefined()}}class ni{constructor(e,t,i){this.type=e,this.branches=t,this.otherwise=i}static parse(e,t){if(e.length<4)return t.error(`Expected at least 3 arguments, but found only ${e.length-1}.`);if(e.length%2!=0)return t.error("Expected an odd number of arguments.");let i;t.expectedType&&"value"!==t.expectedType.kind&&(i=t.expectedType);const n=[];for(let r=1;rt.outputDefined())&&this.otherwise.outputDefined()}}class ri{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 2 or 3 arguments, but found ${e.length-1} instead.`);const i=t.parse(e[1],1,Ve),n=t.parse(e[2],2,ke);if(!i||!n)return null;if(!Ye(i.type,[qe(Ve),De,Ve]))return t.error(`Expected first argument to be of type array or string, but found ${Ke(i.type)} instead`);if(4===e.length){const r=t.parse(e[3],3,ke);return r?new ri(i.type,i,n,r):null}return new ri(i.type,i,n)}evaluate(e){const t=this.input.evaluate(e),i=this.beginIndex.evaluate(e);let n;if(this.endIndex&&(n=this.endIndex.evaluate(e)),et(t,["string"]))return[...t].slice(i,n).join("");if(et(t,["array"]))return t.slice(i,n);throw new Ft(`Expected first argument to be of type array or string, but found ${Ke(Vt(t))} instead.`)}eachChild(e){e(this.input),e(this.beginIndex),this.endIndex&&e(this.endIndex)}outputDefined(){return!1}}function oi(e,t){const i=e.length-1;let n,r,o=0,s=i,a=0;for(;o<=s;)if(a=Math.floor((o+s)/2),n=e[a],r=e[a+1],n<=t){if(a===i||tt))throw new Ft("Input is not a number.");s=a-1}return 0}class si{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,ke);if(!i)return null;const n=[];let r=null;t.expectedType&&"value"!==t.expectedType.kind&&(r=t.expectedType);for(let i=1;i=o)return t.error('Input/output pairs for "step" expressions must be arranged with input values in strictly ascending order.',a);const c=t.parse(s,l,r);if(!c)return null;r=r||c.type,n.push([o,c])}return new si(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[oi(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())}}function ai(e){return e&&e.__esModule&&Object.prototype.hasOwnProperty.call(e,"default")?e.default:e}var li,ci,ui=function(){if(ci)return li;function e(e,t,i,n){this.cx=3*e,this.bx=3*(i-e)-this.cx,this.ax=1-this.cx-this.bx,this.cy=3*t,this.by=3*(n-t)-this.cy,this.ay=1-this.cy-this.by,this.p1x=e,this.p1y=t,this.p2x=i,this.p2y=n}return ci=1,li=e,e.prototype={sampleCurveX:function(e){return((this.ax*e+this.bx)*e+this.cx)*e},sampleCurveY:function(e){return((this.ay*e+this.by)*e+this.cy)*e},sampleCurveDerivativeX:function(e){return(3*this.ax*e+2*this.bx)*e+this.cx},solveCurveX:function(e,t){if(void 0===t&&(t=1e-6),e<0)return 0;if(e>1)return 1;for(var i=e,n=0;n<8;n++){var r=this.sampleCurveX(i)-e;if(Math.abs(r)r?s=i:a=i,i=.5*(a-s)+s;return i},solve:function(e,t){return this.sampleCurveY(this.solveCurveX(e,t))}},li}(),hi=ai(ui);class di{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=pi(t,e.base,i,n);else if("linear"===e.name)r=pi(t,1,i,n);else if("cubic-bezier"===e.name){const o=e.controlPoints;r=new hi(o[0],o[1],o[2],o[3]).solve(pi(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)%2!=0)return t.error("Expected an even number of arguments.");if(r=t.parse(r,2,ke),!r)return null;const s=[];let a=null;"interpolate-hcl"!==i&&"interpolate-lab"!==i||t.expectedType==Qe?t.expectedType&&"value"!==t.expectedType.kind&&(a=t.expectedType):a=ze;for(let e=0;e=i)return t.error('Input/output pairs for "interpolate" expressions must be arranged with input values in strictly ascending order.',r);const c=t.parse(n,l,a);if(!c)return null;a=a||c.type,s.push([i,c])}return tt(a,ke)||tt(a,Ue)||tt(a,ze)||tt(a,He)||tt(a,$e)||tt(a,Qe)||tt(a,We)||tt(a,qe(ke))?new di(a,i,n,r,s):t.error(`Type ${Ke(a)} 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=oi(t,n),s=di.interpolationFactor(this.interpolation,n,t[o],t[o+1]),a=i[o].evaluate(e),l=i[o+1].evaluate(e);switch(this.operator){case"interpolate":switch(this.type.kind){case"number":return Tt(a,l,s);case"color":return Ct.interpolate(a,l,s);case"padding":return Pt.interpolate(a,l,s);case"colorArray":return Lt.interpolate(a,l,s);case"numberArray":return Rt.interpolate(a,l,s);case"variableAnchorOffsetCollection":return Dt.interpolate(a,l,s);case"array":return Et(a,l,s);case"projectionDefinition":return zt.interpolate(a,l,s)}case"interpolate-hcl":switch(this.type.kind){case"color":return Ct.interpolate(a,l,s,"hcl");case"colorArray":return Lt.interpolate(a,l,s,"hcl")}case"interpolate-lab":switch(this.type.kind){case"color":return Ct.interpolate(a,l,s,"lab");case"colorArray":return Lt.interpolate(a,l,s,"lab")}}}eachChild(e){e(this.input);for(const t of this.outputs)e(t)}outputDefined(){return this.outputs.every(e=>e.outputDefined())}}function pi(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)}const fi={color:Ct.interpolate,number:Tt,padding:Pt.interpolate,numberArray:Rt.interpolate,colorArray:Lt.interpolate,variableAnchorOffsetCollection:Dt.interpolate,array:Et};class mi{constructor(e,t){this.type=e,this.args=t}static parse(e,t){if(e.length<2)return t.error("Expected at least one argument.");let i=null;const 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)}if(!i)throw new Error("No output type");const o=n&&r.some(e=>Je(n,e.type));return new mi(o?Ve: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 Ot&&!i.available&&(t||(t=i.name),i=null,n===this.args.length&&(i=t)),null!==i)break;return i}eachChild(e){this.args.forEach(e)}outputDefined(){return this.args.every(e=>e.outputDefined())}}function gi(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 _i(e,t,i,n){return 0===n.compare(t,i)}function Ai(e,t,i){const n="=="!==e&&"!="!==e;return class r{constructor(e,t,i){this.type=Oe,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,Ve);if(!o)return null;if(!gi(i,o.type))return t.concat(1).error(`"${i}" comparisons are not supported for type '${Ke(o.type)}'.`);let s=t.parse(e[2],2,Ve);if(!s)return null;if(!gi(i,s.type))return t.concat(2).error(`"${i}" comparisons are not supported for type '${Ke(s.type)}'.`);if(o.type.kind!==s.type.kind&&"value"!==o.type.kind&&"value"!==s.type.kind)return t.error(`Cannot compare types '${Ke(o.type)}' and '${Ke(s.type)}'.`);n&&("value"===o.type.kind&&"value"!==s.type.kind?o=new Qt(s.type,[o]):"value"!==o.type.kind&&"value"===s.type.kind&&(s=new Qt(o.type,[s])));let a=null;if(4===e.length){if("string"!==o.type.kind&&"string"!==s.type.kind&&"value"!==o.type.kind&&"value"!==s.type.kind)return t.error("Cannot use collator to compare non-string types.");if(a=t.parse(e[3],3,je),!a)return null}return new r(o,s,a)}evaluate(r){const o=this.lhs.evaluate(r),s=this.rhs.evaluate(r);if(n&&this.hasUntypedArgument){const t=Vt(o),i=Vt(s);if(t.kind!==i.kind||"string"!==t.kind&&"number"!==t.kind)throw new Ft(`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=Vt(o),i=Vt(s);if("string"!==e.kind||"string"!==i.kind)return t(r,o,s)}return this.collator?i(r,o,s,this.collator.evaluate(r)):t(r,o,s)}eachChild(e){e(this.lhs),e(this.rhs),this.collator&&e(this.collator)}outputDefined(){return!0}}}const yi=Ai("==",function(e,t,i){return t===i},_i),vi=Ai("!=",function(e,t,i){return t!==i},function(e,t,i,n){return!_i(0,t,i,n)}),xi=Ai("<",function(e,t,i){return t",function(e,t,i){return t>i},function(e,t,i,n){return n.compare(t,i)>0}),wi=Ai("<=",function(e,t,i){return t<=i},function(e,t,i,n){return n.compare(t,i)<=0}),Ti=Ai(">=",function(e,t,i){return t>=i},function(e,t,i,n){return n.compare(t,i)>=0});class Ei{constructor(e,t,i){this.type=je,this.locale=i,this.caseSensitive=e,this.diacriticSensitive=t}static parse(e,t){if(2!==e.length)return t.error("Expected one argument.");const i=e[1];if("object"!=typeof i||Array.isArray(i))return t.error("Collator options argument must be an object.");const n=t.parse(void 0!==i["case-sensitive"]&&i["case-sensitive"],1,Oe);if(!n)return null;const r=t.parse(void 0!==i["diacritic-sensitive"]&&i["diacritic-sensitive"],1,Oe);if(!r)return null;let o=null;return i.locale&&(o=t.parse(i.locale,1,De),!o)?null:new Ei(n,r,o)}evaluate(e){return new St(this.caseSensitive.evaluate(e),this.diacriticSensitive.evaluate(e),this.locale?this.locale.evaluate(e):null)}eachChild(e){e(this.caseSensitive),e(this.diacriticSensitive),this.locale&&e(this.locale)}outputDefined(){return!1}}class Ci{constructor(e,t,i,n,r){this.type=De,this.number=e,this.locale=t,this.currency=i,this.minFractionDigits=n,this.maxFractionDigits=r}static parse(e,t){if(3!==e.length)return t.error("Expected two arguments.");const i=t.parse(e[1],1,ke);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.parse(n.locale,1,De),!r))return null;let o=null;if(n.currency&&(o=t.parse(n.currency,1,De),!o))return null;let s=null;if(n["min-fraction-digits"]&&(s=t.parse(n["min-fraction-digits"],1,ke),!s))return null;let a=null;return n["max-fraction-digits"]&&(a=t.parse(n["max-fraction-digits"],1,ke),!a)?null:new Ci(i,r,o,s,a)}evaluate(e){return new Intl.NumberFormat(this.locale?this.locale.evaluate(e):[],{style:this.currency?"currency":"decimal",currency:this.currency?this.currency.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.minFractionDigits&&e(this.minFractionDigits),this.maxFractionDigits&&e(this.maxFractionDigits)}outputDefined(){return!1}}class Si{constructor(e){this.type=Ge,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.parse(o["font-scale"],1,ke),!e))return null;let i=null;if(o["text-font"]&&(i=t.parse(o["text-font"],1,qe(De)),!i))return null;let s=null;if(o["text-color"]&&(s=t.parse(o["text-color"],1,ze),!s))return null;let a=null;if(o["vertical-align"]){if("string"==typeof o["vertical-align"]&&!Bt.includes(o["vertical-align"]))return t.error(`'vertical-align' must be one of: 'bottom', 'center', 'top' but found '${o["vertical-align"]}' instead.`);if(a=t.parse(o["vertical-align"],1,De),!a)return null}const l=n[n.length-1];l.scale=e,l.font=i,l.textColor=s,l.verticalAlign=a}else{const o=t.parse(e[i],1,Ve);if(!o)return null;const s=o.type.kind;if("string"!==s&&"value"!==s&&"null"!==s&&"resolvedImage"!==s)return t.error("Formatted text type must be 'string', 'value', 'image' or 'null'.");r=!0,n.push({content:o,scale:null,font:null,textColor:null,verticalAlign:null})}}return new Si(n)}evaluate(e){return new Mt(this.sections.map(t=>{const i=t.content.evaluate(e);return Vt(i)===Ze?new It("",i,null,null,null,t.verticalAlign?t.verticalAlign.evaluate(e):null):new It(jt(i),null,t.scale?t.scale.evaluate(e):null,t.font?t.font.evaluate(e).join(","):null,t.textColor?t.textColor.evaluate(e):null,t.verticalAlign?t.verticalAlign.evaluate(e):null)}))}eachChild(e){for(const t of this.sections)e(t.content),t.scale&&e(t.scale),t.font&&e(t.font),t.textColor&&e(t.textColor),t.verticalAlign&&e(t.verticalAlign)}outputDefined(){return!1}}class Bi{constructor(e){this.type=Ze,this.input=e}static parse(e,t){if(2!==e.length)return t.error("Expected two arguments.");const i=t.parse(e[1],1,De);return i?new Bi(i):t.error("No image name provided.")}evaluate(e){const t=this.input.evaluate(e),i=Ot.fromString(t);return i&&e.availableImages&&(i.available=e.availableImages.indexOf(t)>-1),i}eachChild(e){e(this.input)}outputDefined(){return!1}}class Ii{constructor(e){this.type=ke,this.input=e}static parse(e,t){if(2!==e.length)return t.error(`Expected 1 argument, but found ${e.length-1} instead.`);const i=t.parse(e[1],1);return i?"array"!==i.type.kind&&"string"!==i.type.kind&&"value"!==i.type.kind?t.error(`Expected argument of type string or array, but found ${Ke(i.type)} instead.`):new Ii(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 Ft(`Expected value to be of type string or array, but found ${Ke(Vt(t))} instead.`)}eachChild(e){e(this.input)}outputDefined(){return!1}}const Mi=8192;function Pi(e,t){const i=(180+e[0])/360,n=(180-180/Math.PI*Math.log(Math.tan(Math.PI/4+e[1]*Math.PI/360)))/360,r=Math.pow(2,t.z);return[Math.round(i*r*Mi),Math.round(n*r*Mi)]}function Ri(e,t){const i=Math.pow(2,t.z);return[(r=(e[0]/Mi+t.x)/i,360*r-180),(n=(e[1]/Mi+t.y)/i,360/Math.PI*Math.atan(Math.exp((180-360*n)*Math.PI/180))-90)];var n,r}function Li(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 Fi(e,t){return!(e[0]<=t[0]||e[2]>=t[2]||e[1]<=t[1]||e[3]>=t[3])}function ki(e,t,i){const n=e[0]-t[0],r=e[1]-t[1],o=e[0]-i[0],s=e[1]-i[1];return n*s-o*r==0&&n*o<=0&&r*s<=0}function Di(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]&&!(!ji(e,t,i,n)||!ji(i,n,e,t));var r,o}function Oi(e,t,i){for(const n of i)for(let i=0;i(r=e)[1]!=(s=a[t+1])[1]>r[1]&&r[0]<(s[0]-o[0])*(r[1]-o[1])/(s[1]-o[1])+o[0]&&(n=!n)}var r,o,s;return n}function Ui(e,t){for(const i of t)if(zi(e,i))return!0;return!1}function Ni(e,t){for(const i of e)if(!zi(i,t))return!1;for(let i=0;i0&&a<0||s<0&&a>0}function Gi(e,t,i){const n=[];for(let r=0;ri[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}Li(t,e)}function $i(e,t,i,n){const r=Math.pow(2,n.z)*Mi,o=[n.x*Mi,n.y*Mi],s=[];for(const n of e)for(const e of n){const n=[e.x+o[0],e.y+o[1]];Qi(n,t,i,r),s.push(n)}return s}function Zi(e,t,i,n){const r=Math.pow(2,n.z)*Mi,o=[n.x*Mi,n.y*Mi],s=[];for(const i of e){const e=[];for(const n of i){const i=[n.x+o[0],n.y+o[1]];Li(t,i),e.push(i)}s.push(e)}if(t[2]-t[0]<=r/2){(a=t)[0]=a[1]=1/0,a[2]=a[3]=-1/0;for(const e of s)for(const n of e)Qi(n,t,i,r)}var a;return s}class Wi{constructor(e,t){this.type=Oe,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(Nt(e[1])){const t=e[1];if("FeatureCollection"===t.type){const e=[];for(const i of t.features){const{type:t,coordinates:n}=i.geometry;"Polygon"===t&&e.push(n),"MultiPolygon"===t&&e.push(...n)}if(e.length)return new Wi(t,{type:"MultiPolygon",coordinates:e})}else if("Feature"===t.type){const e=t.geometry.type;if("Polygon"===e||"MultiPolygon"===e)return new Wi(t,t.geometry)}else if("Polygon"===t.type||"MultiPolygon"===t.type)return new Wi(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("Polygon"===t.type){const o=Gi(t.coordinates,n,r),s=$i(e.geometry(),i,n,r);if(!Fi(i,n))return!1;for(const e of s)if(!zi(e,o))return!1}if("MultiPolygon"===t.type){const o=Hi(t.coordinates,n,r),s=$i(e.geometry(),i,n,r);if(!Fi(i,n))return!1;for(const e of s)if(!Ui(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("Polygon"===t.type){const o=Gi(t.coordinates,n,r),s=Zi(e.geometry(),i,n,r);if(!Fi(i,n))return!1;for(const e of s)if(!Ni(e,o))return!1}if("MultiPolygon"===t.type){const o=Hi(t.coordinates,n,r),s=Zi(e.geometry(),i,n,r);if(!Fi(i,n))return!1;for(const e of s)if(!Vi(e,o))return!1}return!0}(e,this.geometries)}return!1}eachChild(){}outputDefined(){return!0}}let qi=class{constructor(e=[],t=(e,t)=>et?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=0)break;t[e]=t[n],e=n}t[e]=r}};function Ki(e,t,i=0,n=e.length-1,r=Ji){for(;n>i;){if(n-i>600){const o=n-i+1,s=t-i+1,a=Math.log(o),l=.5*Math.exp(2*a/3),c=.5*Math.sqrt(a*l*(o-l)/o)*(s-o/2<0?-1:1);Ki(e,t,Math.max(i,Math.floor(t-s*l/o+c)),Math.min(n,Math.floor(t+(o-s)*l/o+c)),r)}const o=e[t];let s=i,a=n;for(Xi(e,i,t),r(e[n],o)>0&&Xi(e,i,n);s0;)a--}0===r(e[i],o)?Xi(e,i,a):(a++,Xi(e,a,n)),a<=t&&(i=a+1),t<=a&&(n=a-1)}}function Xi(e,t,i){const n=e[t];e[t]=e[i],e[i]=n}function Ji(e,t){return et?1:0}function Yi(e,t){if(e.length<=1)return[e];const i=[];let n,r;for(const t of e){const e=tn(t);0!==e&&(t.area=Math.abs(e),void 0===r&&(r=e<0),r===e<0?(n&&i.push(n),n=[t]):n.push(t))}if(n&&i.push(n),t>1)for(let e=0;e1?(l=e[a+1][0],c=e[a+1][1]):d>0&&(l+=u/this.kx*d,c+=h/this.ky*d)),u=this.wrap(t[0]-l)*this.kx,h=(t[1]-c)*this.ky;const p=u*u+h*h;p180;)e-=360;return e}}function an(e,t){return t[0]-e[0]}function ln(e){return e[1]-e[0]+1}function cn(e,t){return e[1]>=e[0]&&e[1]e[1])return[null,null];const i=ln(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 n=Math.floor(i/2)-1;return[[e[0],e[0]+n],[e[0]+n+1,e[1]]]}function hn(e,t){if(!cn(t,e.length))return[1/0,1/0,-1/0,-1/0];const i=[1/0,1/0,-1/0,-1/0];for(let n=t[0];n<=t[1];++n)Li(i,e[n]);return i}function dn(e){const t=[1/0,1/0,-1/0,-1/0];for(const i of e)for(const e of i)Li(t,e);return t}function pn(e){return e[0]!==-1/0&&e[1]!==-1/0&&e[2]!==1/0&&e[3]!==1/0}function fn(e,t,i){if(!pn(e)||!pn(t))return NaN;let n=0,r=0;return e[2]t[2]&&(n=e[0]-t[2]),e[1]>t[3]&&(r=e[1]-t[3]),e[3]=n)return n;if(Fi(r,o)){if(xn(e,t))return 0}else if(xn(t,e))return 0;let s=1/0;for(const n of e)for(let e=0,r=n.length,o=r-1;e0;){const r=s.pop();if(r[0]>=o)continue;const l=r[1],c=t?50:100;if(ln(l)<=c){if(!cn(l,e.length))return NaN;if(t){const t=vn(e,l,i,n);if(isNaN(t)||0===t)return t;o=Math.min(o,t)}else for(let t=l[0];t<=l[1];++t){const r=yn(e[t],i,n);if(o=Math.min(o,r),0===o)return 0}}else{const i=un(l,t);wn(s,o,n,e,a,i[0]),wn(s,o,n,e,a,i[1])}}return o}function Cn(e,t,i,n,r,o=1/0){let s=Math.min(o,r.distance(e[0],i[0]));if(0===s)return s;const a=new qi([[0,[0,e.length-1],[0,i.length-1]]],an);for(;a.length>0;){const o=a.pop();if(o[0]>=s)continue;const l=o[1],c=o[2],u=t?50:100,h=n?50:100;if(ln(l)<=u&&ln(c)<=h){if(!cn(l,e.length)&&cn(c,i.length))return NaN;let o;if(t&&n)o=_n(e,l,i,c,r),s=Math.min(s,o);else if(t&&!n){const t=e.slice(l[0],l[1]+1);for(let e=c[0];e<=c[1];++e)if(o=mn(i[e],t,r),s=Math.min(s,o),0===s)return s}else if(!t&&n){const t=i.slice(c[0],c[1]+1);for(let i=l[0];i<=l[1];++i)if(o=mn(e[i],t,r),s=Math.min(s,o),0===s)return s}else o=An(e,l,i,c,r),s=Math.min(s,o)}else{const o=un(l,t),u=un(c,n);Tn(a,s,r,e,i,o[0],u[0]),Tn(a,s,r,e,i,o[0],u[1]),Tn(a,s,r,e,i,o[1],u[0]),Tn(a,s,r,e,i,o[1],u[1])}}return s}function Sn(e){return"MultiPolygon"===e.type?e.coordinates.map(e=>({type:"Polygon",coordinates:e})):"MultiLineString"===e.type?e.coordinates.map(e=>({type:"LineString",coordinates:e})):"MultiPoint"===e.type?e.coordinates.map(e=>({type:"Point",coordinates:e})):[e]}class Bn{constructor(e,t){this.type=ke,this.geojson=e,this.geometries=t}static parse(e,t){if(2!==e.length)return t.error(`'distance' expression requires exactly one argument, but found ${e.length-1} instead.`);if(Nt(e[1])){const t=e[1];if("FeatureCollection"===t.type)return new Bn(t,t.features.map(e=>Sn(e.geometry)).flat());if("Feature"===t.type)return new Bn(t,Sn(t.geometry));if("type"in t&&"coordinates"in t)return new Bn(t,Sn(t))}return t.error("'distance' expression requires valid geojson object that contains polygon geometry type.")}evaluate(e){if(null!=e.geometry()&&null!=e.canonicalID()){if("Point"===e.geometryType())return function(e,t){const i=e.geometry(),n=i.flat().map(t=>Ri([t.x,t.y],e.canonical));if(0===i.length)return NaN;const r=new sn(n[0][1]);let o=1/0;for(const e of t){switch(e.type){case"Point":o=Math.min(o,Cn(n,!1,[e.coordinates],!1,r,o));break;case"LineString":o=Math.min(o,Cn(n,!1,e.coordinates,!0,r,o));break;case"Polygon":o=Math.min(o,En(n,!1,e.coordinates,r,o))}if(0===o)return o}return o}(e,this.geometries);if("LineString"===e.geometryType())return function(e,t){const i=e.geometry(),n=i.flat().map(t=>Ri([t.x,t.y],e.canonical));if(0===i.length)return NaN;const r=new sn(n[0][1]);let o=1/0;for(const e of t){switch(e.type){case"Point":o=Math.min(o,Cn(n,!0,[e.coordinates],!1,r,o));break;case"LineString":o=Math.min(o,Cn(n,!0,e.coordinates,!0,r,o));break;case"Polygon":o=Math.min(o,En(n,!0,e.coordinates,r,o))}if(0===o)return o}return o}(e,this.geometries);if("Polygon"===e.geometryType())return function(e,t){const i=e.geometry();if(0===i.length||0===i[0].length)return NaN;const n=Yi(i,0).map(t=>t.map(t=>t.map(t=>Ri([t.x,t.y],e.canonical)))),r=new sn(n[0][0][0][1]);let o=1/0;for(const e of t)for(const t of n){switch(e.type){case"Point":o=Math.min(o,En([e.coordinates],!1,t,r,o));break;case"LineString":o=Math.min(o,En(e.coordinates,!0,t,r,o));break;case"Polygon":o=Math.min(o,bn(t,e.coordinates,r,o))}if(0===o)return o}return o}(e,this.geometries)}return NaN}eachChild(){}outputDefined(){return!0}}class In{constructor(e){this.type=Ve,this.key=e}static parse(e,t){if(2!==e.length)return t.error(`Expected 1 argument, but found ${e.length-1} instead.`);const i=e[1];return null==i?t.error("Global state property must be defined."):"string"!=typeof i?t.error(`Global state property must be string, but found ${typeof e[1]} instead.`):new In(i)}evaluate(e){var t;const i=null===(t=e.globals)||void 0===t?void 0:t.globalState;return i&&0!==Object.keys(i).length?At(i,this.key):null}eachChild(){}outputDefined(){return!1}}const Mn={"==":yi,"!=":vi,">":bi,"<":xi,">=":Ti,"<=":wi,array:Qt,at:Yt,boolean:Qt,case:ni,coalesce:mi,collator:Ei,format:Si,image:Bi,in:ei,"index-of":ti,interpolate:di,"interpolate-hcl":di,"interpolate-lab":di,length:Ii,let:Xt,literal:Gt,match:ii,number:Qt,"number-format":Ci,object:Qt,slice:ri,step:si,string:Qt,"to-boolean":Zt,"to-color":Zt,"to-number":Zt,"to-string":Zt,var:Jt,within:Wi,distance:Bn,"global-state":In};class Pn{constructor(e,t,i,n){this.name=e,this.type=t,this._evaluate=i,this.args=n}evaluate(e){return this._evaluate(e,this.args)}eachChild(e){this.args.forEach(e)}outputDefined(){return!1}static parse(e,t){const i=e[0],n=Pn.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,s=o.filter(([t])=>!Array.isArray(t)||t.length===e.length-1);let a=null;for(const[n,o]of s){a=new Kt(t.registry,Dn,t.path,null,t.scope);const s=[];let l=!1;for(let t=1;t{return t=e,Array.isArray(t)?`(${t.map(Ke).join(", ")})`:`(${Ke(t.type)}...)`;var t}).join(" | "),n=[];for(let i=1;i{i=t?i&&Dn(e):i&&e instanceof Gt}),!!i&&On(e)&&Un(e,["zoom","heatmap-density","elevation","line-progress","accumulated","is-supported-script"])}function On(e){if(e instanceof Pn){if("get"===e.name&&1===e.args.length)return!1;if("feature-state"===e.name)return!1;if("has"===e.name&&1===e.args.length)return!1;if("properties"===e.name||"geometry-type"===e.name||"id"===e.name)return!1;if(/^filter-/.test(e.name))return!1}if(e instanceof Wi)return!1;if(e instanceof Bn)return!1;let t=!0;return e.eachChild(e=>{t&&!On(e)&&(t=!1)}),t}function zn(e){if(e instanceof Pn&&"feature-state"===e.name)return!1;let t=!0;return e.eachChild(e=>{t&&!zn(e)&&(t=!1)}),t}function Un(e,t){if(e instanceof Pn&&t.indexOf(e.name)>=0)return!1;let i=!0;return e.eachChild(e=>{i&&!Un(e,t)&&(i=!1)}),i}function Nn(e){return{result:"success",value:e}}function Vn(e){return{result:"error",value:e}}function jn(e){return"data-driven"===e["property-type"]||"cross-faded-data-driven"===e["property-type"]}function Gn(e){return!!e.expression&&e.expression.parameters.indexOf("zoom")>-1}function Hn(e){return!!e.expression&&e.expression.interpolated}function Qn(e){return e instanceof Number?"number":e instanceof String?"string":e instanceof Boolean?"boolean":Array.isArray(e)?"array":null===e?"null":typeof e}function $n(e){return"object"==typeof e&&null!==e&&!Array.isArray(e)&&Vt(e)===Ne}function Zn(e){return e}function Wn(e,t){const i=e.stops&&"object"==typeof e.stops[0][0],n=i||!(i||void 0!==e.property),r=e.type||(Hn(t)?"exponential":"interval"),o=function(e){switch(e.type){case"color":return Ct.parse;case"padding":return Pt.parse;case"numberArray":return Rt.parse;case"colorArray":return Lt.parse;default:return null}}(t);if(o&&((e=Pe({},e)).stops&&(e.stops=e.stops.map(e=>[e[0],o(e[1])])),e.default=o(e.default?e.default:t.default)),e.colorSpace&&"rgb"!==(s=e.colorSpace)&&"hcl"!==s&&"lab"!==s)throw new Error(`Unknown color space: "${e.colorSpace}"`);var s;const a=function(e){switch(e){case"exponential":return Jn;case"interval":return Xn;case"categorical":return Kn;case"identity":return Yn;default:throw new Error(`Unknown function type "${e}"`)}}(r);let l,c;if("categorical"===r){l=Object.create(null);for(const t of e.stops)l[t[0]]=t[1];c=typeof e.stops[0][0]}if(i){const i={},n=[];for(let t=0;te[0]),evaluate:({zoom:i},n)=>Jn({stops:r,base:e.base},t,i).evaluate(i,n)}}if(n){const i="exponential"===r?{name:"exponential",base:void 0!==e.base?e.base:1}:null;return{kind:"camera",interpolationType:i,interpolationFactor:di.interpolationFactor.bind(void 0,i),zoomStops:e.stops.map(e=>e[0]),evaluate:({zoom:i})=>a(e,t,i,l,c)}}return{kind:"source",evaluate(i,n){const r=n&&n.properties?n.properties[e.property]:void 0;return void 0===r?qn(e.default,t.default):a(e,t,r,l,c)}}}function qn(e,t,i){return void 0!==e?e:void 0!==t?t:void 0!==i?i:void 0}function Kn(e,t,i,n,r){return qn(typeof i===r?n[i]:void 0,e.default,t.default)}function Xn(e,t,i){if("number"!==Qn(i))return qn(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=oi(e.stops.map(e=>e[0]),i);return e.stops[r][1]}function Jn(e,t,i){const n=void 0!==e.base?e.base:1;if("number"!==Qn(i))return qn(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=oi(e.stops.map(e=>e[0]),i),s=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]),a=e.stops[o][1],l=e.stops[o+1][1],c=fi[t.type]||Zn;return"function"==typeof a.evaluate?{evaluate(...t){const i=a.evaluate.apply(void 0,t),n=l.evaluate.apply(void 0,t);if(void 0!==i&&void 0!==n)return c(i,n,s,e.colorSpace)}}:c(a,l,s,e.colorSpace)}function Yn(e,t,i){switch(t.type){case"color":i=Ct.parse(i);break;case"formatted":i=Mt.fromString(i.toString());break;case"resolvedImage":i=Ot.fromString(i.toString());break;case"padding":i=Pt.parse(i);break;case"colorArray":i=Lt.parse(i);break;case"numberArray":i=Rt.parse(i);break;default:Qn(i)===t.type||"enum"===t.type&&t.values[i]||(i=void 0)}return qn(i,e.default,t.default)}Pn.register(Mn,{error:[{kind:"error"},[De],(e,[t])=>{throw new Ft(t.evaluate(e))}],typeof:[De,[Ve],(e,[t])=>Ke(Vt(t.evaluate(e)))],"to-rgba":[qe(ke,4),[ze],(e,[t])=>{const[i,n,r,o]=t.evaluate(e).rgb;return[255*i,255*n,255*r,o]}],rgb:[ze,[ke,ke,ke],Rn],rgba:[ze,[ke,ke,ke,ke],Rn],has:{type:Oe,overloads:[[[De],(e,[t])=>Ln(t.evaluate(e),e.properties())],[[De,Ne],(e,[t,i])=>Ln(t.evaluate(e),i.evaluate(e))]]},get:{type:Ve,overloads:[[[De],(e,[t])=>Fn(t.evaluate(e),e.properties())],[[De,Ne],(e,[t,i])=>Fn(t.evaluate(e),i.evaluate(e))]]},"feature-state":[Ve,[De],(e,[t])=>Fn(t.evaluate(e),e.featureState||{})],properties:[Ne,[],e=>e.properties()],"geometry-type":[De,[],e=>e.geometryType()],id:[Ve,[],e=>e.id()],zoom:[ke,[],e=>e.globals.zoom],"heatmap-density":[ke,[],e=>e.globals.heatmapDensity||0],elevation:[ke,[],e=>e.globals.elevation||0],"line-progress":[ke,[],e=>e.globals.lineProgress||0],accumulated:[Ve,[],e=>void 0===e.globals.accumulated?null:e.globals.accumulated],"+":[ke,kn(ke),(e,t)=>{let i=0;for(const n of t)i+=n.evaluate(e);return i}],"*":[ke,kn(ke),(e,t)=>{let i=1;for(const n of t)i*=n.evaluate(e);return i}],"-":{type:ke,overloads:[[[ke,ke],(e,[t,i])=>t.evaluate(e)-i.evaluate(e)],[[ke],(e,[t])=>-t.evaluate(e)]]},"/":[ke,[ke,ke],(e,[t,i])=>t.evaluate(e)/i.evaluate(e)],"%":[ke,[ke,ke],(e,[t,i])=>t.evaluate(e)%i.evaluate(e)],ln2:[ke,[],()=>Math.LN2],pi:[ke,[],()=>Math.PI],e:[ke,[],()=>Math.E],"^":[ke,[ke,ke],(e,[t,i])=>Math.pow(t.evaluate(e),i.evaluate(e))],sqrt:[ke,[ke],(e,[t])=>Math.sqrt(t.evaluate(e))],log10:[ke,[ke],(e,[t])=>Math.log(t.evaluate(e))/Math.LN10],ln:[ke,[ke],(e,[t])=>Math.log(t.evaluate(e))],log2:[ke,[ke],(e,[t])=>Math.log(t.evaluate(e))/Math.LN2],sin:[ke,[ke],(e,[t])=>Math.sin(t.evaluate(e))],cos:[ke,[ke],(e,[t])=>Math.cos(t.evaluate(e))],tan:[ke,[ke],(e,[t])=>Math.tan(t.evaluate(e))],asin:[ke,[ke],(e,[t])=>Math.asin(t.evaluate(e))],acos:[ke,[ke],(e,[t])=>Math.acos(t.evaluate(e))],atan:[ke,[ke],(e,[t])=>Math.atan(t.evaluate(e))],min:[ke,kn(ke),(e,t)=>Math.min(...t.map(t=>t.evaluate(e)))],max:[ke,kn(ke),(e,t)=>Math.max(...t.map(t=>t.evaluate(e)))],abs:[ke,[ke],(e,[t])=>Math.abs(t.evaluate(e))],round:[ke,[ke],(e,[t])=>{const i=t.evaluate(e);return i<0?-Math.round(-i):Math.round(i)}],floor:[ke,[ke],(e,[t])=>Math.floor(t.evaluate(e))],ceil:[ke,[ke],(e,[t])=>Math.ceil(t.evaluate(e))],"filter-==":[Oe,[De,Ve],(e,[t,i])=>e.properties()[t.value]===i.value],"filter-id-==":[Oe,[Ve],(e,[t])=>e.id()===t.value],"filter-type-==":[Oe,[De],(e,[t])=>e.geometryType()===t.value],"filter-<":[Oe,[De,Ve],(e,[t,i])=>{const n=e.properties()[t.value],r=i.value;return typeof n==typeof r&&n{const i=e.id(),n=t.value;return typeof i==typeof n&&i":[Oe,[De,Ve],(e,[t,i])=>{const n=e.properties()[t.value],r=i.value;return typeof n==typeof r&&n>r}],"filter-id->":[Oe,[Ve],(e,[t])=>{const i=e.id(),n=t.value;return typeof i==typeof n&&i>n}],"filter-<=":[Oe,[De,Ve],(e,[t,i])=>{const n=e.properties()[t.value],r=i.value;return typeof n==typeof r&&n<=r}],"filter-id-<=":[Oe,[Ve],(e,[t])=>{const i=e.id(),n=t.value;return typeof i==typeof n&&i<=n}],"filter->=":[Oe,[De,Ve],(e,[t,i])=>{const n=e.properties()[t.value],r=i.value;return typeof n==typeof r&&n>=r}],"filter-id->=":[Oe,[Ve],(e,[t])=>{const i=e.id(),n=t.value;return typeof i==typeof n&&i>=n}],"filter-has":[Oe,[Ve],(e,[t])=>t.value in e.properties()],"filter-has-id":[Oe,[],e=>null!==e.id()&&void 0!==e.id()],"filter-type-in":[Oe,[qe(De)],(e,[t])=>t.value.indexOf(e.geometryType())>=0],"filter-id-in":[Oe,[qe(Ve)],(e,[t])=>t.value.indexOf(e.id())>=0],"filter-in-small":[Oe,[De,qe(Ve)],(e,[t,i])=>i.value.indexOf(e.properties()[t.value])>=0],"filter-in-large":[Oe,[De,qe(Ve)],(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:Oe,overloads:[[[Oe,Oe],(e,[t,i])=>t.evaluate(e)&&i.evaluate(e)],[kn(Oe),(e,t)=>{for(const i of t)if(!i.evaluate(e))return!1;return!0}]]},any:{type:Oe,overloads:[[[Oe,Oe],(e,[t,i])=>t.evaluate(e)||i.evaluate(e)],[kn(Oe),(e,t)=>{for(const i of t)if(i.evaluate(e))return!0;return!1}]]},"!":[Oe,[Oe],(e,[t])=>!t.evaluate(e)],"is-supported-script":[Oe,[De],(e,[t])=>{const i=e.globals&&e.globals.isSupportedScript;return!i||i(t.evaluate(e))}],upcase:[De,[De],(e,[t])=>t.evaluate(e).toUpperCase()],downcase:[De,[De],(e,[t])=>t.evaluate(e).toLowerCase()],concat:[De,kn(Ve),(e,t)=>t.map(t=>jt(t.evaluate(e))).join("")],"resolved-locale":[De,[je],(e,[t])=>t.evaluate(e).resolvedLocale()]});class er{constructor(e,t,i){this.expression=e,this._warningHistory={},this._evaluator=new qt,this._defaultValue=t?function(e){if("color"===e.type&&$n(e.default))return new Ct(0,0,0,0);switch(e.type){case"color":return Ct.parse(e.default)||null;case"padding":return Pt.parse(e.default)||null;case"numberArray":return Rt.parse(e.default)||null;case"colorArray":return Lt.parse(e.default)||null;case"variableAnchorOffsetCollection":return Dt.parse(e.default)||null;case"projectionDefinition":return zt.parse(e.default)||null;default:return void 0===e.default?null:e.default}}(t):null,this._enumValues=t&&"enum"===t.type?t.values:null,this._globalState=i}evaluateWithoutErrorHandling(e,t,i,n,r,o){return this._globalState&&(e=cr(e,this._globalState)),this._evaluator.globals=e,this._evaluator.feature=t,this._evaluator.featureState=i,this._evaluator.canonical=n,this._evaluator.availableImages=r||null,this._evaluator.formattedSection=o,this.expression.evaluate(this._evaluator)}evaluate(e,t,i,n,r,o){this._globalState&&(e=cr(e,this._globalState)),this._evaluator.globals=e,this._evaluator.feature=t||null,this._evaluator.featureState=i||null,this._evaluator.canonical=n,this._evaluator.availableImages=r||null,this._evaluator.formattedSection=o||null;try{const e=this.expression.evaluate(this._evaluator);if(null==e||"number"==typeof e&&e!=e)return this._defaultValue;if(this._enumValues&&!(e in this._enumValues))throw new Ft(`Expected value to be one of ${Object.keys(this._enumValues).map(e=>JSON.stringify(e)).join(", ")}, but found ${JSON.stringify(e)} instead.`);return e}catch(e){return this._warningHistory[e.message]||(this._warningHistory[e.message]=!0,"undefined"!=typeof console&&console.warn(e.message)),this._defaultValue}}}function tr(e){return Array.isArray(e)&&e.length>0&&"string"==typeof e[0]&&e[0]in Mn}function ir(e,t,i){const n=new Kt(Mn,Dn,[],t?function(e){const t={color:ze,string:De,number:ke,enum:De,boolean:Oe,formatted:Ge,padding:He,numberArray:$e,colorArray:Qe,projectionDefinition:Ue,resolvedImage:Ze,variableAnchorOffsetCollection:We};return"array"===e.type?qe(t[e.value]||Ve,e.length):t[e.type]}(t):void 0),r=n.parse(e,void 0,void 0,void 0,t&&"string"===t.type?{typeAnnotation:"coerce"}:void 0);return r?Nn(new er(r,t,i)):Vn(n.errors)}class nr{constructor(e,t,i){this.kind=e,this._styleExpression=t,this.isStateDependent="constant"!==e&&!zn(t.expression),this.globalStateRefs=lr(t.expression),this._globalState=i}evaluateWithoutErrorHandling(e,t,i,n,r,o){return this._globalState&&(e=cr(e,this._globalState)),this._styleExpression.evaluateWithoutErrorHandling(e,t,i,n,r,o)}evaluate(e,t,i,n,r,o){return this._globalState&&(e=cr(e,this._globalState)),this._styleExpression.evaluate(e,t,i,n,r,o)}}class rr{constructor(e,t,i,n,r){this.kind=e,this.zoomStops=i,this._styleExpression=t,this.isStateDependent="camera"!==e&&!zn(t.expression),this.globalStateRefs=lr(t.expression),this.interpolationType=n,this._globalState=r}evaluateWithoutErrorHandling(e,t,i,n,r,o){return this._globalState&&(e=cr(e,this._globalState)),this._styleExpression.evaluateWithoutErrorHandling(e,t,i,n,r,o)}evaluate(e,t,i,n,r,o){return this._globalState&&(e=cr(e,this._globalState)),this._styleExpression.evaluate(e,t,i,n,r,o)}interpolationFactor(e,t,i){return this.interpolationType?di.interpolationFactor(this.interpolationType,e,t,i):0}}function or(e,t,i){const n=ir(e,t,i);if("error"===n.result)return n;const r=n.value.expression,o=On(r);if(!o&&!jn(t))return Vn([new Re("","data expressions not supported")]);const s=Un(r,["zoom"]);if(!s&&!Gn(t))return Vn([new Re("","zoom expressions not supported")]);const a=ar(r);return a||s?a instanceof Re?Vn([a]):a instanceof di&&!Hn(t)?Vn([new Re("",'"interpolate" expressions cannot be used with this property')]):Nn(a?new rr(o?"camera":"composite",n.value,a.labels,a instanceof di?a.interpolation:void 0,i):new nr(o?"constant":"source",n.value,i)):Vn([new Re("",'"zoom" expression may only be used as input to a top-level "step" or "interpolate" expression.')])}class sr{constructor(e,t){this._parameters=e,this._specification=t,Pe(this,Wn(this._parameters,this._specification))}static deserialize(e){return new sr(e._parameters,e._specification)}static serialize(e){return{_parameters:e._parameters,_specification:e._specification}}}function ar(e){let t=null;if(e instanceof Xt)t=ar(e.result);else if(e instanceof mi){for(const i of e.args)if(t=ar(i),t)break}else(e instanceof si||e instanceof di)&&e.input instanceof Pn&&"zoom"===e.input.name&&(t=e);return t instanceof Re||e.eachChild(e=>{const i=ar(e);i instanceof Re?t=i:!t&&i?t=new Re("",'"zoom" expression may only be used as input to a top-level "step" or "interpolate" expression.'):t&&i&&t!==i&&(t=new Re("",'Only one zoom-based "step" or "interpolate" subexpression may be used in an expression.'))}),t}function lr(e,t=new Set){return e instanceof In&&t.add(e.key),e.eachChild(e=>{lr(e,t)}),t}function cr(e,t){const{zoom:i,heatmapDensity:n,elevation:r,lineProgress:o,isSupportedScript:s,accumulated:a}=null!=e?e:{};return{zoom:i,heatmapDensity:n,elevation:r,lineProgress:o,isSupportedScript:s,accumulated:a,globalState:t}}function ur(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(!ur(t)&&"boolean"!=typeof t)return!1;return!0;default:return!0}}const hr={type:"boolean",default:!1,transition:!1,"property-type":"data-driven",expression:{interpolated:!1,parameters:["zoom","feature"]}};function dr(e,t){if(null==e)return{filter:()=>!0,needGeometry:!1,getGlobalStateRefs:()=>new Set};ur(e)||(e=mr(e));const i=ir(e,hr,t);if("error"===i.result)throw new Error(i.value.map(e=>`${e.key}: ${e.message}`).join(", "));return{filter:(e,t,n)=>i.value.evaluate(e,t,{},n),needGeometry:fr(e),getGlobalStateRefs:()=>lr(i.value.expression)}}function pr(e,t){return et?1:0}function fr(e){if(!Array.isArray(e))return!1;if("within"===e[0]||"distance"===e[0])return!0;for(let t=1;t"===t||"<="===t||">="===t?gr(e[1],e[2],t):"any"===t?(i=e.slice(1),["any"].concat(i.map(mr))):"all"===t?["all"].concat(e.slice(1).map(mr)):"none"===t?["all"].concat(e.slice(1).map(mr).map(yr)):"in"===t?_r(e[1],e.slice(2)):"!in"===t?yr(_r(e[1],e.slice(2))):"has"===t?Ar(e[1]):"!has"!==t||yr(Ar(e[1]));var i}function gr(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 _r(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(pr)]]:["filter-in-small",e,["literal",t]]}}function Ar(e){switch(e){case"$type":return!0;case"$id":return["filter-has-id"];default:return["filter-has",e]}}function yr(e){return["!",e]}function vr(e){const t=typeof e;if("number"===t||"boolean"===t||"string"===t||null==e)return JSON.stringify(e);if(Array.isArray(e)){let t="[";for(const i of e)t+=`${vr(i)},`;return`${t}]`}const i=Object.keys(e).sort();let n="{";for(let t=0;tn.maximum?[new Me(t,i,`${i} is greater than the maximum value ${n.maximum}`)]:[]}function Br(e){const t=e.valueSpec,i=wr(e.value.type);let n,r,o,s={};const a="categorical"!==i&&void 0===e.value.property,l=!a,c="array"===Qn(e.value.stops)&&"array"===Qn(e.value.stops[0])&&"object"===Qn(e.value.stops[0][0]),u=Er({key:e.key,value:e.value,valueSpec:e.styleSpec.function,validateSpec:e.validateSpec,style:e.style,styleSpec:e.styleSpec,objectElementValidators:{stops:function(e){if("identity"===i)return[new Me(e.key,e.value,'identity function may not have a "stops" property')];let t=[];const n=e.value;return t=t.concat(Cr({key:e.key,value:n,valueSpec:e.valueSpec,validateSpec:e.validateSpec,style:e.style,styleSpec:e.styleSpec,arrayElementValidator:h})),"array"===Qn(n)&&0===n.length&&t.push(new Me(e.key,n,"array must have at least one stop")),t},default:function(e){return e.validateSpec({key:e.key,value:e.value,valueSpec:t,validateSpec:e.validateSpec,style:e.style,styleSpec:e.styleSpec})}}});return"identity"===i&&a&&u.push(new Me(e.key,e.value,'missing required property "property"')),"identity"===i||e.value.stops||u.push(new Me(e.key,e.value,'missing required property "stops"')),"exponential"===i&&e.valueSpec.expression&&!Hn(e.valueSpec)&&u.push(new Me(e.key,e.value,"exponential functions not supported")),e.styleSpec.$version>=8&&(l&&!jn(e.valueSpec)?u.push(new Me(e.key,e.value,"property functions not supported")):a&&!Gn(e.valueSpec)&&u.push(new Me(e.key,e.value,"zoom functions not supported"))),"categorical"!==i&&!c||void 0!==e.value.property||u.push(new Me(e.key,e.value,'"property" property is required')),u;function h(e){let i=[];const n=e.value,a=e.key;if("array"!==Qn(n))return[new Me(a,n,`array expected, ${Qn(n)} found`)];if(2!==n.length)return[new Me(a,n,`array length 2 expected, length ${n.length} found`)];if(c){if("object"!==Qn(n[0]))return[new Me(a,n,`object expected, ${Qn(n[0])} found`)];if(void 0===n[0].zoom)return[new Me(a,n,"object stop key must have zoom")];if(void 0===n[0].value)return[new Me(a,n,"object stop key must have value")];if(o&&o>wr(n[0].zoom))return[new Me(a,n[0].zoom,"stop zoom values must appear in ascending order")];wr(n[0].zoom)!==o&&(o=wr(n[0].zoom),r=void 0,s={}),i=i.concat(Er({key:`${a}[0]`,value:n[0],valueSpec:{zoom:{}},validateSpec:e.validateSpec,style:e.style,styleSpec:e.styleSpec,objectElementValidators:{zoom:Sr,value:d}}))}else i=i.concat(d({key:`${a}[0]`,value:n[0],validateSpec:e.validateSpec,style:e.style,styleSpec:e.styleSpec},n));return tr(Tr(n[1]))?i.concat([new Me(`${a}[1]`,n[1],"expressions are not allowed in function stops.")]):i.concat(e.validateSpec({key:`${a}[1]`,value:n[1],valueSpec:t,validateSpec:e.validateSpec,style:e.style,styleSpec:e.styleSpec}))}function d(e,o){const a=Qn(e.value),l=wr(e.value),c=null!==e.value?e.value:o;if(n){if(a!==n)return[new Me(e.key,c,`${a} stop domain type must match previous stop domain type ${n}`)]}else n=a;if("number"!==a&&"string"!==a&&"boolean"!==a)return[new Me(e.key,c,"stop domain value must be a number, string, or boolean")];if("number"!==a&&"categorical"!==i){let n=`number expected, ${a} found`;return jn(t)&&void 0===i&&(n+='\nIf you intended to use a categorical function, specify `"type": "categorical"`.'),[new Me(e.key,c,n)]}return"categorical"!==i||"number"!==a||isFinite(l)&&Math.floor(l)===l?"categorical"!==i&&"number"===a&&void 0!==r&&lnew Me(`${e.key}${t.key}`,e.value,t.message));const i=t.value.expression||t.value._styleExpression.expression;if("property"===e.expressionContext&&"text-font"===e.propertyKey&&!i.outputDefined())return[new Me(e.key,e.value,`Invalid data expression for "${e.propertyKey}". Output values must be contained as literals within the expression.`)];if("property"===e.expressionContext&&"layout"===e.propertyType&&!zn(i))return[new Me(e.key,e.value,'"feature-state" data expressions are not supported with layout properties.')];if("filter"===e.expressionContext&&!zn(i))return[new Me(e.key,e.value,'"feature-state" data expressions are not supported with filters.')];if(e.expressionContext&&0===e.expressionContext.indexOf("cluster")){if(!Un(i,["zoom","feature-state"]))return[new Me(e.key,e.value,'"zoom" and "feature-state" expressions are not supported with cluster properties.')];if("cluster-initial"===e.expressionContext&&!On(i))return[new Me(e.key,e.value,"Feature data expressions are not supported with initial expression part of cluster properties.")]}return[]}function Mr(e){const t=e.key,i=e.value,n=Qn(i);return"string"!==n?[new Me(t,i,`color expected, ${n} found`)]:Ct.parse(String(i))?[]:[new Me(t,i,`color expected, "${i}" found`)]}function Pr(e){const t=e.key,i=e.value,n=e.valueSpec,r=[];return Array.isArray(n.values)?-1===n.values.indexOf(wr(i))&&r.push(new Me(t,i,`expected one of [${n.values.join(", ")}], ${JSON.stringify(i)} found`)):-1===Object.keys(n.values).indexOf(wr(i))&&r.push(new Me(t,i,`expected one of [${Object.keys(n.values).join(", ")}], ${JSON.stringify(i)} found`)),r}function Rr(e){return ur(Tr(e.value))?Ir(Pe({},e,{expressionContext:"filter",valueSpec:{value:"boolean"}})):Lr(e)}function Lr(e){const t=e.value,i=e.key;if("array"!==Qn(t))return[new Me(i,t,`array expected, ${Qn(t)} found`)];const n=e.styleSpec;let r,o=[];if(t.length<1)return[new Me(i,t,"filter array must have at least 1 element")];switch(o=o.concat(Pr({key:`${i}[0]`,value:t[0],valueSpec:n.filter_operator,style:e.style,styleSpec:e.styleSpec})),wr(t[0])){case"<":case"<=":case">":case">=":t.length>=2&&"$type"===wr(t[1])&&o.push(new Me(i,t,`"$type" cannot be use with operator "${t[0]}"`));case"==":case"!=":3!==t.length&&o.push(new Me(i,t,`filter array for operator "${t[0]}" must have 3 elements`));case"in":case"!in":t.length>=2&&(r=Qn(t[1]),"string"!==r&&o.push(new Me(`${i}[1]`,t[1],`string expected, ${r} found`)));for(let s=2;s{e in i&&t.push(new Me(n,i[e],`"${e}" is prohibited for ref layers`))}),r.layers.forEach(t=>{wr(t.id)===a&&(e=t)}),e?e.ref?t.push(new Me(n,i.ref,"ref cannot reference another ref layer")):s=wr(e.type):t.push(new Me(n,i.ref,`ref layer "${a}" not found`))}else if("background"!==s)if(i.source){const e=r.sources&&r.sources[i.source],o=e&&wr(e.type);e?"vector"===o&&"raster"===s?t.push(new Me(n,i.source,`layer "${i.id}" requires a raster source`)):"raster-dem"!==o&&"hillshade"===s||"raster-dem"!==o&&"color-relief"===s?t.push(new Me(n,i.source,`layer "${i.id}" requires a raster-dem source`)):"raster"===o&&"raster"!==s?t.push(new Me(n,i.source,`layer "${i.id}" requires a vector source`)):"vector"!==o||i["source-layer"]?"raster-dem"===o&&"hillshade"!==s&&"color-relief"!==s?t.push(new Me(n,i.source,"raster-dem source can only be used with layer type 'hillshade' or 'color-relief'.")):"line"!==s||!i.paint||!i.paint["line-gradient"]||"geojson"===o&&e.lineMetrics||t.push(new Me(n,i,`layer "${i.id}" specifies a line-gradient, which requires a GeoJSON source with \`lineMetrics\` enabled.`)):t.push(new Me(n,i,`layer "${i.id}" must specify a "source-layer"`)):t.push(new Me(n,i.source,`source "${i.source}" not found`))}else t.push(new Me(n,i,'missing required property "source"'));return t=t.concat(Er({key:n,value:i,valueSpec:o.layer,style:e.style,styleSpec:e.styleSpec,validateSpec:e.validateSpec,objectElementValidators:{"*":()=>[],type:()=>e.validateSpec({key:`${n}.type`,value:i.type,valueSpec:o.layer.type,style:e.style,styleSpec:e.styleSpec,validateSpec:e.validateSpec,object:i,objectKey:"type"}),filter:Rr,layout:e=>Er({layer:i,key:e.key,value:e.value,style:e.style,styleSpec:e.styleSpec,validateSpec:e.validateSpec,objectElementValidators:{"*":e=>Dr(Pe({layerType:s},e))}}),paint:e=>Er({layer:i,key:e.key,value:e.value,style:e.style,styleSpec:e.styleSpec,validateSpec:e.validateSpec,objectElementValidators:{"*":e=>kr(Pe({layerType:s},e))}})}})),t}function zr(e){const t=e.value,i=e.key,n=Qn(t);return"string"!==n?[new Me(i,t,`string expected, ${n} found`)]:[]}const Ur={promoteId:function({key:e,value:t}){if("string"===Qn(t))return zr({key:e,value:t});{const i=[];for(const n in t)i.push(...zr({key:`${e}.${n}`,value:t[n]}));return i}}};function Nr(e){const t=e.value,i=e.key,n=e.styleSpec,r=e.style,o=e.validateSpec;if(!t.type)return[new Me(i,t,'"type" is required')];const s=wr(t.type);let a;switch(s){case"vector":case"raster":return a=Er({key:i,value:t,valueSpec:n[`source_${s.replace("-","_")}`],style:e.style,styleSpec:n,objectElementValidators:Ur,validateSpec:o}),a;case"raster-dem":return a=function(e){var t;const i=null!==(t=e.sourceName)&&void 0!==t?t:"",n=e.value,r=e.styleSpec,o=r.source_raster_dem,s=e.style;let a=[];const l=Qn(n);if(void 0===n)return a;if("object"!==l)return a.push(new Me("source_raster_dem",n,`object expected, ${l} found`)),a;const c="custom"===wr(n.encoding),u=["redFactor","greenFactor","blueFactor","baseShift"],h=e.value.encoding?`"${e.value.encoding}"`:"Default";for(const t in n)!c&&u.includes(t)?a.push(new Me(t,n[t],`In "${i}": "${t}" is only valid when "encoding" is set to "custom". ${h} encoding found`)):o[t]?a=a.concat(e.validateSpec({key:t,value:n[t],valueSpec:o[t],validateSpec:e.validateSpec,style:s,styleSpec:r})):a.push(new Me(t,n[t],`unknown property "${t}"`));return a}({sourceName:i,value:t,style:e.style,styleSpec:n,validateSpec:o}),a;case"geojson":if(a=Er({key:i,value:t,valueSpec:n.source_geojson,style:r,styleSpec:n,validateSpec:o,objectElementValidators:Ur}),t.cluster)for(const e in t.clusterProperties){const[n,r]=t.clusterProperties[e],o="string"==typeof n?[n,["accumulated"],["get",e]]:n;a.push(...Ir({key:`${i}.${e}.map`,value:r,expressionContext:"cluster-map"})),a.push(...Ir({key:`${i}.${e}.reduce`,value:o,expressionContext:"cluster-reduce"}))}return a;case"video":return Er({key:i,value:t,valueSpec:n.source_video,style:r,validateSpec:o,styleSpec:n});case"image":return Er({key:i,value:t,valueSpec:n.source_image,style:r,validateSpec:o,styleSpec:n});case"canvas":return[new Me(i,null,"Please use runtime APIs to add canvas sources, rather than including them in stylesheets.","source.canvas")];default:return Pr({key:`${i}.type`,value:t.type,valueSpec:{values:["vector","raster","raster-dem","geojson","video","image"]}})}}function Vr(e){const t=e.value,i=e.styleSpec,n=i.light,r=e.style;let o=[];const s=Qn(t);if(void 0===t)return o;if("object"!==s)return o=o.concat([new Me("light",t,`object expected, ${s} found`)]),o;for(const s in t){const a=s.match(/^(.*)-transition$/);o=o.concat(a&&n[a[1]]&&n[a[1]].transition?e.validateSpec({key:s,value:t[s],valueSpec:i.transition,validateSpec:e.validateSpec,style:r,styleSpec:i}):n[s]?e.validateSpec({key:s,value:t[s],valueSpec:n[s],validateSpec:e.validateSpec,style:r,styleSpec:i}):[new Me(s,t[s],`unknown property "${s}"`)])}return o}function jr(e){const t=e.value,i=e.styleSpec,n=i.sky,r=e.style,o=Qn(t);if(void 0===t)return[];if("object"!==o)return[new Me("sky",t,`object expected, ${o} found`)];let s=[];for(const o in t)s=s.concat(n[o]?e.validateSpec({key:o,value:t[o],valueSpec:n[o],style:r,styleSpec:i}):[new Me(o,t[o],`unknown property "${o}"`)]);return s}function Gr(e){const t=e.value,i=e.styleSpec,n=i.terrain,r=e.style;let o=[];const s=Qn(t);if(void 0===t)return o;if("object"!==s)return o=o.concat([new Me("terrain",t,`object expected, ${s} found`)]),o;for(const s in t)o=o.concat(n[s]?e.validateSpec({key:s,value:t[s],valueSpec:n[s],validateSpec:e.validateSpec,style:r,styleSpec:i}):[new Me(s,t[s],`unknown property "${s}"`)]);return o}function Hr(e){let t=[];const i=e.value,n=e.key;if(Array.isArray(i)){const r=[],o=[];for(const s in i)i[s].id&&r.includes(i[s].id)&&t.push(new Me(n,i,`all the sprites' ids must be unique, but ${i[s].id} is duplicated`)),r.push(i[s].id),i[s].url&&o.includes(i[s].url)&&t.push(new Me(n,i,`all the sprites' URLs must be unique, but ${i[s].url} is duplicated`)),o.push(i[s].url),t=t.concat(Er({key:`${n}[${s}]`,value:i[s],valueSpec:{id:{type:"string",required:!0},url:{type:"string",required:!0}},validateSpec:e.validateSpec}));return t}return zr({key:n,value:i})}function Qr(e){return t=e.value,Boolean(t)&&t.constructor===Object?[]:[new Me(e.key,e.value,`object expected, ${Qn(e.value)} found`)];var t}const $r={"*":()=>[],array:Cr,boolean:function(e){const t=e.value,i=e.key,n=Qn(t);return"boolean"!==n?[new Me(i,t,`boolean expected, ${n} found`)]:[]},number:Sr,color:Mr,constants:br,enum:Pr,filter:Rr,function:Br,layer:Or,object:Er,source:Nr,light:Vr,sky:jr,terrain:Gr,projection:function(e){const t=e.value,i=e.styleSpec,n=i.projection,r=e.style,o=Qn(t);if(void 0===t)return[];if("object"!==o)return[new Me("projection",t,`object expected, ${o} found`)];let s=[];for(const o in t)s=s.concat(n[o]?e.validateSpec({key:o,value:t[o],valueSpec:n[o],style:r,styleSpec:i}):[new Me(o,t[o],`unknown property "${o}"`)]);return s},projectionDefinition:function(e){const t=e.key;let i=e.value;i=i instanceof String?i.valueOf():i;const n=Qn(i);return"array"!==n||function(e){return Array.isArray(e)&&3===e.length&&"string"==typeof e[0]&&"string"==typeof e[1]&&"number"==typeof e[2]}(i)||function(e){return!!["interpolate","step","literal"].includes(e[0])}(i)?["array","string"].includes(n)?[]:[new Me(t,i,`projection expected, invalid type "${n}" found`)]:[new Me(t,i,`projection expected, invalid array ${JSON.stringify(i)} found`)]},string:zr,formatted:function(e){return 0===zr(e).length?[]:Ir(e)},resolvedImage:function(e){return 0===zr(e).length?[]:Ir(e)},padding:function(e){const t=e.key,i=e.value;if("array"===Qn(i)){if(i.length<1||i.length>4)return[new Me(t,i,`padding requires 1 to 4 values; ${i.length} values found`)];const n={type:"number"};let r=[];for(let o=0;o[]}})),e.constants&&(i=i.concat(br({key:"constants",value:e.constants}))),Xr(i)}function Kr(e){return function(t){return e(Object.assign({},t,{validateSpec:Zr}))}}function Xr(e){return[].concat(e).sort((e,t)=>e.line-t.line)}function Jr(e){return function(...t){return Xr(e.apply(this,t))}}qr.source=Jr(Kr(Nr)),qr.sprite=Jr(Kr(Hr)),qr.glyphs=Jr(Kr(Wr)),qr.light=Jr(Kr(Vr)),qr.sky=Jr(Kr(jr)),qr.terrain=Jr(Kr(Gr)),qr.state=Jr(Kr(Qr)),qr.layer=Jr(Kr(Or)),qr.filter=Jr(Kr(Rr)),qr.paintProperty=Jr(Kr(kr)),qr.layoutProperty=Jr(Kr(Dr));const Yr=Ae,eo=qr,to=eo.light,io=eo.sky,no=eo.paintProperty,ro=eo.layoutProperty;function oo(e,t){let i=!1;if(t&&t.length)for(const n of t)e.fire(new ge(new Error(n.message))),i=!0;return i}class so{constructor(e,t,i){const n=this.cells=[];if(e instanceof ArrayBuffer){this.arrayBuffer=e;const r=new Int32Array(this.arrayBuffer);e=r[0],this.d=(t=r[1])+2*(i=r[2]);for(let e=0;e=c[l+0]&&n>=c[l+1])?(s[h]=!0,o.push(r[h])):s[h]=!1}}}}_forEachCell(e,t,i,n,r,o,s,a){const l=this._convertToCellCoord(e),c=this._convertToCellCoord(t),u=this._convertToCellCoord(i),h=this._convertToCellCoord(n);for(let d=l;d<=u;d++)for(let l=c;l<=h;l++){const c=this.d*l+d;if((!a||a(this._convertFromCellCoord(d),this._convertFromCellCoord(l),this._convertFromCellCoord(d+1),this._convertFromCellCoord(l+1)))&&r.call(this,e,t,i,n,c,o,s,a))return}}_convertFromCellCoord(e){return(e-this.padding)/this.scale}_convertToCellCoord(e){return Math.max(0,Math.min(this.d-1,Math.floor(e*this.scale)+this.padding))}toArrayBuffer(){if(this.arrayBuffer)return this.arrayBuffer;const e=this.cells,t=3+this.cells.length+1+1;let i=0;for(let e=0;e=0)continue;const o=e[n];r[n]=ao[i].shallow.indexOf(n)>=0?o:po(o,t)}e instanceof Error&&(r.message=e.message)}if(r.$name)throw new Error("$name property is reserved for worker serialization logic.");return"Object"!==i&&(r.$name=i),r}function fo(e){if(ho(e))return e;if(Array.isArray(e))return e.map(fo);if("object"!=typeof e)throw new Error("can't deserialize object of type "+typeof e);const t=uo(e)||"Object";if(!ao[t])throw new Error(`can't deserialize unregistered class ${t}`);const{klass:i}=ao[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 i of Object.keys(e)){if("$name"===i)continue;const r=e[i];n[i]=ao[t].shallow.indexOf(i)>=0?r:fo(r)}return n}class mo{constructor(){this.first=!0}update(e,t){const i=Math.floor(e);return this.first?(this.first=!1,this.lastIntegerZoom=i,this.lastIntegerZoomTime=0,this.lastZoom=e,this.lastFloorZoom=i,!0):(this.lastFloorZoom>i?(this.lastIntegerZoom=i+1,this.lastIntegerZoomTime=t):this.lastFloorZoom{try{return new RegExp(`\\p{sc=${e}}`,"u").source}catch(e){return null}}).filter(e=>e);return new RegExp(t.join("|"),"u")}const bo=xo(["Arab","Dupl","Mong","Ougr","Syrc"]);function wo(e){return!bo.test(String.fromCodePoint(e))}function To(e){return!(_o(e)||(t=e,/[\xA7\xA9\xAE\xB1\xBC-\xBE\xD7\xF7\u2016\u2020\u2021\u2030\u2031\u203B\u203C\u2042\u2047-\u2049\u2051\u2100-\u218F\u221E\u2234\u2235\u2300-\u2307\u230C-\u231F\u2324-\u2328\u232B\u237D-\u239A\u23BE-\u23CD\u23CF\u23D1-\u23DB\u23E2-\u2422\u2424-\u24FF\u25A0-\u2619\u2620-\u2767\u2776-\u2793\u2B12-\u2B2F\u2B50-\u2B59\u2BB8-\u2BEB\u3000-\u303F\u30A0-\u30FF\uE000-\uF8FF\uFE30-\uFE6F\uFF00-\uFFEF\uFFFC\uFFFD]|[\uDB80-\uDBFF][\uDC00-\uDFFF]/gim.test(String.fromCodePoint(t))));var t}const Eo=xo(["Adlm","Arab","Armi","Avst","Chrs","Cprt","Egyp","Elym","Gara","Hatr","Hebr","Hung","Khar","Lydi","Mand","Mani","Mend","Merc","Mero","Narb","Nbat","Nkoo","Orkh","Palm","Phli","Phlp","Phnx","Prti","Rohg","Samr","Sarb","Sogo","Syrc","Thaa","Todr","Yezi"]);function Co(e){return Eo.test(String.fromCodePoint(e))}function So(e,t){return!(!t&&Co(e)||/[\u0900-\u0DFF\u0F00-\u109F\u1780-\u17FF]/gim.test(String.fromCodePoint(e)))}function Bo(e){for(const t of e)if(Co(t.codePointAt(0)))return!0;return!1}const Io=new class{constructor(){this.TIMEOUT=5e3,this.applyArabicShaping=null,this.processBidirectionalText=null,this.processStyledBidirectionalText=null,this.pluginStatus="unavailable",this.pluginURL=null,this.loadScriptResolve=()=>{}}setState(e){this.pluginStatus=e.pluginStatus,this.pluginURL=e.pluginURL}getState(){return{pluginStatus:this.pluginStatus,pluginURL:this.pluginURL}}setMethods(e){if(Io.isParsed())throw new Error("RTL text plugin already registered.");this.applyArabicShaping=e.applyArabicShaping,this.processBidirectionalText=e.processBidirectionalText,this.processStyledBidirectionalText=e.processStyledBidirectionalText,this.loadScriptResolve()}isParsed(){return null!=this.applyArabicShaping&&null!=this.processBidirectionalText&&null!=this.processStyledBidirectionalText}getRTLTextPluginStatus(){return this.pluginStatus}syncState(e,i){return t(this,void 0,void 0,function*(){if(this.isParsed())return this.getState();if("loading"!==e.pluginStatus)return this.setState(e),e;const t=e.pluginURL,n=new Promise(e=>{this.loadScriptResolve=e});i(t);const r=new Promise(e=>setTimeout(()=>e(),this.TIMEOUT));if(yield Promise.race([n,r]),this.isParsed()){const e={pluginStatus:"loaded",pluginURL:t};return this.setState(e),e}throw this.setState({pluginStatus:"error",pluginURL:""}),new Error(`RTL Text Plugin failed to import scripts from ${t}`)})}};class Mo{constructor(e,t){this.isSupportedScript=Po,this.zoom=e,t?(this.now=t.now||0,this.fadeDuration=t.fadeDuration||0,this.zoomHistory=t.zoomHistory||new mo,this.transition=t.transition||{}):(this.now=0,this.fadeDuration=0,this.zoomHistory=new mo,this.transition={})}crossFadingFactor(){return 0===this.fadeDuration?1:Math.min((this.now-this.zoomHistory.lastIntegerZoomTime)/this.fadeDuration,1)}getCrossfadeParameters(){const e=this.zoom,t=e-Math.floor(e),i=this.crossFadingFactor();return e>this.zoomHistory.lastIntegerZoom?{fromScale:2,toScale:1,t:t+(1-t)*i}:{fromScale:.5,toScale:1,t:1-(1-i)*t}}}function Po(e){return function(e,t){for(const i of e)if(!So(i.codePointAt(0),t))return!1;return!0}(e,"loaded"===Io.getRTLTextPluginStatus())}const Ro="-transition";class Lo{constructor(e,t,i){this.property=e,this.value=t,this.expression=function(e,t,i){if($n(e))return new sr(e,t);if(tr(e)){const n=or(e,t,i);if("error"===n.result)throw new Error(n.value.map(e=>`${e.key}: ${e.message}`).join(", "));return n.value}{let i=e;return"color"===t.type&&"string"==typeof e?i=Ct.parse(e):"padding"!==t.type||"number"!=typeof e&&!Array.isArray(e)?"numberArray"!==t.type||"number"!=typeof e&&!Array.isArray(e)?"colorArray"!==t.type||"string"!=typeof e&&!Array.isArray(e)?"variableAnchorOffsetCollection"===t.type&&Array.isArray(e)?i=Dt.parse(e):"projectionDefinition"===t.type&&"string"==typeof e&&(i=zt.parse(e)):i=Lt.parse(e):i=Rt.parse(e):i=Pt.parse(e),{globalStateRefs:new Set,_globalState:null,kind:"constant",evaluate:()=>i}}}(void 0===t?e.specification.default:t,e.specification,i)}isDataDriven(){return"source"===this.expression.kind||"composite"===this.expression.kind}getGlobalStateRefs(){return this.expression.globalStateRefs||new Set}possiblyEvaluate(e,t,i){return this.property.possiblyEvaluate(this,e,t,i)}}class Fo{constructor(e,t){this.property=e,this.value=new Lo(e,void 0,t)}transitioned(e,t){return new Do(this.property,this.value,t,z({},e.transition,this.transition),e.now)}untransitioned(){return new Do(this.property,this.value,null,{},0)}}class ko{constructor(e,t){this._properties=e,this._values=Object.create(e.defaultTransitionablePropertyValues),this._globalState=t}getValue(e){return j(this._values[e].value.value)}setValue(e,t){Object.prototype.hasOwnProperty.call(this._values,e)||(this._values[e]=new Fo(this._values[e].property,this._globalState)),this._values[e].value=new Lo(this._values[e].property,null===t?void 0:j(t),this._globalState)}getTransition(e){return j(this._values[e].transition)}setTransition(e,t){Object.prototype.hasOwnProperty.call(this._values,e)||(this._values[e]=new Fo(this._values[e].property,this._globalState)),this._values[e].transition=j(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}${Ro}`]=n)}return e}transitioned(e,t){const i=new Oo(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 Oo(this._properties);for(const t of Object.keys(this._values))e._values[t]=this._values[t].untransitioned();return e}}class Do{constructor(e,t,i,n,r){this.property=e,this.value=t,this.begin=r+n.delay||0,this.end=this.begin+n.duration||0,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(nn.zoomHistory.lastIntegerZoom?{from:e,to:t}:{from:i,to:t}}interpolate(e){return e}}class Ho{constructor(e){this.specification=e}possiblyEvaluate(e,t,i,n){if(void 0!==e.value){if("constant"===e.expression.kind){const r=e.expression.evaluate(t,null,{},i,n);return this._calculate(r,r,r,t)}return this._calculate(e.expression.evaluate(new Mo(Math.floor(t.zoom-1),t)),e.expression.evaluate(new Mo(Math.floor(t.zoom),t)),e.expression.evaluate(new Mo(Math.floor(t.zoom+1),t)),t)}}_calculate(e,t,i,n){return n.zoom>n.zoomHistory.lastIntegerZoom?{from:e,to:t}:{from:i,to:t}}interpolate(e){return e}}class Qo{constructor(e){this.specification=e}possiblyEvaluate(e,t,i,n){return!!e.expression.evaluate(t,null,{},i,n)}interpolate(){return!1}}class $o{constructor(e){this.properties=e,this.defaultPropertyValues={},this.defaultTransitionablePropertyValues={},this.defaultTransitioningPropertyValues={},this.defaultPossiblyEvaluatedValues={},this.overridableProperties=[];for(const t in e){const i=e[t];i.specification.overridable&&this.overridableProperties.push(t);const n=this.defaultPropertyValues[t]=new Lo(i,void 0,void 0),r=this.defaultTransitionablePropertyValues[t]=new Fo(i,void 0);this.defaultTransitioningPropertyValues[t]=r.untransitioned(),this.defaultPossiblyEvaluatedValues[t]=n.possiblyEvaluate({})}}}lo("DataDrivenProperty",jo),lo("DataConstantProperty",Vo),lo("CrossFadedDataDrivenProperty",Go),lo("CrossFadedProperty",Ho),lo("ColorRampProperty",Qo);class Zo extends _e{constructor(e,t,i){if(super(),this.id=e.id,this.type=e.type,this._globalState=i,this._featureFilter={filter:()=>!0,needGeometry:!1,getGlobalStateRefs:()=>new Set},"custom"!==e.type&&(this.metadata=e.metadata,this.minzoom=e.minzoom,this.maxzoom=e.maxzoom,"background"!==e.type&&(this.source=e.source,this.sourceLayer=e["source-layer"],this.filter=e.filter,this._featureFilter=dr(e.filter,i)),t.layout&&(this._unevaluatedLayout=new zo(t.layout,i)),t.paint)){this._transitionablePaint=new ko(t.paint,i);for(const t in e.paint)this.setPaintProperty(t,e.paint[t],{validate:!1});for(const t in e.layout)this.setLayoutProperty(t,e.layout[t],{validate:!1});this._transitioningPaint=this._transitionablePaint.untransitioned(),this.paint=new No(t.paint)}}setFilter(e){this.filter=e,this._featureFilter=dr(e,this._globalState)}getCrossfadeParameters(){return this._crossfadeParameters}getLayoutProperty(e){return"visibility"===e?this.visibility:this._unevaluatedLayout.getValue(e)}getLayoutAffectingGlobalStateRefs(){const e=new Set;if(this._unevaluatedLayout)for(const t in this._unevaluatedLayout._values){const i=this._unevaluatedLayout._values[t];for(const t of i.getGlobalStateRefs())e.add(t)}for(const t of this._featureFilter.getGlobalStateRefs())e.add(t);return e}getPaintAffectingGlobalStateRefs(){var e;const t=new globalThis.Map;if(this._transitionablePaint)for(const i in this._transitionablePaint._values){const n=this._transitionablePaint._values[i].value;for(const r of n.getGlobalStateRefs()){const o=null!==(e=t.get(r))&&void 0!==e?e:[];o.push({name:i,value:n.value}),t.set(r,o)}}return t}setLayoutProperty(e,t,i={}){null!=t&&this._validate(ro,`layers.${this.id}.layout.${e}`,e,t,i)||("visibility"!==e?this._unevaluatedLayout.setValue(e,t):this.visibility=t)}getPaintProperty(e){return e.endsWith(Ro)?this._transitionablePaint.getTransition(e.slice(0,-11)):this._transitionablePaint.getValue(e)}setPaintProperty(e,t,i={}){if(null!=t&&this._validate(no,`layers.${this.id}.paint.${e}`,e,t,i))return!1;if(e.endsWith(Ro))return this._transitionablePaint.setTransition(e.slice(0,-11),t||void 0),!1;{const i=this._transitionablePaint._values[e],n="cross-faded-data-driven"===i.property.specification["property-type"],r=i.value.isDataDriven(),o=i.value;this._transitionablePaint.setValue(e,t),this._handleSpecialPaintPropertyUpdate(e);const s=this._transitionablePaint._values[e].value;return s.isDataDriven()||r||n||this._handleOverridablePaintPropertyUpdate(e,o,s)}}_handleSpecialPaintPropertyUpdate(e){}_handleOverridablePaintPropertyUpdate(e,t,i){return!1}isHidden(e,t=!1){return!!(this.minzoom&&e<(t?Math.floor(this.minzoom):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){e.getCrossfadeParameters&&(this._crossfadeParameters=e.getCrossfadeParameters()),this._unevaluatedLayout&&(this.layout=this._unevaluatedLayout.possiblyEvaluate(e,void 0,t)),this.paint=this._transitioningPaint.possiblyEvaluate(e,void 0,t)}serialize(){const e={id:this.id,type:this.type,source:this.source,"source-layer":this.sourceLayer,metadata:this.metadata,minzoom:this.minzoom,maxzoom:this.maxzoom,filter:this.filter,layout:this._unevaluatedLayout&&this._unevaluatedLayout.serialize(),paint:this._transitionablePaint&&this._transitionablePaint.serialize()};return this.visibility&&(e.layout=e.layout||{},e.layout.visibility=this.visibility),V(e,(e,t)=>!(void 0===e||"layout"===t&&!Object.keys(e).length||"paint"===t&&!Object.keys(e).length))}_validate(e,t,i,n,r={}){return(!r||!1!==r.validate)&&oo(this,e.call(eo,{key:t,layerType:this.type,objectKey:i,value:n,styleSpec:Ae,style:{glyphs:!0,sprite:!0}}))}is3D(){return!1}isTileClipped(){return!1}hasOffscreenPass(){return!1}resize(){}isStateDependent(){for(const e in this.paint._values){const t=this.paint.get(e);if(t instanceof Uo&&jn(t.property.specification)&&("source"===t.value.kind||"composite"===t.value.kind)&&t.value.isStateDependent)return!0}return!1}}let Wo;var qo={get paint(){return Wo=Wo||new $o({"raster-opacity":new Vo(Ae.paint_raster["raster-opacity"]),"raster-hue-rotate":new Vo(Ae.paint_raster["raster-hue-rotate"]),"raster-brightness-min":new Vo(Ae.paint_raster["raster-brightness-min"]),"raster-brightness-max":new Vo(Ae.paint_raster["raster-brightness-max"]),"raster-saturation":new Vo(Ae.paint_raster["raster-saturation"]),"raster-contrast":new Vo(Ae.paint_raster["raster-contrast"]),"raster-resampling":new Vo(Ae.paint_raster["raster-resampling"]),"raster-fade-duration":new Vo(Ae.paint_raster["raster-fade-duration"])})}};class Ko extends Zo{constructor(e,t){super(e,qo,t)}}const Xo={Int8:Int8Array,Uint8:Uint8Array,Int16:Int16Array,Uint16:Uint16Array,Int32:Int32Array,Uint32:Uint32Array,Float32:Float32Array};class Jo{constructor(e,t){this._structArray=e,this._pos1=t*this.size,this._pos2=this._pos1/2,this._pos4=this._pos1/4,this._pos8=this._pos1/8}}class Yo{constructor(){this.isTransferred=!1,this.capacity=-1,this.resize(0)}static serialize(e,t){return e._trim(),t&&(e.isTransferred=!0,t.push(e.arrayBuffer)),{length:e.length,arrayBuffer:e.arrayBuffer}}static deserialize(e){const t=Object.create(this.prototype);return t.arrayBuffer=e.arrayBuffer,t.length=e.length,t.capacity=e.arrayBuffer.byteLength/t.bytesPerElement,t._refreshViews(),t}_trim(){this.length!==this.capacity&&(this.capacity=this.length,this.arrayBuffer=this.arrayBuffer.slice(0,this.length*this.bytesPerElement),this._refreshViews())}clear(){this.length=0}resize(e){this.reserve(e),this.length=e}reserve(e){if(e>this.capacity){this.capacity=Math.max(e,Math.floor(5*this.capacity),128),this.arrayBuffer=new ArrayBuffer(this.capacity*this.bytesPerElement);const t=this.uint8;this._refreshViews(),t&&this.uint8.set(t)}}_refreshViews(){throw new Error("_refreshViews() must be implemented by each concrete StructArray layout")}}function es(e,t=1){let i=0,n=0;return{members:e.map(e=>{const r=Xo[e.type].BYTES_PER_ELEMENT,o=i=ts(i,Math.max(t,r)),s=e.components||1;return n=Math.max(n,r),i+=r*s,{name:e.name,type:e.type,components:s,offset:o}}),size:ts(i,Math.max(n,t)),alignment:t}}function ts(e,t){return Math.ceil(e/t)*t}class is extends Yo{_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}}is.prototype.bytesPerElement=4,lo("StructArrayLayout2i4",is);class ns extends Yo{_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}}ns.prototype.bytesPerElement=6,lo("StructArrayLayout3i6",ns);class rs extends Yo{_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}}rs.prototype.bytesPerElement=8,lo("StructArrayLayout4i8",rs);class os extends Yo{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer)}emplaceBack(e,t,i,n,r,o){const s=this.length;return this.resize(s+1),this.emplace(s,e,t,i,n,r,o)}emplace(e,t,i,n,r,o,s){const a=6*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,this.int16[a+5]=s,e}}os.prototype.bytesPerElement=12,lo("StructArrayLayout2i4i12",os);class ss extends Yo{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer)}emplaceBack(e,t,i,n,r,o){const s=this.length;return this.resize(s+1),this.emplace(s,e,t,i,n,r,o)}emplace(e,t,i,n,r,o,s){const a=4*e,l=8*e;return this.int16[a+0]=t,this.int16[a+1]=i,this.uint8[l+4]=n,this.uint8[l+5]=r,this.uint8[l+6]=o,this.uint8[l+7]=s,e}}ss.prototype.bytesPerElement=8,lo("StructArrayLayout2i4ub8",ss);class as extends Yo{_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}}as.prototype.bytesPerElement=8,lo("StructArrayLayout2f8",as);class ls extends Yo{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.uint16=new Uint16Array(this.arrayBuffer)}emplaceBack(e,t,i,n,r,o,s,a,l,c){const u=this.length;return this.resize(u+1),this.emplace(u,e,t,i,n,r,o,s,a,l,c)}emplace(e,t,i,n,r,o,s,a,l,c,u){const h=10*e;return this.uint16[h+0]=t,this.uint16[h+1]=i,this.uint16[h+2]=n,this.uint16[h+3]=r,this.uint16[h+4]=o,this.uint16[h+5]=s,this.uint16[h+6]=a,this.uint16[h+7]=l,this.uint16[h+8]=c,this.uint16[h+9]=u,e}}ls.prototype.bytesPerElement=20,lo("StructArrayLayout10ui20",ls);class cs extends Yo{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.uint16=new Uint16Array(this.arrayBuffer)}emplaceBack(e,t,i,n,r,o,s,a){const l=this.length;return this.resize(l+1),this.emplace(l,e,t,i,n,r,o,s,a)}emplace(e,t,i,n,r,o,s,a,l){const c=8*e;return this.uint16[c+0]=t,this.uint16[c+1]=i,this.uint16[c+2]=n,this.uint16[c+3]=r,this.uint16[c+4]=o,this.uint16[c+5]=s,this.uint16[c+6]=a,this.uint16[c+7]=l,e}}cs.prototype.bytesPerElement=16,lo("StructArrayLayout8ui16",cs);class us extends Yo{_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,s,a,l,c,u,h){const d=this.length;return this.resize(d+1),this.emplace(d,e,t,i,n,r,o,s,a,l,c,u,h)}emplace(e,t,i,n,r,o,s,a,l,c,u,h,d){const p=12*e;return this.int16[p+0]=t,this.int16[p+1]=i,this.int16[p+2]=n,this.int16[p+3]=r,this.uint16[p+4]=o,this.uint16[p+5]=s,this.uint16[p+6]=a,this.uint16[p+7]=l,this.int16[p+8]=c,this.int16[p+9]=u,this.int16[p+10]=h,this.int16[p+11]=d,e}}us.prototype.bytesPerElement=24,lo("StructArrayLayout4i4ui4i24",us);class hs extends Yo{_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}}hs.prototype.bytesPerElement=12,lo("StructArrayLayout3f12",hs);class ds extends Yo{_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}}ds.prototype.bytesPerElement=4,lo("StructArrayLayout1ul4",ds);class ps extends Yo{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer),this.uint32=new Uint32Array(this.arrayBuffer),this.uint16=new Uint16Array(this.arrayBuffer)}emplaceBack(e,t,i,n,r,o,s,a,l){const c=this.length;return this.resize(c+1),this.emplace(c,e,t,i,n,r,o,s,a,l)}emplace(e,t,i,n,r,o,s,a,l,c){const u=10*e,h=5*e;return this.int16[u+0]=t,this.int16[u+1]=i,this.int16[u+2]=n,this.int16[u+3]=r,this.int16[u+4]=o,this.int16[u+5]=s,this.uint32[h+3]=a,this.uint16[u+8]=l,this.uint16[u+9]=c,e}}ps.prototype.bytesPerElement=20,lo("StructArrayLayout6i1ul2ui20",ps);class fs extends Yo{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer)}emplaceBack(e,t,i,n,r,o){const s=this.length;return this.resize(s+1),this.emplace(s,e,t,i,n,r,o)}emplace(e,t,i,n,r,o,s){const a=6*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,this.int16[a+5]=s,e}}fs.prototype.bytesPerElement=12,lo("StructArrayLayout2i2i2i12",fs);class ms extends Yo{_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 s=4*e,a=8*e;return this.float32[s+0]=t,this.float32[s+1]=i,this.float32[s+2]=n,this.int16[a+6]=r,this.int16[a+7]=o,e}}ms.prototype.bytesPerElement=16,lo("StructArrayLayout2f1f2i16",ms);class gs extends Yo{_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,o){const s=this.length;return this.resize(s+1),this.emplace(s,e,t,i,n,r,o)}emplace(e,t,i,n,r,o,s){const a=16*e,l=4*e,c=8*e;return this.uint8[a+0]=t,this.uint8[a+1]=i,this.float32[l+1]=n,this.float32[l+2]=r,this.int16[c+6]=o,this.int16[c+7]=s,e}}gs.prototype.bytesPerElement=16,lo("StructArrayLayout2ub2f2i16",gs);class _s extends Yo{_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}}_s.prototype.bytesPerElement=6,lo("StructArrayLayout3ui6",_s);class As extends Yo{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer),this.uint16=new Uint16Array(this.arrayBuffer),this.uint32=new Uint32Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer)}emplaceBack(e,t,i,n,r,o,s,a,l,c,u,h,d,p,f,m,g){const _=this.length;return this.resize(_+1),this.emplace(_,e,t,i,n,r,o,s,a,l,c,u,h,d,p,f,m,g)}emplace(e,t,i,n,r,o,s,a,l,c,u,h,d,p,f,m,g,_){const A=24*e,y=12*e,v=48*e;return this.int16[A+0]=t,this.int16[A+1]=i,this.uint16[A+2]=n,this.uint16[A+3]=r,this.uint32[y+2]=o,this.uint32[y+3]=s,this.uint32[y+4]=a,this.uint16[A+10]=l,this.uint16[A+11]=c,this.uint16[A+12]=u,this.float32[y+7]=h,this.float32[y+8]=d,this.uint8[v+36]=p,this.uint8[v+37]=f,this.uint8[v+38]=m,this.uint32[y+10]=g,this.int16[A+22]=_,e}}As.prototype.bytesPerElement=48,lo("StructArrayLayout2i2ui3ul3ui2f3ub1ul1i48",As);class ys extends Yo{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer),this.uint16=new Uint16Array(this.arrayBuffer),this.uint32=new Uint32Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer)}emplaceBack(e,t,i,n,r,o,s,a,l,c,u,h,d,p,f,m,g,_,A,y,v,x,b,w,T,E,C,S){const B=this.length;return this.resize(B+1),this.emplace(B,e,t,i,n,r,o,s,a,l,c,u,h,d,p,f,m,g,_,A,y,v,x,b,w,T,E,C,S)}emplace(e,t,i,n,r,o,s,a,l,c,u,h,d,p,f,m,g,_,A,y,v,x,b,w,T,E,C,S,B){const I=32*e,M=16*e;return this.int16[I+0]=t,this.int16[I+1]=i,this.int16[I+2]=n,this.int16[I+3]=r,this.int16[I+4]=o,this.int16[I+5]=s,this.int16[I+6]=a,this.int16[I+7]=l,this.uint16[I+8]=c,this.uint16[I+9]=u,this.uint16[I+10]=h,this.uint16[I+11]=d,this.uint16[I+12]=p,this.uint16[I+13]=f,this.uint16[I+14]=m,this.uint16[I+15]=g,this.uint16[I+16]=_,this.uint16[I+17]=A,this.uint16[I+18]=y,this.uint16[I+19]=v,this.uint16[I+20]=x,this.uint16[I+21]=b,this.uint16[I+22]=w,this.uint32[M+12]=T,this.float32[M+13]=E,this.float32[M+14]=C,this.uint16[I+30]=S,this.uint16[I+31]=B,e}}ys.prototype.bytesPerElement=64,lo("StructArrayLayout8i15ui1ul2f2ui64",ys);class vs extends Yo{_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}}vs.prototype.bytesPerElement=4,lo("StructArrayLayout1f4",vs);class xs extends Yo{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.uint16=new Uint16Array(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.uint16[6*e+0]=t,this.float32[r+1]=i,this.float32[r+2]=n,e}}xs.prototype.bytesPerElement=12,lo("StructArrayLayout1ui2f12",xs);class bs extends Yo{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.uint32=new Uint32Array(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=4*e;return this.uint32[2*e+0]=t,this.uint16[r+2]=i,this.uint16[r+3]=n,e}}bs.prototype.bytesPerElement=8,lo("StructArrayLayout1ul2ui8",bs);class ws extends Yo{_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}}ws.prototype.bytesPerElement=4,lo("StructArrayLayout2ui4",ws);class Ts extends Yo{_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}}Ts.prototype.bytesPerElement=2,lo("StructArrayLayout1ui2",Ts);class Es extends Yo{_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}}Es.prototype.bytesPerElement=16,lo("StructArrayLayout4f16",Es);class Cs extends Jo{get anchorPointX(){return this._structArray.int16[this._pos2+0]}get anchorPointY(){return this._structArray.int16[this._pos2+1]}get x1(){return this._structArray.int16[this._pos2+2]}get y1(){return this._structArray.int16[this._pos2+3]}get x2(){return this._structArray.int16[this._pos2+4]}get y2(){return this._structArray.int16[this._pos2+5]}get featureIndex(){return this._structArray.uint32[this._pos4+3]}get sourceLayerIndex(){return this._structArray.uint16[this._pos2+8]}get bucketIndex(){return this._structArray.uint16[this._pos2+9]}get anchorPoint(){return new i(this.anchorPointX,this.anchorPointY)}}Cs.prototype.size=20;class Ss extends ps{get(e){return new Cs(this,e)}}lo("CollisionBoxArray",Ss);class Bs extends Jo{get anchorX(){return this._structArray.int16[this._pos2+0]}get anchorY(){return this._structArray.int16[this._pos2+1]}get glyphStartIndex(){return this._structArray.uint16[this._pos2+2]}get numGlyphs(){return this._structArray.uint16[this._pos2+3]}get vertexStartIndex(){return this._structArray.uint32[this._pos4+2]}get lineStartIndex(){return this._structArray.uint32[this._pos4+3]}get lineLength(){return this._structArray.uint32[this._pos4+4]}get segment(){return this._structArray.uint16[this._pos2+10]}get lowerSize(){return this._structArray.uint16[this._pos2+11]}get upperSize(){return this._structArray.uint16[this._pos2+12]}get lineOffsetX(){return this._structArray.float32[this._pos4+7]}get lineOffsetY(){return this._structArray.float32[this._pos4+8]}get writingMode(){return this._structArray.uint8[this._pos1+36]}get placedOrientation(){return this._structArray.uint8[this._pos1+37]}set placedOrientation(e){this._structArray.uint8[this._pos1+37]=e}get hidden(){return this._structArray.uint8[this._pos1+38]}set hidden(e){this._structArray.uint8[this._pos1+38]=e}get crossTileID(){return this._structArray.uint32[this._pos4+10]}set crossTileID(e){this._structArray.uint32[this._pos4+10]=e}get associatedIconIndex(){return this._structArray.int16[this._pos2+22]}}Bs.prototype.size=48;class Is extends As{get(e){return new Bs(this,e)}}lo("PlacedSymbolArray",Is);class Ms extends Jo{get anchorX(){return this._structArray.int16[this._pos2+0]}get anchorY(){return this._structArray.int16[this._pos2+1]}get rightJustifiedTextSymbolIndex(){return this._structArray.int16[this._pos2+2]}get centerJustifiedTextSymbolIndex(){return this._structArray.int16[this._pos2+3]}get leftJustifiedTextSymbolIndex(){return this._structArray.int16[this._pos2+4]}get verticalPlacedTextSymbolIndex(){return this._structArray.int16[this._pos2+5]}get placedIconSymbolIndex(){return this._structArray.int16[this._pos2+6]}get verticalPlacedIconSymbolIndex(){return this._structArray.int16[this._pos2+7]}get key(){return this._structArray.uint16[this._pos2+8]}get textBoxStartIndex(){return this._structArray.uint16[this._pos2+9]}get textBoxEndIndex(){return this._structArray.uint16[this._pos2+10]}get verticalTextBoxStartIndex(){return this._structArray.uint16[this._pos2+11]}get verticalTextBoxEndIndex(){return this._structArray.uint16[this._pos2+12]}get iconBoxStartIndex(){return this._structArray.uint16[this._pos2+13]}get iconBoxEndIndex(){return this._structArray.uint16[this._pos2+14]}get verticalIconBoxStartIndex(){return this._structArray.uint16[this._pos2+15]}get verticalIconBoxEndIndex(){return this._structArray.uint16[this._pos2+16]}get featureIndex(){return this._structArray.uint16[this._pos2+17]}get numHorizontalGlyphVertices(){return this._structArray.uint16[this._pos2+18]}get numVerticalGlyphVertices(){return this._structArray.uint16[this._pos2+19]}get numIconVertices(){return this._structArray.uint16[this._pos2+20]}get numVerticalIconVertices(){return this._structArray.uint16[this._pos2+21]}get useRuntimeCollisionCircles(){return this._structArray.uint16[this._pos2+22]}get crossTileID(){return this._structArray.uint32[this._pos4+12]}set crossTileID(e){this._structArray.uint32[this._pos4+12]=e}get textBoxScale(){return this._structArray.float32[this._pos4+13]}get collisionCircleDiameter(){return this._structArray.float32[this._pos4+14]}get textAnchorOffsetStartIndex(){return this._structArray.uint16[this._pos2+30]}get textAnchorOffsetEndIndex(){return this._structArray.uint16[this._pos2+31]}}Ms.prototype.size=64;class Ps extends ys{get(e){return new Ms(this,e)}}lo("SymbolInstanceArray",Ps);class Rs extends vs{getoffsetX(e){return this.float32[1*e+0]}}lo("GlyphOffsetArray",Rs);class Ls extends ns{getx(e){return this.int16[3*e+0]}gety(e){return this.int16[3*e+1]}gettileUnitDistanceFromAnchor(e){return this.int16[3*e+2]}}lo("SymbolLineVertexArray",Ls);class Fs extends Jo{get textAnchor(){return this._structArray.uint16[this._pos2+0]}get textOffset0(){return this._structArray.float32[this._pos4+1]}get textOffset1(){return this._structArray.float32[this._pos4+2]}}Fs.prototype.size=12;class ks extends xs{get(e){return new Fs(this,e)}}lo("TextAnchorOffsetArray",ks);class Ds extends Jo{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]}}Ds.prototype.size=8;class Os extends bs{get(e){return new Ds(this,e)}}lo("FeatureIndexArray",Os);class zs extends is{}class Us extends is{}class Ns extends is{}class Vs extends os{}class js extends ss{}class Gs extends as{}class Hs extends ls{}class Qs extends cs{}class $s extends us{}class Zs extends hs{}class Ws extends ds{}class qs extends fs{}class Ks extends gs{}class Xs extends _s{}class Js extends ws{}const Ys=es([{name:"a_pos",components:2,type:"Int16"}],4),{members:ea}=Ys;class ta{constructor(e=[]){this._forceNewSegmentOnNextPrepare=!1,this.segments=e}prepareSegment(e,t,i,n){const r=this.segments[this.segments.length-1];return e>ta.MAX_VERTEX_ARRAY_LENGTH&&H(`Max vertices per segment is ${ta.MAX_VERTEX_ARRAY_LENGTH}: bucket requested ${e}. Consider using the \`fillLargeMeshArrays\` function if you require meshes with more than ${ta.MAX_VERTEX_ARRAY_LENGTH} vertices.`),this._forceNewSegmentOnNextPrepare||!r||r.vertexLength+e>ta.MAX_VERTEX_ARRAY_LENGTH||r.sortKey!==n?this.createNewSegment(t,i,n):r}createNewSegment(e,t,i){const n={vertexOffset:e.length,primitiveOffset:t.length,vertexLength:0,primitiveLength:0,vaos:{}};return void 0!==i&&(n.sortKey=i),this._forceNewSegmentOnNextPrepare=!1,this.segments.push(n),n}getOrCreateLatestSegment(e,t,i){return this.prepareSegment(0,e,t,i)}forceNewSegmentOnNextPrepare(){this._forceNewSegmentOnNextPrepare=!0}get(){return this.segments}destroy(){for(const e of this.segments)for(const t in e.vaos)e.vaos[t].destroy()}static simpleSegment(e,t,i,n){return new ta([{vertexOffset:e,primitiveOffset:t,vertexLength:i,primitiveLength:n,vaos:{},sortKey:0}])}}function ia(e,t){return 256*(e=D(Math.floor(e),0,255))+D(Math.floor(t),0,255)}ta.MAX_VERTEX_ARRAY_LENGTH=Math.pow(2,16)-1,lo("SegmentVector",ta);const na=es([{name:"a_pattern_from",components:4,type:"Uint16"},{name:"a_pattern_to",components:4,type:"Uint16"},{name:"a_pixel_ratio_from",components:1,type:"Uint16"},{name:"a_pixel_ratio_to",components:1,type:"Uint16"}]),ra=es([{name:"a_dasharray_from",components:4,type:"Uint16"},{name:"a_dasharray_to",components:4,type:"Uint16"}]);var oa,sa,aa,la={exports:{}},ca={exports:{}},ua={exports:{}},ha=function(){if(aa)return la.exports;aa=1;var e=(oa||(oa=1,ca.exports=function(e,t){var i,n,r,o,s,a,l,c;for(n=e.length-(i=3&e.length),r=t,s=3432918353,a=461845907,c=0;c>>16)*s&65535)<<16)&4294967295)<<15|l>>>17))*a+(((l>>>16)*a&65535)<<16)&4294967295)<<13|r>>>19))+((5*(r>>>16)&65535)<<16)&4294967295))+((58964+(o>>>16)&65535)<<16);switch(l=0,i){case 3:l^=(255&e.charCodeAt(c+2))<<16;case 2:l^=(255&e.charCodeAt(c+1))<<8;case 1:r^=l=(65535&(l=(l=(65535&(l^=255&e.charCodeAt(c)))*s+(((l>>>16)*s&65535)<<16)&4294967295)<<15|l>>>17))*a+(((l>>>16)*a&65535)<<16)&4294967295}return r^=e.length,r=2246822507*(65535&(r^=r>>>16))+((2246822507*(r>>>16)&65535)<<16)&4294967295,r=3266489909*(65535&(r^=r>>>13))+((3266489909*(r>>>16)&65535)<<16)&4294967295,(r^=r>>>16)>>>0}),ca.exports),t=(sa||(sa=1,ua.exports=function(e,t){for(var i,n=e.length,r=t^n,o=0;n>=4;)i=1540483477*(65535&(i=255&e.charCodeAt(o)|(255&e.charCodeAt(++o))<<8|(255&e.charCodeAt(++o))<<16|(255&e.charCodeAt(++o))<<24))+((1540483477*(i>>>16)&65535)<<16),r=1540483477*(65535&r)+((1540483477*(r>>>16)&65535)<<16)^(i=1540483477*(65535&(i^=i>>>24))+((1540483477*(i>>>16)&65535)<<16)),n-=4,++o;switch(n){case 3:r^=(255&e.charCodeAt(o+2))<<16;case 2:r^=(255&e.charCodeAt(o+1))<<8;case 1:r=1540483477*(65535&(r^=255&e.charCodeAt(o)))+((1540483477*(r>>>16)&65535)<<16)}return r=1540483477*(65535&(r^=r>>>13))+((1540483477*(r>>>16)&65535)<<16),(r^=r>>>15)>>>0}),ua.exports);return la.exports=e,la.exports.murmur3=e,la.exports.murmur2=t,la.exports}(),da=n(ha);class pa{constructor(){this.ids=[],this.positions=[],this.indexed=!1}add(e,t,i,n){this.ids.push(fa(e)),this.positions.push(t,i,n)}getPositions(e){if(!this.indexed)throw new Error("Trying to get index, but feature positions are not indexed");const t=fa(e);let i=0,n=this.ids.length-1;for(;i>1;this.ids[e]>=t?n=e:i=e+1}const r=[];for(;this.ids[i]===t;)r.push({index:this.positions[3*i],start:this.positions[3*i+1],end:this.positions[3*i+2]}),i++;return r}static serialize(e,t){const i=new Float64Array(e.ids),n=new Uint32Array(e.positions);return ma(i,n,0,i.length-1),t&&t.push(i.buffer,n.buffer),{ids:i,positions:n}}static deserialize(e){const t=new pa;return t.ids=e.ids,t.positions=e.positions,t.indexed=!0,t}}function fa(e){const t=+e;return!isNaN(t)&&t<=Number.MAX_SAFE_INTEGER?t:da(String(e))}function ma(e,t,i,n){for(;i>1];let o=i-1,s=n+1;for(;;){do{o++}while(e[o]r);if(o>=s)break;ga(e,o,s),ga(t,3*o,3*s),ga(t,3*o+1,3*s+1),ga(t,3*o+2,3*s+2)}s-i`u_${e}`),this.type=i}setUniform(e,t,i){e.set(i.constantOr(this.value))}getBinding(e,t,i){return"color"===this.type?new va(e,t):new Aa(e,t)}}class Ta{constructor(e,t){this.uniformNames=t.map(e=>`u_${e}`),this.patternFrom=null,this.patternTo=null,this.pixelRatioFrom=1,this.pixelRatioTo=1}setConstantPatternPositions(e,t){this.pixelRatioFrom=t.pixelRatio,this.pixelRatioTo=e.pixelRatio,this.patternFrom=t.tlbr,this.patternTo=e.tlbr}setConstantDashPositions(e,t){this.dashTo=[0,e.y,e.height,e.width],this.dashFrom=[0,t.y,t.height,t.width]}setUniform(e,t,i,n){let r=null;"u_pattern_to"===n?r=this.patternTo:"u_pattern_from"===n?r=this.patternFrom:"u_dasharray_to"===n?r=this.dashTo:"u_dasharray_from"===n?r=this.dashFrom:"u_pixel_ratio_to"===n?r=this.pixelRatioTo:"u_pixel_ratio_from"===n&&(r=this.pixelRatioFrom),null!==r&&e.set(r)}getBinding(e,t,i){return"u_pattern"===i.substr(0,9)||"u_dasharray_"===i.substr(0,12)?new ya(e,t):new Aa(e,t)}}class Ea{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){const n=this.paintVertexArray.length,r=this.expression.evaluate(new Mo(0,i),t,{},i.canonical,[],i.formattedSection);this.paintVertexArray.resize(e),this._setPaintValue(n,e,r)}updatePaintArray(e,t,i,n,r){const o=this.expression.evaluate(new Mo(0,r),i,n);this._setPaintValue(e,t,o)}_setPaintValue(e,t,i){if("color"===this.type){const n=ba(i);for(let i=e;i`u_${e}_t`),this.type=i,this.useIntegerZoom=n,this.zoom=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){const n=this.expression.evaluate(new Mo(this.zoom,i),t,{},i.canonical,[],i.formattedSection),r=this.expression.evaluate(new Mo(this.zoom+1,i),t,{},i.canonical,[],i.formattedSection),o=this.paintVertexArray.length;this.paintVertexArray.resize(e),this._setPaintValue(o,e,n,r)}updatePaintArray(e,t,i,n,r){const o=this.expression.evaluate(new Mo(this.zoom,r),i,n),s=this.expression.evaluate(new Mo(this.zoom+1,r),i,n);this._setPaintValue(e,t,o,s)}_setPaintValue(e,t,i,n){if("color"===this.type){const r=ba(i),o=ba(n);for(let i=e;i`#define HAS_UNIFORM_${e}`))}return e}getBinderAttributes(){const e=[];for(const t in this.binders){const i=this.binders[t];if(i instanceof Ea||i instanceof Ca)for(let t=0;t!0){this.programConfigurations={};for(const n of e)this.programConfigurations[n.id]=new Ma(n,t,i);this.needsUpload=!1,this._featureMap=new pa,this._bufferOffset=0}populatePaintArrays(e,t,i,n){for(const i in this.programConfigurations)this.programConfigurations[i].populatePaintArrays(e,t,n);void 0!==t.id&&this._featureMap.add(t.id,i,this._bufferOffset,e),this._bufferOffset=e,this.needsUpload=!0}updatePaintArrays(e,t,i,n){for(const r of i)this.needsUpload=this.programConfigurations[r.id].updatePaintArrays(e,this._featureMap,t,r,n)||this.needsUpload}get(e){return this.programConfigurations[e]}upload(e){if(this.needsUpload){for(const t in this.programConfigurations)this.programConfigurations[t].upload(e);this.needsUpload=!1}}destroy(){for(const e in this.programConfigurations)this.programConfigurations[e].destroy()}}function Ra(e,t){return{"text-opacity":["opacity"],"icon-opacity":["opacity"],"text-color":["fill_color"],"icon-color":["fill_color"],"text-halo-color":["halo_color"],"icon-halo-color":["halo_color"],"text-halo-blur":["halo_blur"],"icon-halo-blur":["halo_blur"],"text-halo-width":["halo_width"],"icon-halo-width":["halo_width"],"line-gap-width":["gapwidth"],"line-dasharray":["dasharray_to","dasharray_from"],"line-pattern":["pattern_to","pattern_from","pixel_ratio_to","pixel_ratio_from"],"fill-pattern":["pattern_to","pattern_from","pixel_ratio_to","pixel_ratio_from"],"fill-extrusion-pattern":["pattern_to","pattern_from","pixel_ratio_to","pixel_ratio_from"]}[e]||[e.replace(`${t}-`,"").replace(/-/g,"_")]}function La(e,t,i){const n={color:{source:as,composite:Es},number:{source:vs,composite:as}},r=function(e){return{"line-pattern":{source:Hs,composite:Hs},"fill-pattern":{source:Hs,composite:Hs},"fill-extrusion-pattern":{source:Hs,composite:Hs},"line-dasharray":{source:Qs,composite:Qs}}[e]}(e);return r&&r[i]||n[t][i]}lo("ConstantBinder",wa),lo("CrossFadedConstantBinder",Ta),lo("SourceExpressionBinder",Ea),lo("CrossFadedPatternBinder",Ba),lo("CrossFadedDasharrayBinder",Ia),lo("CompositeExpressionBinder",Ca),lo("ProgramConfiguration",Ma,{omit:["_buffers"]}),lo("ProgramConfigurationSet",Pa);const Fa=Math.pow(2,14)-1,ka=-Fa-1;function Da(e){const t=I/e.extent,i=e.loadGeometry();for(let e=0;ei.x+1||oi.y+1)&&H("Geometry exceeds allowed extent, reduce your vector tile buffer size")}}return i}function Oa(e,t){return{type:e.type,id:e.id,properties:e.properties,geometry:t?Da(e):[]}}const za=-32768;function Ua(e,t,i,n,r){e.emplaceBack(za+8*t+n,za+8*i+r)}class Na{constructor(e){this.zoom=e.zoom,this.overscaling=e.overscaling,this.layers=e.layers,this.layerIds=this.layers.map(e=>e.id),this.index=e.index,this.hasDependencies=!1,this.layoutVertexArray=new Us,this.indexArray=new Xs,this.segments=new ta,this.programConfigurations=new Pa(e.layers,e.zoom),this.stateDependentLayerIds=this.layers.filter(e=>e.isStateDependent()).map(e=>e.id)}populate(e,t,i){const n=this.layers[0],r=[];let o=null,s=!1,a="heatmap"===n.type;if("circle"===n.type){const e=n;o=e.layout.get("circle-sort-key"),s=!o.isConstant(),a=a||"map"===e.paint.get("circle-pitch-alignment")}const l=a?t.subdivisionGranularity.circle:1;for(const{feature:t,id:n,index:a,sourceLayerIndex:l}of e){const e=this.layers[0]._featureFilter.needGeometry,c=Oa(t,e);if(!this.layers[0]._featureFilter.filter(new Mo(this.zoom),c,i))continue;const u=s?o.evaluate(c,{},i):void 0,h={id:n,properties:t.properties,type:t.type,sourceLayerIndex:l,index:a,geometry:e?c.geometry:Da(t),patterns:{},sortKey:u};r.push(h)}s&&r.sort((e,t)=>e.sortKey-t.sortKey);for(const n of r){const{geometry:r,index:o,sourceLayerIndex:s}=n,a=e[o].feature;this.addFeature(n,r,o,i,l),t.featureIndex.insert(a,r,o,s,this.index)}}update(e,t,i){this.stateDependentLayers.length&&this.programConfigurations.updatePaintArrays(e,t,this.stateDependentLayers,{imagePositions:i})}isEmpty(){return 0===this.layoutVertexArray.length}uploadPending(){return!this.uploaded||this.programConfigurations.needsUpload}upload(e){this.uploaded||(this.layoutVertexBuffer=e.createVertexBuffer(this.layoutVertexArray,ea),this.indexBuffer=e.createIndexBuffer(this.indexArray)),this.programConfigurations.upload(e),this.uploaded=!0}destroy(){this.layoutVertexBuffer&&(this.layoutVertexBuffer.destroy(),this.indexBuffer.destroy(),this.programConfigurations.destroy(),this.segments.destroy())}addFeature(e,t,i,n,r=1){let o;switch(r){case 1:o=[0,7];break;case 3:o=[0,2,5,7];break;case 5:o=[0,1,3,4,6,7];break;case 7:o=[0,1,2,3,4,5,6,7];break;default:throw new Error(`Invalid circle bucket granularity: ${r}; valid values are 1, 3, 5, 7.`)}const s=o.length;for(const i of t)for(const t of i){const i=t.x,n=t.y;if(i<0||i>=I||n<0||n>=I)continue;const r=this.segments.prepareSegment(s*s,this.layoutVertexArray,this.indexArray,e.sortKey),a=r.vertexLength;for(let e=0;e1){if(Qa(e,t))return!0;for(let n=0;n1?i:i.sub(t)._mult(r)._add(t))}function qa(e,t){let i,n,r,o=!1;for(let s=0;st.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 Ka(e,t){let i=!1;for(let n=0,r=e.length-1;nt.y!=s.y>t.y&&t.x<(s.x-o.x)*(t.y-o.y)/(s.y-o.y)+o.x&&(i=!i)}return i}function Xa(e,t,i){const n=i[0],r=i[2];if(e.xr.x&&t.x>r.x||e.yr.y&&t.y>r.y)return!1;const o=Q(e,t,i[0]);return o!==Q(e,t,i[1])||o!==Q(e,t,i[2])||o!==Q(e,t,i[3])}function Ja(e,t,i){const n=t.paint.get(e).value;return"constant"===n.kind?n.value:i.programConfigurations.get(t.id).getMaxValue(e)}function Ya(e){return Math.sqrt(e[0]*e[0]+e[1]*e[1])}function el(e,t,n,r,o){if(!t[0]&&!t[1])return e;const s=i.convert(t)._mult(o);"viewport"===n&&s._rotate(-r);const a=[];for(let t=0;tsl(e,t,i,n))}(l,r,s,a),p=c),ol({queryGeometry:d,size:p,transform:r,unwrappedTileID:s,getElevation:a,pitchAlignment:h,pitchScale:u},n)}}class hl extends Na{}let dl;lo("HeatmapBucket",hl,{omit:["layers"]});var pl={get paint(){return dl=dl||new $o({"heatmap-radius":new jo(Ae.paint_heatmap["heatmap-radius"]),"heatmap-weight":new jo(Ae.paint_heatmap["heatmap-weight"]),"heatmap-intensity":new Vo(Ae.paint_heatmap["heatmap-intensity"]),"heatmap-color":new Qo(Ae.paint_heatmap["heatmap-color"]),"heatmap-opacity":new Vo(Ae.paint_heatmap["heatmap-opacity"])})}};function fl(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. expected: ${r.length} but got: ${t*i*n}`)}else r=new Uint8Array(t*i*n);return e.width=t,e.height=i,e.data=r,e}function ml(e,{width:t,height:i},n){if(t===e.width&&i===e.height)return;const r=fl({},{width:t,height:i},n);gl(e,r,{x:0,y:0},{x:0,y:0},{width:Math.min(e.width,t),height:Math.min(e.height,i)},n),e.width=t,e.height=i,e.data=r.data}function gl(e,t,i,n,r,o){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 s=e.data,a=t.data;if(s===a)throw new Error("srcData equals dstData, so image is already copied");for(let l=0;l{t[e.evaluationKey]=s;const a=e.expression.evaluate(t);r.setPixel(n/4/i,o/4,a)};if(e.clips)for(let t=0,r=0;tthis.max&&(this.max=i),i=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)}unpack(e,t,i){return e*this.redFactor+t*this.greenFactor+i*this.blueFactor-this.baseShift}pack(e){return Il(e,this.getUnpackVector())}getPixels(){return new Al({width:this.stride,height:this.stride},new Uint8Array(this.data.buffer))}backfillBorder(e,t,i){if(this.dim!==e.dim)throw new Error("dem dimension mismatch");let n=t*this.dim,r=t*this.dim+this.dim,o=i*this.dim,s=i*this.dim+this.dim;switch(t){case-1:n=r-1;break;case 1:r=n+1}switch(i){case-1:o=s-1;break;case 1:s=o+1}const a=-t*this.dim,l=-i*this.dim;for(let t=o;t0)for(let r=t;r=t;r-=n)o=nc(r/n|0,e[r],e[r+1],o);return o&&Xl(o,o.next)&&(rc(o),o=o.next),o}function Dl(e,t){if(!e)return e;t||(t=e);let i,n=e;do{if(i=!1,n.steiner||!Xl(n,n.next)&&0!==Kl(n.prev,n,n.next))n=n.next;else{if(rc(n),n=t=n.prev,n===n.next)break;i=!0}}while(i||n!==t);return t}function Ol(e,t,i,n,r,o,s){if(!e)return;!s&&o&&function(e,t,i,n){let r=e;do{0===r.z&&(r.z=Ql(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 s=r,a=0;for(let e=0;e0||l>0&&s;)0!==a&&(0===l||!s||r.z<=s.z)?(n=r,r=r.nextZ,a--):(n=s,s=s.nextZ,l--),o?o.nextZ=n:e=n,n.prevZ=o,o=n;r=s}o.nextZ=null,i*=2}while(t>1)}(r)}(e,n,r,o);let a=e;for(;e.prev!==e.next;){const l=e.prev,c=e.next;if(o?Ul(e,n,r,o):zl(e))t.push(l.i,e.i,c.i),rc(e),e=c.next,a=c.next;else if((e=c)===a){s?1===s?Ol(e=Nl(Dl(e),t),t,i,n,r,o,2):2===s&&Vl(e,t,i,n,r,o):Ol(Dl(e),t,i,n,r,o,1);break}}}function zl(e){const t=e.prev,i=e,n=e.next;if(Kl(t,i,n)>=0)return!1;const r=t.x,o=i.x,s=n.x,a=t.y,l=i.y,c=n.y,u=Math.min(r,o,s),h=Math.min(a,l,c),d=Math.max(r,o,s),p=Math.max(a,l,c);let f=n.next;for(;f!==t;){if(f.x>=u&&f.x<=d&&f.y>=h&&f.y<=p&&Wl(r,a,o,l,s,c,f.x,f.y)&&Kl(f.prev,f,f.next)>=0)return!1;f=f.next}return!0}function Ul(e,t,i,n){const r=e.prev,o=e,s=e.next;if(Kl(r,o,s)>=0)return!1;const a=r.x,l=o.x,c=s.x,u=r.y,h=o.y,d=s.y,p=Math.min(a,l,c),f=Math.min(u,h,d),m=Math.max(a,l,c),g=Math.max(u,h,d),_=Ql(p,f,t,i,n),A=Ql(m,g,t,i,n);let y=e.prevZ,v=e.nextZ;for(;y&&y.z>=_&&v&&v.z<=A;){if(y.x>=p&&y.x<=m&&y.y>=f&&y.y<=g&&y!==r&&y!==s&&Wl(a,u,l,h,c,d,y.x,y.y)&&Kl(y.prev,y,y.next)>=0)return!1;if(y=y.prevZ,v.x>=p&&v.x<=m&&v.y>=f&&v.y<=g&&v!==r&&v!==s&&Wl(a,u,l,h,c,d,v.x,v.y)&&Kl(v.prev,v,v.next)>=0)return!1;v=v.nextZ}for(;y&&y.z>=_;){if(y.x>=p&&y.x<=m&&y.y>=f&&y.y<=g&&y!==r&&y!==s&&Wl(a,u,l,h,c,d,y.x,y.y)&&Kl(y.prev,y,y.next)>=0)return!1;y=y.prevZ}for(;v&&v.z<=A;){if(v.x>=p&&v.x<=m&&v.y>=f&&v.y<=g&&v!==r&&v!==s&&Wl(a,u,l,h,c,d,v.x,v.y)&&Kl(v.prev,v,v.next)>=0)return!1;v=v.nextZ}return!0}function Nl(e,t){let i=e;do{const n=i.prev,r=i.next.next;!Xl(n,r)&&Jl(n,i,i.next,r)&&tc(n,r)&&tc(r,n)&&(t.push(n.i,i.i,r.i),rc(i),rc(i.next),i=e=r),i=i.next}while(i!==e);return Dl(i)}function Vl(e,t,i,n,r,o){let s=e;do{let e=s.next.next;for(;e!==s.prev;){if(s.i!==e.i&&ql(s,e)){let a=ic(s,e);return s=Dl(s,s.next),a=Dl(a,a.next),Ol(s,t,i,n,r,o,0),void Ol(a,t,i,n,r,o,0)}e=e.next}s=s.next}while(s!==e)}function jl(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 Gl(e,t){const i=function(e,t){let i=t;const n=e.x,r=e.y;let o,s=-1/0;if(Xl(e,i))return i;do{if(Xl(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>s&&(s=e,o=i.x=i.x&&i.x>=l&&n!==i.x&&Zl(ro.x||i.x===o.x&&Hl(o,i)))&&(o=i,u=t)}i=i.next}while(i!==a);return o}(e,t);if(!i)return t;const n=ic(i,e);return Dl(n,n.next),Dl(i,i.next)}function Hl(e,t){return Kl(e.prev,e,t.prev)<0&&Kl(t.next,e,e.next)<0}function Ql(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 $l(e){let t=e,i=e;do{(t.x=(e-s)*(o-a)&&(e-s)*(n-a)>=(i-s)*(t-a)&&(i-s)*(o-a)>=(r-s)*(n-a)}function Wl(e,t,i,n,r,o,s,a){return!(e===s&&t===a)&&Zl(e,t,i,n,r,o,s,a)}function ql(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&&Jl(i,i.next,e,t))return!0;i=i.next}while(i!==e);return!1}(e,t)&&(tc(e,t)&&tc(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)&&(Kl(e.prev,e,t.prev)||Kl(e,t.prev,t))||Xl(e,t)&&Kl(e.prev,e,e.next)>0&&Kl(t.prev,t,t.next)>0)}function Kl(e,t,i){return(t.y-e.y)*(i.x-t.x)-(t.x-e.x)*(i.y-t.y)}function Xl(e,t){return e.x===t.x&&e.y===t.y}function Jl(e,t,i,n){const r=ec(Kl(e,t,i)),o=ec(Kl(e,t,n)),s=ec(Kl(i,n,e)),a=ec(Kl(i,n,t));return r!==o&&s!==a||!(0!==r||!Yl(e,i,t))||!(0!==o||!Yl(e,n,t))||!(0!==s||!Yl(i,e,n))||!(0!==a||!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 ec(e){return e>0?1:e<0?-1:0}function tc(e,t){return Kl(e.prev,e,e.next)<0?Kl(e,t,e.next)>=0&&Kl(e,e.prev,t)>=0:Kl(e,t,e.prev)<0||Kl(e,e.next,t)<0}function ic(e,t){const i=oc(e.i,e.x,e.y),n=oc(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 nc(e,t,i,n){const r=oc(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 rc(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 oc(e,t,i){return{i:e,x:t,y:i,prev:null,next:null,z:0,prevZ:null,nextZ:null,steiner:!1}}class sc{constructor(e,t){if(t>e)throw new Error("Min granularity must not be greater than base granularity.");this._baseZoomGranularity=e,this._minGranularity=t}getGranularityForZoomLevel(e){return Math.max(Math.floor(this._baseZoomGranularity/(1<32767||t>32767)throw new Error("Vertex coordinates are out of signed 16 bit integer range.");const i=0|Math.round(e),n=0|Math.round(t),r=this._getKey(i,n);if(this._vertexDictionary.has(r))return this._vertexDictionary.get(r);const o=this._vertexBuffer.length/2;return this._vertexDictionary.set(r,o),this._vertexBuffer.push(i,n),o}_subdivideTrianglesScanline(e){if(this._granularity<2)return function(e,t){const i=[];for(let n=0;n0?(i.push(r),i.push(s),i.push(o)):(i.push(r),i.push(o),i.push(s))}return i}(this._vertexBuffer,e);const t=[],i=e.length;for(let n=0;n=1||y<=0)||m&&(ar)){c>=n&&c<=r&&o.push(i[(e+1)%3]);continue}!m&&A>0&&o.push(this._vertexToIndex(s+d*A,a+p*A));const v=s+d*Math.max(A,0),x=s+d*Math.min(y,1);f||this._generateIntraEdgeVertices(o,s,a,l,c,v,x),!m&&y<1&&o.push(this._vertexToIndex(s+d*y,a+p*y)),(m||c>=n&&c<=r)&&o.push(i[(e+1)%3]),!m&&(c<=n||c>=r)&&this._generateInterEdgeVertices(o,s,a,l,c,u,h,x,n,r)}return o}_generateIntraEdgeVertices(e,t,i,n,r,o,s){const a=n-t,l=r-i,c=0===l,u=c?Math.min(t,n):Math.min(o,s),h=c?Math.max(t,n):Math.max(o,s),d=Math.floor(u/this._granularityCellSize)+1,p=Math.ceil(h/this._granularityCellSize)-1;if(c?t=d;n--){const r=n*this._granularityCellSize;e.push(this._vertexToIndex(r,i+l*(r-t)/a))}}_generateInterEdgeVertices(e,t,i,n,r,o,s,a,l,c){const u=r-i,h=o-n,d=s-r,p=(l-r)/d,f=(c-r)/d,m=Math.min(p,f),g=Math.max(p,f),_=n+h*m;let A=Math.floor(Math.min(_,a)/this._granularityCellSize)+1,y=Math.ceil(Math.max(_,a)/this._granularityCellSize)-1,v=a<_;const x=0===d;if(x&&(s===l||s===c))return;if(x||m>=1||g<=0){const e=i-s,n=o+(t-o)*Math.min((l-s)/e,(c-s)/e);A=Math.floor(Math.min(n,a)/this._granularityCellSize)+1,y=Math.ceil(Math.max(n,a)/this._granularityCellSize)-1,v=a0?c:l;if(v)for(let t=A;t<=y;t++)e.push(this._vertexToIndex(t*this._granularityCellSize,b));else for(let t=y;t>=A;t--)e.push(this._vertexToIndex(t*this._granularityCellSize,b))}_generateOutline(e){const t=[];for(const i of e){const e=dc(i,this._granularity,!0),n=this._pointArrayToIndices(e),r=[];for(let e=1;er!=(o===lc)?(e.push(t),e.push(i),e.push(this._vertexToIndex(n,o)),e.push(i),e.push(this._vertexToIndex(r,o)),e.push(this._vertexToIndex(n,o))):(e.push(i),e.push(t),e.push(this._vertexToIndex(n,o)),e.push(this._vertexToIndex(r,o)),e.push(i),e.push(this._vertexToIndex(n,o)))}_fillPoles(e,t,i){const n=this._vertexBuffer,r=I,o=e.length;for(let s=2;s80*i){a=e[0],l=e[1];let t=a,n=l;for(let o=i;ot&&(t=i),r>n&&(n=r)}c=Math.max(t-a,n-l),c=0!==c?32767/c:0}return Ol(o,s,i,a,l,c,0),s}(i,n),t=this._convertIndices(i,e);r=this._subdivideTrianglesScanline(t)}catch(e){console.error(e)}let o=[];return t&&(o=this._generateOutline(e)),this._ensureNoPoleVertices(),this._handlePoles(r),{verticesFlattened:this._vertexBuffer,indicesTriangles:r,indicesLineList:o}}_convertIndices(e,t){const i=[];for(let n=0;n0?(Math.floor(A/a)+1)*a:(Math.ceil(A/a)-1)*a,t=m>0?(Math.floor(y/a)+1)*a:(Math.ceil(y/a)-1)*a,n=Math.abs(A-e),r=Math.abs(y-t),o=Math.abs(A-u),s=Math.abs(y-h),c=d?n/g:Number.POSITIVE_INFINITY,v=p?r/_:Number.POSITIVE_INFINITY;if((o<=n||!d)&&(s<=r||!p))break;if(c=0?s-1:o-1,r=(a+1)%o,l=e[2*t[n]],c=e[2*t[r]],u=e[2*t[s]],h=e[2*t[s]+1],d=e[2*t[a]+1];let p=!1;if(lc)p=!1;else{const i=d-h,o=-(e[2*t[a]]-u),s=h((c-u)*i+(e[2*t[r]+1]-h)*o)*s&&(p=!0)}if(p){const e=t[n],r=t[s],l=t[a];e!==r&&e!==l&&r!==l&&i.push(l,r,e),s--,s<0&&(s=o-1)}else{const e=t[r],n=t[s],l=t[a];e!==n&&e!==l&&n!==l&&i.push(l,n,e),a++,a>=o&&(a=0)}if(n===r)break}}function fc(e,t,i,n,r,o,s,a,l){const c=r.length/2,u=s&&a&&l;if(cta.MAX_VERTEX_ARRAY_LENGTH&&(c=e.createNewSegment(t,i),l=a.count,m=!0,g=!0,_=!0,u=0);const A=mc(s,n,o,a,d,m,c),y=mc(s,n,o,a,p,g,c),v=mc(s,n,o,a,f,_,c);i.emplaceBack(u+A-l,u+y-l,u+v-l),c.primitiveLength++}}(t,i,n,r,o,e),u&&function(e,t,i,n,r,o){const s=[];for(let e=0;eta.MAX_VERTEX_ARRAY_LENGTH&&(c=e.createNewSegment(t,i),l=a.count,f=!0,m=!0,u=0);const g=mc(s,n,o,a,r,f,c),_=mc(s,n,o,a,h,m,c);i.emplaceBack(u+g-l,u+_-l),c.primitiveLength++}}}(s,i,a,r,l,e),t.forceNewSegmentOnNextPrepare(),null==s||s.forceNewSegmentOnNextPrepare()}function mc(e,t,i,n,r,o,s){if(o){const o=n.count;return i(t[2*r],t[2*r+1]),e[r]=n.count,n.count++,s.vertexLength++,o}return e[r]}class gc{constructor(e){this.zoom=e.zoom,this.overscaling=e.overscaling,this.layers=e.layers,this.layerIds=this.layers.map(e=>e.id),this.index=e.index,this.hasDependencies=!1,this.patternFeatures=[],this.layoutVertexArray=new Ns,this.indexArray=new Xs,this.indexArray2=new Js,this.programConfigurations=new Pa(e.layers,e.zoom),this.segments=new ta,this.segments2=new ta,this.stateDependentLayerIds=this.layers.filter(e=>e.isStateDependent()).map(e=>e.id)}populate(e,t,i){this.hasDependencies=Ll("fill",this.layers,t);const n=this.layers[0].layout.get("fill-sort-key"),r=!n.isConstant(),o=[];for(const{feature:s,id:a,index:l,sourceLayerIndex:c}of e){const e=this.layers[0]._featureFilter.needGeometry,u=Oa(s,e);if(!this.layers[0]._featureFilter.filter(new Mo(this.zoom),u,i))continue;const h=r?n.evaluate(u,{},i,t.availableImages):void 0,d={id:a,properties:s.properties,type:s.type,sourceLayerIndex:c,index:l,geometry:e?u.geometry:Da(s),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:s}=n;if(this.hasDependencies){const e=Fl("fill",this.layers,n,{zoom:this.zoom},t);this.patternFeatures.push(e)}else this.addFeature(n,r,o,i,{},t.subdivisionGranularity);t.featureIndex.insert(e[o].feature,r,o,s,this.index)}}update(e,t,i){this.stateDependentLayers.length&&this.programConfigurations.updatePaintArrays(e,t,this.stateDependentLayers,{imagePositions:i})}addFeatures(e,t,i){for(const n of this.patternFeatures)this.addFeature(n,n.geometry,n.index,t,i,e.subdivisionGranularity)}isEmpty(){return 0===this.layoutVertexArray.length}uploadPending(){return!this.uploaded||this.programConfigurations.needsUpload}upload(e){this.uploaded||(this.layoutVertexBuffer=e.createVertexBuffer(this.layoutVertexArray,Rl),this.indexBuffer=e.createIndexBuffer(this.indexArray),this.indexBuffer2=e.createIndexBuffer(this.indexArray2)),this.programConfigurations.upload(e),this.uploaded=!0}destroy(){this.layoutVertexBuffer&&(this.layoutVertexBuffer.destroy(),this.indexBuffer.destroy(),this.indexBuffer2.destroy(),this.programConfigurations.destroy(),this.segments.destroy(),this.segments2.destroy())}addFeature(e,t,i,n,r,o){for(const e of Yi(t,500)){const t=hc(e,n,o.fill.getGranularityForZoomLevel(n.z)),i=this.layoutVertexArray;fc((e,t)=>{i.emplaceBack(e,t)},this.segments,this.layoutVertexArray,this.indexArray,t.verticesFlattened,t.indicesTriangles,this.segments2,this.indexArray2,t.indicesLineList)}this.programConfigurations.populatePaintArrays(this.layoutVertexArray.length,e,i,{imagePositions:r,canonical:n})}}let _c,Ac;lo("FillBucket",gc,{omit:["layers","patternFeatures"]});var yc={get paint(){return Ac=Ac||new $o({"fill-antialias":new Vo(Ae.paint_fill["fill-antialias"]),"fill-opacity":new jo(Ae.paint_fill["fill-opacity"]),"fill-color":new jo(Ae.paint_fill["fill-color"]),"fill-outline-color":new jo(Ae.paint_fill["fill-outline-color"]),"fill-translate":new Vo(Ae.paint_fill["fill-translate"]),"fill-translate-anchor":new Vo(Ae.paint_fill["fill-translate-anchor"]),"fill-pattern":new Go(Ae.paint_fill["fill-pattern"])})},get layout(){return _c=_c||new $o({"fill-sort-key":new jo(Ae.layout_fill["fill-sort-key"])})}};class vc extends Zo{constructor(e,t){super(e,yc,t)}recalculate(e,t){super.recalculate(e,t);const i=this.paint._values["fill-outline-color"];"constant"===i.value.kind&&void 0===i.value.value&&(this.paint._values["fill-outline-color"]=this.paint._values["fill-color"])}createBucket(e){return new gc(e)}queryRadius(){return Ya(this.paint.get("fill-translate"))}queryIntersectsFeature({queryGeometry:e,geometry:t,transform:i,pixelsToTileUnits:n}){return Ga(el(e,this.paint.get("fill-translate"),this.paint.get("fill-translate-anchor"),-i.bearingInRadians,n),t)}isTileClipped(){return!0}}const xc=es([{name:"a_pos",components:2,type:"Int16"},{name:"a_normal_ed",components:4,type:"Int16"}],4),bc=es([{name:"a_centroid",components:2,type:"Int16"}],4),{members:wc}=xc;class Tc{constructor(e,t,i,n,r){this.properties={},this.extent=i,this.type=0,this.id=void 0,this._pbf=e,this._geometry=-1,this._keys=n,this._values=r,e.readFields(Ec,this,t)}loadGeometry(){const e=this._pbf;e.pos=this._geometry;const t=e.readVarint()+e.pos,n=[];let r,o=1,s=0,a=0,l=0;for(;e.pos>3}if(s--,1===o||2===o)a+=e.readSVarint(),l+=e.readSVarint(),1===o&&(r&&n.push(r),r=[]),r&&r.push(new i(a,l));else{if(7!==o)throw new Error(`unknown command ${o}`);r&&r.push(r[0].clone())}}return r&&n.push(r),n}bbox(){const e=this._pbf;e.pos=this._geometry;const t=e.readVarint()+e.pos;let i=1,n=0,r=0,o=0,s=1/0,a=-1/0,l=1/0,c=-1/0;for(;e.pos>3}if(n--,1===i||2===i)r+=e.readSVarint(),o+=e.readSVarint(),ra&&(a=r),oc&&(c=o);else if(7!==i)throw new Error(`unknown command ${i}`)}return[s,l,a,c]}toGeoJSON(e,t,i){const n=this.extent*Math.pow(2,i),r=this.extent*e,o=this.extent*t,s=this.loadGeometry();function a(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(a)}let c;if(1===this.type){const e=[];for(const t of s)e.push(t[0]);const t=l(e);c=1===e.length?{type:"Point",coordinates:t[0]}:{type:"MultiPoint",coordinates:t}}else if(2===this.type){const e=s.map(l);c=1===e.length?{type:"LineString",coordinates:e[0]}:{type:"MultiLineString",coordinates:e}}else{if(3!==this.type)throw new Error("unknown feature type");{const e=function(e){const t=e.length;if(t<=1)return[e];const i=[];let n,r;for(let o=0;o=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 Tc(this._pbf,t,this.extent,this._keys,this._values)}}function Bc(e,t,i){15===e?t.version=i.readVarint():1===e?t.name=i.readString():5===e?t.extent=i.readVarint():2===e?t._features.push(i.pos):3===e?t._keys.push(i.readString()):4===e&&t._values.push(function(e){let t=null;const i=e.readVarint()+e.pos;for(;e.pos>3;t=1===i?e.readString():2===i?e.readFloat():3===i?e.readDouble():4===i?e.readVarint64():5===i?e.readVarint():6===i?e.readSVarint():7===i?e.readBoolean():null}if(null==t)throw new Error("unknown feature value");return t}(i))}class Ic{constructor(e,t){this.layers=e.readFields(Mc,{},t)}}function Mc(e,t,i){if(3===e){const e=new Sc(i,i.readVarint()+i.pos);e.length&&(t[e.name]=e)}}const Pc=Math.pow(2,13);function Rc(e,t,i,n,r,o,s,a){e.emplaceBack(t,i,2*Math.floor(n*Pc)+s,r*Pc*2,o*Pc*2,Math.round(a))}class Lc{constructor(e){this.zoom=e.zoom,this.overscaling=e.overscaling,this.layers=e.layers,this.layerIds=this.layers.map(e=>e.id),this.index=e.index,this.hasDependencies=!1,this.layoutVertexArray=new Vs,this.centroidVertexArray=new zs,this.indexArray=new Xs,this.programConfigurations=new Pa(e.layers,e.zoom),this.segments=new ta,this.stateDependentLayerIds=this.layers.filter(e=>e.isStateDependent()).map(e=>e.id)}populate(e,t,i){this.features=[],this.hasDependencies=Ll("fill-extrusion",this.layers,t);for(const{feature:n,id:r,index:o,sourceLayerIndex:s}of e){const e=this.layers[0]._featureFilter.needGeometry,a=Oa(n,e);if(!this.layers[0]._featureFilter.filter(new Mo(this.zoom),a,i))continue;const l={id:r,sourceLayerIndex:s,index:o,geometry:e?a.geometry:Da(n),properties:n.properties,type:n.type,patterns:{}};this.hasDependencies?this.features.push(Fl("fill-extrusion",this.layers,l,{zoom:this.zoom},t)):this.addFeature(l,l.geometry,o,i,{},t.subdivisionGranularity),t.featureIndex.insert(n,l.geometry,o,s,this.index,!0)}}addFeatures(e,t,i){for(const n of this.features){const{geometry:r}=n;this.addFeature(n,r,n.index,t,i,e.subdivisionGranularity)}}update(e,t,i){this.stateDependentLayers.length&&this.programConfigurations.updatePaintArrays(e,t,this.stateDependentLayers,{imagePositions:i})}isEmpty(){return 0===this.layoutVertexArray.length&&0===this.centroidVertexArray.length}uploadPending(){return!this.uploaded||this.programConfigurations.needsUpload}upload(e){this.uploaded||(this.layoutVertexBuffer=e.createVertexBuffer(this.layoutVertexArray,wc),this.centroidVertexBuffer=e.createVertexBuffer(this.centroidVertexArray,bc.members,!0),this.indexBuffer=e.createIndexBuffer(this.indexArray)),this.programConfigurations.upload(e),this.uploaded=!0}destroy(){this.layoutVertexBuffer&&(this.layoutVertexBuffer.destroy(),this.indexBuffer.destroy(),this.programConfigurations.destroy(),this.segments.destroy(),this.centroidVertexBuffer.destroy())}addFeature(e,t,i,n,r,o){for(const i of Yi(t,500)){const t={x:0,y:0,sampleCount:0},r=this.layoutVertexArray.length;this.processPolygon(t,n,e,i,o);const s=this.layoutVertexArray.length-r,a=Math.floor(t.x/t.sampleCount),l=Math.floor(t.y/t.sampleCount);for(let e=0;e{Rc(c,e,t,0,0,1,1,0)},this.segments,this.layoutVertexArray,this.indexArray,l.verticesFlattened,l.indicesTriangles)}_generateSideFaces(e,t){let i=0;for(let n=1;nta.MAX_VERTEX_ARRAY_LENGTH&&(t.segment=this.segments.prepareSegment(4,this.layoutVertexArray,this.indexArray));const s=r.sub(o)._perp()._unit(),a=o.dist(r);i+a>32768&&(i=0),Rc(this.layoutVertexArray,r.x,r.y,s.x,s.y,0,0,i),Rc(this.layoutVertexArray,r.x,r.y,s.x,s.y,0,1,i),i+=a,Rc(this.layoutVertexArray,o.x,o.y,s.x,s.y,0,0,i),Rc(this.layoutVertexArray,o.x,o.y,s.x,s.y,0,1,i);const l=t.segment.vertexLength;this.indexArray.emplaceBack(l,l+2,l+1),this.indexArray.emplaceBack(l+1,l+2,l+3),t.segment.vertexLength+=4,t.segment.primitiveLength+=2}}}function Fc(e,t){for(let i=0;iI)||e.y===t.y&&(e.y<0||e.y>I)}function Dc(e){return e.every(e=>e.x<0)||e.every(e=>e.x>I)||e.every(e=>e.y<0)||e.every(e=>e.y>I)}let Oc;lo("FillExtrusionBucket",Lc,{omit:["layers","features"]});var zc={get paint(){return Oc=Oc||new $o({"fill-extrusion-opacity":new Vo(Ae["paint_fill-extrusion"]["fill-extrusion-opacity"]),"fill-extrusion-color":new jo(Ae["paint_fill-extrusion"]["fill-extrusion-color"]),"fill-extrusion-translate":new Vo(Ae["paint_fill-extrusion"]["fill-extrusion-translate"]),"fill-extrusion-translate-anchor":new Vo(Ae["paint_fill-extrusion"]["fill-extrusion-translate-anchor"]),"fill-extrusion-pattern":new Go(Ae["paint_fill-extrusion"]["fill-extrusion-pattern"]),"fill-extrusion-height":new jo(Ae["paint_fill-extrusion"]["fill-extrusion-height"]),"fill-extrusion-base":new jo(Ae["paint_fill-extrusion"]["fill-extrusion-base"]),"fill-extrusion-vertical-gradient":new Vo(Ae["paint_fill-extrusion"]["fill-extrusion-vertical-gradient"])})}};class Uc extends Zo{constructor(e,t){super(e,zc,t)}createBucket(e){return new Lc(e)}queryRadius(){return Ya(this.paint.get("fill-extrusion-translate"))}is3D(){return!0}queryIntersectsFeature({queryGeometry:e,feature:t,featureState:n,geometry:r,transform:o,pixelsToTileUnits:s,pixelPosMatrix:a}){const l=el(e,this.paint.get("fill-extrusion-translate"),this.paint.get("fill-extrusion-translate-anchor"),-o.bearingInRadians,s),c=this.paint.get("fill-extrusion-height").evaluate(t,n),u=this.paint.get("fill-extrusion-base").evaluate(t,n),h=function(e,t){const n=[];for(const r of e){const e=[r.x,r.y,0,1];T(e,e,t),n.push(new i(e[0]/e[3],e[1]/e[3]))}return n}(l,a),d=function(e,t,n,r){const o=[],s=[],a=r[8]*t,l=r[9]*t,c=r[10]*t,u=r[11]*t,h=r[8]*n,d=r[9]*n,p=r[10]*n,f=r[11]*n;for(const t of e){const e=[],n=[];for(const o of t){const t=o.x,s=o.y,m=r[0]*t+r[4]*s+r[12],g=r[1]*t+r[5]*s+r[13],_=r[2]*t+r[6]*s+r[14],A=r[3]*t+r[7]*s+r[15],y=_+c,v=A+u,x=m+h,b=g+d,w=_+p,T=A+f,E=new i((m+a)/v,(g+l)/v);E.z=y/v,e.push(E);const C=new i(x/T,b/T);C.z=w/T,n.push(C)}o.push(e),s.push(n)}return[o,s]}(r,u,c,a);return function(e,t,i){let n=1/0;Ga(i,t)&&(n=Vc(i,t[0]));for(let r=0;re.id),this.index=e.index,this.hasDependencies=!1,this.patternFeatures=[],this.lineClipsArray=[],this.gradients={},this.layers.forEach(e=>{this.gradients[e.id]={}}),this.layoutVertexArray=new js,this.layoutVertexArray2=new Gs,this.indexArray=new Xs,this.programConfigurations=new Pa(e.layers,e.zoom),this.segments=new ta,this.maxLineLength=0,this.stateDependentLayerIds=this.layers.filter(e=>e.isStateDependent()).map(e=>e.id)}populate(e,t,i){this.hasDependencies=Ll("line",this.layers,t)||this.hasLineDasharray(this.layers);const n=this.layers[0].layout.get("line-sort-key"),r=!n.isConstant(),o=[];for(const{feature:t,id:s,index:a,sourceLayerIndex:l}of e){const e=this.layers[0]._featureFilter.needGeometry,c=Oa(t,e);if(!this.layers[0]._featureFilter.filter(new Mo(this.zoom),c,i))continue;const u=r?n.evaluate(c,{},i):void 0,h={id:s,properties:t.properties,type:t.type,sourceLayerIndex:l,index:a,geometry:e?c.geometry:Da(t),patterns:{},dashes:{},sortKey:u};o.push(h)}r&&o.sort((e,t)=>e.sortKey-t.sortKey);for(const n of o){const{geometry:r,index:o,sourceLayerIndex:s}=n;this.hasDependencies?(Ll("line",this.layers,t)?Fl("line",this.layers,n,{zoom:this.zoom},t):this.hasLineDasharray(this.layers)&&this.addLineDashDependencies(this.layers,n,this.zoom,t),this.patternFeatures.push(n)):this.addFeature(n,r,o,i,{},{},t.subdivisionGranularity),t.featureIndex.insert(e[o].feature,r,o,s,this.index)}}update(e,t,i,n){this.stateDependentLayers.length&&this.programConfigurations.updatePaintArrays(e,t,this.stateDependentLayers,{imagePositions:i,dashPositions:n})}addFeatures(e,t,i,n){for(const r of this.patternFeatures)this.addFeature(r,r.geometry,r.index,t,i,n,e.subdivisionGranularity)}isEmpty(){return 0===this.layoutVertexArray.length}uploadPending(){return!this.uploaded||this.programConfigurations.needsUpload}upload(e){this.uploaded||(0!==this.layoutVertexArray2.length&&(this.layoutVertexBuffer2=e.createVertexBuffer(this.layoutVertexArray2,Qc)),this.layoutVertexBuffer=e.createVertexBuffer(this.layoutVertexArray,Gc),this.indexBuffer=e.createIndexBuffer(this.indexArray)),this.programConfigurations.upload(e),this.uploaded=!0}destroy(){this.layoutVertexBuffer&&(this.layoutVertexBuffer.destroy(),this.indexBuffer.destroy(),this.programConfigurations.destroy(),this.segments.destroy())}lineFeatureClips(e){if(e.properties&&Object.prototype.hasOwnProperty.call(e.properties,"mapbox_clip_start")&&Object.prototype.hasOwnProperty.call(e.properties,"mapbox_clip_end"))return{start:+e.properties.mapbox_clip_start,end:+e.properties.mapbox_clip_end}}addFeature(e,t,i,n,r,o,s){const a=this.layers[0].layout,l=a.get("line-join").evaluate(e,{}),c=a.get("line-cap"),u=a.get("line-miter-limit"),h=a.get("line-round-limit");this.lineClips=this.lineFeatureClips(e);for(const i of t)this.addLine(i,e,l,c,u,h,n,s);this.programConfigurations.populatePaintArrays(this.layoutVertexArray.length,e,i,{imagePositions:r,dashPositions:o,canonical:n})}addLine(e,t,i,n,r,o,s,a){if(this.distance=0,this.scaledDistance=0,this.totalDistance=0,e=dc(e,s?a.line.getGranularityForZoomLevel(s.z):1),this.lineClips){this.lineClipsArray.push(this.lineClips);for(let t=0;t=2&&e[c-1].equals(e[c-2]);)c--;let u=0;for(;u0;if(x&&t>u){const e=p.dist(f);if(e>2*h){const t=p.sub(p.sub(f)._mult(h/e)._round());this.updateDistance(f,t),this.addCurrentVertex(t,g,0,0,d),f=t}}const w=f&&m;let T=w?i:l?"butt":n;if(w&&"round"===T&&(yr&&(T="bevel"),"bevel"===T&&(y>2&&(T="flipbevel"),y100)s=_.mult(-1);else{const e=y*g.add(_).mag()/g.sub(_).mag();s._perp()._mult(e*(b?-1:1))}this.addCurrentVertex(p,s,0,0,d),this.addCurrentVertex(p,s.mult(-1),0,0,d)}else if("bevel"===T||"fakeround"===T){const e=-Math.sqrt(y*y-1),t=b?e:0,i=b?0:e;if(f&&this.addCurrentVertex(p,g,t,i,d),"fakeround"===T){const e=Math.round(180*v/Math.PI/20);for(let t=1;t2*h){const t=p.add(m.sub(p)._mult(h/e)._round());this.updateDistance(p,t),this.addCurrentVertex(t,_,0,0,d),p=t}}}}addCurrentVertex(e,t,i,n,r,o=!1){const s=t.y*n-t.x,a=-t.y-t.x*n;this.addHalfVertex(e,t.x+t.y*i,t.y-t.x*i,o,!1,i,r),this.addHalfVertex(e,s,a,o,!0,-n,r),this.distance>Zc/2&&0===this.totalDistance&&(this.distance=0,this.updateScaledDistance(),this.addCurrentVertex(e,t,i,n,r,o))}addHalfVertex({x:e,y:t},i,n,r,o,s,a){const l=.5*(this.lineClips?this.scaledDistance*(Zc-1):this.scaledDistance);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===s?0:s<0?-1:1)|(63&l)<<2,l>>6),this.lineClips&&this.layoutVertexArray2.emplaceBack((this.scaledDistance-this.lineClips.start)/(this.lineClips.end-this.lineClips.start),this.lineClipsArray.length);const c=a.vertexLength++;this.e1>=0&&this.e2>=0&&(this.indexArray.emplaceBack(this.e1,c,this.e2),a.primitiveLength++),o?this.e2=c:this.e1=c}updateScaledDistance(){this.scaledDistance=this.lineClips?this.lineClips.start+(this.lineClips.end-this.lineClips.start)*this.distance/this.totalDistance:this.distance}updateDistance(e,t){this.distance+=e.dist(t),this.updateScaledDistance()}hasLineDasharray(e){for(const t of e){const e=t.paint.get("line-dasharray");if(e&&!e.isConstant())return!0}return!1}addLineDashDependencies(e,t,i,n){for(const r of e){const e=r.paint.get("line-dasharray");if(!e||"constant"===e.value.kind)continue;const o="round"===r.layout.get("line-cap"),s={dasharray:e.value.evaluate({zoom:i-1},t,{}),round:o},a={dasharray:e.value.evaluate({zoom:i},t,{}),round:o},l={dasharray:e.value.evaluate({zoom:i+1},t,{}),round:o},c=`${s.dasharray.join(",")},${s.round}`,u=`${a.dasharray.join(",")},${a.round}`,h=`${l.dasharray.join(",")},${l.round}`;n.dashDependencies[c]=s,n.dashDependencies[u]=a,n.dashDependencies[h]=l,t.dashes[r.id]={min:c,mid:u,max:h}}}}let qc,Kc;lo("LineBucket",Wc,{omit:["layers","patternFeatures"]});var Xc={get paint(){return Kc=Kc||new $o({"line-opacity":new jo(Ae.paint_line["line-opacity"]),"line-color":new jo(Ae.paint_line["line-color"]),"line-translate":new Vo(Ae.paint_line["line-translate"]),"line-translate-anchor":new Vo(Ae.paint_line["line-translate-anchor"]),"line-width":new jo(Ae.paint_line["line-width"]),"line-gap-width":new jo(Ae.paint_line["line-gap-width"]),"line-offset":new jo(Ae.paint_line["line-offset"]),"line-blur":new jo(Ae.paint_line["line-blur"]),"line-dasharray":new Go(Ae.paint_line["line-dasharray"]),"line-pattern":new Go(Ae.paint_line["line-pattern"]),"line-gradient":new Qo(Ae.paint_line["line-gradient"])})},get layout(){return qc=qc||new $o({"line-cap":new Vo(Ae.layout_line["line-cap"]),"line-join":new jo(Ae.layout_line["line-join"]),"line-miter-limit":new Vo(Ae.layout_line["line-miter-limit"]),"line-round-limit":new Vo(Ae.layout_line["line-round-limit"]),"line-sort-key":new jo(Ae.layout_line["line-sort-key"])})}};class Jc extends jo{possiblyEvaluate(e,t){return t=new Mo(Math.floor(t.zoom),{now:t.now,fadeDuration:t.fadeDuration,zoomHistory:t.zoomHistory,transition:t.transition}),super.possiblyEvaluate(e,t)}evaluate(e,t,i,n){return t=z({},t,{zoom:Math.floor(t.zoom)}),super.evaluate(e,t,i,n)}}let Yc;class eu extends Zo{constructor(e,t){super(e,Xc,t),this.gradientVersion=0,Yc||(Yc=new Jc(Xc.paint.properties["line-width"].specification),Yc.useIntegerZoom=!0)}_handleSpecialPaintPropertyUpdate(e){if("line-gradient"===e){const e=this.gradientExpression();this.stepInterpolant=!!function(e){return void 0!==e._styleExpression}(e)&&e._styleExpression.expression instanceof si,this.gradientVersion=(this.gradientVersion+1)%Number.MAX_SAFE_INTEGER}}gradientExpression(){return this._transitionablePaint._values["line-gradient"].value.expression}recalculate(e,t){super.recalculate(e,t),this.paint._values["line-floorwidth"]=Yc.possiblyEvaluate(this._transitioningPaint._values["line-width"].value,e)}createBucket(e){return new Wc(e)}queryRadius(e){const t=e,i=tu(Ja("line-width",this,t),Ja("line-gap-width",this,t)),n=Ja("line-offset",this,t);return i/2+Math.abs(n)+Ya(this.paint.get("line-translate"))}queryIntersectsFeature({queryGeometry:e,feature:t,featureState:n,geometry:r,transform:o,pixelsToTileUnits:s}){const a=el(e,this.paint.get("line-translate"),this.paint.get("line-translate-anchor"),-o.bearingInRadians,s),l=s/2*tu(this.paint.get("line-width").evaluate(t,n),this.paint.get("line-gap-width").evaluate(t,n)),c=this.paint.get("line-offset").evaluate(t,n);return c&&(r=function(e,t){const n=[];for(let r=0;r=3)for(let t=0;t0?t+2*e:e}const iu=es([{name:"a_pos_offset",components:4,type:"Int16"},{name:"a_data",components:4,type:"Uint16"},{name:"a_pixeloffset",components:4,type:"Int16"}],4),nu=es([{name:"a_projected_pos",components:3,type:"Float32"}],4);es([{name:"a_fade_opacity",components:1,type:"Uint32"}],4);const ru=es([{name:"a_placed",components:2,type:"Uint8"},{name:"a_shift",components:2,type:"Float32"},{name:"a_box_real",components:2,type:"Int16"}]);es([{type:"Int16",name:"anchorPointX"},{type:"Int16",name:"anchorPointY"},{type:"Int16",name:"x1"},{type:"Int16",name:"y1"},{type:"Int16",name:"x2"},{type:"Int16",name:"y2"},{type:"Uint32",name:"featureIndex"},{type:"Uint16",name:"sourceLayerIndex"},{type:"Uint16",name:"bucketIndex"}]);const ou=es([{name:"a_pos",components:2,type:"Int16"},{name:"a_anchor_pos",components:2,type:"Int16"},{name:"a_extrude",components:2,type:"Int16"}],4),su=es([{name:"a_pos",components:2,type:"Float32"},{name:"a_radius",components:1,type:"Float32"},{name:"a_flags",components:2,type:"Int16"}],4);function au(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()),Io.applyArabicShaping&&(e=Io.applyArabicShaping(e)),e}(e.text,t,i)}),e}es([{name:"triangle",components:3,type:"Uint16"}]),es([{type:"Int16",name:"anchorX"},{type:"Int16",name:"anchorY"},{type:"Uint16",name:"glyphStartIndex"},{type:"Uint16",name:"numGlyphs"},{type:"Uint32",name:"vertexStartIndex"},{type:"Uint32",name:"lineStartIndex"},{type:"Uint32",name:"lineLength"},{type:"Uint16",name:"segment"},{type:"Uint16",name:"lowerSize"},{type:"Uint16",name:"upperSize"},{type:"Float32",name:"lineOffsetX"},{type:"Float32",name:"lineOffsetY"},{type:"Uint8",name:"writingMode"},{type:"Uint8",name:"placedOrientation"},{type:"Uint8",name:"hidden"},{type:"Uint32",name:"crossTileID"},{type:"Int16",name:"associatedIconIndex"}]),es([{type:"Int16",name:"anchorX"},{type:"Int16",name:"anchorY"},{type:"Int16",name:"rightJustifiedTextSymbolIndex"},{type:"Int16",name:"centerJustifiedTextSymbolIndex"},{type:"Int16",name:"leftJustifiedTextSymbolIndex"},{type:"Int16",name:"verticalPlacedTextSymbolIndex"},{type:"Int16",name:"placedIconSymbolIndex"},{type:"Int16",name:"verticalPlacedIconSymbolIndex"},{type:"Uint16",name:"key"},{type:"Uint16",name:"textBoxStartIndex"},{type:"Uint16",name:"textBoxEndIndex"},{type:"Uint16",name:"verticalTextBoxStartIndex"},{type:"Uint16",name:"verticalTextBoxEndIndex"},{type:"Uint16",name:"iconBoxStartIndex"},{type:"Uint16",name:"iconBoxEndIndex"},{type:"Uint16",name:"verticalIconBoxStartIndex"},{type:"Uint16",name:"verticalIconBoxEndIndex"},{type:"Uint16",name:"featureIndex"},{type:"Uint16",name:"numHorizontalGlyphVertices"},{type:"Uint16",name:"numVerticalGlyphVertices"},{type:"Uint16",name:"numIconVertices"},{type:"Uint16",name:"numVerticalIconVertices"},{type:"Uint16",name:"useRuntimeCollisionCircles"},{type:"Uint32",name:"crossTileID"},{type:"Float32",name:"textBoxScale"},{type:"Float32",name:"collisionCircleDiameter"},{type:"Uint16",name:"textAnchorOffsetStartIndex"},{type:"Uint16",name:"textAnchorOffsetEndIndex"}]),es([{type:"Float32",name:"offsetX"}]),es([{type:"Int16",name:"x"},{type:"Int16",name:"y"},{type:"Int16",name:"tileUnitDistanceFromAnchor"}]),es([{type:"Uint16",name:"textAnchor"},{type:"Float32",components:2,name:"textOffset"}]);var lu=24;const cu={"!":"︕","#":"#",$:"$","%":"%","&":"&","(":"︵",")":"︶","*":"*","+":"+",",":"︐","-":"︲",".":"・","/":"/",":":"︓",";":"︔","<":"︿","=":"=",">":"﹀","?":"︖","@":"@","[":"﹇","\\":"\","]":"﹈","^":"^",_:"︳","`":"`","{":"︷","|":"―","}":"︸","~":"~","¢":"¢","£":"£","¥":"¥","¦":"¦","¬":"¬","¯":" ̄","–":"︲","—":"︱","‘":"﹃","’":"﹄","“":"﹁","”":"﹂","…":"︙","⋯":"︙","‧":"・","₩":"₩","、":"︑","。":"︒","〈":"︿","〉":"﹀","《":"︽","》":"︾","「":"﹁","」":"﹂","『":"﹃","』":"﹄","【":"︻","】":"︼","〔":"︹","〕":"︺","〖":"︗","〗":"︘","!":"︕","(":"︵",")":"︶",",":"︐","-":"︲",".":"・",":":"︓",";":"︔","<":"︿",">":"﹀","?":"︖","[":"﹇","]":"﹈","_":"︳","{":"︷","|":"―","}":"︸","⦅":"︵","⦆":"︶","。":"︒","「":"﹁","」":"﹂"},uu={10:!0,32:!0,38:!0,41:!0,43:!0,45:!0,47:!0,173:!0,183:!0,8203:!0,8208:!0,8211:!0,8231:!0},hu={40:!0};function du(e,t,i,n,r,o){if("fontStack"in t){const n=i[t.fontStack],o=n&&n[e];return o?o.metrics.advance*t.scale+r:0}{const e=n[t.imageName];return e?e.displaySize[0]*t.scale*lu/o+r:0}}function pu(e,t,i,n){const r=Math.pow(e-t,2);return n?eMath.max(e,this.sections[t].scale),0)}getMaxImageSize(e){let t=0,i=0;for(let n=0;ni))}addImageSection(e){const t=e.image?e.image.name:"";if(0===t.length)return void H("Can't add FormattedSection with an empty image.");const i=this.getNextImageSectionCharCode();i?(this.text+=String.fromCharCode(i),this.sections.push({scale:1,verticalAlign:e.verticalAlign||"bottom",imageName:t}),this.sectionIndex.push(this.sections.length-1)):H("Reached maximum number of images 6401")}getNextImageSectionCharCode(){return this.imageSectionID?this.imageSectionID>=63743?null:++this.imageSectionID:(this.imageSectionID=57344,this.imageSectionID)}determineLineBreaks(e,t,i,n,r){const o=[],s=this.determineAverageLineWidth(e,t,i,n,r),a=this.hasZeroWidthSpaces();let l=0,c=0;const u=this.text[Symbol.iterator]();let h=u.next();const d=this.text[Symbol.iterator]();d.next();let p=d.next();const f=this.text[Symbol.iterator]();f.next(),f.next();let m=f.next();for(;!h.done;){const t=this.getSection(c),g=h.value.codePointAt(0);if(Ao(g)||(l+=du(g,t,i,n,e,r)),!p.done){const e=go(g),i=p.value.codePointAt(0);(uu[g]||e||"imageName"in t||!m.done&&hu[i])&&o.push(mu(c+1,l,s,o,fu(g,i,e&&a),!1))}c++,h=u.next(),p=d.next(),m=f.next()}return gu(mu(this.length(),l,s,o,0,!0))}determineAverageLineWidth(e,t,i,n,r){let o=0,s=0;for(const t of this.text){const a=this.getSection(s);o+=du(t.codePointAt(0),a,i,n,e,r),s++}return o/Math.max(1,Math.ceil(o/t))}}const Au=4294967296,yu=1/Au,vu="undefined"==typeof TextDecoder?null:new TextDecoder("utf-8");class xu{constructor(e=new Uint8Array(16)){this.buf=ArrayBuffer.isView(e)?e:new Uint8Array(e),this.dataView=new DataView(this.buf.buffer),this.pos=0,this.type=0,this.length=this.buf.length}readFields(e,t,i=this.length){for(;this.pos>3,r=this.pos;this.type=7&i,e(n,t,this),this.pos===r&&this.skip(i)}return t}readMessage(e,t){return this.readFields(e,t,this.readVarint()+this.pos)}readFixed32(){const e=this.dataView.getUint32(this.pos,!0);return this.pos+=4,e}readSFixed32(){const e=this.dataView.getInt32(this.pos,!0);return this.pos+=4,e}readFixed64(){const e=this.dataView.getUint32(this.pos,!0)+this.dataView.getUint32(this.pos+4,!0)*Au;return this.pos+=8,e}readSFixed64(){const e=this.dataView.getUint32(this.pos,!0)+this.dataView.getInt32(this.pos+4,!0)*Au;return this.pos+=8,e}readFloat(){const e=this.dataView.getFloat32(this.pos,!0);return this.pos+=4,e}readDouble(){const e=this.dataView.getFloat64(this.pos,!0);return this.pos+=8,e}readVarint(e){const t=this.buf;let i,n;return n=t[this.pos++],i=127&n,n<128?i:(n=t[this.pos++],i|=(127&n)<<7,n<128?i:(n=t[this.pos++],i|=(127&n)<<14,n<128?i:(n=t[this.pos++],i|=(127&n)<<21,n<128?i:(n=t[this.pos],i|=(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 bu(e,r,t);if(o=n[i.pos++],r|=(127&o)<<3,o<128)return bu(e,r,t);if(o=n[i.pos++],r|=(127&o)<<10,o<128)return bu(e,r,t);if(o=n[i.pos++],r|=(127&o)<<17,o<128)return bu(e,r,t);if(o=n[i.pos++],r|=(127&o)<<24,o<128)return bu(e,r,t);if(o=n[i.pos++],r|=(1&o)<<31,o<128)return bu(e,r,t);throw new Error("Expected varint not more than 10 bytes")}(i,e,this)))))}readVarint64(){return this.readVarint(!0)}readSVarint(){const e=this.readVarint();return e%2==1?(e+1)/-2:e/2}readBoolean(){return Boolean(this.readVarint())}readString(){const e=this.readVarint()+this.pos,t=this.pos;return this.pos=e,e-t>=12&&vu?vu.decode(this.buf.subarray(t,e)):function(e,t,i){let n="",r=t;for(;r239?4:t>223?3:t>191?2:1;if(r+c>i)break;1===c?t<128&&(l=t):2===c?(o=e[r+1],128==(192&o)&&(l=(31&t)<<6|63&o,l<=127&&(l=null))):3===c?(o=e[r+1],s=e[r+2],128==(192&o)&&128==(192&s)&&(l=(15&t)<<12|(63&o)<<6|63&s,(l<=2047||l>=55296&&l<=57343)&&(l=null))):4===c&&(o=e[r+1],s=e[r+2],a=e[r+3],128==(192&o)&&128==(192&s)&&128==(192&a)&&(l=(15&t)<<18|(63&o)<<12|(63&s)<<6|63&a,(l<=65535||l>=1114112)&&(l=null))),null===l?(l=65533,c=1):l>65535&&(l-=65536,n+=String.fromCharCode(l>>>10&1023|55296),l=56320|1023&l),n+=String.fromCharCode(l),r+=c}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.pos127;);else if(2===t)this.pos=this.readVarint()+this.pos;else if(5===t)this.pos+=4;else{if(1!==t)throw new Error(`Unimplemented type: ${t}`);this.pos+=8}}writeTag(e,t){this.writeVarint(e<<3|t)}realloc(e){let t=this.length||16;for(;t268435455||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;o55295&&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&&wu(t,i,this),this.pos=t-1,this.writeVarint(i),this.pos+=i}writeFloat(e){this.realloc(4),this.dataView.setFloat32(this.pos,e,!0),this.pos+=4}writeDouble(e){this.realloc(8),this.dataView.setFloat64(this.pos,e,!0),this.pos+=8}writeBytes(e){const t=e.length;this.writeVarint(t),this.realloc(t);for(let i=0;i=128&&wu(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,Tu,t)}writePackedSVarint(e,t){t.length&&this.writeMessage(e,Eu,t)}writePackedBoolean(e,t){t.length&&this.writeMessage(e,Bu,t)}writePackedFloat(e,t){t.length&&this.writeMessage(e,Cu,t)}writePackedDouble(e,t){t.length&&this.writeMessage(e,Su,t)}writePackedFixed32(e,t){t.length&&this.writeMessage(e,Iu,t)}writePackedSFixed32(e,t){t.length&&this.writeMessage(e,Mu,t)}writePackedFixed64(e,t){t.length&&this.writeMessage(e,Pu,t)}writePackedSFixed64(e,t){t.length&&this.writeMessage(e,Ru,t)}writeBytesField(e,t){this.writeTag(e,2),this.writeBytes(t)}writeFixed32Field(e,t){this.writeTag(e,5),this.writeFixed32(t)}writeSFixed32Field(e,t){this.writeTag(e,5),this.writeSFixed32(t)}writeFixed64Field(e,t){this.writeTag(e,1),this.writeFixed64(t)}writeSFixed64Field(e,t){this.writeTag(e,1),this.writeSFixed64(t)}writeVarintField(e,t){this.writeTag(e,0),this.writeVarint(t)}writeSVarintField(e,t){this.writeTag(e,0),this.writeSVarint(t)}writeStringField(e,t){this.writeTag(e,2),this.writeString(t)}writeFloatField(e,t){this.writeTag(e,5),this.writeFloat(t)}writeDoubleField(e,t){this.writeTag(e,1),this.writeDouble(t)}writeBooleanField(e,t){this.writeVarintField(e,+t)}}function bu(e,t,i){return i?4294967296*t+(e>>>0):4294967296*(t>>>0)+(e>>>0)}function wu(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);for(let t=i.pos-1;t>=e;t--)i.buf[t+n]=i.buf[t]}function Tu(e,t){for(let i=0;it.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&&eg.toCodeUnitIndex(e));const e=y(g.toString(),A);for(const t of e){const e=[...t].map(()=>0);_.push(new _u(t,g.sections,e))}}else if(v){_=[],A=A.map(e=>g.toCodeUnitIndex(e));let e=0;const t=[];for(const i of g.text)t.push(...Array(i.length).fill(g.sectionIndex[e])),e++;const i=v(g.text,t,A);for(const e of i){const t=[];let i="";for(const n of e[0])t.push(e[1][i.length]),i+=n;_.push(new _u(e[0],g.sections,t))}}else _=function(e,t){const i=[];let n=0;for(const r of t)i.push(e.substring(n,r)),n=r;return nc){const e=Math.ceil(o/c);r*=e/s,s=e}return{x1:n,y1:r,x2:n+o,y2:r+s}}function Ku(e,t,i,n,r,o){const s=e.image;let a;if(s.content){const e=s.content,t=s.pixelRatio||1;a=[e[0]/t,e[1]/t,s.displaySize[0]-e[2]/t,s.displaySize[1]-e[3]/t]}const l=t.left*o,c=t.right*o;let u,h,d,p;"width"===i||"both"===i?(p=r[0]+l-n[3],h=r[0]+c+n[1]):(p=r[0]+(l+c-s.displaySize[0])/2,h=p+s.displaySize[0]);const f=t.top*o,m=t.bottom*o;return"height"===i||"both"===i?(u=r[1]+f-n[0],d=r[1]+m+n[2]):(u=r[1]+(f+m-s.displaySize[1])/2,d=u+s.displaySize[1]),{image:s,top:u,right:h,bottom:d,left:p,collisionPadding:a}}lo("ImagePosition",Ou),lo("ImageAtlas",zu),e.ay=void 0,(Uu=e.ay||(e.ay={}))[Uu.none=0]="none",Uu[Uu.horizontal=1]="horizontal",Uu[Uu.vertical=2]="vertical",Uu[Uu.horizontalOnly=3]="horizontalOnly";const Xu=128,Ju=32640;function Yu(e,t){const{expression:i}=t;if("constant"===i.kind)return{kind:"constant",layoutSize:i.evaluate(new Mo(e+1))};if("source"===i.kind)return{kind:"source"};{const{zoomStops:t,interpolationType:n}=i;let r=0;for(;re.id),this.index=t.index,this.pixelRatio=t.pixelRatio,this.sourceLayerIndex=t.sourceLayerIndex,this.hasDependencies=!1,this.hasRTLText=!1,this.sortKeyRanges=[],this.collisionCircleArray=[];const i=this.layers[0]._unevaluatedLayout._values;this.textSizeData=Yu(this.zoom,i["text-size"]),this.iconSizeData=Yu(this.zoom,i["icon-size"]);const n=this.layers[0].layout,r=n.get("symbol-sort-key"),o=n.get("symbol-z-order");this.canOverlap="never"!==eh(n,"text-overlap","text-allow-overlap")||"never"!==eh(n,"icon-overlap","icon-allow-overlap")||n.get("text-ignore-placement")||n.get("icon-ignore-placement"),this.sortFeaturesByKey="viewport-y"!==o&&!r.isConstant(),this.sortFeaturesByY=("viewport-y"===o||"auto"===o&&!this.sortFeaturesByKey)&&this.canOverlap,"point"===n.get("symbol-placement")&&(this.writingModes=n.get("text-writing-mode").map(t=>e.ay[t])),this.stateDependentLayerIds=this.layers.filter(e=>e.isStateDependent()).map(e=>e.id),this.sourceID=t.sourceID}createArrays(){this.text=new oh(new Pa(this.layers,this.zoom,e=>/^text/.test(e))),this.icon=new oh(new Pa(this.layers,this.zoom,e=>/^icon/.test(e))),this.glyphOffsetArray=new Rs,this.lineVertexArray=new Ls,this.symbolInstances=new Ps,this.textAnchorOffsets=new ks}calculateGlyphDependencies(e,t,i,n,r){for(const o of e)if(t[o.codePointAt(0)]=!0,(i||n)&&r){const e=cu[o];e&&(t[e.codePointAt(0)]=!0)}}populate(t,i,n){const r=this.layers[0],o=r.layout,s=o.get("text-font"),a=o.get("text-field"),l=o.get("icon-image"),c=("constant"!==a.value.kind||a.value.value instanceof Mt&&!a.value.value.isEmpty()||a.value.value.toString().length>0)&&("constant"!==s.value.kind||s.value.value.length>0),u="constant"!==l.value.kind||!!l.value.value||Object.keys(l.parameters).length>0,h=o.get("symbol-sort-key");if(this.features=[],!c&&!u)return;const d=i.iconDependencies,p=i.glyphDependencies,f=i.availableImages,m=new Mo(this.zoom);for(const{feature:i,id:a,index:l,sourceLayerIndex:g}of t){const t=r._featureFilter.needGeometry,_=Oa(i,t);if(!r._featureFilter.filter(m,_,n))continue;let A,y;if(t||(_.geometry=Da(i)),c){const e=r.getValueAndResolveTokens("text-field",_,n,f),t=Mt.factory(e),i=this.hasRTLText=this.hasRTLText||rh(t);(!i||"unavailable"===Io.getRTLTextPluginStatus()||i&&Io.isParsed())&&(A=au(t,r,_))}if(u){const e=r.getValueAndResolveTokens("icon-image",_,n,f);y=e instanceof Ot?e:Ot.fromString(e)}if(!A&&!y)continue;const v=this.sortFeaturesByKey?h.evaluate(_,{},n):void 0;if(this.features.push({id:a,text:A,icon:y,index:l,sourceLayerIndex:g,geometry:_.geometry,properties:i.properties,type:Tc.types[i.type],sortKey:v}),y&&(d[y.name]=!0),A){const t=s.evaluate(_,{},n).join(","),i="viewport"!==o.get("text-rotation-alignment")&&"point"!==o.get("symbol-placement");this.allowVerticalPlacement=this.writingModes&&this.writingModes.indexOf(e.ay.vertical)>=0;for(const e of A.sections)if(e.image)d[e.image.name]=!0;else{const n=yo(A.toString()),r=e.fontStack||t,o=p[r]=p[r]||{};this.calculateGlyphDependencies(e.text,o,i,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 s(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 a(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][t[0].length-1]:t[0][0];return`${e}:${n.x}:${n.y}`}for(let c=0;ce.geometry)}(this.features)),this.sortFeaturesByKey&&this.features.sort((e,t)=>e.sortKey-t.sortKey)}update(e,t,i){this.stateDependentLayers.length&&(this.text.programConfigurations.updatePaintArrays(e,t,this.layers,{imagePositions:i}),this.icon.programConfigurations.updatePaintArrays(e,t,this.layers,{imagePositions:i}))}isEmpty(){return 0===this.symbolInstances.length&&!this.hasRTLText}uploadPending(){return!this.uploaded||this.text.programConfigurations.needsUpload||this.icon.programConfigurations.needsUpload}upload(e){!this.uploaded&&this.hasDebugData()&&(this.textCollisionBox.upload(e),this.iconCollisionBox.upload(e)),this.text.upload(e,this.sortFeaturesByY,!this.uploaded,this.text.programConfigurations.needsUpload),this.icon.upload(e,this.sortFeaturesByY,!this.uploaded,this.icon.programConfigurations.needsUpload),this.uploaded=!0}destroyDebugData(){this.textCollisionBox.destroy(),this.iconCollisionBox.destroy()}destroy(){this.text.destroy(),this.icon.destroy(),this.hasDebugData()&&this.destroyDebugData()}addToLineVertexArray(e,t){const i=this.lineVertexArray.length;if(void 0!==e.segment){let i=e.dist(t[e.segment+1]),n=e.dist(t[e.segment]);const r={};for(let n=e.segment+1;n=0;i--)r[i]={x:t[i].x,y:t[i].y,tileUnitDistanceFromAnchor:n},i>0&&(n+=t[i-1].dist(t[i]));for(let e=0;e0}hasIconData(){return this.icon.segments.get().length>0}hasDebugData(){return this.textCollisionBox&&this.iconCollisionBox}hasTextCollisionBoxData(){return this.hasDebugData()&&this.textCollisionBox.segments.get().length>0}hasIconCollisionBoxData(){return this.hasDebugData()&&this.iconCollisionBox.segments.get().length>0}addIndicesForPlacedSymbol(e,t){const i=e.placedSymbolArray.get(t),n=i.vertexStartIndex+4*i.numGlyphs;for(let t=i.vertexStartIndex;tn[e]-n[t]||r[t]-r[e]),o}addToSortKeyRanges(e,t){const i=this.sortKeyRanges[this.sortKeyRanges.length-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&&!(this.text.segments.get().length>1||this.icon.segments.get().length>1)){this.symbolInstanceIndexes=this.getSortedSymbolIndexes(e),this.sortedAngle=e,this.text.indexArray.clear(),this.icon.indexArray.clear(),this.featureSortOrder=[];for(const e of this.symbolInstanceIndexes){const t=this.symbolInstances.get(e);this.featureSortOrder.push(t.featureIndex),[t.rightJustifiedTextSymbolIndex,t.centerJustifiedTextSymbolIndex,t.leftJustifiedTextSymbolIndex].forEach((e,t,i)=>{e>=0&&i.indexOf(e)===t&&this.addIndicesForPlacedSymbol(this.text,e)}),t.verticalPlacedTextSymbolIndex>=0&&this.addIndicesForPlacedSymbol(this.text,t.verticalPlacedTextSymbolIndex),t.placedIconSymbolIndex>=0&&this.addIndicesForPlacedSymbol(this.icon,t.placedIconSymbolIndex),t.verticalPlacedIconSymbolIndex>=0&&this.addIndicesForPlacedSymbol(this.icon,t.verticalPlacedIconSymbolIndex)}this.text.indexBuffer&&this.text.indexBuffer.updateData(this.text.indexArray),this.icon.indexBuffer&&this.icon.indexBuffer.updateData(this.icon.indexArray)}}}let lh,ch;lo("SymbolBucket",ah,{omit:["layers","collisionBoxArray","features","compareText"]}),ah.MAX_GLYPHS=65535,ah.addDynamicAttributes=nh;var uh={get paint(){return ch=ch||new $o({"icon-opacity":new jo(Ae.paint_symbol["icon-opacity"]),"icon-color":new jo(Ae.paint_symbol["icon-color"]),"icon-halo-color":new jo(Ae.paint_symbol["icon-halo-color"]),"icon-halo-width":new jo(Ae.paint_symbol["icon-halo-width"]),"icon-halo-blur":new jo(Ae.paint_symbol["icon-halo-blur"]),"icon-translate":new Vo(Ae.paint_symbol["icon-translate"]),"icon-translate-anchor":new Vo(Ae.paint_symbol["icon-translate-anchor"]),"text-opacity":new jo(Ae.paint_symbol["text-opacity"]),"text-color":new jo(Ae.paint_symbol["text-color"],{runtimeType:ze,getOverride:e=>e.textColor,hasOverride:e=>!!e.textColor}),"text-halo-color":new jo(Ae.paint_symbol["text-halo-color"]),"text-halo-width":new jo(Ae.paint_symbol["text-halo-width"]),"text-halo-blur":new jo(Ae.paint_symbol["text-halo-blur"]),"text-translate":new Vo(Ae.paint_symbol["text-translate"]),"text-translate-anchor":new Vo(Ae.paint_symbol["text-translate-anchor"])})},get layout(){return lh=lh||new $o({"symbol-placement":new Vo(Ae.layout_symbol["symbol-placement"]),"symbol-spacing":new Vo(Ae.layout_symbol["symbol-spacing"]),"symbol-avoid-edges":new Vo(Ae.layout_symbol["symbol-avoid-edges"]),"symbol-sort-key":new jo(Ae.layout_symbol["symbol-sort-key"]),"symbol-z-order":new Vo(Ae.layout_symbol["symbol-z-order"]),"icon-allow-overlap":new Vo(Ae.layout_symbol["icon-allow-overlap"]),"icon-overlap":new Vo(Ae.layout_symbol["icon-overlap"]),"icon-ignore-placement":new Vo(Ae.layout_symbol["icon-ignore-placement"]),"icon-optional":new Vo(Ae.layout_symbol["icon-optional"]),"icon-rotation-alignment":new Vo(Ae.layout_symbol["icon-rotation-alignment"]),"icon-size":new jo(Ae.layout_symbol["icon-size"]),"icon-text-fit":new Vo(Ae.layout_symbol["icon-text-fit"]),"icon-text-fit-padding":new Vo(Ae.layout_symbol["icon-text-fit-padding"]),"icon-image":new jo(Ae.layout_symbol["icon-image"]),"icon-rotate":new jo(Ae.layout_symbol["icon-rotate"]),"icon-padding":new jo(Ae.layout_symbol["icon-padding"]),"icon-keep-upright":new Vo(Ae.layout_symbol["icon-keep-upright"]),"icon-offset":new jo(Ae.layout_symbol["icon-offset"]),"icon-anchor":new jo(Ae.layout_symbol["icon-anchor"]),"icon-pitch-alignment":new Vo(Ae.layout_symbol["icon-pitch-alignment"]),"text-pitch-alignment":new Vo(Ae.layout_symbol["text-pitch-alignment"]),"text-rotation-alignment":new Vo(Ae.layout_symbol["text-rotation-alignment"]),"text-field":new jo(Ae.layout_symbol["text-field"]),"text-font":new jo(Ae.layout_symbol["text-font"]),"text-size":new jo(Ae.layout_symbol["text-size"]),"text-max-width":new jo(Ae.layout_symbol["text-max-width"]),"text-line-height":new Vo(Ae.layout_symbol["text-line-height"]),"text-letter-spacing":new jo(Ae.layout_symbol["text-letter-spacing"]),"text-justify":new jo(Ae.layout_symbol["text-justify"]),"text-radial-offset":new jo(Ae.layout_symbol["text-radial-offset"]),"text-variable-anchor":new Vo(Ae.layout_symbol["text-variable-anchor"]),"text-variable-anchor-offset":new jo(Ae.layout_symbol["text-variable-anchor-offset"]),"text-anchor":new jo(Ae.layout_symbol["text-anchor"]),"text-max-angle":new Vo(Ae.layout_symbol["text-max-angle"]),"text-writing-mode":new Vo(Ae.layout_symbol["text-writing-mode"]),"text-rotate":new jo(Ae.layout_symbol["text-rotate"]),"text-padding":new Vo(Ae.layout_symbol["text-padding"]),"text-keep-upright":new Vo(Ae.layout_symbol["text-keep-upright"]),"text-transform":new jo(Ae.layout_symbol["text-transform"]),"text-offset":new jo(Ae.layout_symbol["text-offset"]),"text-allow-overlap":new Vo(Ae.layout_symbol["text-allow-overlap"]),"text-overlap":new Vo(Ae.layout_symbol["text-overlap"]),"text-ignore-placement":new Vo(Ae.layout_symbol["text-ignore-placement"]),"text-optional":new Vo(Ae.layout_symbol["text-optional"])})}};class hh{constructor(e){if(void 0===e.property.overrides)throw new Error("overrides must be provided to instantiate FormatSectionOverride class");this.type=e.property.overrides?e.property.overrides.runtimeType:Fe,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}}lo("FormatSectionOverride",hh,{omit:["defaultValue"]});class dh extends Zo{constructor(e,t){super(e,uh,t)}recalculate(e,t){if(super.recalculate(e,t),"auto"===this.layout.get("icon-rotation-alignment")&&(this.layout._values["icon-rotation-alignment"]="point"!==this.layout.get("symbol-placement")?"map":"viewport"),"auto"===this.layout.get("text-rotation-alignment")&&(this.layout._values["text-rotation-alignment"]="point"!==this.layout.get("symbol-placement")?"map":"viewport"),"auto"===this.layout.get("text-pitch-alignment")&&(this.layout._values["text-pitch-alignment"]="map"===this.layout.get("text-rotation-alignment")?"map":"viewport"),"auto"===this.layout.get("icon-pitch-alignment")&&(this.layout._values["icon-pitch-alignment"]=this.layout.get("icon-rotation-alignment")),"point"===this.layout.get("symbol-placement")){const e=this.layout.get("text-writing-mode");if(e){const t=[];for(const i of e)t.indexOf(i)<0&&t.push(i);this.layout._values["text-writing-mode"]=t}else this.layout._values["text-writing-mode"]=["horizontal"]}this._setPaintOverrides()}getValueAndResolveTokens(e,t,i,n){const r=this.layout.get(e).evaluate(t,{},i,n),o=this._unevaluatedLayout._values[e];return o.isDataDriven()||tr(o.value)||!r?r:function(e,t){return t.replace(/{([^{}]+)}/g,(t,i)=>e&&i in e?String(e[i]):"")}(t.properties,r)}createBucket(e){return new ah(e)}queryRadius(){return 0}queryIntersectsFeature(){throw new Error("Should take a different path in FeatureIndex")}_setPaintOverrides(){for(const e of uh.paint.overridableProperties){if(!dh.hasPaintOverride(this.layout,e))continue;const t=this.paint.get(e),i=new hh(t),n=new er(i,t.property.specification);let r=null;r="constant"===t.value.kind||"source"===t.value.kind?new nr("source",n):new rr("composite",n,t.value.zoomStops),this.paint._values[e]=new Uo(t.property,r,t.parameters)}}_handleOverridablePaintPropertyUpdate(e,t,i){return!(!this.layout||t.isDataDriven()||i.isDataDriven())&&dh.hasPaintOverride(this.layout,e)}static hasPaintOverride(e,t){const i=e.get("text-field"),n=uh.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 Mt)o(i.value.value.sections);else if("source"===i.value.kind||"composite"===i.value.kind){const e=t=>{r||(t instanceof Gt&&Vt(t.value)===Ge?o(t.value.sections):t instanceof Si?o(t.sections):t.eachChild(e))},t=i.value;t._styleExpression&&e(t._styleExpression.expression)}return r}}let ph;var fh={get paint(){return ph=ph||new $o({"background-color":new Vo(Ae.paint_background["background-color"]),"background-pattern":new Ho(Ae.paint_background["background-pattern"]),"background-opacity":new Vo(Ae.paint_background["background-opacity"])})}};class mh extends Zo{constructor(e,t){super(e,fh,t)}}class gh extends Zo{constructor(e,t){super(e,{},t),this.onAdd=e=>{this.implementation.onAdd&&this.implementation.onAdd(e,e.painter.context.gl)},this.onRemove=e=>{this.implementation.onRemove&&this.implementation.onRemove(e,e.painter.context.gl)},this.implementation=e}is3D(){return"3d"===this.implementation.renderingMode}hasOffscreenPass(){return void 0!==this.implementation.prerender}recalculate(){}updateTransitions(){}hasTransition(){return!1}serialize(){throw new Error("Custom layers cannot be serialized")}}class _h{constructor(e){this._methodToThrottle=e,this._triggered=!1,"undefined"!=typeof MessageChannel&&(this._channel=new MessageChannel,this._channel.port2.onmessage=()=>{this._triggered=!1,this._methodToThrottle()})}trigger(){this._triggered||(this._triggered=!0,this._channel?this._channel.port1.postMessage(!0):setTimeout(()=>{this._triggered=!1,this._methodToThrottle()},0))}remove(){delete this._channel,this._methodToThrottle=()=>{}}}const Ah={once:!0},yh=6371008.8;class vh{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 vh(O(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 yh*Math.acos(Math.min(r,1))}static convert(e){if(e instanceof vh)return e;if(Array.isArray(e)&&(2===e.length||3===e.length))return new vh(Number(e[0]),Number(e[1]));if(!Array.isArray(e)&&"object"==typeof e&&null!==e)return new vh(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: , lat: }, an object {lon: , lat: }, or an array of [, ]")}}const xh=2*Math.PI*yh;function bh(e){return xh*Math.cos(e*Math.PI/180)}function wh(e){return(180+e)/360}function Th(e){return(180-180/Math.PI*Math.log(Math.tan(Math.PI/4+e*Math.PI/360)))/360}function Eh(e,t){return e/bh(t)}function Ch(e){return 360*e-180}function Sh(e){return 360/Math.PI*Math.atan(Math.exp((180-360*e)*Math.PI/180))-90}function Bh(e,t){return e*bh(Sh(t))}class Ih{constructor(e,t,i=0){this.x=+e,this.y=+t,this.z=+i}static fromLngLat(e,t=0){const i=vh.convert(e);return new Ih(wh(i.lng),Th(i.lat),Eh(t,i.lat))}toLngLat(){return new vh(Ch(this.x),Sh(this.y))}toAltitude(){return Bh(this.z,this.y)}meterInMercatorCoordinateUnits(){return 1/xh*(e=Sh(this.y),1/Math.cos(e*Math.PI/180));var e}}function Mh(e,t,i){var n=2*Math.PI*6378137/256/Math.pow(2,i);return[e*n-2*Math.PI*6378137/2,t*n-2*Math.PI*6378137/2]}class Ph{constructor(e,t,i){if(!function(e,t,i){return!(e<0||e>25||i<0||i>=Math.pow(2,e)||t<0||t>=Math.pow(2,e))}(e,t,i))throw new Error(`x=${t}, y=${i}, z=${e} outside of bounds. 0<=x<${Math.pow(2,e)}, 0<=y<${Math.pow(2,e)} 0<=z<=25 `);this.z=e,this.x=t,this.y=i,this.key=Fh(0,e,e,t,i)}equals(e){return this.z===e.z&&this.x===e.x&&this.y===e.y}url(e,t,i){const n=(o=this.y,s=this.z,a=Mh(256*(r=this.x),256*(o=Math.pow(2,s)-o-1),s),l=Mh(256*(r+1),256*(o+1),s),a[0]+","+a[1]+","+l[0]+","+l[1]);var r,o,s,a,l;const c=function(e,t,i){let n,r="";for(let o=e;o>0;o--)n=1<1?"@2x":"").replace(/{quadkey}/g,c).replace(/{bbox-epsg-3857}/g,n)}isChildOf(e){const t=this.z-e.z;return t>0&&e.x===this.x>>t&&e.y===this.y>>t}getTilePoint(e){const t=Math.pow(2,this.z);return new i((e.x*t-this.x)*I,(e.y*t-this.y)*I)}toString(){return`${this.z}/${this.x}/${this.y}`}}class Rh{constructor(e,t){this.wrap=e,this.canonical=t,this.key=Fh(e,t.z,t.z,t.x,t.y)}}class Lh{constructor(e,t,i,n,r){if(this.terrainRttPosMatrix32f=null,e= z; overscaledZ = ${e}; z = ${i}`);this.overscaledZ=e,this.wrap=t,this.canonical=new Ph(i,+n,+r),this.key=Fh(t,e,i,n,r)}clone(){return new Lh(this.overscaledZ,this.wrap,this.canonical.z,this.canonical.x,this.canonical.y)}equals(e){return this.overscaledZ===e.overscaledZ&&this.wrap===e.wrap&&this.canonical.equals(e.canonical)}scaledTo(e){if(e>this.overscaledZ)throw new Error(`targetZ > this.overscaledZ; targetZ = ${e}; overscaledZ = ${this.overscaledZ}`);const t=this.canonical.z-e;return e>this.canonical.z?new Lh(e,this.wrap,this.canonical.z,this.canonical.x,this.canonical.y):new Lh(e,this.wrap,e,this.canonical.x>>t,this.canonical.y>>t)}isOverscaled(){return this.overscaledZ>this.canonical.z}calculateScaledKey(e,t){if(e>this.overscaledZ)throw new Error(`targetZ > this.overscaledZ; targetZ = ${e}; overscaledZ = ${this.overscaledZ}`);const i=this.canonical.z-e;return e>this.canonical.z?Fh(this.wrap*+t,e,this.canonical.z,this.canonical.x,this.canonical.y):Fh(this.wrap*+t,e,e,this.canonical.x>>i,this.canonical.y>>i)}isChildOf(e){if(e.wrap!==this.wrap)return!1;if(this.overscaledZ-e.overscaledZ<=0)return!1;if(0===e.overscaledZ)return this.overscaledZ>0;const t=this.canonical.z-e.canonical.z;return!(t<0)&&e.canonical.x===this.canonical.x>>t&&e.canonical.y===this.canonical.y>>t}children(e){if(this.overscaledZ>=e)return[new Lh(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 Lh(t,this.wrap,t,i,n),new Lh(t,this.wrap,t,i+1,n),new Lh(t,this.wrap,t,i,n+1),new Lh(t,this.wrap,t,i+1,n+1)]}isLessThan(e){return this.wrape.wrap)&&(this.overscaledZe.overscaledZ)&&(this.canonical.xe.canonical.x)&&this.canonical.ye.key===i);t>-1&&e.addOrUpdateProperties.splice(t,1)}return(e.removeAllProperties||t.removeAllProperties)&&(i.removeAllProperties=!0),(e.removeProperties||t.removeProperties)&&(i.removeProperties=[...e.removeProperties||[],...t.removeProperties||[]]),(e.addOrUpdateProperties||t.addOrUpdateProperties)&&(i.addOrUpdateProperties=[...e.addOrUpdateProperties||[],...t.addOrUpdateProperties||[]]),(e.newGeometry||t.newGeometry)&&(i.newGeometry=t.newGeometry||e.newGeometry),i}function Oh(e){var t,i;if(!e)return{};const n={};return n.removeAll=e.removeAll,n.remove=new Set(e.remove||[]),n.add=new Map(null===(t=e.add)||void 0===t?void 0:t.map(e=>[e.id,e])),n.update=new Map(null===(i=e.update)||void 0===i?void 0:i.map(e=>[e.id,e])),n}lo("CanonicalTileID",Ph),lo("OverscaledTileID",Lh,{omit:["terrainRttPosMatrix32f"]});class zh{constructor(e){this._stringToNumber={},this._numberToString=[];for(let t=0;t=this._numberToString.length)throw new Error(`Out of bounds. Index requested n=${e} can't be >= this._numberToString.length ${this._numberToString.length}`);return this._numberToString[e]}}class Uh{constructor(e,t,i,n,r){this.type="Feature",this._vectorTileFeature=e,e._z=t,e._x=i,e._y=n,this.properties=e.properties,this.id=r}get geometry(){return void 0===this._geometry&&(this._geometry=this._vectorTileFeature.toGeoJSON(this._vectorTileFeature._x,this._vectorTileFeature._y,this._vectorTileFeature._z).geometry),this._geometry}set geometry(e){this._geometry=e}toJSON(){const e={geometry:this.geometry};for(const t in this)"_geometry"!==t&&"_vectorTileFeature"!==t&&(e[t]=this[t]);return e}}class Nh{_name;dataBuffer;nullabilityBuffer;_size;constructor(e,t,i){this._name=e,this.dataBuffer=t,"number"==typeof i?this._size=i:(this.nullabilityBuffer=i,this._size=i.size())}getValue(e){return this.nullabilityBuffer&&!this.nullabilityBuffer.get(e)?null:this.getValueFromBuffer(e)}has(e){return this.nullabilityBuffer&&this.nullabilityBuffer.get(e)||!this.nullabilityBuffer}get name(){return this._name}get size(){return this._size}}class Vh extends Nh{}class jh extends Vh{getValueFromBuffer(e){return this.dataBuffer[e]}}class Gh extends Vh{getValueFromBuffer(e){return this.dataBuffer[e]}}class Hh extends Nh{delta;constructor(e,t,i,n){super(e,t,n),this.delta=i}}class Qh extends Hh{constructor(e,t,i,n){super(e,Int32Array.of(t),i,n)}getValueFromBuffer(e){return this.dataBuffer[0]+e*this.delta}}class $h extends Nh{constructor(e,t,i){super(e,Int32Array.of(t),i)}getValueFromBuffer(e){return this.dataBuffer[0]}}class Zh{_name;_geometryVector;_idVector;_propertyVectors;_extent;propertyVectorsMap;constructor(e,t,i,n,r=4096){this._name=e,this._geometryVector=t,this._idVector=i,this._propertyVectors=n,this._extent=r}get name(){return this._name}get idVector(){return this._idVector}get geometryVector(){return this._geometryVector}get propertyVectors(){return this._propertyVectors}getPropertyVector(e){return this.propertyVectorsMap||(this.propertyVectorsMap=new Map(this._propertyVectors.map(e=>[e.name,e]))),this.propertyVectorsMap.get(e)}*[Symbol.iterator](){const e=this.geometryVector[Symbol.iterator]();let t=0;for(;t>4,r<128)return 4294967296*n+(e>>>0);if(r=t[i.get()],i.increment(),n|=(127&r)<<3,r<128)return 4294967296*n+(e>>>0);if(r=t[i.get()],i.increment(),n|=(127&r)<<10,r<128)return 4294967296*n+(e>>>0);if(r=t[i.get()],i.increment(),n|=(127&r)<<17,r<128)return 4294967296*n+(e>>>0);if(r=t[i.get()],i.increment(),n|=(127&r)<<24,r<128)return 4294967296*n+(e>>>0);if(r=t[i.get()],i.increment(),n|=(1&r)<<31,r<128)return 4294967296*n+(e>>>0);throw new Error("Expected varint not more than 10 bytes")}(i,e,t)))))}function cd(e,t,i,n){throw new Error("FastPFor is not implemented yet.")}function ud(e){return e>>>1^-(1&e)}function hd(e){return e>>1n^-(1n&e)}function dd(e,t){let i=0n,n=0,r=t.get();for(;r=64)throw new Error("Varint too long")}return t.set(r),i}function pd(e,t,i){const n=new Int32Array(i);let r=0;for(let i=0;i=4)for(let n=e[0];i>>1^-(1&e[0]),e[1]=e[1]>>>1^-(1&e[1]);const t=e.length/4*4;let i=2;if(t>=4)for(;i>>1^-(1&t))+e[i-2],e[i+1]=(n>>>1^-(1&n))+e[i-1],e[i+2]=(r>>>1^-(1&r))+e[i],e[i+3]=(o>>>1^-(1&o))+e[i+1]}for(;i!=e.length;i+=2)e[i]=(e[i]>>>1^-(1&e[i]))+e[i-2],e[i+1]=(e[i+1]>>>1^-(1&e[i+1]))+e[i-1]}function Ad(e,t,i){return Math.min(i,Math.max(t,e))}!function(e){e.NONE="NONE",e.DELTA="DELTA",e.COMPONENTWISE_DELTA="COMPONENTWISE_DELTA",e.RLE="RLE",e.MORTON="MORTON",e.PDE="PDE"}(Kh||(Kh={})),function(e){e.NONE="NONE",e.FAST_PFOR="FAST_PFOR",e.VARINT="VARINT",e.ALP="ALP"}(Xh||(Xh={})),function(e){e.NONE="NONE",e.SINGLE="SINGLE",e.SHARED="SHARED",e.VERTEX="VERTEX",e.MORTON="MORTON",e.FSST="FSST"}(Jh||(Jh={})),function(e){e.VERTEX="VERTEX",e.INDEX="INDEX",e.STRING="STRING",e.KEY="KEY"}(Yh||(Yh={})),function(e){e.VAR_BINARY="VAR_BINARY",e.GEOMETRIES="GEOMETRIES",e.PARTS="PARTS",e.RINGS="RINGS",e.TRIANGLES="TRIANGLES",e.SYMBOL="SYMBOL",e.DICTIONARY="DICTIONARY"}(ed||(ed={}));class yd{_physicalStreamType;_logicalStreamType;_logicalLevelTechnique1;_logicalLevelTechnique2;_physicalLevelTechnique;_numValues;_byteLength;constructor(e,t,i,n,r,o,s){this._physicalStreamType=e,this._logicalStreamType=t,this._logicalLevelTechnique1=i,this._logicalLevelTechnique2=n,this._physicalLevelTechnique=r,this._numValues=o,this._byteLength=s}static decode(e,t){const i=e[t.get()],n=Object.values(qh)[i>>4];let r=null;switch(n){case qh.DATA:r=new od(Object.values(Jh)[15&i]);break;case qh.OFFSET:r=new od(null,Object.values(Yh)[15&i]);break;case qh.LENGTH:r=new od(null,null,Object.values(ed)[15&i])}t.increment();const o=e[t.get()],s=Object.values(Kh)[o>>5],a=Object.values(Kh)[o>>2&7],l=Object.values(Xh)[3&o];t.increment();const c=sd(e,t,2);return new yd(n,r,s,a,l,c[0],c[1])}get physicalStreamType(){return this._physicalStreamType}get logicalStreamType(){return this._logicalStreamType}get logicalLevelTechnique1(){return this._logicalLevelTechnique1}get logicalLevelTechnique2(){return this._logicalLevelTechnique2}get physicalLevelTechnique(){return this._physicalLevelTechnique}get numValues(){return this._numValues}get byteLength(){return this._byteLength}getDecompressedCount(){return this._numValues}}class vd extends yd{num_bits;coordinate_shift;constructor(e,t,i,n,r,o,s,a,l){super(e,t,i,n,r,o,s),this.num_bits=a,this.coordinate_shift=l}static decode(e,t){const i=yd.decode(e,t),n=sd(e,t,2);return new vd(i.physicalStreamType,i.logicalStreamType,i.logicalLevelTechnique1,i.logicalLevelTechnique2,i.physicalLevelTechnique,i.numValues,i.byteLength,n[0],n[1])}static decodePartial(e,t,i){const n=sd(t,i,2);return new vd(e.physicalStreamType,e.logicalStreamType,e.logicalLevelTechnique1,e.logicalLevelTechnique2,e.physicalLevelTechnique,e.numValues,e.byteLength,n[0],n[1])}numBits(){return this.num_bits}coordinateShift(){return this.coordinate_shift}}class xd extends yd{_runs;_numRleValues;constructor(e,t,i,n,r,o,s,a,l){super(e,t,i,n,r,o,s),this._runs=a,this._numRleValues=l}static decode(e,t){const i=yd.decode(e,t),n=sd(e,t,2);return new xd(i.physicalStreamType,i.logicalStreamType,i.logicalLevelTechnique1,i.logicalLevelTechnique2,i.physicalLevelTechnique,i.numValues,i.byteLength,n[0],n[1])}static decodePartial(e,t,i){const n=sd(t,i,2);return new xd(e.physicalStreamType,e.logicalStreamType,e.logicalLevelTechnique1,e.logicalLevelTechnique2,e.physicalLevelTechnique,e.numValues,e.byteLength,n[0],n[1])}get runs(){return this._runs}get numRleValues(){return this._numRleValues}getDecompressedCount(){return this._numRleValues}}class bd{static decode(e,t){const i=yd.decode(e,t);return i.logicalLevelTechnique1===Kh.MORTON?vd.decodePartial(i,e,t):Kh.RLE!==i.logicalLevelTechnique1&&Kh.RLE!==i.logicalLevelTechnique2||Xh.NONE===i.physicalLevelTechnique?i:xd.decodePartial(i,e,t)}}!function(e){e[e.FLAT=0]="FLAT",e[e.CONST=1]="CONST",e[e.SEQUENCE=2]="SEQUENCE",e[e.DICTIONARY=3]="DICTIONARY",e[e.FSST_DICTIONARY=4]="FSST_DICTIONARY"}(td||(td={}));class wd{values;_size;constructor(e,t){this.values=e,this._size=t}get(e){const t=Math.floor(e/8);return 1==(this.values[t]>>e%8&1)}set(e,t){const i=Math.floor(e/8);this.values[i]=this.values[i]|(t?1:0)<>e%8&1}size(){return this._size}getBuffer(){return this.values}}class Td{constructor(){}static decodeIntStream(e,t,i,n,r){const o=Td.decodePhysicalLevelTechnique(e,t,i);return this.decodeIntBuffer(o,i,n,r)}static decodeLengthStreamToOffsetBuffer(e,t,i){const n=Td.decodePhysicalLevelTechnique(e,t,i);return this.decodeLengthToOffsetBuffer(n,i)}static decodePhysicalLevelTechnique(e,t,i){const n=i.physicalLevelTechnique;if(n===Xh.FAST_PFOR)return cd();if(n===Xh.VARINT)return sd(e,t,i.numValues);if(n===Xh.NONE){const n=t.get();t.add(i.byteLength);const r=e.subarray(n,t.get());return new Int32Array(r)}throw new Error("Specified physicalLevelTechnique is not supported (yet).")}static decodeConstIntStream(e,t,i,n){const r=Td.decodePhysicalLevelTechnique(e,t,i);if(1===r.length){const e=r[0];return n?ud(e):e}return n?function(e){return ud(e[1])}(r):function(e){return e[1]}(r)}static decodeSequenceIntStream(e,t,i){return function(e){if(2==e.length){const t=ud(e[1]);return[t,t]}return[ud(e[2]),ud(e[3])]}(Td.decodePhysicalLevelTechnique(e,t,i))}static decodeSequenceLongStream(e,t,i){return function(e){if(2==e.length){const t=hd(e[1]);return[t,t]}return[hd(e[2]),hd(e[3])]}(ad(e,t,i.numValues))}static decodeLongStream(e,t,i,n){const r=ad(e,t,i.numValues);return this.decodeLongBuffer(r,i,n)}static decodeLongFloat64Stream(e,t,i,n){const r=function(e,t,i){const n=new Float64Array(t);for(let r=0;r>>1^-(1&e[0]);const t=e.length/4*4;let i=1;if(t>=4)for(;i>>1^-(1&t))+e[i-1],e[i+1]=(n>>>1^-(1&n))+e[i],e[i+2]=(r>>>1^-(1&r))+e[i+1],e[i+3]=(o>>>1^-(1&o))+e[i+2]}for(;i!=e.length;++i)e[i]=(e[i]>>>1^-(1&e[i]))+e[i-1]}(e),e);case Kh.RLE:return function(e,t,i){return i?function(e,t,i){const n=new Int32Array(i);let r=0;for(let i=0;i>>1^-(1&s),n.fill(s,r,r+o),r+=o}return n}(e,t.runs,t.numRleValues):pd(e,t.runs,t.numRleValues)}(e,t,i);case Kh.MORTON:return gd(e),e;case Kh.COMPONENTWISE_DELTA:return n?(function(e,t,i,n){let r=e[0]>>>1^-(1&e[0]),o=e[1]>>>1^-(1&e[1]);e[0]=Ad(Math.round(r*t),i,n),e[1]=Ad(Math.round(o*t),i,n);const s=e.length/16;let a=2;if(s>=4)for(;a>>1^-(1&s))+r,u=(l>>>1^-(1&l))+o;e[a]=Ad(Math.round(c*t),i,n),e[a+1]=Ad(Math.round(u*t),i,n);const h=e[a+2],d=e[a+3];r=(h>>>1^-(1&h))+c,o=(d>>>1^-(1&d))+u,e[a+2]=Ad(Math.round(r*t),i,n),e[a+3]=Ad(Math.round(o*t),i,n)}for(;a!=e.length;a+=2)r+=e[a]>>>1^-(1&e[a]),o+=e[a+1]>>>1^-(1&e[a+1]),e[a]=Ad(Math.round(r*t),i,n),e[a+1]=Ad(Math.round(o*t),i,n)}(e,n.scale,n.min,n.max),e):(_d(e),e);case Kh.NONE:return i&&function(e){for(let t=0;t>>1^-(1&i)}}(e),e;default:throw new Error(`The specified Logical level technique is not supported: ${t.logicalLevelTechnique1}`)}}static decodeLongBuffer(e,t,i){switch(t.logicalLevelTechnique1){case Kh.DELTA:return t.logicalLevelTechnique2===Kh.RLE?function(e,t,i){const n=new BigInt64Array(i);let r=0,o=0n;for(let i=0;i>1n^-(1n&e[0]);const t=e.length/4*4;let i=1;if(t>=4)for(;i>1n^-(1n&t))+e[i-1],e[i+1]=(n>>1n^-(1n&n))+e[i],e[i+2]=(r>>1n^-(1n&r))+e[i+1],e[i+3]=(o>>1n^-(1n&o))+e[i+2]}for(;i!=e.length;++i)e[i]=(e[i]>>1n^-(1n&e[i]))+e[i-1]}(e),e);case Kh.RLE:return function(e,t,i){return i?function(e,t,i){const n=new BigInt64Array(i);let r=0;for(let i=0;i>1n^-(1n&s),n.fill(s,r,r+o),r+=o}return n}(e,t.runs,t.numRleValues):fd(e,t.runs,t.numRleValues)}(e,t,i);case Kh.NONE:return i&&function(e){for(let t=0;t>1n^-(1n&i)}}(e),e;default:throw new Error(`The specified Logical level technique is not supported: ${t.logicalLevelTechnique1}`)}}static decodeFloat64Buffer(e,t,i){switch(t.logicalLevelTechnique1){case Kh.DELTA:return t.logicalLevelTechnique2===Kh.RLE&&(e=md(e,t.runs,t.numRleValues)),function(e){e[0]=e[0]%2==1?(e[0]+1)/-2:e[0]/2;const t=e.length/4*4;let i=1;if(t>=4)for(;i>>1^-(1&r),t[n]=t[n-1]+i}return t}(e);if(t.logicalLevelTechnique1===Kh.RLE&&t.logicalLevelTechnique2===Kh.NONE)return function(e,t,i){const n=new Int32Array(i+1);n[0]=0;let r=1,o=n[0];for(let i=0;i>>1^-(1&a);for(let e=r;e>>1^-(1&t[0]):0,n=1):i[0]=0;let r=1;for(;r!=i.length;++r)i[r]=e.get(r)?i[r-1]+(t[n]>>>1^-(1&t[n++])):i[r-1];return i}(n,e);case Kh.RLE:return function(e,t,i,n){const r=t;return i?function(e,t,i){const n=new Int32Array(e.size());let r=0;for(let o=0;o>>1^-(1&a);for(let t=r;t>>1^-(1&e)}else i[r]=0;return i}(n,e):function(e,t){const i=new Int32Array(e.size());let n=0,r=0;for(;r!=i.length;++r)i[r]=e.get(r)?t[n++]:0;return i}(n,e),e;default:throw new Error("The specified Logical level technique is not supported")}}static decodeNullableLongBuffer(e,t,i,n){switch(t.logicalLevelTechnique1){case Kh.DELTA:return t.logicalLevelTechnique2===Kh.RLE&&(e=fd(e,t.runs,t.numRleValues)),function(e,t){const i=new BigInt64Array(e.size());let n=0;e.get(0)?(i[0]=e.get(0)?t[0]>>1n^-(1n&t[0]):0n,n=1):i[0]=0n;let r=1;for(;r!=i.length;++r)i[r]=e.get(r)?i[r-1]+(t[n]>>1n^-(1n&t[n++])):i[r-1];return i}(n,e);case Kh.RLE:return function(e,t,i,n){const r=t;return i?function(e,t,i){const n=new BigInt64Array(e.size());let r=0;for(let o=0;o>1n^-(1n&a);for(let t=r;t>1n^-(1n&e)}else i[r]=0n;return i}(n,e):function(e,t){const i=new BigInt64Array(e.size());let n=0,r=0;for(;r!=i.length;++r)i[r]=e.get(r)?t[n++]:0n;return i}(n,e),e;default:throw new Error("The specified Logical level technique is not supported")}}static getVectorType(e,t,i,n){const r=e.logicalLevelTechnique1;if(r===Kh.RLE)return 1===e.runs?td.CONST:td.FLAT;const o=t instanceof wd?t.size():t;if(r===Kh.DELTA&&e.logicalLevelTechnique2===Kh.RLE){const t=e.runs,r=2;if(e.numRleValues!==o)return td.FLAT;if(1===t)return td.SEQUENCE;if(2===t){const t=n.get();let o;if(e.physicalLevelTechnique===Xh.VARINT)o=sd(i,n,4);else{const e=n.get();o=new Int32Array(i.buffer,i.byteOffset+e,4)}if(n.set(t),o[2]===r&&o[3]===r)return td.SEQUENCE}}return 1===e.numValues?td.CONST:td.FLAT}}class Ed extends Vh{getValueFromBuffer(e){return this.dataBuffer[e]}}class Cd extends Hh{constructor(e,t,i,n){super(e,BigInt64Array.of(t),i,n)}getValueFromBuffer(e){return this.dataBuffer[0]+BigInt(e)*this.delta}}class Sd{_geometryOffsets;_partOffsets;_ringOffsets;constructor(e,t,i){this._geometryOffsets=e,this._partOffsets=t,this._ringOffsets=i}get geometryOffsets(){return this._geometryOffsets}get partOffsets(){return this._partOffsets}get ringOffsets(){return this._ringOffsets}}class Bd{tileExtent;_numBits;_coordinateShift;minBound;maxBound;constructor(e,t){this._coordinateShift=e<0?Math.abs(e):0,this.tileExtent=t+this._coordinateShift,this._numBits=Math.ceil(Math.log2(this.tileExtent)),this.minBound=e,this.maxBound=t}validateCoordinates(e){if(e.xthis.maxBound||e.y>this.maxBound)throw new Error("The specified tile buffer size is currently not supported.")}numBits(){return this._numBits}coordinateShift(){return this._coordinateShift}}class Id extends Bd{encode(e){this.validateCoordinates(e);const t=e.x+this._coordinateShift,i=e.y+this._coordinateShift;let n=0;for(let e=0;e>1)-this._coordinateShift}}decodeMorton(e){let t=0;for(let i=0;i>i;return t}static decode(e,t,i){return{x:Id.decodeMorton(e,t)-i,y:Id.decodeMorton(e>>1,t)-i}}static decodeMorton(e,t){let i=0;for(let n=0;n>n;return i}}!function(e){e[e.POINT=0]="POINT",e[e.LINESTRING=1]="LINESTRING",e[e.POLYGON=2]="POLYGON",e[e.MULTIPOINT=3]="MULTIPOINT",e[e.MULTILINESTRING=4]="MULTILINESTRING",e[e.MULTIPOLYGON=5]="MULTIPOLYGON"}(id||(id={})),function(e){e[e.POINT=0]="POINT",e[e.LINESTRING=1]="LINESTRING",e[e.POLYGON=2]="POLYGON"}(nd||(nd={})),function(e){e[e.MORTON=0]="MORTON",e[e.VEC_2=1]="VEC_2",e[e.VEC_3=2]="VEC_3"}(rd||(rd={}));class Md{createPoint(e){return[[e]]}createMultiPoint(e){return e.map(e=>[e])}createLineString(e){return[e]}createMultiLineString(e){return e}createPolygon(e,t){return[e,...t]}createMultiPolygon(e){return e.flat()}}function Pd(e){const t=new Array(e.numGeometries);let n=1,r=1,o=1,s=0;const a=new Md;let l=0,c=0;const u=e.mortonSettings,h=e.topologyVector,d=h.geometryOffsets,p=h.partOffsets,f=h.ringOffsets,m=e.vertexOffsets,g=e.containsPolygonGeometry(),_=e.vertexBuffer;for(let h=0;h0&&t.push(t[0]),h.push(t)}e[t]=h,o&&c++}break;case id.MULTIPOLYGON:{const u=o[c]-o[c-1];c++;const h=[];for(let e=0;e0&&t.push(t[0]),h.push(t)}}e[t]=h}}return e}[Symbol.iterator](){return null}}class jd extends Vd{_numGeometries;_geometryType;constructor(e,t,i,n,r,o){super(i,n,r,o),this._numGeometries=e,this._geometryType=t}static create(e,t,i,n,r,o){return new jd(e,t,i,n,r,o)}geometryType(e){return this._geometryType}get numGeometries(){return this._numGeometries}containsSingleGeometryType(){return!0}}class Gd extends Vd{_geometryTypes;constructor(e,t,i,n,r){super(t,i,n,r),this._geometryTypes=e}static create(e,t,i,n,r){return new Gd(e,t,i,n,r)}geometryType(e){return this._geometryTypes[e]}get numGeometries(){return this._geometryTypes.length}containsSingleGeometryType(){return!1}}function Hd(e,t,i,n,r){const o=bd.decode(e,i);let s=null,a=null,l=null,c=null,u=null,h=null,d=null,p=null;if(Td.getVectorType(o,n,e,i)===td.CONST){const f=Td.decodeConstIntStream(e,i,o,!1);for(let n=0;ni?t[o++]:1);return n}function $d(e,t,i,n){const r=new Int32Array(t[t.length-1]+1);let o=0;r[0]=o;let s=1,a=0;for(let l=0;l=12?Yd.decode(e.subarray(t,i)):function(e,t,i){let n="",r=t;for(;r239?4:t>223?3:t>191?2:1;if(r+c>i)break;1===c?t<128&&(l=t):2===c?(o=e[r+1],128==(192&o)&&(l=(31&t)<<6|63&o,l<=127&&(l=null))):3===c?(o=e[r+1],s=e[r+2],128==(192&o)&&128==(192&s)&&(l=(15&t)<<12|(63&o)<<6|63&s,(l<=2047||l>=55296&&l<=57343)&&(l=null))):4===c&&(o=e[r+1],s=e[r+2],a=e[r+3],128==(192&o)&&128==(192&s)&&128==(192&a)&&(l=(15&t)<<18|(63&o)<<12|(63&s)<<6|63&a,(l<=65535||l>=1114112)&&(l=null))),null===l?(l=65533,c=1):l>65535&&(l-=65536,n+=String.fromCharCode(l>>>10&1023|55296),l=56320|1023&l),n+=String.fromCharCode(l),r+=c}return n}(e,t,i)}class tp extends Nh{offsetBuffer;constructor(e,t,i,n){super(e,i,n),this.offsetBuffer=t}}class ip extends tp{textEncoder;constructor(e,t,i,n){super(e,t,i,n??t.length-1),this.textEncoder=new TextEncoder}getValueFromBuffer(e){return ep(this.dataBuffer,this.offsetBuffer[e],this.offsetBuffer[e+1])}}class np extends tp{indexBuffer;textEncoder;constructor(e,t,i,n,r){super(e,i,n,r??t.length),this.indexBuffer=t,this.indexBuffer=t,this.textEncoder=new TextEncoder}getValueFromBuffer(e){const t=this.indexBuffer[e];return ep(this.dataBuffer,this.offsetBuffer[t],this.offsetBuffer[t+1])}}class rp extends tp{indexBuffer;symbolOffsetBuffer;symbolTableBuffer;textEncoder;symbolLengthBuffer;lengthBuffer;decodedDictionary;constructor(e,t,i,n,r,o,s){super(e,i,n,s),this.indexBuffer=t,this.symbolOffsetBuffer=r,this.symbolTableBuffer=o,this.textEncoder=new TextEncoder}getValueFromBuffer(e){null==this.decodedDictionary&&(null==this.symbolLengthBuffer&&(this.symbolLengthBuffer=this.offsetToLengthBuffer(this.symbolOffsetBuffer),this.lengthBuffer=this.offsetToLengthBuffer(this.offsetBuffer)),this.decodedDictionary=function(e,t,i){const n=[],r=new Array(t.length).fill(0);for(let e=1;e1?6:4,i.type="physicalType",t.scalarType=i,t.type="scalarType",t}case 4:{const e={nullable:!1,columnScope:0},t={type:"physicalType",physicalType:0};return e.type="complexType",e.complexType=t,e}case 30:{const e={nullable:!1,columnScope:0},t={type:"physicalType",physicalType:1};return e.type="complexType",e.complexType=t,e}default:return this.mapScalarType(e)}}static columnTypeHasName(e){return e>=10}static columnTypeHasChildren(e){return 30===e}static hasStreamCount(e){if("id"===e.name)return!1;if("scalarType"===e.type){const t=e.scalarType;if("physicalType"===t.type)switch(t.physicalType){case 0:case 1:case 2:case 3:case 4:case 5:case 6:case 7:case 8:default:return!1;case 9:return!0}else if("logicalType"===t.type)return!1}else if("complexType"===e.type){const t=e.complexType;if("physicalType"===t.type)switch(t.physicalType){case 0:case 1:return!0;default:return!1}}return console.warn("Unexpected column type in hasStreamCount",e),!1}static mapScalarType(e){let t=null;switch(e){case 10:case 11:t=0;break;case 12:case 13:t=1;break;case 14:case 15:t=2;break;case 16:case 17:t=3;break;case 18:case 19:t=4;break;case 20:case 21:t=5;break;case 22:case 23:t=6;break;case 24:case 25:t=7;break;case 26:case 27:t=8;break;case 28:case 29:t=9;break;default:return null}const i={};i.nullable=!!(1&e),i.columnScope=0;const n={type:"physicalType"};return n.physicalType=t,i.type="scalarType",i.scalarType=n,i}}const cp=new TextDecoder;function up(e,t){const i=sd(e,t,1)[0];if(0===i)return"";const n=t.get(),r=e.subarray(n,n+i);return t.add(i),cp.decode(r)}function hp(e,t){const i=sd(e,t,1)[0]>>>0,n=!!(4&i),r=!!(2&i),o=sd(e,t,1)[0]>>>0,s={};if(1&i&&(s.nullable=!0),r){const r={};if(n?(r.type="logicalType",r.logicalType=o):(r.type="physicalType",r.physicalType=o),8&i){const i=sd(e,t,1)[0]>>>0;r.children=new Array(i);for(let n=0;n>>0,n=lp.decodeColumnType(i);if(!n)throw new Error(`Unsupported column type code: ${i}`);if(lp.columnTypeHasName(i)?n.name=up(e,t):i>=0&&i<=3?n.name="id":4===i&&(n.name="geometry"),lp.columnTypeHasChildren(i)){const i=sd(e,t,1)[0]>>>0,r=n.complexType;r.children=new Array(i);for(let n=0;n>>0,o=sd(e,t,1)[0]>>>0;n.columns=new Array(o);for(let i=0;ithis.projectPoint(e,t,i,n))}toGeoJSON(e,t,i){const n=this.extent*Math.pow(2,i),r=this.extent*e,o=this.extent*t,s=this.loadGeometry();let a;switch(this.type){case 1:{const e=[];for(const t of s)e.push(t[0]);const t=this.projectLine(e,r,o,n);a=1===e.length?{type:"Point",coordinates:t[0]}:{type:"MultiPoint",coordinates:t};break}case 2:{const e=s.map(e=>this.projectLine(e,r,o,n));a=1===e.length?{type:"LineString",coordinates:e[0]}:{type:"MultiLineString",coordinates:e};break}case 3:{const e=Yi(s),t=[];for(const i of e)t.push(i.map(e=>this.projectLine(e,r,o,n)));a=1===t.length?{type:"Polygon",coordinates:t[0]}:{type:"MultiPolygon",coordinates:t};break}default:throw new Error(`unknown feature type: ${this.type}`)}const l={type:"Feature",geometry:a,properties:this.properties};return null!=this.id&&(l.id=this.id),l}loadGeometry(){const e=[];for(const t of this._featureData.geometry.coordinates){const n=[];for(const e of t)n.push(new i(e.x,e.y));e.push(n)}return e}bbox(){return[0,0,0,0]}}class gp{constructor(e){this.features=[],this.featureTable=e,this.name=e.name,this.extent=e.extent,this.version=2,this.features=e.getFeatures(),this.length=this.features.length}feature(e){return new mp(this.features[e],this.extent)}}class _p{constructor(e){this.layers={};const t=function(e,t,i=!0){const n=new Wh(0),r=[];for(;n.get()>>0,s=n.get()+o;if(s>e.length)throw new Error(`Block overruns tile: ${s} > ${e.length}`);if(1!=sd(e,n,1)[0]>>>0){n.set(s);continue}const a=pp(e,n),l=a[1],c=a[0].featureTables[0];let u=null,h=null;const d=[];let p=0;for(const r of c.columns){const o=r.name;if("id"===o){let t=null;if(r.nullable){const i=bd.decode(e,n),r=n.get(),o=Xd(e,i.numValues,n);n.set(r+i.byteLength),t=new wd(o,i.numValues)}const s=bd.decode(e,n);p=s.getDecompressedCount(),u=fp(e,r,n,o,s,t??p,i)}else if("geometry"===o){const i=sd(e,n,1)[0];if(0===p){const t=n.get();p=bd.decode(e,n).getDecompressedCount(),n.set(t)}h=Hd(e,i,n,p,t)}else{const t=lp.hasStreamCount(r)?sd(e,n,1)[0]:1;if(0===t&&"scalarType"===r.type)continue;const i=sp(e,n,r,t,p,void 0);i&&(Array.isArray(i)?d.push(...i):d.push(i))}}const f=new Zh(c.name,h,u,d,l);r.push(f),n.set(s)}return r}(new Uint8Array(e));this.layers=t.reduce((e,t)=>Object.assign(Object.assign({},e),{[t.name]:new gp(t)}),{})}}class Ap{constructor(){this.minX=1/0,this.maxX=-1/0,this.minY=1/0,this.maxY=-1/0}extend(e){return this.minX=Math.min(this.minX,e.x),this.minY=Math.min(this.minY,e.y),this.maxX=Math.max(this.maxX,e.x),this.maxY=Math.max(this.maxY,e.y),this}expandBy(e){return this.minX-=e,this.minY-=e,this.maxX+=e,this.maxY+=e,(this.minX>this.maxX||this.minY>this.maxY)&&(this.minX=1/0,this.maxX=-1/0,this.minY=1/0,this.maxY=-1/0),this}shrinkBy(e){return this.expandBy(-e)}map(e){const t=new Ap;return t.extend(e(new i(this.minX,this.minY))),t.extend(e(new i(this.maxX,this.minY))),t.extend(e(new i(this.minX,this.maxY))),t.extend(e(new i(this.maxX,this.maxY))),t}static fromPoints(e){const t=new Ap;for(const i of e)t.extend(i);return t}contains(e){return e.x>=this.minX&&e.x<=this.maxX&&e.y>=this.minY&&e.y<=this.maxY}empty(){return this.minX>this.maxX}width(){return this.maxX-this.minX}height(){return this.maxY-this.minY}covers(e){return!this.empty()&&!e.empty()&&e.minX>=this.minX&&e.maxX<=this.maxX&&e.minY>=this.minY&&e.maxY<=this.maxY}intersects(e){return!this.empty()&&!e.empty()&&e.minX<=this.maxX&&e.maxX>=this.minX&&e.minY<=this.maxY&&e.maxY>=this.minY}}const yp="_geojsonTileLayer";class vp{constructor(e,t){this.tileID=e,this.x=e.canonical.x,this.y=e.canonical.y,this.z=e.canonical.z,this.grid=new so(I,16,0),this.grid3D=new so(I,16,0),this.featureIndexArray=new Os,this.promoteId=t}insert(e,t,i,n,r,o){const s=this.featureIndexArray.length;this.featureIndexArray.emplaceBack(i,n,r);const a=o?this.grid3D:this.grid;for(let e=0;e=0&&n[3]>=0&&a.insert(s,n[0],n[1],n[2],n[3])}}loadVTLayers(){return this.vtLayers||(this.vtLayers="mlt"!==this.encoding?new Ic(new xu(this.rawTileData)).layers:new _p(this.rawTileData).layers,this.sourceLayerCoder=new zh(this.vtLayers?Object.keys(this.vtLayers).sort():[yp])),this.vtLayers}query(e,t,n,r){this.loadVTLayers();const o=e.params,s=I/e.tileSize/e.scale,a=dr(o.filter,o.globalState),l=e.queryGeometry,c=e.queryPadding*s,u=Ap.fromPoints(l),h=this.grid.query(u.minX-c,u.minY-c,u.maxX+c,u.maxY+c),d=Ap.fromPoints(e.cameraQueryGeometry).expandBy(c),p=this.grid3D.query(d.minX,d.minY,d.maxX,d.maxY,(t,n,r,o)=>function(e,t,n,r,o){for(const i of e)if(t<=i.x&&n<=i.y&&r>=i.x&&o>=i.y)return!0;const s=[new i(t,n),new i(t,o),new i(r,o),new i(r,n)];if(e.length>2)for(const t of s)if(Ka(e,t))return!0;for(let t=0;t(d||(d=Da(t)),i.queryIntersectsFeature({queryGeometry:l,feature:t,featureState:n,geometry:d,zoom:this.z,transform:e.transform,pixelsToTileUnits:s,pixelPosMatrix:e.pixelPosMatrix,unwrappedTileID:this.tileID.toUnwrapped(),getElevation:e.getElevation})))}return f}loadMatchingFeature(e,t,i,n,r,o,s,a,l,c,u){const h=this.bucketLayerIDs[t];if(o&&!h.some(e=>o.has(e)))return;const d=this.sourceLayerCoder.decode(i),p=this.vtLayers[d].feature(n);if(r.needGeometry){const e=Oa(p,!0);if(!r.filter(new Mo(this.tileID.overscaledZ),e,this.tileID.canonical))return}else if(!r.filter(new Mo(this.tileID.overscaledZ),p))return;const f=this.getId(p,d);for(let t=0;t{const s=t instanceof No?t.get(o):null;return s&&s.evaluate?s.evaluate(i,n,r):s})}function bp(e,t){return t-e}function wp(e,t,n,r,o){const s=[];for(let a=0;a=r&&u.x>=r||(a.x>=r?a=new i(r,a.y+(r-a.x)/(u.x-a.x)*(u.y-a.y))._round():u.x>=r&&(u=new i(r,a.y+(r-a.x)/(u.x-a.x)*(u.y-a.y))._round()),a.y>=o&&u.y>=o||(a.y>=o?a=new i(a.x+(o-a.y)/(u.y-a.y)*(u.x-a.x),o)._round():u.y>=o&&(u=new i(a.x+(o-a.y)/(u.y-a.y)*(u.x-a.x),o)._round()),c&&a.equals(c[c.length-1])||(c=[a],s.push(c)),c.push(u)))))}}return s}function Tp(e,t,i,n,r){switch(t){case 1:return function(e,t,i,n){const r=[];for(const o of e)for(const e of o){const o=0===n?e.x:e.y;o>=t&&o<=i&&r.push([e])}return r}(e,i,n,r);case 2:return Cp(e,i,n,r,!1);case 3:return Cp(e,i,n,r,!0)}return[]}function Ep(e,t,n,r,o){const s=0===r?Sp:Bp;let a=[];const l=[];for(let i=0;it&&a.push(s(c,u,t)):h>n?d=t&&(a.push(s(c,u,t)),p=!0),d>n&&h<=n&&(a.push(s(c,u,n)),p=!0),!o&&p&&(l.push(a),a=[])}const c=e.length-1,u=0===r?e[c].x:e[c].y;return u>=t&&u<=n&&a.push(e[c]),o&&a.length>0&&!a[0].equals(a[a.length-1])&&a.push(new i(a[0].x,a[0].y)),a.length>0&&l.push(a),l}function Cp(e,t,i,n,r){const o=[];for(const s of e){const e=Ep(s,t,i,n,r);e.length>0&&o.push(...e)}return o}function Sp(e,t,n){return new i(n,e.y+(n-e.x)/(t.x-e.x)*(t.y-e.y))}function Bp(e,t,n){return new i(e.x+(n-e.y)/(t.y-e.y)*(t.x-e.x),n)}lo("FeatureIndex",vp,{omit:["rawTileData","sourceLayerCoder"]});class Ip extends i{constructor(e,t,i,n){super(e,t),this.angle=i,void 0!==n&&(this.segment=n)}clone(){return new Ip(this.x,this.y,this.angle,this.segment)}}function Mp(e,t,i,n,r){if(void 0===t.segment||0===i)return!0;let o=t,s=t.segment+1,a=0;for(;a>-i/2;){if(s--,s<0)return!1;a-=e[s].dist(o),o=e[s]}a+=e[s].dist(e[s+1]),s++;const l=[];let c=0;for(;an;)c-=l.shift().angleDelta;if(c>r)return!1;s++,a+=t.dist(i)}return!0}function Pp(e){let t=0;for(let i=0;ic){const u=(c-l)/o,h=fi.number(n.x,r.x,u),d=fi.number(n.y,r.y,u),p=new Ip(h,d,r.angleTo(n),i);return p._round(),!s||Mp(e,p,a,s,t)?p:void 0}l+=o}}function kp(e,t,i,n,r,o,s,a,l){const c=Rp(n,o,s),u=Lp(n,r),h=u*s,d=0===e[0].x||e[0].x===l||0===e[0].y||e[0].y===l;return t-h=0&&_=0&&A=0&&d+c<=u){const i=new Ip(_,A,m,t);i._round(),n&&!Mp(e,i,o,n,r)||p.push(i)}}h+=f}return a||p.length||s||(p=Dp(e,h/2,i,n,r,o,s,!0,l)),p}function Op(e,t,n,r){const o=[],s=e.image,a=s.pixelRatio,l=s.paddedRect.w-2,c=s.paddedRect.h-2;let u={x1:e.left,y1:e.top,x2:e.right,y2:e.bottom};const h=s.stretchX||[[0,l]],d=s.stretchY||[[0,c]],p=(e,t)=>e+t[1]-t[0],f=h.reduce(p,0),m=d.reduce(p,0),g=l-f,_=c-m;let A=0,y=f,v=0,x=m,b=0,w=g,T=0,E=_;if(s.content&&r){const t=s.content,i=t[2]-t[0],n=t[3]-t[1];(s.textFitWidth||s.textFitHeight)&&(u=qu(e)),A=zp(h,0,t[0]),v=zp(d,0,t[1]),y=zp(h,t[0],t[2]),x=zp(d,t[1],t[3]),b=t[0]-A,T=t[1]-v,w=i-y,E=n-x}const C=u.x1,S=u.y1,B=u.x2-C,I=u.y2-S,M=(e,r,o,l)=>{const c=Np(e.stretch-A,y,B,C),u=Vp(e.fixed-b,w,e.stretch,f),h=Np(r.stretch-v,x,I,S),d=Vp(r.fixed-T,E,r.stretch,m),p=Np(o.stretch-A,y,B,C),g=Vp(o.fixed-b,w,o.stretch,f),_=Np(l.stretch-v,x,I,S),M=Vp(l.fixed-T,E,l.stretch,m),P=new i(c,h),R=new i(p,h),L=new i(p,_),F=new i(c,_),k=new i(u/a,d/a),D=new i(g/a,M/a),O=t*Math.PI/180;if(O){const e=Math.sin(O),t=Math.cos(O),i=[t,-e,e,t];P._matMult(i),R._matMult(i),F._matMult(i),L._matMult(i)}const z=e.stretch+e.fixed,U=r.stretch+r.fixed;return{tl:P,tr:R,bl:F,br:L,tex:{x:s.paddedRect.x+1+z,y:s.paddedRect.y+1+U,w:o.stretch+o.fixed-z,h:l.stretch+l.fixed-U},writingMode:void 0,glyphOffset:[0,0],sectionIndex:0,pixelOffsetTL:k,pixelOffsetBR:D,minFontScaleX:w/a/B,minFontScaleY:E/a/I,isSDF:n}};if(r&&(s.stretchX||s.stretchY)){const e=Up(h,g,f),t=Up(d,_,m);for(let i=0;i0&&(n=Math.max(10,n),this.circleDiameter=n)}else{const c=(null===(h=s.image)||void 0===h?void 0:h.content)&&(s.image.textFitWidth||s.image.textFitHeight)?qu(s):{x1:s.left,y1:s.top,x2:s.right,y2:s.bottom};c.y1=c.y1*a-l[0],c.y2=c.y2*a+l[2],c.x1=c.x1*a-l[3],c.x2=c.x2*a+l[1];const d=s.collisionPadding;if(d&&(c.x1-=d[0]*a,c.y1-=d[1]*a,c.x2+=d[2]*a,c.y2+=d[3]*a),u){const e=new i(c.x1,c.y1),t=new i(c.x2,c.y1),n=new i(c.x1,c.y2),r=new i(c.x2,c.y2),o=u*Math.PI/180;e._rotate(o),t._rotate(o),n._rotate(o),r._rotate(o),c.x1=Math.min(e.x,t.x,n.x,r.x),c.x2=Math.max(e.x,t.x,n.x,r.x),c.y1=Math.min(e.y,t.y,n.y,r.y),c.y2=Math.max(e.y,t.y,n.y,r.y)}e.emplaceBack(t.x,t.y,c.x1,c.y1,c.x2,c.y2,n,r,o)}this.boxEndIndex=e.length}}class Gp{constructor(e=[],t=(e,t)=>et?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=0)break;t[e]=t[n],e=n}t[e]=r}}function Hp(e,t=1,n=!1){const r=Ap.fromPoints(e[0]),o=Math.min(r.width(),r.height());let s=o/2;const a=new Gp([],Qp),{minX:l,minY:c,maxX:u,maxY:h}=r;if(0===o)return new i(l,c);for(let t=l;td.d||!d.d)&&(d=i,n&&console.log("found best %d after %d probes",Math.round(1e4*i.d)/1e4,p)),i.max-d.d<=t||(s=i.h/2,a.push(new $p(i.p.x-s,i.p.y-s,s,e)),a.push(new $p(i.p.x+s,i.p.y-s,s,e)),a.push(new $p(i.p.x-s,i.p.y+s,s,e)),a.push(new $p(i.p.x+s,i.p.y+s,s,e)),p+=4)}return n&&(console.log(`num probes: ${p}`),console.log(`best distance: ${d.d}`)),d.p}function Qp(e,t){return t.max-e.max}function $p(e,t,n,r){this.p=new i(e,t),this.h=n,this.d=function(e,t){let i=!1,n=1/0;for(let r=0;re.y!=a.y>e.y&&e.x<(a.x-r.x)*(e.y-r.y)/(a.y-r.y)+r.x&&(i=!i),n=Math.min(n,Wa(e,r,a))}}return(i?1:-1)*Math.sqrt(n)}(this.p,r),this.max=this.d+this.h*Math.SQRT2}var Zp;e.aO=void 0,(Zp=e.aO||(e.aO={}))[Zp.center=1]="center",Zp[Zp.left=2]="left",Zp[Zp.right=3]="right",Zp[Zp.top=4]="top",Zp[Zp.bottom=5]="bottom",Zp[Zp["top-left"]=6]="top-left",Zp[Zp["top-right"]=7]="top-right",Zp[Zp["bottom-left"]=8]="bottom-left",Zp[Zp["bottom-right"]=9]="bottom-right";const Wp=Number.POSITIVE_INFINITY;function qp(e,t){return t[1]!==Wp?function(e,t,i){let n=0,r=0;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]}(e,t[0],t[1]):function(e,t){let i=0,n=0;t<0&&(t=0);const r=t/Math.SQRT2;switch(e){case"top-right":case"top-left":n=r-7;break;case"bottom-right":case"bottom-left":n=7-r;break;case"bottom":n=7-t;break;case"top":n=t-7}switch(e){case"top-right":case"bottom-right":i=-r;break;case"top-left":case"bottom-left":i=r;break;case"left":i=t;break;case"right":i=-t}return[i,n]}(e,t[0])}function Kp(e,t,i){var n;const r=e.layout,o=null===(n=r.get("text-variable-anchor-offset"))||void 0===n?void 0:n.evaluate(t,{},i);if(o){const e=o.values,t=[];for(let i=0;ie*lu);n.startsWith("top")?r[1]-=7:n.startsWith("bottom")&&(r[1]+=7),t[i+1]=r}return new Dt(t)}const s=r.get("text-variable-anchor");if(s){let n;n=void 0!==e._unevaluatedLayout.getValue("text-radial-offset")?[r.get("text-radial-offset").evaluate(t,{},i)*lu,Wp]:r.get("text-offset").evaluate(t,{},i).map(e=>e*lu);const o=[];for(const e of s)o.push(e,qp(e,n));return new Dt(o)}return null}function Xp(e){switch(e){case"right":case"top-right":case"bottom-right":return"right";case"left":case"top-left":case"bottom-left":return"left"}return"center"}function Jp(t,i,n,r,o,s,a,l,c,u,h,d){let p=s.textMaxSize.evaluate(i,{});void 0===p&&(p=a);const f=t.layers[0].layout,m=f.get("icon-offset").evaluate(i,{},h),g=ef(n.horizontal),_=a/24,A=t.tilePixelRatio*_,y=t.tilePixelRatio*p/24,v=t.tilePixelRatio*l,x=t.tilePixelRatio*f.get("symbol-spacing"),b=f.get("text-padding")*t.tilePixelRatio,w=function(e,t,i,n=1){const r=e.get("icon-padding").evaluate(t,{},i),o=r&&r.values;return[o[0]*n,o[1]*n,o[2]*n,o[3]*n]}(f,i,h,t.tilePixelRatio),T=f.get("text-max-angle")/180*Math.PI,E="viewport"!==f.get("text-rotation-alignment")&&"point"!==f.get("symbol-placement"),C="map"===f.get("icon-rotation-alignment")&&"point"!==f.get("symbol-placement"),S=f.get("symbol-placement"),B=x/2,M=f.get("icon-text-fit");let P;r&&"none"!==M&&(t.allowVerticalPlacement&&n.vertical&&(P=Ku(r,n.vertical,M,f.get("icon-text-fit-padding"),m,_)),g&&(r=Ku(r,g,M,f.get("icon-text-fit-padding"),m,_)));const R=h?d.line.getGranularityForZoomLevel(h.z):1,L=(l,d)=>{d.x<0||d.x>=I||d.y<0||d.y>=I||function(t,i,n,r,o,s,a,l,c,u,h,d,p,f,m,g,_,A,y,v,x,b,w,T,E){const C=t.addToLineVertexArray(i,n);let S,B,I,M,P=0,R=0,L=0,F=0,k=-1,D=-1;const O={};let z=da("");if(t.allowVerticalPlacement&&r.vertical){const e=l.layout.get("text-rotate").evaluate(x,{},T)+90;I=new jp(c,i,u,h,d,r.vertical,p,f,m,e),a&&(M=new jp(c,i,u,h,d,a,_,A,m,e))}if(o){const n=l.layout.get("icon-rotate").evaluate(x,{}),r="none"!==l.layout.get("icon-text-fit"),s=Op(o,n,w,r),p=a?Op(a,n,w,r):void 0;B=new jp(c,i,u,h,d,o,_,A,!1,n),P=4*s.length;const f=t.iconSizeData;let m=null;"source"===f.kind?(m=[Xu*l.layout.get("icon-size").evaluate(x,{})],m[0]>Ju&&H(`${t.layerIds[0]}: Value for "icon-size" is >= 255. Reduce your "icon-size".`)):"composite"===f.kind&&(m=[Xu*b.compositeIconSizes[0].evaluate(x,{},T),Xu*b.compositeIconSizes[1].evaluate(x,{},T)],(m[0]>Ju||m[1]>Ju)&&H(`${t.layerIds[0]}: Value for "icon-size" is >= 255. Reduce your "icon-size".`)),t.addSymbols(t.icon,s,m,v,y,x,e.ay.none,i,C.lineStartIndex,C.lineLength,-1,T),k=t.icon.placedSymbolArray.length-1,p&&(R=4*p.length,t.addSymbols(t.icon,p,m,v,y,x,e.ay.vertical,i,C.lineStartIndex,C.lineLength,-1,T),D=t.icon.placedSymbolArray.length-1)}const U=Object.keys(r.horizontal);for(const n of U){const o=r.horizontal[n];if(!S){z=da(o.text);const e=l.layout.get("text-rotate").evaluate(x,{},T);S=new jp(c,i,u,h,d,o,p,f,m,e)}const a=1===o.positionedLines.length;if(L+=Yp(t,i,o,s,l,m,x,g,C,r.vertical?e.ay.horizontal:e.ay.horizontalOnly,a?U:[n],O,k,b,T),a)break}r.vertical&&(F+=Yp(t,i,r.vertical,s,l,m,x,g,C,e.ay.vertical,["vertical"],O,D,b,T));const N=S?S.boxStartIndex:t.collisionBoxArray.length,V=S?S.boxEndIndex:t.collisionBoxArray.length,j=I?I.boxStartIndex:t.collisionBoxArray.length,G=I?I.boxEndIndex:t.collisionBoxArray.length,Q=B?B.boxStartIndex:t.collisionBoxArray.length,$=B?B.boxEndIndex:t.collisionBoxArray.length,Z=M?M.boxStartIndex:t.collisionBoxArray.length,W=M?M.boxEndIndex:t.collisionBoxArray.length;let q=-1;const K=(e,t)=>e&&e.circleDiameter?Math.max(e.circleDiameter,t):t;q=K(S,q),q=K(I,q),q=K(B,q),q=K(M,q);const X=q>-1?1:0;X&&(q*=E/lu),t.glyphOffsetArray.length>=ah.MAX_GLYPHS&&H("Too many glyphs being rendered in a tile. See https://github.com/mapbox/mapbox-gl-js/issues/2907"),void 0!==x.sortKey&&t.addToSortKeyRanges(t.symbolInstances.length,x.sortKey);const J=Kp(l,x,T),[Y,ee]=function(t,i){const n=t.length,r=null==i?void 0:i.values;if((null==r?void 0:r.length)>0)for(let i=0;i=0?O.right:-1,O.center>=0?O.center:-1,O.left>=0?O.left:-1,O.vertical||-1,k,D,z,N,V,j,G,Q,$,Z,W,u,L,F,P,R,X,0,p,q,Y,ee)}(t,d,l,n,r,o,P,t.layers[0],t.collisionBoxArray,i.index,i.sourceLayerIndex,t.index,A,[b,b,b,b],E,c,v,w,C,m,i,s,u,h,a)};if("line"===S)for(const e of wp(i.geometry,0,0,I,I)){const i=dc(e,R),o=kp(i,x,T,n.vertical||g,r,24,y,t.overscaling,I);for(const e of o)g&&tf(t,g.text,B,e)||L(i,e)}else if("line-center"===S){for(const e of i.geometry)if(e.length>1){const t=dc(e,R),i=Fp(t,T,n.vertical||g,r,24,y);i&&L(t,i)}}else if("Polygon"===i.type)for(const e of Yi(i.geometry,0)){const t=Hp(e,16);L(dc(e[0],R,!0),new Ip(t.x,t.y,0))}else if("LineString"===i.type)for(const e of i.geometry){const t=dc(e,R);L(t,new Ip(t[0].x,t[0].y,0))}else if("Point"===i.type)for(const e of i.geometry)for(const t of e)L([t],new Ip(t.x,t.y,0))}function Yp(e,t,n,r,o,s,a,l,c,u,h,d,p,f,m){const g=function(e,t,n,r,o,s,a,l){const c=r.layout.get("text-rotate").evaluate(s,{})*Math.PI/180,u=[];for(const e of t.positionedLines)for(const r of e.positionedGlyphs){if(!r.rect)continue;const s=r.rect||{};let h=4,d=!0,p=1,f=0;const m=(o||l)&&r.vertical,g=r.metrics.advance*r.scale/2;if(l&&t.verticalizable&&(f=e.lineOffset/2-(r.imageName?-(lu-r.metrics.width*r.scale)/2:(r.scale-1)*lu)),r.imageName){const e=a[r.imageName];d=e.sdf,p=e.pixelRatio,h=1/p}const _=o?[r.x+g,r.y]:[0,0];let A=o?[0,0]:[r.x+g+n[0],r.y+n[1]-f],y=[0,0];m&&(y=A,A=[0,0]);const v=r.metrics.isDoubleResolution?2:1,x=(r.metrics.left-h)*r.scale-g+A[0],b=(-r.metrics.top-h)*r.scale+A[1],w=x+s.w/v*r.scale/p,T=b+s.h/v*r.scale/p,E=new i(x,b),C=new i(w,b),S=new i(x,T),B=new i(w,T);if(m){const e=new i(-g,g- -17),t=-Math.PI/2,n=12-g,o=new i(22-n,-(r.imageName?n:0)),s=new i(...y);E._rotateAround(t,e)._add(o)._add(s),C._rotateAround(t,e)._add(o)._add(s),S._rotateAround(t,e)._add(o)._add(s),B._rotateAround(t,e)._add(o)._add(s)}if(c){const e=Math.sin(c),t=Math.cos(c),i=[t,-e,e,t];E._matMult(i),C._matMult(i),S._matMult(i),B._matMult(i)}const I=new i(0,0),M=new i(0,0);u.push({tl:E,tr:C,bl:S,br:B,tex:s,writingMode:t.writingMode,glyphOffset:_,sectionIndex:r.sectionIndex,isSDF:d,pixelOffsetTL:I,pixelOffsetBR:M,minFontScaleX:0,minFontScaleY:0})}return u}(0,n,l,o,s,a,r,e.allowVerticalPlacement),_=e.textSizeData;let A=null;"source"===_.kind?(A=[Xu*o.layout.get("text-size").evaluate(a,{})],A[0]>Ju&&H(`${e.layerIds[0]}: Value for "text-size" is >= 255. Reduce your "text-size".`)):"composite"===_.kind&&(A=[Xu*f.compositeTextSizes[0].evaluate(a,{},m),Xu*f.compositeTextSizes[1].evaluate(a,{},m)],(A[0]>Ju||A[1]>Ju)&&H(`${e.layerIds[0]}: Value for "text-size" is >= 255. Reduce your "text-size".`)),e.addSymbols(e.text,g,A,l,s,a,u,t,c.lineStartIndex,c.lineLength,p,m);for(const t of h)d[t]=e.text.placedSymbolArray.length-1;return 4*g.length}function ef(e){for(const t in e)return e[t];return null}function tf(e,t,i,n){const r=e.compareText;if(t in r){const e=r[t];for(let t=e.length-1;t>=0;t--)if(n.dist(e[t])>4;if(1!==n)throw new Error(`Got v${n} data when expected v1.`);const r=nf[15&i];if(!r)throw new Error("Unrecognized array type.");const[o]=new Uint16Array(e,2,1),[s]=new Uint32Array(e,4,1);return new rf(s,o,r,e)}constructor(e,t=64,i=Float64Array,n){if(isNaN(e)||e<0)throw new Error(`Unpexpected numItems value: ${e}.`);this.numItems=+e,this.nodeSize=Math.min(Math.max(+t,2),65535),this.ArrayType=i,this.IndexArrayType=e<65536?Uint16Array:Uint32Array;const r=nf.indexOf(this.ArrayType),o=2*e*this.ArrayType.BYTES_PER_ELEMENT,s=e*this.IndexArrayType.BYTES_PER_ELEMENT,a=(8-s%8)%8;if(r<0)throw new Error(`Unexpected typed array class: ${i}.`);n&&n instanceof ArrayBuffer?(this.data=n,this.ids=new this.IndexArrayType(this.data,8,e),this.coords=new this.ArrayType(this.data,8+s+a,2*e),this._pos=2*e,this._finished=!0):(this.data=new ArrayBuffer(8+o+s+a),this.ids=new this.IndexArrayType(this.data,8,e),this.coords=new this.ArrayType(this.data,8+s+a,2*e),this._pos=0,this._finished=!1,new Uint8Array(this.data,0,2).set([219,16+r]),new Uint16Array(this.data,2,1)[0]=t,new Uint32Array(this.data,4,1)[0]=e)}add(e,t){const i=this._pos>>1;return this.ids[i]=i,this.coords[this._pos++]=e,this.coords[this._pos++]=t,i}finish(){const e=this._pos>>1;if(e!==this.numItems)throw new Error(`Added ${e} items when expected ${this.numItems}.`);return of(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:s}=this,a=[0,r.length-1,0],l=[];for(;a.length;){const c=a.pop()||0,u=a.pop()||0,h=a.pop()||0;if(u-h<=s){for(let s=h;s<=u;s++){const a=o[2*s],c=o[2*s+1];a>=e&&a<=i&&c>=t&&c<=n&&l.push(r[s])}continue}const d=h+u>>1,p=o[2*d],f=o[2*d+1];p>=e&&p<=i&&f>=t&&f<=n&&l.push(r[d]),(0===c?e<=p:t<=f)&&(a.push(h),a.push(d-1),a.push(1-c)),(0===c?i>=p:n>=f)&&(a.push(d+1),a.push(u),a.push(1-c))}return l}within(e,t,i){if(!this._finished)throw new Error("Data not yet indexed - call index.finish().");const{ids:n,coords:r,nodeSize:o}=this,s=[0,n.length-1,0],a=[],l=i*i;for(;s.length;){const c=s.pop()||0,u=s.pop()||0,h=s.pop()||0;if(u-h<=o){for(let i=h;i<=u;i++)cf(r[2*i],r[2*i+1],e,t)<=l&&a.push(n[i]);continue}const d=h+u>>1,p=r[2*d],f=r[2*d+1];cf(p,f,e,t)<=l&&a.push(n[d]),(0===c?e-i<=p:t-i<=f)&&(s.push(h),s.push(d-1),s.push(1-c)),(0===c?e+i>=p:t+i>=f)&&(s.push(d+1),s.push(u),s.push(1-c))}return a}}function of(e,t,i,n,r,o){if(r-n<=i)return;const s=n+r>>1;sf(e,t,s,n,r,o),of(e,t,i,n,s-1,1-o),of(e,t,i,s+1,r,1-o)}function sf(e,t,i,n,r,o){for(;r>n;){if(r-n>600){const s=r-n+1,a=i-n+1,l=Math.log(s),c=.5*Math.exp(2*l/3),u=.5*Math.sqrt(l*c*(s-c)/s)*(a-s/2<0?-1:1);sf(e,t,i,Math.max(n,Math.floor(i-a*c/s+u)),Math.min(r,Math.floor(i+(s-a)*c/s+u)),o)}const s=t[2*i+o];let a=n,l=r;for(af(e,t,n,i),t[2*r+o]>s&&af(e,t,n,r);as;)l--}t[2*n+o]===s?af(e,t,n,l):(l++,af(e,t,l,r)),l<=i&&(n=l+1),i<=l&&(r=l-1)}}function af(e,t,i,n){lf(e,i,n),lf(t,2*i,2*n),lf(t,2*i+1,2*n+1)}function lf(e,t,i){const n=e[t];e[t]=e[i],e[i]=n}function cf(e,t,i,n){const r=e-i,o=t-n;return r*r+o*o}var uf;e.cG=void 0,(uf=e.cG||(e.cG={})).create="create",uf.load="load",uf.fullLoad="fullLoad";let hf=null,df=[];const pf=1e3/60,ff="loadTime",mf="fullLoadTime",gf={mark(e){performance.mark(e)},frame(e){const t=e;null!=hf&&df.push(t-hf),hf=t},clearMetrics(){hf=null,df=[],performance.clearMeasures(ff),performance.clearMeasures(mf);for(const t in e.cG)performance.clearMarks(e.cG[t])},getPerformanceMetrics(){performance.measure(ff,e.cG.create,e.cG.load),performance.measure(mf,e.cG.create,e.cG.fullLoad);const t=performance.getEntriesByName(ff)[0].duration,i=performance.getEntriesByName(mf)[0].duration,n=df.length,r=1/(df.reduce((e,t)=>e+t,0)/n/1e3),o=df.filter(e=>e>pf).reduce((e,t)=>e+(t-pf)/pf,0);return{loadTime:t,fullLoadTime:i,fps:r,percentDroppedFrames:o/(n+o)*100,totalFrames:n}}};e.$=h,e.A=p,e.B=oo,e.C=eo,e.D=Vo,e.E=_e,e.F=function([e,t,i]){return t+=90,t*=Math.PI/180,i*=Math.PI/180,{x:e*Math.cos(t)*Math.sin(i),y:e*Math.sin(t)*Math.sin(i),z:e*Math.cos(i)}},e.G=fi,e.H=Mo,e.I=Ou,e.J=io,e.K=function(e){if(null==Z){const t=e.navigator?e.navigator.userAgent:null;Z=!!e.safari||!(!t||!(/\b(iPad|iPhone|iPod)\b/.test(t)||t.match("Safari")&&!t.match("Chrome")))}return Z},e.L=class{constructor(e,t){this.target=e,this.mapId=t,this.resolveRejects={},this.tasks={},this.taskQueue=[],this.abortControllers={},this.messageHandlers={},this.invoker=new _h(()=>this.process()),this.subscription=Y(this.target,"message",e=>this.receive(e),!1),this.globalScope=$(self)?e:window}registerMessageHandler(e,t){this.messageHandlers[e]=t}unregisterMessageHandler(e){delete this.messageHandlers[e]}sendAsync(e,t){return new Promise((i,n)=>{const r=Math.round(1e18*Math.random()).toString(36).substring(0,10),o=t?Y(t.signal,"abort",()=>{null==o||o.unsubscribe(),delete this.resolveRejects[r];const t={id:r,type:"",origin:location.origin,targetMapId:e.targetMapId,sourceMapId:this.mapId};this.target.postMessage(t)},Ah):null;this.resolveRejects[r]={resolve:e=>{null==o||o.unsubscribe(),i(e)},reject:e=>{null==o||o.unsubscribe(),n(e)}};const s=[],a=Object.assign(Object.assign({},e),{id:r,sourceMapId:this.mapId,origin:location.origin,data:po(e.data,s)});this.target.postMessage(a,{transfer:s})})}receive(e){const t=e.data,i=t.id;if(!("file://"!==t.origin&&"file://"!==location.origin&&"resource://android"!==t.origin&&"resource://android"!==location.origin&&t.origin!==location.origin||t.targetMapId&&this.mapId!==t.targetMapId)){if(""===t.type){delete this.tasks[i];const e=this.abortControllers[i];return delete this.abortControllers[i],void(e&&e.abort())}if($(self)||t.mustQueue)return this.tasks[i]=t,this.taskQueue.push(i),void this.invoker.trigger();this.processTask(i,t)}}process(){if(0===this.taskQueue.length)return;const e=this.taskQueue.shift(),t=this.tasks[e];delete this.tasks[e],this.taskQueue.length>0&&this.invoker.trigger(),t&&this.processTask(e,t)}processTask(e,i){return t(this,void 0,void 0,function*(){if(""===i.type){const t=this.resolveRejects[e];if(delete this.resolveRejects[e],!t)return;return void(i.error?t.reject(fo(i.error)):t.resolve(fo(i.data)))}if(!this.messageHandlers[i.type])return void this.completeTask(e,new Error(`Could not find a registered handler for ${i.type}, map ID: ${this.mapId}, available handlers: ${Object.keys(this.messageHandlers).join(", ")}`));const t=fo(i.data),n=new AbortController;this.abortControllers[e]=n;try{const r=yield this.messageHandlers[i.type](i.sourceMapId,t,n);this.completeTask(e,null,r)}catch(t){this.completeTask(e,t)}})}completeTask(e,t,i){const n=[];delete this.abortControllers[e];const r={id:e,type:"",sourceMapId:this.mapId,origin:location.origin,error:t?po(t):null,data:po(i,n)};this.target.postMessage(r,{transfer:n})}remove(){this.invoker.remove(),this.subscription.unsubscribe()}},e.M=le,e.N=function(){var e=new p(16);return p!=Float32Array&&(e[1]=0,e[2]=0,e[3]=0,e[4]=0,e[6]=0,e[7]=0,e[8]=0,e[9]=0,e[11]=0,e[12]=0,e[13]=0,e[14]=0),e[0]=1,e[5]=1,e[10]=1,e[15]=1,e},e.O=function(e,t,i){var n,r,o,s,a,l,c,u,h,d,p,f,m=i[0],g=i[1],_=i[2];return t===e?(e[12]=t[0]*m+t[4]*g+t[8]*_+t[12],e[13]=t[1]*m+t[5]*g+t[9]*_+t[13],e[14]=t[2]*m+t[6]*g+t[10]*_+t[14],e[15]=t[3]*m+t[7]*g+t[11]*_+t[15]):(r=t[1],o=t[2],s=t[3],a=t[4],l=t[5],c=t[6],u=t[7],h=t[8],d=t[9],p=t[10],f=t[11],e[0]=n=t[0],e[1]=r,e[2]=o,e[3]=s,e[4]=a,e[5]=l,e[6]=c,e[7]=u,e[8]=h,e[9]=d,e[10]=p,e[11]=f,e[12]=n*m+a*g+h*_+t[12],e[13]=r*m+l*g+d*_+t[13],e[14]=o*m+c*g+p*_+t[14],e[15]=s*m+u*g+f*_+t[15]),e},e.P=i,e.Q=function(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},e.R=Al,e.S=function(e,t,i){var n=t[0],r=t[1],o=t[2],s=t[3],a=t[4],l=t[5],c=t[6],u=t[7],h=t[8],d=t[9],p=t[10],f=t[11],m=t[12],g=t[13],_=t[14],A=t[15],y=i[0],v=i[1],x=i[2],b=i[3];return e[0]=y*n+v*a+x*h+b*m,e[1]=y*r+v*l+x*d+b*g,e[2]=y*o+v*c+x*p+b*_,e[3]=y*s+v*u+x*f+b*A,e[4]=(y=i[4])*n+(v=i[5])*a+(x=i[6])*h+(b=i[7])*m,e[5]=y*r+v*l+x*d+b*g,e[6]=y*o+v*c+x*p+b*_,e[7]=y*s+v*u+x*f+b*A,e[8]=(y=i[8])*n+(v=i[9])*a+(x=i[10])*h+(b=i[11])*m,e[9]=y*r+v*l+x*d+b*g,e[10]=y*o+v*c+x*p+b*_,e[11]=y*s+v*u+x*f+b*A,e[12]=(y=i[12])*n+(v=i[13])*a+(x=i[14])*h+(b=i[15])*m,e[13]=y*r+v*l+x*d+b*g,e[14]=y*o+v*c+x*p+b*_,e[15]=y*s+v*u+x*f+b*A,e},e.T=Sl,e.U=function(e,t){const i={};for(let n=0;n0||(null===(r=i.addOrUpdateProperties)||void 0===r?void 0:r.length)>0;if((o||s)&&(t=Object.assign({},t),e.set(i.id,t),o&&(t.geometry=i.newGeometry),s)){if(t.properties=i.removeAllProperties?{}:Object.assign({},t.properties||{}),i.removeProperties)for(const e of i.removeProperties)delete t.properties[e];if(i.addOrUpdateProperties)for(const{key:e,value:n}of i.addOrUpdateProperties)t.properties[e]=n}}},e.a9=yp,e.aA=function(e,t){var i=t[0],n=t[1],r=t[2],o=t[3],s=t[4],a=t[5],l=t[6],c=t[7],u=t[8],h=t[9],d=t[10],p=t[11],f=t[12],m=t[13],g=t[14],_=t[15],A=i*a-n*s,y=i*l-r*s,v=i*c-o*s,x=n*l-r*a,b=n*c-o*a,w=r*c-o*l,T=u*m-h*f,E=u*g-d*f,C=u*_-p*f,S=h*g-d*m,B=h*_-p*m,I=d*_-p*g,M=A*I-y*B+v*S+x*C-b*E+w*T;return M?(e[0]=(a*I-l*B+c*S)*(M=1/M),e[1]=(r*B-n*I-o*S)*M,e[2]=(m*w-g*b+_*x)*M,e[3]=(d*b-h*w-p*x)*M,e[4]=(l*C-s*I-c*E)*M,e[5]=(i*I-r*C+o*E)*M,e[6]=(g*v-f*w-_*y)*M,e[7]=(u*w-d*v+p*y)*M,e[8]=(s*B-a*C+c*T)*M,e[9]=(n*C-i*B-o*T)*M,e[10]=(f*b-m*v+_*A)*M,e[11]=(h*v-u*b-p*A)*M,e[12]=(a*E-s*S-l*T)*M,e[13]=(i*S-n*E+r*T)*M,e[14]=(m*y-f*x-g*A)*M,e[15]=(u*x-h*y+d*A)*M,e):null},e.aB=S,e.aC=function(e){var t=e[0],i=e[1];return Math.sqrt(t*t+i*i)},e.aD=function(e){return e[0]=0,e[1]=0,e},e.aE=function(e,t,i){return e[0]=t[0]*i,e[1]=t[1]*i,e},e.aF=nh,e.aG=T,e.aH=function(e,t,n,r){const o=t.y-e.y,s=t.x-e.x,a=r.y-n.y,l=r.x-n.x,c=a*s-l*o;if(0===c)return null;const u=(l*(e.y-n.y)-a*(e.x-n.x))/c;return new i(e.x+u*s,e.y+u*o)},e.aI=wp,e.aJ=Va,e.aK=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[t,i,n,r]},e.aL=lu,e.aM=M,e.aN=function(e,t,i,n,r=!1){if(!i[0]&&!i[1])return[0,0];const o=r?"map"===n?-e.bearingInRadians:0:"viewport"===n?e.bearingInRadians:0;if(o){const e=Math.sin(o),t=Math.cos(o);i=[i[0]*t-i[1]*e,i[0]*e+i[1]*t]}return[r?i[0]:M(t,i[0],e.zoom),r?i[1]:M(t,i[1],e.zoom)]},e.aP=eh,e.aQ=Xp,e.aR=Vu,e.aS=rf,e.aT=es,e.aU=ac,e.aV=zs,e.aW=ta,e.aX=Xs,e.aY=te,e.aZ=Bh,e.a_=v,e.aa=Ih,e.ab=Ap,e.ac=25,e.ad=Ph,e.ae=e=>{const t=window.document.createElement("video");return t.muted=!0,new Promise(i=>{t.onloadstart=()=>{i(t)};for(const i of e){const e=window.document.createElement("source");de(i)||(t.crossOrigin="Anonymous"),e.src=i,t.appendChild(e)}})},e.af=Me,e.ag=function(){return U++},e.ah=Ss,e.ai=ah,e.aj=dr,e.ak=Oa,e.al=Uh,e.am=function(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},e.an=D,e.ao=85.051129,e.ap=ee,e.aq=function(e){return Math.pow(2,e)},e.ar=m,e.as=Eh,e.at=function(e){return Math.log(e)/Math.LN2},e.au=function(e){var t=e[0],i=e[1];return t*t+i*i},e.av=class{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 n=e.wrapped().key;void 0===this.data[n]&&(this.data[n]=[]);const r={value:t,timeout:void 0};if(void 0!==i&&(r.timeout=setTimeout(()=>{this.remove(e,r)},i)),this.data[n].push(r),this.order.push(n),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,n=void 0===t?0:this.data[i].indexOf(t),r=this.data[i][n];return this.data[i].splice(n,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 n of this.data[i])e(n.value)||t.push(n);for(const e of t)this.remove(e.value.tileID,e)}},e.aw=function(e){if(!e.length)return new Set;const t=Math.max(...e.map(e=>e.canonical.z));let i=1/0,n=-1/0,r=1/0,o=-1/0;const s=[];for(const a of e){const{x:e,y:l,z:c}=a.canonical,u=Math.pow(2,t-c),h=e*u,d=l*u;s.push({id:a,x:h,y:d}),hn&&(n=h),do&&(o=d)}const a=new Set;for(const e of s)e.x!==i&&e.x!==n&&e.y!==r&&e.y!==o||a.add(e.id);return a},e.ax=function(e,t){let i=0,n=0;if("constant"===e.kind)n=e.layoutSize;else if("source"!==e.kind){const{interpolationType:r,minZoom:o,maxZoom:s}=e,a=r?D(di.interpolationFactor(r,t,o,s),0,1):0;"camera"===e.kind?n=fi.number(e.minSize,e.maxSize,a):i=a}return{uSizeT:i,uSize:n}},e.az=function(e,{uSize:t,uSizeT:i},{lowerSize:n,upperSize:r}){return"source"===e.kind?n/Xu:"composite"===e.kind?fi.number(n/Xu,r/Xu,i):t},e.b=W,e.b$=class extends _a{constructor(e,t){super(e,t),this.current=xa}set(e){if(e[12]!==this.current[12]||e[0]!==this.current[0])return this.current=e,void this.gl.uniformMatrix4fv(this.location,!1,e);for(let t=1;t<16;t++)if(e[t]!==this.current[t]){this.current=e,this.gl.uniformMatrix4fv(this.location,!1,e);break}}},e.b0=function(e){var t=new p(3);return t[0]=e[0],t[1]=e[1],t[2]=e[2],t},e.b1=function(e,t,i){return e[0]=t[0]-i[0],e[1]=t[1]-i[1],e[2]=t[2]-i[2],e},e.b2=function(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},e.b3=x,e.b4=function(e,t){return e[0]*t[0]+e[1]*t[1]+e[2]*t[2]},e.b5=function(e,t,i){return e[0]=t[0]*i[0],e[1]=t[1]*i[1],e[2]=t[2]*i[2],e[3]=t[3]*i[3],e},e.b6=_,e.b7=function(e,t,i){const n=t[0]*i[0]+t[1]*i[1]+t[2]*i[2];return 0===n?null:(-(e[0]*i[0]+e[1]*i[1]+e[2]*i[2])-i[3])/n},e.b8=w,e.b9=function(e,t,i){return e[0]=t[0]*i,e[1]=t[1]*i,e[2]=t[2]*i,e[3]=t[3]*i,e},e.bA=C,e.bB=function(e,t,i){var n=i[0],r=i[1],o=i[2],s=i[3],a=t[0],l=t[1],c=t[2],u=r*c-o*l,h=o*a-n*c,d=n*l-r*a;return e[0]=a+s*(u+=u)+r*(d+=d)-o*(h+=h),e[1]=l+s*h+o*u-n*d,e[2]=c+s*d+n*h-r*u,e},e.bC=function(e,t,i){const n=(r=[e[0],e[1],e[2],t[0],t[1],t[2],i[0],i[1],i[2]])[0]*((u=r[8])*(s=r[4])-(a=r[5])*(c=r[7]))+r[1]*(-u*(o=r[3])+a*(l=r[6]))+r[2]*(c*o-s*l);var r,o,s,a,l,c,u;if(0===n)return null;const h=x([],[t[0],t[1],t[2]],[i[0],i[1],i[2]]),d=x([],[i[0],i[1],i[2]],[e[0],e[1],e[2]]),p=x([],[e[0],e[1],e[2]],[t[0],t[1],t[2]]),f=v([],h,-e[3]);return y(f,f,v([],d,-t[3])),y(f,f,v([],p,-i[3])),v(f,f,1/n),f},e.bD=yh,e.bE=function(){return new Float64Array(4)},e.bF=function(e,t,i,n){var r=[],o=[];return r[0]=t[0]-i[0],r[1]=t[1]-i[1],r[2]=t[2]-i[2],o[0]=r[0]*Math.cos(n)-r[1]*Math.sin(n),o[1]=r[0]*Math.sin(n)+r[1]*Math.cos(n),o[2]=r[2],e[0]=o[0]+i[0],e[1]=o[1]+i[1],e[2]=o[2]+i[2],e},e.bG=function(e,t,i,n){var r=[],o=[];return r[0]=t[0]-i[0],r[1]=t[1]-i[1],r[2]=t[2]-i[2],o[0]=r[0],o[1]=r[1]*Math.cos(n)-r[2]*Math.sin(n),o[2]=r[1]*Math.sin(n)+r[2]*Math.cos(n),e[0]=o[0]+i[0],e[1]=o[1]+i[1],e[2]=o[2]+i[2],e},e.bH=function(e,t,i,n){var r=[],o=[];return r[0]=t[0]-i[0],r[1]=t[1]-i[1],r[2]=t[2]-i[2],o[0]=r[2]*Math.sin(n)+r[0]*Math.cos(n),o[1]=r[1],o[2]=r[2]*Math.cos(n)-r[0]*Math.sin(n),e[0]=o[0]+i[0],e[1]=o[1]+i[1],e[2]=o[2]+i[2],e},e.bI=function(e,t,i){var n=Math.sin(i),r=Math.cos(i),o=t[0],s=t[1],a=t[2],l=t[3],c=t[8],u=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-c*n,e[1]=s*r-u*n,e[2]=a*r-h*n,e[3]=l*r-d*n,e[8]=o*n+c*r,e[9]=s*n+u*r,e[10]=a*n+h*r,e[11]=l*n+d*r,e},e.bJ=function(e,t){const i=P(e,360),n=P(t,360),r=n-i,o=n>i?r-360:r+360;return Math.abs(r)0?s:-s},e.bM=function(e,t){const i=P(e,2*Math.PI),n=P(t,2*Math.PI);return Math.min(Math.abs(i-n),Math.abs(i-n+2*Math.PI),Math.abs(i-n-2*Math.PI))},e.bN=function(){const e={},t=Ae.$version;for(const i in Ae.$root){const n=Ae.$root[i];if(n.required){let r=null;r="version"===i?t:"array"===n.type?[]:{},null!=r&&(e[i]=r)}}return e},e.bO=ue,e.bP=mo,e.bQ=function e(t,i){if(Array.isArray(t)){if(!Array.isArray(i)||t.length!==i.length)return!1;for(let n=0;n"raster"===e.type,e.bU=j,e.bV=function(e,t){if(!e)return[{command:"setStyle",args:[t]}];let i=[];try{if(!xe(e.version,t.version))return[{command:"setStyle",args:[t]}];xe(e.center,t.center)||i.push({command:"setCenter",args:[t.center]}),xe(e.state,t.state)||i.push({command:"setGlobalState",args:[t.state]}),xe(e.centerAltitude,t.centerAltitude)||i.push({command:"setCenterAltitude",args:[t.centerAltitude]}),xe(e.zoom,t.zoom)||i.push({command:"setZoom",args:[t.zoom]}),xe(e.bearing,t.bearing)||i.push({command:"setBearing",args:[t.bearing]}),xe(e.pitch,t.pitch)||i.push({command:"setPitch",args:[t.pitch]}),xe(e.roll,t.roll)||i.push({command:"setRoll",args:[t.roll]}),xe(e.sprite,t.sprite)||i.push({command:"setSprite",args:[t.sprite]}),xe(e.glyphs,t.glyphs)||i.push({command:"setGlyphs",args:[t.glyphs]}),xe(e.transition,t.transition)||i.push({command:"setTransition",args:[t.transition]}),xe(e.light,t.light)||i.push({command:"setLight",args:[t.light]}),xe(e.terrain,t.terrain)||i.push({command:"setTerrain",args:[t.terrain]}),xe(e.sky,t.sky)||i.push({command:"setSky",args:[t.sky]}),xe(e.projection,t.projection)||i.push({command:"setProjection",args:[t.projection]});const n={},r=[];!function(e,t,i,n){let r;for(r in t=t||{},e=e||{})Object.prototype.hasOwnProperty.call(e,r)&&(Object.prototype.hasOwnProperty.call(t,r)||Te(r,i,n));for(r in t)Object.prototype.hasOwnProperty.call(t,r)&&(Object.prototype.hasOwnProperty.call(e,r)?xe(e[r],t[r])||("geojson"===e[r].type&&"geojson"===t[r].type&&Ce(e,t,r)?be(i,{command:"setGeoJSONSourceData",args:[r,t[r].data]}):Ee(r,t,i,n)):we(r,t,i))}(e.sources,t.sources,r,n);const o=[];e.layers&&e.layers.forEach(e=>{"source"in e&&n[e.source]?i.push({command:"removeLayer",args:[e.id]}):o.push(e)}),i=i.concat(r),function(e,t,i){t=t||[];const n=(e=e||[]).map(Be),r=t.map(Be),o=e.reduce(Ie,{}),s=t.reduce(Ie,{}),a=n.slice(),l=Object.create(null);let c,u,h,d,p;for(let e=0,t=0;ed?(r=Math.acos(o),s=Math.sin(r),a=Math.sin((1-n)*r)/s,l=Math.sin(n*r)/s):(a=1-n,l=n),e[0]=a*c+l*f,e[1]=a*u+l*m,e[2]=a*h+l*g,e[3]=a*p+l*_,e},e.bm=function(e){const t=new Float64Array(9);var i,n,r,o,s,a,l,c,u,h,d,p,f,m,g,_,A,y;h=(r=(n=e)[0])*(l=r+r),d=(o=n[1])*l,f=(s=n[2])*l,m=s*(c=o+o),_=(a=n[3])*l,A=a*c,y=a*(u=s+s),(i=t)[0]=1-(p=o*c)-(g=s*u),i[3]=d-y,i[6]=f+A,i[1]=d+y,i[4]=1-h-g,i[7]=m-_,i[2]=f-A,i[5]=m+_,i[8]=1-h-p;const v=te(-Math.asin(D(t[2],-1,1)));let x,b;return Math.hypot(t[5],t[8])<.001?(x=0,b=-te(Math.atan2(t[3],t[4]))):(x=te(0===t[5]&&0===t[8]?0:Math.atan2(t[5],t[8])),b=te(0===t[1]&&0===t[0]?0:Math.atan2(t[1],t[0]))),{roll:x,pitch:v+90,bearing:b}},e.bn=function(e,t){return e.roll==t.roll&&e.pitch==t.pitch&&e.bearing==t.bearing},e.bo=Ct,e.bp=Aa,e.bq=lc,e.br=cc,e.bs=sc,e.bt=R,e.bu=L,e.bv=zt,e.bw=function(e,t,i,n,r){return R(n,r,D((e-t)/(i-t),0,1))},e.bx=P,e.by=function(){return new Float64Array(3)},e.bz=function(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},e.c=oe,e.c$=class{constructor(e){this._marks={start:[e.url,"start"].join("#"),end:[e.url,"end"].join("#"),measure:e.url.toString()},performance.mark(this._marks.start)}finish(){performance.mark(this._marks.end);let e=performance.getEntriesByName(this._marks.measure);return 0===e.length&&(performance.measure(this._marks.measure,this._marks.start,this._marks.end),e=performance.getEntriesByName(this._marks.measure),performance.clearMarks(this._marks.start),performance.clearMarks(this._marks.end),performance.clearMeasures(this._marks.measure)),e}},e.c0=ya,e.c1=class extends _a{constructor(e,t){super(e,t),this.current=[0,0,0]}set(e){e[0]===this.current[0]&&e[1]===this.current[1]&&e[2]===this.current[2]||(this.current=e,this.gl.uniform3f(this.location,e[0],e[1],e[2]))}},e.c2=class extends _a{constructor(e,t){super(e,t),this.current=[0,0]}set(e){e[0]===this.current[0]&&e[1]===this.current[1]||(this.current=e,this.gl.uniform2f(this.location,e[0],e[1]))}},e.c3=f,e.c4=function(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},e.c5=function(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},e.c6=function(e,t,i,n,r,o,s){var a=1/(t-i),l=1/(n-r),c=1/(o-s);return e[0]=-2*a,e[1]=0,e[2]=0,e[3]=0,e[4]=0,e[5]=-2*l,e[6]=0,e[7]=0,e[8]=0,e[9]=0,e[10]=2*c,e[11]=0,e[12]=(t+i)*a,e[13]=(r+n)*l,e[14]=(s+o)*c,e[15]=1,e},e.c7=class extends _a{constructor(e,t){super(e,t),this.current=new Array}set(e){if(e!=this.current){this.current=e;const t=new Float32Array(4*e.length);for(let i=0;i25||n<0||n>=1||i<0||i>=1)},e.cD=function(e,t){return e[0]=t[0],e[1]=0,e[2]=0,e[3]=0,e[4]=0,e[5]=t[1],e[6]=0,e[7]=0,e[8]=0,e[9]=0,e[10]=t[2],e[11]=0,e[12]=0,e[13]=0,e[14]=0,e[15]=1,e},e.cE=class extends ns{},e.cF=gf,e.cH=function(e){return e.message===re},e.cI=ce,e.cJ=function(e,t){se.REGISTERED_PROTOCOLS[e]=t},e.cK=function(e){delete se.REGISTERED_PROTOCOLS[e]},e.cL=function(e,t){const i={};for(let n=0;ne*lu)}let y=a?"center":n.get("text-justify").evaluate(r,{},t.canonical);const v="point"===n.get("symbol-placement")?n.get("text-max-width").evaluate(r,{},t.canonical)*lu:1/0,x=()=>{t.bucket.allowVerticalPlacement&&yo(o)&&(f.vertical=Nu(m,t.glyphMap,t.glyphPositions,t.imagePositions,u,v,s,g,"left",p,_,e.ay.vertical,!0,d,h))};if(!a&&A){const i=new Set;if("auto"===y)for(let e=0;e=this.maxEntries){const e=this.map.keys().next().value;this.map.delete(e)}this.map.set(e,t)}clear(){this.map.clear()}},e.cZ=Ic,e.c_=_p,e.ca=su,e.cb=class extends _s{},e.cc=vl,e.cd=function(e){return e<=1?1:Math.pow(2,Math.ceil(Math.log(e)/Math.LN2))},e.ce=yl,e.cf=function(e,t,i){var n=t[0],r=t[1],o=t[2],s=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])/(s=s||1),e[1]=(i[1]*n+i[5]*r+i[9]*o+i[13])/s,e[2]=(i[2]*n+i[6]*r+i[10]*o+i[14])/s,e},e.cg=class extends rs{},e.ch=class extends Ts{},e.ci=function(e,t){return e[0]===t[0]&&e[1]===t[1]&&e[2]===t[2]&&e[3]===t[3]&&e[4]===t[4]&&e[5]===t[5]&&e[6]===t[6]&&e[7]===t[7]&&e[8]===t[8]&&e[9]===t[9]&&e[10]===t[10]&&e[11]===t[11]&&e[12]===t[12]&&e[13]===t[13]&&e[14]===t[14]&&e[15]===t[15]},e.cj=function(e,t){var i=e[0],n=e[1],r=e[2],o=e[3],s=e[4],a=e[5],l=e[6],c=e[7],u=e[8],h=e[9],p=e[10],f=e[11],m=e[12],g=e[13],_=e[14],A=e[15],y=t[0],v=t[1],x=t[2],b=t[3],w=t[4],T=t[5],E=t[6],C=t[7],S=t[8],B=t[9],I=t[10],M=t[11],P=t[12],R=t[13],L=t[14],F=t[15];return Math.abs(i-y)<=d*Math.max(1,Math.abs(i),Math.abs(y))&&Math.abs(n-v)<=d*Math.max(1,Math.abs(n),Math.abs(v))&&Math.abs(r-x)<=d*Math.max(1,Math.abs(r),Math.abs(x))&&Math.abs(o-b)<=d*Math.max(1,Math.abs(o),Math.abs(b))&&Math.abs(s-w)<=d*Math.max(1,Math.abs(s),Math.abs(w))&&Math.abs(a-T)<=d*Math.max(1,Math.abs(a),Math.abs(T))&&Math.abs(l-E)<=d*Math.max(1,Math.abs(l),Math.abs(E))&&Math.abs(c-C)<=d*Math.max(1,Math.abs(c),Math.abs(C))&&Math.abs(u-S)<=d*Math.max(1,Math.abs(u),Math.abs(S))&&Math.abs(h-B)<=d*Math.max(1,Math.abs(h),Math.abs(B))&&Math.abs(p-I)<=d*Math.max(1,Math.abs(p),Math.abs(I))&&Math.abs(f-M)<=d*Math.max(1,Math.abs(f),Math.abs(M))&&Math.abs(m-P)<=d*Math.max(1,Math.abs(m),Math.abs(P))&&Math.abs(g-R)<=d*Math.max(1,Math.abs(g),Math.abs(R))&&Math.abs(_-L)<=d*Math.max(1,Math.abs(_),Math.abs(L))&&Math.abs(A-F)<=d*Math.max(1,Math.abs(A),Math.abs(F))},e.ck=function(e,t){return e[0]=t[0],e[1]=t[1],e[2]=t[2],e[3]=t[3],e[4]=t[4],e[5]=t[5],e[6]=t[6],e[7]=t[7],e[8]=t[8],e[9]=t[9],e[10]=t[10],e[11]=t[11],e[12]=t[12],e[13]=t[13],e[14]=t[14],e[15]=t[15],e},e.cl=e=>"symbol"===e.type,e.cm=e=>"circle"===e.type,e.cn=e=>"heatmap"===e.type,e.co=e=>"line"===e.type,e.cp=e=>"fill"===e.type,e.cq=e=>"fill-extrusion"===e.type,e.cr=e=>"hillshade"===e.type,e.cs=e=>"color-relief"===e.type,e.ct=e=>"background"===e.type,e.cu=e=>"custom"===e.type,e.cv=F,e.cw=function(e,t,i){const n=B(t.x-i.x,t.y-i.y),r=B(e.x-i.x,e.y-i.y);var o,s;return te(Math.atan2(n[0]*r[1]-n[1]*r[0],(o=n)[0]*(s=r)[0]+o[1]*s[1]))},e.cx=k,e.cy=function(e,t){return ne[t]&&(e instanceof MouseEvent||e instanceof WheelEvent)},e.cz=function(e,t){return ie[t]&&"touches"in e},e.d=de,e.d0=function(e,i,n,r,o){return t(this,void 0,void 0,function*(){if(h())try{return yield K(e,i,n,r,o)}catch(e){}return function(e,t,i,n,r){const o=e.width,s=e.height;X&&J||(X=new OffscreenCanvas(o,s),J=X.getContext("2d",{willReadFrequently:!0})),X.width=o,X.height=s,J.drawImage(e,0,0,o,s);const a=J.getImageData(t,i,n,r);return J.clearRect(0,0,o,s),a.data}(e,i,n,r,o)})},e.d1=Bl,e.d2=n,e.d3=ir,e.d4=Io,e.e=z,e.f=e=>t(void 0,void 0,void 0,function*(){if(0===e.byteLength)return createImageBitmap(new ImageData(1,1));const t=new Blob([new Uint8Array(e)],{type:"image/png"});try{return createImageBitmap(t)}catch(e){throw new Error(`Could not load image because of ${e.message}. Please make sure to use a supported image type such as PNG or JPEG. Note that SVGs are not supported.`)}}),e.g=ae,e.h=e=>new Promise((t,i)=>{const n=new Image;n.onload=()=>{t(n),URL.revokeObjectURL(n.src),n.onload=null,window.requestAnimationFrame(()=>{n.src=q})},n.onerror=()=>i(new Error("Could not load image. Please make sure to use a supported image type such as PNG or JPEG. Note that SVGs are not supported."));const r=new Blob([new Uint8Array(e)],{type:"image/png"});n.src=e.byteLength?URL.createObjectURL(r):q}),e.i=$,e.j=(e,t)=>he(z(e,{type:"json"}),t),e.k=ge,e.l=me,e.m=he,e.n=(e,t)=>he(z(e,{type:"arrayBuffer"}),t),e.o=function(e){return new xu(e).readFields(Lu,[])},e.p=Du,e.q=function(e){return/[\u02EA\u02EB\u1100-\u11FF\u2E80-\u2FDF\u3000-\u30FF\u3105-\u312F\u3131-\u318E\u31A0-\u4DBF\u4E00-\uA48C\uA490-\uA4C6\uA960-\uA97C\uAC00-\uD7C6\uD7CB-\uD7FB\uF900-\uFA6D\uFA70-\uFAD9\uFE10-\uFE1F\uFE30-\uFE4F\uFF00-\uFFEF]|\uD81B[\uDFE0-\uDFFF]|[\uD81C-\uD822\uD840-\uD868\uD86A-\uD86D\uD86F-\uD872\uD874-\uD879\uD880-\uD883\uD885-\uD88C][\uDC00-\uDFFF]|\uD823[\uDC00-\uDCD5\uDCFF-\uDD1E\uDD80-\uDDF2]|\uD82B[\uDFF0-\uDFFF]|\uD82C[\uDC00-\uDEFB]|\uD83C[\uDE00-\uDEFF]|\uD869[\uDC00-\uDEDF\uDF00-\uDFFF]|\uD86E[\uDC00-\uDC1D\uDC20-\uDFFF]|\uD873[\uDC00-\uDEAD\uDEB0-\uDFFF]|\uD87A[\uDC00-\uDFE0\uDFF0-\uDFFF]|\uD87B[\uDC00-\uDE5D]|\uD87E[\uDC00-\uDE1D]|\uD884[\uDC00-\uDF4A\uDF50-\uDFFF]|\uD88D[\uDC00-\uDC79]/gim.test(String.fromCodePoint(e))},e.r=_l,e.s=Y,e.t=$o,e.u=Ae,e.v=Yr,e.w=H,e.x=ko,e.y=to,e.z=Ro}),i("worker",["./shared"],function(e){class t{constructor(e,t){this.keyCache={},e&&this.replace(e,t)}replace(e,t){this._layerConfigs={},this._layers={},this.update(e,[],t)}update(t,i,n){for(const i of t){this._layerConfigs[i.id]=i;const t=this._layers[i.id]=e.bS(i,n);t._featureFilter=e.aj(t.filter,n),this.keyCache[i.id]&&delete this.keyCache[i.id]}for(const e of i)delete this.keyCache[e],delete this._layerConfigs[e],delete this._layers[e];this.familiesBySource={};const r=e.cL(Object.values(this._layerConfigs),this.keyCache);for(const t of r){const i=t.map(e=>this._layers[e.id]),n=i[0];if("none"===n.visibility)continue;const r=n.source||"";let o=this.familiesBySource[r];o||(o=this.familiesBySource[r]={});const s=n.sourceLayer||e.a9;let a=o[s];a||(a=o[s]=[]),a.push(i)}}}class i{constructor(t){const i={},n=[];for(const e in t){const r=t[e],o=i[e]={};for(const e in r){const t=r[+e];if(!t||0===t.bitmap.width||0===t.bitmap.height)continue;const i={x:0,y:0,w:t.bitmap.width+2,h:t.bitmap.height+2};n.push(i),o[e]={rect:i,metrics:t.metrics}}}const{w:r,h:o}=e.p(n),s=new e.r({width:r||1,height:o||1});for(const n in t){const r=t[n];for(const t in r){const o=r[+t];if(!o||0===o.bitmap.width||0===o.bitmap.height)continue;const a=i[n][t].rect;e.r.copy(o.bitmap,s,{x:0,y:0},{x:a.x+1,y:a.y+1},o.bitmap)}}this.image=s,this.positions=i}}e.cM("GlyphAtlas",i);class n{constructor(t){this.tileID=new e.a1(t.tileID.overscaledZ,t.tileID.wrap,t.tileID.canonical.z,t.tileID.canonical.x,t.tileID.canonical.y),this.uid=t.uid,this.zoom=t.zoom,this.pixelRatio=t.pixelRatio,this.tileSize=t.tileSize,this.source=t.source,this.overscaling=this.tileID.overscaleFactor(),this.showCollisionBoxes=t.showCollisionBoxes,this.collectResourceTiming=!!t.collectResourceTiming,this.returnDependencies=!!t.returnDependencies,this.promoteId=t.promoteId,this.inFlightDependencies=[]}parse(t,n,o,s,a){return e._(this,void 0,void 0,function*(){this.status="parsing",this.data=t,this.collisionBoxArray=new e.ah;const l=new e.cN(Object.keys(t.layers).sort()),c=new e.cO(this.tileID,this.promoteId);c.bucketLayerIDs=[];const u={},h={featureIndex:c,iconDependencies:{},patternDependencies:{},glyphDependencies:{},dashDependencies:{},availableImages:o,subdivisionGranularity:a},d=n.familiesBySource[this.source];for(const i in d){const n=t.layers[i];if(!n)continue;1===n.version&&e.w(`Vector tile source "${this.source}" layer "${i}" does not use vector tile spec v2 and therefore may have some rendering errors.`);const s=l.encode(i),a=[];for(let e=0;ee.id)))}}const p=e.bX(h.glyphDependencies,e=>Object.keys(e).map(Number));this.inFlightDependencies.forEach(e=>null==e?void 0:e.abort()),this.inFlightDependencies=[];let f=Promise.resolve({});if(Object.keys(p).length){const e=new AbortController;this.inFlightDependencies.push(e),f=s.sendAsync({type:"GG",data:{stacks:p,source:this.source,tileID:this.tileID,type:"glyphs"}},e)}const m=Object.keys(h.iconDependencies);let g=Promise.resolve({});if(m.length){const e=new AbortController;this.inFlightDependencies.push(e),g=s.sendAsync({type:"GI",data:{icons:m,source:this.source,tileID:this.tileID,type:"icons"}},e)}const _=Object.keys(h.patternDependencies);let A=Promise.resolve({});if(_.length){const e=new AbortController;this.inFlightDependencies.push(e),A=s.sendAsync({type:"GI",data:{icons:_,source:this.source,tileID:this.tileID,type:"patterns"}},e)}const y=h.dashDependencies;let v=Promise.resolve({});if(Object.keys(y).length){const e=new AbortController;this.inFlightDependencies.push(e),v=s.sendAsync({type:"GDA",data:{dashes:y}},e)}const[x,b,w,T]=yield Promise.all([f,g,A,v]),E=new i(x),C=new e.cP(b,w);for(const t in u){const i=u[t];i instanceof e.ai?(r(i.layers,this.zoom,o),e.cQ({bucket:i,glyphMap:x,glyphPositions:E.positions,imageMap:b,imagePositions:C.iconPositions,showCollisionBoxes:this.showCollisionBoxes,canonical:this.tileID.canonical,subdivisionGranularity:h.subdivisionGranularity})):i.hasDependencies&&(i instanceof e.cR||i instanceof e.cS||i instanceof e.cT)&&(r(i.layers,this.zoom,o),i.addFeatures(h,this.tileID.canonical,C.patternPositions,T))}return this.status="done",{buckets:Object.values(u).filter(e=>!e.isEmpty()),featureIndex:c,collisionBoxArray:this.collisionBoxArray,glyphAtlasImage:E.image,imageAtlas:C,dashPositions:T,glyphMap:this.returnDependencies?x:null,iconMap:this.returnDependencies?b:null,glyphPositions:this.returnDependencies?E.positions:null}})}}function r(t,i,n){const r=new e.H(i);for(const e of t)e.recalculate(r,n)}class o extends e.cW{constructor(t,i){super(new e.cV,0,i,[],[]),this.feature=t,this.type=t.type,this.properties=t.tags?t.tags:{},"id"in t&&("string"==typeof t.id?this.id=parseInt(t.id,10):"number"!=typeof t.id||isNaN(t.id)||(this.id=t.id))}loadGeometry(){const t=[],i=1===this.feature.type?[this.feature.geometry]:this.feature.geometry;for(const n of i){const i=[];for(const t of n)i.push(new e.P(t[0],t[1]));t.push(i)}return t}}class s extends e.cU{constructor(t,i){super(new e.cV),this.layers={_geojsonTileLayer:this},this.name="_geojsonTileLayer",this.version=i?i.version:1,this.extent=i?i.extent:4096,this.length=t.length,this.features=t}feature(e){return new o(this.features[e],this.extent)}}function a(e,t){t.writeVarintField(15,e.version||1),t.writeStringField(1,e.name||""),t.writeVarintField(5,e.extent||4096);const i={keys:[],values:[],keycache:{},valuecache:{}};for(let n=0;n>31}function d(e,t){const i=e.loadGeometry(),n=e.type;let r=0,o=0;for(const s of i){let i=1;1===n&&(i=s.length),t.writeVarint(u(1,i));const a=3===n?s.length-1:s.length;for(let e=0;et.map(t=>new e.P(t.x,t.y)))}}class m extends e.cU{constructor(t,i,n){super(new e.cV),this.version=2,this._myFeatures=t,this.name=i,this.length=t.length,this.extent=n}feature(e){return this._myFeatures[e]}}class g{constructor(){this.layers={}}addLayer(e){this.layers[e.name]=e}}function _(t){let i=function(t){const i=new e.cV;return function(e,t){for(const i in e.layers)t.writeMessage(3,a,e.layers[i])}(t,i),i.finish()}(t);return 0===i.byteOffset&&i.byteLength===i.buffer.byteLength||(i=new Uint8Array(i)),{vectorTile:t,rawData:i.buffer}}function A(t,i,n){const{extent:r}=t,o=Math.pow(2,n.z-i.z),s=(n.x-i.x*o)*r,a=(n.y-i.y*o)*r,l=[];for(let i=0;i0&&l.addLayer(r)}const u=_(l);return this.overzoomedTileResultCache.set(s,u),u}reloadTile(t){return e._(this,void 0,void 0,function*(){const i=t.uid;if(!this.loaded||!this.loaded[i])throw new Error("Should not be trying to reload a tile that was never loaded or has been removed");const n=this.loaded[i];if(n.showCollisionBoxes=t.showCollisionBoxes,"parsing"===n.status){const r=yield n.parse(n.vectorTile,this.layerIndex,this.availableImages,this.actor,t.subdivisionGranularity);let o;if(this.fetching[i]){const{rawTileData:n,cacheControl:s,resourceTiming:a}=this.fetching[i];delete this.fetching[i],o=e.e({rawTileData:n.slice(0),encoding:t.encoding},r,s,a)}else o=r;return o}if("done"===n.status&&n.vectorTile)return n.parse(n.vectorTile,this.layerIndex,this.availableImages,this.actor,t.subdivisionGranularity)})}abortTile(t){return e._(this,void 0,void 0,function*(){const e=this.loading,i=t.uid;e&&e[i]&&e[i].abort&&(e[i].abort.abort(),delete e[i])})}removeTile(t){return e._(this,void 0,void 0,function*(){this.loaded&&this.loaded[t.uid]&&delete this.loaded[t.uid]})}}class v{constructor(){this.loaded={}}loadTile(t){return e._(this,void 0,void 0,function*(){const{uid:i,encoding:n,rawImageData:r,redFactor:o,greenFactor:s,blueFactor:a,baseShift:l}=t,c=r.width+2,u=r.height+2,h=e.b(r)?new e.R({width:c,height:u},yield e.d0(r,-1,-1,c,u)):r,d=new e.d1(i,h,n,o,s,a,l);return this.loaded=this.loaded||{},this.loaded[i]=d,d})}removeTile(e){const t=this.loaded,i=e.uid;t&&t[i]&&delete t[i]}}var x,b,w=function(){if(b)return x;function e(e,i){if(0!==e.length){t(e[0],i);for(var n=1;n=Math.abs(a)?i-l+a:a-l+i,i=l}i+n>=0!=!!t&&e.reverse()}return b=1,x=function t(i,n){var r,o=i&&i.type;if("FeatureCollection"===o)for(r=0;re},C=Math.fround||(S=new Float32Array(1),e=>(S[0]=+e,S[0]));var S;class B{constructor(e){this.options=Object.assign(Object.create(E),e),this.trees=new Array(this.options.maxZoom+1),this.stride=this.options.reduce?7:6,this.clusterProps=[]}load(e){const{log:t,minZoom:i,maxZoom:n}=this.options;t&&console.time("total time");const r=`prepare ${e.length} points`;t&&console.time(r),this.points=e;const o=[];for(let t=0;t=i;e--){const i=+Date.now();s=this.trees[e]=this._createTree(this._cluster(s,e)),t&&console.log("z%d: %d clusters in %dms",e,s.numItems,+Date.now()-i)}return t&&console.timeEnd("total time"),this}getClusters(e,t){let i=((e[0]+180)%360+360)%360-180;const n=Math.max(-90,Math.min(90,e[1]));let r=180===e[2]?180:((e[2]+180)%360+360)%360-180;const o=Math.max(-90,Math.min(90,e[3]));if(e[2]-e[0]>=360)i=-180,r=180;else if(i>r){const e=this.getClusters([i,n,180,o],t),s=this.getClusters([-180,n,r,o],t);return e.concat(s)}const s=this.trees[this._limitZoom(t)],a=s.range(P(i),R(o),P(r),R(n)),l=s.data,c=[];for(const e of a){const t=this.stride*e;c.push(l[t+5]>1?I(l,t,this.clusterProps):this.points[l[t+3]])}return c}getChildren(e){const t=this._getOriginId(e),i=this._getOriginZoom(e),n="No cluster with the specified id.",r=this.trees[i];if(!r)throw new Error(n);const o=r.data;if(t*this.stride>=o.length)throw new Error(n);const s=this.options.radius/(this.options.extent*Math.pow(2,i-1)),a=r.within(o[t*this.stride],o[t*this.stride+1],s),l=[];for(const t of a){const i=t*this.stride;o[i+4]===e&&l.push(o[i+5]>1?I(o,i,this.clusterProps):this.points[o[i+3]])}if(0===l.length)throw new Error(n);return l}getLeaves(e,t,i){const n=[];return this._appendLeaves(n,e,t=t||10,i=i||0,0),n}getTile(e,t,i){const n=this.trees[this._limitZoom(e)],r=Math.pow(2,e),{extent:o,radius:s}=this.options,a=s/o,l=(i-a)/r,c=(i+1+a)/r,u={features:[]};return this._addTileFeatures(n.range((t-a)/r,l,(t+1+a)/r,c),n.data,t,i,r,u),0===t&&this._addTileFeatures(n.range(1-a/r,l,1,c),n.data,r,i,r,u),t===r-1&&this._addTileFeatures(n.range(0,l,a/r,c),n.data,-1,i,r,u),u.features.length?u:null}getClusterExpansionZoom(e){let t=this._getOriginZoom(e)-1;for(;t<=this.options.maxZoom;){const i=this.getChildren(e);if(t++,1!==i.length)break;e=i[0].properties.cluster_id}return t}_appendLeaves(e,t,i,n,r){const o=this.getChildren(t);for(const t of o){const o=t.properties;if(o&&o.cluster?r+o.point_count<=n?r+=o.point_count:r=this._appendLeaves(e,o.cluster_id,i,n,r):r1;let l,c,u;if(a)l=M(t,e,this.clusterProps),c=t[e],u=t[e+1];else{const i=this.points[t[e+3]];l=i.properties;const[n,r]=i.geometry.coordinates;c=P(n),u=R(r)}const h={type:1,geometry:[[Math.round(this.options.extent*(c*r-i)),Math.round(this.options.extent*(u*r-n))]],tags:l};let d;d=a||this.options.generateId?t[e+3]:this.points[t[e+3]].id,void 0!==d&&(h.id=d),o.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:i,extent:n,reduce:r,minPoints:o}=this.options,s=i/(n*Math.pow(2,t)),a=e.data,l=[],c=this.stride;for(let i=0;it&&(p+=a[i+5])}if(p>d&&p>=o){let e,o=n*d,s=u*d,f=-1;const m=(i/c<<5)+(t+1)+this.points.length;for(const n of h){const l=n*c;if(a[l+2]<=t)continue;a[l+2]=t;const u=a[l+5];o+=a[l]*u,s+=a[l+1]*u,a[l+4]=m,r&&(e||(e=this._map(a,i,!0),f=this.clusterProps.length,this.clusterProps.push(e)),r(e,this._map(a,l)))}a[i+4]=m,l.push(o/p,s/p,1/0,m,-1,p),r&&l.push(f)}else{for(let e=0;e1)for(const e of h){const i=e*c;if(!(a[i+2]<=t)){a[i+2]=t;for(let e=0;e>5}_getOriginZoom(e){return(e-this.points.length)%32}_map(e,t,i){if(e[t+5]>1){const n=this.clusterProps[e[t+6]];return i?Object.assign({},n):n}const n=this.points[e[t+3]].properties,r=this.options.map(n);return i&&r===n?Object.assign({},r):r}}function I(e,t,i){return{type:"Feature",id:e[t+3],properties:M(e,t,i),geometry:{type:"Point",coordinates:[(n=e[t],360*(n-.5)),L(e[t+1])]}};var n}function M(e,t,i){const n=e[t+5],r=n>=1e4?`${Math.round(n/1e3)}k`:n>=1e3?Math.round(n/100)/10+"k":n,o=e[t+6],s=-1===o?{}:Object.assign({},i[o]);return Object.assign(s,{cluster:!0,cluster_id:e[t+3],point_count:n,point_count_abbreviated:r})}function P(e){return e/360+.5}function R(e){const t=Math.sin(e*Math.PI/180),i=.5-.25*Math.log((1+t)/(1-t))/Math.PI;return i<0?0:i>1?1:i}function L(e){const t=(180-360*e)*Math.PI/180;return 360*Math.atan(Math.exp(t))/Math.PI-90}function F(e,t,i,n){let r=n;const o=t+(i-t>>1);let s,a=i-t;const l=e[t],c=e[t+1],u=e[i],h=e[i+1];for(let n=t+3;nr)s=n,r=t;else if(t===r){const e=Math.abs(n-o);en&&(s-t>3&&F(e,t,s,n),e[s+2]=r,i-s>3&&F(e,s,i,n))}function k(e,t,i,n,r,o){let s=r-i,a=o-n;if(0!==s||0!==a){const l=((e-i)*s+(t-n)*a)/(s*s+a*a);l>1?(i=r,n=o):l>0&&(i+=s*l,n+=a*l)}return s=e-i,a=t-n,s*s+a*a}function D(e,t,i,n){const r={id:null==e?null:e,type:t,geometry:i,tags:n,minX:1/0,minY:1/0,maxX:-1/0,maxY:-1/0};if("Point"===t||"MultiPoint"===t||"LineString"===t)O(r,i);else if("Polygon"===t)O(r,i[0]);else if("MultiLineString"===t)for(const e of i)O(r,e);else if("MultiPolygon"===t)for(const e of i)O(r,e[0]);return r}function O(e,t){for(let i=0;i0&&(s+=n?(r*l-a*o)/2:Math.sqrt(Math.pow(a-r,2)+Math.pow(l-o,2))),r=a,o=l}const a=t.length-3;t[2]=1,F(t,0,a,i),t[a+2]=1,t.size=Math.abs(s),t.start=0,t.end=t.size}function V(e,t,i,n){for(let r=0;r1?1:i}function H(e,t,i,n,r,o,s,a){if(n/=t,o>=(i/=t)&&s=n)return null;const l=[];for(const t of e){const e=t.geometry;let o=t.type;const s=0===r?t.minX:t.minY,c=0===r?t.maxX:t.maxY;if(s>=i&&c=n)continue;let u=[];if("Point"===o||"MultiPoint"===o)Q(e,u,i,n,r);else if("LineString"===o)$(e,u,i,n,r,!1,a.lineMetrics);else if("MultiLineString"===o)W(e,u,i,n,r,!1);else if("Polygon"===o)W(e,u,i,n,r,!0);else if("MultiPolygon"===o)for(const t of e){const e=[];W(t,e,i,n,r,!0),e.length&&u.push(e)}if(u.length){if(a.lineMetrics&&"LineString"===o){for(const e of u)l.push(D(t.id,o,e,t.tags));continue}"LineString"!==o&&"MultiLineString"!==o||(1===u.length?(o="LineString",u=u[0]):o="MultiLineString"),"Point"!==o&&"MultiPoint"!==o||(o=3===u.length?"Point":"MultiPoint"),l.push(D(t.id,o,u,t.tags))}}return l.length?l:null}function Q(e,t,i,n,r){for(let o=0;o=i&&s<=n&&q(t,e[o],e[o+1],e[o+2])}}function $(e,t,i,n,r,o,s){let a=Z(e);const l=0===r?K:X;let c,u,h=e.start;for(let d=0;di&&(u=l(a,p,f,g,_,i),s&&(a.start=h+c*u)):A>n?y=i&&(u=l(a,p,f,g,_,i),v=!0),y>n&&A<=n&&(u=l(a,p,f,g,_,n),v=!0),!o&&v&&(s&&(a.end=h+c*u),t.push(a),a=Z(e)),s&&(h+=c)}let d=e.length-3;const p=e[d],f=e[d+1],m=0===r?p:f;m>=i&&m<=n&&q(a,p,f,e[d+2]),d=a.length-3,o&&d>=3&&(a[d]!==a[0]||a[d+1]!==a[1])&&q(a,a[0],a[1],a[2]),a.length&&t.push(a)}function Z(e){const t=[];return t.size=e.size,t.start=e.start,t.end=e.end,t}function W(e,t,i,n,r,o){for(const s of e)$(s,t,i,n,r,o,!1)}function q(e,t,i,n){e.push(t,i,n)}function K(e,t,i,n,r,o){const s=(o-t)/(n-t);return q(e,o,i+(r-i)*s,1),s}function X(e,t,i,n,r,o){const s=(o-i)/(r-i);return q(e,t+(n-t)*s,o,1),s}function J(e,t){const i=[];for(let n=0;n0&&t.size<(r?s:n))return void(i.numPoints+=t.length/3);const a=[];for(let e=0;es)&&(i.numSimplified++,a.push(t[e],t[e+1])),i.numPoints++;r&&function(e,t){let i=0;for(let t=0,n=e.length,r=n-2;t0===t)for(let t=0,i=e.length;t24)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 n=function(e,t){const i=[];if("FeatureCollection"===e.type)for(let n=0;n1&&console.time("creation"),d=this.tiles[h]=ie(e,t,i,n,l),this.tileCoords.push({z:t,x:i,y:n}),c)){c>1&&(console.log("tile z%d-%d-%d (features: %d, points: %d, simplified: %d)",t,i,n,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==r){if(t===l.indexMaxZoom||d.numPoints<=l.indexMaxPoints)continue}else{if(t===l.maxZoom||t===r)continue;if(null!=r){const e=r-t;if(i!==o>>e||n!==s>>e)continue}}if(d.source=null,0===e.length)continue;c>1&&console.time("clipping");const p=.5*l.buffer/l.extent,f=.5-p,m=.5+p,g=1+p;let _=null,A=null,y=null,v=null,x=H(e,u,i-p,i+m,0,d.minX,d.maxX,l),b=H(e,u,i+f,i+g,0,d.minX,d.maxX,l);e=null,x&&(_=H(x,u,n-p,n+m,1,d.minY,d.maxY,l),A=H(x,u,n+f,n+g,1,d.minY,d.maxY,l),x=null),b&&(y=H(b,u,n-p,n+m,1,d.minY,d.maxY,l),v=H(b,u,n+f,n+g,1,d.minY,d.maxY,l),b=null),c>1&&console.timeEnd("clipping"),a.push(_||[],t+1,2*i,2*n),a.push(A||[],t+1,2*i,2*n+1),a.push(y||[],t+1,2*i+1,2*n),a.push(v||[],t+1,2*i+1,2*n+1)}}getTile(e,t,i){e=+e,t=+t,i=+i;const n=this.options,{extent:r,debug:o}=n;if(e<0||e>24)return null;const s=1<1&&console.log("drilling down to z%d-%d-%d",e,t,i);let l,c=e,u=t,h=i;for(;!l&&c>0;)c--,u>>=1,h>>=1,l=this.tiles[ae(c,u,h)];return l&&l.source?(o>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,i),o>1&&console.timeEnd("drilling down"),this.tiles[a]?ee(this.tiles[a],r):null):null}}function ae(e,t,i){return 32*((1<`${e.key}: ${e.message}`).join(", "));const r=t.features.filter(e=>n.value.evaluate({zoom:0},e));return this._toFeatureCollection(r)}_toFeatureCollection(e){return{type:"FeatureCollection",features:e}}removeSource(t){return e._(this,void 0,void 0,function*(){this._pendingRequest&&this._pendingRequest.abort()})}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)}}function ce(t,i){return i.cluster?new B(function({superclusterOptions:t,clusterProperties:i}){if(!i||!t)return t;const n={},r={},o={accumulated:null,zoom:0},s={properties:null},a=Object.keys(i);for(const t of a){const[o,s]=i[t],a=e.d3(s),l=e.d3("string"==typeof o?[o,["accumulated"],["get",t]]:o);n[t]=a.value,r[t]=l.value}return t.map=e=>{s.properties=e;const t={};for(const e of a)t[e]=n[e].evaluate(o,s);return t},t.reduce=(e,t)=>{s.properties=t;for(const t of a)o.accumulated=e[t],e[t]=r[t].evaluate(o,s)},t}(i)).load(t.features):function(e,t){return new se(e,t)}(t,i.geojsonVtOptions)}class ue{constructor(t){this.self=t,this.actor=new e.L(t),this.layerIndexes={},this.availableImages={},this.workerSources={},this.demWorkerSources={},this.externalWorkerSourceTypes={},this.globalStates=new Map,this.self.registerWorkerSource=(e,t)=>{if(this.externalWorkerSourceTypes[e])throw new Error(`Worker source with name "${e}" already registered.`);this.externalWorkerSourceTypes[e]=t},this.self.addProtocol=e.cJ,this.self.removeProtocol=e.cK,this.self.registerRTLTextPlugin=t=>{e.d4.setMethods(t)},this.actor.registerMessageHandler("LDT",(e,t)=>this._getDEMWorkerSource(e,t.source).loadTile(t)),this.actor.registerMessageHandler("RDT",(t,i)=>e._(this,void 0,void 0,function*(){this._getDEMWorkerSource(t,i.source).removeTile(i)})),this.actor.registerMessageHandler("GCEZ",(t,i)=>e._(this,void 0,void 0,function*(){return this._getWorkerSource(t,i.type,i.source).getClusterExpansionZoom(i)})),this.actor.registerMessageHandler("GCC",(t,i)=>e._(this,void 0,void 0,function*(){return this._getWorkerSource(t,i.type,i.source).getClusterChildren(i)})),this.actor.registerMessageHandler("GCL",(t,i)=>e._(this,void 0,void 0,function*(){return this._getWorkerSource(t,i.type,i.source).getClusterLeaves(i)})),this.actor.registerMessageHandler("LD",(e,t)=>this._getWorkerSource(e,t.type,t.source).loadData(t)),this.actor.registerMessageHandler("GD",(e,t)=>this._getWorkerSource(e,t.type,t.source).getData()),this.actor.registerMessageHandler("LT",(e,t)=>this._getWorkerSource(e,t.type,t.source).loadTile(t)),this.actor.registerMessageHandler("RT",(e,t)=>this._getWorkerSource(e,t.type,t.source).reloadTile(t)),this.actor.registerMessageHandler("AT",(e,t)=>this._getWorkerSource(e,t.type,t.source).abortTile(t)),this.actor.registerMessageHandler("RMT",(e,t)=>this._getWorkerSource(e,t.type,t.source).removeTile(t)),this.actor.registerMessageHandler("RS",(t,i)=>e._(this,void 0,void 0,function*(){if(!this.workerSources[t]||!this.workerSources[t][i.type]||!this.workerSources[t][i.type][i.source])return;const e=this.workerSources[t][i.type][i.source];delete this.workerSources[t][i.type][i.source],void 0!==e.removeSource&&e.removeSource(i)})),this.actor.registerMessageHandler("RM",t=>e._(this,void 0,void 0,function*(){delete this.layerIndexes[t],delete this.availableImages[t],delete this.workerSources[t],delete this.demWorkerSources[t],this.globalStates.delete(t)})),this.actor.registerMessageHandler("SR",(t,i)=>e._(this,void 0,void 0,function*(){this.referrer=i})),this.actor.registerMessageHandler("SRPS",(e,t)=>this._syncRTLPluginState(e,t)),this.actor.registerMessageHandler("IS",(t,i)=>e._(this,void 0,void 0,function*(){this.self.importScripts(i)})),this.actor.registerMessageHandler("SI",(e,t)=>this._setImages(e,t)),this.actor.registerMessageHandler("UL",(t,i)=>e._(this,void 0,void 0,function*(){this._getLayerIndex(t).update(i.layers,i.removedIds,this._getGlobalState(t))})),this.actor.registerMessageHandler("UGS",(t,i)=>e._(this,void 0,void 0,function*(){const e=this._getGlobalState(t);for(const t in i)e[t]=i[t]})),this.actor.registerMessageHandler("SL",(t,i)=>e._(this,void 0,void 0,function*(){this._getLayerIndex(t).replace(i,this._getGlobalState(t))}))}_getGlobalState(e){let t=this.globalStates.get(e);return t||(t={},this.globalStates.set(e,t)),t}_setImages(t,i){return e._(this,void 0,void 0,function*(){this.availableImages[t]=i;for(const e in this.workerSources[t]){const n=this.workerSources[t][e];for(const e in n)n[e].availableImages=i}})}_syncRTLPluginState(t,i){return e._(this,void 0,void 0,function*(){return yield e.d4.syncState(i,this.self.importScripts)})}_getAvailableImages(e){let t=this.availableImages[e];return t||(t=[]),t}_getLayerIndex(e){let i=this.layerIndexes[e];return i||(i=this.layerIndexes[e]=new t),i}_getWorkerSource(e,t,i){if(this.workerSources[e]||(this.workerSources[e]={}),this.workerSources[e][t]||(this.workerSources[e][t]={}),!this.workerSources[e][t][i]){const n={sendAsync:(t,i)=>(t.targetMapId=e,this.actor.sendAsync(t,i))};switch(t){case"vector":this.workerSources[e][t][i]=new y(n,this._getLayerIndex(e),this._getAvailableImages(e));break;case"geojson":this.workerSources[e][t][i]=new le(n,this._getLayerIndex(e),this._getAvailableImages(e));break;default:this.workerSources[e][t][i]=new this.externalWorkerSourceTypes[t](n,this._getLayerIndex(e),this._getAvailableImages(e))}}return this.workerSources[e][t][i]}_getDEMWorkerSource(e,t){return this.demWorkerSources[e]||(this.demWorkerSources[e]={}),this.demWorkerSources[e][t]||(this.demWorkerSources[e][t]=new v),this.demWorkerSources[e][t]}}return e.i(self)&&(self.worker=new ue(self)),ue}),i("index",["exports","./shared"],function(e,t){var i="5.13.0";function n(){var e=new t.A(4);return t.A!=Float32Array&&(e[1]=0,e[2]=0),e[0]=1,e[3]=1,e}let r,o,s;const a={frame(e,i,n){const r=requestAnimationFrame(e=>{o(),i(e)}),{unsubscribe:o}=t.s(e.signal,"abort",()=>{o(),cancelAnimationFrame(r),n(t.c())},!1)},frameAsync(e){return new Promise((t,i)=>{this.frame(e,t,i)})},getImageData(e,t=0){return this.getImageCanvasContext(e).getImageData(-t,-t,e.width+2*t,e.height+2*t)},getImageCanvasContext(e){const t=window.document.createElement("canvas"),i=t.getContext("2d",{willReadFrequently:!0});if(!i)throw new Error("failed to create canvas 2d context");return t.width=e.width,t.height=e.height,i.drawImage(e,0,0,e.width,e.height),i},resolveURL:e=>(r||(r=document.createElement("a")),r.href=e,r.href),hardwareConcurrency:"undefined"!=typeof navigator&&navigator.hardwareConcurrency||4,get prefersReducedMotion(){return void 0!==s?s:!!matchMedia&&(null==o&&(o=matchMedia("(prefers-reduced-motion: reduce)")),o.matches)},set prefersReducedMotion(e){s=e}},l=new class{constructor(){this._realTime="undefined"!=typeof performance&&performance&&performance.now?performance.now.bind(performance):Date.now.bind(Date),this._frozenAt=null}getCurrentTime(){return null!==this._frozenAt?this._frozenAt:this._realTime()}setNow(e){this._frozenAt=e}restoreNow(){this._frozenAt=null}isFrozen(){return null!==this._frozenAt}};function c(){return l.getCurrentTime()}class u{static testProp(e){if(!u.docStyle)return e[0];for(let t=0;t{window.removeEventListener("click",u.suppressClickInternal,!0)},0)}static getScale(e){const t=e.getBoundingClientRect();return{x:t.width/e.offsetWidth||1,y:t.height/e.offsetHeight||1,boundingClientRect:t}}static getPoint(e,i,n){const r=i.boundingClientRect;return new t.P((n.clientX-r.left)/i.x-e.clientLeft,(n.clientY-r.top)/i.y-e.clientTop)}static mousePos(e,t){const i=u.getScale(e);return u.getPoint(e,i,t)}static touchPos(e,t){const i=[],n=u.getScale(e);for(let r=0;r{d&&g(d),d=null,m=!0},p.onerror=()=>{f=!0,d=null},p.src="data:image/webp;base64,UklGRh4AAABXRUJQVlA4TBEAAAAvAQAAAAfQ//73v/+BiOh/AAA="),function(e){let i,n,r,o;e.resetRequestQueue=()=>{i=[],n=0,r=0,o={}},e.addThrottleControl=e=>{const t=r++;return o[t]=e,t},e.removeThrottleControl=e=>{delete o[e],a()},e.getImage=(e,n,r=!0)=>new Promise((o,s)=>{h.supported&&(e.headers||(e.headers={}),e.headers.accept="image/webp,*/*"),t.e(e,{type:"image"}),i.push({abortController:n,requestParameters:e,supportImageRefresh:r,state:"queued",onError:e=>{s(e)},onSuccess:e=>{o(e)}}),a()});const s=e=>t._(this,void 0,void 0,function*(){e.state="running";const{requestParameters:i,supportImageRefresh:r,onError:o,onSuccess:s,abortController:c}=e,u=!1===r&&!t.i(self)&&!t.g(i.url)&&(!i.headers||Object.keys(i.headers).reduce((e,t)=>e&&"accept"===t,!0));n++;const h=u?l(i,c):t.m(i,c);try{const i=yield h;delete e.abortController,e.state="completed",i.data instanceof HTMLImageElement||t.b(i.data)?s(i):i.data&&s({data:yield(d=i.data,"function"==typeof createImageBitmap?t.f(d):t.h(d)),cacheControl:i.cacheControl,expires:i.expires})}catch(t){delete e.abortController,o(t)}finally{n--,a()}var d}),a=()=>{const e=(()=>{for(const e of Object.keys(o))if(o[e]())return!0;return!1})()?t.a.MAX_PARALLEL_IMAGE_REQUESTS_PER_FRAME:t.a.MAX_PARALLEL_IMAGE_REQUESTS;for(let t=n;t0;t++){const e=i.shift();e.abortController.signal.aborted?t--:s(e)}},l=(e,i)=>new Promise((n,r)=>{const o=new Image,s=e.url,a=e.credentials;a&&"include"===a?o.crossOrigin="use-credentials":(a&&"same-origin"===a||!t.d(s))&&(o.crossOrigin="anonymous"),i.signal.addEventListener("abort",()=>{o.src="",r(t.c())}),o.fetchPriority="high",o.onload=()=>{o.onerror=o.onload=null,n({data:o})},o.onerror=()=>{o.onerror=o.onload=null,i.signal.aborted||r(new Error("Could not load image. Please make sure to use a supported image type such as PNG or JPEG. Note that SVGs are not supported."))},o.src=s})}(_||(_={})),_.resetRequestQueue();class A{constructor(e){this._transformRequestFn=null!=e?e:null}transformRequest(e,t){return this._transformRequestFn&&this._transformRequestFn(e,t)||{url:e}}setTransformRequest(e){this._transformRequestFn=e}}function y(e){const t=[];if("string"==typeof e)t.push({id:"default",url:e});else if(e&&e.length>0){const i=[];for(const{id:n,url:r}of e){const e=`${n}${r}`;-1===i.indexOf(e)&&(i.push(e),t.push({id:n,url:r}))}}return t}function v(e,t,i){try{const n=new URL(e);return n.pathname+=`${t}${i}`,n.toString()}catch(t){throw new Error(`Invalid sprite URL "${e}", must be absolute. Modify style specification directly or use TransformStyleFunction to correct the issue dynamically`)}}function x(e){const{userImage:t}=e;return!!(t&&t.render&&t.render())&&(e.data.replace(new Uint8Array(t.data.buffer)),!0)}class b extends t.E{constructor(){super(),this.images={},this.updatedImages={},this.callbackDispatchedThisFrame={},this.loaded=!1,this.requestors=[],this.patterns={},this.atlasImage=new t.R({width:1,height:1}),this.dirty=!0}destroy(){this.atlasTexture&&(this.atlasTexture.destroy(),this.atlasTexture=null);for(const e of Object.keys(this.images))this.removeImage(e);this.patterns={},this.atlasImage=new t.R({width:1,height:1}),this.dirty=!0}isLoaded(){return this.loaded}setLoaded(e){if(this.loaded!==e&&(this.loaded=e,e)){for(const{ids:e,promiseResolve:t}of this.requestors)t(this._getImagesForIds(e));this.requestors=[]}}getImage(e){const i=this.images[e];if(i&&!i.data&&i.spriteData){const e=i.spriteData;i.data=new t.R({width:e.width,height:e.height},e.context.getImageData(e.x,e.y,e.width,e.height).data),i.spriteData=null}return i}addImage(e,t){if(this.images[e])throw new Error(`Image id ${e} already exist, use updateImage instead`);this._validate(e,t)&&(this.images[e]=t)}_validate(e,i){let n=!0;const r=i.data||i.spriteData;return this._validateStretch(i.stretchX,r&&r.width)||(this.fire(new t.k(new Error(`Image "${e}" has invalid "stretchX" value`))),n=!1),this._validateStretch(i.stretchY,r&&r.height)||(this.fire(new t.k(new Error(`Image "${e}" has invalid "stretchY" value`))),n=!1),this._validateContent(i.content,i)||(this.fire(new t.k(new Error(`Image "${e}" has invalid "content" value`))),n=!1),n}_validateStretch(e,t){if(!e)return!0;let i=0;for(const n of e){if(n[0]{let n=!0;if(!this.isLoaded())for(const t of e)this.images[t]||(n=!1);this.isLoaded()||n?t(this._getImagesForIds(e)):this.requestors.push({ids:e,promiseResolve:t})})}_getImagesForIds(e){const i={};for(const n of e){let e=this.getImage(n);e||(this.fire(new t.l("styleimagemissing",{id:n})),e=this.getImage(n)),e?i[n]={data:e.data.clone(),pixelRatio:e.pixelRatio,sdf:e.sdf,version:e.version,stretchX:e.stretchX,stretchY:e.stretchY,content:e.content,textFitWidth:e.textFitWidth,textFitHeight:e.textFitHeight,hasRenderCallback:Boolean(e.userImage&&e.userImage.render)}:t.w(`Image "${n}" could not be loaded. Please make sure you have added the image with map.addImage() or a "sprite" property in your style. You can provide missing images by listening for the "styleimagemissing" map event.`)}return i}getPixelSize(){const{width:e,height:t}=this.atlasImage;return{width:e,height:t}}getPattern(e){const i=this.patterns[e],n=this.getImage(e);if(!n)return null;if(i&&i.position.version===n.version)return i.position;if(i)i.position.version=n.version;else{const i={w:n.data.width+2,h:n.data.height+2,x:0,y:0},r=new t.I(i,n);this.patterns[e]={bin:i,position:r}}return this._updatePatternAtlas(),this.patterns[e].position}bind(e){const i=e.gl;this.atlasTexture?this.dirty&&(this.atlasTexture.update(this.atlasImage),this.dirty=!1):this.atlasTexture=new t.T(e,this.atlasImage,i.RGBA),this.atlasTexture.bind(i.LINEAR,i.CLAMP_TO_EDGE)}_updatePatternAtlas(){const e=[];for(const t in this.patterns)e.push(this.patterns[t].bin);const{w:i,h:n}=t.p(e),r=this.atlasImage;r.resize({width:i||1,height:n||1});for(const e in this.patterns){const{bin:i}=this.patterns[e],n=i.x+1,o=i.y+1,s=this.getImage(e).data,a=s.width,l=s.height;t.R.copy(s,r,{x:0,y:0},{x:n,y:o},{width:a,height:l}),t.R.copy(s,r,{x:0,y:l-1},{x:n,y:o-1},{width:a,height:1}),t.R.copy(s,r,{x:0,y:0},{x:n,y:o+l},{width:a,height:1}),t.R.copy(s,r,{x:a-1,y:0},{x:n-1,y:o},{width:1,height:l}),t.R.copy(s,r,{x:0,y:0},{x:n+a,y:o},{width:1,height:l})}this.dirty=!0}beginFrame(){this.callbackDispatchedThisFrame={}}dispatchRenderCallbacks(e){for(const i of e){if(this.callbackDispatchedThisFrame[i])continue;this.callbackDispatchedThisFrame[i]=!0;const e=this.getImage(i);e||t.w(`Image with ID: "${i}" was not found`),x(e)&&this.updateImage(i,e)}}cloneImages(){const e={};for(const t in this.images){const i=this.images[t];e[t]=Object.assign(Object.assign({},i),{data:i.data?i.data.clone():null})}return e}}const w=1e20;function T(e,t,i,n,r,o,s,a,l){for(let c=t;c-1);l++,o[l]=a,s[l]=c,s[l+1]=w}for(let a=0,l=0;a/[-\w]+/.test(e)?e:`'${CSS.escape(e)}'`).join(",");return new S.TinySDF({fontSize:48,buffer:6,radius:16,cutoff:.25,fontFamily:i,fontWeight:this._fontWeight(t[0]),fontStyle:this._fontStyle(t[0]),lang:this.lang})}_fontStyle(e){return/italic/i.test(e)?"italic":/oblique/i.test(e)?"oblique":"normal"}_fontWeight(e){const t={thin:100,hairline:100,"extra light":200,"ultra light":200,light:300,normal:400,regular:400,medium:500,semibold:600,demibold:600,bold:700,"extra bold":800,"ultra bold":800,black:900,heavy:900,"extra black":950,"ultra black":950};let i;for(const[n,r]of Object.entries(t))new RegExp(`\\b${n}\\b`,"i").test(e)&&(i=`${r}`);return i}destroy(){for(const e in this.entries){const t=this.entries[e];t.tinySDF&&(t.tinySDF=null),t.ideographTinySDF&&(t.ideographTinySDF=null),t.glyphs={},t.requests={},t.ranges={}}this.entries={}}}S.loadGlyphRange=function(e,i,n,r){return t._(this,void 0,void 0,function*(){const o=256*i,s=o+255,a=r.transformRequest(n.replace("{fontstack}",e).replace("{range}",`${o}-${s}`),"Glyphs"),l=yield t.n(a,new AbortController);if(!l||!l.data)throw new Error(`Could not load glyph range. range: ${i}, ${o}-${s}`);const c={};for(const e of t.o(l.data))c[e.id]=e;return c})},S.TinySDF=class{constructor({fontSize:e=24,buffer:t=3,radius:i=8,cutoff:n=.25,fontFamily:r="sans-serif",fontWeight:o="normal",fontStyle:s="normal",lang:a=null}={}){this.buffer=t,this.cutoff=n,this.radius=i,this.lang=a;const l=this.size=e+4*t,c=this._createCanvas(l),u=this.ctx=c.getContext("2d",{willReadFrequently:!0});u.font=`${s} ${o} ${e}px ${r}`,u.textBaseline="alphabetic",u.textAlign="left",u.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){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),s=Math.ceil(i),a=Math.max(0,Math.min(this.size-this.buffer,Math.ceil(o-r))),l=Math.min(this.size-this.buffer,s+Math.ceil(n)),c=a+2*this.buffer,u=l+2*this.buffer,h=Math.max(c*u,0),d=new Uint8ClampedArray(h),p={data:d,width:c,height:u,glyphWidth:a,glyphHeight:l,glyphTop:s,glyphLeft:0,glyphAdvance:t};if(0===a||0===l)return p;const{ctx:f,buffer:m,gridInner:g,gridOuter:_}=this;this.lang&&(f.lang=this.lang),f.clearRect(m,m,a,l),f.fillText(e,m,m+s);const A=f.getImageData(m,m,a,l);_.fill(w,0,h),g.fill(0,0,h);for(let e=0;e0?e*e:0,g[n]=e<0?e*e:0}}T(_,0,0,c,u,c,this.f,this.v,this.z),T(g,m,m,a,l,c,this.f,this.v,this.z);for(let e=0;e1&&(s=e[++o]);const l=Math.abs(a-s.left),c=Math.abs(a-s.right),u=Math.min(l,c);let h;const d=t/i*(n+1);if(s.isDash){const e=n-Math.abs(d);h=Math.sqrt(u*u+e*e)}else h=n-Math.sqrt(u*u+d*d);this.data[r+a]=Math.max(0,Math.min(255,h+128))}}}addRegularDash(e){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 t=e[0],i=e[e.length-1];t.isDash===i.isDash&&(t.left=i.left-this.width,i.right=t.right+this.width);const n=this.width*this.nextRow;let r=0,o=e[r];for(let t=0;t1&&(o=e[++r]);const i=Math.abs(t-o.left),s=Math.abs(t-o.right),a=Math.min(i,s);this.data[n+t]=Math.max(0,Math.min(255,(o.isDash?a:-a)+128))}}addDash(e,i){const n=i?7:0,r=2*n+1;if(this.nextRow+r>this.height)return t.w("LineAtlas out of space"),null;let o=0;for(let t=0;t{e.terminate()}),this.workers=null)}isPreloaded(){return!!this.active[F]}numActive(){return Object.keys(this.active).length}}const D=Math.floor(a.hardwareConcurrency/2);let O,z;function U(){return O||(O=new k),O}k.workerCount=t.K(globalThis)?Math.max(Math.min(D,3),1):1;class N{constructor(e,i){this.workerPool=e,this.actors=[],this.currentActor=0,this.id=i;const n=this.workerPool.acquire(i);for(let e=0;e{e.remove()}),this.actors=[],e&&this.workerPool.release(this.id)}registerMessageHandler(e,t){for(const i of this.actors)i.registerMessageHandler(e,t)}unregisterMessageHandler(e){for(const t of this.actors)t.unregisterMessageHandler(e)}}function V(){return z||(z=new N(U(),t.M),z.registerMessageHandler("GR",(e,i,n)=>t.m(i,n))),z}function j(e,i){const n=t.N();return t.O(n,n,[1,1,0]),t.Q(n,n,[.5*e.width,.5*e.height,1]),e.calculatePosMatrix?t.S(n,n,e.calculatePosMatrix(i.toUnwrapped())):n}function G(e,t,i,n,r,o,s){var a;const l=function(e,t,i){if(e)for(const n of e){const e=t[n];if(e&&e.source===i&&"fill-extrusion"===e.type)return!0}else for(const e in t){const n=t[e];if(n.source===i&&"fill-extrusion"===n.type)return!0}return!1}(null!==(a=null==r?void 0:r.layers)&&void 0!==a?a:null,t,e.id),c=o.maxPitchScaleFactor(),u=e.tilesIn(n,c,l);u.sort(H);const h=[];for(const n of u)h.push({wrappedTileID:n.tileID.wrapped().key,queryResults:n.tile.queryRenderedFeatures(t,i,e.getState(),n.queryGeometry,n.cameraQueryGeometry,n.scale,r,o,c,j(o,n.tileID),s?(e,t)=>s(n.tileID,e,t):void 0)});return function(e,t){for(const i in e)for(const n of e[i])Q(n,t);return e}(function(e){const t={},i={};for(const n of e){const e=n.queryResults,r=n.wrappedTileID,o=i[r]=i[r]||{};for(const i in e){const n=e[i],r=o[i]=o[i]||{},s=t[i]=t[i]||[];for(const e of n)r[e.featureIndex]||(r[e.featureIndex]=!0,s.push(e))}}return t}(h),e)}function H(e,t){const i=e.tileID,n=t.tileID;return i.overscaledZ-n.overscaledZ||i.canonical.y-n.canonical.y||i.wrap-n.wrap||i.canonical.x-n.canonical.x}function Q(e,t){const i=e.feature,n=t.getFeatureState(i.layer["source-layer"],i.id);i.source=i.layer.source,i.layer["source-layer"]&&(i.sourceLayer=i.layer["source-layer"]),i.state=n}function $(e,i,n){return t._(this,void 0,void 0,function*(){let r=e;if(e.url?r=(yield t.j(i.transformRequest(e.url,"Source"),n)).data:yield a.frameAsync(n),!r)return null;const o=t.U(t.e(r,e),["tiles","minzoom","maxzoom","attribution","bounds","scheme","tileSize","encoding"]);return"vector_layers"in r&&r.vector_layers&&(o.vectorLayerIds=r.vector_layers.map(e=>e.id)),o})}class Z{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 t.V?new t.V(e.lng,e.lat):t.V.convert(e),this}setSouthWest(e){return this._sw=e instanceof t.V?new t.V(e.lng,e.lat):t.V.convert(e),this}extend(e){const i=this._sw,n=this._ne;let r,o;if(e instanceof t.V)r=e,o=e;else{if(!(e instanceof Z))return Array.isArray(e)?4===e.length||e.every(Array.isArray)?this.extend(Z.convert(e)):this.extend(t.V.convert(e)):e&&("lng"in e||"lon"in e)&&"lat"in e?this.extend(t.V.convert(e)):this;if(r=e._sw,o=e._ne,!r||!o)return this}return i||n?(i.lng=Math.min(r.lng,i.lng),i.lat=Math.min(r.lat,i.lat),n.lng=Math.max(o.lng,n.lng),n.lat=Math.max(o.lat,n.lat)):(this._sw=new t.V(r.lng,r.lat),this._ne=new t.V(o.lng,o.lat)),this}getCenter(){return new t.V((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 t.V(this.getWest(),this.getNorth())}getSouthEast(){return new t.V(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:i,lat:n}=t.V.convert(e);let r=this._sw.lng<=i&&i<=this._ne.lng;return this._sw.lng>this._ne.lng&&(r=this._sw.lng>=i&&i>=this._ne.lng),this._sw.lat<=n&&n<=this._ne.lat&&r}intersects(e){if((e=Z.convert(e)).getNorth()this.getNorth())return!1;const i=t.W(this.getWest(),-180,180),n=t.W(this.getEast(),-180,180),r=t.W(e.getWest(),-180,180),o=t.W(e.getEast(),-180,180),s=i>n,a=r>o;return!(!s||!a)||(s?o>=i||r<=n:a?n>=r||i<=o:!(r>n||oi.lng?new t.V(i.lng+360,i.lat):i)}}class W{constructor(e,t,i){this.bounds=Z.convert(this.validateBounds(e)),this.minzoom=t||0,this.maxzoom=i||24}validateBounds(e){return Array.isArray(e)&&4===e.length?[Math.max(-180,e[0]),Math.max(-90,e[1]),Math.min(180,e[2]),Math.min(90,e[3])]:[-180,-90,180,90]}contains(e){const i=Math.pow(2,e.z),n=Math.floor(t.Y(this.bounds.getWest())*i),r=Math.floor(t.X(this.bounds.getNorth())*i),o=Math.ceil(t.Y(this.bounds.getEast())*i),s=Math.ceil(t.X(this.bounds.getSouth())*i);return e.x>=n&&e.x=r&&e.y{this._options.tiles=e}),this}setUrl(e){return this.setSourceProperty(()=>{this.url=e,this._options.url=e}),this}onRemove(){this._tileJSONRequest&&(this._tileJSONRequest.abort(),this._tileJSONRequest=null)}serialize(){return t.e({},this._options)}loadTile(e){return t._(this,void 0,void 0,function*(){const t=e.tileID.canonical.url(this.tiles,this.map.getPixelRatio(),this.scheme),i={request:this.map._requestManager.transformRequest(t,"Tile"),uid:e.uid,tileID:e.tileID,zoom:e.tileID.overscaledZ,tileSize:this.tileSize*e.tileID.overscaleFactor(),type:this.type,source:this.id,pixelRatio:this.map.getPixelRatio(),showCollisionBoxes:this.map.showCollisionBoxes,promoteId:this.promoteId,subdivisionGranularity:this.map.style.projection.subdivisionGranularity,encoding:this.encoding,overzoomParameters:this._getOverzoomParameters(e)};i.request.collectResourceTiming=this._collectResourceTiming;let n="RT";if(e.actor&&"expired"!==e.state){if("loading"===e.state)return new Promise((t,i)=>{e.reloadPromise={resolve:t,reject:i}})}else e.actor=this.dispatcher.getActor(),n="LT";e.abortController=new AbortController;try{const t=yield e.actor.sendAsync({type:n,data:i},e.abortController);if(delete e.abortController,e.aborted)return;this._afterTileLoadWorkerResponse(e,t)}catch(t){if(delete e.abortController,e.aborted)return;if(t&&404!==t.status)throw t;this._afterTileLoadWorkerResponse(e,null)}})}_getOverzoomParameters(e){if(e.tileID.canonical.z<=this.maxzoom)return;if(void 0===this.map._zoomLevelsToOverscale)return;const t=e.tileID.scaledTo(this.maxzoom).canonical,i=t.url(this.tiles,this.map.getPixelRatio(),this.scheme);return{maxZoomTileID:t,overzoomRequest:this.map._requestManager.transformRequest(i,"Tile")}}_afterTileLoadWorkerResponse(e,t){if(t&&t.resourceTiming&&(e.resourceTiming=t.resourceTiming),t&&this.map._refreshExpiredTiles&&e.setExpiryData(t),e.loadVectorData(t,this.map.painter),e.reloadPromise){const t=e.reloadPromise;e.reloadPromise=null,this.loadTile(e).then(t.resolve).catch(t.reject)}}abortTile(e){return t._(this,void 0,void 0,function*(){e.abortController&&(e.abortController.abort(),delete e.abortController),e.actor&&(yield e.actor.sendAsync({type:"AT",data:{uid:e.uid,type:this.type,source:this.id}}))})}unloadTile(e){return t._(this,void 0,void 0,function*(){e.unloadVectorData(),e.actor&&(yield e.actor.sendAsync({type:"RMT",data:{uid:e.uid,type:this.type,source:this.id}}))})}hasTransition(){return!1}}class K extends t.E{constructor(e,i,n,r){super(),this.id=e,this.dispatcher=n,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=t.e({type:"raster"},i),t.e(this,t.U(i,["url","scheme","tileSize"]))}load(){return t._(this,arguments,void 0,function*(e=!1){this._loaded=!1,this.fire(new t.l("dataloading",{dataType:"source"})),this._tileJSONRequest=new AbortController;try{const i=yield $(this._options,this.map._requestManager,this._tileJSONRequest);this._tileJSONRequest=null,this._loaded=!0,i&&(t.e(this,i),i.bounds&&(this.tileBounds=new W(i.bounds,this.minzoom,this.maxzoom)),this.fire(new t.l("data",{dataType:"source",sourceDataType:"metadata"})),this.fire(new t.l("data",{dataType:"source",sourceDataType:"content",sourceDataChanged:e})))}catch(e){this._tileJSONRequest=null,this._loaded=!0,this.fire(new t.k(e))}})}loaded(){return this._loaded}onAdd(e){this.map=e,this.load()}onRemove(){this._tileJSONRequest&&(this._tileJSONRequest.abort(),this._tileJSONRequest=null)}setSourceProperty(e){this._tileJSONRequest&&(this._tileJSONRequest.abort(),this._tileJSONRequest=null),e(),this.load(!0)}setTiles(e){return this.setSourceProperty(()=>{this._options.tiles=e}),this}setUrl(e){return this.setSourceProperty(()=>{this.url=e,this._options.url=e}),this}serialize(){return t.e({},this._options)}hasTile(e){return!this.tileBounds||this.tileBounds.contains(e.canonical)}loadTile(e){return t._(this,void 0,void 0,function*(){const i=e.tileID.canonical.url(this.tiles,this.map.getPixelRatio(),this.scheme);e.abortController=new AbortController;try{const n=yield _.getImage(this.map._requestManager.transformRequest(i,"Tile"),e.abortController,this.map._refreshExpiredTiles);if(delete e.abortController,e.aborted)return void(e.state="unloaded");if(n&&n.data){this.map._refreshExpiredTiles&&(n.cacheControl||n.expires)&&e.setExpiryData({cacheControl:n.cacheControl,expires:n.expires});const i=this.map.painter.context,r=i.gl,o=n.data;e.texture=this.map.painter.getTileTexture(o.width),e.texture?e.texture.update(o,{useMipmap:!0}):(e.texture=new t.T(i,o,r.RGBA,{useMipmap:!0}),e.texture.bind(r.LINEAR,r.CLAMP_TO_EDGE,r.LINEAR_MIPMAP_NEAREST)),e.state="loaded"}}catch(t){if(delete e.abortController,e.aborted)e.state="unloaded";else if(t)throw e.state="errored",t}})}abortTile(e){return t._(this,void 0,void 0,function*(){e.abortController&&(e.abortController.abort(),delete e.abortController)})}unloadTile(e){return t._(this,void 0,void 0,function*(){e.texture&&this.map.painter.saveTileTexture(e.texture)})}hasTransition(){return!1}}class X extends K{constructor(e,i,n,r){super(e,i,n,r),this.type="raster-dem",this.maxzoom=22,this._options=t.e({type:"raster-dem"},i),this.encoding=i.encoding||"mapbox",this.redFactor=i.redFactor,this.greenFactor=i.greenFactor,this.blueFactor=i.blueFactor,this.baseShift=i.baseShift}loadTile(e){return t._(this,void 0,void 0,function*(){const i=e.tileID.canonical.url(this.tiles,this.map.getPixelRatio(),this.scheme),n=this.map._requestManager.transformRequest(i,"Tile");e.neighboringTiles=this._getNeighboringTiles(e.tileID),e.abortController=new AbortController;try{const i=yield _.getImage(n,e.abortController,this.map._refreshExpiredTiles);if(delete e.abortController,e.aborted)return void(e.state="unloaded");if(i&&i.data){const n=i.data;this.map._refreshExpiredTiles&&(i.cacheControl||i.expires)&&e.setExpiryData({cacheControl:i.cacheControl,expires:i.expires});const r=t.b(n)&&t.Z()?n:yield this.readImageNow(n),o={type:this.type,uid:e.uid,source:this.id,rawImageData:r,encoding:this.encoding,redFactor:this.redFactor,greenFactor:this.greenFactor,blueFactor:this.blueFactor,baseShift:this.baseShift};if(!e.actor||"expired"===e.state){e.actor=this.dispatcher.getActor();const t=yield e.actor.sendAsync({type:"LDT",data:o});e.dem=t,e.needsHillshadePrepare=!0,e.needsTerrainPrepare=!0,e.state="loaded"}}}catch(t){if(delete e.abortController,e.aborted)e.state="unloaded";else if(t)throw e.state="errored",t}})}readImageNow(e){return t._(this,void 0,void 0,function*(){if("undefined"!=typeof VideoFrame&&t.$()){const i=e.width+2,n=e.height+2;try{return new t.R({width:i,height:n},yield t.a0(e,-1,-1,i,n))}catch(e){}}return a.getImageData(e,1)})}_getNeighboringTiles(e){const i=e.canonical,n=Math.pow(2,i.z),r=(i.x-1+n)%n,o=0===i.x?e.wrap-1:e.wrap,s=(i.x+1+n)%n,a=i.x+1===n?e.wrap+1:e.wrap,l={};return l[new t.a1(e.overscaledZ,o,i.z,r,i.y).key]={backfilled:!1},l[new t.a1(e.overscaledZ,a,i.z,s,i.y).key]={backfilled:!1},i.y>0&&(l[new t.a1(e.overscaledZ,o,i.z,r,i.y-1).key]={backfilled:!1},l[new t.a1(e.overscaledZ,e.wrap,i.z,i.x,i.y-1).key]={backfilled:!1},l[new t.a1(e.overscaledZ,a,i.z,s,i.y-1).key]={backfilled:!1}),i.y+1e.coordinates).flat(1/0):e.coordinates.flat(1/0)}function Y(e){const t=new Z;let i;switch(e.type){case"FeatureCollection":i=e.features.map(e=>J(e.geometry)).flat(1/0);break;case"Feature":i=J(e.geometry);break;default:i=J(e)}if(0==i.length)return t;for(let e=0;e0&&t.e(o,{resourceTiming:r}),this.fire(new t.l("data",Object.assign(Object.assign({},o),{sourceDataType:"metadata"}))),this.fire(new t.l("data",Object.assign(Object.assign({},o),{sourceDataType:"content",shouldReloadTileOptions:this._getShouldReloadTileOptions(i)})))}catch(e){if(this._isUpdatingWorker=!1,this._removed)return void this.fire(new t.l("dataabort",{dataType:"source"}));this.fire(new t.k(e))}finally{this._hasPendingWorkerUpdate()&&this._updateWorkerData()}})}_applyDiff(e){const i="string"==typeof this.promoteId?this.promoteId:void 0;this._data.url||this._data.updateable||!t.a6(this._data.geojson,i)||(this._data={updateable:t.a7(this._data.geojson,i)}),e&&this._data.updateable?t.a8(this._data.updateable,e,i):t.w("Cannot apply GeoJSONSource#updateData due to internal error")}_getShouldReloadTileOptions(e){if(this._options.cluster||!e||e.removeAll)return;const{add:i=[],update:n=[],remove:r=[]}=e||{},o=new Set([...n.map(e=>e.id),...r]);for(const e of o.values())if("number"!=typeof e&&null==this.promoteId)return void t.w(`GeoJSONSource "${this.id}": updateData is slower when using string GeoJSON feature IDs (e.g. "${e}"). Consider using promoteId or numeric IDs for better performance.`);return{nextBounds:[...n.map(e=>e.newGeometry),...i.map(e=>e.geometry)].filter(Boolean).map(e=>Y(e)),prevIds:o}}shouldReloadTile(e,{nextBounds:i,prevIds:n}){if(!e.latestFeatureIndex)return"unloaded"!==e.state;const r=e.latestFeatureIndex.loadVTLayers();for(let i=0;i{this.texture=null}),this):this}_finishLoading(){this.map&&(this.setCoordinates(this.coordinates),this.fire(new t.l("data",{dataType:"source",sourceDataType:"metadata"})))}onAdd(e){this.map=e,this.load()}onRemove(){this._request&&(this._request.abort(),this._request=null)}setCoordinates(e){this.coordinates=e;const i=e.map(t.aa.fromLngLat);var n;return this.tileID=function(e){const i=t.ab.fromPoints(e),n=i.width(),r=i.height(),o=Math.max(n,r),s=Math.max(0,Math.floor(-Math.log(o)/Math.LN2)),a=Math.pow(2,s);return new t.ad(s,Math.floor((i.minX+i.maxX)/2*a),Math.floor((i.minY+i.maxY)/2*a))}(i),this.terrainTileRanges=this._getOverlappingTileRanges(i),this.minzoom=this.maxzoom=this.tileID.z,this.tileCoords=i.map(e=>this.tileID.getTilePoint(e)._round()),this.flippedWindingOrder=((n=this.tileCoords)[1].x-n[0].x)*(n[2].y-n[0].y)-(n[1].y-n[0].y)*(n[2].x-n[0].x)<0,this.fire(new t.l("data",{dataType:"source",sourceDataType:"content"})),this}prepare(){if(0===Object.keys(this.tiles).length||!this.image)return;const e=this.map.painter.context,i=e.gl;this.texture||(this.texture=new t.T(e,this.image,i.RGBA),this.texture.bind(i.LINEAR,i.CLAMP_TO_EDGE));let n=!1;for(const e in this.tiles){const t=this.tiles[e];"loaded"!==t.state&&(t.state="loaded",t.texture=this.texture,n=!0)}n&&this.fire(new t.l("data",{dataType:"source",sourceDataType:"idle",sourceId:this.id}))}loadTile(e){return t._(this,void 0,void 0,function*(){this.tileID&&this.tileID.equals(e.tileID.canonical)?(this.tiles[String(e.tileID.wrap)]=e,e.buckets={}):e.state="errored"})}serialize(){return{type:"image",url:this.options.url,coordinates:this.coordinates}}hasTransition(){return!1}_getOverlappingTileRanges(e){const{minX:i,minY:n,maxX:r,maxY:o}=t.ab.fromPoints(e),s={};for(let e=0;e<=t.ac;e++){const t=Math.pow(2,e),a=Math.floor(i*t),l=Math.floor(n*t),c=Math.floor(r*t),u=Math.floor(o*t);s[e]={minTileX:a,minTileY:l,maxTileX:c,maxTileY:u}}return s}}class ie extends te{constructor(e,t,i,n){super(e,t,i,n),this.roundZoom=!0,this.type="video",this.options=t}load(){return t._(this,void 0,void 0,function*(){this._loaded=!1;const e=this.options;this.urls=[];for(const t of e.urls)this.urls.push(this.map._requestManager.transformRequest(t,"Source").url);try{const e=yield t.ae(this.urls);if(this._loaded=!0,!e)return;this.video=e,this.video.loop=!0,this.video.addEventListener("playing",()=>{this.map.triggerRepaint()}),this.map&&this.video.play(),this._finishLoading()}catch(e){this.fire(new t.k(e))}})}pause(){this.video&&this.video.pause()}play(){this.video&&this.video.play()}seek(e){if(this.video){const i=this.video.seekable;ei.end(0)?this.fire(new t.k(new t.af(`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=e}}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 e=this.map.painter.context,i=e.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 t.T(e,this.video,i.RGBA),this.texture.bind(i.LINEAR,i.CLAMP_TO_EDGE));let n=!1;for(const e in this.tiles){const t=this.tiles[e];"loaded"!==t.state&&(t.state="loaded",t.texture=this.texture,n=!0)}n&&this.fire(new t.l("data",{dataType:"source",sourceDataType:"idle",sourceId:this.id}))}serialize(){return{type:"video",urls:this.urls,coordinates:this.coordinates}}hasTransition(){return this.video&&!this.video.paused}}class ne extends te{constructor(e,i,n,r){super(e,i,n,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 t.k(new t.af(`sources.${e}`,null,'"coordinates" property must be an array of 4 longitude/latitude array pairs'))):this.fire(new t.k(new t.af(`sources.${e}`,null,'missing required property "coordinates"'))),i.animate&&"boolean"!=typeof i.animate&&this.fire(new t.k(new t.af(`sources.${e}`,null,'optional "animate" property must be a boolean value'))),i.canvas?"string"==typeof i.canvas||i.canvas instanceof HTMLCanvasElement||this.fire(new t.k(new t.af(`sources.${e}`,null,'"canvas" must be either a string representing the ID of the canvas element from which to read, or an HTMLCanvasElement instance'))):this.fire(new t.k(new t.af(`sources.${e}`,null,'missing required property "canvas"'))),this.options=i,this.animate=void 0===i.animate||i.animate}load(){return t._(this,void 0,void 0,function*(){this._loaded=!0,this.canvas||(this.canvas=this.options.canvas instanceof HTMLCanvasElement?this.options.canvas:document.getElementById(this.options.canvas)),this.width=this.canvas.width,this.height=this.canvas.height,this._hasInvalidDimensions()?this.fire(new t.k(new Error("Canvas dimensions cannot be less than or equal to zero."))):(this.play=function(){this._playing=!0,this.map.triggerRepaint()},this.pause=function(){this._playing&&(this.prepare(),this._playing=!1)},this._finishLoading())})}getCanvas(){return this.canvas}onAdd(e){this.map=e,this.load(),this.canvas&&this.animate&&this.play()}onRemove(){this.pause()}prepare(){let e=!1;if(this.canvas.width!==this.width&&(this.width=this.canvas.width,e=!0),this.canvas.height!==this.height&&(this.height=this.canvas.height,e=!0),this._hasInvalidDimensions())return;if(0===Object.keys(this.tiles).length)return;const i=this.map.painter.context,n=i.gl;this.texture?(e||this._playing)&&this.texture.update(this.canvas,{premultiply:!0}):this.texture=new t.T(i,this.canvas,n.RGBA,{premultiply:!0});let r=!1;for(const e in this.tiles){const t=this.tiles[e];"loaded"!==t.state&&(t.state="loaded",t.texture=this.texture,r=!0)}r&&this.fire(new t.l("data",{dataType:"source",sourceDataType:"idle",sourceId:this.id}))}serialize(){return{type:"canvas",animate:this.animate,canvas:this.options.canvas,coordinates:this.coordinates}}hasTransition(){return this._playing}_hasInvalidDimensions(){for(const e of[this.canvas.width,this.canvas.height])if(isNaN(e)||e<=0)return!0;return!1}}const re={},oe=e=>{switch(e){case"geojson":return ee;case"image":return te;case"raster":return K;case"raster-dem":return X;case"vector":return q;case"video":return ie;case"canvas":return ne}return re[e]},se="RTLPluginLoaded";class ae extends t.E{constructor(){super(...arguments),this.status="unavailable",this.url=null,this.dispatcher=V()}_syncState(e){return this.status=e,this.dispatcher.broadcast("SRPS",{pluginStatus:e,pluginURL:this.url}).catch(e=>{throw this.status="error",e})}getRTLTextPluginStatus(){return this.status}clearRTLTextPlugin(){this.status="unavailable",this.url=null}setRTLTextPlugin(e){return t._(this,arguments,void 0,function*(e,t=!1){if(this.url)throw new Error("setRTLTextPlugin cannot be called multiple times.");if(this.url=a.resolveURL(e),!this.url)throw new Error(`requested url ${e} is invalid`);if("unavailable"===this.status){if(!t)return this._requestImport();this.status="deferred",this._syncState(this.status)}else if("requested"===this.status)return this._requestImport()})}_requestImport(){return t._(this,void 0,void 0,function*(){yield this._syncState("loading"),this.status="loaded",this.fire(new t.l(se))})}lazyLoad(){"unavailable"===this.status?this.status="requested":"deferred"===this.status&&this._requestImport()}}let le=null;function ce(){return le||(le=new ae),le}var ue,he;!function(e){e[e.Base=0]="Base",e[e.Parent=1]="Parent"}(ue||(ue={})),function(e){e[e.Departing=0]="Departing",e[e.Incoming=1]="Incoming"}(he||(he={}));class de{constructor(e,i){this.timeAdded=0,this.fadeEndTime=0,this.fadeOpacity=1,this.tileID=e,this.uid=t.ag(),this.uses=0,this.tileSize=i,this.buckets={},this.expirationTime=null,this.queryPadding=0,this.hasSymbolBuckets=!1,this.hasRTLText=!1,this.dependencies={},this.rtt=[],this.rttCoords={},this.expiredRequestCount=0,this.state="loading"}isRenderable(e){return this.hasData()&&(!this.fadeEndTime||this.fadeOpacity>0)&&(e||!this.holdingForSymbolFade())}setCrossFadeLogic({fadingRole:e,fadingDirection:t,fadingParentID:i,fadeEndTime:n}){this.resetFadeLogic(),this.fadingRole=e,this.fadingDirection=t,this.fadingParentID=i,this.fadeEndTime=n}setSelfFadeLogic(e){this.resetFadeLogic(),this.selfFading=!0,this.fadeEndTime=e}resetFadeLogic(){this.fadingRole=null,this.fadingDirection=null,this.fadingParentID=null,this.selfFading=!1,this.timeAdded=c(),this.fadeEndTime=0,this.fadeOpacity=1}wasRequested(){return"errored"===this.state||"loaded"===this.state||"reloading"===this.state}clearTextures(e){this.demTexture&&e.saveTileTexture(this.demTexture),this.demTexture=null}loadVectorData(e,i,n){if(this.hasData()&&this.unloadVectorData(),this.state="loaded",e){e.featureIndex&&(this.latestFeatureIndex=e.featureIndex,e.rawTileData?(this.latestRawTileData=e.rawTileData,this.latestFeatureIndex.rawTileData=e.rawTileData,this.latestFeatureIndex.encoding=e.encoding):this.latestRawTileData&&(this.latestFeatureIndex.rawTileData=this.latestRawTileData,this.latestFeatureIndex.encoding=this.latestEncoding)),this.collisionBoxArray=e.collisionBoxArray,this.buckets=function(e,t){const i={};if(!t)return i;for(const n of e){const e=n.layerIds.map(e=>t.getLayer(e)).filter(Boolean);if(0!==e.length){n.layers=e,n.stateDependentLayerIds&&(n.stateDependentLayers=n.stateDependentLayerIds.map(t=>e.filter(e=>e.id===t)[0]));for(const t of e)i[t.id]=n}}return i}(e.buckets,null==i?void 0:i.style),this.hasSymbolBuckets=!1;for(const e in this.buckets){const i=this.buckets[e];if(i instanceof t.ai){if(this.hasSymbolBuckets=!0,!n)break;i.justReloaded=!0}}if(this.hasRTLText=!1,this.hasSymbolBuckets)for(const e in this.buckets){const i=this.buckets[e];if(i instanceof t.ai&&i.hasRTLText){this.hasRTLText=!0,ce().lazyLoad();break}}this.queryPadding=0;for(const e in this.buckets){const t=this.buckets[e];this.queryPadding=Math.max(this.queryPadding,i.style.getLayer(e).queryRadius(t))}e.imageAtlas&&(this.imageAtlas=e.imageAtlas),e.glyphAtlasImage&&(this.glyphAtlasImage=e.glyphAtlasImage),this.dashPositions=e.dashPositions}else this.collisionBoxArray=new t.ah}unloadVectorData(){for(const e in this.buckets)this.buckets[e].destroy();this.buckets={},this.imageAtlasTexture&&this.imageAtlasTexture.destroy(),this.imageAtlas&&(this.imageAtlas=null),this.glyphAtlasTexture&&this.glyphAtlasTexture.destroy(),this.dashPositions&&(this.dashPositions=null),this.latestFeatureIndex=null,this.state="unloaded"}getBucket(e){return this.buckets[e.id]}upload(e){for(const t in this.buckets){const i=this.buckets[t];i.uploadPending()&&i.upload(e)}const i=e.gl;this.imageAtlas&&!this.imageAtlas.uploaded&&(this.imageAtlasTexture=new t.T(e,this.imageAtlas.image,i.RGBA),this.imageAtlas.uploaded=!0),this.glyphAtlasImage&&(this.glyphAtlasTexture=new t.T(e,this.glyphAtlasImage,i.ALPHA),this.glyphAtlasImage=null)}prepare(e){this.imageAtlas&&this.imageAtlas.patchUpdatedImages(e,this.imageAtlasTexture)}queryRenderedFeatures(e,t,i,n,r,o,s,a,l,c,u){return this.latestFeatureIndex&&this.latestFeatureIndex.rawTileData?this.latestFeatureIndex.query({queryGeometry:n,cameraQueryGeometry:r,scale:o,tileSize:this.tileSize,pixelPosMatrix:c,transform:a,params:s,queryPadding:this.queryPadding*l,getElevation:u},e,t,i):{}}querySourceFeatures(e,i){const n=this.latestFeatureIndex;if(!n||!n.rawTileData)return;const r=n.loadVTLayers(),o=i&&i.sourceLayer?i.sourceLayer:"",s=r[t.a9]||r[o];if(!s)return;const a=t.aj(null==i?void 0:i.filter,null==i?void 0:i.globalState),{z:l,x:c,y:u}=this.tileID.canonical,h={z:l,x:c,y:u};for(let i=0;ie)t=!1;else if(i)if(this.expirationTime({zoom:0,x:0,y:0,wrap:e,fullyVisible:!1}),v=[],x=[];if(e.renderWorldCopies&&a.allowWorldCopies())for(let e=1;e<=3;e++)v.push(y(-e)),v.push(y(e));for(v.push(y(0));v.length>0;){const p=v.pop(),g=p.x,y=p.y;let b=p.fullyVisible;const w={x:g,y:y,z:p.zoom},T=a.getTileBoundingVolume(w,p.wrap,e.elevation,i);if(!b){const e=ve(n,T,r);if(0===e)continue;b=2===e}const E=a.distanceToTile2d(o.x,o.y,w,T);let C=c;l&&(C=(i.calculateTileZoom||we)(e.zoom+t.at(e.tileSize/i.tileSize),E,_,A,e.fov)),C=(i.roundZoom?Math.round:Math.floor)(C),C=Math.max(0,C);const S=Math.min(C,h);if(p.wrap=a.getWrap(s,w,p.wrap),p.zoom>=S){if(p.zoom>1),wrap:p.wrap,fullyVisible:b})}return x.sort((e,t)=>e.distanceSq-t.distanceSq).map(e=>e.tileID)}const Ce=t.ab.fromPoints([new t.P(0,0),new t.P(t.a4,t.a4)]);class Se extends t.E{constructor(e,i,n){super(),this.id=e,this.dispatcher=n,this.on("data",e=>this._dataHandler(e)),this.on("dataloading",()=>{this._sourceErrored=!1}),this.on("error",()=>{this._sourceErrored=this._source.loaded()}),this._source=((e,t,i,n)=>{const r=new(oe(t.type))(e,t,i,n);if(r.id!==e)throw new Error(`Expected Source id to be ${e} instead of ${r.id}`);return r})(e,i,n,this),this._tiles={},this._cache=new t.av(0,e=>this._unloadTile(e)),this._timers={},this._maxTileCacheSize=null,this._maxTileCacheZoomLevels=null,this._rasterFadeDuration=0,this._maxFadingAncestorLevels=5,this._state=new pe,this._didEmitContent=!1,this._updated=!1}onAdd(e){this.map=e,this._maxTileCacheSize=e?e._maxTileCacheSize:null,this._maxTileCacheZoomLevels=e?e._maxTileCacheZoomLevels:null,this._source&&this._source.onAdd&&this._source.onAdd(e)}onRemove(e){this.clearTiles(),this._source&&this._source.onRemove&&this._source.onRemove(e)}loaded(){if(this._sourceErrored)return!0;if(!this._sourceLoaded)return!1;if(!this._source.loaded())return!1;if(!(void 0===this.used&&void 0===this.usedForTerrain||this.used||this.usedForTerrain))return!0;if(!this._updated)return!1;for(const e in this._tiles){const t=this._tiles[e];if("loaded"!==t.state&&"errored"!==t.state)return!1}return!0}getSource(){return this._source}getState(){return this._state}pause(){this._paused=!0}resume(){if(!this._paused)return;const e=this._shouldReloadOnResume;this._paused=!1,this._shouldReloadOnResume=!1,e&&this.reload(),this.transform&&this.update(this.transform,this.terrain)}_loadTile(e,i,n){return t._(this,void 0,void 0,function*(){try{yield this._source.loadTile(e),this._tileLoaded(e,i,n)}catch(i){e.state="errored",404!==i.status?this._source.fire(new t.k(i,{tile:e})):this.update(this.transform,this.terrain)}})}_unloadTile(e){this._source.unloadTile&&this._source.unloadTile(e)}_abortTile(e){this._source.abortTile&&this._source.abortTile(e),this._source.fire(new t.l("dataabort",{tile:e,coord:e.tileID,dataType:"source"}))}serialize(){return this._source.serialize()}prepare(e){this._source.prepare&&this._source.prepare(),this._state.coalesceChanges(this._tiles,this.map?this.map.painter:null);for(const t in this._tiles){const i=this._tiles[t];i.upload(e),i.prepare(this.map.style.imageManager)}}getIds(){return Object.values(this._tiles).map(e=>e.tileID).sort(Be).map(e=>e.key)}getRenderableIds(e){const i=[];for(const t in this._tiles)this._isIdRenderable(t,e)&&i.push(this._tiles[t]);return e?i.sort((e,i)=>{const n=e.tileID,r=i.tileID,o=new t.P(n.canonical.x,n.canonical.y)._rotate(-this.transform.bearingInRadians),s=new t.P(r.canonical.x,r.canonical.y)._rotate(-this.transform.bearingInRadians);return n.overscaledZ-r.overscaledZ||s.y-o.y||s.x-o.x}).map(e=>e.tileID.key):i.map(e=>e.tileID).sort(Be).map(e=>e.key)}hasRenderableParent(e){const t=e.overscaledZ-1;if(t>=this._source.minzoom){const i=this.getLoadedTile(e.scaledTo(t));if(i)return this._isIdRenderable(i.tileID.key)}return!1}_isIdRenderable(e,t=!1){var i;return null===(i=this._tiles[e])||void 0===i?void 0:i.isRenderable(t)}reload(e,t=void 0){if(this._paused)this._shouldReloadOnResume=!0;else{this._cache.reset();for(const i in this._tiles)t&&this._source.shouldReloadTile&&!this._source.shouldReloadTile(this._tiles[i],t)||(e?this._reloadTile(i,"expired"):"errored"!==this._tiles[i].state&&this._reloadTile(i,"reloading"))}}_reloadTile(e,i){return t._(this,void 0,void 0,function*(){const t=this._tiles[e];t&&("loading"!==t.state&&(t.state=i),yield this._loadTile(t,e,i))})}_tileLoaded(e,i,n){e.timeAdded=c(),e.selfFading&&(e.fadeEndTime=e.timeAdded+this._rasterFadeDuration),"expired"===n&&(e.refreshedUponExpiration=!0),this._setTileReloadTimer(i,e),"raster-dem"===this.getSource().type&&e.dem&&this._backfillDEM(e),this._state.initializeTileState(e,this.map?this.map.painter:null),e.aborted||this._source.fire(new t.l("data",{dataType:"source",tile:e,coord:e.tileID}))}_backfillDEM(e){const t=this.getRenderableIds();for(let n=0;n1||(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,n),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){const i=this._getLoadedDescendents(t),n=new Set;for(const r of t){const t=i[r.key];if(!(null==t?void 0:t.length)){n.add(r);continue}const o=r.overscaledZ+Se.maxOverzooming,s=t.filter(e=>e.tileID.overscaledZ<=o);if(!s.length){n.add(r);continue}const a=Math.min(...s.map(e=>e.tileID.overscaledZ)),l=s.filter(e=>e.tileID.overscaledZ===a).map(e=>e.tileID);for(const t of l)e[t.key]=t;this._areDescendentsComplete(l,a,r.overscaledZ)||n.add(r)}return n}_getLoadedDescendents(e){var t;const i={};for(const n in this._tiles){const r=this._tiles[n];if(r.hasData())for(const n of e)r.tileID.isChildOf(n)&&(i[t=n.key]||(i[t]=[])).push(r)}return i}_areDescendentsComplete(e,t,i){return 1===e.length&&e[0].isOverscaled()?e[0].overscaledZ===t:Math.pow(4,t-i)===e.length}getLoadedTile(e){const t=this._tiles[e.key];return(null==t?void 0:t.hasData())?t:null}updateCacheSize(e){const i=Math.ceil(e.width/this._source.tileSize)+1,n=Math.ceil(e.height/this._source.tileSize)+1,r=Math.floor(i*n*(null===this._maxTileCacheZoomLevels?t.a.MAX_TILE_CACHE_ZOOM_LEVELS:this._maxTileCacheZoomLevels)),o="number"==typeof this._maxTileCacheSize?Math.min(this._maxTileCacheSize,r):r;this._cache.setMaxSize(o)}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 n=this._tiles[i];n.tileID=n.tileID.unwrapTo(n.tileID.wrap+t),e[n.tileID.key]=n}this._tiles=e,this._resetTileReloadTimers()}}update(e,i){if(!this._sourceLoaded||this._paused)return;let n;this.transform=e,this.terrain=i,this.updateCacheSize(e),this.handleWrapJump(this.transform.center.lng),this.used||this.usedForTerrain?this._source.tileID?n=e.getVisibleUnwrappedCoordinates(this._source.tileID).map(e=>new t.a1(e.canonical.z,e.wrap,e.canonical.z,e.canonical.x,e.canonical.y)):(n=Ee(e,{tileSize:this.usedForTerrain?this.tileSize:this._source.tileSize,minzoom:this._source.minzoom,maxzoom:"vector"===this._source.type&&void 0!==this.map._zoomLevelsToOverscale?e.maxZoom-this.map._zoomLevelsToOverscale:this._source.maxzoom,roundZoom:!this.usedForTerrain&&this._source.roundZoom,reparseOverscaled:this._source.reparseOverscaled,terrain:i,calculateTileZoom:this._source.calculateTileZoom}),this._source.hasTile&&(n=n.filter(e=>this._source.hasTile(e)))):n=[],this.usedForTerrain&&(n=this._addTerrainIdealTiles(n));const r=0===n.length&&!this._updated&&this._didEmitContent;this._updated=!0,r&&this.fire(new t.l("data",{sourceDataType:"idle",dataType:"source",sourceId:this.id}));const o=Te(e,this._source),s=this._updateRetainedTiles(n,o),a=Ie(this._source.type);a&&this._rasterFadeDuration>0&&!i&&this._updateFadingTiles(n,s),a?this._cleanUpRasterTiles(s):this._cleanUpVectorTiles(s)}_cleanUpRasterTiles(e){for(const t in this._tiles)e[t]||this._removeTile(t)}_cleanUpVectorTiles(e){for(const t in this._tiles){const i=this._tiles[t];e[t]?i.clearSymbolFadeHold():i.hasSymbolBuckets?i.holdingForSymbolFade()?i.symbolFadeFinished()&&this._removeTile(t):i.setSymbolHoldDuration(this.map._fadeDuration):this._removeTile(t)}}_addTerrainIdealTiles(e){const t=[];for(const i of e)if(i.canonical.z>this._source.minzoom){const e=i.scaledTo(i.canonical.z-1);t.push(e);const n=i.scaledTo(Math.max(this._source.minzoom,Math.min(i.canonical.z,5)));t.push(n)}return e.concat(t)}releaseSymbolFadeTiles(){for(const e in this._tiles)this._tiles[e].holdingForSymbolFade()&&this._removeTile(e)}_updateRetainedTiles(e,t){var i;const n=new Set;for(const t of e)this._addTile(t).hasData()||n.add(t);const r=e.reduce((e,t)=>(e[t.key]=t,e),{}),o=this._retainLoadedChildren(r,n),s={},a=Math.max(t-Se.maxUnderzooming,this._source.minzoom);for(const e of o){let t=this._tiles[e.key],n=null==t?void 0:t.wasRequested();for(let o=e.overscaledZ-1;o>=a;--o){const a=e.scaledTo(o);if(s[a.key])break;if(s[a.key]=!0,t=this.getTile(a),!t&&n&&(t=this._addTile(a)),t){const e=t.hasData();if((e||!(null===(i=this.map)||void 0===i?void 0:i.cancelPendingTileRequestsWhileZooming)||n)&&(r[a.key]=a),n=t.wasRequested(),e)break}}}return r}_updateFadingTiles(e,i){const n=c(),r=t.aw(e);for(const t of e){const e=this._tiles[t.key];e.fadingDirection!==he.Departing&&0!==e.fadeOpacity||e.resetFadeLogic(),this._updateFadingAncestor(e,i,n)||this._updateFadingDescendents(e,i,n)||this._updateFadingEdge(e,r,n)||e.resetFadeLogic()}}_updateFadingAncestor(e,t,i){if(!e.hasData())return!1;const{tileID:n,fadingRole:r,fadingDirection:o,fadingParentID:s}=e;if(r===ue.Base&&o===he.Incoming&&s)return t[s.key]=s,!0;const a=Math.max(n.overscaledZ-this._maxFadingAncestorLevels,this._source.minzoom);for(let r=n.overscaledZ-1;r>=a;r--){const o=n.scaledTo(r),s=this.getLoadedTile(o);if(s)return e.setCrossFadeLogic({fadingRole:ue.Base,fadingDirection:he.Incoming,fadingParentID:s.tileID,fadeEndTime:i+this._rasterFadeDuration}),s.setCrossFadeLogic({fadingRole:ue.Parent,fadingDirection:he.Departing,fadeEndTime:i+this._rasterFadeDuration}),t[o.key]=o,!0}return!1}_updateFadingDescendents(e,t,i){if(!e.hasData())return!1;const n=e.tileID.children(this._source.maxzoom);let r=this._updateFadingChildren(e,n,t,i);if(r)return!0;for(const o of n){const n=o.children(this._source.maxzoom);this._updateFadingChildren(e,n,t,i)&&(r=!0)}return r}_updateFadingChildren(e,t,i,n){if(t[0].overscaledZ>=this._source.maxzoom)return!1;let r=!1;for(const o of t){const t=this.getLoadedTile(o);if(!t)continue;const{fadingRole:s,fadingDirection:a,fadingParentID:l}=t;s===ue.Base&&a===he.Departing&&l||(t.setCrossFadeLogic({fadingRole:ue.Base,fadingDirection:he.Departing,fadingParentID:e.tileID,fadeEndTime:n+this._rasterFadeDuration}),e.setCrossFadeLogic({fadingRole:ue.Parent,fadingDirection:he.Incoming,fadeEndTime:n+this._rasterFadeDuration})),i[o.key]=o,r=!0}return r}_updateFadingEdge(e,t,i){const n=e.tileID;return!!e.selfFading||!e.hasData()&&!!t.has(n)&&(e.setSelfFadeLogic(i+this._rasterFadeDuration),!0)}_addTile(e){let i=this._tiles[e.key];if(i)return i;i=this._cache.getAndRemove(e),i&&(i.resetFadeLogic(),this._setTileReloadTimer(e.key,i),i.tileID=e,this._state.initializeTileState(i,this.map?this.map.painter:null));const n=i;return i||(i=new de(e,this._source.tileSize*e.overscaleFactor()),this._loadTile(i,e.key,i.state)),i.uses++,this._tiles[e.key]=i,n||this._source.fire(new t.l("dataloading",{tile:i,coord:i.tileID,dataType:"source"})),i}_setTileReloadTimer(e,t){this._clearTileReloadTimer(e);const i=t.getExpiryTimeout();i&&(this._timers[e]=setTimeout(()=>{this._reloadTile(e,"expired"),delete this._timers[e]},i))}_clearTileReloadTimer(e){const t=this._timers[e];t&&(clearTimeout(t),delete this._timers[e])}_resetTileReloadTimers(){for(const e in this._timers)clearTimeout(this._timers[e]),delete this._timers[e];for(const e in this._tiles)this._setTileReloadTimer(e,this._tiles[e])}refreshTiles(e){for(const t in this._tiles)(this._isIdRenderable(t)||"errored"==this._tiles[t].state)&&e.some(e=>e.equals(this._tiles[t].tileID.canonical))&&this._reloadTile(t,"expired")}_removeTile(e){const t=this._tiles[e];t&&(t.uses--,delete this._tiles[e],this._clearTileReloadTimer(e),t.uses>0||(t.hasData()&&"reloading"!==t.state?this._cache.add(t.tileID,t,t.getExpiryTimeout()):(t.aborted=!0,this._abortTile(t),this._unloadTile(t))))}_dataHandler(e){"source"===e.dataType&&("metadata"!==e.sourceDataType?"content"===e.sourceDataType&&this._sourceLoaded&&!this._paused&&(this.reload(e.sourceDataChanged,e.shouldReloadTileOptions),this.transform&&this.update(this.transform,this.terrain),this._didEmitContent=!0):this._sourceLoaded=!0)}clearTiles(){this._shouldReloadOnResume=!1,this._paused=!1;for(const e in this._tiles)this._removeTile(e);this._cache.reset()}tilesIn(e,i,n){const r=[],o=this.transform;if(!o)return r;const s=o.getCoveringTilesDetailsProvider().allowWorldCopies(),a=n?o.getCameraQueryGeometry(e):e,l=e=>o.screenPointToMercatorCoordinate(e,this.terrain),c=this.transformBbox(e,l,!s),u=this.transformBbox(a,l,!s),h=this.getIds(),d=t.ab.fromPoints(u);for(let e=0;ee.getTilePoint(new t.aa(i.x,i.y)));if(i.expandBy(p),i.intersects(Ce)){const t=c.map(t=>e.getTilePoint(t)),i=u.map(t=>e.getTilePoint(t));r.push({tile:n,tileID:s?e:e.unwrapTo(0),queryGeometry:t,cameraQueryGeometry:i,scale:l})}}}return r}transformBbox(e,i,n){let r=e.map(i);if(n){const n=t.ab.fromPoints(e);n.shrinkBy(.001*Math.min(n.width(),n.height()));const o=n.map(i);t.ab.fromPoints(r).covers(o)||(r=r.map(e=>e.x>.5?new t.aa(e.x-1,e.y,e.z):e))}return r}getVisibleCoordinates(e){const t=this.getRenderableIds(e).map(e=>this._tiles[e].tileID);return this.transform&&this.transform.populateCache(t),t}hasTransition(){if(this._source.hasTransition())return!0;if(Ie(this._source.type)&&this._rasterFadeDuration>0){const e=c();for(const t in this._tiles)if(this._tiles[t].fadeEndTime>=e)return!0}return!1}setRasterFadeDuration(e){this._rasterFadeDuration=e}setFeatureState(e,i,n){this._state.updateState(e=e||t.a9,i,n)}removeFeatureState(e,i,n){this._state.removeFeatureState(e=e||t.a9,i,n)}getFeatureState(e,i){return this._state.getState(e=e||t.a9,i)}setDependencies(e,t,i){const n=this._tiles[e];n&&n.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))}}function Be(e,t){const i=Math.abs(2*e.wrap)-+(e.wrap<0),n=Math.abs(2*t.wrap)-+(t.wrap<0);return e.overscaledZ-t.overscaledZ||n-i||t.canonical.y-e.canonical.y||t.canonical.x-e.canonical.x}function Ie(e){return"raster"===e||"image"===e||"video"===e}Se.maxUnderzooming=10,Se.maxOverzooming=3;class Me{constructor(e,t){this.reset(e,t)}reset(e,t){this.points=e||[],this._distances=[0];for(let e=1;e0?(r-s)/a:0;return this.points[o].mult(1-l).add(this.points[i].mult(l))}}function Pe(e,t){let i=!0;return"always"===e||"never"!==e&&"never"!==t||(i=!1),i}class Re{constructor(e,t,i){const n=this.boxCells=[],r=this.circleCells=[];this.xCellCount=Math.ceil(e/i),this.yCellCount=Math.ceil(t/i);for(let e=0;ethis.width||n<0||t>this.height)return[];const a=[];if(e<=0&&t<=0&&this.width<=i&&this.height<=n){if(r)return[{key:null,x1:e,y1:t,x2:i,y2:n}];for(let e=0;e0}hitTestCircle(e,t,i,n,r){const o=e-i,s=e+i,a=t-i,l=t+i;if(s<0||o>this.width||l<0||a>this.height)return!1;const c=[];return this._forEachCell(o,a,s,l,this._queryCellCircle,c,{hitTest:!0,overlapMode:n,circle:{x:e,y:t,radius:i},seenUids:{box:{},circle:{}}},r),c.length>0}_queryCell(e,t,i,n,r,o,s,a){const{seenUids:l,hitTest:c,overlapMode:u}=s,h=this.boxCells[r];if(null!==h){const r=this.bboxes;for(const s of h)if(!l.box[s]){l.box[s]=!0;const h=4*s,d=this.boxKeys[s];if(e<=r[h+2]&&t<=r[h+3]&&i>=r[h+0]&&n>=r[h+1]&&(!a||a(d))&&(!c||!Pe(u,d.overlapMode))&&(o.push({key:d,x1:r[h],y1:r[h+1],x2:r[h+2],y2:r[h+3]}),c))return!0}}const d=this.circleCells[r];if(null!==d){const r=this.circles;for(const s of d)if(!l.circle[s]){l.circle[s]=!0;const h=3*s,d=this.circleKeys[s];if(this._circleAndRectCollide(r[h],r[h+1],r[h+2],e,t,i,n)&&(!a||a(d))&&(!c||!Pe(u,d.overlapMode))){const e=r[h],t=r[h+1],i=r[h+2];if(o.push({key:d,x1:e-i,y1:t-i,x2:e+i,y2:t+i}),c)return!0}}}return!1}_queryCellCircle(e,t,i,n,r,o,s,a){const{circle:l,seenUids:c,overlapMode:u}=s,h=this.boxCells[r];if(null!==h){const e=this.bboxes;for(const t of h)if(!c.box[t]){c.box[t]=!0;const i=4*t,n=this.boxKeys[t];if(this._circleAndRectCollide(l.x,l.y,l.radius,e[i+0],e[i+1],e[i+2],e[i+3])&&(!a||a(n))&&!Pe(u,n.overlapMode))return o.push(!0),!0}}const d=this.circleCells[r];if(null!==d){const e=this.circles;for(const t of d)if(!c.circle[t]){c.circle[t]=!0;const i=3*t,n=this.circleKeys[t];if(this._circlesCollide(e[i],e[i+1],e[i+2],l.x,l.y,l.radius)&&(!a||a(n))&&!Pe(u,n.overlapMode))return o.push(!0),!0}}}_forEachCell(e,t,i,n,r,o,s,a){const l=this._convertToXCellCoord(e),c=this._convertToYCellCoord(t),u=this._convertToXCellCoord(i),h=this._convertToYCellCoord(n);for(let d=l;d<=u;d++)for(let l=c;l<=h;l++)if(r.call(this,e,t,i,n,this.xCellCount*l+d,o,s,a))return}_convertToXCellCoord(e){return Math.max(0,Math.min(this.xCellCount-1,Math.floor(e*this.xScale)))}_convertToYCellCoord(e){return Math.max(0,Math.min(this.yCellCount-1,Math.floor(e*this.yScale)))}_circlesCollide(e,t,i,n,r,o){const s=n-e,a=r-t,l=i+o;return l*l>s*s+a*a}_circleAndRectCollide(e,t,i,n,r,o,s){const a=(o-n)/2,l=Math.abs(e-(n+a));if(l>a+i)return!1;const c=(s-r)/2,u=Math.abs(t-(r+c));if(u>c+i)return!1;if(l<=a||u<=c)return!0;const h=l-a,d=u-c;return h*h+d*d<=i*i}}function Le(e,i,r){const o=t.N();if(!e){const{vecSouth:e,vecEast:t}=ke(i),r=n();r[0]=t[0],r[1]=t[1],r[2]=e[0],r[3]=e[1],s=r,(d=(l=(a=r)[0])*(h=a[3])-(u=a[2])*(c=a[1]))&&(s[0]=h*(d=1/d),s[1]=-c*d,s[2]=-u*d,s[3]=l*d),o[0]=r[0],o[1]=r[1],o[4]=r[2],o[5]=r[3]}var s,a,l,c,u,h,d;return t.Q(o,o,[1/r,1/r,1]),o}function Fe(e,i,n,r){if(e){const e=t.N();if(!i){const{vecSouth:t,vecEast:i}=ke(n);e[0]=i[0],e[1]=i[1],e[4]=t[0],e[5]=t[1]}return t.Q(e,e,[r,r,1]),e}return n.pixelsToClipSpaceMatrix}function ke(e){const i=Math.cos(e.rollInRadians),n=Math.sin(e.rollInRadians),r=Math.cos(e.pitchInRadians),o=Math.cos(e.bearingInRadians),s=Math.sin(e.bearingInRadians),a=t.aB();a[0]=-o*r*n-s*i,a[1]=-s*r*n+o*i;const l=t.aC(a);l<1e-9?t.aD(a):t.aE(a,a,1/l);const c=t.aB();c[0]=o*r*i-s*n,c[1]=s*r*i+o*n;const u=t.aC(c);return u<1e-9?t.aD(c):t.aE(c,c,1/u),{vecEast:c,vecSouth:a}}function De(e,i,n,r){let o;r?(o=[e,i,r(e,i),1],t.aG(o,o,n)):(o=[e,i,0,1],Ye(o,o,n));const s=o[3];return{point:new t.P(o[0]/s,o[1]/s),signedDistanceFromCamera:s,isOccluded:!1}}function Oe(e,t){return.5+e/t*.5}function ze(e,t){return e.x>=-t[0]&&e.x<=t[0]&&e.y>=-t[1]&&e.y<=t[1]}function Ue(e,i,n,r,o,s,a,l,c,u,h,d,p){const f=n?e.textSizeData:e.iconSizeData,m=t.ax(f,i.transform.zoom),g=[256/i.width*2+1,256/i.height*2+1],_=n?e.text.dynamicLayoutVertexArray:e.icon.dynamicLayoutVertexArray;_.clear();const A=e.lineVertexArray,y=n?e.text.placedSymbolArray:e.icon.placedSymbolArray,v=i.transform.width/i.transform.height;let x=!1;for(let n=0;nMath.abs(n.x-i.x)*r?{useVertical:!0}:(e===t.ay.vertical?i.yn.x)?{needsFlipping:!0}:null}function je(e){const{projectionContext:i,pitchedLabelPlaneMatrixInverse:n,symbol:r,fontSize:o,flip:s,keepUpright:a,glyphOffsetArray:l,dynamicLayoutVertexArray:c,aspectRatio:u,rotateToLine:h}=e,d=o/24,p=r.lineOffsetX*d,f=r.lineOffsetY*d;let m;if(r.numGlyphs>1){const e=r.glyphStartIndex+r.numGlyphs,t=r.lineStartIndex,o=r.lineStartIndex+r.lineLength,c=Ne(d,l,p,f,s,r,h,i);if(!c)return{notEnoughRoom:!0};const g=$e(c.first.point.x,c.first.point.y,i,n),_=$e(c.last.point.x,c.last.point.y,i,n);if(a&&!s){const e=Ve(r.writingMode,g,_,u);if(e)return e}m=[c.first];for(let n=r.glyphStartIndex+1;n0?a.point:Ge(i.tileAnchorPoint,s,e,1,i),c=$e(e.x,e.y,i,n),h=$e(l.x,l.y,i,n),d=Ve(r.writingMode,c,h,u);if(d)return d}const e=Ke(d*l.getoffsetX(r.glyphStartIndex),p,f,s,r.segment,r.lineStartIndex,r.lineStartIndex+r.lineLength,i,h);if(!e||i.projectionCache.anyProjectionOccluded)return{notEnoughRoom:!0};m=[e]}for(const e of m)t.aF(c,e.point,e.angle);return{}}function Ge(e,t,i,n,r){const o=e.add(e.sub(t)._unit()),s=Qe(o.x,o.y,r).point,a=i.sub(s);return i.add(a._mult(n/a.mag()))}function He(e,i,n){const r=i.projectionCache;if(r.projections[e])return r.projections[e];const o=new t.P(i.lineVertexArray.getx(e),i.lineVertexArray.gety(e)),s=Qe(o.x,o.y,i);if(s.signedDistanceFromCamera>0)return r.projections[e]=s.point,r.anyProjectionOccluded=r.anyProjectionOccluded||s.isOccluded,s.point;const a=e-n.direction;return Ge(0===n.distanceFromAnchor?i.tileAnchorPoint:new t.P(i.lineVertexArray.getx(a),i.lineVertexArray.gety(a)),o,n.previousVertex,n.absOffsetX-n.distanceFromAnchor+1,i)}function Qe(e,t,i){const n=e+i.translation[0],r=t+i.translation[1];let o;return i.pitchWithMap?(o=De(n,r,i.pitchedLabelPlaneMatrix,i.getElevation),o.isOccluded=!1):(o=i.transform.projectTileCoordinates(n,r,i.unwrappedTileID,i.getElevation),o.point.x=(.5*o.point.x+.5)*i.width,o.point.y=(.5*-o.point.y+.5)*i.height),o}function $e(e,i,n,r){if(n.pitchWithMap){const o=[e,i,0,1];return t.aG(o,o,r),n.transform.projectTileCoordinates(o[0]/o[3],o[1]/o[3],n.unwrappedTileID,n.getElevation).point}return{x:e/n.width*2-1,y:1-i/n.height*2}}function Ze(e,t,i){return i.transform.projectTileCoordinates(e,t,i.unwrappedTileID,i.getElevation)}function We(e,t,i){return e._unit()._perp()._mult(t*i)}function qe(e,i,n,r,o,s,a,l,c){if(l.projectionCache.offsets[e])return l.projectionCache.offsets[e];const u=n.add(i);if(e+c.direction=o)return l.projectionCache.offsets[e]=u,u;const h=He(e+c.direction,l,c),d=We(h.sub(n),a,c.direction),p=n.add(d),f=h.add(d);return l.projectionCache.offsets[e]=t.aH(s,u,p,f)||u,l.projectionCache.offsets[e]}function Ke(e,t,i,n,r,o,s,a,l){const c=n?e-t:e+t;let u=c>0?1:-1,h=0;n&&(u*=-1,h=Math.PI),u<0&&(h+=Math.PI);let d,p=u>0?o+r:o+r+1;a.projectionCache.cachedAnchorPoint?d=a.projectionCache.cachedAnchorPoint:(d=Qe(a.tileAnchorPoint.x,a.tileAnchorPoint.y,a).point,a.projectionCache.cachedAnchorPoint=d);let f,m,g=d,_=d,A=0,y=0;const v=Math.abs(c),x=[];let b;for(;A+y<=v;){if(p+=u,p=s)return null;A+=y,_=g,m=f;const e={absOffsetX:v,direction:u,distanceFromAnchor:A,previousVertex:_};if(g=He(p,a,e),0===i)x.push(_),b=g.sub(_);else{let t;const n=g.sub(_);t=0===n.mag()?We(He(p+u,a,e).sub(g),i,u):We(n,i,u),m||(m=_.add(t)),f=qe(p,t,g,o,s,m,i,a,e),x.push(m),b=f.sub(m)}y=b.mag()}const w=b._mult((v-A)/y)._add(m||_),T=h+Math.atan2(g.y-_.y,g.x-_.x);return x.push(w),{point:w,angle:l?T:0,path:x}}const Xe=new Float32Array([-1/0,-1/0,0,-1/0,-1/0,0,-1/0,-1/0,0,-1/0,-1/0,0]);function Je(e,t){for(let i=0;i=1;e--)p.push(s.path[e]);for(let e=1;ee.signedDistanceFromCamera<=0)?[]:e.map(e=>e.point)}let g=[];if(p.length>0){const e=p[0].clone(),i=p[0].clone();for(let t=1;t=n.x&&i.x<=r.x&&e.y>=n.y&&i.y<=r.y?[p]:i.xr.x||i.yr.y?[]:t.aI([p],n.x,n.y,r.x,r.y)}for(const t of g){o.reset(t,.25*i);let n=0;n=o.length<=.5*i?1:Math.ceil(o.paddedLength/f)+1;for(let t=0;t{const t=De(e.x,e.y,n,i.getElevation),r=i.transform.projectTileCoordinates(t.point.x,t.point.y,i.unwrappedTileID,i.getElevation);return r.point.x=(.5*r.point.x+.5)*i.width,r.point.y=(.5*-r.point.y+.5)*i.height,r})}(e,i);return function(e){let t=0,i=0,n=0,r=0;for(let o=0;oi&&(i=r,t=n));return e.slice(t,t+i)}(n)}queryRenderedSymbols(e){if(0===e.length||0===this.grid.keysLength()&&0===this.ignoredGrid.keysLength())return{};const i=[],n=new t.ab;for(const r of e){const e=new t.P(r.x+et,r.y+et);n.extend(e),i.push(e)}const{minX:r,minY:o,maxX:s,maxY:a}=n,l=this.grid.query(r,o,s,a).concat(this.ignoredGrid.query(r,o,s,a)),c={},u={};for(const e of l){const n=e.key;if(void 0===c[n.bucketInstanceId]&&(c[n.bucketInstanceId]={}),c[n.bucketInstanceId][n.featureIndex])continue;const r=[new t.P(e.x1,e.y1),new t.P(e.x2,e.y1),new t.P(e.x2,e.y2),new t.P(e.x1,e.y2)];t.aJ(i,r)&&(c[n.bucketInstanceId][n.featureIndex]=!0,void 0===u[n.bucketInstanceId]&&(u[n.bucketInstanceId]=[]),u[n.bucketInstanceId].push(n.featureIndex))}return u}insertCollisionBox(e,t,i,n,r,o){(i?this.ignoredGrid:this.grid).insert({bucketInstanceId:n,featureIndex:r,collisionGroupID:o,overlapMode:t},e[0],e[1],e[2],e[3])}insertCollisionCircles(e,t,i,n,r,o){const s=i?this.ignoredGrid:this.grid,a={bucketInstanceId:n,featureIndex:r,collisionGroupID:o,overlapMode:t};for(let t=0;t=this.screenRightBoundary||nthis.screenBottomBoundary}isInsideGrid(e,t,i,n){return i>=0&&e=0&&tthis.projectAndGetPerspectiveRatio(e.x,e.y,r,c,h));I=e.some(e=>!e.isOccluded),B=e.map(e=>new t.P(e.x,e.y))}else I=!0;return{box:t.aK(B),allPointsOccluded:!I}}}class it{constructor(e,t,i,n){this.opacity=e?Math.max(0,Math.min(1,e.opacity+(e.placed?t:-t))):n&&i?1:0,this.placed=i}isHidden(){return 0===this.opacity&&!this.placed}}class nt{constructor(e,t,i,n,r){this.text=new it(e?e.text:null,t,i,r),this.icon=new it(e?e.icon:null,t,n,r)}isHidden(){return this.text.isHidden()&&this.icon.isHidden()}}class rt{constructor(e,t,i){this.text=e,this.icon=t,this.skipFade=i}}class ot{constructor(e,t,i,n,r){this.bucketInstanceId=e,this.featureIndex=t,this.sourceLayerIndex=i,this.bucketIndex=n,this.tileID=r}}class st{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 at(e,i,n,r,o){const{horizontalAlign:s,verticalAlign:a}=t.aR(e);return new t.P(-(s-.5)*i+r[0]*o,-(a-.5)*n+r[1]*o)}class lt{constructor(e,t,i,n,r){this.transform=e.clone(),this.terrain=t,this.collisionIndex=new tt(this.transform),this.placements={},this.opacities={},this.variableOffsets={},this.stale=!1,this.commitTime=0,this.fadeDuration=i,this.retainedQueryData={},this.collisionGroups=new st(n),this.collisionCircleArrays={},this.collisionBoxArrays=new Map,this.prevPlacement=r,r&&(r.prevPlacement=void 0),this.placedOrientations={}}_getTerrainElevationFunc(e){const t=this.terrain;return t?(i,n)=>t.getElevation(e,i,n):null}getBucketParts(e,i,n,r){const o=n.getBucket(i),s=n.latestFeatureIndex;if(!o||!s||i.id!==o.layerIds[0])return;const a=n.collisionBoxArray,l=o.layers[0].layout,c=o.layers[0].paint,u=Math.pow(2,this.transform.zoom-n.tileID.overscaledZ),h=n.tileSize/t.a4,d=n.tileID.toUnwrapped(),p="map"===l.get("text-rotation-alignment"),f=t.aM(n,1,this.transform.zoom),m=t.aN(this.collisionIndex.transform,n,c.get("text-translate"),c.get("text-translate-anchor")),g=t.aN(this.collisionIndex.transform,n,c.get("icon-translate"),c.get("icon-translate-anchor")),_=Le(p,this.transform,f);this.retainedQueryData[o.bucketInstanceId]=new ot(o.bucketInstanceId,s,o.sourceLayerIndex,o.index,n.tileID);const A={bucket:o,layout:l,translationText:m,translationIcon:g,unwrappedTileID:d,pitchedLabelPlaneMatrix:_,scale:u,textPixelRatio:h,holdingForFade:n.holdingForSymbolFade(),collisionBoxArray:a,partiallyEvaluatedTextSize:t.ax(o.textSizeData,this.transform.zoom),collisionGroup:this.collisionGroups.get(o.sourceID)};if(r)for(const t of o.sortKeyRanges){const{sortKey:i,symbolInstanceStart:n,symbolInstanceEnd:r}=t;e.push({sortKey:i,symbolInstanceStart:n,symbolInstanceEnd:r,parameters:A})}else e.push({symbolInstanceStart:0,symbolInstanceEnd:o.symbolInstances.length,parameters:A})}attemptAnchorPlacement(e,i,n,r,o,s,a,l,c,u,h,d,p,f,m,g,_,A,y,v){const x=t.aO[e.textAnchor],b=[e.textOffset0,e.textOffset1],w=at(x,n,r,b,o),T=this.collisionIndex.placeCollisionBox(i,d,l,c,u,a,s,g,h.predicate,y,w,v);if((!A||this.collisionIndex.placeCollisionBox(A,d,l,c,u,a,s,_,h.predicate,y,w,v).placeable)&&T.placeable){let e;if(this.prevPlacement&&this.prevPlacement.variableOffsets[p.crossTileID]&&this.prevPlacement.placements[p.crossTileID]&&this.prevPlacement.placements[p.crossTileID].text&&(e=this.prevPlacement.variableOffsets[p.crossTileID].anchor),0===p.crossTileID)throw new Error("symbolInstance.crossTileID can't be 0");return this.variableOffsets[p.crossTileID]={textOffset:b,width:n,height:r,anchor:x,textBoxScale:o,prevAnchor:e},this.markUsedJustification(f,x,p,m),f.allowVerticalPlacement&&(this.markUsedOrientation(f,m,p),this.placedOrientations[p.crossTileID]=m),{shift:w,placedGlyphBoxes:T}}}placeLayerBucketPart(e,i,n){const{bucket:r,layout:o,translationText:s,translationIcon:a,unwrappedTileID:l,pitchedLabelPlaneMatrix:c,textPixelRatio:u,holdingForFade:h,collisionBoxArray:d,partiallyEvaluatedTextSize:p,collisionGroup:f}=e.parameters,m=o.get("text-optional"),g=o.get("icon-optional"),_=t.aP(o,"text-overlap","text-allow-overlap"),A="always"===_,y=t.aP(o,"icon-overlap","icon-allow-overlap"),v="always"===y,x="map"===o.get("text-rotation-alignment"),b="map"===o.get("text-pitch-alignment"),w="none"!==o.get("icon-text-fit"),T="viewport-y"===o.get("symbol-z-order"),E=A&&(v||!r.hasIconData()||g),C=v&&(A||!r.hasTextData()||m);!r.collisionArrays&&d&&r.deserializeCollisionBoxes(d);const S=this.retainedQueryData[r.bucketInstanceId].tileID,B=this._getTerrainElevationFunc(S),I=this.transform.getFastPathSimpleProjectionMatrix(S),M=(e,d,v)=>{var T,M;if(i[e.crossTileID])return;if(h)return void(this.placements[e.crossTileID]=new rt(!1,!1,!1));let P=!1,R=!1,L=!0,F=null,k={box:null,placeable:!1,offscreen:null,occluded:!1},D={placeable:!1},O=null,z=null,U=null,N=0,V=0,j=0;d.textFeatureIndex?N=d.textFeatureIndex:e.useRuntimeCollisionCircles&&(N=e.featureIndex),d.verticalTextFeatureIndex&&(V=d.verticalTextFeatureIndex);const G=d.textBox;if(G){const i=i=>{let n=t.ay.horizontal;if(r.allowVerticalPlacement&&!i&&this.prevPlacement){const t=this.prevPlacement.placedOrientations[e.crossTileID];t&&(this.placedOrientations[e.crossTileID]=t,n=t,this.markUsedOrientation(r,n,e))}return n},o=(i,n)=>{if(r.allowVerticalPlacement&&e.numVerticalGlyphVertices>0&&d.verticalTextBox){for(const e of r.writingModes)if(e===t.ay.vertical?(k=n(),D=k):k=i(),k&&k.placeable)break}else k=i()},c=e.textAnchorOffsetStartIndex,h=e.textAnchorOffsetEndIndex;if(h===c){const n=(t,i)=>{const n=this.collisionIndex.placeCollisionBox(t,_,u,S,l,b,x,s,f.predicate,B,void 0,I);return n&&n.placeable&&(this.markUsedOrientation(r,i,e),this.placedOrientations[e.crossTileID]=i),n};o(()=>n(G,t.ay.horizontal),()=>{const i=d.verticalTextBox;return r.allowVerticalPlacement&&e.numVerticalGlyphVertices>0&&i?n(i,t.ay.vertical):{box:null,offscreen:null}}),i(k&&k.placeable)}else{let p=t.aO[null===(M=null===(T=this.prevPlacement)||void 0===T?void 0:T.variableOffsets[e.crossTileID])||void 0===M?void 0:M.anchor];const m=(t,i,o)=>{const d=t.x2-t.x1,m=t.y2-t.y1,g=e.textBoxScale,A=w&&"never"===y?i:null;let v=null,T="never"===_?1:2,E="never";p&&T++;for(let i=0;im(G,d.iconBox,t.ay.horizontal),()=>{const i=d.verticalTextBox;return r.allowVerticalPlacement&&(!k||!k.placeable)&&e.numVerticalGlyphVertices>0&&i?m(i,d.verticalIconBox,t.ay.vertical):{box:null,occluded:!0,offscreen:null}}),k&&(P=k.placeable,L=k.offscreen);const g=i(k&&k.placeable);if(!P&&this.prevPlacement){const t=this.prevPlacement.variableOffsets[e.crossTileID];t&&(this.variableOffsets[e.crossTileID]=t,this.markUsedJustification(r,t.anchor,e,g))}}}if(O=k,P=O&&O.placeable,L=O&&O.offscreen,e.useRuntimeCollisionCircles&&e.centerJustifiedTextSymbolIndex>=0){const i=r.text.placedSymbolArray.get(e.centerJustifiedTextSymbolIndex),a=t.az(r.textSizeData,p,i),u=o.get("text-padding");z=this.collisionIndex.placeCollisionCircles(_,i,r.lineVertexArray,r.glyphOffsetArray,a,l,c,n,b,f.predicate,e.collisionCircleDiameter,u,s,B),z.circles.length&&z.collisionDetected&&!n&&t.w("Collisions detected, but collision boxes are not shown"),P=A||z.circles.length>0&&!z.collisionDetected,L=L&&z.offscreen}if(d.iconFeatureIndex&&(j=d.iconFeatureIndex),d.iconBox){const e=e=>this.collisionIndex.placeCollisionBox(e,y,u,S,l,b,x,a,f.predicate,B,w&&F?F:void 0,I);D&&D.placeable&&d.verticalIconBox?(U=e(d.verticalIconBox),R=U.placeable):(U=e(d.iconBox),R=U.placeable),L=L&&U.offscreen}const H=m||0===e.numHorizontalGlyphVertices&&0===e.numVerticalGlyphVertices,Q=g||0===e.numIconVertices;H||Q?Q?H||(R=R&&P):P=R&&P:R=P=R&&P;const $=R&&U.placeable;if(P&&O.placeable&&this.collisionIndex.insertCollisionBox(O.box,_,o.get("text-ignore-placement"),r.bucketInstanceId,D&&D.placeable&&V?V:N,f.ID),$&&this.collisionIndex.insertCollisionBox(U.box,y,o.get("icon-ignore-placement"),r.bucketInstanceId,j,f.ID),z&&P&&this.collisionIndex.insertCollisionCircles(z.circles,_,o.get("text-ignore-placement"),r.bucketInstanceId,N,f.ID),n&&this.storeCollisionData(r.bucketInstanceId,v,d,O,U,z),0===e.crossTileID)throw new Error("symbolInstance.crossTileID can't be 0");if(0===r.bucketInstanceId)throw new Error("bucket.bucketInstanceId can't be 0");this.placements[e.crossTileID]=new rt((P||E)&&!(null==O?void 0:O.occluded),(R||C)&&!(null==U?void 0:U.occluded),L||r.justReloaded),i[e.crossTileID]=!0};if(T){if(0!==e.symbolInstanceStart)throw new Error("bucket.bucketInstanceId should be 0");const t=r.getSortedSymbolIndexes(-this.transform.bearingInRadians);for(let e=t.length-1;e>=0;--e){const i=t[e];M(r.symbolInstances.get(i),r.collisionArrays[i],i)}}else for(let t=e.symbolInstanceStart;t=0&&(e.text.placedSymbolArray.get(t).crossTileID=o>=0&&t!==o?0:n.crossTileID)}markUsedOrientation(e,i,n){const r=i===t.ay.horizontal||i===t.ay.horizontalOnly?i:0,o=i===t.ay.vertical?i:0,s=[n.leftJustifiedTextSymbolIndex,n.centerJustifiedTextSymbolIndex,n.rightJustifiedTextSymbolIndex];for(const t of s)e.text.placedSymbolArray.get(t).placedOrientation=r;n.verticalPlacedTextSymbolIndex&&(e.text.placedSymbolArray.get(n.verticalPlacedTextSymbolIndex).placedOrientation=o)}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 n=t?t.symbolFadeChange(e):1,r=t?t.opacities:{},o=t?t.variableOffsets:{},s=t?t.placedOrientations:{};for(const e in this.placements){const t=this.placements[e],o=r[e];o?(this.opacities[e]=new nt(o,n,t.text,t.icon),i=i||t.text!==o.text.placed||t.icon!==o.icon.placed):(this.opacities[e]=new nt(null,n,t.text,t.icon,t.skipFade),i=i||t.text||t.icon)}for(const e in r){const t=r[e];if(!this.opacities[e]){const r=new nt(t,n,!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 s)this.placedOrientations[e]||!this.opacities[e]||this.opacities[e].isHidden()||(this.placedOrientations[e]=s[e]);if(t&&void 0===t.lastPlacementChangeTime)throw new Error("Last placement time for previous placement is not defined");i?this.lastPlacementChangeTime=e:"number"!=typeof this.lastPlacementChangeTime&&(this.lastPlacementChangeTime=t?t.lastPlacementChangeTime:e)}updateLayerOpacities(e,t){const i={};for(const n of t){const t=n.getBucket(e);t&&n.latestFeatureIndex&&e.id===t.layerIds[0]&&this.updateBucketOpacities(t,n.tileID,i,n.collisionBoxArray)}}updateBucketOpacities(e,i,n,r){e.hasTextData()&&(e.text.opacityVertexArray.clear(),e.text.hasVisibleVertices=!1),e.hasIconData()&&(e.icon.opacityVertexArray.clear(),e.icon.hasVisibleVertices=!1),e.hasIconCollisionBoxData()&&e.iconCollisionBox.collisionVertexArray.clear(),e.hasTextCollisionBoxData()&&e.textCollisionBox.collisionVertexArray.clear();const o=e.layers[0],s=o.layout,a=new nt(null,0,!1,!1,!0),l=s.get("text-allow-overlap"),c=s.get("icon-allow-overlap"),u=o._unevaluatedLayout.hasValue("text-variable-anchor")||o._unevaluatedLayout.hasValue("text-variable-anchor-offset"),h="map"===s.get("text-rotation-alignment"),d="map"===s.get("text-pitch-alignment"),p="none"!==s.get("icon-text-fit"),f=new nt(null,0,l&&(c||!e.hasIconData()||s.get("icon-optional")),c&&(l||!e.hasTextData()||s.get("text-optional")),!0);!e.collisionArrays&&r&&(e.hasIconCollisionBoxData()||e.hasTextCollisionBoxData())&&e.deserializeCollisionBoxes(r);const m=(e,t,i)=>{for(let n=0;n0,A=this.placedOrientations[r.crossTileID],y=A===t.ay.vertical,v=A===t.ay.horizontal||A===t.ay.horizontalOnly;if(o>0||s>0){const t=_t(c.text);m(e.text,o,y?At:t),m(e.text,s,v?At:t);const i=c.text.isHidden();[r.rightJustifiedTextSymbolIndex,r.centerJustifiedTextSymbolIndex,r.leftJustifiedTextSymbolIndex].forEach(t=>{t>=0&&(e.text.placedSymbolArray.get(t).hidden=i||y?1:0)}),r.verticalPlacedTextSymbolIndex>=0&&(e.text.placedSymbolArray.get(r.verticalPlacedTextSymbolIndex).hidden=i||v?1:0);const n=this.variableOffsets[r.crossTileID];n&&this.markUsedJustification(e,n.anchor,r,A);const a=this.placedOrientations[r.crossTileID];a&&(this.markUsedJustification(e,"left",r,a),this.markUsedOrientation(e,a,r))}if(_){const t=_t(c.icon),i=!(p&&r.verticalPlacedIconSymbolIndex&&y);r.placedIconSymbolIndex>=0&&(m(e.icon,r.numIconVertices,i?t:At),e.icon.placedSymbolArray.get(r.placedIconSymbolIndex).hidden=c.icon.isHidden()),r.verticalPlacedIconSymbolIndex>=0&&(m(e.icon,r.numVerticalIconVertices,i?At:t),e.icon.placedSymbolArray.get(r.verticalPlacedIconSymbolIndex).hidden=c.icon.isHidden())}const x=g&&g.has(i)?g.get(i):{text:null,icon:null};if(e.hasIconCollisionBoxData()||e.hasTextCollisionBoxData()){const n=e.collisionArrays[i];if(n){let i=new t.P(0,0);if(n.textBox||n.verticalTextBox){let t=!0;if(u){const e=this.variableOffsets[l];e?(i=at(e.anchor,e.width,e.height,e.textOffset,e.textBoxScale),h&&i._rotate(d?-this.transform.bearingInRadians:this.transform.bearingInRadians)):t=!1}if(n.textBox||n.verticalTextBox){let r;n.textBox&&(r=y),n.verticalTextBox&&(r=v),ct(e.textCollisionBox.collisionVertexArray,c.text.placed,!t||r,x.text,i.x,i.y)}}if(n.iconBox||n.verticalIconBox){const t=Boolean(!v&&n.verticalIconBox);let r;n.iconBox&&(r=t),n.verticalIconBox&&(r=!t),ct(e.iconCollisionBox.collisionVertexArray,c.icon.placed,r,x.icon,p?i.x:0,p?i.y:0)}}}}if(e.sortFeatures(-this.transform.bearingInRadians),this.retainedQueryData[e.bucketInstanceId]&&(this.retainedQueryData[e.bucketInstanceId].featureSortOrder=e.featureSortOrder),e.hasTextData()&&e.text.opacityVertexBuffer&&e.text.opacityVertexBuffer.updateData(e.text.opacityVertexArray),e.hasIconData()&&e.icon.opacityVertexBuffer&&e.icon.opacityVertexBuffer.updateData(e.icon.opacityVertexArray),e.hasIconCollisionBoxData()&&e.iconCollisionBox.collisionVertexBuffer&&e.iconCollisionBox.collisionVertexBuffer.updateData(e.iconCollisionBox.collisionVertexArray),e.hasTextCollisionBoxData()&&e.textCollisionBox.collisionVertexBuffer&&e.textCollisionBox.collisionVertexBuffer.updateData(e.textCollisionBox.collisionVertexArray),e.text.opacityVertexArray.length!==e.text.layoutVertexArray.length/4)throw new Error(`bucket.text.opacityVertexArray.length (= ${e.text.opacityVertexArray.length}) !== bucket.text.layoutVertexArray.length (= ${e.text.layoutVertexArray.length}) / 4`);if(e.icon.opacityVertexArray.length!==e.icon.layoutVertexArray.length/4)throw new Error(`bucket.icon.opacityVertexArray.length (= ${e.icon.opacityVertexArray.length}) !== bucket.icon.layoutVertexArray.length (= ${e.icon.layoutVertexArray.length}) / 4`);e.bucketInstanceId in this.collisionCircleArrays&&(e.collisionCircleArray=this.collisionCircleArrays[e.bucketInstanceId],delete this.collisionCircleArrays[e.bucketInstanceId])}symbolFadeChange(e){return 0===this.fadeDuration?1:(e-this.commitTime)/this.fadeDuration+this.prevZoomAdjustment}zoomAdjustment(e){return Math.max(0,(this.transform.zoom-e)/1.5)}hasTransitions(e){return this.stale||e-this.lastPlacementChangeTimee}setStale(){this.stale=!0}}function ct(e,t,i,n,r,o){n&&0!==n.length||(n=[0,0,0,0]);const s=n[0]-et,a=n[1]-et,l=n[2]-et,c=n[3]-et;e.emplaceBack(t?1:0,i?1:0,r||0,o||0,s,a),e.emplaceBack(t?1:0,i?1:0,r||0,o||0,l,a),e.emplaceBack(t?1:0,i?1:0,r||0,o||0,l,c),e.emplaceBack(t?1:0,i?1:0,r||0,o||0,s,c)}const ut=Math.pow(2,25),ht=Math.pow(2,24),dt=Math.pow(2,17),pt=Math.pow(2,16),ft=Math.pow(2,9),mt=Math.pow(2,8),gt=Math.pow(2,1);function _t(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*ut+t*ht+i*dt+t*pt+i*ft+t*mt+i*gt+t}const At=0;class yt{constructor(e){this._sortAcrossTiles="viewport-y"!==e.layout.get("symbol-z-order")&&!e.layout.get("symbol-sort-key").isConstant(),this._currentTileIndex=0,this._currentPartIndex=0,this._seenCrossTileIDs={},this._bucketParts=[]}continuePlacement(e,t,i,n,r){const o=this._bucketParts;for(;this._currentTileIndexe.sortKey-t.sortKey));this._currentPartIndex!this._forceFullPlacement&&c()-n>2;for(;this._currentPlacementIndex>=0;){const n=t[e[this._currentPlacementIndex]],o=this.placement.collisionIndex.transform.zoom;if("symbol"===n.type&&(!n.minzoom||n.minzoom<=o)&&(!n.maxzoom||n.maxzoom>o)){if(this._inProgressLayer||(this._inProgressLayer=new yt(n)),this._inProgressLayer.continuePlacement(i[n.source],this.placement,this._showCollisionBoxes,n,r))return;delete this._inProgressLayer}this._currentPlacementIndex--}this._done=!0}commit(e){return this.placement.commit(e),this.placement}}const xt=512/t.a4/2;class bt{constructor(e,i,n){this.tileID=e,this.bucketInstanceId=n,this._symbolsByKey={};const r=new Map;for(let e=0;e({x:Math.floor(e.anchorX*xt),y:Math.floor(e.anchorY*xt)})),crossTileIDs:i.map(e=>e.crossTileID)};if(n.positions.length>128){const e=new t.aS(n.positions.length,16,Uint16Array);for(const{x:t,y:i}of n.positions)e.add(t,i);e.finish(),delete n.positions,n.index=e}this._symbolsByKey[e]=n}}getScaledCoordinates(e,i){const{x:n,y:r,z:o}=this.tileID.canonical,{x:s,y:a,z:l}=i.canonical,c=xt/Math.pow(2,l-o),u=(a*t.a4+e.anchorY)*c,h=r*t.a4*xt;return{x:Math.floor((s*t.a4+e.anchorX)*c-n*t.a4*xt),y:Math.floor(u-h)}}findMatches(e,t,i){const n=this.tileID.canonical.ze)}}class wt{constructor(){this.maxCrossTileID=0}generate(){return++this.maxCrossTileID}}class Tt{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],n={};for(const e in i){const r=i[e];r.tileID=r.tileID.unwrapTo(r.tileID.wrap+t),n[r.tileID.key]=r}this.indexes[e]=n}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;ee.overscaledZ)for(const i in r){const o=r[i];o.tileID.isChildOf(e)&&o.findMatches(t.symbolInstances,e,n)}else{const o=r[e.scaledTo(Number(i)).key];o&&o.findMatches(t.symbolInstances,e,n)}}for(let e=0;e{t[e]=!0});for(const e in this.layerIndexes)t[e]||delete this.layerIndexes[e]}}var Ct="void main() {fragColor=vec4(1.0);}";const St={prelude:Bt("#ifdef GL_ES\nprecision mediump float;\n#else\n#if !defined(lowp)\n#define lowp\n#endif\n#if !defined(mediump)\n#define mediump\n#endif\n#if !defined(highp)\n#define highp\n#endif\n#endif\nout highp vec4 fragColor;","#ifdef GL_ES\nprecision highp float;\n#else\n#if !defined(lowp)\n#define lowp\n#endif\n#if !defined(mediump)\n#define mediump\n#endif\n#if !defined(highp)\n#define highp\n#endif\n#endif\nvec2 unpack_float(const float packedValue) {int packedIntValue=int(packedValue);int v0=packedIntValue/256;return vec2(v0,packedIntValue-v0*256);}vec2 unpack_opacity(const float packedOpacity) {int intOpacity=int(packedOpacity)/2;return vec2(float(intOpacity)/127.0,mod(packedOpacity,2.0));}vec4 decode_color(const vec2 encodedColor) {return vec4(unpack_float(encodedColor[0])/255.0,unpack_float(encodedColor[1])/255.0\n);}float unpack_mix_vec2(const vec2 packedValue,const float t) {return mix(packedValue[0],packedValue[1],t);}vec4 unpack_mix_color(const vec4 packedColors,const float t) {vec4 minColor=decode_color(vec2(packedColors[0],packedColors[1]));vec4 maxColor=decode_color(vec2(packedColors[2],packedColors[3]));return mix(minColor,maxColor,t);}vec2 get_pattern_pos(const vec2 pixel_coord_upper,const vec2 pixel_coord_lower,const vec2 pattern_size,const float tile_units_to_pixels,const vec2 pos) {vec2 offset=mod(mod(mod(pixel_coord_upper,pattern_size)*256.0,pattern_size)*256.0+pixel_coord_lower,pattern_size);return (tile_units_to_pixels*pos+offset)/pattern_size;}mat3 rotationMatrixFromAxisAngle(vec3 u,float angle) {float c=cos(angle);float s=sin(angle);float c2=1.0-c;return mat3(u.x*u.x*c2+ c,u.x*u.y*c2-u.z*s,u.x*u.z*c2+u.y*s,u.y*u.x*c2+u.z*s,u.y*u.y*c2+ c,u.y*u.z*c2-u.x*s,u.z*u.x*c2-u.y*s,u.z*u.y*c2+u.x*s,u.z*u.z*c2+ c\n);}\n#ifdef TERRAIN3D\nuniform sampler2D u_terrain;uniform float u_terrain_dim;uniform mat4 u_terrain_matrix;uniform vec4 u_terrain_unpack;uniform float u_terrain_exaggeration;uniform highp sampler2D u_depth;\n#endif\nconst highp vec4 bitSh=vec4(256.*256.*256.,256.*256.,256.,1.);const highp vec4 bitShifts=vec4(1.)/bitSh;highp float unpack(highp vec4 color) {return dot(color,bitShifts);}highp float depthOpacity(vec3 frag) {\n#ifdef TERRAIN3D\nhighp float d=unpack(texture(u_depth,frag.xy*0.5+0.5))+0.0001-frag.z;return 1.0-max(0.0,min(1.0,-d*500.0));\n#else\nreturn 1.0;\n#endif\n}float calculate_visibility(vec4 pos) {\n#ifdef TERRAIN3D\nvec3 frag=pos.xyz/pos.w;highp float d=depthOpacity(frag);if (d > 0.95) return 1.0;return (d+depthOpacity(frag+vec3(0.0,0.01,0.0)))/2.0;\n#else\nreturn 1.0;\n#endif\n}float ele(vec2 pos) {\n#ifdef TERRAIN3D\nvec4 rgb=(texture(u_terrain,pos)*255.0)*u_terrain_unpack;return rgb.r+rgb.g+rgb.b-u_terrain_unpack.a;\n#else\nreturn 0.0;\n#endif\n}float get_elevation(vec2 pos) {\n#ifdef TERRAIN3D\n#ifdef GLOBE\nif ((pos.y <-32767.5) || (pos.y > 32766.5)) {return 0.0;}\n#endif\nvec2 coord=(u_terrain_matrix*vec4(pos,0.0,1.0)).xy*u_terrain_dim+1.0;vec2 f=fract(coord);vec2 c=(floor(coord)+0.5)/(u_terrain_dim+2.0);float d=1.0/(u_terrain_dim+2.0);float tl=ele(c);float tr=ele(c+vec2(d,0.0));float bl=ele(c+vec2(0.0,d));float br=ele(c+vec2(d,d));float elevation=mix(mix(tl,tr,f.x),mix(bl,br,f.x),f.y);return elevation*u_terrain_exaggeration;\n#else\nreturn 0.0;\n#endif\n}const float PI=3.141592653589793;uniform mat4 u_projection_matrix;"),projectionMercator:Bt("","float projectLineThickness(float tileY) {return 1.0;}float projectCircleRadius(float tileY) {return 1.0;}vec4 projectTile(vec2 p) {vec4 result=u_projection_matrix*vec4(p,0.0,1.0);return result;}vec4 projectTile(vec2 p,vec2 rawPos) {vec4 result=u_projection_matrix*vec4(p,0.0,1.0);if (rawPos.y <-32767.5 || rawPos.y > 32766.5) {result.z=-10000000.0;}return result;}vec4 projectTileWithElevation(vec2 posInTile,float elevation) {return u_projection_matrix*vec4(posInTile,elevation,1.0);}vec4 projectTileFor3D(vec2 posInTile,float elevation) {return projectTileWithElevation(posInTile,elevation);}"),projectionGlobe:Bt("","#define GLOBE_RADIUS 6371008.8\nuniform highp vec4 u_projection_tile_mercator_coords;uniform highp vec4 u_projection_clipping_plane;uniform highp float u_projection_transition;uniform mat4 u_projection_fallback_matrix;vec3 globeRotateVector(vec3 vec,vec2 angles) {vec3 axisRight=vec3(vec.z,0.0,-vec.x);vec3 axisUp=cross(axisRight,vec);axisRight=normalize(axisRight);axisUp=normalize(axisUp);vec2 t=tan(angles);return normalize(vec+axisRight*t.x+axisUp*t.y);}mat3 globeGetRotationMatrix(vec3 spherePos) {vec3 axisRight=vec3(spherePos.z,0.0,-spherePos.x);vec3 axisDown=cross(axisRight,spherePos);axisRight=normalize(axisRight);axisDown=normalize(axisDown);return mat3(axisRight,axisDown,spherePos\n);}float circumferenceRatioAtTileY(float tileY) {float mercator_pos_y=u_projection_tile_mercator_coords.y+u_projection_tile_mercator_coords.w*tileY;float spherical_y=2.0*atan(exp(PI-(mercator_pos_y*PI*2.0)))-PI*0.5;return cos(spherical_y);}float projectLineThickness(float tileY) {float thickness=1.0/circumferenceRatioAtTileY(tileY); \nif (u_projection_transition < 0.999) {return mix(1.0,thickness,u_projection_transition);} else {return thickness;}}vec3 projectToSphere(vec2 translatedPos,vec2 rawPos) {vec2 mercator_pos=u_projection_tile_mercator_coords.xy+u_projection_tile_mercator_coords.zw*translatedPos;vec2 spherical;spherical.x=mercator_pos.x*PI*2.0+PI;spherical.y=2.0*atan(exp(PI-(mercator_pos.y*PI*2.0)))-PI*0.5;float len=cos(spherical.y);vec3 pos=vec3(sin(spherical.x)*len,sin(spherical.y),cos(spherical.x)*len\n);if (rawPos.y <-32767.5) {pos=vec3(0.0,1.0,0.0);}if (rawPos.y > 32766.5) {pos=vec3(0.0,-1.0,0.0);}return pos;}vec3 projectToSphere(vec2 posInTile) {return projectToSphere(posInTile,vec2(0.0,0.0));}float globeComputeClippingZ(vec3 spherePos) {return (1.0-(dot(spherePos,u_projection_clipping_plane.xyz)+u_projection_clipping_plane.w));}vec4 interpolateProjection(vec2 posInTile,vec3 spherePos,float elevation) {vec3 elevatedPos=spherePos*(1.0+elevation/GLOBE_RADIUS);vec4 globePosition=u_projection_matrix*vec4(elevatedPos,1.0);globePosition.z=globeComputeClippingZ(elevatedPos)*globePosition.w;if (u_projection_transition > 0.999) {return globePosition;}vec4 flatPosition=u_projection_fallback_matrix*vec4(posInTile,elevation,1.0);const float z_globeness_threshold=0.2;vec4 result=globePosition;result.z=mix(0.0,globePosition.z,clamp((u_projection_transition-z_globeness_threshold)/(1.0-z_globeness_threshold),0.0,1.0));result.xyw=mix(flatPosition.xyw,globePosition.xyw,u_projection_transition);if ((posInTile.y <-32767.5) || (posInTile.y > 32766.5)) {result=globePosition;const float poles_hidden_anim_percentage=0.02;result.z=mix(globePosition.z,100.0,pow(max((1.0-u_projection_transition)/poles_hidden_anim_percentage,0.0),8.0));}return result;}vec4 interpolateProjectionFor3D(vec2 posInTile,vec3 spherePos,float elevation) {vec3 elevatedPos=spherePos*(1.0+elevation/GLOBE_RADIUS);vec4 globePosition=u_projection_matrix*vec4(elevatedPos,1.0);if (u_projection_transition > 0.999) {return globePosition;}vec4 fallbackPosition=u_projection_fallback_matrix*vec4(posInTile,elevation,1.0);return mix(fallbackPosition,globePosition,u_projection_transition);}vec4 projectTile(vec2 posInTile) {return interpolateProjection(posInTile,projectToSphere(posInTile),0.0);}vec4 projectTile(vec2 posInTile,vec2 rawPos) {return interpolateProjection(posInTile,projectToSphere(posInTile,rawPos),0.0);}vec4 projectTileWithElevation(vec2 posInTile,float elevation) {return interpolateProjection(posInTile,projectToSphere(posInTile),elevation);}vec4 projectTileFor3D(vec2 posInTile,float elevation) {vec3 spherePos=projectToSphere(posInTile,posInTile);return interpolateProjectionFor3D(posInTile,spherePos,elevation);}"),background:Bt("uniform vec4 u_color;uniform float u_opacity;void main() {fragColor=u_color*u_opacity;\n#ifdef OVERDRAW_INSPECTOR\nfragColor=vec4(1.0);\n#endif\n}","in vec2 a_pos;void main() {gl_Position=projectTile(a_pos);}"),backgroundPattern:Bt("uniform vec2 u_pattern_tl_a;uniform vec2 u_pattern_br_a;uniform vec2 u_pattern_tl_b;uniform vec2 u_pattern_br_b;uniform vec2 u_texsize;uniform float u_mix;uniform float u_opacity;uniform sampler2D u_image;in vec2 v_pos_a;in vec2 v_pos_b;void main() {vec2 imagecoord=mod(v_pos_a,1.0);vec2 pos=mix(u_pattern_tl_a/u_texsize,u_pattern_br_a/u_texsize,imagecoord);vec4 color1=texture(u_image,pos);vec2 imagecoord_b=mod(v_pos_b,1.0);vec2 pos2=mix(u_pattern_tl_b/u_texsize,u_pattern_br_b/u_texsize,imagecoord_b);vec4 color2=texture(u_image,pos2);fragColor=mix(color1,color2,u_mix)*u_opacity;\n#ifdef OVERDRAW_INSPECTOR\nfragColor=vec4(1.0);\n#endif\n}","uniform vec2 u_pattern_size_a;uniform vec2 u_pattern_size_b;uniform vec2 u_pixel_coord_upper;uniform vec2 u_pixel_coord_lower;uniform float u_scale_a;uniform float u_scale_b;uniform float u_tile_units_to_pixels;in vec2 a_pos;out vec2 v_pos_a;out vec2 v_pos_b;void main() {gl_Position=projectTile(a_pos);v_pos_a=get_pattern_pos(u_pixel_coord_upper,u_pixel_coord_lower,u_scale_a*u_pattern_size_a,u_tile_units_to_pixels,a_pos);v_pos_b=get_pattern_pos(u_pixel_coord_upper,u_pixel_coord_lower,u_scale_b*u_pattern_size_b,u_tile_units_to_pixels,a_pos);}"),circle:Bt("in vec3 v_data;in float v_visibility;\n#pragma mapbox: define highp vec4 color\n#pragma mapbox: define mediump float radius\n#pragma mapbox: define lowp float blur\n#pragma mapbox: define lowp float opacity\n#pragma mapbox: define highp vec4 stroke_color\n#pragma mapbox: define mediump float stroke_width\n#pragma mapbox: define lowp float stroke_opacity\nvoid main() {\n#pragma mapbox: initialize highp vec4 color\n#pragma mapbox: initialize mediump float radius\n#pragma mapbox: initialize lowp float blur\n#pragma mapbox: initialize lowp float opacity\n#pragma mapbox: initialize highp vec4 stroke_color\n#pragma mapbox: initialize mediump float stroke_width\n#pragma mapbox: initialize lowp float stroke_opacity\nvec2 extrude=v_data.xy;float extrude_length=length(extrude);float antialiased_blur=v_data.z;float opacity_t=smoothstep(0.0,antialiased_blur,extrude_length-1.0);float color_t=stroke_width < 0.01 ? 0.0 : smoothstep(antialiased_blur,0.0,extrude_length-radius/(radius+stroke_width));fragColor=v_visibility*opacity_t*mix(color*opacity,stroke_color*stroke_opacity,color_t);const float epsilon=0.5/255.0;if (fragColor.r < epsilon && fragColor.g < epsilon && fragColor.b < epsilon && fragColor.a < epsilon) {discard;}\n#ifdef OVERDRAW_INSPECTOR\nfragColor=vec4(1.0);\n#endif\n}","uniform bool u_scale_with_map;uniform bool u_pitch_with_map;uniform vec2 u_extrude_scale;uniform highp float u_globe_extrude_scale;uniform lowp float u_device_pixel_ratio;uniform highp float u_camera_to_center_distance;uniform vec2 u_translate;in vec2 a_pos;out vec3 v_data;out float v_visibility;\n#pragma mapbox: define highp vec4 color\n#pragma mapbox: define mediump float radius\n#pragma mapbox: define lowp float blur\n#pragma mapbox: define lowp float opacity\n#pragma mapbox: define highp vec4 stroke_color\n#pragma mapbox: define mediump float stroke_width\n#pragma mapbox: define lowp float stroke_opacity\nvoid main(void) {\n#pragma mapbox: initialize highp vec4 color\n#pragma mapbox: initialize mediump float radius\n#pragma mapbox: initialize lowp float blur\n#pragma mapbox: initialize lowp float opacity\n#pragma mapbox: initialize highp vec4 stroke_color\n#pragma mapbox: initialize mediump float stroke_width\n#pragma mapbox: initialize lowp float stroke_opacity\nvec2 pos_raw=a_pos+32768.0;vec2 extrude=vec2(mod(pos_raw,8.0)/7.0*2.0-1.0);vec2 circle_center=floor(pos_raw/8.0)+u_translate;float ele=get_elevation(circle_center);v_visibility=calculate_visibility(projectTileWithElevation(circle_center,ele));if (u_pitch_with_map) {\n#ifdef GLOBE\nvec3 center_vector=projectToSphere(circle_center);\n#endif\nfloat angle_scale=u_globe_extrude_scale;vec2 corner_position=circle_center;if (u_scale_with_map) {angle_scale*=(radius+stroke_width);corner_position+=extrude*u_extrude_scale*(radius+stroke_width);} else {\n#ifdef GLOBE\nvec4 projected_center=interpolateProjection(circle_center,center_vector,ele);\n#else\nvec4 projected_center=projectTileWithElevation(circle_center,ele);\n#endif\ncorner_position+=extrude*u_extrude_scale*(radius+stroke_width)*(projected_center.w/u_camera_to_center_distance);angle_scale*=(radius+stroke_width)*(projected_center.w/u_camera_to_center_distance);}\n#ifdef GLOBE\nvec2 angles=extrude*angle_scale;vec3 corner_vector=globeRotateVector(center_vector,angles);gl_Position=interpolateProjection(corner_position,corner_vector,ele);\n#else\ngl_Position=projectTileWithElevation(corner_position,ele);\n#endif\n} else {gl_Position=projectTileWithElevation(circle_center,ele);if (gl_Position.z/gl_Position.w > 1.0) {gl_Position.xy=vec2(10000.0);}if (u_scale_with_map) {gl_Position.xy+=extrude*(radius+stroke_width)*u_extrude_scale*u_camera_to_center_distance;} else {gl_Position.xy+=extrude*(radius+stroke_width)*u_extrude_scale*gl_Position.w;}}float antialiasblur=-max(1.0/u_device_pixel_ratio/(radius+stroke_width),blur);v_data=vec3(extrude.x,extrude.y,antialiasblur);}"),clippingMask:Bt(Ct,"in vec2 a_pos;void main() {gl_Position=projectTile(a_pos);}"),heatmap:Bt("uniform highp float u_intensity;in vec2 v_extrude;\n#pragma mapbox: define highp float weight\n#define GAUSS_COEF 0.3989422804014327\nvoid main() {\n#pragma mapbox: initialize highp float weight\nfloat d=-0.5*3.0*3.0*dot(v_extrude,v_extrude);float val=weight*u_intensity*GAUSS_COEF*exp(d);fragColor=vec4(val,1.0,1.0,1.0);\n#ifdef OVERDRAW_INSPECTOR\nfragColor=vec4(1.0);\n#endif\n}","uniform float u_extrude_scale;uniform float u_opacity;uniform float u_intensity;uniform highp float u_globe_extrude_scale;in vec2 a_pos;out vec2 v_extrude;\n#pragma mapbox: define highp float weight\n#pragma mapbox: define mediump float radius\nconst highp float ZERO=1.0/255.0/16.0;\n#define GAUSS_COEF 0.3989422804014327\nvoid main(void) {\n#pragma mapbox: initialize highp float weight\n#pragma mapbox: initialize mediump float radius\nvec2 pos_raw=a_pos+32768.0;vec2 unscaled_extrude=vec2(mod(pos_raw,8.0)/7.0*2.0-1.0);float S=sqrt(-2.0*log(ZERO/weight/u_intensity/GAUSS_COEF))/3.0;v_extrude=S*unscaled_extrude;vec2 extrude=v_extrude*radius*u_extrude_scale;vec2 circle_center=floor(pos_raw/8.0);\n#ifdef GLOBE\nvec2 angles=v_extrude*radius*u_globe_extrude_scale;vec3 center_vector=projectToSphere(circle_center);vec3 corner_vector=globeRotateVector(center_vector,angles);gl_Position=interpolateProjection(circle_center+extrude,corner_vector,0.0);\n#else\ngl_Position=projectTileFor3D(circle_center+extrude,get_elevation(circle_center));\n#endif\n}"),heatmapTexture:Bt("uniform sampler2D u_image;uniform sampler2D u_color_ramp;uniform float u_opacity;in vec2 v_pos;void main() {float t=texture(u_image,v_pos).r;vec4 color=texture(u_color_ramp,vec2(t,0.5));fragColor=color*u_opacity;\n#ifdef OVERDRAW_INSPECTOR\nfragColor=vec4(0.0);\n#endif\n}","uniform mat4 u_matrix;uniform vec2 u_world;in vec2 a_pos;out vec2 v_pos;void main() {gl_Position=u_matrix*vec4(a_pos*u_world,0,1);v_pos.x=a_pos.x;v_pos.y=1.0-a_pos.y;}"),collisionBox:Bt("in float v_placed;in float v_notUsed;void main() {float alpha=0.5;fragColor=vec4(1.0,0.0,0.0,1.0)*alpha;if (v_placed > 0.5) {fragColor=vec4(0.0,0.0,1.0,0.5)*alpha;}if (v_notUsed > 0.5) {fragColor*=.1;}}","in vec2 a_anchor_pos;in vec2 a_placed;in vec2 a_box_real;uniform vec2 u_pixel_extrude_scale;out float v_placed;out float v_notUsed;void main() {gl_Position=projectTileWithElevation(a_anchor_pos,get_elevation(a_anchor_pos));gl_Position.xy=((a_box_real+0.5)*u_pixel_extrude_scale*2.0-1.0)*vec2(1.0,-1.0)*gl_Position.w;if (gl_Position.z/gl_Position.w < 1.1) {gl_Position.z=0.5;}v_placed=a_placed.x;v_notUsed=a_placed.y;}"),collisionCircle:Bt("in float v_radius;in vec2 v_extrude;in float v_collision;void main() {float alpha=0.5;float stroke_radius=0.9;float distance_to_center=length(v_extrude);float distance_to_edge=abs(distance_to_center-v_radius);float opacity_t=smoothstep(-stroke_radius,0.0,-distance_to_edge);vec4 color=mix(vec4(0.0,0.0,1.0,0.5),vec4(1.0,0.0,0.0,1.0),v_collision);fragColor=color*alpha*opacity_t;}","in vec2 a_pos;in float a_radius;in vec2 a_flags;uniform vec2 u_viewport_size;out float v_radius;out vec2 v_extrude;out float v_collision;void main() {float radius=a_radius;float collision=a_flags.x;float vertexIdx=a_flags.y;vec2 quadVertexOffset=vec2(mix(-1.0,1.0,float(vertexIdx >=2.0)),mix(-1.0,1.0,float(vertexIdx >=1.0 && vertexIdx <=2.0)));vec2 quadVertexExtent=quadVertexOffset*radius;float padding_factor=1.2;v_radius=radius;v_extrude=quadVertexExtent*padding_factor;v_collision=collision;gl_Position=vec4((a_pos/u_viewport_size*2.0-1.0)*vec2(1.0,-1.0),0.0,1.0)+vec4(quadVertexExtent*padding_factor/u_viewport_size*2.0,0.0,0.0);}"),colorRelief:Bt("#ifdef GL_ES\nprecision highp float;\n#endif\nuniform sampler2D u_image;uniform vec4 u_unpack;uniform sampler2D u_elevation_stops;uniform sampler2D u_color_stops;uniform int u_color_ramp_size;uniform float u_opacity;in vec2 v_pos;float getElevation(vec2 coord) {vec4 data=texture(u_image,coord)*255.0;data.a=-1.0;return dot(data,u_unpack);}float getElevationStop(int stop) {float x=(float(stop)+0.5)/float(u_color_ramp_size);vec4 data=texture(u_elevation_stops,vec2(x,0))*255.0;data.a=-1.0;return dot(data,u_unpack);}void main() {float el=getElevation(v_pos);int r=(u_color_ramp_size-1);int l=0;float el_l=getElevationStop(l);float el_r=getElevationStop(r);while(r-l > 1){int m=(r+l)/2;float el_m=getElevationStop(m);if(el < el_m){r=m;el_r=el_m;}else\n{l=m;el_l=el_m;}}float x=(float(l)+(el-el_l)/(el_r-el_l)+0.5)/float(u_color_ramp_size);fragColor=u_opacity*texture(u_color_stops,vec2(x,0));\n#ifdef OVERDRAW_INSPECTOR\nfragColor=vec4(1.0);\n#endif\n}","uniform vec2 u_dimension;in vec2 a_pos;out vec2 v_pos;void main() {gl_Position=projectTile(a_pos,a_pos);highp vec2 epsilon=1.0/u_dimension;float scale=(u_dimension.x-2.0)/u_dimension.x;v_pos=(a_pos/8192.0)*scale+epsilon;if (a_pos.y <-32767.5) {v_pos.y=0.0;}if (a_pos.y > 32766.5) {v_pos.y=1.0;}}"),debug:Bt("uniform highp vec4 u_color;uniform sampler2D u_overlay;in vec2 v_uv;void main() {vec4 overlay_color=texture(u_overlay,v_uv);fragColor=mix(u_color,overlay_color,overlay_color.a);}","in vec2 a_pos;out vec2 v_uv;uniform float u_overlay_scale;void main() {v_uv=a_pos/8192.0;gl_Position=projectTileWithElevation(a_pos*u_overlay_scale,get_elevation(a_pos));}"),depth:Bt(Ct,"in vec2 a_pos;void main() {\n#ifdef GLOBE\ngl_Position=projectTileFor3D(a_pos,0.0);\n#else\ngl_Position=u_projection_matrix*vec4(a_pos,0.0,1.0);\n#endif\n}"),fill:Bt("#pragma mapbox: define highp vec4 color\n#pragma mapbox: define lowp float opacity\nvoid main() {\n#pragma mapbox: initialize highp vec4 color\n#pragma mapbox: initialize lowp float opacity\nfragColor=color*opacity;\n#ifdef OVERDRAW_INSPECTOR\nfragColor=vec4(1.0);\n#endif\n}","uniform vec2 u_fill_translate;in vec2 a_pos;\n#pragma mapbox: define highp vec4 color\n#pragma mapbox: define lowp float opacity\nvoid main() {\n#pragma mapbox: initialize highp vec4 color\n#pragma mapbox: initialize lowp float opacity\ngl_Position=projectTile(a_pos+u_fill_translate,a_pos);}"),fillOutline:Bt("in vec2 v_pos;\n#ifdef GLOBE\nin float v_depth;\n#endif\n#pragma mapbox: define highp vec4 outline_color\n#pragma mapbox: define lowp float opacity\nvoid main() {\n#pragma mapbox: initialize highp vec4 outline_color\n#pragma mapbox: initialize lowp float opacity\nfloat dist=length(v_pos-gl_FragCoord.xy);float alpha=1.0-smoothstep(0.0,1.0,dist);fragColor=outline_color*(alpha*opacity);\n#ifdef GLOBE\nif (v_depth > 1.0) {discard;}\n#endif\n#ifdef OVERDRAW_INSPECTOR\nfragColor=vec4(1.0);\n#endif\n}","uniform vec2 u_world;uniform vec2 u_fill_translate;in vec2 a_pos;out vec2 v_pos;\n#ifdef GLOBE\nout float v_depth;\n#endif\n#pragma mapbox: define highp vec4 outline_color\n#pragma mapbox: define lowp float opacity\nvoid main() {\n#pragma mapbox: initialize highp vec4 outline_color\n#pragma mapbox: initialize lowp float opacity\ngl_Position=projectTile(a_pos+u_fill_translate,a_pos);v_pos=(gl_Position.xy/gl_Position.w+1.0)/2.0*u_world;\n#ifdef GLOBE\nv_depth=gl_Position.z/gl_Position.w;\n#endif\n}"),fillOutlinePattern:Bt("uniform vec2 u_texsize;uniform sampler2D u_image;uniform float u_fade;in vec2 v_pos_a;in vec2 v_pos_b;in vec2 v_pos;\n#ifdef GLOBE\nin float v_depth;\n#endif\n#pragma mapbox: define lowp float opacity\n#pragma mapbox: define lowp vec4 pattern_from\n#pragma mapbox: define lowp vec4 pattern_to\nvoid main() {\n#pragma mapbox: initialize lowp float opacity\n#pragma mapbox: initialize mediump vec4 pattern_from\n#pragma mapbox: initialize mediump vec4 pattern_to\nvec2 pattern_tl_a=pattern_from.xy;vec2 pattern_br_a=pattern_from.zw;vec2 pattern_tl_b=pattern_to.xy;vec2 pattern_br_b=pattern_to.zw;vec2 imagecoord=mod(v_pos_a,1.0);vec2 pos=mix(pattern_tl_a/u_texsize,pattern_br_a/u_texsize,imagecoord);vec4 color1=texture(u_image,pos);vec2 imagecoord_b=mod(v_pos_b,1.0);vec2 pos2=mix(pattern_tl_b/u_texsize,pattern_br_b/u_texsize,imagecoord_b);vec4 color2=texture(u_image,pos2);float dist=length(v_pos-gl_FragCoord.xy);float alpha=1.0-smoothstep(0.0,1.0,dist);fragColor=mix(color1,color2,u_fade)*alpha*opacity;\n#ifdef GLOBE\nif (v_depth > 1.0) {discard;}\n#endif\n#ifdef OVERDRAW_INSPECTOR\nfragColor=vec4(1.0);\n#endif\n}","uniform vec2 u_world;uniform vec2 u_pixel_coord_upper;uniform vec2 u_pixel_coord_lower;uniform vec3 u_scale;uniform vec2 u_fill_translate;in vec2 a_pos;out vec2 v_pos_a;out vec2 v_pos_b;out vec2 v_pos;\n#ifdef GLOBE\nout float v_depth;\n#endif\n#pragma mapbox: define lowp float opacity\n#pragma mapbox: define lowp vec4 pattern_from\n#pragma mapbox: define lowp vec4 pattern_to\n#pragma mapbox: define lowp float pixel_ratio_from\n#pragma mapbox: define lowp float pixel_ratio_to\nvoid main() {\n#pragma mapbox: initialize lowp float opacity\n#pragma mapbox: initialize mediump vec4 pattern_from\n#pragma mapbox: initialize mediump vec4 pattern_to\n#pragma mapbox: initialize lowp float pixel_ratio_from\n#pragma mapbox: initialize lowp float pixel_ratio_to\nvec2 pattern_tl_a=pattern_from.xy;vec2 pattern_br_a=pattern_from.zw;vec2 pattern_tl_b=pattern_to.xy;vec2 pattern_br_b=pattern_to.zw;float tileRatio=u_scale.x;float fromScale=u_scale.y;float toScale=u_scale.z;gl_Position=projectTile(a_pos+u_fill_translate,a_pos);vec2 display_size_a=(pattern_br_a-pattern_tl_a)/pixel_ratio_from;vec2 display_size_b=(pattern_br_b-pattern_tl_b)/pixel_ratio_to;v_pos_a=get_pattern_pos(u_pixel_coord_upper,u_pixel_coord_lower,fromScale*display_size_a,tileRatio,a_pos);v_pos_b=get_pattern_pos(u_pixel_coord_upper,u_pixel_coord_lower,toScale*display_size_b,tileRatio,a_pos);v_pos=(gl_Position.xy/gl_Position.w+1.0)/2.0*u_world;\n#ifdef GLOBE\nv_depth=gl_Position.z/gl_Position.w;\n#endif\n}"),fillPattern:Bt("#ifdef GL_ES\nprecision highp float;\n#endif\nuniform vec2 u_texsize;uniform float u_fade;uniform sampler2D u_image;in vec2 v_pos_a;in vec2 v_pos_b;\n#pragma mapbox: define lowp float opacity\n#pragma mapbox: define lowp vec4 pattern_from\n#pragma mapbox: define lowp vec4 pattern_to\nvoid main() {\n#pragma mapbox: initialize lowp float opacity\n#pragma mapbox: initialize mediump vec4 pattern_from\n#pragma mapbox: initialize mediump vec4 pattern_to\nvec2 pattern_tl_a=pattern_from.xy;vec2 pattern_br_a=pattern_from.zw;vec2 pattern_tl_b=pattern_to.xy;vec2 pattern_br_b=pattern_to.zw;vec2 imagecoord=mod(v_pos_a,1.0);vec2 pos=mix(pattern_tl_a/u_texsize,pattern_br_a/u_texsize,imagecoord);vec4 color1=texture(u_image,pos);vec2 imagecoord_b=mod(v_pos_b,1.0);vec2 pos2=mix(pattern_tl_b/u_texsize,pattern_br_b/u_texsize,imagecoord_b);vec4 color2=texture(u_image,pos2);fragColor=mix(color1,color2,u_fade)*opacity;\n#ifdef OVERDRAW_INSPECTOR\nfragColor=vec4(1.0);\n#endif\n}","uniform vec2 u_pixel_coord_upper;uniform vec2 u_pixel_coord_lower;uniform vec3 u_scale;uniform vec2 u_fill_translate;in vec2 a_pos;out vec2 v_pos_a;out vec2 v_pos_b;\n#pragma mapbox: define lowp float opacity\n#pragma mapbox: define lowp vec4 pattern_from\n#pragma mapbox: define lowp vec4 pattern_to\n#pragma mapbox: define lowp float pixel_ratio_from\n#pragma mapbox: define lowp float pixel_ratio_to\nvoid main() {\n#pragma mapbox: initialize lowp float opacity\n#pragma mapbox: initialize mediump vec4 pattern_from\n#pragma mapbox: initialize mediump vec4 pattern_to\n#pragma mapbox: initialize lowp float pixel_ratio_from\n#pragma mapbox: initialize lowp float pixel_ratio_to\nvec2 pattern_tl_a=pattern_from.xy;vec2 pattern_br_a=pattern_from.zw;vec2 pattern_tl_b=pattern_to.xy;vec2 pattern_br_b=pattern_to.zw;float tileZoomRatio=u_scale.x;float fromScale=u_scale.y;float toScale=u_scale.z;vec2 display_size_a=(pattern_br_a-pattern_tl_a)/pixel_ratio_from;vec2 display_size_b=(pattern_br_b-pattern_tl_b)/pixel_ratio_to;gl_Position=projectTile(a_pos+u_fill_translate,a_pos);v_pos_a=get_pattern_pos(u_pixel_coord_upper,u_pixel_coord_lower,fromScale*display_size_a,tileZoomRatio,a_pos);v_pos_b=get_pattern_pos(u_pixel_coord_upper,u_pixel_coord_lower,toScale*display_size_b,tileZoomRatio,a_pos);}"),fillExtrusion:Bt("in vec4 v_color;void main() {fragColor=v_color;\n#ifdef OVERDRAW_INSPECTOR\nfragColor=vec4(1.0);\n#endif\n}","uniform vec3 u_lightcolor;uniform lowp vec3 u_lightpos;uniform lowp vec3 u_lightpos_globe;uniform lowp float u_lightintensity;uniform float u_vertical_gradient;uniform lowp float u_opacity;uniform vec2 u_fill_translate;in vec2 a_pos;in vec4 a_normal_ed;\n#ifdef TERRAIN3D\nin vec2 a_centroid;\n#endif\nout vec4 v_color;\n#pragma mapbox: define highp float base\n#pragma mapbox: define highp float height\n#pragma mapbox: define highp vec4 color\nvoid main() {\n#pragma mapbox: initialize highp float base\n#pragma mapbox: initialize highp float height\n#pragma mapbox: initialize highp vec4 color\nvec3 normal=a_normal_ed.xyz;\n#ifdef TERRAIN3D\nfloat height_terrain3d_offset=get_elevation(a_centroid);float base_terrain3d_offset=height_terrain3d_offset-(base > 0.0 ? 0.0 : 10.0);\n#else\nfloat height_terrain3d_offset=0.0;float base_terrain3d_offset=0.0;\n#endif\nbase=max(0.0,base)+base_terrain3d_offset;height=max(0.0,height)+height_terrain3d_offset;float t=mod(normal.x,2.0);float elevation=t > 0.0 ? height : base;vec2 posInTile=a_pos+u_fill_translate;\n#ifdef GLOBE\nvec3 spherePos=projectToSphere(posInTile,a_pos);gl_Position=interpolateProjectionFor3D(posInTile,spherePos,elevation);\n#else\ngl_Position=u_projection_matrix*vec4(posInTile,elevation,1.0);\n#endif\nfloat colorvalue=color.r*0.2126+color.g*0.7152+color.b*0.0722;v_color=vec4(0.0,0.0,0.0,1.0);vec4 ambientlight=vec4(0.03,0.03,0.03,1.0);color+=ambientlight;vec3 normalForLighting=normal/16384.0;float directional=clamp(dot(normalForLighting,u_lightpos),0.0,1.0);\n#ifdef GLOBE\nmat3 rotMatrix=globeGetRotationMatrix(spherePos);normalForLighting=rotMatrix*normalForLighting;directional=mix(directional,clamp(dot(normalForLighting,u_lightpos_globe),0.0,1.0),u_projection_transition);\n#endif\ndirectional=mix((1.0-u_lightintensity),max((1.0-colorvalue+u_lightintensity),1.0),directional);if (normal.y !=0.0) {directional*=((1.0-u_vertical_gradient)+(u_vertical_gradient*clamp((t+base)*pow(height/150.0,0.5),mix(0.7,0.98,1.0-u_lightintensity),1.0)));}v_color.r+=clamp(color.r*directional*u_lightcolor.r,mix(0.0,0.3,1.0-u_lightcolor.r),1.0);v_color.g+=clamp(color.g*directional*u_lightcolor.g,mix(0.0,0.3,1.0-u_lightcolor.g),1.0);v_color.b+=clamp(color.b*directional*u_lightcolor.b,mix(0.0,0.3,1.0-u_lightcolor.b),1.0);v_color*=u_opacity;}"),fillExtrusionPattern:Bt("uniform vec2 u_texsize;uniform float u_fade;uniform sampler2D u_image;in vec2 v_pos_a;in vec2 v_pos_b;in vec4 v_lighting;\n#pragma mapbox: define lowp float base\n#pragma mapbox: define lowp float height\n#pragma mapbox: define lowp vec4 pattern_from\n#pragma mapbox: define lowp vec4 pattern_to\n#pragma mapbox: define lowp float pixel_ratio_from\n#pragma mapbox: define lowp float pixel_ratio_to\nvoid main() {\n#pragma mapbox: initialize lowp float base\n#pragma mapbox: initialize lowp float height\n#pragma mapbox: initialize mediump vec4 pattern_from\n#pragma mapbox: initialize mediump vec4 pattern_to\n#pragma mapbox: initialize lowp float pixel_ratio_from\n#pragma mapbox: initialize lowp float pixel_ratio_to\nvec2 pattern_tl_a=pattern_from.xy;vec2 pattern_br_a=pattern_from.zw;vec2 pattern_tl_b=pattern_to.xy;vec2 pattern_br_b=pattern_to.zw;vec2 imagecoord=mod(v_pos_a,1.0);vec2 pos=mix(pattern_tl_a/u_texsize,pattern_br_a/u_texsize,imagecoord);vec4 color1=texture(u_image,pos);vec2 imagecoord_b=mod(v_pos_b,1.0);vec2 pos2=mix(pattern_tl_b/u_texsize,pattern_br_b/u_texsize,imagecoord_b);vec4 color2=texture(u_image,pos2);vec4 mixedColor=mix(color1,color2,u_fade);fragColor=mixedColor*v_lighting;\n#ifdef OVERDRAW_INSPECTOR\nfragColor=vec4(1.0);\n#endif\n}","uniform vec2 u_pixel_coord_upper;uniform vec2 u_pixel_coord_lower;uniform float u_height_factor;uniform vec3 u_scale;uniform float u_vertical_gradient;uniform lowp float u_opacity;uniform vec2 u_fill_translate;uniform vec3 u_lightcolor;uniform lowp vec3 u_lightpos;uniform lowp vec3 u_lightpos_globe;uniform lowp float u_lightintensity;in vec2 a_pos;in vec4 a_normal_ed;\n#ifdef TERRAIN3D\nin vec2 a_centroid;\n#endif\n#ifdef GLOBE\nout vec3 v_sphere_pos;\n#endif\nout vec2 v_pos_a;out vec2 v_pos_b;out vec4 v_lighting;\n#pragma mapbox: define lowp float base\n#pragma mapbox: define lowp float height\n#pragma mapbox: define lowp vec4 pattern_from\n#pragma mapbox: define lowp vec4 pattern_to\n#pragma mapbox: define lowp float pixel_ratio_from\n#pragma mapbox: define lowp float pixel_ratio_to\nvoid main() {\n#pragma mapbox: initialize lowp float base\n#pragma mapbox: initialize lowp float height\n#pragma mapbox: initialize mediump vec4 pattern_from\n#pragma mapbox: initialize mediump vec4 pattern_to\n#pragma mapbox: initialize lowp float pixel_ratio_from\n#pragma mapbox: initialize lowp float pixel_ratio_to\nvec2 pattern_tl_a=pattern_from.xy;vec2 pattern_br_a=pattern_from.zw;vec2 pattern_tl_b=pattern_to.xy;vec2 pattern_br_b=pattern_to.zw;float tileRatio=u_scale.x;float fromScale=u_scale.y;float toScale=u_scale.z;vec3 normal=a_normal_ed.xyz;float edgedistance=a_normal_ed.w;vec2 display_size_a=(pattern_br_a-pattern_tl_a)/pixel_ratio_from;vec2 display_size_b=(pattern_br_b-pattern_tl_b)/pixel_ratio_to;\n#ifdef TERRAIN3D\nfloat height_terrain3d_offset=get_elevation(a_centroid);float base_terrain3d_offset=height_terrain3d_offset-(base > 0.0 ? 0.0 : 10.0);\n#else\nfloat height_terrain3d_offset=0.0;float base_terrain3d_offset=0.0;\n#endif\nbase=max(0.0,base)+base_terrain3d_offset;height=max(0.0,height)+height_terrain3d_offset;float t=mod(normal.x,2.0);float elevation=t > 0.0 ? height : base;vec2 posInTile=a_pos+u_fill_translate;\n#ifdef GLOBE\nvec3 spherePos=projectToSphere(posInTile,a_pos);vec3 elevatedPos=spherePos*(1.0+elevation/GLOBE_RADIUS);v_sphere_pos=elevatedPos;gl_Position=interpolateProjectionFor3D(posInTile,spherePos,elevation);\n#else\ngl_Position=u_projection_matrix*vec4(posInTile,elevation,1.0);\n#endif\nvec2 pos=normal.x==1.0 && normal.y==0.0 && normal.z==16384.0\n? a_pos\n: vec2(edgedistance,elevation*u_height_factor);v_pos_a=get_pattern_pos(u_pixel_coord_upper,u_pixel_coord_lower,fromScale*display_size_a,tileRatio,pos);v_pos_b=get_pattern_pos(u_pixel_coord_upper,u_pixel_coord_lower,toScale*display_size_b,tileRatio,pos);v_lighting=vec4(0.0,0.0,0.0,1.0);float directional=clamp(dot(normal/16383.0,u_lightpos),0.0,1.0);directional=mix((1.0-u_lightintensity),max((0.5+u_lightintensity),1.0),directional);if (normal.y !=0.0) {directional*=((1.0-u_vertical_gradient)+(u_vertical_gradient*clamp((t+base)*pow(height/150.0,0.5),mix(0.7,0.98,1.0-u_lightintensity),1.0)));}v_lighting.rgb+=clamp(directional*u_lightcolor,mix(vec3(0.0),vec3(0.3),1.0-u_lightcolor),vec3(1.0));v_lighting*=u_opacity;}"),hillshadePrepare:Bt("#ifdef GL_ES\nprecision highp float;\n#endif\nuniform sampler2D u_image;in vec2 v_pos;uniform vec2 u_dimension;uniform float u_zoom;uniform vec4 u_unpack;float getElevation(vec2 coord,float bias) {vec4 data=texture(u_image,coord)*255.0;data.a=-1.0;return dot(data,u_unpack);}void main() {vec2 epsilon=1.0/u_dimension;float tileSize=u_dimension.x-2.0;float a=getElevation(v_pos+vec2(-epsilon.x,-epsilon.y),0.0);float b=getElevation(v_pos+vec2(0,-epsilon.y),0.0);float c=getElevation(v_pos+vec2(epsilon.x,-epsilon.y),0.0);float d=getElevation(v_pos+vec2(-epsilon.x,0),0.0);float e=getElevation(v_pos,0.0);float f=getElevation(v_pos+vec2(epsilon.x,0),0.0);float g=getElevation(v_pos+vec2(-epsilon.x,epsilon.y),0.0);float h=getElevation(v_pos+vec2(0,epsilon.y),0.0);float i=getElevation(v_pos+vec2(epsilon.x,epsilon.y),0.0);float exaggerationFactor=u_zoom < 2.0 ? 0.4 : u_zoom < 4.5 ? 0.35 : 0.3;float exaggeration=u_zoom < 15.0 ? (u_zoom-15.0)*exaggerationFactor : 0.0;vec2 deriv=vec2((c+f+f+i)-(a+d+d+g),(g+h+h+i)-(a+b+b+c))*tileSize/pow(2.0,exaggeration+(28.2562-u_zoom));fragColor=clamp(vec4(deriv.x/8.0+0.5,deriv.y/8.0+0.5,1.0,1.0),0.0,1.0);\n#ifdef OVERDRAW_INSPECTOR\nfragColor=vec4(1.0);\n#endif\n}","uniform mat4 u_matrix;uniform vec2 u_dimension;in vec2 a_pos;in vec2 a_texture_pos;out vec2 v_pos;void main() {gl_Position=u_matrix*vec4(a_pos,0,1);highp vec2 epsilon=1.0/u_dimension;float scale=(u_dimension.x-2.0)/u_dimension.x;v_pos=(a_texture_pos/8192.0)*scale+epsilon;}"),hillshade:Bt("uniform sampler2D u_image;in vec2 v_pos;uniform vec2 u_latrange;uniform float u_exaggeration;uniform vec4 u_accent;uniform int u_method;uniform float u_altitudes[NUM_ILLUMINATION_SOURCES];uniform float u_azimuths[NUM_ILLUMINATION_SOURCES];uniform vec4 u_shadows[NUM_ILLUMINATION_SOURCES];uniform vec4 u_highlights[NUM_ILLUMINATION_SOURCES];\n#define PI 3.141592653589793\n#define STANDARD 0\n#define COMBINED 1\n#define IGOR 2\n#define MULTIDIRECTIONAL 3\n#define BASIC 4\nfloat get_aspect(vec2 deriv){return deriv.x !=0.0 ? atan(deriv.y,-deriv.x) : PI/2.0*(deriv.y > 0.0 ? 1.0 :-1.0);}void igor_hillshade(vec2 deriv){deriv=deriv*u_exaggeration*2.0;float aspect=get_aspect(deriv);float azimuth=u_azimuths[0]+PI;float slope_stength=atan(length(deriv))*2.0/PI;float aspect_strength=1.0-abs(mod((aspect+azimuth)/PI+0.5,2.0)-1.0);float shadow_strength=slope_stength*aspect_strength;float highlight_strength=slope_stength*(1.0-aspect_strength);fragColor=u_shadows[0]*shadow_strength+u_highlights[0]*highlight_strength;}void standard_hillshade(vec2 deriv){float azimuth=u_azimuths[0]+PI;float slope=atan(0.625*length(deriv));float aspect=get_aspect(deriv);float intensity=u_exaggeration;float base=1.875-intensity*1.75;float maxValue=0.5*PI;float scaledSlope=intensity !=0.5 ? ((pow(base,slope)-1.0)/(pow(base,maxValue)-1.0))*maxValue : slope;float accent=cos(scaledSlope);vec4 accent_color=(1.0-accent)*u_accent*clamp(intensity*2.0,0.0,1.0);float shade=abs(mod((aspect+azimuth)/PI+0.5,2.0)-1.0);vec4 shade_color=mix(u_shadows[0],u_highlights[0],shade)*sin(scaledSlope)*clamp(intensity*2.0,0.0,1.0);fragColor=accent_color*(1.0-shade_color.a)+shade_color;}void basic_hillshade(vec2 deriv){deriv=deriv*u_exaggeration*2.0;float azimuth=u_azimuths[0]+PI;float cos_az=cos(azimuth);float sin_az=sin(azimuth);float cos_alt=cos(u_altitudes[0]);float sin_alt=sin(u_altitudes[0]);float cang=(sin_alt-(deriv.y*cos_az*cos_alt-deriv.x*sin_az*cos_alt))/sqrt(1.0+dot(deriv,deriv));float shade=clamp(cang,0.0,1.0);if(shade > 0.5){fragColor=u_highlights[0]*(2.0*shade-1.0);}else\n{fragColor=u_shadows[0]*(1.0-2.0*shade);}}void multidirectional_hillshade(vec2 deriv){deriv=deriv*u_exaggeration*2.0;fragColor=vec4(0,0,0,0);for(int i=0; i < NUM_ILLUMINATION_SOURCES; i++){float cos_alt=cos(u_altitudes[i]);float sin_alt=sin(u_altitudes[i]);float cos_az=-cos(u_azimuths[i]);float sin_az=-sin(u_azimuths[i]);float cang=(sin_alt-(deriv.y*cos_az*cos_alt-deriv.x*sin_az*cos_alt))/sqrt(1.0+dot(deriv,deriv));float shade=clamp(cang,0.0,1.0);if(shade > 0.5){fragColor+=u_highlights[i]*(2.0*shade-1.0)/float(NUM_ILLUMINATION_SOURCES);}else\n{fragColor+=u_shadows[i]*(1.0-2.0*shade)/float(NUM_ILLUMINATION_SOURCES);}}}void combined_hillshade(vec2 deriv){deriv=deriv*u_exaggeration*2.0;float azimuth=u_azimuths[0]+PI;float cos_az=cos(azimuth);float sin_az=sin(azimuth);float cos_alt=cos(u_altitudes[0]);float sin_alt=sin(u_altitudes[0]);float cang=acos((sin_alt-(deriv.y*cos_az*cos_alt-deriv.x*sin_az*cos_alt))/sqrt(1.0+dot(deriv,deriv)));cang=clamp(cang,0.0,PI/2.0);float shade=cang*atan(length(deriv))*4.0/PI/PI;float highlight=(PI/2.0-cang)*atan(length(deriv))*4.0/PI/PI;fragColor=u_shadows[0]*shade+u_highlights[0]*highlight;}void main() {vec4 pixel=texture(u_image,v_pos);float scaleFactor=cos(radians((u_latrange[0]-u_latrange[1])*(1.0-v_pos.y)+u_latrange[1]));vec2 deriv=((pixel.rg*8.0)-4.0)/scaleFactor;if (u_method==BASIC) {basic_hillshade(deriv);} else if (u_method==COMBINED) {combined_hillshade(deriv);} else if (u_method==IGOR) {igor_hillshade(deriv);} else if (u_method==MULTIDIRECTIONAL) {multidirectional_hillshade(deriv);} else if (u_method==STANDARD) {standard_hillshade(deriv);} else {standard_hillshade(deriv);}\n#ifdef OVERDRAW_INSPECTOR\nfragColor=vec4(1.0);\n#endif\n}","uniform mat4 u_matrix;in vec2 a_pos;out vec2 v_pos;void main() {gl_Position=projectTile(a_pos,a_pos);v_pos=a_pos/8192.0;if (a_pos.y <-32767.5) {v_pos.y=0.0;}if (a_pos.y > 32766.5) {v_pos.y=1.0;}}"),line:Bt("uniform lowp float u_device_pixel_ratio;in vec2 v_width2;in vec2 v_normal;in float v_gamma_scale;\n#ifdef GLOBE\nin float v_depth;\n#endif\n#pragma mapbox: define highp vec4 color\n#pragma mapbox: define lowp float blur\n#pragma mapbox: define lowp float opacity\nvoid main() {\n#pragma mapbox: initialize highp vec4 color\n#pragma mapbox: initialize lowp float blur\n#pragma mapbox: initialize lowp float opacity\nfloat dist=length(v_normal)*v_width2.s;float blur2=(blur+1.0/u_device_pixel_ratio)*v_gamma_scale;float alpha=clamp(min(dist-(v_width2.t-blur2),v_width2.s-dist)/blur2,0.0,1.0);fragColor=color*(alpha*opacity);\n#ifdef GLOBE\nif (v_depth > 1.0) {discard;}\n#endif\n#ifdef OVERDRAW_INSPECTOR\nfragColor=vec4(1.0);\n#endif\n}","\n#define scale 0.015873016\nin vec2 a_pos_normal;in vec4 a_data;uniform vec2 u_translation;uniform mediump float u_ratio;uniform vec2 u_units_to_pixels;uniform lowp float u_device_pixel_ratio;out vec2 v_normal;out vec2 v_width2;out float v_gamma_scale;out highp float v_linesofar;\n#ifdef GLOBE\nout float v_depth;\n#endif\n#pragma mapbox: define highp vec4 color\n#pragma mapbox: define lowp float blur\n#pragma mapbox: define lowp float opacity\n#pragma mapbox: define mediump float gapwidth\n#pragma mapbox: define lowp float offset\n#pragma mapbox: define mediump float width\nvoid main() {\n#pragma mapbox: initialize highp vec4 color\n#pragma mapbox: initialize lowp float blur\n#pragma mapbox: initialize lowp float opacity\n#pragma mapbox: initialize mediump float gapwidth\n#pragma mapbox: initialize lowp float offset\n#pragma mapbox: initialize mediump float width\nfloat ANTIALIASING=1.0/u_device_pixel_ratio/2.0;vec2 a_extrude=a_data.xy-128.0;float a_direction=mod(a_data.z,4.0)-1.0;v_linesofar=(floor(a_data.z/4.0)+a_data.w*64.0)*2.0;vec2 pos=floor(a_pos_normal*0.5);mediump vec2 normal=a_pos_normal-2.0*pos;normal.y=normal.y*2.0-1.0;v_normal=normal;gapwidth=gapwidth/2.0;float halfwidth=width/2.0;offset=-1.0*offset;float inset=gapwidth+(gapwidth > 0.0 ? ANTIALIASING : 0.0);float outset=gapwidth+halfwidth*(gapwidth > 0.0 ? 2.0 : 1.0)+(halfwidth==0.0 ? 0.0 : ANTIALIASING);mediump vec2 dist=outset*a_extrude*scale;mediump float u=0.5*a_direction;mediump float t=1.0-abs(u);mediump vec2 offset2=offset*a_extrude*scale*normal.y*mat2(t,-u,u,t);float adjustedThickness=projectLineThickness(pos.y);vec4 projected_no_extrude=projectTile(pos+offset2/u_ratio*adjustedThickness+u_translation);vec4 projected_with_extrude=projectTile(pos+offset2/u_ratio*adjustedThickness+u_translation+dist/u_ratio*adjustedThickness);gl_Position=projected_with_extrude;\n#ifdef GLOBE\nv_depth=gl_Position.z/gl_Position.w;\n#endif\n#ifdef TERRAIN3D\nv_gamma_scale=1.0;\n#else\nfloat extrude_length_without_perspective=length(dist);float extrude_length_with_perspective=length((projected_with_extrude.xy-projected_no_extrude.xy)/projected_with_extrude.w*u_units_to_pixels);v_gamma_scale=extrude_length_without_perspective/extrude_length_with_perspective;\n#endif\nv_width2=vec2(outset,inset);}"),lineGradient:Bt("uniform lowp float u_device_pixel_ratio;uniform sampler2D u_image;in vec2 v_width2;in vec2 v_normal;in float v_gamma_scale;in highp vec2 v_uv;\n#ifdef GLOBE\nin float v_depth;\n#endif\n#pragma mapbox: define lowp float blur\n#pragma mapbox: define lowp float opacity\nvoid main() {\n#pragma mapbox: initialize lowp float blur\n#pragma mapbox: initialize lowp float opacity\nfloat dist=length(v_normal)*v_width2.s;float blur2=(blur+1.0/u_device_pixel_ratio)*v_gamma_scale;float alpha=clamp(min(dist-(v_width2.t-blur2),v_width2.s-dist)/blur2,0.0,1.0);vec4 color=texture(u_image,v_uv);fragColor=color*(alpha*opacity);\n#ifdef GLOBE\nif (v_depth > 1.0) {discard;}\n#endif\n#ifdef OVERDRAW_INSPECTOR\nfragColor=vec4(1.0);\n#endif\n}","\n#define scale 0.015873016\nin vec2 a_pos_normal;in vec4 a_data;in float a_uv_x;in float a_split_index;uniform vec2 u_translation;uniform mediump float u_ratio;uniform lowp float u_device_pixel_ratio;uniform vec2 u_units_to_pixels;uniform float u_image_height;out vec2 v_normal;out vec2 v_width2;out float v_gamma_scale;out highp vec2 v_uv;\n#ifdef GLOBE\nout float v_depth;\n#endif\n#pragma mapbox: define lowp float blur\n#pragma mapbox: define lowp float opacity\n#pragma mapbox: define mediump float gapwidth\n#pragma mapbox: define lowp float offset\n#pragma mapbox: define mediump float width\nvoid main() {\n#pragma mapbox: initialize lowp float blur\n#pragma mapbox: initialize lowp float opacity\n#pragma mapbox: initialize mediump float gapwidth\n#pragma mapbox: initialize lowp float offset\n#pragma mapbox: initialize mediump float width\nfloat ANTIALIASING=1.0/u_device_pixel_ratio/2.0;vec2 a_extrude=a_data.xy-128.0;float a_direction=mod(a_data.z,4.0)-1.0;highp float texel_height=1.0/u_image_height;highp float half_texel_height=0.5*texel_height;v_uv=vec2(a_uv_x,a_split_index*texel_height-half_texel_height);vec2 pos=floor(a_pos_normal*0.5);mediump vec2 normal=a_pos_normal-2.0*pos;normal.y=normal.y*2.0-1.0;v_normal=normal;gapwidth=gapwidth/2.0;float halfwidth=width/2.0;offset=-1.0*offset;float inset=gapwidth+(gapwidth > 0.0 ? ANTIALIASING : 0.0);float outset=gapwidth+halfwidth*(gapwidth > 0.0 ? 2.0 : 1.0)+(halfwidth==0.0 ? 0.0 : ANTIALIASING);mediump vec2 dist=outset*a_extrude*scale;mediump float u=0.5*a_direction;mediump float t=1.0-abs(u);mediump vec2 offset2=offset*a_extrude*scale*normal.y*mat2(t,-u,u,t);float adjustedThickness=projectLineThickness(pos.y);vec4 projected_no_extrude=projectTile(pos+offset2/u_ratio*adjustedThickness+u_translation);vec4 projected_with_extrude=projectTile(pos+offset2/u_ratio*adjustedThickness+u_translation+dist/u_ratio*adjustedThickness);gl_Position=projected_with_extrude;\n#ifdef GLOBE\nv_depth=gl_Position.z/gl_Position.w;\n#endif\n#ifdef TERRAIN3D\nv_gamma_scale=1.0;\n#else\nfloat extrude_length_without_perspective=length(dist);float extrude_length_with_perspective=length((projected_with_extrude.xy-projected_no_extrude.xy)/projected_with_extrude.w*u_units_to_pixels);v_gamma_scale=extrude_length_without_perspective/extrude_length_with_perspective;\n#endif\nv_width2=vec2(outset,inset);}"),linePattern:Bt("#ifdef GL_ES\nprecision highp float;\n#endif\nuniform lowp float u_device_pixel_ratio;uniform vec2 u_texsize;uniform float u_fade;uniform mediump vec3 u_scale;uniform sampler2D u_image;in vec2 v_normal;in vec2 v_width2;in float v_linesofar;in float v_gamma_scale;in float v_width;\n#ifdef GLOBE\nin float v_depth;\n#endif\n#pragma mapbox: define lowp vec4 pattern_from\n#pragma mapbox: define lowp vec4 pattern_to\n#pragma mapbox: define lowp float pixel_ratio_from\n#pragma mapbox: define lowp float pixel_ratio_to\n#pragma mapbox: define lowp float blur\n#pragma mapbox: define lowp float opacity\nvoid main() {\n#pragma mapbox: initialize mediump vec4 pattern_from\n#pragma mapbox: initialize mediump vec4 pattern_to\n#pragma mapbox: initialize lowp float pixel_ratio_from\n#pragma mapbox: initialize lowp float pixel_ratio_to\n#pragma mapbox: initialize lowp float blur\n#pragma mapbox: initialize lowp float opacity\nvec2 pattern_tl_a=pattern_from.xy;vec2 pattern_br_a=pattern_from.zw;vec2 pattern_tl_b=pattern_to.xy;vec2 pattern_br_b=pattern_to.zw;float tileZoomRatio=u_scale.x;float fromScale=u_scale.y;float toScale=u_scale.z;vec2 display_size_a=(pattern_br_a-pattern_tl_a)/pixel_ratio_from;vec2 display_size_b=(pattern_br_b-pattern_tl_b)/pixel_ratio_to;vec2 pattern_size_a=vec2(display_size_a.x*fromScale/tileZoomRatio,display_size_a.y);vec2 pattern_size_b=vec2(display_size_b.x*toScale/tileZoomRatio,display_size_b.y);float aspect_a=display_size_a.y/v_width;float aspect_b=display_size_b.y/v_width;float dist=length(v_normal)*v_width2.s;float blur2=(blur+1.0/u_device_pixel_ratio)*v_gamma_scale;float alpha=clamp(min(dist-(v_width2.t-blur2),v_width2.s-dist)/blur2,0.0,1.0);float x_a=mod(v_linesofar/pattern_size_a.x*aspect_a,1.0);float x_b=mod(v_linesofar/pattern_size_b.x*aspect_b,1.0);float y=0.5*v_normal.y+0.5;vec2 texel_size=1.0/u_texsize;vec2 pos_a=mix(pattern_tl_a*texel_size-texel_size,pattern_br_a*texel_size+texel_size,vec2(x_a,y));vec2 pos_b=mix(pattern_tl_b*texel_size-texel_size,pattern_br_b*texel_size+texel_size,vec2(x_b,y));vec4 color=mix(texture(u_image,pos_a),texture(u_image,pos_b),u_fade);fragColor=color*alpha*opacity;\n#ifdef GLOBE\nif (v_depth > 1.0) {discard;}\n#endif\n#ifdef OVERDRAW_INSPECTOR\nfragColor=vec4(1.0);\n#endif\n}","\n#define scale 0.015873016\n#define LINE_DISTANCE_SCALE 2.0\nin vec2 a_pos_normal;in vec4 a_data;uniform vec2 u_translation;uniform vec2 u_units_to_pixels;uniform mediump float u_ratio;uniform lowp float u_device_pixel_ratio;out vec2 v_normal;out vec2 v_width2;out float v_linesofar;out float v_gamma_scale;out float v_width;\n#ifdef GLOBE\nout float v_depth;\n#endif\n#pragma mapbox: define lowp float blur\n#pragma mapbox: define lowp float opacity\n#pragma mapbox: define lowp float offset\n#pragma mapbox: define mediump float gapwidth\n#pragma mapbox: define mediump float width\n#pragma mapbox: define lowp float floorwidth\n#pragma mapbox: define lowp vec4 pattern_from\n#pragma mapbox: define lowp vec4 pattern_to\n#pragma mapbox: define lowp float pixel_ratio_from\n#pragma mapbox: define lowp float pixel_ratio_to\nvoid main() {\n#pragma mapbox: initialize lowp float blur\n#pragma mapbox: initialize lowp float opacity\n#pragma mapbox: initialize lowp float offset\n#pragma mapbox: initialize mediump float gapwidth\n#pragma mapbox: initialize mediump float width\n#pragma mapbox: initialize lowp float floorwidth\n#pragma mapbox: initialize mediump vec4 pattern_from\n#pragma mapbox: initialize mediump vec4 pattern_to\n#pragma mapbox: initialize lowp float pixel_ratio_from\n#pragma mapbox: initialize lowp float pixel_ratio_to\nfloat ANTIALIASING=1.0/u_device_pixel_ratio/2.0;vec2 a_extrude=a_data.xy-128.0;float a_direction=mod(a_data.z,4.0)-1.0;float a_linesofar=(floor(a_data.z/4.0)+a_data.w*64.0)*LINE_DISTANCE_SCALE;vec2 pos=floor(a_pos_normal*0.5);mediump vec2 normal=a_pos_normal-2.0*pos;normal.y=normal.y*2.0-1.0;v_normal=normal;gapwidth=gapwidth/2.0;float halfwidth=width/2.0;offset=-1.0*offset;float inset=gapwidth+(gapwidth > 0.0 ? ANTIALIASING : 0.0);float outset=gapwidth+halfwidth*(gapwidth > 0.0 ? 2.0 : 1.0)+(halfwidth==0.0 ? 0.0 : ANTIALIASING);mediump vec2 dist=outset*a_extrude*scale;mediump float u=0.5*a_direction;mediump float t=1.0-abs(u);mediump vec2 offset2=offset*a_extrude*scale*normal.y*mat2(t,-u,u,t);float adjustedThickness=projectLineThickness(pos.y);vec4 projected_no_extrude=projectTile(pos+offset2/u_ratio*adjustedThickness+u_translation);vec4 projected_with_extrude=projectTile(pos+offset2/u_ratio*adjustedThickness+u_translation+dist/u_ratio*adjustedThickness);gl_Position=projected_with_extrude;\n#ifdef GLOBE\nv_depth=gl_Position.z/gl_Position.w;\n#endif\n#ifdef TERRAIN3D\nv_gamma_scale=1.0;\n#else\nfloat extrude_length_without_perspective=length(dist);float extrude_length_with_perspective=length((projected_with_extrude.xy-projected_no_extrude.xy)/projected_with_extrude.w*u_units_to_pixels);v_gamma_scale=extrude_length_without_perspective/extrude_length_with_perspective;\n#endif\nv_linesofar=a_linesofar;v_width2=vec2(outset,inset);v_width=floorwidth;}"),lineSDF:Bt("uniform lowp float u_device_pixel_ratio;uniform lowp float u_lineatlas_width;uniform sampler2D u_image;uniform float u_mix;in vec2 v_normal;in vec2 v_width2;in vec2 v_tex_a;in vec2 v_tex_b;in float v_gamma_scale;\n#ifdef GLOBE\nin float v_depth;\n#endif\n#pragma mapbox: define highp vec4 color\n#pragma mapbox: define lowp float blur\n#pragma mapbox: define lowp float opacity\n#pragma mapbox: define mediump float width\n#pragma mapbox: define lowp float floorwidth\n#pragma mapbox: define mediump vec4 dasharray_from\n#pragma mapbox: define mediump vec4 dasharray_to\nvoid main() {\n#pragma mapbox: initialize highp vec4 color\n#pragma mapbox: initialize lowp float blur\n#pragma mapbox: initialize lowp float opacity\n#pragma mapbox: initialize mediump float width\n#pragma mapbox: initialize lowp float floorwidth\n#pragma mapbox: initialize mediump vec4 dasharray_from\n#pragma mapbox: initialize mediump vec4 dasharray_to\nfloat dist=length(v_normal)*v_width2.s;float blur2=(blur+1.0/u_device_pixel_ratio)*v_gamma_scale;float alpha=clamp(min(dist-(v_width2.t-blur2),v_width2.s-dist)/blur2,0.0,1.0);float sdfdist_a=texture(u_image,v_tex_a).a;float sdfdist_b=texture(u_image,v_tex_b).a;float sdfdist=mix(sdfdist_a,sdfdist_b,u_mix);float sdfgamma=(u_lineatlas_width/256.0/u_device_pixel_ratio)/min(dasharray_from.w,dasharray_to.w);alpha*=smoothstep(0.5-sdfgamma/floorwidth,0.5+sdfgamma/floorwidth,sdfdist);fragColor=color*(alpha*opacity);\n#ifdef GLOBE\nif (v_depth > 1.0) {discard;}\n#endif\n#ifdef OVERDRAW_INSPECTOR\nfragColor=vec4(1.0);\n#endif\n}","\n#define scale 0.015873016\n#define LINE_DISTANCE_SCALE 2.0\nin vec2 a_pos_normal;in vec4 a_data;uniform vec2 u_translation;uniform mediump float u_ratio;uniform lowp float u_device_pixel_ratio;uniform vec2 u_units_to_pixels;uniform float u_tileratio;uniform float u_crossfade_from;uniform float u_crossfade_to;uniform float u_lineatlas_height;out vec2 v_normal;out vec2 v_width2;out vec2 v_tex_a;out vec2 v_tex_b;out float v_gamma_scale;\n#ifdef GLOBE\nout float v_depth;\n#endif\n#pragma mapbox: define highp vec4 color\n#pragma mapbox: define lowp float blur\n#pragma mapbox: define lowp float opacity\n#pragma mapbox: define mediump float gapwidth\n#pragma mapbox: define lowp float offset\n#pragma mapbox: define mediump float width\n#pragma mapbox: define lowp float floorwidth\n#pragma mapbox: define mediump vec4 dasharray_from\n#pragma mapbox: define mediump vec4 dasharray_to\nvoid main() {\n#pragma mapbox: initialize highp vec4 color\n#pragma mapbox: initialize lowp float blur\n#pragma mapbox: initialize lowp float opacity\n#pragma mapbox: initialize mediump float gapwidth\n#pragma mapbox: initialize lowp float offset\n#pragma mapbox: initialize mediump float width\n#pragma mapbox: initialize lowp float floorwidth\n#pragma mapbox: initialize mediump vec4 dasharray_from\n#pragma mapbox: initialize mediump vec4 dasharray_to\nfloat ANTIALIASING=1.0/u_device_pixel_ratio/2.0;vec2 a_extrude=a_data.xy-128.0;float a_direction=mod(a_data.z,4.0)-1.0;float a_linesofar=(floor(a_data.z/4.0)+a_data.w*64.0)*LINE_DISTANCE_SCALE;vec2 pos=floor(a_pos_normal*0.5);mediump vec2 normal=a_pos_normal-2.0*pos;normal.y=normal.y*2.0-1.0;v_normal=normal;gapwidth=gapwidth/2.0;float halfwidth=width/2.0;offset=-1.0*offset;float inset=gapwidth+(gapwidth > 0.0 ? ANTIALIASING : 0.0);float outset=gapwidth+halfwidth*(gapwidth > 0.0 ? 2.0 : 1.0)+(halfwidth==0.0 ? 0.0 : ANTIALIASING);mediump vec2 dist=outset*a_extrude*scale;mediump float u=0.5*a_direction;mediump float t=1.0-abs(u);mediump vec2 offset2=offset*a_extrude*scale*normal.y*mat2(t,-u,u,t);float adjustedThickness=projectLineThickness(pos.y);vec4 projected_no_extrude=projectTile(pos+offset2/u_ratio*adjustedThickness+u_translation);vec4 projected_with_extrude=projectTile(pos+offset2/u_ratio*adjustedThickness+u_translation+dist/u_ratio*adjustedThickness);gl_Position=projected_with_extrude;\n#ifdef GLOBE\nv_depth=gl_Position.z/gl_Position.w;\n#endif\n#ifdef TERRAIN3D\nv_gamma_scale=1.0;\n#else\nfloat extrude_length_without_perspective=length(dist);float extrude_length_with_perspective=length((projected_with_extrude.xy-projected_no_extrude.xy)/projected_with_extrude.w*u_units_to_pixels);v_gamma_scale=extrude_length_without_perspective/extrude_length_with_perspective;\n#endif\nfloat u_patternscale_a_x=u_tileratio/dasharray_from.w/u_crossfade_from;float u_patternscale_a_y=-dasharray_from.z/2.0/u_lineatlas_height;float u_patternscale_b_x=u_tileratio/dasharray_to.w/u_crossfade_to;float u_patternscale_b_y=-dasharray_to.z/2.0/u_lineatlas_height;v_tex_a=vec2(a_linesofar*u_patternscale_a_x/floorwidth,normal.y*u_patternscale_a_y+(float(dasharray_from.y)+0.5)/u_lineatlas_height);v_tex_b=vec2(a_linesofar*u_patternscale_b_x/floorwidth,normal.y*u_patternscale_b_y+(float(dasharray_to.y)+0.5)/u_lineatlas_height);v_width2=vec2(outset,inset);}"),lineGradientSDF:Bt("uniform lowp float u_device_pixel_ratio;uniform sampler2D u_image;uniform sampler2D u_image_dash;uniform float u_mix;uniform lowp float u_lineatlas_width;in vec2 v_normal;in vec2 v_width2;in vec2 v_tex_a;in vec2 v_tex_b;in float v_gamma_scale;in highp vec2 v_uv;\n#ifdef GLOBE\nin float v_depth;\n#endif\n#pragma mapbox: define lowp float blur\n#pragma mapbox: define lowp float opacity\n#pragma mapbox: define mediump float width\n#pragma mapbox: define lowp float floorwidth\n#pragma mapbox: define mediump vec4 dasharray_from\n#pragma mapbox: define mediump vec4 dasharray_to\nvoid main() {\n#pragma mapbox: initialize lowp float blur\n#pragma mapbox: initialize lowp float opacity\n#pragma mapbox: initialize mediump float width\n#pragma mapbox: initialize lowp float floorwidth\n#pragma mapbox: initialize mediump vec4 dasharray_from\n#pragma mapbox: initialize mediump vec4 dasharray_to\nfloat dist=length(v_normal)*v_width2.s;float blur2=(blur+1.0/u_device_pixel_ratio)*v_gamma_scale;float alpha=clamp(min(dist-(v_width2.t-blur2),v_width2.s-dist)/blur2,0.0,1.0);vec4 color=texture(u_image,v_uv);float sdfdist_a=texture(u_image_dash,v_tex_a).a;float sdfdist_b=texture(u_image_dash,v_tex_b).a;float sdfdist=mix(sdfdist_a,sdfdist_b,u_mix);float sdfgamma=(u_lineatlas_width/256.0)/min(dasharray_from.w,dasharray_to.w);float dash_alpha=smoothstep(0.5-sdfgamma/floorwidth,0.5+sdfgamma/floorwidth,sdfdist);fragColor=color*(alpha*dash_alpha*opacity);\n#ifdef GLOBE\nif (v_depth > 1.0) {discard;}\n#endif\n#ifdef OVERDRAW_INSPECTOR\nfragColor=vec4(1.0);\n#endif\n}","\n#define scale 0.015873016\n#define LINE_DISTANCE_SCALE 2.0\nin vec2 a_pos_normal;in vec4 a_data;in float a_uv_x;in float a_split_index;uniform vec2 u_translation;uniform mediump float u_ratio;uniform lowp float u_device_pixel_ratio;uniform vec2 u_units_to_pixels;uniform float u_image_height;uniform float u_tileratio;uniform float u_crossfade_from;uniform float u_crossfade_to;uniform float u_lineatlas_height;out vec2 v_normal;out vec2 v_width2;out float v_gamma_scale;out highp vec2 v_uv;out vec2 v_tex_a;out vec2 v_tex_b;\n#ifdef GLOBE\nout float v_depth;\n#endif\n#pragma mapbox: define lowp float blur\n#pragma mapbox: define lowp float opacity\n#pragma mapbox: define mediump float gapwidth\n#pragma mapbox: define lowp float offset\n#pragma mapbox: define mediump float width\n#pragma mapbox: define lowp float floorwidth\n#pragma mapbox: define mediump vec4 dasharray_from\n#pragma mapbox: define mediump vec4 dasharray_to\nvoid main() {\n#pragma mapbox: initialize lowp float blur\n#pragma mapbox: initialize lowp float opacity\n#pragma mapbox: initialize mediump float gapwidth\n#pragma mapbox: initialize lowp float offset\n#pragma mapbox: initialize mediump float width\n#pragma mapbox: initialize lowp float floorwidth\n#pragma mapbox: initialize mediump vec4 dasharray_from\n#pragma mapbox: initialize mediump vec4 dasharray_to\nfloat ANTIALIASING=1.0/u_device_pixel_ratio/2.0;vec2 a_extrude=a_data.xy-128.0;float a_direction=mod(a_data.z,4.0)-1.0;float a_linesofar=(floor(a_data.z/4.0)+a_data.w*64.0)*LINE_DISTANCE_SCALE;float texel_height=1.0/u_image_height;float half_texel_height=0.5*texel_height;v_uv=vec2(a_uv_x,a_split_index*texel_height-half_texel_height);vec2 pos=floor(a_pos_normal*0.5);mediump vec2 normal=a_pos_normal-2.0*pos;normal.y=normal.y*2.0-1.0;v_normal=normal;gapwidth=gapwidth/2.0;float halfwidth=width/2.0;offset=-1.0*offset;float inset=gapwidth+(gapwidth > 0.0 ? ANTIALIASING : 0.0);float outset=gapwidth+halfwidth*(gapwidth > 0.0 ? 2.0 : 1.0)+(halfwidth==0.0 ? 0.0 : ANTIALIASING);mediump vec2 dist=outset*a_extrude*scale;mediump float u=0.5*a_direction;mediump float t=1.0-abs(u);mediump vec2 offset2=offset*a_extrude*scale*normal.y*mat2(t,-u,u,t);float adjustedThickness=projectLineThickness(pos.y);vec4 projected_no_extrude=projectTile(pos+offset2/u_ratio*adjustedThickness+u_translation);vec4 projected_with_extrude=projectTile(pos+offset2/u_ratio*adjustedThickness+u_translation+dist/u_ratio*adjustedThickness);gl_Position=projected_with_extrude;\n#ifdef GLOBE\nv_depth=gl_Position.z/gl_Position.w;\n#endif\n#ifdef TERRAIN3D\nv_gamma_scale=1.0;\n#else\nfloat extrude_length_without_perspective=length(dist);float extrude_length_with_perspective=length((projected_with_extrude.xy-projected_no_extrude.xy)/projected_with_extrude.w*u_units_to_pixels);v_gamma_scale=extrude_length_without_perspective/extrude_length_with_perspective;\n#endif\nfloat u_patternscale_a_x=u_tileratio/dasharray_from.w/u_crossfade_from;float u_patternscale_a_y=-dasharray_from.z/2.0/u_lineatlas_height;float u_patternscale_b_x=u_tileratio/dasharray_to.w/u_crossfade_to;float u_patternscale_b_y=-dasharray_to.z/2.0/u_lineatlas_height;v_tex_a=vec2(a_linesofar*u_patternscale_a_x/floorwidth,normal.y*u_patternscale_a_y+(float(dasharray_from.y)+0.5)/u_lineatlas_height);v_tex_b=vec2(a_linesofar*u_patternscale_b_x/floorwidth,normal.y*u_patternscale_b_y+(float(dasharray_to.y)+0.5)/u_lineatlas_height);v_width2=vec2(outset,inset);}"),raster:Bt("uniform float u_fade_t;uniform float u_opacity;uniform sampler2D u_image0;uniform sampler2D u_image1;in vec2 v_pos0;in vec2 v_pos1;uniform float u_brightness_low;uniform float u_brightness_high;uniform float u_saturation_factor;uniform float u_contrast_factor;uniform vec3 u_spin_weights;void main() {vec4 color0=texture(u_image0,v_pos0);vec4 color1=texture(u_image1,v_pos1);if (color0.a > 0.0) {color0.rgb=color0.rgb/color0.a;}if (color1.a > 0.0) {color1.rgb=color1.rgb/color1.a;}vec4 color=mix(color0,color1,u_fade_t);color.a*=u_opacity;vec3 rgb=color.rgb;rgb=vec3(dot(rgb,u_spin_weights.xyz),dot(rgb,u_spin_weights.zxy),dot(rgb,u_spin_weights.yzx));float average=(color.r+color.g+color.b)/3.0;rgb+=(average-rgb)*u_saturation_factor;rgb=(rgb-0.5)*u_contrast_factor+0.5;vec3 u_high_vec=vec3(u_brightness_low,u_brightness_low,u_brightness_low);vec3 u_low_vec=vec3(u_brightness_high,u_brightness_high,u_brightness_high);fragColor=vec4(mix(u_high_vec,u_low_vec,rgb)*color.a,color.a);\n#ifdef OVERDRAW_INSPECTOR\nfragColor=vec4(1.0);\n#endif\n}","uniform vec2 u_tl_parent;uniform float u_scale_parent;uniform float u_buffer_scale;uniform vec4 u_coords_top;uniform vec4 u_coords_bottom;in vec2 a_pos;out vec2 v_pos0;out vec2 v_pos1;void main() {vec2 fractionalPos=a_pos/8192.0;vec2 position=mix(mix(u_coords_top.xy,u_coords_top.zw,fractionalPos.x),mix(u_coords_bottom.xy,u_coords_bottom.zw,fractionalPos.x),fractionalPos.y);gl_Position=projectTile(position,position);v_pos0=((fractionalPos-0.5)/u_buffer_scale)+0.5;\n#ifdef GLOBE\nif (a_pos.y <-32767.5) {v_pos0.y=0.0;}if (a_pos.y > 32766.5) {v_pos0.y=1.0;}\n#endif\nv_pos1=(v_pos0*u_scale_parent)+u_tl_parent;}"),symbolIcon:Bt("uniform sampler2D u_texture;in vec2 v_tex;in float v_fade_opacity;\n#pragma mapbox: define lowp float opacity\nvoid main() {\n#pragma mapbox: initialize lowp float opacity\nlowp float alpha=opacity*v_fade_opacity;fragColor=texture(u_texture,v_tex)*alpha;\n#ifdef OVERDRAW_INSPECTOR\nfragColor=vec4(1.0);\n#endif\n}","in vec4 a_pos_offset;in vec4 a_data;in vec4 a_pixeloffset;in vec3 a_projected_pos;in float a_fade_opacity;uniform bool u_is_size_zoom_constant;uniform bool u_is_size_feature_constant;uniform highp float u_size_t;uniform highp float u_size;uniform highp float u_camera_to_center_distance;uniform highp float u_pitch;uniform bool u_rotate_symbol;uniform highp float u_aspect_ratio;uniform float u_fade_change;uniform mat4 u_label_plane_matrix;uniform mat4 u_coord_matrix;uniform bool u_is_text;uniform bool u_pitch_with_map;uniform vec2 u_texsize;uniform bool u_is_along_line;uniform bool u_is_variable_anchor;uniform vec2 u_translation;uniform float u_pitched_scale;out vec2 v_tex;out float v_fade_opacity;\n#pragma mapbox: define lowp float opacity\nvoid main() {\n#pragma mapbox: initialize lowp float opacity\nvec2 a_pos=a_pos_offset.xy;vec2 a_offset=a_pos_offset.zw;vec2 a_tex=a_data.xy;vec2 a_size=a_data.zw;float a_size_min=floor(a_size[0]*0.5);vec2 a_pxoffset=a_pixeloffset.xy;vec2 a_minFontScale=a_pixeloffset.zw/256.0;float ele=get_elevation(a_pos);highp float segment_angle=-a_projected_pos[2];float size;if (!u_is_size_zoom_constant && !u_is_size_feature_constant) {size=mix(a_size_min,a_size[1],u_size_t)/128.0;} else if (u_is_size_zoom_constant && !u_is_size_feature_constant) {size=a_size_min/128.0;} else {size=u_size;}vec2 translated_a_pos=a_pos+u_translation;vec4 projectedPoint=projectTileWithElevation(translated_a_pos,ele);highp float camera_to_anchor_distance=projectedPoint.w;highp float distance_ratio=u_pitch_with_map ?\ncamera_to_anchor_distance/u_camera_to_center_distance :\nu_camera_to_center_distance/camera_to_anchor_distance;highp float perspective_ratio=clamp(0.5+0.5*distance_ratio,0.0,4.0);size*=perspective_ratio;float fontScale=u_is_text ? size/24.0 : size;highp float symbol_rotation=0.0;if (u_rotate_symbol) {vec4 offsetProjectedPoint=projectTileWithElevation(translated_a_pos+vec2(1,0),ele);vec2 a=projectedPoint.xy/projectedPoint.w;vec2 b=offsetProjectedPoint.xy/offsetProjectedPoint.w;symbol_rotation=atan((b.y-a.y)/u_aspect_ratio,b.x-a.x);}highp float angle_sin=sin(segment_angle+symbol_rotation);highp float angle_cos=cos(segment_angle+symbol_rotation);mat2 rotation_matrix=mat2(angle_cos,-1.0*angle_sin,angle_sin,angle_cos);vec4 projected_pos;if (u_is_along_line || u_is_variable_anchor) {projected_pos=vec4(a_projected_pos.xy,ele,1.0);} else if (u_pitch_with_map) {projected_pos=u_label_plane_matrix*vec4(a_projected_pos.xy+u_translation,ele,1.0);} else {projected_pos=u_label_plane_matrix*projectTileWithElevation(a_projected_pos.xy+u_translation,ele);}float z=float(u_pitch_with_map)*projected_pos.z/projected_pos.w;float projectionScaling=1.0;\n#ifdef GLOBE\nif(u_pitch_with_map) {float anchor_pos_tile_y=(u_coord_matrix*vec4(projected_pos.xy/projected_pos.w,z,1.0)).y;projectionScaling=mix(projectionScaling,1.0/circumferenceRatioAtTileY(anchor_pos_tile_y)*u_pitched_scale,u_projection_transition);}\n#endif\nvec4 finalPos=u_coord_matrix*vec4(projected_pos.xy/projected_pos.w+rotation_matrix*(a_offset/32.0*max(a_minFontScale,fontScale)+a_pxoffset/16.0)*projectionScaling,z,1.0);if(u_pitch_with_map) {finalPos=projectTileWithElevation(finalPos.xy,finalPos.z);}gl_Position=finalPos;v_tex=a_tex/u_texsize;vec2 fade_opacity=unpack_opacity(a_fade_opacity);float fade_change=fade_opacity[1] > 0.5 ? u_fade_change :-u_fade_change;float visibility=calculate_visibility(projectedPoint);v_fade_opacity=max(0.0,min(visibility,fade_opacity[0]+fade_change));}"),symbolSDF:Bt("#define SDF_PX 8.0\nuniform bool u_is_halo;uniform sampler2D u_texture;uniform highp float u_gamma_scale;uniform lowp float u_device_pixel_ratio;uniform bool u_is_text;in vec2 v_data0;in vec3 v_data1;\n#pragma mapbox: define highp vec4 fill_color\n#pragma mapbox: define highp vec4 halo_color\n#pragma mapbox: define lowp float opacity\n#pragma mapbox: define lowp float halo_width\n#pragma mapbox: define lowp float halo_blur\nvoid main() {\n#pragma mapbox: initialize highp vec4 fill_color\n#pragma mapbox: initialize highp vec4 halo_color\n#pragma mapbox: initialize lowp float opacity\n#pragma mapbox: initialize lowp float halo_width\n#pragma mapbox: initialize lowp float halo_blur\nfloat EDGE_GAMMA=0.105/u_device_pixel_ratio;vec2 tex=v_data0.xy;float gamma_scale=v_data1.x;float size=v_data1.y;float fade_opacity=v_data1[2];float fontScale=u_is_text ? size/24.0 : size;lowp vec4 color=fill_color;highp float gamma=EDGE_GAMMA/(fontScale*u_gamma_scale);lowp float inner_edge=(256.0-64.0)/256.0;if (u_is_halo) {color=halo_color;gamma=(halo_blur*1.19/SDF_PX+EDGE_GAMMA)/(fontScale*u_gamma_scale);inner_edge=inner_edge+gamma*gamma_scale;}lowp float dist=texture(u_texture,tex).a;highp float gamma_scaled=gamma*gamma_scale;highp float alpha=smoothstep(inner_edge-gamma_scaled,inner_edge+gamma_scaled,dist);if (u_is_halo) {lowp float halo_edge=(6.0-halo_width/fontScale)/SDF_PX;alpha=min(smoothstep(halo_edge-gamma_scaled,halo_edge+gamma_scaled,dist),1.0-alpha);}fragColor=color*(alpha*opacity*fade_opacity);\n#ifdef OVERDRAW_INSPECTOR\nfragColor=vec4(1.0);\n#endif\n}","in vec4 a_pos_offset;in vec4 a_data;in vec4 a_pixeloffset;in vec3 a_projected_pos;in float a_fade_opacity;uniform bool u_is_size_zoom_constant;uniform bool u_is_size_feature_constant;uniform highp float u_size_t;uniform highp float u_size;uniform mat4 u_label_plane_matrix;uniform mat4 u_coord_matrix;uniform bool u_is_text;uniform bool u_pitch_with_map;uniform bool u_is_along_line;uniform bool u_is_variable_anchor;uniform highp float u_pitch;uniform bool u_rotate_symbol;uniform highp float u_aspect_ratio;uniform highp float u_camera_to_center_distance;uniform float u_fade_change;uniform vec2 u_texsize;uniform vec2 u_translation;uniform float u_pitched_scale;out vec2 v_data0;out vec3 v_data1;\n#pragma mapbox: define highp vec4 fill_color\n#pragma mapbox: define highp vec4 halo_color\n#pragma mapbox: define lowp float opacity\n#pragma mapbox: define lowp float halo_width\n#pragma mapbox: define lowp float halo_blur\nvoid main() {\n#pragma mapbox: initialize highp vec4 fill_color\n#pragma mapbox: initialize highp vec4 halo_color\n#pragma mapbox: initialize lowp float opacity\n#pragma mapbox: initialize lowp float halo_width\n#pragma mapbox: initialize lowp float halo_blur\nvec2 a_pos=a_pos_offset.xy;vec2 a_offset=a_pos_offset.zw;vec2 a_tex=a_data.xy;vec2 a_size=a_data.zw;float a_size_min=floor(a_size[0]*0.5);vec2 a_pxoffset=a_pixeloffset.xy;float ele=get_elevation(a_pos);highp float segment_angle=-a_projected_pos[2];float size;if (!u_is_size_zoom_constant && !u_is_size_feature_constant) {size=mix(a_size_min,a_size[1],u_size_t)/128.0;} else if (u_is_size_zoom_constant && !u_is_size_feature_constant) {size=a_size_min/128.0;} else {size=u_size;}vec2 translated_a_pos=a_pos+u_translation;vec4 projectedPoint=projectTileWithElevation(translated_a_pos,ele);highp float camera_to_anchor_distance=projectedPoint.w;highp float distance_ratio=u_pitch_with_map ?\ncamera_to_anchor_distance/u_camera_to_center_distance :\nu_camera_to_center_distance/camera_to_anchor_distance;highp float perspective_ratio=clamp(0.5+0.5*distance_ratio,0.0,4.0);size*=perspective_ratio;float fontScale=u_is_text ? size/24.0 : size;highp float symbol_rotation=0.0;if (u_rotate_symbol) {vec4 offsetProjectedPoint=projectTileWithElevation(translated_a_pos+vec2(1,0),ele);vec2 a=projectedPoint.xy/projectedPoint.w;vec2 b=offsetProjectedPoint.xy/offsetProjectedPoint.w;symbol_rotation=atan((b.y-a.y)/u_aspect_ratio,b.x-a.x);}highp float angle_sin=sin(segment_angle+symbol_rotation);highp float angle_cos=cos(segment_angle+symbol_rotation);mat2 rotation_matrix=mat2(angle_cos,-1.0*angle_sin,angle_sin,angle_cos);vec4 projected_pos;if (u_is_along_line || u_is_variable_anchor) {projected_pos=vec4(a_projected_pos.xy,ele,1.0);} else if (u_pitch_with_map) {projected_pos=u_label_plane_matrix*vec4(a_projected_pos.xy+u_translation,ele,1.0);} else {projected_pos=u_label_plane_matrix*projectTileWithElevation(a_projected_pos.xy+u_translation,ele);}float z=float(u_pitch_with_map)*projected_pos.z/projected_pos.w;float projectionScaling=1.0;\n#ifdef GLOBE\nif(u_pitch_with_map) {float anchor_pos_tile_y=(u_coord_matrix*vec4(projected_pos.xy/projected_pos.w,z,1.0)).y;projectionScaling=mix(projectionScaling,1.0/circumferenceRatioAtTileY(anchor_pos_tile_y)*u_pitched_scale,u_projection_transition);}\n#endif\nvec4 finalPos=u_coord_matrix*vec4(projected_pos.xy/projected_pos.w+rotation_matrix*(a_offset/32.0*fontScale+a_pxoffset)*projectionScaling,z,1.0);if(u_pitch_with_map) {finalPos=projectTileWithElevation(finalPos.xy,finalPos.z);}float gamma_scale=finalPos.w;gl_Position=finalPos;vec2 fade_opacity=unpack_opacity(a_fade_opacity);float visibility=calculate_visibility(projectedPoint);float fade_change=fade_opacity[1] > 0.5 ? u_fade_change :-u_fade_change;float interpolated_fade_opacity=max(0.0,min(visibility,fade_opacity[0]+fade_change));v_data0=a_tex/u_texsize;v_data1=vec3(gamma_scale,size,interpolated_fade_opacity);}"),symbolTextAndIcon:Bt("#define SDF_PX 8.0\n#define SDF 1.0\n#define ICON 0.0\nuniform bool u_is_halo;uniform sampler2D u_texture;uniform sampler2D u_texture_icon;uniform highp float u_gamma_scale;uniform lowp float u_device_pixel_ratio;in vec4 v_data0;in vec4 v_data1;\n#pragma mapbox: define highp vec4 fill_color\n#pragma mapbox: define highp vec4 halo_color\n#pragma mapbox: define lowp float opacity\n#pragma mapbox: define lowp float halo_width\n#pragma mapbox: define lowp float halo_blur\nvoid main() {\n#pragma mapbox: initialize highp vec4 fill_color\n#pragma mapbox: initialize highp vec4 halo_color\n#pragma mapbox: initialize lowp float opacity\n#pragma mapbox: initialize lowp float halo_width\n#pragma mapbox: initialize lowp float halo_blur\nfloat fade_opacity=v_data1[2];if (v_data1.w==ICON) {vec2 tex_icon=v_data0.zw;lowp float alpha=opacity*fade_opacity;fragColor=texture(u_texture_icon,tex_icon)*alpha;\n#ifdef OVERDRAW_INSPECTOR\nfragColor=vec4(1.0);\n#endif\nreturn;}vec2 tex=v_data0.xy;float EDGE_GAMMA=0.105/u_device_pixel_ratio;float gamma_scale=v_data1.x;float size=v_data1.y;float fontScale=size/24.0;lowp vec4 color=fill_color;highp float gamma=EDGE_GAMMA/(fontScale*u_gamma_scale);lowp float buff=(256.0-64.0)/256.0;if (u_is_halo) {color=halo_color;gamma=(halo_blur*1.19/SDF_PX+EDGE_GAMMA)/(fontScale*u_gamma_scale);buff=(6.0-halo_width/fontScale)/SDF_PX;}lowp float dist=texture(u_texture,tex).a;highp float gamma_scaled=gamma*gamma_scale;highp float alpha=smoothstep(buff-gamma_scaled,buff+gamma_scaled,dist);fragColor=color*(alpha*opacity*fade_opacity);\n#ifdef OVERDRAW_INSPECTOR\nfragColor=vec4(1.0);\n#endif\n}","in vec4 a_pos_offset;in vec4 a_data;in vec3 a_projected_pos;in float a_fade_opacity;uniform bool u_is_size_zoom_constant;uniform bool u_is_size_feature_constant;uniform highp float u_size_t;uniform highp float u_size;uniform mat4 u_label_plane_matrix;uniform mat4 u_coord_matrix;uniform bool u_is_text;uniform bool u_pitch_with_map;uniform highp float u_pitch;uniform bool u_rotate_symbol;uniform highp float u_aspect_ratio;uniform highp float u_camera_to_center_distance;uniform float u_fade_change;uniform vec2 u_texsize;uniform vec2 u_texsize_icon;uniform bool u_is_along_line;uniform bool u_is_variable_anchor;uniform vec2 u_translation;uniform float u_pitched_scale;out vec4 v_data0;out vec4 v_data1;\n#pragma mapbox: define highp vec4 fill_color\n#pragma mapbox: define highp vec4 halo_color\n#pragma mapbox: define lowp float opacity\n#pragma mapbox: define lowp float halo_width\n#pragma mapbox: define lowp float halo_blur\nvoid main() {\n#pragma mapbox: initialize highp vec4 fill_color\n#pragma mapbox: initialize highp vec4 halo_color\n#pragma mapbox: initialize lowp float opacity\n#pragma mapbox: initialize lowp float halo_width\n#pragma mapbox: initialize lowp float halo_blur\nvec2 a_pos=a_pos_offset.xy;vec2 a_offset=a_pos_offset.zw;vec2 a_tex=a_data.xy;vec2 a_size=a_data.zw;float a_size_min=floor(a_size[0]*0.5);float is_sdf=a_size[0]-2.0*a_size_min;float ele=get_elevation(a_pos);highp float segment_angle=-a_projected_pos[2];float size;if (!u_is_size_zoom_constant && !u_is_size_feature_constant) {size=mix(a_size_min,a_size[1],u_size_t)/128.0;} else if (u_is_size_zoom_constant && !u_is_size_feature_constant) {size=a_size_min/128.0;} else {size=u_size;}vec2 translated_a_pos=a_pos+u_translation;vec4 projectedPoint=projectTileWithElevation(translated_a_pos,ele);highp float camera_to_anchor_distance=projectedPoint.w;highp float distance_ratio=u_pitch_with_map ?\ncamera_to_anchor_distance/u_camera_to_center_distance :\nu_camera_to_center_distance/camera_to_anchor_distance;highp float perspective_ratio=clamp(0.5+0.5*distance_ratio,0.0,4.0);size*=perspective_ratio;float fontScale=size/24.0;highp float symbol_rotation=0.0;if (u_rotate_symbol) {vec4 offsetProjectedPoint=projectTileWithElevation(translated_a_pos+vec2(1,0),ele);vec2 a=projectedPoint.xy/projectedPoint.w;vec2 b=offsetProjectedPoint.xy/offsetProjectedPoint.w;symbol_rotation=atan((b.y-a.y)/u_aspect_ratio,b.x-a.x);}highp float angle_sin=sin(segment_angle+symbol_rotation);highp float angle_cos=cos(segment_angle+symbol_rotation);mat2 rotation_matrix=mat2(angle_cos,-1.0*angle_sin,angle_sin,angle_cos);vec4 projected_pos;if (u_is_along_line || u_is_variable_anchor) {projected_pos=vec4(a_projected_pos.xy,ele,1.0);} else if (u_pitch_with_map) {projected_pos=u_label_plane_matrix*vec4(a_projected_pos.xy+u_translation,ele,1.0);} else {projected_pos=u_label_plane_matrix*projectTileWithElevation(a_projected_pos.xy+u_translation,ele);}float z=float(u_pitch_with_map)*projected_pos.z/projected_pos.w;float projectionScaling=1.0;\n#ifdef GLOBE\nif(u_pitch_with_map && !u_is_along_line) {float anchor_pos_tile_y=(u_coord_matrix*vec4(projected_pos.xy/projected_pos.w,z,1.0)).y;projectionScaling=mix(projectionScaling,1.0/circumferenceRatioAtTileY(anchor_pos_tile_y)*u_pitched_scale,u_projection_transition);}\n#endif\nvec4 finalPos=u_coord_matrix*vec4(projected_pos.xy/projected_pos.w+rotation_matrix*(a_offset/32.0*fontScale)*projectionScaling,z,1.0);if(u_pitch_with_map) {finalPos=projectTileWithElevation(finalPos.xy,finalPos.z);}float gamma_scale=finalPos.w;gl_Position=finalPos;vec2 fade_opacity=unpack_opacity(a_fade_opacity);float visibility=calculate_visibility(projectedPoint);float fade_change=fade_opacity[1] > 0.5 ? u_fade_change :-u_fade_change;float interpolated_fade_opacity=max(0.0,min(visibility,fade_opacity[0]+fade_change));v_data0.xy=a_tex/u_texsize;v_data0.zw=a_tex/u_texsize_icon;v_data1=vec4(gamma_scale,size,interpolated_fade_opacity,is_sdf);}"),terrain:Bt("uniform sampler2D u_texture;uniform vec4 u_fog_color;uniform vec4 u_horizon_color;uniform float u_fog_ground_blend;uniform float u_fog_ground_blend_opacity;uniform float u_horizon_fog_blend;uniform bool u_is_globe_mode;in vec2 v_texture_pos;in float v_fog_depth;const float gamma=2.2;vec4 gammaToLinear(vec4 color) {return pow(color,vec4(gamma));}vec4 linearToGamma(vec4 color) {return pow(color,vec4(1.0/gamma));}void main() {vec4 surface_color=texture(u_texture,vec2(v_texture_pos.x,1.0-v_texture_pos.y));if (!u_is_globe_mode && v_fog_depth > u_fog_ground_blend) {vec4 surface_color_linear=gammaToLinear(surface_color);float blend_color=smoothstep(0.0,1.0,max((v_fog_depth-u_horizon_fog_blend)/(1.0-u_horizon_fog_blend),0.0));vec4 fog_horizon_color_linear=mix(gammaToLinear(u_fog_color),gammaToLinear(u_horizon_color),blend_color);float factor_fog=max(v_fog_depth-u_fog_ground_blend,0.0)/(1.0-u_fog_ground_blend);fragColor=linearToGamma(mix(surface_color_linear,fog_horizon_color_linear,pow(factor_fog,2.0)*u_fog_ground_blend_opacity));} else {fragColor=surface_color;}}","in vec3 a_pos3d;uniform mat4 u_fog_matrix;uniform float u_ele_delta;out vec2 v_texture_pos;out float v_fog_depth;void main() {float ele=get_elevation(a_pos3d.xy);float ele_delta=a_pos3d.z==1.0 ? u_ele_delta : 0.0;v_texture_pos=a_pos3d.xy/8192.0;gl_Position=projectTileFor3D(a_pos3d.xy,get_elevation(a_pos3d.xy)-ele_delta);vec4 pos=u_fog_matrix*vec4(a_pos3d.xy,ele,1.0);v_fog_depth=pos.z/pos.w*0.5+0.5;}"),terrainDepth:Bt("in float v_depth;const highp vec4 bitSh=vec4(256.*256.*256.,256.*256.,256.,1.);const highp vec4 bitMsk=vec4(0.,vec3(1./256.0));highp vec4 pack(highp float value) {highp vec4 comp=fract(value*bitSh);comp-=comp.xxyz*bitMsk;return comp;}void main() {fragColor=pack(v_depth);}","in vec3 a_pos3d;uniform float u_ele_delta;out float v_depth;void main() {float ele=get_elevation(a_pos3d.xy);float ele_delta=a_pos3d.z==1.0 ? u_ele_delta : 0.0;gl_Position=projectTileFor3D(a_pos3d.xy,ele-ele_delta);v_depth=gl_Position.z/gl_Position.w;}"),terrainCoords:Bt("precision mediump float;uniform sampler2D u_texture;uniform float u_terrain_coords_id;in vec2 v_texture_pos;void main() {vec4 rgba=texture(u_texture,v_texture_pos);fragColor=vec4(rgba.r,rgba.g,rgba.b,u_terrain_coords_id);}","in vec3 a_pos3d;uniform float u_ele_delta;out vec2 v_texture_pos;void main() {float ele=get_elevation(a_pos3d.xy);float ele_delta=a_pos3d.z==1.0 ? u_ele_delta : 0.0;v_texture_pos=a_pos3d.xy/8192.0;gl_Position=projectTileFor3D(a_pos3d.xy,ele-ele_delta);}"),projectionErrorMeasurement:Bt("in vec4 v_output_error_encoded;void main() {fragColor=v_output_error_encoded;}","in vec2 a_pos;uniform highp float u_input;uniform highp float u_output_expected;out vec4 v_output_error_encoded;void main() {float real_output=2.0*atan(exp(PI-(u_input*PI*2.0)))-PI*0.5;float error=real_output-u_output_expected;float abs_error=abs(error)*128.0;v_output_error_encoded.x=min(floor(abs_error*256.0),255.0)/255.0;abs_error-=v_output_error_encoded.x;v_output_error_encoded.y=min(floor(abs_error*65536.0),255.0)/255.0;abs_error-=v_output_error_encoded.x/255.0;v_output_error_encoded.z=min(floor(abs_error*16777216.0),255.0)/255.0;v_output_error_encoded.w=error >=0.0 ? 1.0 : 0.0;gl_Position=vec4(a_pos,0.0,1.0);}"),atmosphere:Bt("in vec3 view_direction;uniform vec3 u_sun_pos;uniform vec3 u_globe_position;uniform float u_globe_radius;uniform float u_atmosphere_blend;/**Shader use from https:*Made some change to adapt to MapLibre Globe geometry*/const float PI=3.141592653589793;const int iSteps=5;const int jSteps=3;/*radius of the planet*/const float EARTH_RADIUS=6371e3;/*radius of the atmosphere*/const float ATMOS_RADIUS=6471e3;vec2 rsi(vec3 r0,vec3 rd,float sr) {float a=dot(rd,rd);float b=2.0*dot(rd,r0);float c=dot(r0,r0)-(sr*sr);float d=(b*b)-4.0*a*c;if (d < 0.0) return vec2(1e5,-1e5);return vec2((-b-sqrt(d))/(2.0*a),(-b+sqrt(d))/(2.0*a));}vec4 atmosphere(vec3 r,vec3 r0,vec3 pSun,float iSun,float rPlanet,float rAtmos,vec3 kRlh,float kMie,float shRlh,float shMie,float g) {pSun=normalize(pSun);r=normalize(r);vec2 p=rsi(r0,r,rAtmos);if (p.x > p.y) {return vec4(0.0,0.0,0.0,1.0);}if (p.x < 0.0) {p.x=0.0;}vec3 pos=r0+r*p.x;vec2 p2=rsi(r0,r,rPlanet);if (p2.x <=p2.y && p2.x > 0.0) {p.y=min(p.y,p2.x);}float iStepSize=(p.y-p.x)/float(iSteps);float iTime=p.x+iStepSize*0.5;vec3 totalRlh=vec3(0,0,0);vec3 totalMie=vec3(0,0,0);float iOdRlh=0.0;float iOdMie=0.0;float mu=dot(r,pSun);float mumu=mu*mu;float gg=g*g;float pRlh=3.0/(16.0*PI)*(1.0+mumu);float pMie=3.0/(8.0*PI)*((1.0-gg)*(mumu+1.0))/(pow(1.0+gg-2.0*mu*g,1.5)*(2.0+gg));for (int i=0; i < iSteps; i++) {vec3 iPos=r0+r*iTime;float iHeight=length(iPos)-rPlanet;float odStepRlh=exp(-iHeight/shRlh)*iStepSize;float odStepMie=exp(-iHeight/shMie)*iStepSize;iOdRlh+=odStepRlh;iOdMie+=odStepMie;float jStepSize=rsi(iPos,pSun,rAtmos).y/float(jSteps);float jTime=jStepSize*0.5;float jOdRlh=0.0;float jOdMie=0.0;for (int j=0; j < jSteps; j++) {vec3 jPos=iPos+pSun*jTime;float jHeight=length(jPos)-rPlanet;jOdRlh+=exp(-jHeight/shRlh)*jStepSize;jOdMie+=exp(-jHeight/shMie)*jStepSize;jTime+=jStepSize;}vec3 attn=exp(-(kMie*(iOdMie+jOdMie)+kRlh*(iOdRlh+jOdRlh)));totalRlh+=odStepRlh*attn;totalMie+=odStepMie*attn;iTime+=iStepSize;}float opacity=exp(-(length(kRlh)*length(totalRlh)+kMie*length(totalMie)));vec3 color=iSun*(pRlh*kRlh*totalRlh+pMie*kMie*totalMie);return vec4(color,opacity);}void main() {vec3 scale_camera_pos=-u_globe_position*EARTH_RADIUS/u_globe_radius;vec4 color=atmosphere(normalize(view_direction),scale_camera_pos,u_sun_pos,22.0,EARTH_RADIUS,ATMOS_RADIUS,vec3(5.5e-6,13.0e-6,22.4e-6),21e-6,8e3,1.2e3,0.758\n);color.rgb=1.0-exp(-1.0*color.rgb);color=pow(color,vec4(1.0/2.2));fragColor=vec4(color.rgb,1.0-color.a)*u_atmosphere_blend;}","in vec2 a_pos;uniform mat4 u_inv_proj_matrix;out vec3 view_direction;void main() {view_direction=(u_inv_proj_matrix*vec4(a_pos,0.0,1.0)).xyz;gl_Position=vec4(a_pos,0.0,1.0);}"),sky:Bt("uniform vec4 u_sky_color;uniform vec4 u_horizon_color;uniform vec2 u_horizon;uniform vec2 u_horizon_normal;uniform float u_sky_horizon_blend;uniform float u_sky_blend;void main() {float x=gl_FragCoord.x;float y=gl_FragCoord.y;float blend=(y-u_horizon.y)*u_horizon_normal.y+(x-u_horizon.x)*u_horizon_normal.x;if (blend > 0.0) {if (blend < u_sky_horizon_blend) {fragColor=mix(u_sky_color,u_horizon_color,pow(1.0-blend/u_sky_horizon_blend,2.0));} else {fragColor=u_sky_color;}}fragColor=mix(fragColor,vec4(vec3(0.0),0.0),u_sky_blend);}","in vec2 a_pos;void main() {gl_Position=vec4(a_pos,1.0,1.0);}")};function Bt(e,t){const i=/#pragma mapbox: ([\w]+) ([\w]+) ([\w]+) ([\w]+)/g,n=t.match(/in ([\w]+) ([\w]+)/g),r=e.match(/uniform ([\w]+) ([\w]+)([\s]*)([\w]*)/g),o=t.match(/uniform ([\w]+) ([\w]+)([\s]*)([\w]*)/g),s=o?o.concat(r):r,a={};return{fragmentSource:e=e.replace(i,(e,t,i,n,r)=>(a[r]=!0,"define"===t?`\n#ifndef HAS_UNIFORM_u_${r}\nin ${i} ${n} ${r};\n#else\nuniform ${i} ${n} u_${r};\n#endif\n`:`\n#ifdef HAS_UNIFORM_u_${r}\n ${i} ${n} ${r} = u_${r};\n#endif\n`)),vertexSource:t=t.replace(i,(e,t,i,n,r)=>{const o="float"===n?"vec2":"vec4",s=r.match(/color/)?"color":o;return a[r]?"define"===t?`\n#ifndef HAS_UNIFORM_u_${r}\nuniform lowp float u_${r}_t;\nin ${i} ${o} a_${r};\nout ${i} ${n} ${r};\n#else\nuniform ${i} ${n} u_${r};\n#endif\n`:"vec4"===s?`\n#ifndef HAS_UNIFORM_u_${r}\n ${r} = a_${r};\n#else\n ${i} ${n} ${r} = u_${r};\n#endif\n`:`\n#ifndef HAS_UNIFORM_u_${r}\n ${r} = unpack_mix_${s}(a_${r}, u_${r}_t);\n#else\n ${i} ${n} ${r} = u_${r};\n#endif\n`:"define"===t?`\n#ifndef HAS_UNIFORM_u_${r}\nuniform lowp float u_${r}_t;\nin ${i} ${o} a_${r};\n#else\nuniform ${i} ${n} u_${r};\n#endif\n`:"vec4"===s?`\n#ifndef HAS_UNIFORM_u_${r}\n ${i} ${n} ${r} = a_${r};\n#else\n ${i} ${n} ${r} = u_${r};\n#endif\n`:`\n#ifndef HAS_UNIFORM_u_${r}\n ${i} ${n} ${r} = unpack_mix_${s}(a_${r}, u_${r}_t);\n#else\n ${i} ${n} ${r} = u_${r};\n#endif\n`}),staticAttributes:n,staticUniforms:s}}class It{constructor(e,t,i){this.vertexBuffer=e,this.indexBuffer=t,this.segments=i}destroy(){this.vertexBuffer.destroy(),this.indexBuffer.destroy(),this.segments.destroy(),this.vertexBuffer=null,this.indexBuffer=null,this.segments=null}}var Mt=t.aT([{name:"a_pos",type:"Int16",components:2}]);const Pt="#define PROJECTION_MERCATOR",Rt="mercator";class Lt{constructor(){this._cachedMesh=null}get name(){return"mercator"}get useSubdivision(){return!1}get shaderVariantName(){return Rt}get shaderDefine(){return Pt}get shaderPreludeCode(){return St.projectionMercator}get vertexShaderPreludeCode(){return St.projectionMercator.vertexSource}get subdivisionGranularity(){return t.aU.noSubdivision}get useGlobeControls(){return!1}get transitionState(){return 0}get latitudeErrorCorrectionRadians(){return 0}destroy(){}updateGPUdependent(e){}getMeshFromTileID(e,i,n,r,o){if(this._cachedMesh)return this._cachedMesh;const s=new t.aV;s.emplaceBack(0,0),s.emplaceBack(t.a4,0),s.emplaceBack(0,t.a4),s.emplaceBack(t.a4,t.a4);const a=e.createVertexBuffer(s,Mt.members),l=t.aW.simpleSegment(0,0,4,2),c=new t.aX;c.emplaceBack(1,0,2),c.emplaceBack(1,2,3);const u=e.createIndexBuffer(c);return this._cachedMesh=new It(a,u,l),this._cachedMesh}recalculate(){}hasTransition(){return!1}setErrorQueryLatitudeDegrees(e){}}class Ft{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,i,n){return null!=i.top&&null!=e.top&&(this.top=t.G.number(e.top,i.top,n)),null!=i.bottom&&null!=e.bottom&&(this.bottom=t.G.number(e.bottom,i.bottom,n)),null!=i.left&&null!=e.left&&(this.left=t.G.number(e.left,i.left,n)),null!=i.right&&null!=e.right&&(this.right=t.G.number(e.right,i.right,n)),this}getCenter(e,i){const n=t.an((this.left+e-this.right)/2,0,e),r=t.an((this.top+i-this.bottom)/2,0,i);return new t.P(n,r)}equals(e){return this.top===e.top&&this.bottom===e.bottom&&this.left===e.left&&this.right===e.right}clone(){return new Ft(this.top,this.bottom,this.left,this.right)}toJSON(){return{top:this.top,bottom:this.bottom,left:this.left,right:this.right}}}function kt(e,t){if(!e.renderWorldCopies||e.lngRange)return;const i=t.lng-e.center.lng;t.lng+=i>180?-360:i<-180?360:0}function Dt(e){return Math.max(0,Math.floor(e))}class Ot{constructor(e,i){var n;this.applyConstrain=(e,t)=>null!==this._constrainOverride?this._constrainOverride(e,t):this._callbacks.defaultConstrain(e,t),this._callbacks=e,this._tileSize=512,this._renderWorldCopies=void 0===(null==i?void 0:i.renderWorldCopies)||!!(null==i?void 0:i.renderWorldCopies),this._minZoom=(null==i?void 0:i.minZoom)||0,this._maxZoom=(null==i?void 0:i.maxZoom)||22,this._minPitch=null==(null==i?void 0:i.minPitch)?0:null==i?void 0:i.minPitch,this._maxPitch=null==(null==i?void 0:i.maxPitch)?60:null==i?void 0:i.maxPitch,this._constrainOverride=null!==(n=null==i?void 0:i.constrainOverride)&&void 0!==n?n:null,this.setMaxBounds(),this._width=0,this._height=0,this._center=new t.V(0,0),this._elevation=0,this._zoom=0,this._tileZoom=Dt(this._zoom),this._scale=t.aq(this._zoom),this._bearingInRadians=0,this._fovInRadians=.6435011087932844,this._pitchInRadians=0,this._rollInRadians=0,this._unmodified=!0,this._edgeInsets=new Ft,this._minElevationForCurrentTile=0,this._autoCalculateNearFarZ=!0}apply(e,i,n){this._constrainOverride=e.constrainOverride,this._latRange=e.latRange,this._lngRange=e.lngRange,this._width=e.width,this._height=e.height,this._center=e.center,this._elevation=e.elevation,this._minElevationForCurrentTile=e.minElevationForCurrentTile,this._zoom=e.zoom,this._tileZoom=Dt(this._zoom),this._scale=t.aq(this._zoom),this._bearingInRadians=e.bearingInRadians,this._fovInRadians=e.fovInRadians,this._pitchInRadians=e.pitchInRadians,this._rollInRadians=e.rollInRadians,this._unmodified=e.unmodified,this._edgeInsets=new Ft(e.padding.top,e.padding.bottom,e.padding.left,e.padding.right),this._minZoom=e.minZoom,this._maxZoom=e.maxZoom,this._minPitch=e.minPitch,this._maxPitch=e.maxPitch,this._renderWorldCopies=e.renderWorldCopies,this._cameraToCenterDistance=e.cameraToCenterDistance,this._nearZ=e.nearZ,this._farZ=e.farZ,this._autoCalculateNearFarZ=!n&&e.autoCalculateNearFarZ,i&&this.constrainInternal(),this._calcMatrices()}get pixelsToClipSpaceMatrix(){return this._pixelsToClipSpaceMatrix}get clipSpaceToPixelsMatrix(){return this._clipSpaceToPixelsMatrix}get minElevationForCurrentTile(){return this._minElevationForCurrentTile}setMinElevationForCurrentTile(e){this._minElevationForCurrentTile=e}get tileSize(){return this._tileSize}get tileZoom(){return this._tileZoom}get scale(){return this._scale}get width(){return this._width}get height(){return this._height}get bearingInRadians(){return this._bearingInRadians}get lngRange(){return this._lngRange}get latRange(){return this._latRange}get pixelsToGLUnits(){return this._pixelsToGLUnits}get minZoom(){return this._minZoom}setMinZoom(e){this._minZoom!==e&&(this._minZoom=e,this.setZoom(this.applyConstrain(this._center,this.zoom).zoom))}get maxZoom(){return this._maxZoom}setMaxZoom(e){this._maxZoom!==e&&(this._maxZoom=e,this.setZoom(this.applyConstrain(this._center,this.zoom).zoom))}get minPitch(){return this._minPitch}setMinPitch(e){this._minPitch!==e&&(this._minPitch=e,this.setPitch(Math.max(this.pitch,e)))}get maxPitch(){return this._maxPitch}setMaxPitch(e){this._maxPitch!==e&&(this._maxPitch=e,this.setPitch(Math.min(this.pitch,e)))}get renderWorldCopies(){return this._renderWorldCopies}setRenderWorldCopies(e){void 0===e?e=!0:null===e&&(e=!1),this._renderWorldCopies=e}get constrainOverride(){return this._constrainOverride}setConstrainOverride(e){void 0===e&&(e=null),this._constrainOverride!==e&&(this._constrainOverride=e,this.constrainInternal(),this._calcMatrices())}get worldSize(){return this._tileSize*this._scale}get centerOffset(){return this.centerPoint._sub(this.size._div(2))}get size(){return new t.P(this._width,this._height)}get bearing(){return this._bearingInRadians/Math.PI*180}setBearing(e){const i=t.W(e,-180,180)*Math.PI/180;var r,o,s,a,l,c,u,h,d;this._bearingInRadians!==i&&(this._unmodified=!1,this._bearingInRadians=i,this._calcMatrices(),this._rotationMatrix=n(),r=this._rotationMatrix,s=-this._bearingInRadians,a=(o=this._rotationMatrix)[0],l=o[1],c=o[2],u=o[3],h=Math.sin(s),d=Math.cos(s),r[0]=a*d+c*h,r[1]=l*d+u*h,r[2]=a*-h+c*d,r[3]=l*-h+u*d)}get rotationMatrix(){return this._rotationMatrix}get pitchInRadians(){return this._pitchInRadians}get pitch(){return this._pitchInRadians/Math.PI*180}setPitch(e){const i=t.an(e,this.minPitch,this.maxPitch)/180*Math.PI;this._pitchInRadians!==i&&(this._unmodified=!1,this._pitchInRadians=i,this._calcMatrices())}get rollInRadians(){return this._rollInRadians}get roll(){return this._rollInRadians/Math.PI*180}setRoll(e){const t=e/180*Math.PI;this._rollInRadians!==t&&(this._unmodified=!1,this._rollInRadians=t,this._calcMatrices())}get fovInRadians(){return this._fovInRadians}get fov(){return t.aY(this._fovInRadians)}setFov(e){e=t.an(e,.1,150),this.fov!==e&&(this._unmodified=!1,this._fovInRadians=t.ap(e),this._calcMatrices())}get zoom(){return this._zoom}setZoom(e){const i=this.applyConstrain(this._center,e).zoom;this._zoom!==i&&(this._unmodified=!1,this._zoom=i,this._tileZoom=Math.max(0,Math.floor(i)),this._scale=t.aq(i),this.constrainInternal(),this._calcMatrices())}get center(){return this._center}setCenter(e){e.lat===this._center.lat&&e.lng===this._center.lng||(this._unmodified=!1,this._center=e,this.constrainInternal(),this._calcMatrices())}get elevation(){return this._elevation}setElevation(e){e!==this._elevation&&(this._elevation=e,this.constrainInternal(),this._calcMatrices())}get padding(){return this._edgeInsets.toJSON()}setPadding(e){this._edgeInsets.equals(e)||(this._unmodified=!1,this._edgeInsets.interpolate(this._edgeInsets,e,1),this._calcMatrices())}get centerPoint(){return this._edgeInsets.getCenter(this._width,this._height)}get pixelsPerMeter(){return this._pixelPerMeter}get unmodified(){return this._unmodified}get cameraToCenterDistance(){return this._cameraToCenterDistance}get nearZ(){return this._nearZ}get farZ(){return this._farZ}get autoCalculateNearFarZ(){return this._autoCalculateNearFarZ}overrideNearFarZ(e,t){this._autoCalculateNearFarZ=!1,this._nearZ=e,this._farZ=t,this._calcMatrices()}clearNearFarZOverride(){this._autoCalculateNearFarZ=!0,this._calcMatrices()}isPaddingEqual(e){return this._edgeInsets.equals(e)}interpolatePadding(e,t,i){this._unmodified=!1,this._edgeInsets.interpolate(e,t,i),this.constrainInternal(),this._calcMatrices()}resize(e,t,i=!0){this._width=e,this._height=t,i&&this.constrainInternal(),this._calcMatrices()}getMaxBounds(){return this._latRange&&2===this._latRange.length&&this._lngRange&&2===this._lngRange.length?new Z([this._lngRange[0],this._latRange[0]],[this._lngRange[1],this._latRange[1]]):null}setMaxBounds(e){e?(this._lngRange=[e.getWest(),e.getEast()],this._latRange=[e.getSouth(),e.getNorth()],this.constrainInternal()):(this._lngRange=null,this._latRange=[-t.ao,t.ao])}getCameraQueryGeometry(e,i){if(1===i.length)return[i[0],e];{const{minX:n,minY:r,maxX:o,maxY:s}=t.ab.fromPoints(i).extend(e);return[new t.P(n,r),new t.P(o,r),new t.P(o,s),new t.P(n,s),new t.P(n,r)]}}constrainInternal(){if(!this.center||!this._width||!this._height||this._constraining)return;this._constraining=!0;const e=this._unmodified,{center:t,zoom:i}=this.applyConstrain(this.center,this.zoom);this.setCenter(t),this.setZoom(i),this._unmodified=e,this._constraining=!1}_calcMatrices(){if(this._width&&this._height){this._pixelsToGLUnits=[2/this._width,-2/this._height];let e=t.ar(new Float64Array(16));t.Q(e,e,[this._width/2,-this._height/2,1]),t.O(e,e,[1,-1,0]),this._clipSpaceToPixelsMatrix=e,e=t.ar(new Float64Array(16)),t.Q(e,e,[1,-1,1]),t.O(e,e,[-1,-1,0]),t.Q(e,e,[2/this._width,2/this._height,1]),this._pixelsToClipSpaceMatrix=e,this._cameraToCenterDistance=.5/Math.tan(this.fovInRadians/2)*this._height}this._callbacks.calcMatrices()}calculateCenterFromCameraLngLatAlt(e,i,n,r){const o=void 0!==n?n:this.bearing,s=r=void 0!==r?r:this.pitch,a=t.aa.fromLngLat(e,i),l=-Math.cos(t.ap(s)),c=Math.sin(t.ap(s)),u=c*Math.sin(t.ap(o)),h=-c*Math.cos(t.ap(o));let d=this.elevation;const p=i-d;let f;l*p>=0||Math.abs(l)<.1?(f=1e4,d=i+f*l):f=-p/l;let m,g,_=t.aZ(1,a.y),A=0;do{if(A+=1,A>10)break;g=f/_,m=new t.aa(a.x+u*g,a.y+h*g),_=1/m.meterInMercatorCoordinateUnits()}while(Math.abs(f-g*_)>1e-12);return{center:m.toLngLat(),elevation:d,zoom:t.at(this.height/2/Math.tan(this.fovInRadians/2)/g/this.tileSize)}}recalculateZoomAndCenter(e){if(this.elevation-e==0)return;const i=t.as(1,this.center.lat)*this.worldSize,n=this.cameraToCenterDistance/i,r=t.aa.fromLngLat(this.center,this.elevation),o=ye(this.center,this.elevation,this.pitch,this.bearing,n);this._elevation=e;const s=this.calculateCenterFromCameraLngLatAlt(o.toLngLat(),t.aZ(o.z,r.y),this.bearing,this.pitch);this._elevation=s.elevation,this._center=s.center,this.setZoom(s.zoom)}getCameraPoint(){const e=Math.tan(this.pitchInRadians)*(this.cameraToCenterDistance||1);return this.centerPoint.add(new t.P(e*Math.sin(this.rollInRadians),e*Math.cos(this.rollInRadians)))}getCameraAltitude(){return Math.cos(this.pitchInRadians)*this._cameraToCenterDistance/this._pixelPerMeter+this.elevation}getCameraLngLat(){const e=t.as(1,this.center.lat)*this.worldSize;return ye(this.center,this.elevation,this.pitch,this.bearing,this.cameraToCenterDistance/e).toLngLat()}getMercatorTileCoordinates(e){if(!e)return[0,0,1,1];const i=e.canonical.z>=0?1<this.max[0]||e.aabb.min[1]>this.max[1]||e.aabb.min[2]>this.max[2]||e.aabb.max[0]0?(t+=e[n]*this.min[n],i+=e[n]*this.max[n]):(i+=e[n]*this.min[n],t+=e[n]*this.max[n]);return t>=0?2:i<0?0:1}}class Ut{distanceToTile2d(e,t,i,n){const r=n.distanceX([e,t]),o=n.distanceY([e,t]);return Math.hypot(r,o)}getWrap(e,t,i){return i}getTileBoundingVolume(e,i,n,r){var o,s;let a=0,l=0;if(null==r?void 0:r.terrain){const c=new t.a1(e.z,i,e.z,e.x,e.y),u=r.terrain.getMinMaxElevation(c);a=null!==(o=u.minElevation)&&void 0!==o?o:Math.min(0,n),l=null!==(s=u.maxElevation)&&void 0!==s?s:Math.max(0,n)}const c=1<r}allowWorldCopies(){return!0}prepareNextFrame(){}}class Nt{constructor(e,t,i){this.points=e,this.planes=t,this.aabb=i}static fromInvProjectionMatrix(e,i=1,n=0,r,o){const s=o?[[6,5,4],[0,1,2],[0,3,7],[2,1,5],[3,2,6],[0,4,5]]:[[0,1,2],[6,5,4],[0,3,7],[2,1,5],[3,2,6],[0,4,5]],a=Math.pow(2,n),l=[[-1,1,-1,1],[1,1,-1,1],[1,-1,-1,1],[-1,-1,-1,1],[-1,1,1,1],[1,1,1,1],[1,-1,1,1],[-1,-1,1,1]].map(n=>function(e,i,n,r){const o=t.aG([],e,i),s=1/o[3]/n*r;return t.b5(o,o,[s,s,1/o[3],s])}(n,e,i,a));r&&function(e,i,n,r){const o=r?4:0,s=r?0:4;let a=0;const l=[],c=[];for(let i=0;i<4;i++){const n=t.b1([],e[i+s],e[i+o]),r=t.b6(n);t.a_(n,n,1/r),l.push(r),c.push(n)}for(let i=0;i<4;i++){const r=t.b7(e[i+o],c[i],n);a=null!==r&&r>=0?Math.max(a,r):Math.max(a,l[i])}const u=function(e,i){const n=t.b1([],e[i[0]],e[i[1]]),r=t.b1([],e[i[2]],e[i[1]]),o=[0,0,0,0];return t.b2(o,t.b3([],n,r)),o[3]=-t.b4(o,e[i[0]]),o}(e,i),h=function(e,i){const n=t.b8(e),r=t.b9([],e,1/n),o=t.b1([],i,t.a_([],r,t.b4(i,r))),s=t.b8(o);if(s>0){const e=Math.sqrt(1-r[3]*r[3]),n=t.a_([],r,-r[3]),a=t.a$([],n,t.a_([],o,e/s));return t.ba(i,a)}return null}(n,u);if(null!==h){const e=h/t.b4(c[0],u);a=Math.min(a,e)}for(let t=0;t<4;t++){const i=Math.min(a,l[t]);e[t+s]=[e[t+o][0]+c[t][0]*i,e[t+o][1]+c[t][1]*i,e[t+o][2]+c[t][2]*i,1]}}(l,s[0],r,o);const c=s.map(e=>{const i=t.b1([],l[e[0]],l[e[1]]),n=t.b1([],l[e[2]],l[e[1]]),r=t.b2([],t.b3([],i,n)),o=-t.b4(r,l[e[1]]);return r.concat(o)}),u=[Number.POSITIVE_INFINITY,Number.POSITIVE_INFINITY,Number.POSITIVE_INFINITY],h=[Number.NEGATIVE_INFINITY,Number.NEGATIVE_INFINITY,Number.NEGATIVE_INFINITY];for(const e of l)for(let t=0;t<3;t++)u[t]=Math.min(u[t],e[t]),h[t]=Math.max(h[t],e[t]);return new Nt(l,c,new zt(u,h))}}class Vt{get pixelsToClipSpaceMatrix(){return this._helper.pixelsToClipSpaceMatrix}get clipSpaceToPixelsMatrix(){return this._helper.clipSpaceToPixelsMatrix}get pixelsToGLUnits(){return this._helper.pixelsToGLUnits}get centerOffset(){return this._helper.centerOffset}get size(){return this._helper.size}get rotationMatrix(){return this._helper.rotationMatrix}get centerPoint(){return this._helper.centerPoint}get pixelsPerMeter(){return this._helper.pixelsPerMeter}setMinZoom(e){this._helper.setMinZoom(e)}setMaxZoom(e){this._helper.setMaxZoom(e)}setMinPitch(e){this._helper.setMinPitch(e)}setMaxPitch(e){this._helper.setMaxPitch(e)}setRenderWorldCopies(e){this._helper.setRenderWorldCopies(e)}setBearing(e){this._helper.setBearing(e)}setPitch(e){this._helper.setPitch(e)}setRoll(e){this._helper.setRoll(e)}setFov(e){this._helper.setFov(e)}setZoom(e){this._helper.setZoom(e)}setCenter(e){this._helper.setCenter(e)}setElevation(e){this._helper.setElevation(e)}setMinElevationForCurrentTile(e){this._helper.setMinElevationForCurrentTile(e)}setPadding(e){this._helper.setPadding(e)}interpolatePadding(e,t,i){return this._helper.interpolatePadding(e,t,i)}isPaddingEqual(e){return this._helper.isPaddingEqual(e)}resize(e,t,i=!0){this._helper.resize(e,t,i)}getMaxBounds(){return this._helper.getMaxBounds()}setMaxBounds(e){this._helper.setMaxBounds(e)}setConstrainOverride(e){this._helper.setConstrainOverride(e)}overrideNearFarZ(e,t){this._helper.overrideNearFarZ(e,t)}clearNearFarZOverride(){this._helper.clearNearFarZOverride()}getCameraQueryGeometry(e){return this._helper.getCameraQueryGeometry(this.getCameraPoint(),e)}get tileSize(){return this._helper.tileSize}get tileZoom(){return this._helper.tileZoom}get scale(){return this._helper.scale}get worldSize(){return this._helper.worldSize}get width(){return this._helper.width}get height(){return this._helper.height}get lngRange(){return this._helper.lngRange}get latRange(){return this._helper.latRange}get minZoom(){return this._helper.minZoom}get maxZoom(){return this._helper.maxZoom}get zoom(){return this._helper.zoom}get center(){return this._helper.center}get minPitch(){return this._helper.minPitch}get maxPitch(){return this._helper.maxPitch}get pitch(){return this._helper.pitch}get pitchInRadians(){return this._helper.pitchInRadians}get roll(){return this._helper.roll}get rollInRadians(){return this._helper.rollInRadians}get bearing(){return this._helper.bearing}get bearingInRadians(){return this._helper.bearingInRadians}get fov(){return this._helper.fov}get fovInRadians(){return this._helper.fovInRadians}get elevation(){return this._helper.elevation}get minElevationForCurrentTile(){return this._helper.minElevationForCurrentTile}get padding(){return this._helper.padding}get unmodified(){return this._helper.unmodified}get renderWorldCopies(){return this._helper.renderWorldCopies}get cameraToCenterDistance(){return this._helper.cameraToCenterDistance}get constrainOverride(){return this._helper.constrainOverride}get nearZ(){return this._helper.nearZ}get farZ(){return this._helper.farZ}get autoCalculateNearFarZ(){return this._helper.autoCalculateNearFarZ}setTransitionState(e,t){}constructor(e){this._posMatrixCache=new Map,this._alignedPosMatrixCache=new Map,this._fogMatrixCacheF32=new Map,this.defaultConstrain=(e,i)=>{i=t.an(+i,this.minZoom,this.maxZoom);const n={center:new t.V(e.lng,e.lat),zoom:i};let r=this._helper._lngRange;if(!this._helper._renderWorldCopies&&null===r){const e=180-1e-10;r=[-e,e]}const o=this.tileSize*t.aq(n.zoom);let s=0,a=o,l=0,c=o,u=0,h=0;const{x:d,y:p}=this.size;if(this._helper._latRange){const e=this._helper._latRange;s=t.X(e[1])*o,a=t.X(e[0])*o,a-sa&&(_=a-e)}if(r){const e=(l+c)/2;let i=f;this._helper._renderWorldCopies&&(i=t.W(f,e-o/2,e+o/2));const n=d/2;i-nc&&(g=c-n)}if(void 0!==g||void 0!==_){const e=new t.P(null!=g?g:f,null!=_?_:m);n.center=ge(o,e).wrap()}return n},this.applyConstrain=(e,t)=>this._helper.applyConstrain(e,t),this._helper=new Ot({calcMatrices:()=>{this._calcMatrices()},defaultConstrain:(e,t)=>this.defaultConstrain(e,t)},e),this._coveringTilesDetailsProvider=new Ut}clone(){const e=new Vt;return e.apply(this),e}apply(e,t,i){this._helper.apply(e,t,i)}get cameraPosition(){return this._cameraPosition}get projectionMatrix(){return this._projectionMatrix}get modelViewProjectionMatrix(){return this._viewProjMatrix}get inverseProjectionMatrix(){return this._invProjMatrix}get mercatorMatrix(){return this._mercatorMatrix}getVisibleUnwrappedCoordinates(e){const i=[new t.bb(0,e)];if(this._helper._renderWorldCopies){const n=this.screenPointToMercatorCoordinate(new t.P(0,0)),r=this.screenPointToMercatorCoordinate(new t.P(this._helper._width,0)),o=this.screenPointToMercatorCoordinate(new t.P(this._helper._width,this._helper._height)),s=this.screenPointToMercatorCoordinate(new t.P(0,this._helper._height)),a=Math.floor(Math.min(n.x,r.x,o.x,s.x)),l=Math.floor(Math.max(n.x,r.x,o.x,s.x)),c=1;for(let n=a-c;n<=l+c;n++)0!==n&&i.push(new t.bb(n,e))}return i}getCameraFrustum(){return Nt.fromInvProjectionMatrix(this._invViewProjMatrix,this.worldSize)}getClippingPlane(){return null}getCoveringTilesDetailsProvider(){return this._coveringTilesDetailsProvider}recalculateZoomAndCenter(e){const t=this.screenPointToLocation(this.centerPoint,e),i=e?e.getElevationForLngLatZoom(t,this._helper._tileZoom):0;this._helper.recalculateZoomAndCenter(i)}setLocationAtPoint(e,i){const n=t.as(this.elevation,this.center.lat),r=this.screenPointToMercatorCoordinateAtZ(i,n),o=this.screenPointToMercatorCoordinateAtZ(this.centerPoint,n),s=t.aa.fromLngLat(e),a=new t.aa(s.x-(r.x-o.x),s.y-(r.y-o.y));this.setCenter(null==a?void 0:a.toLngLat()),this._helper._renderWorldCopies&&this.setCenter(this.center.wrap())}locationToScreenPoint(e,i){return i?this.coordinatePoint(t.aa.fromLngLat(e),i.getElevationForLngLatZoom(e,this._helper._tileZoom),this._pixelMatrix3D):this.coordinatePoint(t.aa.fromLngLat(e))}screenPointToLocation(e,t){var i;return null===(i=this.screenPointToMercatorCoordinate(e,t))||void 0===i?void 0:i.toLngLat()}screenPointToMercatorCoordinate(e,t){if(t){const i=t.pointCoordinate(e);if(null!=i)return i}return this.screenPointToMercatorCoordinateAtZ(e)}screenPointToMercatorCoordinateAtZ(e,i){const n=i||0,r=[e.x,e.y,0,1],o=[e.x,e.y,1,1];t.aG(r,r,this._pixelMatrixInverse),t.aG(o,o,this._pixelMatrixInverse);const s=r[3],a=o[3],l=r[1]/s,c=o[1]/a,u=r[2]/s,h=o[2]/a,d=u===h?0:(n-u)/(h-u);return new t.aa(t.G.number(r[0]/s,o[0]/a,d)/this.worldSize,t.G.number(l,c,d)/this.worldSize,n)}coordinatePoint(e,i=0,n=this._pixelMatrix){const r=[e.x*this.worldSize,e.y*this.worldSize,i,1];return t.aG(r,r,n),new t.P(r[0]/r[3],r[1]/r[3])}getBounds(){const e=Math.max(0,this._helper._height/2-_e(this));return(new Z).extend(this.screenPointToLocation(new t.P(0,e))).extend(this.screenPointToLocation(new t.P(this._helper._width,e))).extend(this.screenPointToLocation(new t.P(this._helper._width,this._helper._height))).extend(this.screenPointToLocation(new t.P(0,this._helper._height)))}isPointOnMapSurface(e,t){return t?null!=t.pointCoordinate(e):e.y>this.height/2-_e(this)}calculatePosMatrix(e,i=!1,n){var r;const o=null!==(r=e.key)&&void 0!==r?r:t.bc(e.wrap,e.canonical.z,e.canonical.z,e.canonical.x,e.canonical.y),s=i?this._alignedPosMatrixCache:this._posMatrixCache;if(s.has(o)){const e=s.get(o);return n?e.f32:e.f64}const a=Ae(e,this.worldSize);t.S(a,i?this._alignedProjMatrix:this._viewProjMatrix,a);const l={f64:a,f32:new Float32Array(a)};return s.set(o,l),n?l.f32:l.f64}calculateFogMatrix(e){const i=e.key,n=this._fogMatrixCacheF32;if(n.has(i))return n.get(i);const r=Ae(e,this.worldSize);return t.S(r,this._fogMatrix,r),n.set(i,new Float32Array(r)),n.get(i)}calculateCenterFromCameraLngLatAlt(e,t,i,n){return this._helper.calculateCenterFromCameraLngLatAlt(e,t,i,n)}_calculateNearFarZIfNeeded(e,i,n){if(!this._helper.autoCalculateNearFarZ)return;const r=Math.min(this.elevation,this.minElevationForCurrentTile,this.getCameraAltitude()-100),o=e-r*this._helper._pixelPerMeter/Math.cos(i),s=r<0?o:e,a=Math.PI/2+this.pitchInRadians,l=t.ap(this.fov)*(Math.abs(Math.cos(t.ap(this.roll)))*this.height+Math.abs(Math.sin(t.ap(this.roll)))*this.width)/this.height*(.5+n.y/this.height),c=Math.sin(l)*s/Math.sin(t.an(Math.PI-a-l,.01,Math.PI-.01)),u=_e(this),h=Math.atan(u/this._helper.cameraToCenterDistance),d=t.ap(.75),p=h>d?2*h*(.5+n.y/(2*u)):d,f=Math.sin(p)*s/Math.sin(t.an(Math.PI-a-p,.01,Math.PI-.01)),m=Math.min(c,f);this._helper._farZ=1.01*(Math.cos(Math.PI/2-i)*m+s),this._helper._nearZ=this._helper._height/50}_calcMatrices(){if(!this._helper._height)return;const e=this.centerOffset,i=me(this.worldSize,this.center),n=i.x,r=i.y;this._helper._pixelPerMeter=t.as(1,this.center.lat)*this.worldSize;const o=t.ap(Math.min(this.pitch,fe)),s=Math.max(this._helper.cameraToCenterDistance/2,this._helper.cameraToCenterDistance+this._helper._elevation*this._helper._pixelPerMeter/Math.cos(o));let a;this._calculateNearFarZIfNeeded(s,o,e),a=new Float64Array(16),t.bd(a,this.fovInRadians,this._helper._width/this._helper._height,this._helper._nearZ,this._helper._farZ),this._invProjMatrix=new Float64Array(16),t.aA(this._invProjMatrix,a),a[8]=2*-e.x/this._helper._width,a[9]=2*e.y/this._helper._height,this._projectionMatrix=t.be(a),t.Q(a,a,[1,-1,1]),t.O(a,a,[0,0,-this._helper.cameraToCenterDistance]),t.bf(a,a,-this.rollInRadians),t.bg(a,a,this.pitchInRadians),t.bf(a,a,-this.bearingInRadians),t.O(a,a,[-n,-r,0]),this._mercatorMatrix=t.Q([],a,[this.worldSize,this.worldSize,this.worldSize]),t.Q(a,a,[1,1,this._helper._pixelPerMeter]),this._pixelMatrix=t.S(new Float64Array(16),this.clipSpaceToPixelsMatrix,a),t.O(a,a,[0,0,-this.elevation]),this._viewProjMatrix=a,this._invViewProjMatrix=t.aA([],a);const l=[0,0,-1,1];t.aG(l,l,this._invViewProjMatrix),this._cameraPosition=[l[0]/l[3],l[1]/l[3],l[2]/l[3]],this._fogMatrix=new Float64Array(16),t.bd(this._fogMatrix,this.fovInRadians,this.width/this.height,s,this._helper._farZ),this._fogMatrix[8]=2*-e.x/this.width,this._fogMatrix[9]=2*e.y/this.height,t.Q(this._fogMatrix,this._fogMatrix,[1,-1,1]),t.O(this._fogMatrix,this._fogMatrix,[0,0,-this.cameraToCenterDistance]),t.bf(this._fogMatrix,this._fogMatrix,-this.rollInRadians),t.bg(this._fogMatrix,this._fogMatrix,this.pitchInRadians),t.bf(this._fogMatrix,this._fogMatrix,-this.bearingInRadians),t.O(this._fogMatrix,this._fogMatrix,[-n,-r,0]),t.Q(this._fogMatrix,this._fogMatrix,[1,1,this._helper._pixelPerMeter]),t.O(this._fogMatrix,this._fogMatrix,[0,0,-this.elevation]),this._pixelMatrix3D=t.S(new Float64Array(16),this.clipSpaceToPixelsMatrix,a);const c=this._helper._width%2/2,u=this._helper._height%2/2,h=Math.cos(this.bearingInRadians),d=Math.sin(-this.bearingInRadians),p=n-Math.round(n)+h*c+d*u,f=r-Math.round(r)+h*u+d*c,m=new Float64Array(a);if(t.O(m,m,[p>.5?p-1:p,f>.5?f-1:f,0]),this._alignedProjMatrix=m,a=t.aA(new Float64Array(16),this._pixelMatrix),!a)throw new Error("failed to invert matrix");this._pixelMatrixInverse=a,this._clearMatrixCaches()}_clearMatrixCaches(){this._posMatrixCache.clear(),this._alignedPosMatrixCache.clear(),this._fogMatrixCacheF32.clear()}maxPitchScaleFactor(){if(!this._pixelMatrixInverse)return 1;const e=this.screenPointToMercatorCoordinate(new t.P(0,0)),i=[e.x*this.worldSize,e.y*this.worldSize,0,1];return t.aG(i,i,this._pixelMatrix)[3]/this._helper.cameraToCenterDistance}getCameraPoint(){return this._helper.getCameraPoint()}getCameraAltitude(){return this._helper.getCameraAltitude()}getCameraLngLat(){const e=t.as(1,this.center.lat)*this.worldSize;return ye(this.center,this.elevation,this.pitch,this.bearing,this._helper.cameraToCenterDistance/e).toLngLat()}lngLatToCameraDepth(e,i){const n=t.aa.fromLngLat(e),r=[n.x*this.worldSize,n.y*this.worldSize,i,1];return t.aG(r,r,this._viewProjMatrix),r[2]/r[3]}getProjectionData(e){const{overscaledTileID:i,aligned:n,applyTerrainMatrix:r}=e,o=this._helper.getMercatorTileCoordinates(i),s=i?this.calculatePosMatrix(i,n,!0):null;let a;return a=i&&i.terrainRttPosMatrix32f&&r?i.terrainRttPosMatrix32f:s||t.bh(),{mainMatrix:a,tileMercatorCoords:o,clippingPlane:[0,0,0,0],projectionTransition:0,fallbackMatrix:a}}isLocationOccluded(e){return!1}getPixelScale(){return 1}getCircleRadiusCorrection(){return 1}getPitchedTextCorrection(e,t,i){return 1}transformLightDirection(e){return t.b0(e)}getRayDirectionFromPixel(e){throw new Error("Not implemented.")}projectTileCoordinates(e,i,n,r){const o=this.calculatePosMatrix(n);let s;r?(s=[e,i,r(e,i),1],t.aG(s,s,o)):(s=[e,i,0,1],Ye(s,s,o));const a=s[3];return{point:new t.P(s[0]/a,s[1]/a),signedDistanceFromCamera:a,isOccluded:!1}}populateCache(e){for(const t of e)this.calculatePosMatrix(t)}getMatrixForModel(e,i){const n=t.aa.fromLngLat(e,i),r=n.meterInMercatorCoordinateUnits(),o=t.bi();return t.O(o,o,[n.x,n.y,n.z]),t.bf(o,o,Math.PI),t.bg(o,o,Math.PI/2),t.Q(o,o,[-r,r,r]),o}getProjectionDataForCustomLayer(e=!0){const i=new t.a1(0,0,0,0,0),n=this.getProjectionData({overscaledTileID:i,applyGlobeMatrix:e}),r=Ae(i,this.worldSize);t.S(r,this._viewProjMatrix,r),n.tileMercatorCoords=[0,0,1,1];const o=[t.a4,t.a4,this.worldSize/this._helper.pixelsPerMeter],s=t.bj();return t.Q(s,r,o),n.fallbackMatrix=s,n.mainMatrix=s,n}getFastPathSimpleProjectionMatrix(e){return this.calculatePosMatrix(e)}}function jt(){t.w("Map cannot fit within canvas with the given bounds, padding, and/or offset.")}function Gt(e){if(e.useSlerp)if(e.k<1){const i=t.bk(e.startEulerAngles.roll,e.startEulerAngles.pitch,e.startEulerAngles.bearing),n=t.bk(e.endEulerAngles.roll,e.endEulerAngles.pitch,e.endEulerAngles.bearing),r=new Float64Array(4);t.bl(r,i,n,e.k);const o=t.bm(r);e.tr.setRoll(o.roll),e.tr.setPitch(o.pitch),e.tr.setBearing(o.bearing)}else e.tr.setRoll(e.endEulerAngles.roll),e.tr.setPitch(e.endEulerAngles.pitch),e.tr.setBearing(e.endEulerAngles.bearing);else e.tr.setRoll(t.G.number(e.startEulerAngles.roll,e.endEulerAngles.roll,e.k)),e.tr.setPitch(t.G.number(e.startEulerAngles.pitch,e.endEulerAngles.pitch,e.k)),e.tr.setBearing(t.G.number(e.startEulerAngles.bearing,e.endEulerAngles.bearing,e.k))}function Ht(e,i,n,r,o){const s=o.padding,a=me(o.worldSize,n.getNorthWest()),l=me(o.worldSize,n.getNorthEast()),c=me(o.worldSize,n.getSouthEast()),u=me(o.worldSize,n.getSouthWest()),h=t.ap(-r),d=a.rotate(h),p=l.rotate(h),f=c.rotate(h),m=u.rotate(h),g=new t.P(Math.max(d.x,p.x,m.x,f.x),Math.max(d.y,p.y,m.y,f.y)),_=new t.P(Math.min(d.x,p.x,m.x,f.x),Math.min(d.y,p.y,m.y,f.y)),A=g.sub(_),y=(o.width-(s.left+s.right+i.left+i.right))/A.x,v=(o.height-(s.top+s.bottom+i.top+i.bottom))/A.y;if(v<0||y<0)return void jt();const x=Math.min(t.at(o.scale*Math.min(y,v)),e.maxZoom),b=t.P.convert(e.offset),w=new t.P((i.left-i.right)/2,(i.top-i.bottom)/2).rotate(t.ap(r)),T=b.add(w).mult(o.scale/t.aq(x));return{center:ge(o.worldSize,a.add(c).div(2).sub(T)),zoom:x,bearing:r}}class Qt{get useGlobeControls(){return!1}handlePanInertia(e,t){const i=e.mag(),n=Math.abs(_e(t));return{easingOffset:e.mult(Math.min(.75*n/i,1)),easingCenter:t.center}}handleMapControlsRollPitchBearingZoom(e,t){e.bearingDelta&&t.setBearing(t.bearing+e.bearingDelta),e.pitchDelta&&t.setPitch(t.pitch+e.pitchDelta),e.rollDelta&&t.setRoll(t.roll+e.rollDelta),e.zoomDelta&&t.setZoom(t.zoom+e.zoomDelta)}handleMapControlsPan(e,t,i){e.around.distSqr(t.centerPoint)<.01||t.setLocationAtPoint(i,e.around)}cameraForBoxAndBearing(e,t,i,n,r){return Ht(e,t,i,n,r)}handleJumpToCenterZoom(e,i){e.zoom!==(void 0!==i.zoom?+i.zoom:e.zoom)&&e.setZoom(+i.zoom),void 0!==i.center&&e.setCenter(t.V.convert(i.center))}handleEaseTo(e,i){const n=e.zoom,r=e.padding,o={roll:e.roll,pitch:e.pitch,bearing:e.bearing},s={roll:void 0===i.roll?e.roll:i.roll,pitch:void 0===i.pitch?e.pitch:i.pitch,bearing:void 0===i.bearing?e.bearing:i.bearing},a=void 0!==i.zoom,l=!e.isPaddingEqual(i.padding);let c=!1;const u=a?+i.zoom:e.zoom;let h=e.centerPoint.add(i.offsetAsPoint);const d=e.screenPointToLocation(h),{center:p,zoom:f}=e.applyConstrain(t.V.convert(i.center||d),null!=u?u:n);kt(e,p);const m=me(e.worldSize,d),g=me(e.worldSize,p).sub(m),_=t.aq(f-n);return c=f!==n,{easeFunc:a=>{if(c&&e.setZoom(t.G.number(n,f,a)),t.bn(o,s)||Gt({startEulerAngles:o,endEulerAngles:s,tr:e,k:a,useSlerp:o.roll!=s.roll}),l&&(e.interpolatePadding(r,i.padding,a),h=e.centerPoint.add(i.offsetAsPoint)),i.around)e.setLocationAtPoint(i.around,i.aroundPoint);else{const i=t.aq(e.zoom-n),r=f>n?Math.min(2,_):Math.max(.5,_),o=Math.pow(r,1-a),s=ge(e.worldSize,m.add(g.mult(a*o)).mult(i));e.setLocationAtPoint(e.renderWorldCopies?s.wrap():s,h)}},isZooming:c,elevationCenter:p}}handleFlyTo(e,i){const n=void 0!==i.zoom,r=e.zoom,o=e.applyConstrain(t.V.convert(i.center||i.locationAtOffset),n?+i.zoom:r),s=o.center,a=o.zoom;kt(e,s);const l=me(e.worldSize,i.locationAtOffset),c=me(e.worldSize,s).sub(l),u=c.mag(),h=t.aq(a-r);let d;if(void 0!==i.minZoom){const n=Math.min(+i.minZoom,r,a),o=e.applyConstrain(s,n).zoom;d=t.aq(o-r)}return{easeFunc:(i,n,o,u)=>{e.setZoom(1===i?a:r+t.at(n));const h=1===i?s:ge(e.worldSize,l.add(c.mult(o)).mult(n));e.setLocationAtPoint(e.renderWorldCopies?h.wrap():h,u)},scaleOfZoom:h,targetCenter:s,scaleOfMinZoom:d,pixelPathLength:u}}}class $t{constructor(e,t,i){this.blendFunction=e,this.blendColor=t,this.mask=i}}$t.Replace=[1,0],$t.disabled=new $t($t.Replace,t.bo.transparent,[!1,!1,!1,!1]),$t.unblended=new $t($t.Replace,t.bo.transparent,[!0,!0,!0,!0]),$t.alphaBlended=new $t([1,771],t.bo.transparent,[!0,!0,!0,!0]);const Zt=2305;class Wt{constructor(e,t,i){this.enable=e,this.mode=t,this.frontFace=i}}Wt.disabled=new Wt(!1,1029,Zt),Wt.backCCW=new Wt(!0,1029,Zt),Wt.frontCCW=new Wt(!0,1028,Zt);class qt{constructor(e,t,i){this.func=e,this.mask=t,this.range=i}}qt.ReadOnly=!1,qt.ReadWrite=!0,qt.disabled=new qt(519,qt.ReadOnly,[0,1]);const Kt=7680;class Xt{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}}Xt.disabled=new Xt({func:519,mask:0},0,0,Kt,Kt,Kt);const Jt=new WeakMap;function Yt(e){var t;if(Jt.has(e))return Jt.get(e);{const i=null===(t=e.getParameter(e.VERSION))||void 0===t?void 0:t.startsWith("WebGL 2.0");return Jt.set(e,i),i}}class ei{get awaitingQuery(){return!!this._readbackQueue}constructor(e){this._readbackWaitFrames=4,this._measureWaitFrames=6,this._texWidth=1,this._texHeight=1,this._measuredError=0,this._updateCount=0,this._lastReadbackFrame=-1e3,this._readbackQueue=null,this._cachedRenderContext=e;const i=e.context,n=i.gl;this._texFormat=n.RGBA,this._texType=n.UNSIGNED_BYTE;const r=new t.aV;r.emplaceBack(-1,-1),r.emplaceBack(2,-1),r.emplaceBack(-1,2);const o=new t.aX;o.emplaceBack(0,1,2),this._fullscreenTriangle=new It(i.createVertexBuffer(r,Mt.members),i.createIndexBuffer(o),t.aW.simpleSegment(0,0,r.length,o.length)),this._resultBuffer=new Uint8Array(4),i.activeTexture.set(n.TEXTURE1);const s=n.createTexture();n.bindTexture(n.TEXTURE_2D,s),n.texParameteri(n.TEXTURE_2D,n.TEXTURE_WRAP_S,n.CLAMP_TO_EDGE),n.texParameteri(n.TEXTURE_2D,n.TEXTURE_WRAP_T,n.CLAMP_TO_EDGE),n.texParameteri(n.TEXTURE_2D,n.TEXTURE_MIN_FILTER,n.NEAREST),n.texParameteri(n.TEXTURE_2D,n.TEXTURE_MAG_FILTER,n.NEAREST),n.texImage2D(n.TEXTURE_2D,0,this._texFormat,this._texWidth,this._texHeight,0,this._texFormat,this._texType,null),this._fbo=i.createFramebuffer(this._texWidth,this._texHeight,!1,!1),this._fbo.colorAttachment.set(s),Yt(n)&&(this._pbo=n.createBuffer(),n.bindBuffer(n.PIXEL_PACK_BUFFER,this._pbo),n.bufferData(n.PIXEL_PACK_BUFFER,4,n.STREAM_READ),n.bindBuffer(n.PIXEL_PACK_BUFFER,null))}destroy(){const e=this._cachedRenderContext.context.gl;this._fullscreenTriangle.destroy(),this._fbo.destroy(),e.deleteBuffer(this._pbo),this._fullscreenTriangle=null,this._fbo=null,this._pbo=null,this._resultBuffer=null}updateErrorLoop(e,t){const i=this._updateCount;return this._readbackQueue?i>=this._readbackQueue.frameNumberIssued+this._readbackWaitFrames&&this._tryReadback():i>=this._lastReadbackFrame+this._measureWaitFrames&&this._renderErrorTexture(e,t),this._updateCount++,this._measuredError}_bindFramebuffer(){const e=this._cachedRenderContext.context,t=e.gl;e.activeTexture.set(t.TEXTURE1),t.bindTexture(t.TEXTURE_2D,this._fbo.colorAttachment.get()),e.bindFramebuffer.set(this._fbo.framebuffer)}_renderErrorTexture(e,i){const n=this._cachedRenderContext.context,r=n.gl;if(this._bindFramebuffer(),n.viewport.set([0,0,this._texWidth,this._texHeight]),n.clear({color:t.bo.transparent}),this._cachedRenderContext.useProgram("projectionErrorMeasurement").draw(n,r.TRIANGLES,qt.disabled,Xt.disabled,$t.unblended,Wt.disabled,((e,t)=>({u_input:e,u_output_expected:t}))(e,i),null,null,"$clipping",this._fullscreenTriangle.vertexBuffer,this._fullscreenTriangle.indexBuffer,this._fullscreenTriangle.segments),this._pbo&&Yt(r)){r.bindBuffer(r.PIXEL_PACK_BUFFER,this._pbo),r.readBuffer(r.COLOR_ATTACHMENT0),r.readPixels(0,0,this._texWidth,this._texHeight,this._texFormat,this._texType,0),r.bindBuffer(r.PIXEL_PACK_BUFFER,null);const e=r.fenceSync(r.SYNC_GPU_COMMANDS_COMPLETE,0);r.flush(),this._readbackQueue={frameNumberIssued:this._updateCount,sync:e}}else this._readbackQueue={frameNumberIssued:this._updateCount,sync:null}}_tryReadback(){const e=this._cachedRenderContext.context.gl;if(this._pbo&&this._readbackQueue&&Yt(e)){const i=e.clientWaitSync(this._readbackQueue.sync,0,0);if(i===e.WAIT_FAILED)return t.w("WebGL2 clientWaitSync failed."),this._readbackQueue=null,void(this._lastReadbackFrame=this._updateCount);if(i===e.TIMEOUT_EXPIRED)return;e.bindBuffer(e.PIXEL_PACK_BUFFER,this._pbo),e.getBufferSubData(e.PIXEL_PACK_BUFFER,0,this._resultBuffer,0,4),e.bindBuffer(e.PIXEL_PACK_BUFFER,null)}else this._bindFramebuffer(),e.readPixels(0,0,this._texWidth,this._texHeight,this._texFormat,this._texType,this._resultBuffer);this._readbackQueue=null,this._measuredError=ei._parseRGBA8float(this._resultBuffer),this._lastReadbackFrame=this._updateCount}static _parseRGBA8float(e){let t=0;return t+=e[0]/256,t+=e[1]/65536,t+=e[2]/16777216,e[3]<127&&(t=-t),t/128}}const ti=t.a4/128;function ii(e,i){const n=void 0!==e.granularity?Math.max(e.granularity,1):1,r=n+(e.generateBorders?2:0),o=n+(e.extendToNorthPole||e.generateBorders?1:0)+(e.extendToSouthPole||e.generateBorders?1:0),s=r+1,a=o+1,l=e.generateBorders?-1:0,c=e.generateBorders||e.extendToNorthPole?-1:0,u=n+(e.generateBorders?1:0),h=n+(e.generateBorders||e.extendToSouthPole?1:0),d=s*a,p=r*o*6,f=s*a>65536;if(f&&"16bit"===i)throw new Error("Granularity is too large and meshes would not fit inside 16 bit vertex indices.");const m=f||"32bit"===i,g=new Int16Array(2*d);let _=0;for(let i=c;i<=h;i++)for(let r=l;r<=u;r++){let o=r/n*t.a4;-1===r&&(o=-ti),r===n+1&&(o=t.a4+ti);let s=i/n*t.a4;-1===i&&(s=e.extendToNorthPole?t.bq:-ti),i===n+1&&(s=e.extendToSouthPole?t.br:t.a4+ti),g[_++]=o,g[_++]=s}const A=m?new Uint32Array(p):new Uint16Array(p);let y=0;for(let e=0;e0}get latitudeErrorCorrectionRadians(){return this._verticalPerspectiveProjection.latitudeErrorCorrectionRadians}get currentProjection(){return this.useGlobeRendering?this._verticalPerspectiveProjection:this._mercatorProjection}get name(){return"globe"}get useSubdivision(){return this.currentProjection.useSubdivision}get shaderVariantName(){return this.currentProjection.shaderVariantName}get shaderDefine(){return this.currentProjection.shaderDefine}get shaderPreludeCode(){return this.currentProjection.shaderPreludeCode}get vertexShaderPreludeCode(){return this.currentProjection.vertexShaderPreludeCode}get subdivisionGranularity(){return this.currentProjection.subdivisionGranularity}get useGlobeControls(){return this.transitionState>0}destroy(){this._mercatorProjection.destroy(),this._verticalPerspectiveProjection.destroy()}updateGPUdependent(e){this._mercatorProjection.updateGPUdependent(e),this._verticalPerspectiveProjection.updateGPUdependent(e)}getMeshFromTileID(e,t,i,n,r){return this.currentProjection.getMeshFromTileID(e,t,i,n,r)}setProjection(e){this._transitionable.setValue("type",(null==e?void 0:e.type)||"mercator")}updateTransitions(e){this._transitioning=this._transitionable.transitioned(e,this._transitioning)}hasTransition(){return this._transitioning.hasTransition()||this.currentProjection.hasTransition()}recalculate(e){this.properties=this._transitioning.possiblyEvaluate(e)}setErrorQueryLatitudeDegrees(e){this._verticalPerspectiveProjection.setErrorQueryLatitudeDegrees(e),this._mercatorProjection.setErrorQueryLatitudeDegrees(e)}}function ai(e){const t=ui(e.worldSize,e.center.lat);return 2*Math.PI*t}function li(e,i,n,r,o){const s=1/(1<1e-6){const r=e[0]/n,o=Math.acos(e[2]/n),s=(r>0?o:-o)/Math.PI*180;return new t.V(t.W(s,-180,180),i)}return new t.V(0,i)}function di(e){return Math.cos(e*Math.PI/180)}function pi(e,i){const n=di(e),r=di(i);return t.at(r/n)}function fi(e,i){const n=e.rotate(i.bearingInRadians),r=i.zoom+pi(i.center.lat,0),o=t.bt(1/di(i.center.lat),1/di(Math.min(Math.abs(i.center.lat),60)),t.bw(r,7,3,0,1)),s=360/ai({worldSize:i.worldSize,center:{lat:i.center.lat}});return new t.V(i.center.lng-n.x*s*o,t.an(i.center.lat+n.y*s,-t.ao,t.ao))}function mi(e){const t=.5*e,i=Math.sin(t),n=Math.cos(t);return Math.log(i+n)-Math.log(n-i)}function gi(e,i,n,r){const o=e.lat+n*r;if(Math.abs(n)>1){const s=(Math.sign(e.lat+n)!==Math.sign(e.lat)?-Math.abs(e.lat):Math.abs(e.lat))*Math.PI/180,a=Math.abs(e.lat+n)*Math.PI/180,l=mi(s+r*(a-s)),c=mi(s),u=mi(a);return new t.V(e.lng+i*((l-c)/(u-c)),o)}return new t.V(e.lng+i*r,o)}class _i{constructor(e){this._cachePrevious=new Map,this._cache=new Map,this._hadAnyChanges=!1,this._boundingVolumeFactory=e}swapBuffers(){if(!this._hadAnyChanges)return;const e=this._cachePrevious;this._cachePrevious=this._cache,this._cache=e,this._cache.clear(),this._hadAnyChanges=!1}getTileBoundingVolume(e,t,i,n){const r=`${e.z}_${e.x}_${e.y}_${(null==n?void 0:n.terrain)?"t":""}`,o=this._cache.get(r);if(o)return o;const s=this._cachePrevious.get(r);if(s)return this._cache.set(r,s),s;const a=this._boundingVolumeFactory(e,t,i,n);return this._cache.set(r,a),this._hadAnyChanges=!0,a}}class Ai{constructor(e,t,i,n){this.min=i,this.max=n,this.points=e,this.planes=t}static fromAabb(e,t){const i=[];for(let n=0;n<8;n++)i.push([1&~n?e[0]:t[0],1==(n>>1&1)?t[1]:e[1],1==(n>>2&1)?t[2]:e[2]]);return new Ai(i,[[-1,0,0,t[0]],[1,0,0,-e[0]],[0,-1,0,t[1]],[0,1,0,-e[1]],[0,0,-1,t[2]],[0,0,1,-e[2]]],e,t)}static fromCenterSizeAngles(e,i,n){const r=t.bA([],n[0],n[1],n[2]),o=t.bB([],[i[0],0,0],r),s=t.bB([],[0,i[1],0],r),a=t.bB([],[0,0,i[2]],r),l=[...e],c=[...e];for(let t=0;t<8;t++)for(let i=0;i<3;i++){const n=e[i]+o[i]*(1&~t?-1:1)+s[i]*(1==(t>>1&1)?1:-1)+a[i]*(1==(t>>2&1)?1:-1);l[i]=Math.min(l[i],n),c[i]=Math.max(c[i],n)}const u=[];for(let i=0;i<8;i++){const n=[...e];t.a$(n,n,t.a_([],o,1&~i?-1:1)),t.a$(n,n,t.a_([],s,1==(i>>1&1)?1:-1)),t.a$(n,n,t.a_([],a,1==(i>>2&1)?1:-1)),u.push(n)}return new Ai(u,[[...o,-t.b4(o,u[0])],[...s,-t.b4(s,u[0])],[...a,-t.b4(a,u[0])],[-o[0],-o[1],-o[2],-t.b4(o,u[7])],[-s[0],-s[1],-s[2],-t.b4(s,u[7])],[-a[0],-a[1],-a[2],-t.b4(a,u[7])]],l,c)}intersectsFrustum(e){let t=!0;const i=this.points.length,n=this.planes.length,r=e.planes.length,o=e.points.length;for(let n=0;n=0&&o++}if(0===o)return 0;o=0&&n++}if(0===n)return 0}return 1}intersectsPlane(e){const t=this.points.length;let i=0;for(let n=0;n=0&&i++}return i===t?2:0===i?0:1}}function yi(e,t,i){const n=e-t;return n<0?-n:Math.max(0,n-i)}function vi(e,t,i,n,r){const o=e-i;let s;return s=o<0?Math.min(-o,1+o-r):o>1?Math.min(Math.max(o-r,0),1-o):0,Math.max(s,yi(t,n,r))}class xi{constructor(){this._boundingVolumeCache=new _i(this._computeTileBoundingVolume)}prepareNextFrame(){this._boundingVolumeCache.swapBuffers()}distanceToTile2d(e,t,i,n){const r=1<4}allowWorldCopies(){return!1}getTileBoundingVolume(e,t,i,n){return this._boundingVolumeCache.getTileBoundingVolume(e,t,i,n)}_computeTileBoundingVolume(e,i,n,r){var o,s;let a=0,l=0;if(null==r?void 0:r.terrain){const c=new t.a1(e.z,i,e.z,e.x,e.y),u=r.terrain.getMinMaxElevation(c);a=null!==(o=u.minElevation)&&void 0!==o?o:Math.min(0,n),l=null!==(s=u.maxElevation)&&void 0!==s?s:Math.max(0,n)}if(a/=t.bD,l/=t.bD,a+=1,l+=1,e.z<=0)return Ai.fromAabb([-l,-l,-l],[l,l,l]);if(1===e.z)return Ai.fromAabb([0===e.x?-l:0,0===e.y?0:-l,-l],[0===e.x?0:l,0===e.y?l:0,l]);{const i=[li(0,0,e.x,e.y,e.z),li(t.a4,0,e.x,e.y,e.z),li(t.a4,t.a4,e.x,e.y,e.z),li(0,t.a4,e.x,e.y,e.z)],n=[];for(const e of i)n.push(t.a_([],e,l));if(l!==a)for(const e of i)n.push(t.a_([],e,a));0===e.y&&n.push([0,1,0]),e.y===(1<=(1<{const n=t.an(e.lat,-t.ao,t.ao),r=t.an(+i,this.minZoom+pi(0,n),this.maxZoom);return{center:new t.V(e.lng,n),zoom:r}},this.applyConstrain=(e,t)=>this._helper.applyConstrain(e,t),this._helper=new Ot({calcMatrices:()=>{this._calcMatrices()},defaultConstrain:(e,t)=>this.defaultConstrain(e,t)},e),this._coveringTilesDetailsProvider=new xi}clone(){const e=new wi;return e.apply(this),e}apply(e,t){this._globeLatitudeErrorCorrectionRadians=t||0,this._helper.apply(e)}get projectionMatrix(){return this._projectionMatrix}get modelViewProjectionMatrix(){return this._globeViewProjMatrixNoCorrection}get inverseProjectionMatrix(){return this._globeProjMatrixInverted}get cameraPosition(){const e=t.by();return e[0]=this._cameraPosition[0],e[1]=this._cameraPosition[1],e[2]=this._cameraPosition[2],e}get cameraToCenterDistance(){return this._helper.cameraToCenterDistance}getProjectionData(e){const{overscaledTileID:t,applyGlobeMatrix:i}=e,n=this._helper.getMercatorTileCoordinates(t);return{mainMatrix:this._globeViewProjMatrix32f,tileMercatorCoords:n,clippingPlane:this._cachedClippingPlane,projectionTransition:i?1:0,fallbackMatrix:this._globeViewProjMatrix32f}}_computeClippingPlane(e){const i=this.pitchInRadians,n=this.cameraToCenterDistance/e,r=Math.sin(i)*n,o=Math.cos(i)*n+1,s=1/Math.sqrt(r*r+o*o)*1;let a=-r,l=o;const c=Math.sqrt(a*a+l*l);a/=c,l/=c;const u=[0,a,l];t.bF(u,u,[0,0,0],-this.bearingInRadians),t.bG(u,u,[0,0,0],-1*this.center.lat*Math.PI/180),t.bH(u,u,[0,0,0],this.center.lng*Math.PI/180);const h=1/t.b6(u);return t.a_(u,u,h),[...u,-s*h]}isLocationOccluded(e){return!this.isSurfacePointVisible(ci(e))}transformLightDirection(e){const i=this._helper._center.lng*Math.PI/180,n=this._helper._center.lat*Math.PI/180,r=Math.cos(n),o=[Math.sin(i)*r,Math.sin(n),Math.cos(i)*r],s=[o[2],0,-o[0]],a=[0,0,0];t.b3(a,s,o),t.b2(s,s),t.b2(a,a);const l=[0,0,0];return t.b2(l,[s[0]*e[0]+a[0]*e[1]+o[0]*e[2],s[1]*e[0]+a[1]*e[1]+o[1]*e[2],s[2]*e[0]+a[2]*e[1]+o[2]*e[2]]),l}getPixelScale(){return 1/Math.cos(this._helper._center.lat*Math.PI/180)}getCircleRadiusCorrection(){return Math.cos(this._helper._center.lat*Math.PI/180)}getPitchedTextCorrection(e,i,n){const r=function(e,i,n){const r=1/(1<o&&(o=i),na&&(a=n)}const u=[c.lng+s,c.lat+l,c.lng+o,c.lat+a];return this.isSurfacePointOnScreen([0,1,0])&&(u[3]=90,u[0]=-180,u[2]=180),this.isSurfacePointOnScreen([0,-1,0])&&(u[1]=-90,u[0]=-180,u[2]=180),new Z(u)}calculateCenterFromCameraLngLatAlt(e,t,i,n){return this._helper.calculateCenterFromCameraLngLatAlt(e,t,i,n)}setLocationAtPoint(e,i){const n=ci(this.unprojectScreenPoint(i)),r=ci(e),o=t.by();t.bK(o);const s=t.by();t.bH(s,n,o,-this.center.lng*Math.PI/180),t.bG(s,s,o,this.center.lat*Math.PI/180);const a=r[0]*r[0]+r[2]*r[2],l=s[0]*s[0];if(a=-_&&f<=_,y=g>=-_&&g<=_;let v,x;if(A&&y){const e=this.center.lng*Math.PI/180,i=this.center.lat*Math.PI/180;t.bM(h,e)+t.bM(f,i)=0}isSurfacePointOnScreen(e){if(!this.isSurfacePointVisible(e))return!1;const i=t.bE();return t.aG(i,[...e,1],this._globeViewProjMatrixNoCorrection),i[0]/=i[3],i[1]/=i[3],i[2]/=i[3],i[0]>-1&&i[0]<1&&i[1]>-1&&i[1]<1&&i[2]>-1&&i[2]<1}rayPlanetIntersection(e,i){const n=t.b4(e,i),r=t.by(),o=t.by();t.a_(o,i,n),t.b1(r,e,o);const s=1-t.b4(r,r);if(s<0)return null;const a=t.b4(e,e)-1,l=-n+(n<0?1:-1)*Math.sqrt(s),c=a/l,u=l;return{tMin:Math.min(c,u),tMax:Math.max(c,u)}}unprojectScreenPoint(e){const i=this._cameraPosition,n=this.getRayDirectionFromPixel(e),r=this.rayPlanetIntersection(i,n);if(r){const e=t.by();t.a$(e,i,[n[0]*r.tMin,n[1]*r.tMin,n[2]*r.tMin]);const o=t.by();return t.b2(o,e),hi(o)}const o=this._cachedClippingPlane,s=o[0]*n[0]+o[1]*n[1]+o[2]*n[2],a=-t.ba(o,i)/s,l=t.by();if(a>0)t.a$(l,i,[n[0]*a,n[1]*a,n[2]*a]);else{const e=t.by();t.a$(e,i,[2*n[0],2*n[1],2*n[2]]);const r=t.ba(this._cachedClippingPlane,e);t.b1(l,e,[this._cachedClippingPlane[0]*r,this._cachedClippingPlane[1]*r,this._cachedClippingPlane[2]*r])}const c=function(e){const i=t.by();return i[0]=e[0]*-e[3],i[1]=e[1]*-e[3],i[2]=e[2]*-e[3],{center:i,radius:Math.sqrt(1-e[3]*e[3])}}(o);return hi(function(e,i,n){const r=t.by();t.b1(r,n,e);const o=t.by();return t.bz(o,e,r,i/t.b8(r)),o}(c.center,c.radius,l))}getMatrixForModel(e,i){const n=t.V.convert(e),r=1/t.bD,o=t.bi();return t.bI(o,o,n.lng/180*Math.PI),t.bg(o,o,-n.lat/180*Math.PI),t.O(o,o,[0,0,1+i/t.bD]),t.bg(o,o,.5*Math.PI),t.Q(o,o,[r,r,r]),o}getProjectionDataForCustomLayer(e=!0){const i=this.getProjectionData({overscaledTileID:new t.a1(0,0,0,0,0),applyGlobeMatrix:e});return i.tileMercatorCoords=[0,0,1,1],i}getFastPathSimpleProjectionMatrix(e){}}class Ti{get pixelsToClipSpaceMatrix(){return this._helper.pixelsToClipSpaceMatrix}get clipSpaceToPixelsMatrix(){return this._helper.clipSpaceToPixelsMatrix}get pixelsToGLUnits(){return this._helper.pixelsToGLUnits}get centerOffset(){return this._helper.centerOffset}get size(){return this._helper.size}get rotationMatrix(){return this._helper.rotationMatrix}get centerPoint(){return this._helper.centerPoint}get pixelsPerMeter(){return this._helper.pixelsPerMeter}setMinZoom(e){this._helper.setMinZoom(e)}setMaxZoom(e){this._helper.setMaxZoom(e)}setMinPitch(e){this._helper.setMinPitch(e)}setMaxPitch(e){this._helper.setMaxPitch(e)}setRenderWorldCopies(e){this._helper.setRenderWorldCopies(e)}setBearing(e){this._helper.setBearing(e)}setPitch(e){this._helper.setPitch(e)}setRoll(e){this._helper.setRoll(e)}setFov(e){this._helper.setFov(e)}setZoom(e){this._helper.setZoom(e)}setCenter(e){this._helper.setCenter(e)}setElevation(e){this._helper.setElevation(e)}setMinElevationForCurrentTile(e){this._helper.setMinElevationForCurrentTile(e)}setPadding(e){this._helper.setPadding(e)}interpolatePadding(e,t,i){return this._helper.interpolatePadding(e,t,i)}isPaddingEqual(e){return this._helper.isPaddingEqual(e)}resize(e,t,i=!0){this._helper.resize(e,t,i)}getMaxBounds(){return this._helper.getMaxBounds()}setMaxBounds(e){this._helper.setMaxBounds(e)}setConstrainOverride(e){this._helper.setConstrainOverride(e)}overrideNearFarZ(e,t){this._helper.overrideNearFarZ(e,t)}clearNearFarZOverride(){this._helper.clearNearFarZOverride()}getCameraQueryGeometry(e){return this._helper.getCameraQueryGeometry(this.getCameraPoint(),e)}get tileSize(){return this._helper.tileSize}get tileZoom(){return this._helper.tileZoom}get scale(){return this._helper.scale}get worldSize(){return this._helper.worldSize}get width(){return this._helper.width}get height(){return this._helper.height}get lngRange(){return this._helper.lngRange}get latRange(){return this._helper.latRange}get minZoom(){return this._helper.minZoom}get maxZoom(){return this._helper.maxZoom}get zoom(){return this._helper.zoom}get center(){return this._helper.center}get minPitch(){return this._helper.minPitch}get maxPitch(){return this._helper.maxPitch}get pitch(){return this._helper.pitch}get pitchInRadians(){return this._helper.pitchInRadians}get roll(){return this._helper.roll}get rollInRadians(){return this._helper.rollInRadians}get bearing(){return this._helper.bearing}get bearingInRadians(){return this._helper.bearingInRadians}get fov(){return this._helper.fov}get fovInRadians(){return this._helper.fovInRadians}get elevation(){return this._helper.elevation}get minElevationForCurrentTile(){return this._helper.minElevationForCurrentTile}get padding(){return this._helper.padding}get unmodified(){return this._helper.unmodified}get renderWorldCopies(){return this._helper.renderWorldCopies}get cameraToCenterDistance(){return this._helper.cameraToCenterDistance}get constrainOverride(){return this._helper.constrainOverride}get nearZ(){return this._helper.nearZ}get farZ(){return this._helper.farZ}get autoCalculateNearFarZ(){return this._helper.autoCalculateNearFarZ}get isGlobeRendering(){return this._globeness>0}setTransitionState(e,t){this._globeness=e,this._globeLatitudeErrorCorrectionRadians=t,this._calcMatrices(),this._verticalPerspectiveTransform.getCoveringTilesDetailsProvider().prepareNextFrame(),this._mercatorTransform.getCoveringTilesDetailsProvider().prepareNextFrame()}get currentTransform(){return this.isGlobeRendering?this._verticalPerspectiveTransform:this._mercatorTransform}constructor(e){this._globeLatitudeErrorCorrectionRadians=0,this._globeness=1,this.defaultConstrain=(e,t)=>this.currentTransform.defaultConstrain(e,t),this.applyConstrain=(e,t)=>this._helper.applyConstrain(e,t),this._helper=new Ot({calcMatrices:()=>{this._calcMatrices()},defaultConstrain:(e,t)=>this.defaultConstrain(e,t)},e),this._globeness=1,this._mercatorTransform=new Vt,this._verticalPerspectiveTransform=new wi}clone(){const e=new Ti;return e._globeness=this._globeness,e._globeLatitudeErrorCorrectionRadians=this._globeLatitudeErrorCorrectionRadians,e.apply(this),e}apply(e){this._helper.apply(e),this._mercatorTransform.apply(this),this._verticalPerspectiveTransform.apply(this,this._globeLatitudeErrorCorrectionRadians)}get projectionMatrix(){return this.currentTransform.projectionMatrix}get modelViewProjectionMatrix(){return this.currentTransform.modelViewProjectionMatrix}get inverseProjectionMatrix(){return this.currentTransform.inverseProjectionMatrix}get cameraPosition(){return this.currentTransform.cameraPosition}getProjectionData(e){const t=this._mercatorTransform.getProjectionData(e),i=this._verticalPerspectiveTransform.getProjectionData(e);return{mainMatrix:this.isGlobeRendering?i.mainMatrix:t.mainMatrix,clippingPlane:i.clippingPlane,tileMercatorCoords:i.tileMercatorCoords,projectionTransition:e.applyGlobeMatrix?this._globeness:0,fallbackMatrix:t.fallbackMatrix}}isLocationOccluded(e){return this.currentTransform.isLocationOccluded(e)}transformLightDirection(e){return this.currentTransform.transformLightDirection(e)}getPixelScale(){return t.bt(this._mercatorTransform.getPixelScale(),this._verticalPerspectiveTransform.getPixelScale(),this._globeness)}getCircleRadiusCorrection(){return t.bt(this._mercatorTransform.getCircleRadiusCorrection(),this._verticalPerspectiveTransform.getCircleRadiusCorrection(),this._globeness)}getPitchedTextCorrection(e,i,n){const r=this._mercatorTransform.getPitchedTextCorrection(e,i,n),o=this._verticalPerspectiveTransform.getPitchedTextCorrection(e,i,n);return t.bt(r,o,this._globeness)}projectTileCoordinates(e,t,i,n){return this.currentTransform.projectTileCoordinates(e,t,i,n)}_calcMatrices(){this._helper._width&&this._helper._height&&(this._verticalPerspectiveTransform.apply(this,this._globeLatitudeErrorCorrectionRadians),this._helper._nearZ=this._verticalPerspectiveTransform.nearZ,this._helper._farZ=this._verticalPerspectiveTransform.farZ,this._mercatorTransform.apply(this,!0,this.isGlobeRendering),this._helper._nearZ=this._mercatorTransform.nearZ,this._helper._farZ=this._mercatorTransform.farZ)}calculateFogMatrix(e){return this.currentTransform.calculateFogMatrix(e)}getVisibleUnwrappedCoordinates(e){return this.currentTransform.getVisibleUnwrappedCoordinates(e)}getCameraFrustum(){return this.currentTransform.getCameraFrustum()}getClippingPlane(){return this.currentTransform.getClippingPlane()}getCoveringTilesDetailsProvider(){return this.currentTransform.getCoveringTilesDetailsProvider()}recalculateZoomAndCenter(e){this._mercatorTransform.recalculateZoomAndCenter(e),this._verticalPerspectiveTransform.recalculateZoomAndCenter(e)}maxPitchScaleFactor(){return this._mercatorTransform.maxPitchScaleFactor()}getCameraPoint(){return this._helper.getCameraPoint()}getCameraAltitude(){return this._helper.getCameraAltitude()}getCameraLngLat(){return this._helper.getCameraLngLat()}lngLatToCameraDepth(e,t){return this.currentTransform.lngLatToCameraDepth(e,t)}populateCache(e){this._mercatorTransform.populateCache(e),this._verticalPerspectiveTransform.populateCache(e)}getBounds(){return this.currentTransform.getBounds()}calculateCenterFromCameraLngLatAlt(e,t,i,n){return this._helper.calculateCenterFromCameraLngLatAlt(e,t,i,n)}setLocationAtPoint(e,t){if(!this.isGlobeRendering)return this._mercatorTransform.setLocationAtPoint(e,t),void this.apply(this._mercatorTransform);this._verticalPerspectiveTransform.setLocationAtPoint(e,t),this.apply(this._verticalPerspectiveTransform)}locationToScreenPoint(e,t){return this.currentTransform.locationToScreenPoint(e,t)}screenPointToMercatorCoordinate(e,t){return this.currentTransform.screenPointToMercatorCoordinate(e,t)}screenPointToLocation(e,t){return this.currentTransform.screenPointToLocation(e,t)}isPointOnMapSurface(e,t){return this.currentTransform.isPointOnMapSurface(e,t)}getRayDirectionFromPixel(e){return this._verticalPerspectiveTransform.getRayDirectionFromPixel(e)}getMatrixForModel(e,t){return this.currentTransform.getMatrixForModel(e,t)}getProjectionDataForCustomLayer(e=!0){const t=this._mercatorTransform.getProjectionDataForCustomLayer(e);if(!this.isGlobeRendering)return t;const i=this._verticalPerspectiveTransform.getProjectionDataForCustomLayer(e);return i.fallbackMatrix=t.mainMatrix,i}getFastPathSimpleProjectionMatrix(e){return this.currentTransform.getFastPathSimpleProjectionMatrix(e)}}class Ei{get useGlobeControls(){return!0}handlePanInertia(e,i){const n=fi(e,i);return Math.abs(n.lng-i.center.lng)>180&&(n.lng=i.center.lng+179.5*Math.sign(n.lng-i.center.lng)),{easingCenter:n,easingOffset:new t.P(0,0)}}handleMapControlsRollPitchBearingZoom(e,i){const n=e.around,r=i.screenPointToLocation(n);e.bearingDelta&&i.setBearing(i.bearing+e.bearingDelta),e.pitchDelta&&i.setPitch(i.pitch+e.pitchDelta),e.rollDelta&&i.setRoll(i.roll+e.rollDelta);const o=i.zoom;e.zoomDelta&&i.setZoom(i.zoom+e.zoomDelta);const s=i.zoom-o;if(0===s)return;const a=t.bJ(i.center.lng,r.lng),l=a/(Math.abs(a/180)+1),c=t.bJ(i.center.lat,r.lat),u=i.getRayDirectionFromPixel(n),h=i.cameraPosition,d=-1*t.b4(h,u),p=t.by();t.a$(p,h,[u[0]*d,u[1]*d,u[2]*d]);const f=t.b6(p)-1,m=Math.exp(.5*-Math.max(f-.3,0)),g=ui(i.worldSize,i.center.lat)/Math.min(i.width,i.height),_=t.bw(g,.9,.5,1,.25),A=(1-t.aq(-s))*Math.min(m,_),y=i.center.lat,v=i.zoom,x=new t.V(i.center.lng+l*A,t.an(i.center.lat+c*A,-t.ao,t.ao));i.setLocationAtPoint(r,n);const b=i.center,w=t.bw(Math.abs(a),45,85,0,1),T=t.bw(g,.75,.35,0,1),E=Math.pow(Math.max(w,T),.25),C=t.bJ(b.lng,x.lng),S=t.bJ(b.lat,x.lat);i.setCenter(new t.V(b.lng+C*E,b.lat+S*E).wrap()),i.setZoom(v+pi(y,i.center.lat))}handleMapControlsPan(e,t,i){if(!e.panDelta)return;const n=t.center.lat,r=t.zoom;t.setCenter(fi(e.panDelta,t).wrap()),t.setZoom(r+pi(n,t.center.lat))}cameraForBoxAndBearing(e,i,n,r,o){const s=Ht(e,i,n,r,o),a=i.left/o.width*2-1,l=(o.width-i.right)/o.width*2-1,c=i.top/o.height*-2+1,u=(o.height-i.bottom)/o.height*-2+1,h=t.bJ(n.getWest(),n.getEast())<0,d=h?n.getEast():n.getWest(),p=h?n.getWest():n.getEast(),f=Math.max(n.getNorth(),n.getSouth()),m=Math.min(n.getNorth(),n.getSouth()),g=d+.5*t.bJ(d,p),_=f+.5*t.bJ(f,m),A=o.clone();A.setCenter(s.center),A.setBearing(s.bearing),A.setPitch(0),A.setRoll(0),A.setZoom(s.zoom);const y=A.modelViewProjectionMatrix,v=[ci(n.getNorthWest()),ci(n.getNorthEast()),ci(n.getSouthWest()),ci(n.getSouthEast()),ci(new t.V(p,_)),ci(new t.V(d,_)),ci(new t.V(g,f)),ci(new t.V(g,m))],x=ci(s.center);let b=Number.POSITIVE_INFINITY;for(const e of v)a<0&&(b=Ei.getLesserNonNegativeNonNull(b,Ei.solveVectorScale(e,x,y,"x",a))),l>0&&(b=Ei.getLesserNonNegativeNonNull(b,Ei.solveVectorScale(e,x,y,"x",l))),c>0&&(b=Ei.getLesserNonNegativeNonNull(b,Ei.solveVectorScale(e,x,y,"y",c))),u<0&&(b=Ei.getLesserNonNegativeNonNull(b,Ei.solveVectorScale(e,x,y,"y",u)));if(Number.isFinite(b)&&0!==b)return s.zoom=A.zoom+t.at(b),s;jt()}handleJumpToCenterZoom(e,i){const n=e.center.lat,r=e.applyConstrain(i.center?t.V.convert(i.center):e.center,e.zoom).center;e.setCenter(r.wrap());const o=void 0!==i.zoom?+i.zoom:e.zoom+pi(n,r.lat);e.zoom!==o&&e.setZoom(o)}handleEaseTo(e,i){const n=e.zoom,r=e.center,o=e.padding,s={roll:e.roll,pitch:e.pitch,bearing:e.bearing},a={roll:void 0===i.roll?e.roll:i.roll,pitch:void 0===i.pitch?e.pitch:i.pitch,bearing:void 0===i.bearing?e.bearing:i.bearing},l=void 0!==i.zoom,c=!e.isPaddingEqual(i.padding);let u=!1;const h=i.center?t.V.convert(i.center):r,d=e.applyConstrain(h,n).center;kt(e,d);const p=e.clone();p.setCenter(d),p.setZoom(l?+i.zoom:n+pi(r.lat,h.lat)),p.setBearing(i.bearing);const f=new t.P(t.an(e.centerPoint.x+i.offsetAsPoint.x,0,e.width),t.an(e.centerPoint.y+i.offsetAsPoint.y,0,e.height));p.setLocationAtPoint(d,f);const m=(i.offset&&i.offsetAsPoint.mag())>0?p.center:d,g=l?+i.zoom:n+pi(r.lat,m.lat),_=n+pi(r.lat,0),A=g+pi(m.lat,0),y=t.bJ(r.lng,m.lng),v=t.bJ(r.lat,m.lat),x=t.aq(A-_);return u=g!==n,{easeFunc:n=>{if(t.bn(s,a)||Gt({startEulerAngles:s,endEulerAngles:a,tr:e,k:n,useSlerp:s.roll!=a.roll}),c&&e.interpolatePadding(o,i.padding,n),i.around)t.w("Easing around a point is not supported under globe projection."),e.setLocationAtPoint(i.around,i.aroundPoint);else{const t=A>_?Math.min(2,x):Math.max(.5,x),i=Math.pow(t,1-n),o=gi(r,y,v,n*i);e.setCenter(o.wrap())}if(u){const i=t.G.number(_,A,n)+pi(0,e.center.lat);e.setZoom(i)}},isZooming:u,elevationCenter:m}}handleFlyTo(e,i){const n=void 0!==i.zoom,r=e.center,o=e.zoom,s=e.padding,a=!e.isPaddingEqual(i.padding),l=e.applyConstrain(t.V.convert(i.center||i.locationAtOffset),o).center,c=n?+i.zoom:e.zoom+pi(e.center.lat,l.lat),u=e.clone();u.setCenter(l),u.setZoom(c),u.setBearing(i.bearing);const h=new t.P(t.an(e.centerPoint.x+i.offsetAsPoint.x,0,e.width),t.an(e.centerPoint.y+i.offsetAsPoint.y,0,e.height));u.setLocationAtPoint(l,h);const d=u.center;kt(e,d);const p=function(e,i,n){const r=ci(i),o=ci(n),s=t.b4(r,o),a=Math.acos(s),l=ai(e);return a/(2*Math.PI)*l}(e,r,d),f=o+pi(r.lat,0),m=c+pi(d.lat,0),g=t.aq(m-f);let _;if("number"==typeof i.minZoom){const n=+i.minZoom+pi(d.lat,0),r=Math.min(n,f,m)+pi(0,d.lat),o=e.applyConstrain(d,r).zoom+pi(d.lat,0);_=t.aq(o-f)}const A=t.bJ(r.lng,d.lng),y=t.bJ(r.lat,d.lat);return{easeFunc:(n,o,l,u)=>{const h=gi(r,A,y,l);a&&e.interpolatePadding(s,i.padding,n);const p=1===n?d:h;e.setCenter(p.wrap());const m=f+t.at(o);e.setZoom(1===n?c:m+pi(0,p.lat))},scaleOfZoom:g,targetCenter:d,scaleOfMinZoom:_,pixelPathLength:p}}static solveVectorScale(e,t,i,n,r){const o="x"===n?[i[0],i[4],i[8],i[12]]:[i[1],i[5],i[9],i[13]],s=[i[3],i[7],i[11],i[15]],a=e[0]*o[0]+e[1]*o[1]+e[2]*o[2],l=e[0]*s[0]+e[1]*s[1]+e[2]*s[2],c=t[0]*o[0]+t[1]*o[1]+t[2]*o[2],u=t[0]*s[0]+t[1]*s[1]+t[2]*s[2];return c+r*l===a+r*u||s[3]*(a-c)+o[3]*(u-l)+a*u==c*l?null:(c+o[3]-r*u-r*s[3])/(c-a-r*u+r*l)}static getLesserNonNegativeNonNull(e,t){return null!==t&&t>=0&&tt.B(e,i&&i.filter(e=>"source.canvas"!==e.identifier)),Bi=t.bN();class Ii extends t.E{constructor(e,i={}){var n,r;super(),this._rtlPluginLoaded=()=>{for(const e in this.tileManagers){const t=this.tileManagers[e].getSource().type;"vector"!==t&&"geojson"!==t||this.tileManagers[e].reload()}},this.map=e,this.dispatcher=new N(U(),e._getMapId()),this.dispatcher.registerMessageHandler("GG",(e,t)=>this.getGlyphs(e,t)),this.dispatcher.registerMessageHandler("GI",(e,t)=>this.getImages(e,t)),this.dispatcher.registerMessageHandler("GDA",(e,t)=>this.getDashes(e,t)),this.imageManager=new b,this.imageManager.setEventedParent(this);const o=(null===(n=e._container)||void 0===n?void 0:n.lang)||"undefined"!=typeof document&&(null===(r=document.documentElement)||void 0===r?void 0:r.lang)||void 0;this.glyphManager=new S(e._requestManager,i.localIdeographFontFamily,o),this.lineAtlas=new L(256,512),this.crossTileSymbolIndex=new Et,this._setInitialValues(),this._resetUpdates(),this.dispatcher.broadcast("SR",t.bO()),ce().on(se,this._rtlPluginLoaded),this.on("data",e=>{if("source"!==e.dataType||"metadata"!==e.sourceDataType)return;const t=this.tileManagers[e.sourceId];if(!t)return;const i=t.getSource();if(i&&i.vectorLayerIds)for(const e in this._layers){const t=this._layers[e];t.source===i.id&&this._validateLayer(t)}})}_setInitialValues(){var e;this._spritesImagesIds={},this._layers={},this._order=[],this.tileManagers={},this.zoomHistory=new t.bP,this._availableImages=[],this._globalState={},this._serializedLayers={},this.stylesheet=null,this.light=null,this.sky=null,this.projection&&(this.projection.destroy(),delete this.projection),this._loaded=!1,this._changed=!1,this._updatedLayers={},this._updatedSources={},this._changedImages={},this._glyphsDidChange=!1,this._updatedPaintProps={},this._layerOrderChanged=!1,this.crossTileSymbolIndex=new((null===(e=this.crossTileSymbolIndex)||void 0===e?void 0:e.constructor)||Object),this.pauseablePlacement=void 0,this.placement=void 0,this.z=0}setGlobalStateProperty(e,i){var n,r,o;this._checkLoaded();const s=null===i?null!==(o=null===(r=null===(n=this.stylesheet.state)||void 0===n?void 0:n[e])||void 0===r?void 0:r.default)&&void 0!==o?o:null:i;if(t.bQ(s,this._globalState[e]))return this;this._globalState[e]=s,this._applyGlobalStateChanges([e])}getGlobalState(){return this._globalState}setGlobalState(e){this._checkLoaded();const i=[];for(const n in e)!t.bQ(this._globalState[n],e[n].default)&&(i.push(n),this._globalState[n]=e[n].default);this._applyGlobalStateChanges(i)}_applyGlobalStateChanges(e){if(0===e.length)return;const t=new Set,i={};for(const n of e){i[n]=this._globalState[n];for(const e in this._layers){const i=this._layers[e],r=i.getLayoutAffectingGlobalStateRefs(),o=i.getPaintAffectingGlobalStateRefs();if(r.has(n)&&t.add(i.source),o.has(n))for(const{name:e,value:t}of o.get(n))this._updatePaintProperty(i,e,t)}}this.dispatcher.broadcast("UGS",i);for(const e in this.tileManagers)t.has(e)&&(this._reloadSource(e),this._changed=!0)}loadURL(e,i={},n){this.fire(new t.l("dataloading",{dataType:"style"})),i.validate="boolean"!=typeof i.validate||i.validate;const r=this.map._requestManager.transformRequest(e,"Style");this._loadStyleRequest=new AbortController;const o=this._loadStyleRequest;t.j(r,this._loadStyleRequest).then(e=>{this._loadStyleRequest=null,this._load(e.data,i,n)}).catch(e=>{this._loadStyleRequest=null,e&&!o.signal.aborted&&this.fire(new t.k(e))})}loadJSON(e,i={},n){this.fire(new t.l("dataloading",{dataType:"style"})),this._frameRequest=new AbortController,a.frameAsync(this._frameRequest).then(()=>{this._frameRequest=null,i.validate=!1!==i.validate,this._load(e,i,n)}).catch(()=>{})}loadEmpty(){this.fire(new t.l("dataloading",{dataType:"style"})),this._load(Bi,{validate:!1})}_load(e,i,n){var r,o;let s=i.transformStyle?i.transformStyle(n,e):e;if(!i.validate||!Si(this,t.C(s))){s=Object.assign({},s),this._loaded=!0,this.stylesheet=s;for(const e in s.sources)this.addSource(e,s.sources[e],{validate:!1});s.sprite?this._loadSprite(s.sprite):this.imageManager.setLoaded(!0),this.glyphManager.setURL(s.glyphs),this._createLayers(),this.light=new M(this.stylesheet.light),this._setProjectionInternal((null===(r=this.stylesheet.projection)||void 0===r?void 0:r.type)||"mercator"),this.sky=new R(this.stylesheet.sky),this.map.setTerrain(null!==(o=this.stylesheet.terrain)&&void 0!==o?o:null),this.fire(new t.l("data",{dataType:"style"})),this.fire(new t.l("style.load"))}}_createLayers(){var e,i,n;const r=t.bR(this.stylesheet.layers);this.setGlobalState(null!==(e=this.stylesheet.state)&&void 0!==e?e:null),this.dispatcher.broadcast("SL",r),this._order=r.map(e=>e.id),this._layers={},this._serializedLayers=null;for(const e of r){const r=t.bS(e,this._globalState);if(r.setEventedParent(this,{layer:{id:e.id}}),this._layers[e.id]=r,t.bT(r)&&this.tileManagers[r.source]){const t=null!==(n=null===(i=e.paint)||void 0===i?void 0:i["raster-fade-duration"])&&void 0!==n?n:r.paint.get("raster-fade-duration");this.tileManagers[r.source].setRasterFadeDuration(t)}}}_loadSprite(e,i=!1,n=void 0){let r;this.imageManager.setLoaded(!1),this._spriteRequest=new AbortController,function(e,i,n,r){return t._(this,void 0,void 0,function*(){const o=y(e),s=n>1?"@2x":"",l={},c={};for(const{id:e,url:n}of o){const o=i.transformRequest(v(n,s,".json"),"SpriteJSON");l[e]=t.j(o,r);const a=i.transformRequest(v(n,s,".png"),"SpriteImage");c[e]=_.getImage(a,r)}return yield Promise.all([...Object.values(l),...Object.values(c)]),function(e,i){return t._(this,void 0,void 0,function*(){const t={};for(const n in e){t[n]={};const r=a.getImageCanvasContext((yield i[n]).data),o=(yield e[n]).data;for(const e in o){const{width:i,height:s,x:a,y:l,sdf:c,pixelRatio:u,stretchX:h,stretchY:d,content:p,textFitWidth:f,textFitHeight:m}=o[e];t[n][e]={data:null,pixelRatio:u,sdf:c,stretchX:h,stretchY:d,content:p,textFitWidth:f,textFitHeight:m,spriteData:{width:i,height:s,x:a,y:l,context:r}}}}return t})}(l,c)})}(e,this.map._requestManager,this.map.getPixelRatio(),this._spriteRequest).then(e=>{if(this._spriteRequest=null,e)for(const t in e){this._spritesImagesIds[t]=[];const n=this._spritesImagesIds[t]?this._spritesImagesIds[t].filter(t=>!(t in e)):[];for(const e of n)this.imageManager.removeImage(e),this._changedImages[e]=!0;for(const n in e[t]){const r="default"===t?n:`${t}:${n}`;this._spritesImagesIds[t].push(r),r in this.imageManager.images?this.imageManager.updateImage(r,e[t][n],!1):this.imageManager.addImage(r,e[t][n]),i&&(this._changedImages[r]=!0)}}}).catch(e=>{this._spriteRequest=null,r=e,this.fire(new t.k(r))}).finally(()=>{this.imageManager.setLoaded(!0),this._availableImages=this.imageManager.listImages(),i&&(this._changed=!0),this.dispatcher.broadcast("SI",this._availableImages),this.fire(new t.l("data",{dataType:"style"})),n&&n(r)})}_unloadSprite(){for(const e of Object.values(this._spritesImagesIds).flat())this.imageManager.removeImage(e),this._changedImages[e]=!0;this._spritesImagesIds={},this._availableImages=this.imageManager.listImages(),this._changed=!0,this.dispatcher.broadcast("SI",this._availableImages),this.fire(new t.l("data",{dataType:"style"}))}_validateLayer(e){const i=this.tileManagers[e.source];if(!i)return;const n=e.sourceLayer;if(!n)return;const r=i.getSource();("geojson"===r.type||r.vectorLayerIds&&-1===r.vectorLayerIds.indexOf(n))&&this.fire(new t.k(new Error(`Source layer "${n}" does not exist on source "${r.id}" as specified by style layer "${e.id}".`)))}loaded(){if(!this._loaded)return!1;if(Object.keys(this._updatedSources).length)return!1;for(const e in this.tileManagers)if(!this.tileManagers[e].loaded())return!1;return!!this.imageManager.isLoaded()}_serializeByIds(e,i=!1){const n=this._serializedAllLayers();if(!e||0===e.length)return Object.values(i?t.bU(n):n);const r=[];for(const o of e)if(n[o]){const e=i?t.bU(n[o]):n[o];r.push(e)}return r}_serializedAllLayers(){let e=this._serializedLayers;if(e)return e;e=this._serializedLayers={};const t=Object.keys(this._layers);for(const i of t){const t=this._layers[i];"custom"!==t.type&&(e[i]=t.serialize())}return e}hasTransitions(){var e,t,i;if(null===(e=this.light)||void 0===e?void 0:e.hasTransition())return!0;if(null===(t=this.sky)||void 0===t?void 0:t.hasTransition())return!0;if(null===(i=this.projection)||void 0===i?void 0:i.hasTransition())return!0;for(const e in this.tileManagers)if(this.tileManagers[e].hasTransition())return!0;for(const e in this._layers)if(this._layers[e].hasTransition())return!0;return!1}_checkLoaded(){if(!this._loaded)throw new Error("Style is not done loading.")}update(e){if(!this._loaded)return;const i=this._changed;if(i){const t=Object.keys(this._updatedLayers),i=Object.keys(this._removedLayers);(t.length||i.length)&&this._updateWorkerLayers(t,i);for(const e in this._updatedSources){const t=this._updatedSources[e];if("reload"===t)this._reloadSource(e);else{if("clear"!==t)throw new Error(`Invalid action ${t}`);this._clearSource(e)}}this._updateTilesForChangedImages(),this._updateTilesForChangedGlyphs();for(const t in this._updatedPaintProps)this._layers[t].updateTransitions(e);this.light.updateTransitions(e),this.sky.updateTransitions(e),this._resetUpdates()}const n={};for(const e in this.tileManagers){const t=this.tileManagers[e];n[e]=t.used,t.used=!1}for(const t of this._order){const i=this._layers[t];i.recalculate(e,this._availableImages),!i.isHidden(e.zoom)&&i.source&&(this.tileManagers[i.source].used=!0)}for(const e in n){const i=this.tileManagers[e];!!n[e]!=!!i.used&&i.fire(new t.l("data",{sourceDataType:"visibility",dataType:"source",sourceId:e}))}this.light.recalculate(e),this.sky.recalculate(e),this.projection.recalculate(e),this.z=e.zoom,i&&this.fire(new t.l("data",{dataType:"style"}))}_updateTilesForChangedImages(){const e=Object.keys(this._changedImages);if(e.length){for(const t in this.tileManagers)this.tileManagers[t].reloadTilesForDependencies(["icons","patterns"],e);this._changedImages={}}}_updateTilesForChangedGlyphs(){if(this._glyphsDidChange){for(const e in this.tileManagers)this.tileManagers[e].reloadTilesForDependencies(["glyphs"],[""]);this._glyphsDidChange=!1}}_updateWorkerLayers(e,t){this.dispatcher.broadcast("UL",{layers:this._serializeByIds(e,!1),removedIds:t})}_resetUpdates(){this._changed=!1,this._updatedLayers={},this._removedLayers={},this._updatedSources={},this._updatedPaintProps={},this._changedImages={},this._glyphsDidChange=!1}setState(e,i={}){var n;this._checkLoaded();const r=this.serialize();if(e=i.transformStyle?i.transformStyle(r,e):e,(null===(n=i.validate)||void 0===n||n)&&Si(this,t.C(e)))return!1;(e=t.bU(e)).layers=t.bR(e.layers);const o=t.bV(r,e),s=this._getOperationsToPerform(o);if(s.unimplemented.length>0)throw new Error(`Unimplemented: ${s.unimplemented.join(", ")}.`);if(0===s.operations.length)return!1;for(const e of s.operations)e();return this.stylesheet=e,this._serializedLayers=null,!0}_getOperationsToPerform(e){const t=[],i=[];for(const n of e)switch(n.command){case"setCenter":case"setZoom":case"setBearing":case"setPitch":case"setRoll":continue;case"addLayer":t.push(()=>this.addLayer.apply(this,n.args));break;case"removeLayer":t.push(()=>this.removeLayer.apply(this,n.args));break;case"setPaintProperty":t.push(()=>this.setPaintProperty.apply(this,n.args));break;case"setLayoutProperty":t.push(()=>this.setLayoutProperty.apply(this,n.args));break;case"setFilter":t.push(()=>this.setFilter.apply(this,n.args));break;case"addSource":t.push(()=>this.addSource.apply(this,n.args));break;case"removeSource":t.push(()=>this.removeSource.apply(this,n.args));break;case"setLayerZoomRange":t.push(()=>this.setLayerZoomRange.apply(this,n.args));break;case"setLight":t.push(()=>this.setLight.apply(this,n.args));break;case"setGeoJSONSourceData":t.push(()=>this.setGeoJSONSourceData.apply(this,n.args));break;case"setGlyphs":t.push(()=>this.setGlyphs.apply(this,n.args));break;case"setSprite":t.push(()=>this.setSprite.apply(this,n.args));break;case"setTerrain":t.push(()=>this.map.setTerrain.apply(this,n.args));break;case"setSky":t.push(()=>this.setSky.apply(this,n.args));break;case"setProjection":this.setProjection.apply(this,n.args);break;case"setGlobalState":t.push(()=>this.setGlobalState.apply(this,n.args));break;case"setTransition":t.push(()=>{});break;default:i.push(n.command)}return{operations:t,unimplemented:i}}addImage(e,i){if(this.getImage(e))return this.fire(new t.k(new Error(`An image named "${e}" already exists.`)));this.imageManager.addImage(e,i),this._afterImageUpdated(e)}updateImage(e,t){this.imageManager.updateImage(e,t)}getImage(e){return this.imageManager.getImage(e)}removeImage(e){if(!this.getImage(e))return this.fire(new t.k(new Error(`An image named "${e}" does not exist.`)));this.imageManager.removeImage(e),this._afterImageUpdated(e)}_afterImageUpdated(e){this._availableImages=this.imageManager.listImages(),this._changedImages[e]=!0,this._changed=!0,this.dispatcher.broadcast("SI",this._availableImages),this.fire(new t.l("data",{dataType:"style"}))}listImages(){return this._checkLoaded(),this.imageManager.listImages()}addSource(e,i,n={}){if(this._checkLoaded(),void 0!==this.tileManagers[e])throw new Error(`Source "${e}" already exists.`);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"].indexOf(i.type)>=0&&this._validate(t.C.source,`sources.${e}`,i,null,n))return;this.map&&this.map._collectResourceTiming&&(i.collectResourceTiming=!0);const r=this.tileManagers[e]=new Se(e,i,this.dispatcher);r.style=this,r.setEventedParent(this,()=>({isSourceLoaded:r.loaded(),source:r.serialize(),sourceId:e})),r.onAdd(this.map),this._changed=!0}removeSource(e){if(this._checkLoaded(),void 0===this.tileManagers[e])throw new Error("There is no source with this ID");for(const i in this._layers)if(this._layers[i].source===e)return this.fire(new t.k(new Error(`Source "${e}" cannot be removed while layer "${i}" is using it.`)));const i=this.tileManagers[e];delete this.tileManagers[e],delete this._updatedSources[e],i.fire(new t.l("data",{sourceDataType:"metadata",dataType:"source",sourceId:e})),i.setEventedParent(null),i.onRemove(this.map),this._changed=!0}setGeoJSONSourceData(e,t){if(this._checkLoaded(),void 0===this.tileManagers[e])throw new Error(`There is no source with this ID=${e}`);const i=this.tileManagers[e].getSource();if("geojson"!==i.type)throw new Error(`geojsonSource.type is ${i.type}, which is !== 'geojson`);i.setData(t),this._changed=!0}getSource(e){return this.tileManagers[e]&&this.tileManagers[e].getSource()}addLayer(e,i,n={}){this._checkLoaded();const r=e.id;if(this.getLayer(r))return void this.fire(new t.k(new Error(`Layer "${r}" already exists on this map.`)));let o;if("custom"===e.type){if(Si(this,t.bW(e)))return;o=t.bS(e,this._globalState)}else{if("source"in e&&"object"==typeof e.source&&(this.addSource(r,e.source),e=t.bU(e),e=t.e(e,{source:r})),this._validate(t.C.layer,`layers.${r}`,e,{arrayIndex:-1},n))return;o=t.bS(e,this._globalState),this._validateLayer(o),o.setEventedParent(this,{layer:{id:r}})}const s=i?this._order.indexOf(i):this._order.length;if(i&&-1===s)this.fire(new t.k(new Error(`Cannot add layer "${r}" before non-existing layer "${i}".`)));else{if(this._order.splice(s,0,r),this._layerOrderChanged=!0,this._layers[r]=o,this._removedLayers[r]&&o.source&&"custom"!==o.type){const e=this._removedLayers[r];delete this._removedLayers[r],e.type!==o.type?this._updatedSources[o.source]="clear":(this._updatedSources[o.source]="reload",this.tileManagers[o.source].pause())}this._updateLayer(o),o.onAdd&&o.onAdd(this.map)}}moveLayer(e,i){if(this._checkLoaded(),this._changed=!0,!this._layers[e])return void this.fire(new t.k(new Error(`The layer '${e}' does not exist in the map's style and cannot be moved.`)));if(e===i)return;const n=this._order.indexOf(e);this._order.splice(n,1);const r=i?this._order.indexOf(i):this._order.length;i&&-1===r?this.fire(new t.k(new Error(`Cannot move layer "${e}" before non-existing layer "${i}".`))):(this._order.splice(r,0,e),this._layerOrderChanged=!0)}removeLayer(e){this._checkLoaded();const i=this._layers[e];if(!i)return void this.fire(new t.k(new Error(`Cannot remove non-existing layer "${e}".`)));i.setEventedParent(null);const n=this._order.indexOf(e);this._order.splice(n,1),this._layerOrderChanged=!0,this._changed=!0,this._removedLayers[e]=i,delete this._layers[e],this._serializedLayers&&delete this._serializedLayers[e],delete this._updatedLayers[e],delete this._updatedPaintProps[e],i.onRemove&&i.onRemove(this.map)}getLayer(e){return this._layers[e]}getLayersOrder(){return[...this._order]}hasLayer(e){return e in this._layers}setLayerZoomRange(e,i,n){this._checkLoaded();const r=this.getLayer(e);r?r.minzoom===i&&r.maxzoom===n||(null!=i&&(r.minzoom=i),null!=n&&(r.maxzoom=n),this._updateLayer(r)):this.fire(new t.k(new Error(`Cannot set the zoom range of non-existing layer "${e}".`)))}setFilter(e,i,n={}){this._checkLoaded();const r=this.getLayer(e);if(r){if(!t.bQ(r.filter,i))return null==i?(r.setFilter(void 0),void this._updateLayer(r)):void(this._validate(t.C.filter,`layers.${r.id}.filter`,i,null,n)||(r.setFilter(t.bU(i)),this._updateLayer(r)))}else this.fire(new t.k(new Error(`Cannot filter non-existing layer "${e}".`)))}getFilter(e){return t.bU(this.getLayer(e).filter)}setLayoutProperty(e,i,n,r={}){this._checkLoaded();const o=this.getLayer(e);o?t.bQ(o.getLayoutProperty(i),n)||(o.setLayoutProperty(i,n,r),this._updateLayer(o)):this.fire(new t.k(new Error(`Cannot style non-existing layer "${e}".`)))}getLayoutProperty(e,i){const n=this.getLayer(e);if(n)return n.getLayoutProperty(i);this.fire(new t.k(new Error(`Cannot get style of non-existing layer "${e}".`)))}setPaintProperty(e,i,n,r={}){this._checkLoaded();const o=this.getLayer(e);o?t.bQ(o.getPaintProperty(i),n)||this._updatePaintProperty(o,i,n,r):this.fire(new t.k(new Error(`Cannot style non-existing layer "${e}".`)))}_updatePaintProperty(e,i,n,r={}){e.setPaintProperty(i,n,r)&&this._updateLayer(e),t.bT(e)&&"raster-fade-duration"===i&&this.tileManagers[e.source].setRasterFadeDuration(n),this._changed=!0,this._updatedPaintProps[e.id]=!0,this._serializedLayers=null}getPaintProperty(e,t){return this.getLayer(e).getPaintProperty(t)}setFeatureState(e,i){this._checkLoaded();const n=e.source,r=e.sourceLayer,o=this.tileManagers[n];if(void 0===o)return void this.fire(new t.k(new Error(`The source '${n}' does not exist in the map's style.`)));const s=o.getSource().type;"geojson"===s&&r?this.fire(new t.k(new Error("GeoJSON sources cannot have a sourceLayer parameter."))):"vector"!==s||r?(void 0===e.id&&this.fire(new t.k(new Error("The feature id parameter must be provided."))),o.setFeatureState(r,e.id,i)):this.fire(new t.k(new Error("The sourceLayer parameter must be provided for vector source types.")))}removeFeatureState(e,i){this._checkLoaded();const n=e.source,r=this.tileManagers[n];if(void 0===r)return void this.fire(new t.k(new Error(`The source '${n}' does not exist in the map's style.`)));const o=r.getSource().type,s="vector"===o?e.sourceLayer:void 0;"vector"!==o||s?i&&"string"!=typeof e.id&&"number"!=typeof e.id?this.fire(new t.k(new Error("A feature id is required to remove its specific state property."))):r.removeFeatureState(s,e.id,i):this.fire(new t.k(new Error("The sourceLayer parameter must be provided for vector source types.")))}getFeatureState(e){this._checkLoaded();const i=e.source,n=e.sourceLayer,r=this.tileManagers[i];if(void 0!==r)return"vector"!==r.getSource().type||n?(void 0===e.id&&this.fire(new t.k(new Error("The feature id parameter must be provided."))),r.getFeatureState(n,e.id)):void this.fire(new t.k(new Error("The sourceLayer parameter must be provided for vector source types.")));this.fire(new t.k(new Error(`The source '${i}' does not exist in the map's style.`)))}getTransition(){return t.e({duration:300,delay:0},this.stylesheet&&this.stylesheet.transition)}serialize(){if(!this._loaded)return;const e=t.bX(this.tileManagers,e=>e.serialize()),i=this._serializeByIds(this._order,!0),n=this.map.getTerrain()||void 0,r=this.stylesheet;return t.bY({version:r.version,name:r.name,metadata:r.metadata,light:r.light,sky:r.sky,center:r.center,zoom:r.zoom,bearing:r.bearing,pitch:r.pitch,sprite:r.sprite,glyphs:r.glyphs,transition:r.transition,projection:r.projection,sources:e,layers:i,terrain:n},e=>void 0!==e)}_updateLayer(e){this._updatedLayers[e.id]=!0,e.source&&!this._updatedSources[e.source]&&"raster"!==this.tileManagers[e.source].getSource().type&&(this._updatedSources[e.source]="reload",this.tileManagers[e.source].pause()),this._serializedLayers=null,this._changed=!0}_flattenAndSortRenderedFeatures(e){const t=e=>"fill-extrusion"===this._layers[e].type,i={},n=[];for(let r=this._order.length-1;r>=0;r--){const o=this._order[r];if(t(o)){i[o]=r;for(const t of e){const e=t[o];if(e)for(const t of e)n.push(t)}}}n.sort((e,t)=>t.intersectionZ-e.intersectionZ);const r=[];for(let o=this._order.length-1;o>=0;o--){const s=this._order[o];if(t(s))for(let e=n.length-1;e>=0;e--){const t=n[e].feature;if(i[t.layer.id]this.map.terrain.getElevation(e,t,i):void 0));return this.placement&&o.push(function(e,t,i,n,r,o,s){const a={},l=o.queryRenderedSymbols(n),c=[];for(const e of Object.keys(l).map(Number))c.push(s[e]);c.sort(H);for(const i of c){const n=i.featureIndex.lookupSymbolFeatures(l[i.bucketInstanceId],t,i.bucketIndex,i.sourceLayerIndex,{filterSpec:r.filter,globalState:r.globalState},r.layers,r.availableImages,e);for(const e in n){const t=a[e]=a[e]||[],r=n[e];r.sort((e,t)=>{const n=i.featureSortOrder;if(n){const i=n.indexOf(e.featureIndex);return n.indexOf(t.featureIndex)-i}return t.featureIndex-e.featureIndex});for(const e of r)t.push(e)}}return function(e,t,i){for(const n in e)for(const r of e[n])Q(r,i[t[n].source]);return e}(a,e,i)}(this._layers,s,this.tileManagers,e,l,this.placement.collisionIndex,this.placement.retainedQueryData)),this._flattenAndSortRenderedFeatures(o)}querySourceFeatures(e,i){(null==i?void 0:i.filter)&&this._validate(t.C.filter,"querySourceFeatures.filter",i.filter,null,i);const n=this.tileManagers[e];return n?function(e,t){const i=e.getRenderableIds().map(t=>e.getTileByID(t)),n=[],r={};for(let e=0;ee.getTileByID(t)).sort((e,t)=>t.tileID.overscaledZ-e.tileID.overscaledZ||(e.tileID.isLessThan(t.tileID)?-1:1))}const n=this.crossTileSymbolIndex.addLayer(i,a[i.source],e.center.lng);o=o||n}if(this.crossTileSymbolIndex.pruneUnusedLayers(this._order),((r=r||this._layerOrderChanged||0===i)||!this.pauseablePlacement||this.pauseablePlacement.isDone()&&!this.placement.stillRecent(c(),e.zoom))&&(this.pauseablePlacement=new vt(e,this.map.terrain,this._order,r,t,i,n,this.placement),this._layerOrderChanged=!1),this.pauseablePlacement.isDone()?this.placement.setStale():(this.pauseablePlacement.continuePlacement(this._order,this._layers,a),this.pauseablePlacement.isDone()&&(this.placement=this.pauseablePlacement.commit(c()),s=!0),o&&this.pauseablePlacement.placement.setStale()),s||o)for(const e of this._order){const t=this._layers[e];"symbol"===t.type&&this.placement.updateLayerOpacities(t,a[t.source])}return!this.pauseablePlacement.isDone()||this.placement.hasTransitions(c())}_releaseSymbolFadeTiles(){for(const e in this.tileManagers)this.tileManagers[e].releaseSymbolFadeTiles()}getImages(e,i){return t._(this,void 0,void 0,function*(){const e=yield this.imageManager.getImages(i.icons);this._updateTilesForChangedImages();const t=this.tileManagers[i.source];return t&&t.setDependencies(i.tileID.key,i.type,i.icons),e})}getGlyphs(e,i){return t._(this,void 0,void 0,function*(){const e=yield this.glyphManager.getGlyphs(i.stacks),t=this.tileManagers[i.source];return t&&t.setDependencies(i.tileID.key,i.type,[""]),e})}getGlyphsUrl(){return this.stylesheet.glyphs||null}setGlyphs(e,i={}){this._checkLoaded(),e&&this._validate(t.C.glyphs,"glyphs",e,null,i)||(this._glyphsDidChange=!0,this.stylesheet.glyphs=e,this.glyphManager.entries={},this.glyphManager.setURL(e))}getDashes(e,i){return t._(this,void 0,void 0,function*(){const e={};for(const[t,n]of Object.entries(i.dashes))e[t]=this.lineAtlas.getDash(n.dasharray,n.round);return e})}addSprite(e,i,n={},r){this._checkLoaded();const o=[{id:e,url:i}],s=[...y(this.stylesheet.sprite),...o];this._validate(t.C.sprite,"sprite",s,null,n)||(this.stylesheet.sprite=s,this._loadSprite(o,!0,r))}removeSprite(e){this._checkLoaded();const i=y(this.stylesheet.sprite);if(i.find(t=>t.id===e)){if(this._spritesImagesIds[e])for(const t of this._spritesImagesIds[e])this.imageManager.removeImage(t),this._changedImages[t]=!0;i.splice(i.findIndex(t=>t.id===e),1),this.stylesheet.sprite=i.length>0?i:void 0,delete this._spritesImagesIds[e],this._availableImages=this.imageManager.listImages(),this._changed=!0,this.dispatcher.broadcast("SI",this._availableImages),this.fire(new t.l("data",{dataType:"style"}))}else this.fire(new t.k(new Error(`Sprite "${e}" doesn't exists on this map.`)))}getSprite(){return y(this.stylesheet.sprite)}setSprite(e,i={},n){this._checkLoaded(),e&&this._validate(t.C.sprite,"sprite",e,null,i)||(this.stylesheet.sprite=e,e?this._loadSprite(e,!0,n):(this._unloadSprite(),n&&n(null)))}destroy(){this._frameRequest&&(this._frameRequest.abort(),this._frameRequest=null),this._loadStyleRequest&&(this._loadStyleRequest.abort(),this._loadStyleRequest=null),this._spriteRequest&&(this._spriteRequest.abort(),this._spriteRequest=null);for(const e in this.tileManagers){const t=this.tileManagers[e];if(t.setEventedParent(null),t._tiles){for(const e in t._tiles)t._tiles[e].unloadVectorData();t._tiles={}}t._cache.reset(),t.onRemove(this.map)}this.tileManagers={},this.imageManager&&(this.imageManager.setEventedParent(null),this.imageManager.destroy(),this._availableImages=[],this._spritesImagesIds={}),this.glyphManager&&this.glyphManager.destroy();for(const e in this._layers){const t=this._layers[e];t.setEventedParent(null),t.onRemove&&t.onRemove(this.map)}this._setInitialValues(),this.setEventedParent(null),this.dispatcher.unregisterMessageHandler("GG"),this.dispatcher.unregisterMessageHandler("GI"),this.dispatcher.unregisterMessageHandler("GDA"),this.dispatcher.remove(!0),this._listeners={},this._oneTimeListeners={}}}var Mi=t.aT([{name:"a_pos",type:"Int16",components:2},{name:"a_texture_pos",type:"Int16",components:2}]);class Pi{constructor(){this.boundProgram=null,this.boundLayoutVertexBuffer=null,this.boundPaintVertexBuffers=[],this.boundIndexBuffer=null,this.boundVertexOffset=null,this.boundDynamicVertexBuffer=null,this.vao=null}bind(e,t,i,n,r,o,s,a,l){this.context=e;let c=this.boundPaintVertexBuffers.length!==n.length;for(let e=0;!c&&e({u_texture:0,u_ele_delta:e,u_fog_matrix:i,u_fog_color:n?n.properties.get("fog-color"):t.bo.white,u_fog_ground_blend:n?n.properties.get("fog-ground-blend"):1,u_fog_ground_blend_opacity:o?0:n?n.calculateFogBlendOpacity(r):0,u_horizon_color:n?n.properties.get("horizon-color"):t.bo.white,u_horizon_fog_blend:n?n.properties.get("horizon-fog-blend"):1,u_is_globe_mode:o?1:0}),Li={mainMatrix:"u_projection_matrix",tileMercatorCoords:"u_projection_tile_mercator_coords",clippingPlane:"u_projection_clipping_plane",projectionTransition:"u_projection_transition",fallbackMatrix:"u_projection_fallback_matrix"};function Fi(e){const t=[];for(let i=0;i({u_depth:new t.bZ(e,i.u_depth),u_terrain:new t.bZ(e,i.u_terrain),u_terrain_dim:new t.bp(e,i.u_terrain_dim),u_terrain_matrix:new t.b$(e,i.u_terrain_matrix),u_terrain_unpack:new t.c0(e,i.u_terrain_unpack),u_terrain_exaggeration:new t.bp(e,i.u_terrain_exaggeration)}))(e,E),this.projectionUniforms=((e,i)=>({u_projection_matrix:new t.b$(e,i.u_projection_matrix),u_projection_tile_mercator_coords:new t.c0(e,i.u_projection_tile_mercator_coords),u_projection_clipping_plane:new t.c0(e,i.u_projection_clipping_plane),u_projection_transition:new t.bp(e,i.u_projection_transition),u_projection_fallback_matrix:new t.b$(e,i.u_projection_fallback_matrix)}))(e,E),this.binderUniforms=n?n.getUniforms(e,E):[]}draw(e,t,i,n,r,o,s,a,l,c,u,h,d,p,f,m,g,_,A){const y=e.gl;if(this.failedToCreate)return;if(e.program.set(this.program),e.setDepthMode(i),e.setStencilMode(n),e.setColorMode(r),e.setCullFace(o),a){e.activeTexture.set(y.TEXTURE2),y.bindTexture(y.TEXTURE_2D,a.depthTexture),e.activeTexture.set(y.TEXTURE3),y.bindTexture(y.TEXTURE_2D,a.texture);for(const e in this.terrainUniforms)this.terrainUniforms[e].set(a[e])}if(l)for(const e in l)this.projectionUniforms[Li[e]].set(l[e]);if(s)for(const e in this.fixedUniforms)this.fixedUniforms[e].set(s[e]);m&&m.setUniforms(e,this.binderUniforms,p,{zoom:f});let v=0;switch(t){case y.LINES:v=2;break;case y.TRIANGLES:v=3;break;case y.LINE_STRIP:v=1}for(const i of d.get()){const n=i.vaos||(i.vaos={});(n[c]||(n[c]=new Pi)).bind(e,this,u,m?m.getPaintVertexBuffers():[],h,i.vertexOffset,g,_,A),y.drawElements(t,i.primitiveLength*v,y.UNSIGNED_SHORT,i.primitiveOffset*v*2)}}}function Di(e,i,n){const r=1/t.aM(n,1,i.transform.tileZoom),o=Math.pow(2,n.tileID.overscaledZ),s=n.tileSize*Math.pow(2,i.transform.tileZoom)/o,a=s*(n.tileID.canonical.x+n.tileID.wrap*o),l=s*n.tileID.canonical.y;return{u_image:0,u_texsize:n.imageAtlasTexture.size,u_scale:[r,e.fromScale,e.toScale],u_fade:e.t,u_pixel_coord_upper:[a>>16,l>>16],u_pixel_coord_lower:[65535&a,65535&l]}}const Oi=(e,i,n,r)=>{const o=e.style.light,s=o.properties.get("position"),a=[s.x,s.y,s.z],l=t.c3();"viewport"===o.properties.get("anchor")&&t.c4(l,e.transform.bearingInRadians),t.c5(a,a,l);const c=e.transform.transformLightDirection(a),u=o.properties.get("color");return{u_lightpos:a,u_lightpos_globe:c,u_lightintensity:o.properties.get("intensity"),u_lightcolor:[u.r,u.g,u.b],u_vertical_gradient:+i,u_opacity:n,u_fill_translate:r}},zi=(e,i,n,r,o,s,a)=>t.e(Oi(e,i,n,r),Di(s,e,a),{u_height_factor:-Math.pow(2,o.overscaledZ)/a.tileSize/8}),Ui=(e,i,n,r)=>t.e(Di(i,e,n),{u_fill_translate:r}),Ni=(e,t)=>({u_world:e,u_fill_translate:t}),Vi=(e,i,n,r,o)=>t.e(Ui(e,i,n,o),{u_world:r}),ji=(e,i,n,r,o)=>{const s=e.transform;let a,l,c=0;if("map"===n.paint.get("circle-pitch-alignment")){const e=t.aM(i,1,s.zoom);a=!0,l=[e,e],c=e/(t.a4*Math.pow(2,i.tileID.overscaledZ))*2*Math.PI*o}else a=!1,l=s.pixelsToGLUnits;return{u_camera_to_center_distance:s.cameraToCenterDistance,u_scale_with_map:+("map"===n.paint.get("circle-pitch-scale")),u_pitch_with_map:+a,u_device_pixel_ratio:e.pixelRatio,u_extrude_scale:l,u_globe_extrude_scale:c,u_translate:r}},Gi=e=>({u_pixel_extrude_scale:[1/e.width,1/e.height]}),Hi=e=>({u_viewport_size:[e.width,e.height]}),Qi=(e,t=1)=>({u_color:e,u_overlay:0,u_overlay_scale:t}),$i=(e,i,n,r)=>{const o=t.aM(e,1,i)/(t.a4*Math.pow(2,e.tileID.overscaledZ))*2*Math.PI*r;return{u_extrude_scale:t.aM(e,1,i),u_intensity:n,u_globe_extrude_scale:o}},Zi=(e,i,n,r)=>{const o=t.N();t.c6(o,0,e.width,e.height,0,0,1);const s=e.context.gl;return{u_matrix:o,u_world:[s.drawingBufferWidth,s.drawingBufferHeight],u_image:n,u_color_ramp:r,u_opacity:i.paint.get("heatmap-opacity")}},Wi=(e,t,i)=>{const n=i.paint.get("hillshade-accent-color");let r;switch(i.paint.get("hillshade-method")){case"basic":r=4;break;case"combined":r=1;break;case"igor":r=2;break;case"multidirectional":r=3;break;default:r=0}const o=i.getIlluminationProperties();for(let t=0;t{const n=i.stride,r=t.N();return t.c6(r,0,t.a4,-t.a4,0,0,1),t.O(r,r,[0,-t.a4,0]),{u_matrix:r,u_image:1,u_dimension:[n,n],u_zoom:e.overscaledZ,u_unpack:i.getUnpackVector()}};function Ki(e,i){const n=Math.pow(2,i.canonical.z),r=i.canonical.y;return[new t.aa(0,r/n).toLngLat().lat,new t.aa(0,(r+1)/n).toLngLat().lat]}const Xi=(e,t,i=0)=>({u_image:0,u_unpack:t.getUnpackVector(),u_dimension:[t.stride,t.stride],u_elevation_stops:1,u_color_stops:4,u_color_ramp_size:i,u_opacity:e.paint.get("color-relief-opacity")}),Ji=(e,i,n,r)=>{const o=e.transform;return{u_translation:on(e,i,n),u_ratio:r/t.aM(i,1,o.zoom),u_device_pixel_ratio:e.pixelRatio,u_units_to_pixels:[1/o.pixelsToGLUnits[0],1/o.pixelsToGLUnits[1]]}},Yi=(e,i,n,r,o)=>t.e(Ji(e,i,n,r),{u_image:0,u_image_height:o}),en=(e,i,n,r,o)=>{const s=e.transform,a=rn(i,s);return{u_translation:on(e,i,n),u_texsize:i.imageAtlasTexture.size,u_ratio:r/t.aM(i,1,s.zoom),u_device_pixel_ratio:e.pixelRatio,u_image:0,u_scale:[a,o.fromScale,o.toScale],u_fade:o.t,u_units_to_pixels:[1/s.pixelsToGLUnits[0],1/s.pixelsToGLUnits[1]]}},tn=(e,i,n,r,o)=>{const s=rn(i,e.transform);return t.e(Ji(e,i,n,r),{u_tileratio:s,u_crossfade_from:o.fromScale,u_crossfade_to:o.toScale,u_image:0,u_mix:o.t,u_lineatlas_width:e.lineAtlas.width,u_lineatlas_height:e.lineAtlas.height})},nn=(e,i,n,r,o,s)=>{const a=rn(i,e.transform);return t.e(Ji(e,i,n,r),{u_image:0,u_image_height:s,u_tileratio:a,u_crossfade_from:o.fromScale,u_crossfade_to:o.toScale,u_image_dash:1,u_mix:o.t,u_lineatlas_width:e.lineAtlas.width,u_lineatlas_height:e.lineAtlas.height})};function rn(e,i){return 1/t.aM(e,1,i.tileZoom)}function on(e,i,n){return t.aN(e.transform,i,n.paint.get("line-translate"),n.paint.get("line-translate-anchor"))}const sn=(e,t,i,n,r)=>{return{u_tl_parent:e,u_scale_parent:t,u_buffer_scale:1,u_fade_t:i.mix,u_opacity:i.opacity*n.paint.get("raster-opacity"),u_image0:0,u_image1:1,u_brightness_low:n.paint.get("raster-brightness-min"),u_brightness_high:n.paint.get("raster-brightness-max"),u_saturation_factor:(s=n.paint.get("raster-saturation"),s>0?1-1/(1.001-s):-s),u_contrast_factor:(o=n.paint.get("raster-contrast"),o>0?1/(1-o):1+o),u_spin_weights:an(n.paint.get("raster-hue-rotate")),u_coords_top:[r[0].x,r[0].y,r[1].x,r[1].y],u_coords_bottom:[r[3].x,r[3].y,r[2].x,r[2].y]};var o,s};function an(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 ln=(e,t,i,n,r,o,s,a,l,c,u,h,d)=>{const p=s.transform;return{u_is_size_zoom_constant:+("constant"===e||"source"===e),u_is_size_feature_constant:+("constant"===e||"camera"===e),u_size_t:t?t.uSizeT:0,u_size:t?t.uSize:0,u_camera_to_center_distance:p.cameraToCenterDistance,u_pitch:p.pitch/360*2*Math.PI,u_rotate_symbol:+i,u_aspect_ratio:p.width/p.height,u_fade_change:s.options.fadeDuration?s.symbolFadeChange:1,u_label_plane_matrix:a,u_coord_matrix:l,u_is_text:+u,u_pitch_with_map:+n,u_is_along_line:r,u_is_variable_anchor:o,u_texsize:h,u_texture:0,u_translation:c,u_pitched_scale:d}},cn=(e,i,n,r,o,s,a,l,c,u,h,d,p,f)=>{const m=a.transform;return t.e(ln(e,i,n,r,o,s,a,l,c,u,h,d,f),{u_gamma_scale:r?Math.cos(m.pitch*Math.PI/180)*m.cameraToCenterDistance:1,u_device_pixel_ratio:a.pixelRatio,u_is_halo:1})},un=(e,i,n,r,o,s,a,l,c,u,h,d,p)=>t.e(cn(e,i,n,r,o,s,a,l,c,u,!0,h,0,p),{u_texsize_icon:d,u_texture_icon:1}),hn=(e,t)=>({u_opacity:e,u_color:t}),dn=(e,i,n,r,o)=>t.e(function(e,i,n,r){const o=n.imageManager.getPattern(e.from.toString()),s=n.imageManager.getPattern(e.to.toString()),{width:a,height:l}=n.imageManager.getPixelSize(),c=Math.pow(2,r.tileID.overscaledZ),u=r.tileSize*Math.pow(2,n.transform.tileZoom)/c,h=u*(r.tileID.canonical.x+r.tileID.wrap*c),d=u*r.tileID.canonical.y;return{u_image:0,u_pattern_tl_a:o.tl,u_pattern_br_a:o.br,u_pattern_tl_b:s.tl,u_pattern_br_b:s.br,u_texsize:[a,l],u_mix:i.t,u_pattern_size_a:o.displaySize,u_pattern_size_b:s.displaySize,u_scale_a:i.fromScale,u_scale_b:i.toScale,u_tile_units_to_pixels:1/t.aM(r,1,n.transform.tileZoom),u_pixel_coord_upper:[h>>16,d>>16],u_pixel_coord_lower:[65535&h,65535&d]}}(n,o,i,r),{u_opacity:e}),pn=(e,t)=>{},fn={fillExtrusion:(e,i)=>({u_lightpos:new t.c1(e,i.u_lightpos),u_lightpos_globe:new t.c1(e,i.u_lightpos_globe),u_lightintensity:new t.bp(e,i.u_lightintensity),u_lightcolor:new t.c1(e,i.u_lightcolor),u_vertical_gradient:new t.bp(e,i.u_vertical_gradient),u_opacity:new t.bp(e,i.u_opacity),u_fill_translate:new t.c2(e,i.u_fill_translate)}),fillExtrusionPattern:(e,i)=>({u_lightpos:new t.c1(e,i.u_lightpos),u_lightpos_globe:new t.c1(e,i.u_lightpos_globe),u_lightintensity:new t.bp(e,i.u_lightintensity),u_lightcolor:new t.c1(e,i.u_lightcolor),u_vertical_gradient:new t.bp(e,i.u_vertical_gradient),u_height_factor:new t.bp(e,i.u_height_factor),u_opacity:new t.bp(e,i.u_opacity),u_fill_translate:new t.c2(e,i.u_fill_translate),u_image:new t.bZ(e,i.u_image),u_texsize:new t.c2(e,i.u_texsize),u_pixel_coord_upper:new t.c2(e,i.u_pixel_coord_upper),u_pixel_coord_lower:new t.c2(e,i.u_pixel_coord_lower),u_scale:new t.c1(e,i.u_scale),u_fade:new t.bp(e,i.u_fade)}),fill:(e,i)=>({u_fill_translate:new t.c2(e,i.u_fill_translate)}),fillPattern:(e,i)=>({u_image:new t.bZ(e,i.u_image),u_texsize:new t.c2(e,i.u_texsize),u_pixel_coord_upper:new t.c2(e,i.u_pixel_coord_upper),u_pixel_coord_lower:new t.c2(e,i.u_pixel_coord_lower),u_scale:new t.c1(e,i.u_scale),u_fade:new t.bp(e,i.u_fade),u_fill_translate:new t.c2(e,i.u_fill_translate)}),fillOutline:(e,i)=>({u_world:new t.c2(e,i.u_world),u_fill_translate:new t.c2(e,i.u_fill_translate)}),fillOutlinePattern:(e,i)=>({u_world:new t.c2(e,i.u_world),u_image:new t.bZ(e,i.u_image),u_texsize:new t.c2(e,i.u_texsize),u_pixel_coord_upper:new t.c2(e,i.u_pixel_coord_upper),u_pixel_coord_lower:new t.c2(e,i.u_pixel_coord_lower),u_scale:new t.c1(e,i.u_scale),u_fade:new t.bp(e,i.u_fade),u_fill_translate:new t.c2(e,i.u_fill_translate)}),circle:(e,i)=>({u_camera_to_center_distance:new t.bp(e,i.u_camera_to_center_distance),u_scale_with_map:new t.bZ(e,i.u_scale_with_map),u_pitch_with_map:new t.bZ(e,i.u_pitch_with_map),u_extrude_scale:new t.c2(e,i.u_extrude_scale),u_device_pixel_ratio:new t.bp(e,i.u_device_pixel_ratio),u_globe_extrude_scale:new t.bp(e,i.u_globe_extrude_scale),u_translate:new t.c2(e,i.u_translate)}),collisionBox:(e,i)=>({u_pixel_extrude_scale:new t.c2(e,i.u_pixel_extrude_scale)}),collisionCircle:(e,i)=>({u_viewport_size:new t.c2(e,i.u_viewport_size)}),debug:(e,i)=>({u_color:new t.b_(e,i.u_color),u_overlay:new t.bZ(e,i.u_overlay),u_overlay_scale:new t.bp(e,i.u_overlay_scale)}),depth:pn,clippingMask:pn,heatmap:(e,i)=>({u_extrude_scale:new t.bp(e,i.u_extrude_scale),u_intensity:new t.bp(e,i.u_intensity),u_globe_extrude_scale:new t.bp(e,i.u_globe_extrude_scale)}),heatmapTexture:(e,i)=>({u_matrix:new t.b$(e,i.u_matrix),u_world:new t.c2(e,i.u_world),u_image:new t.bZ(e,i.u_image),u_color_ramp:new t.bZ(e,i.u_color_ramp),u_opacity:new t.bp(e,i.u_opacity)}),hillshade:(e,i)=>({u_image:new t.bZ(e,i.u_image),u_latrange:new t.c2(e,i.u_latrange),u_exaggeration:new t.bp(e,i.u_exaggeration),u_altitudes:new t.c8(e,i.u_altitudes),u_azimuths:new t.c8(e,i.u_azimuths),u_accent:new t.b_(e,i.u_accent),u_method:new t.bZ(e,i.u_method),u_shadows:new t.c7(e,i.u_shadows),u_highlights:new t.c7(e,i.u_highlights)}),hillshadePrepare:(e,i)=>({u_matrix:new t.b$(e,i.u_matrix),u_image:new t.bZ(e,i.u_image),u_dimension:new t.c2(e,i.u_dimension),u_zoom:new t.bp(e,i.u_zoom),u_unpack:new t.c0(e,i.u_unpack)}),colorRelief:(e,i)=>({u_image:new t.bZ(e,i.u_image),u_unpack:new t.c0(e,i.u_unpack),u_dimension:new t.c2(e,i.u_dimension),u_elevation_stops:new t.bZ(e,i.u_elevation_stops),u_color_stops:new t.bZ(e,i.u_color_stops),u_color_ramp_size:new t.bZ(e,i.u_color_ramp_size),u_opacity:new t.bp(e,i.u_opacity)}),line:(e,i)=>({u_translation:new t.c2(e,i.u_translation),u_ratio:new t.bp(e,i.u_ratio),u_device_pixel_ratio:new t.bp(e,i.u_device_pixel_ratio),u_units_to_pixels:new t.c2(e,i.u_units_to_pixels)}),lineGradient:(e,i)=>({u_translation:new t.c2(e,i.u_translation),u_ratio:new t.bp(e,i.u_ratio),u_device_pixel_ratio:new t.bp(e,i.u_device_pixel_ratio),u_units_to_pixels:new t.c2(e,i.u_units_to_pixels),u_image:new t.bZ(e,i.u_image),u_image_height:new t.bp(e,i.u_image_height)}),linePattern:(e,i)=>({u_translation:new t.c2(e,i.u_translation),u_texsize:new t.c2(e,i.u_texsize),u_ratio:new t.bp(e,i.u_ratio),u_device_pixel_ratio:new t.bp(e,i.u_device_pixel_ratio),u_image:new t.bZ(e,i.u_image),u_units_to_pixels:new t.c2(e,i.u_units_to_pixels),u_scale:new t.c1(e,i.u_scale),u_fade:new t.bp(e,i.u_fade)}),lineSDF:(e,i)=>({u_translation:new t.c2(e,i.u_translation),u_ratio:new t.bp(e,i.u_ratio),u_device_pixel_ratio:new t.bp(e,i.u_device_pixel_ratio),u_units_to_pixels:new t.c2(e,i.u_units_to_pixels),u_image:new t.bZ(e,i.u_image),u_mix:new t.bp(e,i.u_mix),u_tileratio:new t.bp(e,i.u_tileratio),u_crossfade_from:new t.bp(e,i.u_crossfade_from),u_crossfade_to:new t.bp(e,i.u_crossfade_to),u_lineatlas_width:new t.bp(e,i.u_lineatlas_width),u_lineatlas_height:new t.bp(e,i.u_lineatlas_height)}),lineGradientSDF:(e,i)=>({u_translation:new t.c2(e,i.u_translation),u_ratio:new t.bp(e,i.u_ratio),u_device_pixel_ratio:new t.bp(e,i.u_device_pixel_ratio),u_units_to_pixels:new t.c2(e,i.u_units_to_pixels),u_image:new t.bZ(e,i.u_image),u_image_height:new t.bp(e,i.u_image_height),u_tileratio:new t.bp(e,i.u_tileratio),u_crossfade_from:new t.bp(e,i.u_crossfade_from),u_crossfade_to:new t.bp(e,i.u_crossfade_to),u_image_dash:new t.bZ(e,i.u_image_dash),u_mix:new t.bp(e,i.u_mix),u_lineatlas_width:new t.bp(e,i.u_lineatlas_width),u_lineatlas_height:new t.bp(e,i.u_lineatlas_height)}),raster:(e,i)=>({u_tl_parent:new t.c2(e,i.u_tl_parent),u_scale_parent:new t.bp(e,i.u_scale_parent),u_buffer_scale:new t.bp(e,i.u_buffer_scale),u_fade_t:new t.bp(e,i.u_fade_t),u_opacity:new t.bp(e,i.u_opacity),u_image0:new t.bZ(e,i.u_image0),u_image1:new t.bZ(e,i.u_image1),u_brightness_low:new t.bp(e,i.u_brightness_low),u_brightness_high:new t.bp(e,i.u_brightness_high),u_saturation_factor:new t.bp(e,i.u_saturation_factor),u_contrast_factor:new t.bp(e,i.u_contrast_factor),u_spin_weights:new t.c1(e,i.u_spin_weights),u_coords_top:new t.c0(e,i.u_coords_top),u_coords_bottom:new t.c0(e,i.u_coords_bottom)}),symbolIcon:(e,i)=>({u_is_size_zoom_constant:new t.bZ(e,i.u_is_size_zoom_constant),u_is_size_feature_constant:new t.bZ(e,i.u_is_size_feature_constant),u_size_t:new t.bp(e,i.u_size_t),u_size:new t.bp(e,i.u_size),u_camera_to_center_distance:new t.bp(e,i.u_camera_to_center_distance),u_pitch:new t.bp(e,i.u_pitch),u_rotate_symbol:new t.bZ(e,i.u_rotate_symbol),u_aspect_ratio:new t.bp(e,i.u_aspect_ratio),u_fade_change:new t.bp(e,i.u_fade_change),u_label_plane_matrix:new t.b$(e,i.u_label_plane_matrix),u_coord_matrix:new t.b$(e,i.u_coord_matrix),u_is_text:new t.bZ(e,i.u_is_text),u_pitch_with_map:new t.bZ(e,i.u_pitch_with_map),u_is_along_line:new t.bZ(e,i.u_is_along_line),u_is_variable_anchor:new t.bZ(e,i.u_is_variable_anchor),u_texsize:new t.c2(e,i.u_texsize),u_texture:new t.bZ(e,i.u_texture),u_translation:new t.c2(e,i.u_translation),u_pitched_scale:new t.bp(e,i.u_pitched_scale)}),symbolSDF:(e,i)=>({u_is_size_zoom_constant:new t.bZ(e,i.u_is_size_zoom_constant),u_is_size_feature_constant:new t.bZ(e,i.u_is_size_feature_constant),u_size_t:new t.bp(e,i.u_size_t),u_size:new t.bp(e,i.u_size),u_camera_to_center_distance:new t.bp(e,i.u_camera_to_center_distance),u_pitch:new t.bp(e,i.u_pitch),u_rotate_symbol:new t.bZ(e,i.u_rotate_symbol),u_aspect_ratio:new t.bp(e,i.u_aspect_ratio),u_fade_change:new t.bp(e,i.u_fade_change),u_label_plane_matrix:new t.b$(e,i.u_label_plane_matrix),u_coord_matrix:new t.b$(e,i.u_coord_matrix),u_is_text:new t.bZ(e,i.u_is_text),u_pitch_with_map:new t.bZ(e,i.u_pitch_with_map),u_is_along_line:new t.bZ(e,i.u_is_along_line),u_is_variable_anchor:new t.bZ(e,i.u_is_variable_anchor),u_texsize:new t.c2(e,i.u_texsize),u_texture:new t.bZ(e,i.u_texture),u_gamma_scale:new t.bp(e,i.u_gamma_scale),u_device_pixel_ratio:new t.bp(e,i.u_device_pixel_ratio),u_is_halo:new t.bZ(e,i.u_is_halo),u_translation:new t.c2(e,i.u_translation),u_pitched_scale:new t.bp(e,i.u_pitched_scale)}),symbolTextAndIcon:(e,i)=>({u_is_size_zoom_constant:new t.bZ(e,i.u_is_size_zoom_constant),u_is_size_feature_constant:new t.bZ(e,i.u_is_size_feature_constant),u_size_t:new t.bp(e,i.u_size_t),u_size:new t.bp(e,i.u_size),u_camera_to_center_distance:new t.bp(e,i.u_camera_to_center_distance),u_pitch:new t.bp(e,i.u_pitch),u_rotate_symbol:new t.bZ(e,i.u_rotate_symbol),u_aspect_ratio:new t.bp(e,i.u_aspect_ratio),u_fade_change:new t.bp(e,i.u_fade_change),u_label_plane_matrix:new t.b$(e,i.u_label_plane_matrix),u_coord_matrix:new t.b$(e,i.u_coord_matrix),u_is_text:new t.bZ(e,i.u_is_text),u_pitch_with_map:new t.bZ(e,i.u_pitch_with_map),u_is_along_line:new t.bZ(e,i.u_is_along_line),u_is_variable_anchor:new t.bZ(e,i.u_is_variable_anchor),u_texsize:new t.c2(e,i.u_texsize),u_texsize_icon:new t.c2(e,i.u_texsize_icon),u_texture:new t.bZ(e,i.u_texture),u_texture_icon:new t.bZ(e,i.u_texture_icon),u_gamma_scale:new t.bp(e,i.u_gamma_scale),u_device_pixel_ratio:new t.bp(e,i.u_device_pixel_ratio),u_is_halo:new t.bZ(e,i.u_is_halo),u_translation:new t.c2(e,i.u_translation),u_pitched_scale:new t.bp(e,i.u_pitched_scale)}),background:(e,i)=>({u_opacity:new t.bp(e,i.u_opacity),u_color:new t.b_(e,i.u_color)}),backgroundPattern:(e,i)=>({u_opacity:new t.bp(e,i.u_opacity),u_image:new t.bZ(e,i.u_image),u_pattern_tl_a:new t.c2(e,i.u_pattern_tl_a),u_pattern_br_a:new t.c2(e,i.u_pattern_br_a),u_pattern_tl_b:new t.c2(e,i.u_pattern_tl_b),u_pattern_br_b:new t.c2(e,i.u_pattern_br_b),u_texsize:new t.c2(e,i.u_texsize),u_mix:new t.bp(e,i.u_mix),u_pattern_size_a:new t.c2(e,i.u_pattern_size_a),u_pattern_size_b:new t.c2(e,i.u_pattern_size_b),u_scale_a:new t.bp(e,i.u_scale_a),u_scale_b:new t.bp(e,i.u_scale_b),u_pixel_coord_upper:new t.c2(e,i.u_pixel_coord_upper),u_pixel_coord_lower:new t.c2(e,i.u_pixel_coord_lower),u_tile_units_to_pixels:new t.bp(e,i.u_tile_units_to_pixels)}),terrain:(e,i)=>({u_texture:new t.bZ(e,i.u_texture),u_ele_delta:new t.bp(e,i.u_ele_delta),u_fog_matrix:new t.b$(e,i.u_fog_matrix),u_fog_color:new t.b_(e,i.u_fog_color),u_fog_ground_blend:new t.bp(e,i.u_fog_ground_blend),u_fog_ground_blend_opacity:new t.bp(e,i.u_fog_ground_blend_opacity),u_horizon_color:new t.b_(e,i.u_horizon_color),u_horizon_fog_blend:new t.bp(e,i.u_horizon_fog_blend),u_is_globe_mode:new t.bp(e,i.u_is_globe_mode)}),terrainDepth:(e,i)=>({u_ele_delta:new t.bp(e,i.u_ele_delta)}),terrainCoords:(e,i)=>({u_texture:new t.bZ(e,i.u_texture),u_terrain_coords_id:new t.bp(e,i.u_terrain_coords_id),u_ele_delta:new t.bp(e,i.u_ele_delta)}),projectionErrorMeasurement:(e,i)=>({u_input:new t.bp(e,i.u_input),u_output_expected:new t.bp(e,i.u_output_expected)}),atmosphere:(e,i)=>({u_sun_pos:new t.c1(e,i.u_sun_pos),u_atmosphere_blend:new t.bp(e,i.u_atmosphere_blend),u_globe_position:new t.c1(e,i.u_globe_position),u_globe_radius:new t.bp(e,i.u_globe_radius),u_inv_proj_matrix:new t.b$(e,i.u_inv_proj_matrix)}),sky:(e,i)=>({u_sky_color:new t.b_(e,i.u_sky_color),u_horizon_color:new t.b_(e,i.u_horizon_color),u_horizon:new t.c2(e,i.u_horizon),u_horizon_normal:new t.c2(e,i.u_horizon_normal),u_sky_horizon_blend:new t.bp(e,i.u_sky_horizon_blend),u_sky_blend:new t.bp(e,i.u_sky_blend)})};class mn{constructor(e,t,i){this.context=e;const n=e.gl;this.buffer=n.createBuffer(),this.dynamicDraw=Boolean(i),this.context.unbindVAO(),e.bindElementBuffer.set(this.buffer),n.bufferData(n.ELEMENT_ARRAY_BUFFER,t.arrayBuffer,this.dynamicDraw?n.DYNAMIC_DRAW:n.STATIC_DRAW),this.dynamicDraw||delete t.arrayBuffer}bind(){this.context.bindElementBuffer.set(this.buffer)}updateData(e){const t=this.context.gl;if(!this.dynamicDraw)throw new Error("Attempted to update data while not in dynamic mode.");this.context.unbindVAO(),this.bind(),t.bufferSubData(t.ELEMENT_ARRAY_BUFFER,0,e.arrayBuffer)}destroy(){this.buffer&&(this.context.gl.deleteBuffer(this.buffer),delete this.buffer)}}const gn={Int8:"BYTE",Uint8:"UNSIGNED_BYTE",Int16:"SHORT",Uint16:"UNSIGNED_SHORT",Int32:"INT",Uint32:"UNSIGNED_INT",Float32:"FLOAT"};class _n{constructor(e,t,i,n){this.length=t.length,this.attributes=i,this.itemSize=t.bytesPerElement,this.dynamicDraw=n,this.context=e;const r=e.gl;this.buffer=r.createBuffer(),e.bindVertexBuffer.set(this.buffer),r.bufferData(r.ARRAY_BUFFER,t.arrayBuffer,this.dynamicDraw?r.DYNAMIC_DRAW:r.STATIC_DRAW),this.dynamicDraw||delete t.arrayBuffer}bind(){this.context.bindVertexBuffer.set(this.buffer)}updateData(e){if(e.length!==this.length)throw new Error(`Length of new data is ${e.length}, which doesn't match current length of ${this.length}`);const t=this.context.gl;this.bind(),t.bufferSubData(t.ARRAY_BUFFER,0,e.arrayBuffer)}enableAttributes(e,t){for(let i=0;i0&&(u.push({circleArray:g,circleOffset:d,coord:p}),h+=g.length/4,d=h),m&&c.draw(s,l.LINES,qt.disabled,Xt.disabled,e.colorModeForRenderPass(),Wt.disabled,Gi(e.transform),e.style.map.terrain&&e.style.map.terrain.getTerrainData(p),a.getProjectionData({overscaledTileID:p,applyGlobeMatrix:!0,applyTerrainMatrix:!0}),n.id,m.layoutVertexBuffer,m.indexBuffer,m.segments,null,e.transform.zoom,null,null,m.collisionVertexBuffer)}if(!o||!u.length)return;const p=e.useProgram("collisionCircle"),f=new t.c9;f.resize(4*h),f._trim();let m=0;for(const e of u)for(let t=0;t=0&&(g[_.associatedIconIndex]={shiftedAnchor:B,angle:I})}else Je(_.numGlyphs,f)}if(c){m.clear();const i=e.icon.placedSymbolArray;for(let e=0;ee.style.map.terrain.getElevation(l,t,i):null,i="map"===n.layout.get("text-rotation-alignment");Ue(c,e,o,z,U,A,u,i,l.toUnwrapped(),g.width,g.height,V,t)}const Q=o&&T||H,$=y||Q?or:A?z:e.transform.clipSpaceToPixelsMatrix,Z=f&&0!==n.paint.get(o?"text-halo-width":"icon-halo-width").constantOr(1);let W;W=f?c.iconsInText?un(w.kind,I,v,A,y,Q,e,$,N,V,P,k,C):cn(w.kind,I,v,A,y,Q,e,$,N,V,o,P,0,C):ln(w.kind,I,v,A,y,Q,e,$,N,V,o,P,C);const q={program:B,buffers:h,uniformValues:W,projectionData:j,atlasTexture:R,atlasTextureIcon:D,atlasInterpolation:L,atlasInterpolationIcon:F,isSDF:f,hasHalo:Z};if(x&&c.canOverlap){b=!0;const e=h.segments.get();for(const i of e)E.push({segments:new t.aW([i]),sortKey:i.sortKey,state:q,terrainData:M})}else E.push({segments:h.segments,sortKey:0,state:q,terrainData:M})}b&&E.sort((e,t)=>e.sortKey-t.sortKey);for(const t of E){const i=t.state;if(f.activeTexture.set(m.TEXTURE0),i.atlasTexture.bind(i.atlasInterpolation,m.CLAMP_TO_EDGE),i.atlasTextureIcon&&(f.activeTexture.set(m.TEXTURE1),i.atlasTextureIcon&&i.atlasTextureIcon.bind(i.atlasInterpolationIcon,m.CLAMP_TO_EDGE)),i.isSDF){const r=i.uniformValues;i.hasHalo&&(r.u_is_halo=1,hr(i.buffers,t.segments,n,e,i.program,w,h,d,r,i.projectionData,t.terrainData)),r.u_is_halo=0}hr(i.buffers,t.segments,n,e,i.program,w,h,d,i.uniformValues,i.projectionData,t.terrainData)}}function hr(e,t,i,n,r,o,s,a,l,c,u){const h=n.context;r.draw(h,h.gl.TRIANGLES,o,s,a,Wt.backCCW,l,u,c,i.id,e.layoutVertexBuffer,e.indexBuffer,t,i.paint,n.transform.zoom,e.programConfigurations.get(i.id),e.dynamicLayoutVertexBuffer,e.opacityVertexBuffer)}function dr(e,i,n,r,o){const s=e.context,a=s.gl,l=Xt.disabled,c=new $t([a.ONE,a.ONE],t.bo.transparent,[!0,!0,!0,!0]),u=i.getBucket(n);if(!u)return;const h=r.key;let d=n.heatmapFbos.get(h);d||(d=fr(s,i.tileSize,i.tileSize),n.heatmapFbos.set(h,d)),s.bindFramebuffer.set(d.framebuffer),s.viewport.set([0,0,i.tileSize,i.tileSize]),s.clear({color:t.bo.transparent});const p=u.programConfigurations.get(n.id),f=e.useProgram("heatmap",p,!o),m=e.transform.getProjectionData({overscaledTileID:i.tileID,applyGlobeMatrix:!0,applyTerrainMatrix:!0}),g=e.style.map.terrain.getTerrainData(r);f.draw(s,a.TRIANGLES,qt.disabled,l,c,Wt.disabled,$i(i,e.transform.zoom,n.paint.get("heatmap-intensity"),1),g,m,n.id,u.layoutVertexBuffer,u.indexBuffer,u.segments,n.paint,e.transform.zoom,p)}function pr(e,t,i,n,r){const o=e.context,s=o.gl,a=e.transform;o.setColorMode(e.colorModeForRenderPass());const l=mr(o,t),c=i.key,u=t.heatmapFbos.get(c);if(!u)return;o.activeTexture.set(s.TEXTURE0),s.bindTexture(s.TEXTURE_2D,u.colorAttachment.get()),o.activeTexture.set(s.TEXTURE1),l.bind(s.LINEAR,s.CLAMP_TO_EDGE);const h=a.getProjectionData({overscaledTileID:i,applyTerrainMatrix:r,applyGlobeMatrix:!n});e.useProgram("heatmapTexture").draw(o,s.TRIANGLES,qt.disabled,Xt.disabled,e.colorModeForRenderPass(),Wt.disabled,Zi(e,t,0,1),null,h,t.id,e.rasterBoundsBuffer,e.quadTriangleIndexBuffer,e.rasterBoundsSegments,t.paint,a.zoom),u.destroy(),t.heatmapFbos.delete(c)}function fr(e,t,i){var n,r;const o=e.gl,s=o.createTexture();o.bindTexture(o.TEXTURE_2D,s),o.texParameteri(o.TEXTURE_2D,o.TEXTURE_WRAP_S,o.CLAMP_TO_EDGE),o.texParameteri(o.TEXTURE_2D,o.TEXTURE_WRAP_T,o.CLAMP_TO_EDGE),o.texParameteri(o.TEXTURE_2D,o.TEXTURE_MIN_FILTER,o.LINEAR),o.texParameteri(o.TEXTURE_2D,o.TEXTURE_MAG_FILTER,o.LINEAR);const a=null!==(n=e.HALF_FLOAT)&&void 0!==n?n:o.UNSIGNED_BYTE,l=null!==(r=e.RGBA16F)&&void 0!==r?r:o.RGBA;o.texImage2D(o.TEXTURE_2D,0,l,t,i,0,o.RGBA,a,null);const c=e.createFramebuffer(t,i,!1,!1);return c.colorAttachment.set(s),c}function mr(e,i){return i.colorRampTexture||(i.colorRampTexture=new t.T(e,i.colorRamp,e.gl.RGBA)),i.colorRampTexture}function gr(e,i,n,r,o,s,a,l){let c=256;if(o.stepInterpolant){const r=i.getSource().maxzoom,o=a.canonical.z===r?Math.ceil(1<20&&d.texParameterf(d.TEXTURE_2D,h.extTextureFilterAnisotropic.TEXTURE_MAX_ANISOTROPY_EXT,h.extTextureFilterAnisotropicMax);const I=e.style.map.terrain&&e.style.map.terrain.getTerrainData(b),M=f.getProjectionData({overscaledTileID:b,aligned:_,applyGlobeMatrix:!c,applyTerrainMatrix:!0}),P=sn(S,C,B.fadeMix,i,a),R=m.getMeshFromTileID(h,b.canonical,o,s,"raster");p.draw(h,d.TRIANGLES,n,r?r[b.overscaledZ]:Xt.disabled,g,l?Wt.frontCCW:Wt.backCCW,P,I,M,i.id,R.vertexBuffer,R.indexBuffer,R.segments)}}function Br(e,i,n,r){const o={parentTile:null,parentScaleBy:1,parentTopLeft:[0,0],fadeValues:{tileOpacity:1,parentTileOpacity:1,fadeMix:{opacity:1,mix:0}}};if(0===n||r)return o;if(e.fadingParentID){const r=i.getLoadedTile(e.fadingParentID);if(!r)return o;const s=Math.pow(2,r.tileID.overscaledZ-e.tileID.overscaledZ),a=[e.tileID.canonical.x*s%1,e.tileID.canonical.y*s%1],l=function(e,i,n){const r=c(),o=(r-i.timeAdded)/n,s=e.fadingDirection===he.Incoming,a=t.an((r-e.timeAdded)/n,0,1),l=t.an(1-o,0,1),u=s?a:l;return{tileOpacity:u,parentTileOpacity:s?l:a,fadeMix:{opacity:1,mix:1-u}}}(e,r,n);return{parentTile:r,parentScaleBy:s,parentTopLeft:a,fadeValues:l}}if(e.selfFading){const i=function(e,i){const n=(c()-e.timeAdded)/i,r=t.an(n,0,1);return{tileOpacity:r,fadeMix:{opacity:r,mix:0}}}(e,n);return{parentTile:null,parentScaleBy:1,parentTopLeft:[0,0],fadeValues:i}}return o}const Ir=new t.bo(1,0,0,1),Mr=new t.bo(0,1,0,1),Pr=new t.bo(0,0,1,1),Rr=new t.bo(1,0,1,1),Lr=new t.bo(0,1,1,1);function Fr(e,t,i,n){Dr(e,0,t+i/2,e.transform.width,i,n)}function kr(e,t,i,n){Dr(e,t-i/2,0,i,e.transform.height,n)}function Dr(e,t,i,n,r,o){const s=e.context,a=s.gl;a.enable(a.SCISSOR_TEST),a.scissor(t*e.pixelRatio,i*e.pixelRatio,n*e.pixelRatio,r*e.pixelRatio),s.clear({color:o}),a.disable(a.SCISSOR_TEST)}function Or(e,i,n){const r=e.context,o=r.gl,s=e.useProgram("debug"),a=qt.disabled,l=Xt.disabled,c=e.colorModeForRenderPass(),u="$debug",h=e.style.map.terrain&&e.style.map.terrain.getTerrainData(n);r.activeTexture.set(o.TEXTURE0);const d=i.getTileByID(n.key).latestRawTileData,p=Math.floor((d&&d.byteLength||0)/1024),f=i.getTile(n).tileSize,m=512/Math.min(f,512)*(n.overscaledZ/e.transform.zoom)*.5;let g=n.canonical.toString();n.overscaledZ!==n.canonical.z&&(g+=` => ${n.overscaledZ}`),function(e,t){e.initDebugOverlayCanvas();const i=e.debugOverlayCanvas,n=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(n.LINEAR,n.CLAMP_TO_EDGE)}(e,`${g} ${p}kB`);const _=e.transform.getProjectionData({overscaledTileID:n,applyGlobeMatrix:!0,applyTerrainMatrix:!0});s.draw(r,o.TRIANGLES,a,l,$t.alphaBlended,Wt.disabled,Qi(t.bo.transparent,m),null,_,u,e.debugBuffer,e.quadTriangleIndexBuffer,e.debugSegments),s.draw(r,o.LINE_STRIP,a,l,c,Wt.disabled,Qi(t.bo.red),h,_,u,e.debugBuffer,e.tileBorderIndexBuffer,e.debugSegments)}function zr(e,t,i,n){const{isRenderingGlobe:r}=n,o=e.context,s=o.gl,a=e.transform,l=e.colorModeForRenderPass(),c=e.getDepthModeFor3D(),u=e.useProgram("terrain");o.bindFramebuffer.set(null),o.viewport.set([0,0,e.width,e.height]);for(const n of i){const i=t.getTerrainMesh(n.tileID),h=e.renderToTexture.getTexture(n),d=t.getTerrainData(n.tileID);o.activeTexture.set(s.TEXTURE0),s.bindTexture(s.TEXTURE_2D,h.texture);const p=t.getMeshFrameDelta(a.zoom),f=a.calculateFogMatrix(n.tileID.toUnwrapped()),m=Ri(p,f,e.style.sky,a.pitch,r),g=a.getProjectionData({overscaledTileID:n.tileID,applyTerrainMatrix:!1,applyGlobeMatrix:!0});u.draw(o,s.TRIANGLES,c,Xt.disabled,l,Wt.backCCW,m,d,g,"terrain",i.vertexBuffer,i.indexBuffer,i.segments)}}function Ur(e,i){if(!i.mesh){const n=new t.aV;n.emplaceBack(-1,-1),n.emplaceBack(1,-1),n.emplaceBack(1,1),n.emplaceBack(-1,1);const r=new t.aX;r.emplaceBack(0,1,2),r.emplaceBack(0,2,3),i.mesh=new It(e.createVertexBuffer(n,Mt.members),e.createIndexBuffer(r),t.aW.simpleSegment(0,0,n.length,r.length))}return i.mesh}class Nr{constructor(e,i){this.context=new ir(e),this.transform=i,this._tileTextures={},this.terrainFacilitator={dirty:!0,matrix:t.ar(new Float64Array(16)),renderTime:0},this.setup(),this.numSublayers=Se.maxOverzooming+Se.maxUnderzooming+1,this.depthEpsilon=1/Math.pow(2,16),this.crossTileSymbolIndex=new Et}resize(e,t,i){if(this.width=Math.floor(e*i),this.height=Math.floor(t*i),this.pixelRatio=i,this.context.viewport.set([0,0,this.width,this.height]),this.style)for(const e of this.style._order)this.style._layers[e].resize()}setup(){const e=this.context,i=new t.aV;i.emplaceBack(0,0),i.emplaceBack(t.a4,0),i.emplaceBack(0,t.a4),i.emplaceBack(t.a4,t.a4),this.tileExtentBuffer=e.createVertexBuffer(i,Mt.members),this.tileExtentSegments=t.aW.simpleSegment(0,0,4,2);const n=new t.aV;n.emplaceBack(0,0),n.emplaceBack(t.a4,0),n.emplaceBack(0,t.a4),n.emplaceBack(t.a4,t.a4),this.debugBuffer=e.createVertexBuffer(n,Mt.members),this.debugSegments=t.aW.simpleSegment(0,0,4,5);const r=new t.cg;r.emplaceBack(0,0,0,0),r.emplaceBack(t.a4,0,t.a4,0),r.emplaceBack(0,t.a4,0,t.a4),r.emplaceBack(t.a4,t.a4,t.a4,t.a4),this.rasterBoundsBuffer=e.createVertexBuffer(r,Mi.members),this.rasterBoundsSegments=t.aW.simpleSegment(0,0,4,2);const o=new t.aV;o.emplaceBack(0,0),o.emplaceBack(t.a4,0),o.emplaceBack(0,t.a4),o.emplaceBack(t.a4,t.a4),this.rasterBoundsBufferPosOnly=e.createVertexBuffer(o,Mt.members),this.rasterBoundsSegmentsPosOnly=t.aW.simpleSegment(0,0,4,5);const s=new t.aV;s.emplaceBack(0,0),s.emplaceBack(1,0),s.emplaceBack(0,1),s.emplaceBack(1,1),this.viewportBuffer=e.createVertexBuffer(s,Mt.members),this.viewportSegments=t.aW.simpleSegment(0,0,4,2);const a=new t.ch;a.emplaceBack(0),a.emplaceBack(1),a.emplaceBack(3),a.emplaceBack(2),a.emplaceBack(0),this.tileBorderIndexBuffer=e.createIndexBuffer(a);const l=new t.aX;l.emplaceBack(1,0,2),l.emplaceBack(1,2,3),this.quadTriangleIndexBuffer=e.createIndexBuffer(l);const c=this.context.gl;this.stencilClearMode=new Xt({func:c.ALWAYS,mask:0},0,255,c.ZERO,c.ZERO,c.ZERO),this.tileExtentMesh=new It(this.tileExtentBuffer,this.quadTriangleIndexBuffer,this.tileExtentSegments)}clearStencil(){const e=this.context,i=e.gl;this.nextStencilID=1,this.currentStencilSource=void 0;const n=t.N();t.c6(n,0,this.width,this.height,0,0,1),t.Q(n,n,[i.drawingBufferWidth,i.drawingBufferHeight,0]);const r={mainMatrix:n,tileMercatorCoords:[0,0,1,1],clippingPlane:[0,0,0,0],projectionTransition:0,fallbackMatrix:n};this.useProgram("clippingMask",null,!0).draw(e,i.TRIANGLES,qt.disabled,this.stencilClearMode,$t.disabled,Wt.disabled,null,null,r,"$clipping",this.viewportBuffer,this.quadTriangleIndexBuffer,this.viewportSegments)}_renderTileClippingMasks(e,t,i){if(this.currentStencilSource===e.source||!e.isTileClipped()||!t||!t.length)return;this.currentStencilSource=e.source,this.nextStencilID+t.length>256&&this.clearStencil();const n=this.context;n.setColorMode($t.disabled),n.setDepthMode(qt.disabled);const r={};for(const e of t)r[e.key]=this.nextStencilID++;this._renderTileMasks(r,t,i,!0),this._renderTileMasks(r,t,i,!1),this._tileClippingMaskIDs=r}_renderTileMasks(e,t,i,n){const r=this.context,o=r.gl,s=this.style.projection,a=this.transform,l=this.useProgram("clippingMask");for(const c of t){const t=e[c.key],u=this.style.map.terrain&&this.style.map.terrain.getTerrainData(c),h=s.getMeshFromTileID(this.context,c.canonical,n,!0,"stencil"),d=a.getProjectionData({overscaledTileID:c,applyGlobeMatrix:!i,applyTerrainMatrix:!0});l.draw(r,o.TRIANGLES,qt.disabled,new Xt({func:o.ALWAYS,mask:0},t,255,o.KEEP,o.KEEP,o.REPLACE),$t.disabled,i?Wt.disabled:Wt.backCCW,null,u,d,"$clipping",h.vertexBuffer,h.indexBuffer,h.segments)}}_renderTilesDepthBuffer(){const e=this.context,t=e.gl,i=this.style.projection,n=this.transform,r=this.useProgram("depth"),o=this.getDepthModeFor3D(),s=Ee(n,{tileSize:n.tileSize});for(const a of s){const s=this.style.map.terrain&&this.style.map.terrain.getTerrainData(a),l=i.getMeshFromTileID(this.context,a.canonical,!0,!0,"raster"),c=n.getProjectionData({overscaledTileID:a,applyGlobeMatrix:!0,applyTerrainMatrix:!0});r.draw(e,t.TRIANGLES,o,Xt.disabled,$t.disabled,Wt.backCCW,null,s,c,"$clipping",l.vertexBuffer,l.indexBuffer,l.segments)}}stencilModeFor3D(){this.currentStencilSource=void 0,this.nextStencilID+1>256&&this.clearStencil();const e=this.nextStencilID++,t=this.context.gl;return new Xt({func:t.NOTEQUAL,mask:255},e,255,t.KEEP,t.KEEP,t.REPLACE)}stencilModeForClipping(e){const t=this.context.gl;return new Xt({func:t.EQUAL,mask:255},this._tileClippingMaskIDs[e.key],0,t.KEEP,t.KEEP,t.REPLACE)}getStencilConfigForOverlapAndUpdateStencilID(e){const t=this.context.gl,i=e.sort((e,t)=>t.overscaledZ-e.overscaledZ),n=i[i.length-1].overscaledZ,r=i[0].overscaledZ-n+1;if(r>1){this.currentStencilSource=void 0,this.nextStencilID+r>256&&this.clearStencil();const e={};for(let i=0;it.overscaledZ-e.overscaledZ),n=i[i.length-1].overscaledZ,r=i[0].overscaledZ-n+1;if(this.clearStencil(),r>1){const e={},o={};for(let i=0;i0};for(const e in s){const t=s[e];t.used&&t.prepare(this.context),a[e]=t.getVisibleCoordinates(!1),l[e]=a[e].slice().reverse(),u[e]=t.getVisibleCoordinates(!0).reverse()}this.opaquePassCutoff=1/0;for(let e=0;ethis.useProgram(e)}),this.context.viewport.set([0,0,this.width,this.height]),this.context.bindFramebuffer.set(null),this.context.clear({color:i.showOverdrawInspector?t.bo.black:t.bo.transparent,depth:1}),this.clearStencil(),this.style.sky&&function(e,t){const i=e.context,n=i.gl,r=((e,t,i)=>{const n=Math.cos(t.rollInRadians),r=Math.sin(t.rollInRadians),o=_e(t),s=t.getProjectionData({overscaledTileID:null,applyGlobeMatrix:!0,applyTerrainMatrix:!0}).projectionTransition;return{u_sky_color:e.properties.get("sky-color"),u_horizon_color:e.properties.get("horizon-color"),u_horizon:[(t.width/2-o*r)*i,(t.height/2+o*n)*i],u_horizon_normal:[-r,n],u_sky_horizon_blend:e.properties.get("sky-horizon-blend")*t.height/2*i,u_sky_blend:s}})(t,e.style.map.transform,e.pixelRatio),o=new qt(n.LEQUAL,qt.ReadWrite,[0,1]),s=Xt.disabled,a=e.colorModeForRenderPass(),l=e.useProgram("sky"),c=Ur(i,t);l.draw(i,n.TRIANGLES,o,s,a,Wt.disabled,r,null,void 0,"sky",c.vertexBuffer,c.indexBuffer,c.segments)}(this,this.style.sky),this._showOverdrawInspector=i.showOverdrawInspector,this.depthRangeFor3D=[0,1-(e._order.length+2)*this.numSublayers*this.depthEpsilon],!this.renderToTexture)for(this.renderPass="opaque",this.currentLayer=o.length-1;this.currentLayer>=0;this.currentLayer--){const e=this.style._layers[o[this.currentLayer]],t=s[e.source],i=a[e.source];this._renderTileClippingMasks(e,i,!1),this.renderLayer(this,t,e,i,h)}this.renderPass="translucent";let d=!1;for(this.currentLayer=0;this.currentLayer({u_sun_pos:e,u_atmosphere_blend:t,u_globe_position:i,u_globe_radius:n,u_inv_proj_matrix:r}))(c,h,[f[0],f[1],f[2]],d,p),g=Ur(r,i);s.draw(r,o.TRIANGLES,a,Xt.disabled,$t.alphaBlended,Wt.disabled,m,null,null,"atmosphere",g.vertexBuffer,g.indexBuffer,g.segments)}(this,this.style.sky,this.style.light),this.options.showTileBoundaries){const e=function(e,t){let i=null;const n=Object.values(e._layers).flatMap(i=>i.source&&!i.isHidden(t)?[e.tileManagers[i.source]]:[]),r=n.filter(e=>"vector"===e.getSource().type),o=n.filter(e=>"vector"!==e.getSource().type),s=e=>{(!i||i.getSource().maxzooms(e)),i||o.forEach(e=>s(e)),i}(this.style,this.transform.zoom);e&&function(e,t,i){for(let n=0;nh.getElevation(o,e,t):null;lr(s,d,p,c,u,g,i,f,_,t.aN(u,e,a,l),o.toUnwrapped(),n)}}}(r,e,n,i,n.layout.get("text-rotation-alignment"),n.layout.get("text-pitch-alignment"),n.paint.get("text-translate"),n.paint.get("text-translate-anchor"),o),0!==n.paint.get("icon-opacity").constantOr(1)&&ur(e,i,n,r,!1,n.paint.get("icon-translate"),n.paint.get("icon-translate-anchor"),n.layout.get("icon-rotation-alignment"),n.layout.get("icon-pitch-alignment"),n.layout.get("icon-keep-upright"),l,c,a),0!==n.paint.get("text-opacity").constantOr(1)&&ur(e,i,n,r,!0,n.paint.get("text-translate"),n.paint.get("text-translate-anchor"),n.layout.get("text-rotation-alignment"),n.layout.get("text-pitch-alignment"),n.layout.get("text-keep-upright"),l,c,a),i.map.showCollisionBoxes&&(rr(e,i,n,r,!0),rr(e,i,n,r,!1))}(e,i,n,r,this.style.placement.variableOffsets,o):t.cm(n)?function(e,i,n,r,o){if("translucent"!==e.renderPass)return;const{isRenderingToTexture:s}=o,a=n.paint.get("circle-opacity"),l=n.paint.get("circle-stroke-width"),c=n.paint.get("circle-stroke-opacity"),u=!n.layout.get("circle-sort-key").isConstant();if(0===a.constantOr(1)&&(0===l.constantOr(1)||0===c.constantOr(1)))return;const h=e.context,d=h.gl,p=e.transform,f=e.getDepthModeForSublayer(0,qt.ReadOnly),m=Xt.disabled,g=e.colorModeForRenderPass(),_=[],A=p.getCircleRadiusCorrection();for(let o=0;oe.sortKey-t.sortKey);for(const t of _){const{programConfiguration:i,program:r,layoutVertexBuffer:o,indexBuffer:s,uniformValues:a,terrainData:l,projectionData:c}=t.state;r.draw(h,d.TRIANGLES,f,m,g,Wt.backCCW,a,l,c,n.id,o,s,t.segments,n.paint,e.transform.zoom,i)}}(e,i,n,r,o):t.cn(n)?function(e,i,n,r,o){if(0===n.paint.get("heatmap-opacity"))return;const s=e.context,{isRenderingToTexture:a,isRenderingGlobe:l}=o;if(e.style.map.terrain){for(const t of r){const r=i.getTile(t);i.hasRenderableParent(t)||("offscreen"===e.renderPass?dr(e,r,n,t,l):"translucent"===e.renderPass&&pr(e,n,t,a,l))}s.viewport.set([0,0,e.width,e.height])}else"offscreen"===e.renderPass?function(e,i,n,r){const o=e.context,s=o.gl,a=e.transform,l=Xt.disabled,c=new $t([s.ONE,s.ONE],t.bo.transparent,[!0,!0,!0,!0]);(function(e,i,n){const r=e.gl;e.activeTexture.set(r.TEXTURE1),e.viewport.set([0,0,i.width/4,i.height/4]);let o=n.heatmapFbos.get(t.cc);o?(r.bindTexture(r.TEXTURE_2D,o.colorAttachment.get()),e.bindFramebuffer.set(o.framebuffer)):(o=fr(e,i.width/4,i.height/4),n.heatmapFbos.set(t.cc,o))})(o,e,n),o.clear({color:t.bo.transparent});for(let t=0;t0?t.pop():null}isPatternMissing(e){if(!e)return!1;if(!e.from||!e.to)return!0;const t=this.imageManager.getPattern(e.from.toString()),i=this.imageManager.getPattern(e.to.toString());return!t||!i}useProgram(e,t,i=!1,n=[]){this.cache=this.cache||{};const r=!!this.style.map.terrain,o=this.style.projection,s=i?St.projectionMercator:o.shaderPreludeCode,a=i?Pt:o.shaderDefine,l=e+(t?t.cacheKey:"")+`/${i?Rt:o.shaderVariantName}`+(this._showOverdrawInspector?"/overdraw":"")+(r?"/terrain":"")+(n?`/${n.join("/")}`:"");return this.cache[l]||(this.cache[l]=new ki(this.context,St[e],t,fn[e],this._showOverdrawInspector,r,s,a,n)),this.cache[l]}setCustomLayerDefaults(){this.context.unbindVAO(),this.context.cullFace.setDefault(),this.context.activeTexture.setDefault(),this.context.pixelStoreUnpack.setDefault(),this.context.pixelStoreUnpackPremultiplyAlpha.setDefault(),this.context.pixelStoreUnpackFlipY.setDefault()}setBaseState(){const e=this.context.gl;this.context.cullFace.set(!1),this.context.viewport.set([0,0,this.width,this.height]),this.context.blendEquation.set(e.FUNC_ADD)}initDebugOverlayCanvas(){null==this.debugOverlayCanvas&&(this.debugOverlayCanvas=document.createElement("canvas"),this.debugOverlayCanvas.width=512,this.debugOverlayCanvas.height=512,this.debugOverlayTexture=new t.T(this.context,this.debugOverlayCanvas,this.context.gl.RGBA))}destroy(){var e,t;if(this._tileTextures){for(const e in this._tileTextures){const t=this._tileTextures[e];if(t)for(const e of t)e.destroy()}this._tileTextures={}}if(this.tileExtentBuffer&&this.tileExtentBuffer.destroy(),this.debugBuffer&&this.debugBuffer.destroy(),this.rasterBoundsBuffer&&this.rasterBoundsBuffer.destroy(),this.rasterBoundsBufferPosOnly&&this.rasterBoundsBufferPosOnly.destroy(),this.viewportBuffer&&this.viewportBuffer.destroy(),this.tileBorderIndexBuffer&&this.tileBorderIndexBuffer.destroy(),this.quadTriangleIndexBuffer&&this.quadTriangleIndexBuffer.destroy(),this.tileExtentMesh&&(null===(e=this.tileExtentMesh.vertexBuffer)||void 0===e||e.destroy()),this.tileExtentMesh&&(null===(t=this.tileExtentMesh.indexBuffer)||void 0===t||t.destroy()),this.debugOverlayTexture&&this.debugOverlayTexture.destroy(),this.cache){for(const e in this.cache){const t=this.cache[e];t&&t.program&&this.context.gl.deleteProgram(t.program)}this.cache={}}this.context&&this.context.setDefault()}overLimit(){const{drawingBufferWidth:e,drawingBufferHeight:t}=this.context.gl;return this.width!==e||this.height!==t}}function Vr(e,t){let i,n=!1,r=null,o=null;const s=()=>{r=null,n&&(e.apply(o,i),r=setTimeout(s,t),n=!1)};return(...e)=>(n=!0,o=this,i=e,r||s(),r)}class jr{constructor(e){this._getCurrentHash=()=>{const e=window.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("/")},this._onHashChange=()=>{const e=this._getCurrentHash();if(!this._isValidHash(e))return!1;const t=this._map.dragRotate.isEnabled()&&this._map.touchZoomRotate.isEnabled()?+(e[3]||0):this._map.getBearing();return this._map.jumpTo({center:[+e[2],+e[1]],zoom:+e[0],bearing:t,pitch:+(e[4]||0)}),!0},this._updateHashUnthrottled=()=>{const e=window.location.href.replace(/(#.*)?$/,this.getHashString());window.history.replaceState(window.history.state,null,e)},this._removeHash=()=>{const e=this._getCurrentHash();if(0===e.length)return;const t=e.join("/");let i=t;i.split("&").length>0&&(i=i.split("&")[0]),this._hashName&&(i=`${this._hashName}=${t}`);let n=window.location.hash.replace(i,"");n.startsWith("#&")?n=n.slice(0,1)+n.slice(2):"#"===n&&(n="");let r=window.location.href.replace(/(#.+)?$/,n);r=r.replace("&&","&"),window.history.replaceState(window.history.state,null,r)},this._updateHash=Vr(this._updateHashUnthrottled,300),this._hashName=e&&encodeURIComponent(e)}addTo(e){return this._map=e,addEventListener("hashchange",this._onHashChange,!1),this._map.on("moveend",this._updateHash),this}remove(){return removeEventListener("hashchange",this._onHashChange,!1),this._map.off("moveend",this._updateHash),clearTimeout(this._updateHash()),this._removeHash(),delete this._map,this}getHashString(e){const t=this._map.getCenter(),i=Math.round(100*this._map.getZoom())/100,n=Math.ceil((i*Math.LN2+Math.log(512/360/.5))/Math.LN10),r=Math.pow(10,n),o=Math.round(t.lng*r)/r,s=Math.round(t.lat*r)/r,a=this._map.getBearing(),l=this._map.getPitch();let c="";if(c+=e?`/${o}/${s}/${i}`:`${i}/${s}/${o}`,(a||l)&&(c+="/"+Math.round(10*a)/10),l&&(c+=`/${Math.round(l)}`),this._hashName){const e=this._hashName;let t=!1;const i=window.location.hash.slice(1).split("&").map(i=>{const n=i.split("=")[0];return n===e?(t=!0,`${n}=${c}`):i}).filter(e=>e);return t||i.push(`${e}=${c}`),`#${i.join("&")}`}return`#${c}`}_isValidHash(e){if(e.length<3||e.some(isNaN))return!1;try{new t.V(+e[2],+e[1])}catch(e){return!1}const i=+e[0],n=+(e[3]||0),r=+(e[4]||0);return i>=this._map.getMinZoom()&&i<=this._map.getMaxZoom()&&n>=-180&&n<=180&&r>=this._map.getMinPitch()&&r<=this._map.getMaxPitch()}}const Gr={linearity:.3,easing:t.cv(0,0,.3,1)},Hr=t.e({deceleration:2500,maxSpeed:1400},Gr),Qr=t.e({deceleration:20,maxSpeed:1400},Gr),$r=t.e({deceleration:1e3,maxSpeed:360},Gr),Zr=t.e({deceleration:1e3,maxSpeed:90},Gr),Wr=t.e({deceleration:1e3,maxSpeed:360},Gr);class qr{constructor(e){this._map=e,this.clear()}clear(){this._inertiaBuffer=[]}record(e){this._drainInertiaBuffer(),this._inertiaBuffer.push({time:c(),settings:e})}_drainInertiaBuffer(){const e=this._inertiaBuffer,t=c();for(;e.length>0&&t-e[0].time>160;)e.shift()}_onMoveEnd(e){if(this._drainInertiaBuffer(),this._inertiaBuffer.length<2)return;const i={zoom:0,bearing:0,pitch:0,roll:0,pan:new t.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,i.roll+=e.rollDelta||0,e.panDelta&&i.pan._add(e.panDelta),e.around&&(i.around=e.around),e.pinchAround&&(i.pinchAround=e.pinchAround);const n=this._inertiaBuffer[this._inertiaBuffer.length-1].time-this._inertiaBuffer[0].time,r={};if(i.pan.mag()){const o=Xr(i.pan.mag(),n,t.e({},Hr,e||{})),s=i.pan.mult(o.amount/i.pan.mag()),a=this._map.cameraHelper.handlePanInertia(s,this._map.transform);r.center=a.easingCenter,r.offset=a.easingOffset,Kr(r,o)}if(i.zoom){const e=Xr(i.zoom,n,Qr);r.zoom=this._map.transform.zoom+e.amount,Kr(r,e)}if(i.bearing){const e=Xr(i.bearing,n,$r);r.bearing=this._map.transform.bearing+t.an(e.amount,-179,179),Kr(r,e)}if(i.pitch){const e=Xr(i.pitch,n,Zr);r.pitch=this._map.transform.pitch+e.amount,Kr(r,e)}if(i.roll){const e=Xr(i.roll,n,Wr);r.roll=this._map.transform.roll+t.an(e.amount,-179,179),Kr(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(),t.e(r,{noMoveStart:!0})}}function Kr(e,t){(!e.duration||e.durationi.unproject(e)),a=o.reduce((e,t,i,n)=>e.add(t.div(n.length)),new t.P(0,0));super(e,{points:o,point:a,lngLats:s,lngLat:i.unproject(a),originalEvent:n}),this._defaultPrevented=!1}}class eo extends t.l{preventDefault(){this._defaultPrevented=!0}get defaultPrevented(){return this._defaultPrevented}constructor(e,t,i){super(e,{originalEvent:i}),this._defaultPrevented=!1}}class to{constructor(e,t){this._map=e,this._clickTolerance=t.clickTolerance}reset(){delete this._mousedownPos}wheel(e){return this._firePreventable(new eo(e.type,this._map,e))}mousedown(e,t){return this._mousedownPos=t,this._firePreventable(new Jr(e.type,this._map,e))}mouseup(e){this._map.fire(new Jr(e.type,this._map,e))}click(e,t){this._mousedownPos&&this._mousedownPos.dist(t)>=this._clickTolerance||this._map.fire(new Jr(e.type,this._map,e))}dblclick(e){return this._firePreventable(new Jr(e.type,this._map,e))}mouseover(e){this._map.fire(new Jr(e.type,this._map,e))}mouseout(e){this._map.fire(new Jr(e.type,this._map,e))}touchstart(e){return this._firePreventable(new Yr(e.type,this._map,e))}touchmove(e){this._map.fire(new Yr(e.type,this._map,e))}touchend(e){this._map.fire(new Yr(e.type,this._map,e))}touchcancel(e){this._map.fire(new Yr(e.type,this._map,e))}_firePreventable(e){if(this._map.fire(e),e.defaultPrevented)return{}}isEnabled(){return!0}isActive(){return!1}enable(){}disable(){}}class io{constructor(e){this._map=e}reset(){this._delayContextMenu=!1,this._ignoreContextMenu=!0,delete this._contextMenuEvent}mousemove(e){this._map.fire(new Jr(e.type,this._map,e))}mousedown(){this._delayContextMenu=!0,this._ignoreContextMenu=!1}mouseup(){this._delayContextMenu=!1,this._contextMenuEvent&&(this._map.fire(new Jr("contextmenu",this._map,this._contextMenuEvent)),delete this._contextMenuEvent)}contextmenu(e){this._delayContextMenu?this._contextMenuEvent=e:this._ignoreContextMenu||this._map.fire(new Jr(e.type,this._map,e)),this._map.listens("contextmenu")&&e.preventDefault()}isEnabled(){return!0}isActive(){return!1}enable(){}disable(){}}class no{constructor(e){this._map=e}get transform(){return this._map._requestedCameraState||this._map.transform}get center(){return{lng:this.transform.center.lng,lat:this.transform.center.lat}}get zoom(){return this.transform.zoom}get pitch(){return this.transform.pitch}get bearing(){return this.transform.bearing}unproject(e){return this.transform.screenPointToLocation(t.P.convert(e),this._map.terrain)}}class ro{constructor(e,t){this._map=e,this._tr=new no(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.disableDrag(),this._startPos=this._lastPos=t,this._active=!0)}mousemoveWindow(e,t){if(!this._active)return;const i=t;if(this._lastPos.equals(i)||!this._box&&i.dist(this._startPos)e.fitScreenCoordinates(n,r,this._tr.bearing,{linear:!0})};this._fireEvent("boxzoomcancel",e)}keydown(e){this._active&&27===e.keyCode&&(this.reset(),this._fireEvent("boxzoomcancel",e))}reset(){this._active=!1,this._container.classList.remove("maplibregl-crosshair"),this._box&&(u.remove(this._box),this._box=null),u.enableDrag(),delete this._startPos,delete this._lastPos}_fireEvent(e,i){return this._map.fire(new t.l(e,{originalEvent:i}))}}function oo(e,t){if(e.length!==t.length)throw new Error(`The number of touches and points are not equal - touches ${e.length}, points ${t.length}`);const i={};for(let n=0;nthis.numTouches)&&(this.aborted=!0),this.aborted||(void 0===this.startTime&&(this.startTime=e.timeStamp),n.length===this.numTouches&&(this.centroid=function(e){const i=new t.P(0,0);for(const t of e)i._add(t);return i.div(e.length)}(i),this.touches=oo(n,i)))}touchmove(e,t,i){if(this.aborted||!this.centroid)return;const n=oo(i,t);for(const e in this.touches){const t=n[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 ao{constructor(e){this.singleTap=new so(e),this.numTaps=e.numTaps,this.reset()}reset(){this.lastTime=1/0,delete this.lastTap,this.count=0,this.singleTap.reset()}touchstart(e,t,i){this.singleTap.touchstart(e,t,i)}touchmove(e,t,i){this.singleTap.touchmove(e,t,i)}touchend(e,t,i){const n=this.singleTap.touchend(e,t,i);if(n){const t=e.timeStamp-this.lastTime<500,i=!this.lastTap||this.lastTap.dist(n)<30;if(t&&i||this.reset(),this.count++,this.lastTime=e.timeStamp,this.lastTap=n,this.count===this.numTaps)return this.reset(),n}}}class lo{constructor(e){this._tr=new no(e),this._zoomIn=new ao({numTouches:1,numTaps:2}),this._zoomOut=new ao({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 n=this._zoomIn.touchend(e,t,i),r=this._zoomOut.touchend(e,t,i),o=this._tr;return n?(this._active=!0,e.preventDefault(),setTimeout(()=>this.reset(),0),{cameraAnimation:t=>t.easeTo({duration:300,zoom:o.zoom+1,around:o.unproject(n)},{originalEvent:e})}):r?(this._active=!0,e.preventDefault(),setTimeout(()=>this.reset(),0),{cameraAnimation:t=>t.easeTo({duration:300,zoom:o.zoom-1,around:o.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}}class co{constructor(e){this._enabled=!!e.enable,this._moveStateManager=e.moveStateManager,this._clickTolerance=e.clickTolerance||1,this._moveFunction=e.move,this._activateOnStart=!!e.activateOnStart,e.assignEvents(this),this.reset()}reset(e){this._active=!1,this._moved=!1,delete this._lastPoint,this._moveStateManager.endMove(e)}_move(...e){const t=this._moveFunction(...e);if(t.bearingDelta||t.pitchDelta||t.rollDelta||t.around||t.panDelta)return this._active=!0,t}dragStart(e,t){this.isEnabled()&&!this._lastPoint&&this._moveStateManager.isValidStartEvent(e)&&(this._moveStateManager.startMove(e),this._lastPoint=Array.isArray(t)?t[0]:t,this._activateOnStart&&this._lastPoint&&(this._active=!0))}dragMove(e,t){if(!this.isEnabled())return;const i=this._lastPoint;if(!i)return;if(e.preventDefault(),!this._moveStateManager.isValidMoveEvent(e))return void this.reset(e);const n=Array.isArray(t)?t[0]:t;return!this._moved&&n.dist(i)!0}),t=new mo){this.mouseMoveStateManager=e,this.oneFingerTouchMoveStateManager=t}_executeRelevantHandler(e,t,i){return e instanceof MouseEvent?t(e):"undefined"!=typeof TouchEvent&&e instanceof TouchEvent?i(e):void 0}startMove(e){this._executeRelevantHandler(e,e=>this.mouseMoveStateManager.startMove(e),e=>this.oneFingerTouchMoveStateManager.startMove(e))}endMove(e){this._executeRelevantHandler(e,e=>this.mouseMoveStateManager.endMove(e),e=>this.oneFingerTouchMoveStateManager.endMove(e))}isValidStartEvent(e){return this._executeRelevantHandler(e,e=>this.mouseMoveStateManager.isValidStartEvent(e),e=>this.oneFingerTouchMoveStateManager.isValidStartEvent(e))}isValidMoveEvent(e){return this._executeRelevantHandler(e,e=>this.mouseMoveStateManager.isValidMoveEvent(e),e=>this.oneFingerTouchMoveStateManager.isValidMoveEvent(e))}isValidEndEvent(e){return this._executeRelevantHandler(e,e=>this.mouseMoveStateManager.isValidEndEvent(e),e=>this.oneFingerTouchMoveStateManager.isValidEndEvent(e))}}const _o=e=>{e.mousedown=e.dragStart,e.mousemoveWindow=e.dragMove,e.mouseup=e.dragEnd,e.contextmenu=e=>{e.preventDefault()}};class Ao{constructor(e,t){this._clickTolerance=e.clickTolerance||1,this._map=t,this.reset()}reset(){this._active=!1,this._touches={},this._sum=new t.P(0,0)}_shouldBePrevented(e){return e<(this._map.cooperativeGestures.isEnabled()?2:1)}touchstart(e,t,i){return this._calculateTransform(e,t,i)}touchmove(e,t,i){if(this._active){if(!this._shouldBePrevented(i.length))return e.preventDefault(),this._calculateTransform(e,t,i);this._map.cooperativeGestures.notifyGestureBlocked("touch_pan",e)}}touchend(e,t,i){this._calculateTransform(e,t,i),this._active&&this._shouldBePrevented(i.length)&&this.reset()}touchcancel(){this.reset()}_calculateTransform(e,i,n){n.length>0&&(this._active=!0);const r=oo(n,i),o=new t.P(0,0),s=new t.P(0,0);let a=0;for(const e in r){const t=r[e],i=this._touches[e];i&&(o._add(t),s._add(t.sub(i)),a++,r[e]=t)}if(this._touches=r,this._shouldBePrevented(a)||!s.mag())return;const l=s.div(a);return this._sum._add(l),this._sum.mag()Math.abs(e.x)}class Co extends yo{constructor(e){super(),this._currentTouchCount=0,this._map=e}reset(){super.reset(),this._valid=void 0,delete this._firstMove,delete this._lastPoints}touchstart(e,t,i){super.touchstart(e,t,i),this._currentTouchCount=i.length}_start(e){this._lastPoints=e,Eo(e[0].sub(e[1]))&&(this._valid=!1)}_move(e,t,i){if(this._map.cooperativeGestures.isEnabled()&&this._currentTouchCount<3)return;const n=e[0].sub(this._lastPoints[0]),r=e[1].sub(this._lastPoints[1]);return this._valid=this.gestureBeginsVertically(n,r,i.timeStamp),this._valid?(this._lastPoints=e,this._active=!0,{pitchDelta:(n.y+r.y)/2*-.5}):void 0}gestureBeginsVertically(e,t,i){if(void 0!==this._valid)return this._valid;const n=e.mag()>=2,r=t.mag()>=2;if(!n&&!r)return;if(!n||!r)return void 0===this._firstMove&&(this._firstMove=i),i-this._firstMove<100&&void 0;const o=e.y>0==t.y>0;return Eo(e)&&Eo(t)&&o}}const So={panStep:100,bearingStep:15,pitchStep:10};class Bo{constructor(e){this._tr=new no(e);const t=So;this._panStep=t.panStep,this._bearingStep=t.bearingStep,this._pitchStep=t.pitchStep,this._rotationDisabled=!1}reset(){this._active=!1}keydown(e){if(e.altKey||e.ctrlKey||e.metaKey)return;let t=0,i=0,n=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?n=1:(e.preventDefault(),o=-1);break;case 40:e.shiftKey?n=-1:(e.preventDefault(),o=1);break;default:return}return this._rotationDisabled&&(i=0,n=0),{cameraAnimation:s=>{const a=this._tr;s.easeTo({duration:300,easeId:"keyboardHandler",easing:Io,zoom:t?Math.round(a.zoom)+t*(e.shiftKey?2:1):a.zoom,bearing:a.bearing+i*this._bearingStep,pitch:a.pitch+n*this._pitchStep,offset:[-r*this._panStep,-o*this._panStep],center:a.center},{originalEvent:e})}}}enable(){this._enabled=!0}disable(){this._enabled=!1,this.reset()}isEnabled(){return this._enabled}isActive(){return this._active}disableRotation(){this._rotationDisabled=!0}enableRotation(){this._rotationDisabled=!1}}function Io(e){return e*(2-e)}const Mo=4.000244140625,Po=1/450;class Ro{constructor(e,t){this._onTimeout=e=>{this._type="wheel",this._delta-=this._lastValue,this._active||this._start(e)},this._map=e,this._tr=new no(e),this._triggerRenderFrame=t,this._delta=0,this._defaultZoomRate=.01,this._wheelZoomRate=Po}setZoomRate(e){this._defaultZoomRate=e}setWheelZoomRate(e){this._wheelZoomRate=e}isEnabled(){return!!this._enabled}isActive(){return!!this._active||void 0!==this._finishTimeout}isZooming(){return!!this._zooming}enable(e){this.isEnabled()||(this._enabled=!0,this._aroundCenter=!!e&&"center"===e.around)}disable(){this.isEnabled()&&(this._enabled=!1)}_shouldBePrevented(e){return!!this._map.cooperativeGestures.isEnabled()&&!(e.ctrlKey||this._map.cooperativeGestures.isBypassed(e))}wheel(e){if(!this.isEnabled())return;if(this._shouldBePrevented(e))return void this._map.cooperativeGestures.notifyGestureBlocked("wheel_zoom",e);let t=e.deltaMode===WheelEvent.DOM_DELTA_LINE?40*e.deltaY:e.deltaY;const i=c(),n=i-(this._lastWheelEventTime||0);this._lastWheelEventTime=i,0!==t&&t%Mo==0?this._type="wheel":0!==t&&Math.abs(t)<4?this._type="trackpad":n>400?(this._type=null,this._lastValue=t,this._timeout=setTimeout(this._onTimeout,40,e)):this._type||(this._type=Math.abs(n*t)<200?"trackpad":"wheel",this._timeout&&(clearTimeout(this._timeout),this._timeout=null,t+=this._lastValue)),e.shiftKey&&t&&(t/=4),this._type&&(this._lastWheelEvent=e,this._delta-=t,this._active||this._start(e)),e.preventDefault()}_start(e){if(!this._delta)return;this._frameId&&(this._frameId=null),this._active=!0,this.isZooming()||(this._zooming=!0),this._finishTimeout&&(clearTimeout(this._finishTimeout),delete this._finishTimeout);const i=u.mousePos(this._map.getCanvas(),e),n=this._tr;this._aroundPoint=this._aroundCenter?n.transform.locationToScreenPoint(t.V.convert(n.center)):i,this._frameId||(this._frameId=!0,this._triggerRenderFrame())}renderFrame(){if(!this._frameId)return;if(this._frameId=null,!this.isActive())return;const e=this._tr.transform;if("number"==typeof this._lastExpectedZoom){const t=e.zoom-this._lastExpectedZoom;"number"==typeof this._startZoom&&(this._startZoom+=t),"number"==typeof this._targetZoom&&(this._targetZoom+=t)}if(0!==this._delta){const i="wheel"===this._type&&Math.abs(this._delta)>Mo?this._wheelZoomRate:this._defaultZoomRate;let n=2/(1+Math.exp(-Math.abs(this._delta*i)));this._delta<0&&0!==n&&(n=1/n);const r="number"!=typeof this._targetZoom?e.scale:t.aq(this._targetZoom);this._targetZoom=e.applyConstrain(e.getCameraLngLat(),t.at(r*n)).zoom,"wheel"===this._type&&(this._startZoom=e.zoom,this._easing=this._smoothOutEasing(200)),this._delta=0}const i="number"!=typeof this._targetZoom?e.zoom:this._targetZoom,n=this._startZoom,r=this._easing;let o,s=!1;if("wheel"===this._type&&n&&r){const e=c()-this._lastWheelEventTime,a=Math.min((e+5)/200,1),l=r(a);o=t.G.number(n,i,l),a<1?this._frameId||(this._frameId=!0):s=!0}else o=i,s=!0;return this._active=!0,s&&(this._active=!1,this._finishTimeout=setTimeout(()=>{this._zooming=!1,this._triggerRenderFrame(),delete this._targetZoom,delete this._lastExpectedZoom,delete this._finishTimeout},200)),this._lastExpectedZoom=o,{noInertia:!0,needsRenderFrame:!s,zoomDelta:o-e.zoom,around:this._aroundPoint,originalEvent:this._lastWheelEvent}}_smoothOutEasing(e){let i=t.cx;if(this._prevEase){const e=this._prevEase,n=(c()-e.start)/e.duration,r=e.easing(n+.01)-e.easing(n),o=.27/Math.sqrt(r*r+1e-4)*.01,s=Math.sqrt(.0729-o*o);i=t.cv(o,s,.25,1)}return this._prevEase={start:c(),duration:e,easing:i},i}reset(){this._active=!1,this._zooming=!1,delete this._targetZoom,delete this._lastExpectedZoom,this._finishTimeout&&(clearTimeout(this._finishTimeout),delete this._finishTimeout)}}class Lo{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 Fo{constructor(e){this._tr=new no(e),this.reset()}reset(){this._active=!1}dblclick(e,t){return e.preventDefault(),{cameraAnimation:i=>{i.easeTo({duration:300,zoom:this._tr.zoom+(e.shiftKey?-1:1),around:this._tr.unproject(t)},{originalEvent:e})}}}enable(){this._enabled=!0}disable(){this._enabled=!1,this.reset()}isEnabled(){return this._enabled}isActive(){return this._active}}class ko{constructor(){this._tap=new ao({numTouches:1,numTaps:1}),this.reset()}reset(){this._active=!1,delete this._swipePoint,delete this._swipeTouch,delete this._tapTime,delete this._tapPoint,this._tap.reset()}touchstart(e,t,i){if(!this._swipePoint)if(this._tapTime){const n=t[0],r=e.timeStamp-this._tapTime<500,o=this._tapPoint.dist(n)<30;r&&o?i.length>0&&(this._swipePoint=n,this._swipeTouch=i[0].identifier):this.reset()}else this._tap.touchstart(e,t,i)}touchmove(e,t,i){if(this._tapTime){if(this._swipePoint){if(i[0].identifier!==this._swipeTouch)return;const n=t[0],r=n.y-this._swipePoint.y;return this._swipePoint=n,e.preventDefault(),this._active=!0,{zoomDelta:r/128}}}else this._tap.touchmove(e,t,i)}touchend(e,t,i){if(this._tapTime)this._swipePoint&&0===i.length&&this.reset();else{const n=this._tap.touchend(e,t,i);n&&(this._tapTime=e.timeStamp,this._tapPoint=n)}}touchcancel(){this.reset()}enable(){this._enabled=!0}disable(){this._enabled=!1,this.reset()}isEnabled(){return this._enabled}isActive(){return this._active}}class Do{constructor(e,t,i){this._el=e,this._mousePan=t,this._touchPan=i}enable(e){this._inertiaOptions=e||{},this._mousePan.enable(),this._touchPan.enable(),this._el.classList.add("maplibregl-touch-drag-pan")}disable(){this._mousePan.disable(),this._touchPan.disable(),this._el.classList.remove("maplibregl-touch-drag-pan")}isEnabled(){return this._mousePan.isEnabled()&&this._touchPan.isEnabled()}isActive(){return this._mousePan.isActive()||this._touchPan.isActive()}}class Oo{constructor(e,t,i,n){this._pitchWithRotate=e.pitchWithRotate,this._rollEnabled=e.rollEnabled,this._mouseRotate=t,this._mousePitch=i,this._mouseRoll=n}enable(){this._mouseRotate.enable(),this._pitchWithRotate&&this._mousePitch.enable(),this._rollEnabled&&this._mouseRoll.enable()}disable(){this._mouseRotate.disable(),this._mousePitch.disable(),this._mouseRoll.disable()}isEnabled(){return this._mouseRotate.isEnabled()&&(!this._pitchWithRotate||this._mousePitch.isEnabled())&&(!this._rollEnabled||this._mouseRoll.isEnabled())}isActive(){return this._mouseRotate.isActive()||this._mousePitch.isActive()||this._mouseRoll.isActive()}}class zo{constructor(e,t,i,n){this._el=e,this._touchZoom=t,this._touchRotate=i,this._tapDragZoom=n,this._rotationDisabled=!1,this._enabled=!0}enable(e){this._touchZoom.enable(e),this._rotationDisabled||this._touchRotate.enable(e),this._tapDragZoom.enable(),this._el.classList.add("maplibregl-touch-zoom-rotate")}disable(){this._touchZoom.disable(),this._touchRotate.disable(),this._tapDragZoom.disable(),this._el.classList.remove("maplibregl-touch-zoom-rotate")}isEnabled(){return this._touchZoom.isEnabled()&&(this._rotationDisabled||this._touchRotate.isEnabled())&&this._tapDragZoom.isEnabled()}isActive(){return this._touchZoom.isActive()||this._touchRotate.isActive()||this._tapDragZoom.isActive()}disableRotation(){this._rotationDisabled=!0,this._touchRotate.disable()}enableRotation(){this._rotationDisabled=!1,this._touchZoom.isEnabled()&&this._touchRotate.enable()}}class Uo{constructor(e,t){this._bypassKey=-1!==navigator.userAgent.indexOf("Mac")?"metaKey":"ctrlKey",this._map=e,this._options=t,this._enabled=!1}isActive(){return!1}reset(){}_setupUI(){if(this._container)return;const e=this._map.getCanvasContainer();e.classList.add("maplibregl-cooperative-gestures"),this._container=u.create("div","maplibregl-cooperative-gesture-screen",e);let t=this._map._getUIString("CooperativeGesturesHandler.WindowsHelpText");"metaKey"===this._bypassKey&&(t=this._map._getUIString("CooperativeGesturesHandler.MacHelpText"));const i=this._map._getUIString("CooperativeGesturesHandler.MobileHelpText"),n=document.createElement("div");n.className="maplibregl-desktop-message",n.textContent=t,this._container.appendChild(n);const r=document.createElement("div");r.className="maplibregl-mobile-message",r.textContent=i,this._container.appendChild(r),this._container.setAttribute("aria-hidden","true")}_destroyUI(){this._container&&(u.remove(this._container),this._map.getCanvasContainer().classList.remove("maplibregl-cooperative-gestures")),delete this._container}enable(){this._setupUI(),this._enabled=!0}disable(){this._enabled=!1,this._destroyUI()}isEnabled(){return this._enabled}isBypassed(e){return e[this._bypassKey]}notifyGestureBlocked(e,i){this._enabled&&(this._map.fire(new t.l("cooperativegestureprevented",{gestureType:e,originalEvent:i})),this._container.classList.add("maplibregl-show"),setTimeout(()=>{this._container.classList.remove("maplibregl-show")},100))}}const No=e=>e.zoom||e.drag||e.roll||e.pitch||e.rotate;class Vo extends t.l{}function jo(e){return e.panDelta&&e.panDelta.mag()||e.zoomDelta||e.bearingDelta||e.pitchDelta||e.rollDelta}class Go{constructor(e,i){this.handleWindowEvent=e=>{this.handleEvent(e,`${e.type}Window`)},this.handleEvent=(e,i)=>{if("blur"===e.type)return void this.stop(!0);this._updatingCamera=!0;const n="renderFrame"===e.type?void 0:e,r={needsRenderFrame:!1},o={},s={};for(const{handlerName:a,handler:l,allowed:c}of this._handlers){if(!l.isEnabled())continue;let h;if(this._blockedByActive(s,c,a))l.reset();else if(l[i||e.type]){if(t.cy(e,i||e.type)){const t=u.mousePos(this._map.getCanvas(),e);h=l[i||e.type](e,t)}else if(t.cz(e,i||e.type)){const t=this._getMapTouches(e.touches),n=u.touchPos(this._map.getCanvas(),t);h=l[i||e.type](e,n,t)}else t.cA(i||e.type)||(h=l[i||e.type](e));this.mergeHandlerResult(r,o,h,a,n),h&&h.needsRenderFrame&&this._triggerRenderFrame()}(h||l.isActive())&&(s[a]=l)}const a={};for(const e in this._previousActiveHandlers)s[e]||(a[e]=n);this._previousActiveHandlers=s,(Object.keys(a).length||jo(r))&&(this._changes.push([r,o,a]),this._triggerRenderFrame()),(Object.keys(s).length||jo(r))&&this._map._stop(!0),this._updatingCamera=!1;const{cameraAnimation:l}=r;l&&(this._inertia.clear(),this._fireEvents({},{},!0),this._changes=[],l(this._map))},this._map=e,this._el=this._map.getCanvasContainer(),this._handlers=[],this._handlersById={},this._changes=[],this._inertia=new qr(e),this._bearingSnap=i.bearingSnap,this._previousActiveHandlers={},this._eventsInProgress={},this._addDefaultHandlers(i);const n=this._el;this._listeners=[[n,"touchstart",{passive:!0}],[n,"touchmove",{passive:!1}],[n,"touchend",void 0],[n,"touchcancel",void 0],[n,"mousedown",void 0],[n,"mousemove",void 0],[n,"mouseup",void 0],[document,"mousemove",{capture:!0}],[document,"mouseup",void 0],[n,"mouseover",void 0],[n,"mouseout",void 0],[n,"dblclick",void 0],[n,"click",void 0],[n,"keydown",{capture:!1}],[n,"keyup",void 0],[n,"wheel",{passive:!1}],[n,"contextmenu",void 0],[window,"blur",void 0]];for(const[e,t,i]of this._listeners)u.addEventListener(e,t,e===document?this.handleWindowEvent:this.handleEvent,i)}destroy(){for(const[e,t,i]of this._listeners)u.removeEventListener(e,t,e===document?this.handleWindowEvent:this.handleEvent,i)}_addDefaultHandlers(e){const i=this._map,n=i.getCanvasContainer();this._add("mapEvent",new to(i,e));const r=i.boxZoom=new ro(i,e);this._add("boxZoom",r),e.interactive&&e.boxZoom&&r.enable();const o=i.cooperativeGestures=new Uo(i,e.cooperativeGestures);this._add("cooperativeGestures",o),e.cooperativeGestures&&o.enable();const s=new lo(i),a=new Fo(i);i.doubleClickZoom=new Lo(a,s),this._add("tapZoom",s),this._add("clickZoom",a),e.interactive&&e.doubleClickZoom&&i.doubleClickZoom.enable();const l=new ko;this._add("tapDragZoom",l);const c=i.touchPitch=new Co(i);this._add("touchPitch",c),e.interactive&&e.touchPitch&&i.touchPitch.enable(e.touchPitch);const h=()=>i.project(i.getCenter()),d=function({enable:e,clickTolerance:i,aroundCenter:n=!0,minPixelCenterThreshold:r=100,rotateDegreesPerPixelMoved:o=.8},s){const a=new fo({checkCorrectEvent:e=>0===u.mouseButton(e)&&e.ctrlKey||2===u.mouseButton(e)&&!e.ctrlKey});return new co({clickTolerance:i,move:(e,i)=>{const a=s();if(n&&Math.abs(a.y-e.y)>r)return{bearingDelta:t.cw(new t.P(e.x,i.y),i,a)};let l=(i.x-e.x)*o;return n&&i.y0===u.mouseButton(e)&&e.ctrlKey||2===u.mouseButton(e)});return new co({clickTolerance:t,move:(e,t)=>({pitchDelta:(t.y-e.y)*i}),moveStateManager:n,enable:e,assignEvents:_o})}(e),f=function({enable:e,clickTolerance:t,rollDegreesPerPixelMoved:i=.3},n){const r=new fo({checkCorrectEvent:e=>2===u.mouseButton(e)&&e.ctrlKey});return new co({clickTolerance:t,move:(e,t)=>{const r=n();let o=(t.x-e.x)*i;return t.y0===u.mouseButton(e)&&!e.ctrlKey});return new co({clickTolerance:t,move:(e,t)=>({around:t,panDelta:t.sub(e)}),activateOnStart:!0,moveStateManager:i,enable:e,assignEvents:_o})}(e),g=new Ao(e,i);i.dragPan=new Do(n,m,g),this._add("mousePan",m),this._add("touchPan",g,["touchZoom","touchRotate"]),e.interactive&&e.dragPan&&i.dragPan.enable(e.dragPan);const _=new To,A=new bo;i.touchZoomRotate=new zo(n,A,_,l),this._add("touchRotate",_,["touchPan","touchZoom"]),this._add("touchZoom",A,["touchPan","touchRotate"]),e.interactive&&e.touchZoomRotate&&i.touchZoomRotate.enable(e.touchZoomRotate),this._add("blockableMapEvent",new io(i));const y=i.scrollZoom=new Ro(i,()=>this._triggerRenderFrame());this._add("scrollZoom",y,["mousePan"]),e.interactive&&e.scrollZoom&&i.scrollZoom.enable(e.scrollZoom);const v=i.keyboard=new Bo(i);this._add("keyboard",v),e.interactive&&e.keyboard&&i.keyboard.enable()}_add(e,t,i){this._handlers.push({handlerName:e,handler:t,allowed:i}),this._handlersById[e]=t}stop(e){if(!this._updatingCamera){for(const{handler:e}of this._handlers)e.reset();this._inertia.clear(),this._fireEvents({},{},e),this._changes=[]}}isActive(){for(const{handler:e}of this._handlers)if(e.isActive())return!0;return!1}isZooming(){return!!this._eventsInProgress.zoom||this._map.scrollZoom.isZooming()}isRotating(){return!!this._eventsInProgress.rotate}isMoving(){return Boolean(No(this._eventsInProgress))||this.isZooming()}_blockedByActive(e,t,i){for(const n in e)if(n!==i&&(!t||t.indexOf(n)<0))return!0;return!1}_getMapTouches(e){const t=[];for(const i of e)this._el.contains(i.target)&&t.push(i);return t}mergeHandlerResult(e,i,n,r,o){if(!n)return;t.e(e,n);const s={handlerName:r,originalEvent:n.originalEvent||o};void 0!==n.zoomDelta&&(i.zoom=s),void 0!==n.panDelta&&(i.drag=s),void 0!==n.rollDelta&&(i.roll=s),void 0!==n.pitchDelta&&(i.pitch=s),void 0!==n.bearingDelta&&(i.rotate=s)}_applyChanges(){const e={},i={},n={};for(const[r,o,s]of this._changes)r.panDelta&&(e.panDelta=(e.panDelta||new t.P(0,0))._add(r.panDelta)),r.zoomDelta&&(e.zoomDelta=(e.zoomDelta||0)+r.zoomDelta),r.bearingDelta&&(e.bearingDelta=(e.bearingDelta||0)+r.bearingDelta),r.pitchDelta&&(e.pitchDelta=(e.pitchDelta||0)+r.pitchDelta),r.rollDelta&&(e.rollDelta=(e.rollDelta||0)+r.rollDelta),void 0!==r.around&&(e.around=r.around),void 0!==r.pinchAround&&(e.pinchAround=r.pinchAround),r.noInertia&&(e.noInertia=r.noInertia),t.e(i,o),t.e(n,s);this._updateMapTransform(e,i,n),this._changes=[]}_updateMapTransform(e,t,i){const n=this._map,r=n._getTransformForUpdate(),o=n.terrain;if(!(jo(e)||o&&this._terrainMovement))return this._fireEvents(t,i,!0);n._stop(!0);let{panDelta:s,zoomDelta:a,bearingDelta:l,pitchDelta:c,rollDelta:u,around:h,pinchAround:d}=e;void 0!==d&&(h=d),h=h||n.transform.centerPoint,o&&!r.isPointOnMapSurface(h)&&(h=r.centerPoint);const p={panDelta:s,zoomDelta:a,rollDelta:u,pitchDelta:c,bearingDelta:l,around:h};this._map.cameraHelper.useGlobeControls&&!r.isPointOnMapSurface(h)&&(h=r.centerPoint);const f=h.distSqr(r.centerPoint)<.01?r.center:r.screenPointToLocation(s?h.sub(s):h);this._handleMapControls({terrain:o,tr:r,deltasForHelper:p,preZoomAroundLoc:f,combinedEventsInProgress:t,panDelta:s}),n._applyUpdatedTransform(r),this._map._update(),e.noInertia||this._inertia.record(e),this._fireEvents(t,i,!0)}_handleMapControls({terrain:e,tr:t,deltasForHelper:i,preZoomAroundLoc:n,combinedEventsInProgress:r,panDelta:o}){const s=this._map.cameraHelper;if(s.handleMapControlsRollPitchBearingZoom(i,t),e)return s.useGlobeControls?(this._terrainMovement||!r.drag&&!r.zoom||(this._terrainMovement=!0,this._map._elevationFreeze=!0),void s.handleMapControlsPan(i,t,n)):this._terrainMovement||!r.drag&&!r.zoom?void(r.drag&&this._terrainMovement&&o?t.setCenter(t.screenPointToLocation(t.centerPoint.sub(o))):s.handleMapControlsPan(i,t,n)):(this._terrainMovement=!0,this._map._elevationFreeze=!0,void s.handleMapControlsPan(i,t,n));s.handleMapControlsPan(i,t,n)}_fireEvents(e,i,n){const r=No(this._eventsInProgress),o=No(e),s={};for(const t in e){const{originalEvent:i}=e[t];this._eventsInProgress[t]||(s[`${t}start`]=i),this._eventsInProgress[t]=e[t]}!r&&o&&this._fireEvent("movestart",o.originalEvent);for(const e in s)this._fireEvent(e,s[e]);o&&this._fireEvent("move",o.originalEvent);for(const t in e){const{originalEvent:i}=e[t];this._fireEvent(t,i)}const l={};let c;for(const e in this._eventsInProgress){const{handlerName:t,originalEvent:n}=this._eventsInProgress[e];this._handlersById[t].isActive()||(delete this._eventsInProgress[e],c=i[t]||n,l[`${e}end`]=c)}for(const e in l)this._fireEvent(e,l[e]);const u=No(this._eventsInProgress),h=(r||o)&&!u;if(h&&this._terrainMovement){this._map._elevationFreeze=!1,this._terrainMovement=!1;const e=this._map._getTransformForUpdate();this._map.getCenterClampedToGround()&&e.recalculateZoomAndCenter(this._map.terrain),this._map._applyUpdatedTransform(e)}if(n&&h){this._updatingCamera=!0;const e=this._inertia._onMoveEnd(this._map.dragPan._inertiaOptions),i=e=>0!==e&&-this._bearingSnap{delete this._frameId,this.handleEvent(new Vo("renderFrame",{timeStamp:e})),this._applyChanges()})}_triggerRenderFrame(){void 0===this._frameId&&(this._frameId=this._requestFrame())}}class Ho extends t.E{constructor(e,t,i){super(),this._renderFrameCallback=()=>{const e=Math.min((c()-this._easeStart)/this._easeOptions.duration,1);this._onEaseFrame(this._easeOptions.easing(e)),e<1&&this._easeFrameId?this._easeFrameId=this._requestRenderFrame(this._renderFrameCallback):this.stop()},this._moving=!1,this._zooming=!1,this.transform=e,this._bearingSnap=i.bearingSnap,this.cameraHelper=t,this.on("moveend",()=>{delete this._requestedCameraState})}migrateProjection(e,t){e.apply(this.transform),this.transform=e,this.cameraHelper=t}getCenter(){return new t.V(this.transform.center.lng,this.transform.center.lat)}setCenter(e,t){return this.jumpTo({center:e},t)}getCenterElevation(){return this.transform.elevation}setCenterElevation(e,t){return this.jumpTo({elevation:e},t),this}getCenterClampedToGround(){return this._centerClampedToGround}setCenterClampedToGround(e){this._centerClampedToGround=e}panBy(e,i,n){return e=t.P.convert(e).mult(-1),this.panTo(this.transform.center,t.e({offset:e},i),n)}panTo(e,i,n){return this.easeTo(t.e({center:e},i),n)}getZoom(){return this.transform.zoom}setZoom(e,t){return this.jumpTo({zoom:e},t),this}zoomTo(e,i,n){return this.easeTo(t.e({zoom:e},i),n)}zoomIn(e,t){return this.zoomTo(this.getZoom()+1,e,t),this}zoomOut(e,t){return this.zoomTo(this.getZoom()-1,e,t),this}getVerticalFieldOfView(){return this.transform.fov}setVerticalFieldOfView(e,i){return e!=this.transform.fov&&(this.transform.setFov(e),this.fire(new t.l("movestart",i)).fire(new t.l("move",i)).fire(new t.l("moveend",i))),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,i,n){return this.easeTo(t.e({bearing:e},i),n)}resetNorth(e,i){return this.rotateTo(0,t.e({duration:1e3},e),i),this}resetNorthPitch(e,i){return this.easeTo(t.e({bearing:0,pitch:0,roll:0,duration:1e3},e),i),this}snapToNorth(e,t){return Math.abs(this.getBearing()){g.easeFunc(t),this.terrain&&!e.freezeElevation&&this._updateElevation(t),this._applyUpdatedTransform(n),this._fireMoveEvents(i)},t=>{this.terrain&&e.freezeElevation&&this._finalizeElevation(),this._afterEase(i,t)},e),this}_prepareEase(e,i,n={}){this._moving=!0,i||n.moving||this.fire(new t.l("movestart",e)),this._zooming&&!n.zooming&&this.fire(new t.l("zoomstart",e)),this._rotating&&!n.rotating&&this.fire(new t.l("rotatestart",e)),this._pitching&&!n.pitching&&this.fire(new t.l("pitchstart",e)),this._rolling&&!n.rolling&&this.fire(new t.l("rollstart",e))}_prepareElevation(e){this._elevationCenter=e,this._elevationStart=this.transform.elevation,this._elevationTarget=this.terrain.getElevationForLngLatZoom(e,this.transform.tileZoom),this._elevationFreeze=!0}_updateElevation(e){void 0!==this._elevationStart&&void 0!==this._elevationCenter||this._prepareElevation(this.transform.center),this.transform.setMinElevationForCurrentTile(this.terrain.getMinTileElevationForLngLatZoom(this._elevationCenter,this.transform.tileZoom));const i=this.terrain.getElevationForLngLatZoom(this._elevationCenter,this.transform.tileZoom);if(e<1&&i!==this._elevationTarget){const t=this._elevationTarget-this._elevationStart;this._elevationStart+=e*(t-(i-(t*e+this._elevationStart))/(1-e)),this._elevationTarget=i}this.transform.setElevation(t.G.number(this._elevationStart,this._elevationTarget,e))}_finalizeElevation(){this._elevationFreeze=!1,this.getCenterClampedToGround()&&this.transform.recalculateZoomAndCenter(this.terrain)}_getTransformForUpdate(){return this.transformCameraUpdate||this.terrain?(this._requestedCameraState||(this._requestedCameraState=this.transform.clone()),this._requestedCameraState):this.transform}_elevateCameraIfInsideTerrain(e){if(!this.terrain&&e.elevation>=0&&e.pitch<=90)return{};const t=e.getCameraLngLat(),i=e.getCameraAltitude(),n=this.terrain?this.terrain.getElevationForLngLatZoom(t,e.zoom):0;if(ithis._elevateCameraIfInsideTerrain(e)),this.transformCameraUpdate&&t.push(e=>this.transformCameraUpdate(e)),!t.length)return;const i=e.clone();for(const e of t){const t=i.clone(),{center:n,zoom:r,roll:o,pitch:s,bearing:a,elevation:l}=e(t);n&&t.setCenter(n),void 0!==l&&t.setElevation(l),void 0!==r&&t.setZoom(r),void 0!==o&&t.setRoll(o),void 0!==s&&t.setPitch(s),void 0!==a&&t.setBearing(a),i.apply(t)}this.transform.apply(i)}_fireMoveEvents(e){this.fire(new t.l("move",e)),this._zooming&&this.fire(new t.l("zoom",e)),this._rotating&&this.fire(new t.l("rotate",e)),this._pitching&&this.fire(new t.l("pitch",e)),this._rolling&&this.fire(new t.l("roll",e))}_afterEase(e,i){if(this._easeId&&i&&this._easeId===i)return;delete this._easeId;const n=this._zooming,r=this._rotating,o=this._pitching,s=this._rolling;this._moving=!1,this._zooming=!1,this._rotating=!1,this._pitching=!1,this._rolling=!1,this._padding=!1,n&&this.fire(new t.l("zoomend",e)),r&&this.fire(new t.l("rotateend",e)),o&&this.fire(new t.l("pitchend",e)),s&&this.fire(new t.l("rollend",e)),this.fire(new t.l("moveend",e))}flyTo(e,i){if(!e.essential&&a.prefersReducedMotion){const n=t.U(e,["center","zoom","bearing","pitch","roll","elevation","padding"]);return this.jumpTo(n,i)}this.stop(),e=t.e({offset:[0,0],speed:1.2,curve:1.42,easing:t.cx},e);const n=this._getTransformForUpdate(),r=n.bearing,o=n.pitch,s=n.roll,l=n.padding,c="bearing"in e?this._normalizeBearing(e.bearing,r):r,u="pitch"in e?+e.pitch:o,h="roll"in e?this._normalizeBearing(e.roll,s):s,d="padding"in e?e.padding:n.padding,p=t.P.convert(e.offset);let f=n.centerPoint.add(p);const m=n.screenPointToLocation(f),g=this.cameraHelper.handleFlyTo(n,{bearing:c,pitch:u,roll:h,padding:d,locationAtOffset:m,offsetAsPoint:p,center:e.center,minZoom:e.minZoom,zoom:e.zoom});let _=e.curve;const A=Math.max(n.width,n.height),y=A/g.scaleOfZoom,v=g.pixelPathLength;"number"==typeof g.scaleOfMinZoom&&(_=Math.sqrt(A/g.scaleOfMinZoom/v*2));const x=_*_;function b(e){const t=(y*y-A*A+(e?-1:1)*x*x*v*v)/(2*(e?y:A)*x*v);return Math.log(Math.sqrt(t*t+1)-t)}function w(e){return(Math.exp(e)-Math.exp(-e))/2}function T(e){return(Math.exp(e)+Math.exp(-e))/2}const E=b(!1);let C=function(e){return T(E)/T(E+_*e)},S=function(e){return A*((T(E)*(w(t=E+_*e)/T(t))-w(E))/x)/v;var t},B=(b(!0)-E)/_;if(Math.abs(v)<2e-6||!isFinite(B)){if(Math.abs(A-y)<1e-6)return this.easeTo(e,i);const t=y0,C=e=>Math.exp(t*_*e)}return e.duration="duration"in e?+e.duration:1e3*B/("screenSpeed"in e?+e.screenSpeed/_:+e.speed),e.maxDuration&&e.duration>e.maxDuration&&(e.duration=0),this._zooming=!0,this._rotating=r!==c,this._pitching=u!==o,this._rolling=h!==s,this._padding=!n.isPaddingEqual(d),this._prepareEase(i,!1),this.terrain&&this._prepareElevation(g.targetCenter),this._ease(a=>{const m=a*B,_=1/C(m),A=S(m);this._rotating&&n.setBearing(t.G.number(r,c,a)),this._pitching&&n.setPitch(t.G.number(o,u,a)),this._rolling&&n.setRoll(t.G.number(s,h,a)),this._padding&&(n.interpolatePadding(l,d,a),f=n.centerPoint.add(p)),g.easeFunc(a,_,A,f),this.terrain&&!e.freezeElevation&&this._updateElevation(a),this._applyUpdatedTransform(n),this._fireMoveEvents(i)},()=>{this.terrain&&e.freezeElevation&&this._finalizeElevation(),this._afterEase(i)},e),this}isEasing(){return!!this._easeFrameId}stop(){return this._stop()}_stop(e,t){var i;if(this._easeFrameId&&(this._cancelRenderFrame(this._easeFrameId),delete this._easeFrameId,delete this._onEaseFrame),this._onEaseEnd){const e=this._onEaseEnd;delete this._onEaseEnd,e.call(this,t)}return e||null===(i=this.handlers)||void 0===i||i.stop(!1),this}_ease(e,t,i){!1===i.animate||0===i.duration?(e(1),t()):(this._easeStart=c(),this._easeOptions=i,this._onEaseFrame=e,this._onEaseEnd=t,this._easeFrameId=this._requestRenderFrame(this._renderFrameCallback))}_normalizeBearing(e,i){e=t.W(e,-180,180);const n=Math.abs(e-i);return Math.abs(e-360-i)MapLibre'};class $o{constructor(e=Qo){this._toggleAttribution=()=>{this._container.classList.contains("maplibregl-compact")&&(this._container.classList.contains("maplibregl-compact-show")?(this._container.setAttribute("open",""),this._container.classList.remove("maplibregl-compact-show")):(this._container.classList.add("maplibregl-compact-show"),this._container.removeAttribute("open")))},this._updateData=e=>{!e||"metadata"!==e.sourceDataType&&"visibility"!==e.sourceDataType&&"style"!==e.dataType&&"terrain"!==e.type||this._updateAttributions()},this._updateCompact=()=>{this._map.getCanvasContainer().offsetWidth<=640||this._compact?!1===this._compact?this._container.setAttribute("open",""):this._container.classList.contains("maplibregl-compact")||this._container.classList.contains("maplibregl-attrib-empty")||(this._container.setAttribute("open",""),this._container.classList.add("maplibregl-compact","maplibregl-compact-show")):(this._container.setAttribute("open",""),this._container.classList.contains("maplibregl-compact")&&this._container.classList.remove("maplibregl-compact","maplibregl-compact-show"))},this._updateCompactMinimize=()=>{this._container.classList.contains("maplibregl-compact")&&this._container.classList.contains("maplibregl-compact-show")&&this._container.classList.remove("maplibregl-compact-show")},this.options=e}getDefaultPosition(){return"bottom-right"}onAdd(e){return this._map=e,this._compact=this.options.compact,this._container=u.create("details","maplibregl-ctrl maplibregl-ctrl-attrib"),this._compactButton=u.create("summary","maplibregl-ctrl-attrib-button",this._container),this._compactButton.addEventListener("click",this._toggleAttribution),this._setElementTitle(this._compactButton,"ToggleAttribution"),this._innerContainer=u.create("div","maplibregl-ctrl-attrib-inner",this._container),this._updateAttributions(),this._updateCompact(),this._map.on("styledata",this._updateData),this._map.on("sourcedata",this._updateData),this._map.on("terrain",this._updateData),this._map.on("resize",this._updateCompact),this._map.on("drag",this._updateCompactMinimize),this._container}onRemove(){u.remove(this._container),this._map.off("styledata",this._updateData),this._map.off("sourcedata",this._updateData),this._map.off("terrain",this._updateData),this._map.off("resize",this._updateCompact),this._map.off("drag",this._updateCompactMinimize),this._map=void 0,this._compact=void 0,this._attribHTML=void 0}_setElementTitle(e,t){const i=this._map._getUIString(`AttributionControl.${t}`);e.title=i,e.setAttribute("aria-label",i)}_updateAttributions(){if(!this._map.style)return;let e=[];if(this.options.customAttribution&&(Array.isArray(this.options.customAttribution)?e=e.concat(this.options.customAttribution.map(e=>"string"!=typeof e?"":e)):"string"==typeof this.options.customAttribution&&e.push(this.options.customAttribution)),this._map.style.stylesheet){const e=this._map.style.stylesheet;this.styleOwner=e.owner,this.styleId=e.id}const t=this._map.style.tileManagers;for(const i in t){const n=t[i];if(n.used||n.usedForTerrain){const t=n.getSource();t.attribution&&e.indexOf(t.attribution)<0&&e.push(t.attribution)}}e=e.filter(e=>String(e).trim()),e.sort((e,t)=>e.length-t.length),e=e.filter((t,i)=>{for(let n=i+1;n=0)return!1;return!0});const i=e.join(" | ");i!==this._attribHTML&&(this._attribHTML=i,e.length?(this._innerContainer.innerHTML=u.sanitize(i),this._container.classList.remove("maplibregl-attrib-empty")):this._container.classList.add("maplibregl-attrib-empty"),this._updateCompact(),this._editLink=null)}}class Zo{constructor(e={}){this._updateCompact=()=>{const e=this._container.children;if(e.length){const t=e[0];this._map.getCanvasContainer().offsetWidth<=640||this._compact?!1!==this._compact&&t.classList.add("maplibregl-compact"):t.classList.remove("maplibregl-compact")}},this.options=e}getDefaultPosition(){return"bottom-left"}onAdd(e){this._map=e,this._compact=this.options&&this.options.compact,this._container=u.create("div","maplibregl-ctrl");const t=u.create("a","maplibregl-ctrl-logo");return t.target="_blank",t.rel="noopener nofollow",t.href="https://maplibre.org/",t.setAttribute("aria-label",this._map._getUIString("LogoControl.Title")),t.setAttribute("rel","noopener nofollow"),this._container.appendChild(t),this._container.style.display="block",this._map.on("resize",this._updateCompact),this._updateCompact(),this._container}onRemove(){u.remove(this._container),this._map.off("resize",this._updateCompact),this._map=void 0,this._compact=void 0}}class Wo{constructor(){this._queue=[],this._id=0,this._cleared=!1,this._currentlyRunning=!1}add(e){const t=++this._id;return this._queue.push({callback:e,id:t,cancelled:!1}),t}remove(e){const t=this._currentlyRunning,i=t?this._queue.concat(t):this._queue;for(const t of i)if(t.id===e)return void(t.cancelled=!0)}run(e=0){if(this._currentlyRunning)throw new Error("Attempting to run(), but is already running.");const t=this._currentlyRunning=this._queue;this._queue=[];for(const i of t)if(!i.cancelled&&(i.callback(e),this._cleared))break;this._cleared=!1,this._currentlyRunning=!1}clear(){this._currentlyRunning&&(this._cleared=!0),this._queue=[]}}var qo=t.aT([{name:"a_pos3d",type:"Int16",components:3}]);class Ko extends t.E{constructor(e){super(),this._lastTilesetChange=c(),this.tileManager=e,this._tiles={},this._renderableTilesKeys=[],this._sourceTileCache={},this.minzoom=0,this.maxzoom=22,this.deltaZoom=1,this.tileSize=e._source.tileSize*2**this.deltaZoom,e.usedForTerrain=!0,e.tileSize=this.tileSize}destruct(){this.tileManager.usedForTerrain=!1,this.tileManager.tileSize=null}getSource(){return this.tileManager._source}update(e,i){this.tileManager.update(e,i),this._renderableTilesKeys=[];const n={};for(const r of Ee(e,{tileSize:this.tileSize,minzoom:this.minzoom,maxzoom:this.maxzoom,reparseOverscaled:!1,terrain:i,calculateTileZoom:this.tileManager._source.calculateTileZoom}))n[r.key]=!0,this._renderableTilesKeys.push(r.key),this._tiles[r.key]||(r.terrainRttPosMatrix32f=new Float64Array(16),t.c6(r.terrainRttPosMatrix32f,0,t.a4,t.a4,0,0,1),this._tiles[r.key]=new de(r,this.tileSize),this._lastTilesetChange=c());for(const e in this._tiles)n[e]||delete this._tiles[e]}freeRtt(e){for(const t in this._tiles){const i=this._tiles[t];(!e||i.tileID.equals(e)||i.tileID.isChildOf(e)||e.isChildOf(i.tileID))&&(i.rtt=[])}}getRenderableTiles(){return this._renderableTilesKeys.map(e=>this.getTileByID(e))}getTileByID(e){return this._tiles[e]}getTerrainCoords(e,t){return t?this._getTerrainCoordsForTileRanges(e,t):this._getTerrainCoordsForRegularTile(e)}_getTerrainCoordsForRegularTile(e){const i={};for(const n of this._renderableTilesKeys){const r=this._tiles[n].tileID,o=e.clone(),s=t.bj();if(r.canonical.equals(e.canonical))t.c6(s,0,t.a4,t.a4,0,0,1);else if(r.canonical.isChildOf(e.canonical)){const i=r.canonical.z-e.canonical.z,n=r.canonical.x-(r.canonical.x>>i<>i<>i;t.c6(s,0,a,a,0,0,1),t.O(s,s,[-n*a,-o*a,0])}else{if(!e.canonical.isChildOf(r.canonical))continue;{const i=e.canonical.z-r.canonical.z,n=e.canonical.x-(e.canonical.x>>i<>i<>i;t.c6(s,0,t.a4,t.a4,0,0,1),t.O(s,s,[n*a,o*a,0]),t.Q(s,s,[1/2**i,1/2**i,0])}}o.terrainRttPosMatrix32f=new Float32Array(s),i[n]=o}return i}_getTerrainCoordsForTileRanges(e,i){const n={};for(const r of this._renderableTilesKeys){const o=this._tiles[r].tileID;if(!this._isWithinTileRanges(o,i))continue;const s=e.clone(),a=t.bj();if(o.canonical.z===e.canonical.z){const i=e.canonical.x-o.canonical.x,n=e.canonical.y-o.canonical.y;t.c6(a,0,t.a4,t.a4,0,0,1),t.O(a,a,[i*t.a4,n*t.a4,0])}else if(o.canonical.z>e.canonical.z){const i=o.canonical.z-e.canonical.z,n=o.canonical.x-(o.canonical.x>>i<>i<>i),l=e.canonical.y-(o.canonical.y>>i),c=t.a4>>i;t.c6(a,0,c,c,0,0,1),t.O(a,a,[-n*c+s*t.a4,-r*c+l*t.a4,0])}else{const i=e.canonical.z-o.canonical.z,n=e.canonical.x-(e.canonical.x>>i<>i<>i)-o.canonical.x,l=(e.canonical.y>>i)-o.canonical.y,c=t.a4<i.maxzoom&&(n=i.maxzoom),n=i.minzoom&&(!r||!r.dem);)r=this.tileManager.getTileByID(e.scaledTo(n--).key);return r}anyTilesAfterTime(e=Date.now()){return this._lastTilesetChange>=e}_isWithinTileRanges(e,t){return t[e.canonical.z]&&e.canonical.x>=t[e.canonical.z].minTileX&&e.canonical.x<=t[e.canonical.z].maxTileX&&e.canonical.y>=t[e.canonical.z].minTileY&&e.canonical.y<=t[e.canonical.z].maxTileY}}class Xo{constructor(e,t,i){this._meshCache={},this.painter=e,this.tileManager=new Ko(t),this.options=i,this.exaggeration="number"==typeof i.exaggeration?i.exaggeration:1,this.qualityFactor=2,this.meshSize=128,this._demMatrixCache={},this.coordsIndex=[],this._coordsTextureSize=1024}getDEMElevation(e,i,n,r=t.a4){var o;if(!(i>=0&&i=0&&ne.canonical.z&&(e.canonical.z>=n?r=e.canonical.z-n:t.w("cannot calculate elevation if elevation maxzoom > source.maxzoom"));const o=e.canonical.x-(e.canonical.x>>r<>r<>8<<4|e>>8,i[t+3]=0;const n=new t.R({width:this._coordsTextureSize,height:this._coordsTextureSize},new Uint8Array(i.buffer)),r=new t.T(e,n,e.gl.RGBA,{premultiply:!1});return r.bind(e.gl.NEAREST,e.gl.CLAMP_TO_EDGE),this._coordsTexture=r,r}pointCoordinate(e){this.painter.maybeDrawDepthAndCoords(!0);const i=new Uint8Array(4),n=this.painter.context,r=n.gl,o=Math.round(e.x*this.painter.pixelRatio/devicePixelRatio),s=Math.round(e.y*this.painter.pixelRatio/devicePixelRatio),a=Math.round(this.painter.height/devicePixelRatio);n.bindFramebuffer.set(this.getFramebuffer("coords").framebuffer),r.readPixels(o,a-s-1,1,1,r.RGBA,r.UNSIGNED_BYTE,i),n.bindFramebuffer.set(null);const l=i[0]+(i[2]>>4<<8),c=i[1]+((15&i[2])<<8),u=this.coordsIndex[255-i[3]],h=u&&this.tileManager.getTileByID(u);if(!h)return null;const d=this._coordsTextureSize,p=(1<0,r=n&&0===e.canonical.y,o=n&&e.canonical.y===(1<e.id!==t),this._recentlyUsed.push(e.id)}stampObject(e){e.stamp=++this._stamp}getOrCreateFreeObject(){for(const e of this._recentlyUsed)if(!this._objects[e].inUse)return this._objects[e];if(this._objects.length>=this._size)throw new Error("No free RenderPool available, call freeAllObjects() required!");const e=this._createObject(this._objects.length);return this._objects.push(e),e}freeObject(e){e.inUse=!1}freeAllObjects(){for(const e of this._objects)this.freeObject(e)}isFull(){return!(this._objects.length!e.inUse)}}const Yo={background:!0,fill:!0,line:!0,raster:!0,hillshade:!0,"color-relief":!0};class es{constructor(e,t){this.painter=e,this.terrain=t,this.pool=new Jo(e.context,30,t.tileManager.tileSize*t.qualityFactor)}destruct(){this.pool.destruct()}getTexture(e){return this.pool.getObjectForId(e.rtt[this._stacks.length-1].id).texture}prepareForRender(e,t){this._stacks=[],this._prevType=null,this._rttTiles=[],this._renderableTiles=this.terrain.tileManager.getRenderableTiles(),this._renderableLayerIds=e._order.filter(i=>!e._layers[i].isHidden(t)),this._coordsAscending={};for(const t in e.tileManagers){this._coordsAscending[t]={};const i=e.tileManagers[t].getVisibleCoordinates(),n=e.tileManagers[t].getSource(),r=n instanceof te?n.terrainTileRanges:null;for(const e of i){const i=this.terrain.tileManager.getTerrainCoords(e,r);for(const e in i)this._coordsAscending[t][e]||(this._coordsAscending[t][e]=[]),this._coordsAscending[t][e].push(i[e])}}this._coordsAscendingStr={};for(const t of e._order){const i=e._layers[t],n=i.source;if(Yo[i.type]&&!this._coordsAscendingStr[n]){this._coordsAscendingStr[n]={};for(const e in this._coordsAscending[n])this._coordsAscendingStr[n][e]=this._coordsAscending[n][e].map(e=>e.key).sort().join()}}for(const e of this._renderableTiles)for(const t in this._coordsAscendingStr){const i=this._coordsAscendingStr[t][e.tileID.key];i&&i!==e.rttCoords[t]&&(e.rtt=[])}}renderLayer(e,i){if(e.isHidden(this.painter.transform.zoom))return!1;const n=Object.assign(Object.assign({},i),{isRenderingToTexture:!0}),r=e.type,o=this.painter,s=this._renderableLayerIds[this._renderableLayerIds.length-1]===e.id;if(Yo[r]&&(this._prevType&&Yo[this._prevType]||this._stacks.push([]),this._prevType=r,this._stacks[this._stacks.length-1].push(e.id),!s))return!0;if(Yo[this._prevType]||Yo[r]&&s){this._prevType=r;const e=this._stacks.length-1,i=this._stacks[e]||[];for(const r of this._renderableTiles){if(this.pool.isFull()&&(zr(this.painter,this.terrain,this._rttTiles,n),this._rttTiles=[],this.pool.freeAllObjects()),this._rttTiles.push(r),r.rtt[e]){const t=this.pool.getObjectForId(r.rtt[e].id);if(t.stamp===r.rtt[e].stamp){this.pool.useObject(t);continue}}const s=this.pool.getOrCreateFreeObject();this.pool.useObject(s),this.pool.stampObject(s),r.rtt[e]={id:s.id,stamp:s.stamp},o.context.bindFramebuffer.set(s.fbo.framebuffer),o.context.clear({color:t.bo.transparent,stencil:0}),o.currentStencilSource=void 0;for(let e=0;e{this.startMove(e,u.mousePos(this.element,e)),u.addEventListener(window,"mousemove",this.mousemove),u.addEventListener(window,"mouseup",this.mouseup)},this.mousemove=e=>{this.move(e,u.mousePos(this.element,e))},this.mouseup=e=>{this._rotatePitchHandler.dragEnd(e),this.offTemp()},this.touchstart=e=>{1!==e.targetTouches.length?this.reset():(this._startPos=this._lastPos=u.touchPos(this.element,e.targetTouches)[0],this.startMove(e,this._startPos),u.addEventListener(window,"touchmove",this.touchmove,{passive:!1}),u.addEventListener(window,"touchend",this.touchend))},this.touchmove=e=>{1!==e.targetTouches.length?this.reset():(this._lastPos=u.touchPos(this.element,e.targetTouches)[0],this.move(e,this._lastPos))},this.touchend=e=>{0===e.targetTouches.length&&this._startPos&&this._lastPos&&this._startPos.dist(this._lastPos){this._rotatePitchHandler.reset(),delete this._startPos,delete this._lastPos,this.offTemp()},this._clickTolerance=10,this.element=i;const r=new go;this._rotatePitchHandler=new co({clickTolerance:3,move:(e,r)=>{const o=i.getBoundingClientRect(),s=new t.P((o.bottom-o.top)/2,(o.right-o.left)/2);return{bearingDelta:t.cw(new t.P(e.x,r.y),r,s),pitchDelta:n?-.5*(r.y-e.y):void 0}},moveStateManager:r,enable:!0,assignEvents:()=>{}}),this.map=e,u.addEventListener(i,"mousedown",this.mousedown),u.addEventListener(i,"touchstart",this.touchstart,{passive:!1}),u.addEventListener(i,"touchcancel",this.reset)}startMove(e,t){this._rotatePitchHandler.dragStart(e,t),u.disableDrag()}move(e,t){const i=this.map,{bearingDelta:n,pitchDelta:r}=this._rotatePitchHandler.dragMove(e,t)||{};n&&i.setBearing(i.getBearing()+n),r&&i.setPitch(i.getPitch()+r)}off(){const e=this.element;u.removeEventListener(e,"mousedown",this.mousedown),u.removeEventListener(e,"touchstart",this.touchstart,{passive:!1}),u.removeEventListener(window,"touchmove",this.touchmove,{passive:!1}),u.removeEventListener(window,"touchend",this.touchend),u.removeEventListener(e,"touchcancel",this.reset),this.offTemp()}offTemp(){u.enableDrag(),u.removeEventListener(window,"mousemove",this.mousemove),u.removeEventListener(window,"mouseup",this.mouseup),u.removeEventListener(window,"touchmove",this.touchmove,{passive:!1}),u.removeEventListener(window,"touchend",this.touchend)}}let ss;function as(e,i,n,r=!1){if(r||!n.getCoveringTilesDetailsProvider().allowWorldCopies())return null==e?void 0:e.wrap();const o=new t.V(e.lng,e.lat);if(e=new t.V(e.lng,e.lat),i){const r=new t.V(e.lng-360,e.lat),o=new t.V(e.lng+360,e.lat),s=n.locationToScreenPoint(e).distSqr(i);n.locationToScreenPoint(r).distSqr(i)180;){const t=n.locationToScreenPoint(e);if(t.x>=0&&t.y>=0&&t.x<=n.width&&t.y<=n.height)break;e.lng>n.center.lng?e.lng-=360:e.lng+=360}return e.lng!==o.lng&&n.isPointOnMapSurface(n.locationToScreenPoint(e))?e:o}const ls={center:"translate(-50%,-50%)",top:"translate(-50%,0)","top-left":"translate(0,0)","top-right":"translate(-100%,0)",bottom:"translate(-50%,-100%)","bottom-left":"translate(0,-100%)","bottom-right":"translate(-100%,-100%)",left:"translate(0,-50%)",right:"translate(-100%,-50%)"};function cs(e,t,i){const n=e.classList;for(const e in ls)n.remove(`maplibregl-${i}-anchor-${e}`);n.add(`maplibregl-${i}-anchor-${t}`)}class us extends t.E{constructor(e){if(super(),this._onKeyPress=e=>{const t=e.code,i=e.charCode||e.keyCode;"Space"!==t&&"Enter"!==t&&32!==i&&13!==i||this.togglePopup()},this._onMapClick=e=>{const t=e.originalEvent.target,i=this._element;this._popup&&(t===i||i.contains(t))&&this.togglePopup()},this._update=e=>{if(!this._map)return;const t=this._map.loaded()&&!this._map.isMoving();("terrain"===(null==e?void 0:e.type)||"render"===(null==e?void 0:e.type)&&!t)&&this._map.once("render",this._update),this._lngLat=as(this._lngLat,this._flatPos,this._map.transform),this._flatPos=this._pos=this._map.project(this._lngLat)._add(this._offset),this._map.terrain&&(this._flatPos=this._map.transform.locationToScreenPoint(this._lngLat)._add(this._offset));let i="";"viewport"===this._rotationAlignment||"auto"===this._rotationAlignment?i=`rotateZ(${this._rotation}deg)`:"map"===this._rotationAlignment&&(i=`rotateZ(${this._rotation-this._map.getBearing()}deg)`);let n="";"viewport"===this._pitchAlignment||"auto"===this._pitchAlignment?n="rotateX(0deg)":"map"===this._pitchAlignment&&(n=`rotateX(${this._map.getPitch()}deg)`),this._subpixelPositioning||e&&"moveend"!==e.type||(this._pos=this._pos.round()),u.setTransform(this._element,`${ls[this._anchor]} translate(${this._pos.x}px, ${this._pos.y}px) ${n} ${i}`),a.frameAsync(new AbortController).then(()=>{this._updateOpacity(e&&"moveend"===e.type)}).catch(()=>{})},this._onMove=e=>{if(!this._isDragging){const t=this._clickTolerance||this._map._clickTolerance;this._isDragging=e.point.dist(this._pointerdownPos)>=t}this._isDragging&&(this._pos=e.point.sub(this._positionDelta),this._lngLat=this._map.unproject(this._pos),this.setLngLat(this._lngLat),this._element.style.pointerEvents="none","pending"===this._state&&(this._state="active",this.fire(new t.l("dragstart"))),this.fire(new t.l("drag")))},this._onUp=()=>{this._element.style.pointerEvents="auto",this._positionDelta=null,this._pointerdownPos=null,this._isDragging=!1,this._map.off("mousemove",this._onMove),this._map.off("touchmove",this._onMove),"active"===this._state&&this.fire(new t.l("dragend")),this._state="inactive"},this._addDragHandler=e=>{this._element.contains(e.originalEvent.target)&&(e.preventDefault(),this._positionDelta=e.point.sub(this._pos).add(this._offset),this._pointerdownPos=e.point,this._state="pending",this._map.on("mousemove",this._onMove),this._map.on("touchmove",this._onMove),this._map.once("mouseup",this._onUp),this._map.once("touchend",this._onUp))},this._anchor=e&&e.anchor||"center",this._color=e&&e.color||"#3FB1CE",this._scale=e&&e.scale||1,this._draggable=e&&e.draggable||!1,this._clickTolerance=e&&e.clickTolerance||0,this._subpixelPositioning=e&&e.subpixelPositioning||!1,this._isDragging=!1,this._state="inactive",this._rotation=e&&e.rotation||0,this._rotationAlignment=e&&e.rotationAlignment||"auto",this._pitchAlignment=e&&e.pitchAlignment&&"auto"!==e.pitchAlignment?e.pitchAlignment:this._rotationAlignment,this.setOpacity(null==e?void 0:e.opacity,null==e?void 0:e.opacityWhenCovered),e&&e.element)this._element=e.element,this._offset=t.P.convert(e&&e.offset||[0,0]);else{this._defaultMarker=!0,this._element=u.create("div");const i=u.createNS("http://www.w3.org/2000/svg","svg"),n=41,r=27;i.setAttributeNS(null,"display","block"),i.setAttributeNS(null,"height",`${n}px`),i.setAttributeNS(null,"width",`${r}px`),i.setAttributeNS(null,"viewBox",`0 0 ${r} ${n}`);const o=u.createNS("http://www.w3.org/2000/svg","g");o.setAttributeNS(null,"stroke","none"),o.setAttributeNS(null,"stroke-width","1"),o.setAttributeNS(null,"fill","none"),o.setAttributeNS(null,"fill-rule","evenodd");const s=u.createNS("http://www.w3.org/2000/svg","g");s.setAttributeNS(null,"fill-rule","nonzero");const a=u.createNS("http://www.w3.org/2000/svg","g");a.setAttributeNS(null,"transform","translate(3.0, 29.0)"),a.setAttributeNS(null,"fill","#000000");const l=[{rx:"10.5",ry:"5.25002273"},{rx:"10.5",ry:"5.25002273"},{rx:"9.5",ry:"4.77275007"},{rx:"8.5",ry:"4.29549936"},{rx:"7.5",ry:"3.81822308"},{rx:"6.5",ry:"3.34094679"},{rx:"5.5",ry:"2.86367051"},{rx:"4.5",ry:"2.38636864"}];for(const e of l){const t=u.createNS("http://www.w3.org/2000/svg","ellipse");t.setAttributeNS(null,"opacity","0.04"),t.setAttributeNS(null,"cx","10.5"),t.setAttributeNS(null,"cy","5.80029008"),t.setAttributeNS(null,"rx",e.rx),t.setAttributeNS(null,"ry",e.ry),a.appendChild(t)}const c=u.createNS("http://www.w3.org/2000/svg","g");c.setAttributeNS(null,"fill",this._color);const h=u.createNS("http://www.w3.org/2000/svg","path");h.setAttributeNS(null,"d","M27,13.5 C27,19.074644 20.250001,27.000002 14.75,34.500002 C14.016665,35.500004 12.983335,35.500004 12.25,34.500002 C6.7499993,27.000002 0,19.222562 0,13.5 C0,6.0441559 6.0441559,0 13.5,0 C20.955844,0 27,6.0441559 27,13.5 Z"),c.appendChild(h);const d=u.createNS("http://www.w3.org/2000/svg","g");d.setAttributeNS(null,"opacity","0.25"),d.setAttributeNS(null,"fill","#000000");const p=u.createNS("http://www.w3.org/2000/svg","path");p.setAttributeNS(null,"d","M13.5,0 C6.0441559,0 0,6.0441559 0,13.5 C0,19.222562 6.7499993,27 12.25,34.5 C13,35.522727 14.016664,35.500004 14.75,34.5 C20.250001,27 27,19.074644 27,13.5 C27,6.0441559 20.955844,0 13.5,0 Z M13.5,1 C20.415404,1 26,6.584596 26,13.5 C26,15.898657 24.495584,19.181431 22.220703,22.738281 C19.945823,26.295132 16.705119,30.142167 13.943359,33.908203 C13.743445,34.180814 13.612715,34.322738 13.5,34.441406 C13.387285,34.322738 13.256555,34.180814 13.056641,33.908203 C10.284481,30.127985 7.4148684,26.314159 5.015625,22.773438 C2.6163816,19.232715 1,15.953538 1,13.5 C1,6.584596 6.584596,1 13.5,1 Z"),d.appendChild(p);const f=u.createNS("http://www.w3.org/2000/svg","g");f.setAttributeNS(null,"transform","translate(6.0, 7.0)"),f.setAttributeNS(null,"fill","#FFFFFF");const m=u.createNS("http://www.w3.org/2000/svg","g");m.setAttributeNS(null,"transform","translate(8.0, 8.0)");const g=u.createNS("http://www.w3.org/2000/svg","circle");g.setAttributeNS(null,"fill","#000000"),g.setAttributeNS(null,"opacity","0.25"),g.setAttributeNS(null,"cx","5.5"),g.setAttributeNS(null,"cy","5.5"),g.setAttributeNS(null,"r","5.4999962");const _=u.createNS("http://www.w3.org/2000/svg","circle");_.setAttributeNS(null,"fill","#FFFFFF"),_.setAttributeNS(null,"cx","5.5"),_.setAttributeNS(null,"cy","5.5"),_.setAttributeNS(null,"r","5.4999962"),m.appendChild(g),m.appendChild(_),s.appendChild(a),s.appendChild(c),s.appendChild(d),s.appendChild(f),s.appendChild(m),i.appendChild(s),i.setAttributeNS(null,"height",n*this._scale+"px"),i.setAttributeNS(null,"width",r*this._scale+"px"),this._element.appendChild(i),this._offset=t.P.convert(e&&e.offset||[0,-14])}if(this._element.classList.add("maplibregl-marker"),this._element.addEventListener("dragstart",e=>{e.preventDefault()}),this._element.addEventListener("mousedown",e=>{e.preventDefault()}),cs(this._element,this._anchor,"marker"),e&&e.className)for(const t of e.className.split(" "))this._element.classList.add(t);this._popup=null}addTo(e){return this.remove(),this._map=e,this._element.hasAttribute("aria-label")||this._element.setAttribute("aria-label",e._getUIString("Marker.Title")),this._element.hasAttribute("role")||this._element.setAttribute("role","button"),e.getCanvasContainer().appendChild(this._element),e.on("move",this._update),e.on("moveend",this._update),e.on("terrain",this._update),e.on("projectiontransition",this._update),this.setDraggable(this._draggable),this._update(),this._map.on("click",this._onMapClick),this}remove(){return this._opacityTimeout&&(clearTimeout(this._opacityTimeout),delete this._opacityTimeout),this._map&&(this._map.off("click",this._onMapClick),this._map.off("move",this._update),this._map.off("moveend",this._update),this._map.off("terrain",this._update),this._map.off("projectiontransition",this._update),this._map.off("mousedown",this._addDragHandler),this._map.off("touchstart",this._addDragHandler),this._map.off("mouseup",this._onUp),this._map.off("touchend",this._onUp),this._map.off("mousemove",this._onMove),this._map.off("touchmove",this._onMove),delete this._map),u.remove(this._element),this._popup&&this._popup.remove(),this}getLngLat(){return this._lngLat}setLngLat(e){return this._lngLat=t.V.convert(e),this._pos=null,this._popup&&this._popup.setLngLat(this._lngLat),this._update(),this}getElement(){return this._element}setPopup(e){if(this._popup&&(this._popup.remove(),this._popup=null,this._element.removeEventListener("keypress",this._onKeyPress),this._originalTabIndex||this._element.removeAttribute("tabindex")),e){if(!("offset"in e.options)){const t=38.1,i=13.5,n=Math.abs(i)/Math.SQRT2;e.options.offset=this._defaultMarker?{top:[0,0],"top-left":[0,0],"top-right":[0,0],bottom:[0,-t],"bottom-left":[n,-1*(t-i+n)],"bottom-right":[-n,-1*(t-i+n)],left:[i,-1*(t-i)],right:[-i,-1*(t-i)]}:this._offset}this._popup=e,this._originalTabIndex=this._element.getAttribute("tabindex"),this._originalTabIndex||this._element.setAttribute("tabindex","0"),this._element.addEventListener("keypress",this._onKeyPress)}return this}setSubpixelPositioning(e){return this._subpixelPositioning=e,this}getPopup(){return this._popup}togglePopup(){const e=this._popup;return this._element.style.opacity===this._opacityWhenCovered?this:e?(e.isOpen()?e.remove():(e.setLngLat(this._lngLat),e.addTo(this._map)),this):this}_updateOpacity(e=!1){var i,n;const r=null===(i=this._map)||void 0===i?void 0:i.terrain,o=this._map.transform.isLocationOccluded(this._lngLat);if(!r||o){const e=o?this._opacityWhenCovered:this._opacity;return void(this._element.style.opacity!==e&&(this._element.style.opacity=e))}if(e)this._opacityTimeout=null;else{if(this._opacityTimeout)return;this._opacityTimeout=setTimeout(()=>{this._opacityTimeout=null},100)}const s=this._map,a=s.terrain.depthAtPoint(this._pos),l=s.terrain.getElevationForLngLatZoom(this._lngLat,s.transform.tileZoom);if(s.transform.lngLatToCameraDepth(this._lngLat,l)-a<.006)return void(this._element.style.opacity=this._opacity);const c=-this._offset.y/s.transform.pixelsPerMeter,u=Math.sin(s.getPitch()*Math.PI/180)*c,h=s.terrain.depthAtPoint(new t.P(this._pos.x,this._pos.y-this._offset.y)),d=s.transform.lngLatToCameraDepth(this._lngLat,l+u)-h>.006;(null===(n=this._popup)||void 0===n?void 0:n.isOpen())&&d&&this._popup.remove(),this._element.style.opacity=d?this._opacityWhenCovered:this._opacity}getOffset(){return this._offset}setOffset(e){return this._offset=t.P.convert(e),this._update(),this}addClassName(e){this._element.classList.add(e)}removeClassName(e){this._element.classList.remove(e)}toggleClassName(e){return this._element.classList.toggle(e)}setDraggable(e){return this._draggable=!!e,this._map&&(e?(this._map.on("mousedown",this._addDragHandler),this._map.on("touchstart",this._addDragHandler)):(this._map.off("mousedown",this._addDragHandler),this._map.off("touchstart",this._addDragHandler))),this}isDraggable(){return this._draggable}setRotation(e){return this._rotation=e||0,this._update(),this}getRotation(){return this._rotation}setRotationAlignment(e){return this._rotationAlignment=e||"auto",this._update(),this}getRotationAlignment(){return this._rotationAlignment}setPitchAlignment(e){return this._pitchAlignment=e&&"auto"!==e?e:this._rotationAlignment,this._update(),this}getPitchAlignment(){return this._pitchAlignment}setOpacity(e,t){return(void 0===this._opacity||void 0===e&&void 0===t)&&(this._opacity="1",this._opacityWhenCovered="0.2"),void 0!==e&&(this._opacity=e),void 0!==t&&(this._opacityWhenCovered=t),this._map&&this._updateOpacity(!0),this}}const hs={positionOptions:{enableHighAccuracy:!1,maximumAge:0,timeout:6e3},fitBoundsOptions:{maxZoom:15},trackUserLocation:!1,showAccuracyCircle:!0,showUserLocation:!0};let ds=0,ps=!1;const fs={maxWidth:100,unit:"metric"};function ms(e,t,i){const n=i&&i.maxWidth||100,r=e._container.clientHeight/2,o=e._container.clientWidth/2,s=e.unproject([o-n/2,r]),a=e.unproject([o+n/2,r]),l=Math.round(e.project(a).x-e.project(s).x),c=Math.min(n,l,e._container.clientWidth),u=s.distanceTo(a);if(i&&"imperial"===i.unit){const i=3.2808*u;i>5280?gs(t,c,i/5280,e._getUIString("ScaleControl.Miles")):gs(t,c,i,e._getUIString("ScaleControl.Feet"))}else i&&"nautical"===i.unit?gs(t,c,u/1852,e._getUIString("ScaleControl.NauticalMiles")):u>=1e3?gs(t,c,u/1e3,e._getUIString("ScaleControl.Kilometers")):gs(t,c,u,e._getUIString("ScaleControl.Meters"))}function gs(e,t,i,n){const r=function(e){const t=Math.pow(10,`${Math.floor(e)}`.length-1);let i=e/t;return i=i>=10?10:i>=5?5:i>=3?3:i>=2?2:i>=1?1:function(e){const t=Math.pow(10,Math.ceil(-Math.log(e)/Math.LN10));return Math.round(e*t)/t}(i),t*i}(i);e.style.width=t*(r/i)+"px",e.innerHTML=`${r} ${n}`}const _s={closeButton:!0,closeOnClick:!0,focusAfterOpen:!0,className:"",maxWidth:"240px",subpixelPositioning:!1,locationOccludedOpacity:void 0},As=["a[href]","[tabindex]:not([tabindex='-1'])","[contenteditable]:not([contenteditable='false'])","button:not([disabled])","input:not([disabled])","select:not([disabled])","textarea:not([disabled])"].join(", ");function ys(e){if(e){if("number"==typeof e){const i=Math.round(Math.abs(e)/Math.SQRT2);return{center:new t.P(0,0),top:new t.P(0,e),"top-left":new t.P(i,i),"top-right":new t.P(-i,i),bottom:new t.P(0,-e),"bottom-left":new t.P(i,-i),"bottom-right":new t.P(-i,-i),left:new t.P(e,0),right:new t.P(-e,0)}}if(e instanceof t.P||Array.isArray(e)){const i=t.P.convert(e);return{center:i,top:i,"top-left":i,"top-right":i,bottom:i,"bottom-left":i,"bottom-right":i,left:i,right:i}}return{center:t.P.convert(e.center||[0,0]),top:t.P.convert(e.top||[0,0]),"top-left":t.P.convert(e["top-left"]||[0,0]),"top-right":t.P.convert(e["top-right"]||[0,0]),bottom:t.P.convert(e.bottom||[0,0]),"bottom-left":t.P.convert(e["bottom-left"]||[0,0]),"bottom-right":t.P.convert(e["bottom-right"]||[0,0]),left:t.P.convert(e.left||[0,0]),right:t.P.convert(e.right||[0,0])}}return ys(new t.P(0,0))}const vs=i;e.AJAXError=t.cI,e.Event=t.l,e.Evented=t.E,e.LngLat=t.V,e.MercatorCoordinate=t.aa,e.Point=t.P,e.addProtocol=t.cJ,e.config=t.a,e.removeProtocol=t.cK,e.AttributionControl=$o,e.BoxZoomHandler=ro,e.CanvasSource=ne,e.CooperativeGesturesHandler=Uo,e.DoubleClickZoomHandler=Lo,e.DragPanHandler=Do,e.DragRotateHandler=Oo,e.EdgeInsets=Ft,e.FullscreenControl=class extends t.E{constructor(e={}){super(),this._onFullscreenChange=()=>{var e;let t=window.document.fullscreenElement||window.document.mozFullScreenElement||window.document.webkitFullscreenElement||window.document.msFullscreenElement;for(;null===(e=null==t?void 0:t.shadowRoot)||void 0===e?void 0:e.fullscreenElement;)t=t.shadowRoot.fullscreenElement;t===this._container!==this._fullscreen&&this._handleFullscreenChange()},this._onClickFullscreen=()=>{this._isFullscreen()?this._exitFullscreen():this._requestFullscreen()},this._fullscreen=!1,e&&e.container&&(e.container instanceof HTMLElement?this._container=e.container:t.w("Full screen control 'container' must be a DOM element.")),"onfullscreenchange"in document?this._fullscreenchange="fullscreenchange":"onmozfullscreenchange"in document?this._fullscreenchange="mozfullscreenchange":"onwebkitfullscreenchange"in document?this._fullscreenchange="webkitfullscreenchange":"onmsfullscreenchange"in document&&(this._fullscreenchange="MSFullscreenChange")}onAdd(e){return this._map=e,this._container||(this._container=this._map.getContainer()),this._controlContainer=u.create("div","maplibregl-ctrl maplibregl-ctrl-group"),this._setupUI(),this._controlContainer}onRemove(){u.remove(this._controlContainer),this._map=null,window.document.removeEventListener(this._fullscreenchange,this._onFullscreenChange)}_setupUI(){const e=this._fullscreenButton=u.create("button","maplibregl-ctrl-fullscreen",this._controlContainer);u.create("span","maplibregl-ctrl-icon",e).setAttribute("aria-hidden","true"),e.type="button",this._updateTitle(),this._fullscreenButton.addEventListener("click",this._onClickFullscreen),window.document.addEventListener(this._fullscreenchange,this._onFullscreenChange)}_updateTitle(){const e=this._getTitle();this._fullscreenButton.setAttribute("aria-label",e),this._fullscreenButton.title=e}_getTitle(){return this._map._getUIString(this._isFullscreen()?"FullscreenControl.Exit":"FullscreenControl.Enter")}_isFullscreen(){return this._fullscreen}_handleFullscreenChange(){this._fullscreen=!this._fullscreen,this._fullscreenButton.classList.toggle("maplibregl-ctrl-shrink"),this._fullscreenButton.classList.toggle("maplibregl-ctrl-fullscreen"),this._updateTitle(),this._fullscreen?(this.fire(new t.l("fullscreenstart")),this._prevCooperativeGesturesEnabled=this._map.cooperativeGestures.isEnabled(),this._map.cooperativeGestures.disable()):(this.fire(new t.l("fullscreenend")),this._prevCooperativeGesturesEnabled&&this._map.cooperativeGestures.enable())}_exitFullscreen(){window.document.exitFullscreen?window.document.exitFullscreen():window.document.mozCancelFullScreen?window.document.mozCancelFullScreen():window.document.msExitFullscreen?window.document.msExitFullscreen():window.document.webkitCancelFullScreen?window.document.webkitCancelFullScreen():this._togglePseudoFullScreen()}_requestFullscreen(){this._container.requestFullscreen?this._container.requestFullscreen():this._container.mozRequestFullScreen?this._container.mozRequestFullScreen():this._container.msRequestFullscreen?this._container.msRequestFullscreen():this._container.webkitRequestFullscreen?this._container.webkitRequestFullscreen():this._togglePseudoFullScreen()}_togglePseudoFullScreen(){this._container.classList.toggle("maplibregl-pseudo-fullscreen"),this._handleFullscreenChange(),this._map.resize()}},e.GeoJSONSource=ee,e.GeolocateControl=class extends t.E{constructor(e){super(),this._onSuccess=e=>{if(this._map){if(this._isOutOfMapMaxBounds(e))return this._setErrorState(),this.fire(new t.l("outofmaxbounds",e)),this._updateMarker(),void this._finish();if(this.options.trackUserLocation)switch(this._lastKnownPosition=e,this._watchState){case"WAITING_ACTIVE":case"ACTIVE_LOCK":case"ACTIVE_ERROR":this._watchState="ACTIVE_LOCK",this._geolocateButton.classList.remove("maplibregl-ctrl-geolocate-waiting"),this._geolocateButton.classList.remove("maplibregl-ctrl-geolocate-active-error"),this._geolocateButton.classList.add("maplibregl-ctrl-geolocate-active");break;case"BACKGROUND":case"BACKGROUND_ERROR":this._watchState="BACKGROUND",this._geolocateButton.classList.remove("maplibregl-ctrl-geolocate-waiting"),this._geolocateButton.classList.remove("maplibregl-ctrl-geolocate-background-error"),this._geolocateButton.classList.add("maplibregl-ctrl-geolocate-background");break;default:throw new Error(`Unexpected watchState ${this._watchState}`)}this.options.showUserLocation&&"OFF"!==this._watchState&&this._updateMarker(e),this.options.trackUserLocation&&"ACTIVE_LOCK"!==this._watchState||this._updateCamera(e),this.options.showUserLocation&&this._dotElement.classList.remove("maplibregl-user-location-dot-stale"),this.fire(new t.l("geolocate",e)),this._finish()}},this._updateCamera=e=>{const i=new t.V(e.coords.longitude,e.coords.latitude),n=e.coords.accuracy,r=this._map.getBearing(),o=t.e({bearing:r},this.options.fitBoundsOptions),s=Z.fromLngLat(i,n);this._map.fitBounds(s,o,{geolocateSource:!0})},this._updateMarker=e=>{if(e){const i=new t.V(e.coords.longitude,e.coords.latitude);this._accuracyCircleMarker.setLngLat(i).addTo(this._map),this._userLocationDotMarker.setLngLat(i).addTo(this._map),this._accuracy=e.coords.accuracy,this._updateCircleRadiusIfNeeded()}else this._userLocationDotMarker.remove(),this._accuracyCircleMarker.remove()},this._onUpdate=()=>{this._updateCircleRadiusIfNeeded()},this._onError=e=>{if(this._map){if(1===e.code){this._watchState="OFF",this._geolocateButton.classList.remove("maplibregl-ctrl-geolocate-waiting"),this._geolocateButton.classList.remove("maplibregl-ctrl-geolocate-active"),this._geolocateButton.classList.remove("maplibregl-ctrl-geolocate-active-error"),this._geolocateButton.classList.remove("maplibregl-ctrl-geolocate-background"),this._geolocateButton.classList.remove("maplibregl-ctrl-geolocate-background-error"),this._geolocateButton.disabled=!0;const e=this._map._getUIString("GeolocateControl.LocationNotAvailable");this._geolocateButton.title=e,this._geolocateButton.setAttribute("aria-label",e),void 0!==this._geolocationWatchID&&this._clearWatch()}else{if(3===e.code&&ps)return;this._setErrorState()}"OFF"!==this._watchState&&this.options.showUserLocation&&this._dotElement.classList.add("maplibregl-user-location-dot-stale"),this.fire(new t.l("error",e)),this._finish()}},this._finish=()=>{this._timeoutId&&clearTimeout(this._timeoutId),this._timeoutId=void 0},this._setupUI=()=>{this._map&&(this._container.addEventListener("contextmenu",e=>e.preventDefault()),this._geolocateButton=u.create("button","maplibregl-ctrl-geolocate",this._container),u.create("span","maplibregl-ctrl-icon",this._geolocateButton).setAttribute("aria-hidden","true"),this._geolocateButton.type="button",this._geolocateButton.disabled=!0)},this._finishSetupUI=e=>{if(this._map){if(!1===e){t.w("Geolocation support is not available so the GeolocateControl will be disabled.");const e=this._map._getUIString("GeolocateControl.LocationNotAvailable");this._geolocateButton.disabled=!0,this._geolocateButton.title=e,this._geolocateButton.setAttribute("aria-label",e)}else{const e=this._map._getUIString("GeolocateControl.FindMyLocation");this._geolocateButton.disabled=!1,this._geolocateButton.title=e,this._geolocateButton.setAttribute("aria-label",e)}this.options.trackUserLocation&&(this._geolocateButton.setAttribute("aria-pressed","false"),this._watchState="OFF"),this.options.showUserLocation&&(this._dotElement=u.create("div","maplibregl-user-location-dot"),this._userLocationDotMarker=new us({element:this._dotElement}),this._circleElement=u.create("div","maplibregl-user-location-accuracy-circle"),this._accuracyCircleMarker=new us({element:this._circleElement,pitchAlignment:"map"}),this.options.trackUserLocation&&(this._watchState="OFF"),this._map.on("zoom",this._onUpdate),this._map.on("move",this._onUpdate),this._map.on("rotate",this._onUpdate),this._map.on("pitch",this._onUpdate)),this._geolocateButton.addEventListener("click",()=>this.trigger()),this._setup=!0,this.options.trackUserLocation&&this._map.on("movestart",e=>{const i=(null==e?void 0:e[0])instanceof ResizeObserverEntry;e.geolocateSource||"ACTIVE_LOCK"!==this._watchState||i||this._map.isZooming()||(this._watchState="BACKGROUND",this._geolocateButton.classList.add("maplibregl-ctrl-geolocate-background"),this._geolocateButton.classList.remove("maplibregl-ctrl-geolocate-active"),this.fire(new t.l("trackuserlocationend")),this.fire(new t.l("userlocationlostfocus")))})}},this.options=t.e({},hs,e)}onAdd(e){return this._map=e,this._container=u.create("div","maplibregl-ctrl maplibregl-ctrl-group"),this._setupUI(),function(){return t._(this,arguments,void 0,function*(e=!1){if(void 0!==ss&&!e)return ss;if(void 0===window.navigator.permissions)return ss=!!window.navigator.geolocation,ss;try{const e=yield window.navigator.permissions.query({name:"geolocation"});ss="denied"!==e.state}catch(e){ss=!!window.navigator.geolocation}return ss})}().then(e=>this._finishSetupUI(e)),this._container}onRemove(){void 0!==this._geolocationWatchID&&(window.navigator.geolocation.clearWatch(this._geolocationWatchID),this._geolocationWatchID=void 0),this.options.showUserLocation&&this._userLocationDotMarker&&this._userLocationDotMarker.remove(),this.options.showAccuracyCircle&&this._accuracyCircleMarker&&this._accuracyCircleMarker.remove(),u.remove(this._container),this._map.off("zoom",this._onUpdate),this._map.off("move",this._onUpdate),this._map.off("rotate",this._onUpdate),this._map.off("pitch",this._onUpdate),this._map=void 0,ds=0,ps=!1}_isOutOfMapMaxBounds(e){const t=this._map.getMaxBounds(),i=e.coords;return t&&(i.longitudet.getEast()||i.latitudet.getNorth())}_setErrorState(){switch(this._watchState){case"WAITING_ACTIVE":this._watchState="ACTIVE_ERROR",this._geolocateButton.classList.remove("maplibregl-ctrl-geolocate-active"),this._geolocateButton.classList.add("maplibregl-ctrl-geolocate-active-error");break;case"ACTIVE_LOCK":this._watchState="ACTIVE_ERROR",this._geolocateButton.classList.remove("maplibregl-ctrl-geolocate-active"),this._geolocateButton.classList.add("maplibregl-ctrl-geolocate-active-error"),this._geolocateButton.classList.add("maplibregl-ctrl-geolocate-waiting");break;case"BACKGROUND":this._watchState="BACKGROUND_ERROR",this._geolocateButton.classList.remove("maplibregl-ctrl-geolocate-background"),this._geolocateButton.classList.add("maplibregl-ctrl-geolocate-background-error"),this._geolocateButton.classList.add("maplibregl-ctrl-geolocate-waiting");break;case"ACTIVE_ERROR":case"BACKGROUND_ERROR":case"OFF":case void 0:break;default:throw new Error(`Unexpected watchState ${this._watchState}`)}}_updateCircleRadiusIfNeeded(){const e=this._userLocationDotMarker.getLngLat();if(!(this.options.showUserLocation&&this.options.showAccuracyCircle&&this._accuracy&&e))return;const t=this._map.project(e),i=this._map.unproject([t.x+100,t.y]),n=e.distanceTo(i)/100,r=2*this._accuracy/n;this._circleElement.style.width=`${r.toFixed(2)}px`,this._circleElement.style.height=`${r.toFixed(2)}px`}trigger(){if(!this._setup)return t.w("Geolocate control triggered before added to a map"),!1;if(this.options.trackUserLocation){switch(this._watchState){case"OFF":this._watchState="WAITING_ACTIVE",this.fire(new t.l("trackuserlocationstart"));break;case"WAITING_ACTIVE":case"ACTIVE_LOCK":case"ACTIVE_ERROR":case"BACKGROUND_ERROR":ds--,ps=!1,this._watchState="OFF",this._geolocateButton.classList.remove("maplibregl-ctrl-geolocate-waiting"),this._geolocateButton.classList.remove("maplibregl-ctrl-geolocate-active"),this._geolocateButton.classList.remove("maplibregl-ctrl-geolocate-active-error"),this._geolocateButton.classList.remove("maplibregl-ctrl-geolocate-background"),this._geolocateButton.classList.remove("maplibregl-ctrl-geolocate-background-error"),this.fire(new t.l("trackuserlocationend"));break;case"BACKGROUND":this._watchState="ACTIVE_LOCK",this._geolocateButton.classList.remove("maplibregl-ctrl-geolocate-background"),this._lastKnownPosition&&this._updateCamera(this._lastKnownPosition),this.fire(new t.l("trackuserlocationstart")),this.fire(new t.l("userlocationfocus"));break;default:throw new Error(`Unexpected watchState ${this._watchState}`)}switch(this._watchState){case"WAITING_ACTIVE":this._geolocateButton.classList.add("maplibregl-ctrl-geolocate-waiting"),this._geolocateButton.classList.add("maplibregl-ctrl-geolocate-active");break;case"ACTIVE_LOCK":this._geolocateButton.classList.add("maplibregl-ctrl-geolocate-active");break;case"OFF":break;default:throw new Error(`Unexpected watchState ${this._watchState}`)}if("OFF"===this._watchState&&void 0!==this._geolocationWatchID)this._clearWatch();else if(void 0===this._geolocationWatchID){let e;this._geolocateButton.classList.add("maplibregl-ctrl-geolocate-waiting"),this._geolocateButton.setAttribute("aria-pressed","true"),ds++,ds>1?(e={maximumAge:6e5,timeout:0},ps=!0):(e=this.options.positionOptions,ps=!1),this._geolocationWatchID=window.navigator.geolocation.watchPosition(this._onSuccess,this._onError,e)}}else window.navigator.geolocation.getCurrentPosition(this._onSuccess,this._onError,this.options.positionOptions),this._timeoutId=setTimeout(this._finish,1e4);return!0}_clearWatch(){window.navigator.geolocation.clearWatch(this._geolocationWatchID),this._geolocationWatchID=void 0,this._geolocateButton.classList.remove("maplibregl-ctrl-geolocate-waiting"),this._geolocateButton.setAttribute("aria-pressed","false"),this.options.showUserLocation&&this._updateMarker(null)}},e.GlobeControl=class{constructor(){this._toggleProjection=()=>{var e;const t=null===(e=this._map.getProjection())||void 0===e?void 0:e.type;this._map.setProjection("mercator"!==t&&t?{type:"mercator"}:{type:"globe"}),this._updateGlobeIcon()},this._updateGlobeIcon=()=>{var e;this._globeButton.classList.remove("maplibregl-ctrl-globe"),this._globeButton.classList.remove("maplibregl-ctrl-globe-enabled"),"globe"===(null===(e=this._map.getProjection())||void 0===e?void 0:e.type)?(this._globeButton.classList.add("maplibregl-ctrl-globe-enabled"),this._globeButton.title=this._map._getUIString("GlobeControl.Disable")):(this._globeButton.classList.add("maplibregl-ctrl-globe"),this._globeButton.title=this._map._getUIString("GlobeControl.Enable"))}}onAdd(e){return this._map=e,this._container=u.create("div","maplibregl-ctrl maplibregl-ctrl-group"),this._globeButton=u.create("button","maplibregl-ctrl-globe",this._container),u.create("span","maplibregl-ctrl-icon",this._globeButton).setAttribute("aria-hidden","true"),this._globeButton.type="button",this._globeButton.addEventListener("click",this._toggleProjection),this._updateGlobeIcon(),this._map.on("styledata",this._updateGlobeIcon),this._container}onRemove(){u.remove(this._container),this._map.off("styledata",this._updateGlobeIcon),this._globeButton.removeEventListener("click",this._toggleProjection),this._map=void 0}},e.Hash=jr,e.ImageSource=te,e.KeyboardHandler=Bo,e.LngLatBounds=Z,e.LogoControl=Zo,e.Map=class extends Ho{constructor(e){var i,n;t.cF.mark(t.cG.create);const r=Object.assign(Object.assign(Object.assign({},ns),e),{canvasContextAttributes:Object.assign(Object.assign({},ns.canvasContextAttributes),e.canvasContextAttributes)});if(null!=r.minZoom&&null!=r.maxZoom&&r.minZoom>r.maxZoom)throw new Error("maxZoom must be greater than or equal to minZoom");if(null!=r.minPitch&&null!=r.maxPitch&&r.minPitch>r.maxPitch)throw new Error("maxPitch must be greater than or equal to minPitch");if(null!=r.minPitch&&r.minPitch<0)throw new Error("minPitch must be greater than or equal to 0");if(null!=r.maxPitch&&r.maxPitch>180)throw new Error("maxPitch must be less than or equal to 180");const o=new Vt,s=new Qt;if(void 0!==r.minZoom&&o.setMinZoom(r.minZoom),void 0!==r.maxZoom&&o.setMaxZoom(r.maxZoom),void 0!==r.minPitch&&o.setMinPitch(r.minPitch),void 0!==r.maxPitch&&o.setMaxPitch(r.maxPitch),void 0!==r.renderWorldCopies&&o.setRenderWorldCopies(r.renderWorldCopies),null!==r.transformConstrain&&o.setConstrainOverride(r.transformConstrain),super(o,s,{bearingSnap:r.bearingSnap}),this._idleTriggered=!1,this._crossFadingFactor=1,this._renderTaskQueue=new Wo,this._controls=[],this._mapId=t.ag(),this._lostContextStyle={style:null,images:null},this._contextLost=e=>{e.preventDefault(),this._frameRequest&&(this._frameRequest.abort(),this._frameRequest=null),this.painter.destroy();for(const e of Object.values(this.style._layers))if("custom"===e.type&&console.warn(`Custom layer with id '${e.id}' cannot be restored after WebGL context loss. You will need to re-add it manually after context restoration.`),e._listeners)for(const[t]of Object.entries(e._listeners))console.warn(`Custom layer with id '${e.id}' had event listeners for event '${t}' which cannot be restored after WebGL context loss. You will need to re-add them manually after context restoration.`);this._lostContextStyle=this._getStyleAndImages(),this.style.destroy(),this.style=null,this.fire(new t.l("webglcontextlost",{originalEvent:e}))},this._contextRestored=e=>{this._lostContextStyle.style&&this.setStyle(this._lostContextStyle.style,{diff:!1}),this._lostContextStyle.images&&(this.style.imageManager.images=this._lostContextStyle.images),this._setupPainter(),this.resize(),this._update(),this.fire(new t.l("webglcontextrestored",{originalEvent:e}))},this._onMapScroll=e=>{if(e.target===this._container)return this._container.scrollTop=0,this._container.scrollLeft=0,!1},this._onWindowOnline=()=>{this._update()},this._interactive=r.interactive,this._maxTileCacheSize=r.maxTileCacheSize,this._maxTileCacheZoomLevels=r.maxTileCacheZoomLevels,this._canvasContextAttributes=Object.assign({},r.canvasContextAttributes),this._trackResize=!0===r.trackResize,this._bearingSnap=r.bearingSnap,this._centerClampedToGround=r.centerClampedToGround,this._refreshExpiredTiles=!0===r.refreshExpiredTiles,this._fadeDuration=r.fadeDuration,this._crossSourceCollisions=!0===r.crossSourceCollisions,this._collectResourceTiming=!0===r.collectResourceTiming,this._locale=Object.assign(Object.assign({},ts),r.locale),this._clickTolerance=r.clickTolerance,this._overridePixelRatio=r.pixelRatio,this._maxCanvasSize=r.maxCanvasSize,this._zoomLevelsToOverscale=r.experimentalZoomLevelsToOverscale,this.transformCameraUpdate=r.transformCameraUpdate,this.transformConstrain=r.transformConstrain,this.cancelPendingTileRequestsWhileZooming=!0===r.cancelPendingTileRequestsWhileZooming,void 0!==r.reduceMotion&&(a.prefersReducedMotion=r.reduceMotion),this._imageQueueHandle=_.addThrottleControl(()=>this.isMoving()),this._requestManager=new A(r.transformRequest),"string"==typeof r.container){if(this._container=document.getElementById(r.container),!this._container)throw new Error(`Container '${r.container}' not found.`)}else{if(!(r.container instanceof HTMLElement))throw new Error("Invalid type: 'container' must be a String or HTMLElement.");this._container=r.container}if(r.maxBounds&&this.setMaxBounds(r.maxBounds),this._setupContainer(),this._setupPainter(),this.on("move",()=>this._update(!1)),this.on("moveend",()=>this._update(!1)),this.on("zoom",()=>this._update(!0)),this.on("terrain",()=>{this.painter.terrainFacilitator.dirty=!0,this._update(!0)}),this.once("idle",()=>{this._idleTriggered=!0}),"undefined"!=typeof window){addEventListener("online",this._onWindowOnline,!1);let e=!1;const t=Vr(e=>{this._trackResize&&!this._removed&&(this.resize(e),this.redraw())},50);this._resizeObserver=new ResizeObserver(i=>{e?t(i):e=!0}),this._resizeObserver.observe(this._container)}this.handlers=new Go(this,r),this._hash=r.hash&&new jr("string"==typeof r.hash&&r.hash||void 0).addTo(this),this._hash&&this._hash._onHashChange()||(this.jumpTo({center:r.center,elevation:r.elevation,zoom:r.zoom,bearing:r.bearing,pitch:r.pitch,roll:r.roll}),r.bounds&&(this.resize(),this.fitBounds(r.bounds,t.e({},r.fitBoundsOptions,{duration:0}))));const l="string"==typeof r.style||!("globe"===(null===(n=null===(i=r.style)||void 0===i?void 0:i.projection)||void 0===n?void 0:n.type));this.resize(null,l),this._localIdeographFontFamily=r.localIdeographFontFamily,this._validateStyle=r.validateStyle,r.style&&this.setStyle(r.style,{localIdeographFontFamily:r.localIdeographFontFamily}),r.attributionControl&&this.addControl(new $o("boolean"==typeof r.attributionControl?void 0:r.attributionControl)),r.maplibreLogo&&this.addControl(new Zo,r.logoPosition),this.on("style.load",()=>{if(l||this._resizeTransform(),this.transform.unmodified){const e=t.U(this.style.stylesheet,["center","zoom","bearing","pitch","roll"]);this.jumpTo(e)}}),this.on("data",e=>{this._update("style"===e.dataType),this.fire(new t.l(`${e.dataType}data`,e))}),this.on("dataloading",e=>{this.fire(new t.l(`${e.dataType}dataloading`,e))}),this.on("dataabort",e=>{this.fire(new t.l("sourcedataabort",e))})}_getMapId(){return this._mapId}setGlobalStateProperty(e,t){return this.style.setGlobalStateProperty(e,t),this._update(!0)}getGlobalState(){return this.style.getGlobalState()}addControl(e,i){if(void 0===i&&(i=e.getDefaultPosition?e.getDefaultPosition():"top-right"),!e||!e.onAdd)return this.fire(new t.k(new Error("Invalid argument to map.addControl(). Argument must be a control with onAdd and onRemove methods.")));const n=e.onAdd(this);this._controls.push(e);const r=this._controlPositions[i];return-1!==i.indexOf("bottom")?r.insertBefore(n,r.firstChild):r.appendChild(n),this}removeControl(e){if(!e||!e.onRemove)return this.fire(new t.k(new Error("Invalid argument to map.removeControl(). Argument must be a control with onAdd and onRemove methods.")));const i=this._controls.indexOf(e);return i>-1&&this._controls.splice(i,1),e.onRemove(this),this}hasControl(e){return this._controls.indexOf(e)>-1}coveringTiles(e){return Ee(this.transform,e)}calculateCameraOptionsFromTo(e,t,i,n){return null==n&&this.terrain&&(n=this.terrain.getElevationForLngLatZoom(i,this.transform.tileZoom)),super.calculateCameraOptionsFromTo(e,t,i,n)}resize(e,i=!0){const[n,r]=this._containerDimensions(),o=this._getClampedPixelRatio(n,r);if(this._resizeCanvas(n,r,o),this.painter.resize(n,r,o),this.painter.overLimit()){const e=this.painter.context.gl;this._maxCanvasSize=[e.drawingBufferWidth,e.drawingBufferHeight];const t=this._getClampedPixelRatio(n,r);this._resizeCanvas(n,r,t),this.painter.resize(n,r,t)}this._resizeTransform(i);const s=!this._moving;return s&&(this.stop(),this.fire(new t.l("movestart",e)).fire(new t.l("move",e))),this.fire(new t.l("resize",e)),s&&this.fire(new t.l("moveend",e)),this}_resizeTransform(e=!0){var t;const[i,n]=this._containerDimensions();this.transform.resize(i,n,e),null===(t=this._requestedCameraState)||void 0===t||t.resize(i,n,e)}_getClampedPixelRatio(e,t){const{0:i,1:n}=this._maxCanvasSize,r=this.getPixelRatio(),o=e*r,s=t*r;return Math.min(o>i?i/o:1,s>n?n/s:1)*r}getPixelRatio(){var e;return null!==(e=this._overridePixelRatio)&&void 0!==e?e:devicePixelRatio}setPixelRatio(e){this._overridePixelRatio=e,this.resize()}getBounds(){return this.transform.getBounds()}getMaxBounds(){return this.transform.getMaxBounds()}setMaxBounds(e){return this.transform.setMaxBounds(Z.convert(e)),this._update()}setMinZoom(e){if((e=null==e?-2:e)>=-2&&e<=this.transform.maxZoom)return this.transform.setMinZoom(e),this._update(),this.getZoom()=this.transform.minZoom)return this.transform.setMaxZoom(e),this._update(),this.getZoom()>e&&this.setZoom(e),this;throw new Error("maxZoom must be greater than the current minZoom")}getMaxZoom(){return this.transform.maxZoom}setMinPitch(e){if((e=null==e?0:e)<0)throw new Error("minPitch must be greater than or equal to 0");if(e>=0&&e<=this.transform.maxPitch)return this.transform.setMinPitch(e),this._update(),this.getPitch()180)throw new Error("maxPitch must be less than or equal to 180");if(e>=this.transform.minPitch)return this.transform.setMaxPitch(e),this._update(),this.getPitch()>e&&this.setPitch(e),this;throw new Error("maxPitch must be greater than the current minPitch")}getMaxPitch(){return this.transform.maxPitch}getRenderWorldCopies(){return this.transform.renderWorldCopies}setRenderWorldCopies(e){return this.transform.setRenderWorldCopies(e),this._update()}setTransformConstrain(e){return this.transform.setConstrainOverride(e),this._update()}project(e){return this.transform.locationToScreenPoint(t.V.convert(e),this.style&&this.terrain)}unproject(e){return this.transform.screenPointToLocation(t.P.convert(e),this.terrain)}isMoving(){var e;return this._moving||(null===(e=this.handlers)||void 0===e?void 0:e.isMoving())}isZooming(){var e;return this._zooming||(null===(e=this.handlers)||void 0===e?void 0:e.isZooming())}isRotating(){var e;return this._rotating||(null===(e=this.handlers)||void 0===e?void 0:e.isRotating())}_createDelegatedListener(e,t,i){if("mouseenter"===e||"mouseover"===e){let n=!1;const r=r=>{const o=t.filter(e=>this.getLayer(e)),s=0!==o.length?this.queryRenderedFeatures(r.point,{layers:o}):[];s.length?n||(n=!0,i.call(this,new Jr(e,this,r.originalEvent,{features:s}))):n=!1};return{layers:t,listener:i,delegates:{mousemove:r,mouseout:()=>{n=!1}}}}if("mouseleave"===e||"mouseout"===e){let n=!1;const r=r=>{const o=t.filter(e=>this.getLayer(e));(0!==o.length?this.queryRenderedFeatures(r.point,{layers:o}):[]).length?n=!0:n&&(n=!1,i.call(this,new Jr(e,this,r.originalEvent)))},o=t=>{n&&(n=!1,i.call(this,new Jr(e,this,t.originalEvent)))};return{layers:t,listener:i,delegates:{mousemove:r,mouseout:o}}}{const n=e=>{const n=t.filter(e=>this.getLayer(e)),r=0!==n.length?this.queryRenderedFeatures(e.point,{layers:n}):[];r.length&&(e.features=r,i.call(this,e),delete e.features)};return{layers:t,listener:i,delegates:{[e]:n}}}}_saveDelegatedListener(e,t){this._delegatedListeners=this._delegatedListeners||{},this._delegatedListeners[e]=this._delegatedListeners[e]||[],this._delegatedListeners[e].push(t)}_removeDelegatedListener(e,t,i){if(!this._delegatedListeners||!this._delegatedListeners[e])return;const n=this._delegatedListeners[e];for(let e=0;et.includes(e))){for(const e in r.delegates)this.off(e,r.delegates[e]);return void n.splice(e,1)}}}on(e,t,i){if(void 0===i)return super.on(e,t);const n="string"==typeof t?[t]:t,r=this._createDelegatedListener(e,n,i);this._saveDelegatedListener(e,r);for(const e in r.delegates)this.on(e,r.delegates[e]);return{unsubscribe:()=>{this._removeDelegatedListener(e,n,i)}}}once(e,t,i){if(void 0===i)return super.once(e,t);const n="string"==typeof t?[t]:t,r=this._createDelegatedListener(e,n,i);for(const t in r.delegates){const o=r.delegates[t];r.delegates[t]=(...t)=>{this._removeDelegatedListener(e,n,i),o(...t)}}this._saveDelegatedListener(e,r);for(const e in r.delegates)this.once(e,r.delegates[e]);return this}off(e,t,i){return void 0===i?super.off(e,t):(this._removeDelegatedListener(e,"string"==typeof t?[t]:t,i),this)}queryRenderedFeatures(e,i){if(!this.style)return[];let n;const r=e instanceof t.P||Array.isArray(e),o=r?e:[[0,0],[this.transform.width,this.transform.height]];if(i=i||(r?{}:e)||{},o instanceof t.P||"number"==typeof o[0])n=[t.P.convert(o)];else{const e=t.P.convert(o[0]),i=t.P.convert(o[1]);n=[e,new t.P(i.x,e.y),i,new t.P(e.x,i.y),e]}return this.style.queryRenderedFeatures(n,i,this.transform)}querySourceFeatures(e,t){return this.style.querySourceFeatures(e,t)}setStyle(e,i){return!1!==(i=t.e({},{localIdeographFontFamily:this._localIdeographFontFamily,validate:this._validateStyle},i)).diff&&i.localIdeographFontFamily===this._localIdeographFontFamily&&this.style&&e?(this._diffStyle(e,i),this):(this._localIdeographFontFamily=i.localIdeographFontFamily,this._updateStyle(e,i))}setTransformRequest(e){return this._requestManager.setTransformRequest(e),this}_getUIString(e){const t=this._locale[e];if(null==t)throw new Error(`Missing UI string '${e}'`);return t}_updateStyle(e,t){var i,n;if(t.transformStyle&&this.style&&!this.style._loaded)return void this.style.once("style.load",()=>this._updateStyle(e,t));const r=this.style&&t.transformStyle?this.style.serialize():void 0;return this.style&&(this.style.setEventedParent(null),this.style._remove(!e)),e?(this.style=new Ii(this,t||{}),this.style.setEventedParent(this,{style:this.style}),"string"==typeof e?this.style.loadURL(e,t,r):this.style.loadJSON(e,t,r),this):(null===(n=null===(i=this.style)||void 0===i?void 0:i.projection)||void 0===n||n.destroy(),delete this.style,this)}_lazyInitEmptyStyle(){this.style||(this.style=new Ii(this,{}),this.style.setEventedParent(this,{style:this.style}),this.style.loadEmpty())}_diffStyle(e,i){if("string"==typeof e){const n=this._requestManager.transformRequest(e,"Style");t.j(n,new AbortController).then(e=>{this._updateDiff(e.data,i)}).catch(e=>{e&&this.fire(new t.k(e))})}else"object"==typeof e&&this._updateDiff(e,i)}_updateDiff(e,i){try{this.style.setState(e,i)&&this._update(!0)}catch(n){t.w(`Unable to perform style diff: ${n.message||n.error||n}. Rebuilding the style from scratch.`),this._updateStyle(e,i)}}getStyle(){if(this.style)return this.style.serialize()}_getStyleAndImages(){return this.style?{style:this.style.serialize(),images:this.style.imageManager.cloneImages()}:{style:null,images:{}}}isStyleLoaded(){return this.style?this.style.loaded():t.w("There is no style added to the map.")}addSource(e,t){return this._lazyInitEmptyStyle(),this.style.addSource(e,t),this._update(!0)}isSourceLoaded(e){const i=this.style&&this.style.tileManagers[e];if(void 0!==i)return i.loaded();this.fire(new t.k(new Error(`There is no tile manager with ID '${e}'`)))}setTerrain(e){if(this.style._checkLoaded(),this._terrainDataCallback&&this.style.off("data",this._terrainDataCallback),e){const i=this.style.tileManagers[e.source];if(!i)throw new Error(`cannot load terrain, because there exists no source with ID: ${e.source}`);null===this.terrain&&i.reload();for(const i in this.style._layers){const n=this.style._layers[i];"hillshade"===n.type&&n.source===e.source&&t.w("You are using the same source for a hillshade layer and for 3D terrain. Please consider using two separate sources to improve rendering quality."),"color-relief"===n.type&&n.source===e.source&&t.w("You are using the same source for a color-relief layer and for 3D terrain. Please consider using two separate sources to improve rendering quality.")}this.terrain=new Xo(this.painter,i,e),this.painter.renderToTexture=new es(this.painter,this.terrain),this.transform.setMinElevationForCurrentTile(this.terrain.getMinTileElevationForLngLatZoom(this.transform.center,this.transform.tileZoom)),this.transform.setElevation(this.terrain.getElevationForLngLatZoom(this.transform.center,this.transform.tileZoom)),this._terrainDataCallback=t=>{var i;"style"===t.dataType?this.terrain.tileManager.freeRtt():"source"===t.dataType&&t.tile&&(t.sourceId!==e.source||this._elevationFreeze||(this.transform.setMinElevationForCurrentTile(this.terrain.getMinTileElevationForLngLatZoom(this.transform.center,this.transform.tileZoom)),this._centerClampedToGround&&this.transform.setElevation(this.terrain.getElevationForLngLatZoom(this.transform.center,this.transform.tileZoom))),"image"===(null===(i=t.source)||void 0===i?void 0:i.type)?this.terrain.tileManager.freeRtt():this.terrain.tileManager.freeRtt(t.tile.tileID))},this.style.on("data",this._terrainDataCallback)}else this.terrain&&this.terrain.tileManager.destruct(),this.terrain=null,this.painter.renderToTexture&&this.painter.renderToTexture.destruct(),this.painter.renderToTexture=null,this.transform.setMinElevationForCurrentTile(0),this._centerClampedToGround&&this.transform.setElevation(0);return this.fire(new t.l("terrain",{terrain:e})),this}getTerrain(){var e,t;return null!==(t=null===(e=this.terrain)||void 0===e?void 0:e.options)&&void 0!==t?t:null}areTilesLoaded(){const e=this.style&&this.style.tileManagers;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}removeSource(e){return this.style.removeSource(e),this._update(!0)}getSource(e){return this.style.getSource(e)}setSourceTileLodParams(e,t,i){if(i){const n=this.getSource(i);if(!n)throw new Error(`There is no source with ID "${i}", cannot set LOD parameters`);n.calculateTileZoom=be(Math.max(1,e),Math.max(1,t))}else for(const i in this.style.tileManagers)this.style.tileManagers[i].getSource().calculateTileZoom=be(Math.max(1,e),Math.max(1,t));return this._update(!0),this}refreshTiles(e,i){const n=this.style.tileManagers[e];if(!n)throw new Error(`There is no tile manager with ID "${e}", cannot refresh tile`);void 0===i?n.reload(!0):n.refreshTiles(i.map(e=>new t.ad(e.z,e.x,e.y)))}addImage(e,i,n={}){const{pixelRatio:r=1,sdf:o=!1,stretchX:s,stretchY:l,content:c,textFitWidth:u,textFitHeight:h}=n;if(this._lazyInitEmptyStyle(),!(i instanceof HTMLImageElement||t.b(i))){if(void 0===i.width||void 0===i.height)return this.fire(new t.k(new Error("Invalid arguments to map.addImage(). The second argument must be an `HTMLImageElement`, `ImageData`, `ImageBitmap`, or object with `width`, `height`, and `data` properties with the same format as `ImageData`")));{const{width:n,height:a,data:d}=i,p=i;return this.style.addImage(e,{data:new t.R({width:n,height:a},new Uint8Array(d)),pixelRatio:r,stretchX:s,stretchY:l,content:c,textFitWidth:u,textFitHeight:h,sdf:o,version:0,userImage:p}),p.onAdd&&p.onAdd(this,e),this}}{const{width:n,height:d,data:p}=a.getImageData(i);this.style.addImage(e,{data:new t.R({width:n,height:d},p),pixelRatio:r,stretchX:s,stretchY:l,content:c,textFitWidth:u,textFitHeight:h,sdf:o,version:0})}}updateImage(e,i){const n=this.style.getImage(e);if(!n)return this.fire(new t.k(new Error("The map has no image with that id. If you are adding a new image use `map.addImage(...)` instead.")));const r=i instanceof HTMLImageElement||t.b(i)?a.getImageData(i):i,{width:o,height:s,data:l}=r;if(void 0===o||void 0===s)return this.fire(new t.k(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(o!==n.data.width||s!==n.data.height)return this.fire(new t.k(new Error("The width and height of the updated image must be that same as the previous version of the image")));const c=!(i instanceof HTMLImageElement||t.b(i));return n.data.replace(l,c),this.style.updateImage(e,n),this}getImage(e){return this.style.getImage(e)}hasImage(e){return e?!!this.style.getImage(e):(this.fire(new t.k(new Error("Missing required image id"))),!1)}removeImage(e){this.style.removeImage(e)}loadImage(e){return _.getImage(this._requestManager.transformRequest(e,"Image"),new AbortController)}listImages(){return this.style.listImages()}addLayer(e,t){return this._lazyInitEmptyStyle(),this.style.addLayer(e,t),this._update(!0)}moveLayer(e,t){return this.style.moveLayer(e,t),this._update(!0)}removeLayer(e){return this.style.removeLayer(e),this._update(!0)}getLayer(e){return this.style.getLayer(e)}getLayersOrder(){return this.style.getLayersOrder()}setLayerZoomRange(e,t,i){return this.style.setLayerZoomRange(e,t,i),this._update(!0)}setFilter(e,t,i={}){return this.style.setFilter(e,t,i),this._update(!0)}getFilter(e){return this.style.getFilter(e)}setPaintProperty(e,t,i,n={}){return this.style.setPaintProperty(e,t,i,n),this._update(!0)}getPaintProperty(e,t){return this.style.getPaintProperty(e,t)}setLayoutProperty(e,t,i,n={}){return this.style.setLayoutProperty(e,t,i,n),this._update(!0)}getLayoutProperty(e,t){return this.style.getLayoutProperty(e,t)}setGlyphs(e,t={}){return this._lazyInitEmptyStyle(),this.style.setGlyphs(e,t),this._update(!0)}getGlyphs(){return this.style.getGlyphsUrl()}addSprite(e,t,i={}){return this._lazyInitEmptyStyle(),this.style.addSprite(e,t,i,e=>{e||this._update(!0)}),this}removeSprite(e){return this._lazyInitEmptyStyle(),this.style.removeSprite(e),this._update(!0)}getSprite(){return this.style.getSprite()}setSprite(e,t={}){return this._lazyInitEmptyStyle(),this.style.setSprite(e,t,e=>{e||this._update(!0)}),this}setLight(e,t={}){return this._lazyInitEmptyStyle(),this.style.setLight(e,t),this._update(!0)}getLight(){return this.style.getLight()}setSky(e,t={}){return this._lazyInitEmptyStyle(),this.style.setSky(e,t),this._update(!0)}getSky(){return this.style.getSky()}setFeatureState(e,t){return this.style.setFeatureState(e,t),this._update()}removeFeatureState(e,t){return this.style.removeFeatureState(e,t),this._update()}getFeatureState(e){return this.style.getFeatureState(e)}getContainer(){return this._container}getCanvasContainer(){return this._canvasContainer}getCanvas(){return this._canvas}_containerDimensions(){let e=0,t=0;return this._container&&(e=this._container.clientWidth||400,t=this._container.clientHeight||300),[e,t]}_setupContainer(){const e=this._container;e.classList.add("maplibregl-map");const t=this._canvasContainer=u.create("div","maplibregl-canvas-container",e);this._interactive&&t.classList.add("maplibregl-interactive"),this._canvas=u.create("canvas","maplibregl-canvas",t),this._canvas.addEventListener("webglcontextlost",this._contextLost,!1),this._canvas.addEventListener("webglcontextrestored",this._contextRestored,!1),this._canvas.setAttribute("tabindex",this._interactive?"0":"-1"),this._canvas.setAttribute("aria-label",this._getUIString("Map.Title")),this._canvas.setAttribute("role","region");const i=this._containerDimensions(),n=this._getClampedPixelRatio(i[0],i[1]);this._resizeCanvas(i[0],i[1],n);const r=this._controlContainer=u.create("div","maplibregl-control-container",e),o=this._controlPositions={};["top-left","top-right","bottom-left","bottom-right"].forEach(e=>{o[e]=u.create("div",`maplibregl-ctrl-${e} `,r)}),this._container.addEventListener("scroll",this._onMapScroll,!1)}_resizeCanvas(e,t,i){this._canvas.width=Math.floor(i*e),this._canvas.height=Math.floor(i*t),this._canvas.style.width=`${e}px`,this._canvas.style.height=`${t}px`}_setupPainter(){const e=Object.assign(Object.assign({},this._canvasContextAttributes),{alpha:!0,depth:!0,stencil:!0,premultipliedAlpha:!0});let t=null;this._canvas.addEventListener("webglcontextcreationerror",i=>{t={requestedAttributes:e},i&&(t.statusMessage=i.statusMessage,t.type=i.type)},{once:!0});let i=null;if(i=this._canvasContextAttributes.contextType?this._canvas.getContext(this._canvasContextAttributes.contextType,e):this._canvas.getContext("webgl2",e)||this._canvas.getContext("webgl",e),!i){const e="Failed to initialize WebGL";throw t?(t.message=e,new Error(JSON.stringify(t))):new Error(e)}this.painter=new Nr(i,this.transform),h.testSupport(i)}migrateProjection(e,i){super.migrateProjection(e,i),this.painter.transform=e,this.fire(new t.l("projectiontransition",{newProjection:this.style.projection.name}))}loaded(){return!this._styleDirty&&!this._sourcesDirty&&!!this.style&&this.style.loaded()}_update(e){return this.style&&this.style._loaded?(this._styleDirty=this._styleDirty||e,this._sourcesDirty=!0,this.triggerRepaint(),this):this}_requestRenderFrame(e){return this._update(),this._renderTaskQueue.add(e)}_cancelRenderFrame(e){this._renderTaskQueue.remove(e)}_render(e){var i,n,r,o,s;const a=this._idleTriggered?this._fadeDuration:0,l=(null===(i=this.style.projection)||void 0===i?void 0:i.transitionState)>0;if(this.painter.context.setDirty(),this.painter.setBaseState(),this._renderTaskQueue.run(e),this._removed)return;let u=!1;if(this.style&&this._styleDirty){this._styleDirty=!1;const e=this.transform.zoom,i=c();this.style.zoomHistory.update(e,i);const n=new t.H(e,{now:i,fadeDuration:a,zoomHistory:this.style.zoomHistory,transition:this.style.getTransition()}),r=n.crossFadingFactor();1===r&&r===this._crossFadingFactor||(u=!0,this._crossFadingFactor=r),this.style.update(n)}const h=(null===(n=this.style.projection)||void 0===n?void 0:n.transitionState)>0!==l;null===(r=this.style.projection)||void 0===r||r.setErrorQueryLatitudeDegrees(this.transform.center.lat),this.transform.setTransitionState(null===(o=this.style.projection)||void 0===o?void 0:o.transitionState,null===(s=this.style.projection)||void 0===s?void 0:s.latitudeErrorCorrectionRadians),this.style&&(this._sourcesDirty||h)&&(this._sourcesDirty=!1,this.style._updateSources(this.transform)),this.terrain?(this.terrain.tileManager.update(this.transform,this.terrain),this.transform.setMinElevationForCurrentTile(this.terrain.getMinTileElevationForLngLatZoom(this.transform.center,this.transform.tileZoom)),!this._elevationFreeze&&this._centerClampedToGround&&this.transform.setElevation(this.terrain.getElevationForLngLatZoom(this.transform.center,this.transform.tileZoom))):(this.transform.setMinElevationForCurrentTile(0),this._centerClampedToGround&&this.transform.setElevation(0)),this._placementDirty=this.style&&this.style._updatePlacement(this.transform,this.showCollisionBoxes,a,this._crossSourceCollisions,h),this.painter.render(this.style,{showTileBoundaries:this.showTileBoundaries,showOverdrawInspector:this._showOverdrawInspector,rotating:this.isRotating(),zooming:this.isZooming(),moving:this.isMoving(),fadeDuration:a,showPadding:this.showPadding}),this.fire(new t.l("render")),this.loaded()&&!this._loaded&&(this._loaded=!0,t.cF.mark(t.cG.load),this.fire(new t.l("load"))),this.style&&(this.style.hasTransitions()||u)&&(this._styleDirty=!0),this.style&&!this._placementDirty&&this.style._releaseSymbolFadeTiles();const d=this._sourcesDirty||this._styleDirty||this._placementDirty;return d||this._repaint?this.triggerRepaint():!this.isMoving()&&this.loaded()&&this.fire(new t.l("idle")),!this._loaded||this._fullyLoaded||d||(this._fullyLoaded=!0,t.cF.mark(t.cG.fullLoad)),this}redraw(){return this.style&&(this._frameRequest&&(this._frameRequest.abort(),this._frameRequest=null),this._render(0)),this}remove(){var e;this._hash&&this._hash.remove();for(const e of this._controls)e.onRemove(this);this._controls=[],this._frameRequest&&(this._frameRequest.abort(),this._frameRequest=null),this._renderTaskQueue.clear(),this.painter.destroy(),this.handlers.destroy(),delete this.handlers,this.setStyle(null),"undefined"!=typeof window&&removeEventListener("online",this._onWindowOnline,!1),_.removeThrottleControl(this._imageQueueHandle),null===(e=this._resizeObserver)||void 0===e||e.disconnect();const i=this.painter.context.gl.getExtension("WEBGL_lose_context");(null==i?void 0:i.loseContext)&&i.loseContext(),this._canvas.removeEventListener("webglcontextrestored",this._contextRestored,!1),this._canvas.removeEventListener("webglcontextlost",this._contextLost,!1),u.remove(this._canvasContainer),u.remove(this._controlContainer),this._container.removeEventListener("scroll",this._onMapScroll,!1),this._container.classList.remove("maplibregl-map"),t.cF.clearMetrics(),this._removed=!0,this.fire(new t.l("remove"))}triggerRepaint(){this.style&&!this._frameRequest&&(this._frameRequest=new AbortController,a.frame(this._frameRequest,e=>{t.cF.frame(e),this._frameRequest=null;try{this._render(e)}catch(e){if(!t.cH(e)&&!function(e){return e.message===er}(e))throw e}},()=>{}))}get showTileBoundaries(){return!!this._showTileBoundaries}set showTileBoundaries(e){this._showTileBoundaries!==e&&(this._showTileBoundaries=e,this._update())}get showPadding(){return!!this._showPadding}set showPadding(e){this._showPadding!==e&&(this._showPadding=e,this._update())}get showCollisionBoxes(){return!!this._showCollisionBoxes}set showCollisionBoxes(e){this._showCollisionBoxes!==e&&(this._showCollisionBoxes=e,e?this.style._generateCollisionBoxes():this._update())}get showOverdrawInspector(){return!!this._showOverdrawInspector}set showOverdrawInspector(e){this._showOverdrawInspector!==e&&(this._showOverdrawInspector=e,this._update())}get repaint(){return!!this._repaint}set repaint(e){this._repaint!==e&&(this._repaint=e,this.triggerRepaint())}get vertices(){return!!this._vertices}set vertices(e){this._vertices=e,this._update()}get version(){return is}getCameraTargetElevation(){return this.transform.elevation}getProjection(){return this.style.getProjection()}setProjection(e){return this._lazyInitEmptyStyle(),this.style.setProjection(e),this._update(!0)}},e.MapMouseEvent=Jr,e.MapTouchEvent=Yr,e.MapWheelEvent=eo,e.Marker=us,e.NavigationControl=class{constructor(e){this._updateZoomButtons=()=>{const e=this._map.getZoom(),t=e===this._map.getMaxZoom(),i=e===this._map.getMinZoom();this._zoomInButton.disabled=t,this._zoomOutButton.disabled=i,this._zoomInButton.setAttribute("aria-disabled",t.toString()),this._zoomOutButton.setAttribute("aria-disabled",i.toString())},this._rotateCompassArrow=()=>{this._compassIcon.style.transform=this.options.visualizePitch&&this.options.visualizeRoll?`scale(${1/Math.pow(Math.cos(this._map.transform.pitchInRadians),.5)}) rotateZ(${-this._map.transform.roll}deg) rotateX(${this._map.transform.pitch}deg) rotateZ(${-this._map.transform.bearing}deg)`:this.options.visualizePitch?`scale(${1/Math.pow(Math.cos(this._map.transform.pitchInRadians),.5)}) rotateX(${this._map.transform.pitch}deg) rotateZ(${-this._map.transform.bearing}deg)`:this.options.visualizeRoll?`rotate(${-this._map.transform.bearing-this._map.transform.roll}deg)`:`rotate(${-this._map.transform.bearing}deg)`},this._setButtonTitle=(e,t)=>{const i=this._map._getUIString(`NavigationControl.${t}`);e.title=i,e.setAttribute("aria-label",i)},this.options=t.e({},rs,e),this._container=u.create("div","maplibregl-ctrl maplibregl-ctrl-group"),this._container.addEventListener("contextmenu",e=>e.preventDefault()),this.options.showZoom&&(this._zoomInButton=this._createButton("maplibregl-ctrl-zoom-in",e=>this._map.zoomIn({},{originalEvent:e})),u.create("span","maplibregl-ctrl-icon",this._zoomInButton).setAttribute("aria-hidden","true"),this._zoomOutButton=this._createButton("maplibregl-ctrl-zoom-out",e=>this._map.zoomOut({},{originalEvent:e})),u.create("span","maplibregl-ctrl-icon",this._zoomOutButton).setAttribute("aria-hidden","true")),this.options.showCompass&&(this._compass=this._createButton("maplibregl-ctrl-compass",e=>{this.options.visualizePitch?this._map.resetNorthPitch({},{originalEvent:e}):this._map.resetNorth({},{originalEvent:e})}),this._compassIcon=u.create("span","maplibregl-ctrl-icon",this._compass),this._compassIcon.setAttribute("aria-hidden","true"))}onAdd(e){return this._map=e,this.options.showZoom&&(this._setButtonTitle(this._zoomInButton,"ZoomIn"),this._setButtonTitle(this._zoomOutButton,"ZoomOut"),this._map.on("zoom",this._updateZoomButtons),this._updateZoomButtons()),this.options.showCompass&&(this._setButtonTitle(this._compass,"ResetBearing"),this.options.visualizePitch&&this._map.on("pitch",this._rotateCompassArrow),this.options.visualizeRoll&&this._map.on("roll",this._rotateCompassArrow),this._map.on("rotate",this._rotateCompassArrow),this._rotateCompassArrow(),this._handler=new os(this._map,this._compass,this.options.visualizePitch)),this._container}onRemove(){u.remove(this._container),this.options.showZoom&&this._map.off("zoom",this._updateZoomButtons),this.options.showCompass&&(this.options.visualizePitch&&this._map.off("pitch",this._rotateCompassArrow),this.options.visualizeRoll&&this._map.off("roll",this._rotateCompassArrow),this._map.off("rotate",this._rotateCompassArrow),this._handler.off(),delete this._handler),delete this._map}_createButton(e,t){const i=u.create("button",e,this._container);return i.type="button",i.addEventListener("click",t),i}},e.Popup=class extends t.E{constructor(e){super(),this._updateOpacity=()=>{void 0!==this.options.locationOccludedOpacity&&(this._container.style.opacity=this._map.transform.isLocationOccluded(this.getLngLat())?`${this.options.locationOccludedOpacity}`:"")},this.remove=()=>(this._content&&u.remove(this._content),this._container&&(u.remove(this._container),delete this._container),this._map&&(this._map.off("move",this._update),this._map.off("move",this._onClose),this._map.off("click",this._onClose),this._map.off("remove",this.remove),this._map.off("mousemove",this._onMouseMove),this._map.off("mouseup",this._onMouseUp),this._map.off("drag",this._onDrag),this._map._canvasContainer.classList.remove("maplibregl-track-pointer"),delete this._map,this.fire(new t.l("close"))),this),this._onMouseUp=e=>{this._update(e.point)},this._onMouseMove=e=>{this._update(e.point)},this._onDrag=e=>{this._update(e.point)},this._update=e=>{if(!this._map||!this._lngLat&&!this._trackPointer||!this._content)return;if(!this._container){if(this._container=u.create("div","maplibregl-popup",this._map.getContainer()),this._tip=u.create("div","maplibregl-popup-tip",this._container),this._container.appendChild(this._content),this.options.className)for(const e of this.options.className.split(" "))this._container.classList.add(e);this._closeButton&&this._closeButton.setAttribute("aria-label",this._map._getUIString("Popup.Close")),this._trackPointer&&this._container.classList.add("maplibregl-popup-track-pointer")}if(this.options.maxWidth&&this._container.style.maxWidth!==this.options.maxWidth&&(this._container.style.maxWidth=this.options.maxWidth),this._lngLat=as(this._lngLat,this._flatPos,this._map.transform,this._trackPointer),this._trackPointer&&!e)return;const t=this._flatPos=this._pos=this._trackPointer&&e?e:this._map.project(this._lngLat);this._map.terrain&&(this._flatPos=this._trackPointer&&e?e:this._map.transform.locationToScreenPoint(this._lngLat));let i=this.options.anchor;const n=ys(this.options.offset);if(!i){const e=this._container.offsetWidth,r=this._container.offsetHeight;let o;o=t.y+n.bottom.ythis._map.transform.height-r?["bottom"]:[],t.xthis._map.transform.width-e/2&&o.push("right"),i=0===o.length?"bottom":o.join("-")}let r=t.add(n[i]);this.options.subpixelPositioning||(r=r.round()),u.setTransform(this._container,`${ls[i]} translate(${r.x}px,${r.y}px)`),cs(this._container,i,"popup"),this._updateOpacity()},this._onClose=()=>{this.remove()},this.options=t.e(Object.create(_s),e)}addTo(e){return this._map&&this.remove(),this._map=e,this.options.closeOnClick&&this._map.on("click",this._onClose),this.options.closeOnMove&&this._map.on("move",this._onClose),this._map.on("remove",this.remove),this._update(),this._focusFirstElement(),this._trackPointer?(this._map.on("mousemove",this._onMouseMove),this._map.on("mouseup",this._onMouseUp),this._container&&this._container.classList.add("maplibregl-popup-track-pointer"),this._map._canvasContainer.classList.add("maplibregl-track-pointer")):this._map.on("move",this._update),this.fire(new t.l("open")),this}isOpen(){return!!this._map}getLngLat(){return this._lngLat}setLngLat(e){return this._lngLat=t.V.convert(e),this._pos=null,this._flatPos=null,this._trackPointer=!1,this._update(),this._map&&(this._map.on("move",this._update),this._map.off("mousemove",this._onMouseMove),this._container&&this._container.classList.remove("maplibregl-popup-track-pointer"),this._map._canvasContainer.classList.remove("maplibregl-track-pointer")),this}trackPointer(){return this._trackPointer=!0,this._pos=null,this._flatPos=null,this._update(),this._map&&(this._map.off("move",this._update),this._map.on("mousemove",this._onMouseMove),this._map.on("drag",this._onDrag),this._container&&this._container.classList.add("maplibregl-popup-track-pointer"),this._map._canvasContainer.classList.add("maplibregl-track-pointer")),this}getElement(){return this._container}setText(e){return this.setDOMContent(document.createTextNode(e))}setHTML(e){const t=document.createDocumentFragment(),i=document.createElement("body");let n;for(i.innerHTML=e;n=i.firstChild,n;)t.appendChild(n);return this.setDOMContent(t)}getMaxWidth(){var e;return null===(e=this._container)||void 0===e?void 0:e.style.maxWidth}setMaxWidth(e){return this.options.maxWidth=e,this._update(),this}setDOMContent(e){if(this._content)for(;this._content.hasChildNodes();)this._content.firstChild&&this._content.removeChild(this._content.firstChild);else this._content=u.create("div","maplibregl-popup-content",this._container);return this._content.appendChild(e),this._createCloseButton(),this._update(),this._focusFirstElement(),this}addClassName(e){return this._container&&this._container.classList.add(e),this}removeClassName(e){return this._container&&this._container.classList.remove(e),this}setOffset(e){return this.options.offset=e,this._update(),this}toggleClassName(e){if(this._container)return this._container.classList.toggle(e)}setSubpixelPositioning(e){this.options.subpixelPositioning=e}_createCloseButton(){this.options.closeButton&&(this._closeButton=u.create("button","maplibregl-popup-close-button",this._content),this._closeButton.type="button",this._closeButton.innerHTML="×",this._closeButton.addEventListener("click",this._onClose))}_focusFirstElement(){if(!this.options.focusAfterOpen||!this._container)return;const e=this._container.querySelector(As);e&&e.focus()}},e.RasterDEMTileSource=X,e.RasterTileSource=K,e.ScaleControl=class{constructor(e){this._onMove=()=>{ms(this._map,this._container,this.options)},this.setUnit=e=>{this.options.unit=e,ms(this._map,this._container,this.options)},this.options=Object.assign(Object.assign({},fs),e)}getDefaultPosition(){return"bottom-left"}onAdd(e){return this._map=e,this._container=u.create("div","maplibregl-ctrl maplibregl-ctrl-scale",e.getContainer()),this._map.on("move",this._onMove),this._onMove(),this._container}onRemove(){u.remove(this._container),this._map.off("move",this._onMove),this._map=void 0}},e.ScrollZoomHandler=Ro,e.Style=Ii,e.TerrainControl=class{constructor(e){this._toggleTerrain=()=>{this._map.getTerrain()?this._map.setTerrain(null):this._map.setTerrain(this.options),this._updateTerrainIcon()},this._updateTerrainIcon=()=>{this._terrainButton.classList.remove("maplibregl-ctrl-terrain"),this._terrainButton.classList.remove("maplibregl-ctrl-terrain-enabled"),this._map.terrain?(this._terrainButton.classList.add("maplibregl-ctrl-terrain-enabled"),this._terrainButton.title=this._map._getUIString("TerrainControl.Disable")):(this._terrainButton.classList.add("maplibregl-ctrl-terrain"),this._terrainButton.title=this._map._getUIString("TerrainControl.Enable"))},this.options=e}onAdd(e){return this._map=e,this._container=u.create("div","maplibregl-ctrl maplibregl-ctrl-group"),this._terrainButton=u.create("button","maplibregl-ctrl-terrain",this._container),u.create("span","maplibregl-ctrl-icon",this._terrainButton).setAttribute("aria-hidden","true"),this._terrainButton.type="button",this._terrainButton.addEventListener("click",this._toggleTerrain),this._updateTerrainIcon(),this._map.on("terrain",this._updateTerrainIcon),this._container}onRemove(){u.remove(this._container),this._map.off("terrain",this._updateTerrainIcon),this._map=void 0}},e.TwoFingersTouchPitchHandler=Co,e.TwoFingersTouchRotateHandler=To,e.TwoFingersTouchZoomHandler=bo,e.TwoFingersTouchZoomRotateHandler=zo,e.VectorTileSource=q,e.VideoSource=ie,e.addSourceType=(e,i)=>t._(void 0,void 0,void 0,function*(){if(oe(e))throw new Error(`A source type called "${e}" already exists.`);((e,t)=>{re[e]=t})(e,i)}),e.clearPrewarmedResources=function(){const e=O;e&&(e.isPreloaded()&&1===e.numActive()?(e.release(F),O=null):console.warn("Could not clear WebWorkers since there are active Map instances that still reference it. The pre-warmed WebWorker pool can only be cleared when all map instances have been removed with map.remove()"))},e.createTileMesh=ii,e.getMaxParallelImageRequests=function(){return t.a.MAX_PARALLEL_IMAGE_REQUESTS},e.getRTLTextPluginStatus=function(){return ce().getRTLTextPluginStatus()},e.getVersion=function(){return vs},e.getWorkerCount=function(){return k.workerCount},e.getWorkerUrl=function(){return t.a.WORKER_URL},e.importScriptInWorkers=function(e){return V().broadcast("IS",e)},e.isTimeFrozen=function(){return l.isFrozen()},e.now=c,e.prewarm=function(){U().acquire(F)},e.restoreNow=function(){l.restoreNow()},e.setMaxParallelImageRequests=function(e){t.a.MAX_PARALLEL_IMAGE_REQUESTS=e},e.setNow=function(e){l.setNow(e)},e.setRTLTextPlugin=function(e,t){return ce().setRTLTextPlugin(e,t)},e.setWorkerCount=function(e){k.workerCount=e},e.setWorkerUrl=function(e){t.a.WORKER_URL=e}});var n=e;return n}();var Ke=He(qe.exports),Xe=e({__proto__:null,default:Ke},[qe.exports]);const Je=[];function Ye(e,i=t){let n;const r=new Set;function o(t){if(a(e,t)&&(e=t,n)){const t=!Je.length;for(const t of r)t[1](),Je.push(t,e);if(t){for(let e=0;e{r.delete(l),0===r.size&&n&&(n(),n=null)}}}}const et=Ye([]),tt=Ye([]),it=Ye([]),nt=Ye(!0),rt=Ye(!0),ot=Ye([]),st=Ye({}),at=e=>{if(!Array.isArray(e))return!1;const t=["id","name","type"],i=e=>{const i=Object.keys(e);return t.filter(e=>!i.includes(e)).length>0};return!(e.filter(e=>"sublist"===e.type?e.presets.every(i):i(e)).length>0)},lt=(e,t)=>Math.round(e*10**t)/10**t;var ct="Expected a function",ut=/^\s+|\s+$/g,ht=/^[-+]0x[0-9a-f]+$/i,dt=/^0b[01]+$/i,pt=/^0o[0-7]+$/i,ft=parseInt,mt="object"==typeof Ge&&Ge&&Ge.Object===Object&&Ge,gt="object"==typeof self&&self&&self.Object===Object&&self,_t=mt||gt||Function("return this")(),At=Object.prototype.toString,yt=Math.max,vt=Math.min,xt=function(){return _t.Date.now()};function bt(e,t,i){var n,r,o,s,a,l,c=0,u=!1,h=!1,d=!0;if("function"!=typeof e)throw new TypeError(ct);function p(t){var i=n,o=r;return n=r=void 0,c=t,s=e.apply(o,i)}function f(e){var i=e-l;return void 0===l||i>=t||i<0||h&&e-c>=o}function m(){var e=xt();if(f(e))return g(e);a=setTimeout(m,function(e){var i=t-(e-l);return h?vt(i,o-(e-c)):i}(e))}function g(e){return a=void 0,d&&n?p(e):(n=r=void 0,s)}function _(){var e=xt(),i=f(e);if(n=arguments,r=this,l=e,i){if(void 0===a)return function(e){return c=e,a=setTimeout(m,t),u?p(e):s}(l);if(h)return a=setTimeout(m,t),p(l)}return void 0===a&&(a=setTimeout(m,t)),s}return t=Tt(t)||0,wt(i)&&(u=!!i.leading,o=(h="maxWait"in i)?yt(Tt(i.maxWait)||0,t):o,d="trailing"in i?!!i.trailing:d),_.cancel=function(){void 0!==a&&clearTimeout(a),c=0,n=l=r=a=void 0},_.flush=function(){return void 0===a?s:g(xt())},_}function wt(e){var t=typeof e;return!!e&&("object"==t||"function"==t)}function Tt(e){if("number"==typeof e)return e;if(function(e){return"symbol"==typeof e||function(e){return!!e&&"object"==typeof e}(e)&&"[object Symbol]"==At.call(e)}(e))return NaN;if(wt(e)){var t="function"==typeof e.valueOf?e.valueOf():e;e=wt(t)?t+"":t}if("string"!=typeof e)return 0===e?e:+e;e=e.replace(ut,"");var i=dt.test(e);return i||pt.test(e)?ft(e.slice(2),i?2:8):ht.test(e)?NaN:+e}var Et,Ct=function(e,t,i){var n=!0,r=!0;if("function"!=typeof e)throw new TypeError(ct);return wt(i)&&(n="leading"in i?!!i.leading:n,r="trailing"in i?!!i.trailing:r),bt(e,t,{leading:n,maxWait:t,trailing:r})},St=Object.prototype.toString,Bt=function(e){var t=St.call(e),i="[object Arguments]"===t;return i||(i="[object Array]"!==t&&null!==e&&"object"==typeof e&&"number"==typeof e.length&&e.length>=0&&"[object Function]"===St.call(e.callee)),i};if(!Object.keys){var It=Object.prototype.hasOwnProperty,Mt=Object.prototype.toString,Pt=Bt,Rt=Object.prototype.propertyIsEnumerable,Lt=!Rt.call({toString:null},"toString"),Ft=Rt.call(function(){},"prototype"),kt=["toString","toLocaleString","valueOf","hasOwnProperty","isPrototypeOf","propertyIsEnumerable","constructor"],Dt=function(e){var t=e.constructor;return t&&t.prototype===e},Ot={$applicationCache:!0,$console:!0,$external:!0,$frame:!0,$frameElement:!0,$frames:!0,$innerHeight:!0,$innerWidth:!0,$onmozfullscreenchange:!0,$onmozfullscreenerror:!0,$outerHeight:!0,$outerWidth:!0,$pageXOffset:!0,$pageYOffset:!0,$parent:!0,$scrollLeft:!0,$scrollTop:!0,$scrollX:!0,$scrollY:!0,$self:!0,$webkitIndexedDB:!0,$webkitStorageInfo:!0,$window:!0},zt=function(){if("undefined"==typeof window)return!1;for(var e in window)try{if(!Ot["$"+e]&&It.call(window,e)&&null!==window[e]&&"object"==typeof window[e])try{Dt(window[e])}catch(e){return!0}}catch(e){return!0}return!1}();Et=function(e){var t=null!==e&&"object"==typeof e,i="[object Function]"===Mt.call(e),n=Pt(e),r=t&&"[object String]"===Mt.call(e),o=[];if(!t&&!i&&!n)throw new TypeError("Object.keys called on a non-object");var s=Ft&&i;if(r&&e.length>0&&!It.call(e,0))for(var a=0;a0)for(var l=0;l3&&"boolean"!=typeof arguments[3]&&null!==arguments[3])throw new ei("`nonEnumerable`, if provided, must be a boolean or null");if(arguments.length>4&&"boolean"!=typeof arguments[4]&&null!==arguments[4])throw new ei("`nonWritable`, if provided, must be a boolean or null");if(arguments.length>5&&"boolean"!=typeof arguments[5]&&null!==arguments[5])throw new ei("`nonConfigurable`, if provided, must be a boolean or null");if(arguments.length>6&&"boolean"!=typeof arguments[6])throw new ei("`loose`, if provided, must be a boolean");var n=arguments.length>3?arguments[3]:null,r=arguments.length>4?arguments[4]:null,o=arguments.length>5?arguments[5]:null,s=arguments.length>6&&arguments[6],a=!!ti&&ti(e,t);if(Jt)Jt(e,t,{configurable:null===o&&a?a.configurable:!o,enumerable:null===n&&a?a.enumerable:!n,value:i,writable:null===r&&a?a.writable:!r});else{if(!s&&(n||r||o))throw new Yt("This environment does not support defining a property as non-configurable, non-writable, or non-enumerable.");e[t]=i}},ni=Zt,ri=function(){return!!ni};ri.hasArrayLengthDefineBug=function(){if(!ni)return null;try{return 1!==ni([],"length",{value:1}).length}catch(e){return!0}};var oi=ri,si=Qt,ai="function"==typeof Symbol&&"symbol"==typeof Symbol("foo"),li=Object.prototype.toString,ci=Array.prototype.concat,ui=ii,hi=oi(),di=function(e,t,i,n){if(t in e)if(!0===n){if(e[t]===i)return}else if(!function(e){return"function"==typeof e&&"[object Function]"===li.call(e)}(n)||!n())return;hi?ui(e,t,i,!0):ui(e,t,i)},pi=function(e,t){var i=arguments.length>2?arguments[2]:{},n=si(t);ai&&(n=ci.call(n,Object.getOwnPropertySymbols(t)));for(var r=0;r1&&"boolean"!=typeof t)throw new yn('"allowMissing" argument must be a boolean');if(null===Jn(/^%?[^%]*%?$/,e))throw new An("`%` may not be present anywhere but at the beginning and end of the intrinsic name");var i=function(e){var t=Xn(e,0,1),i=Xn(e,-1);if("%"===t&&"%"!==i)throw new An("invalid intrinsic syntax, expected closing `%`");if("%"===i&&"%"!==t)throw new An("invalid intrinsic syntax, expected opening `%`");var n=[];return Kn(e,Yn,function(e,t,i,r){n[n.length]=i?Kn(r,er,"$1"):t||e}),n}(e),n=i.length>0?i[0]:"",r=tr("%"+n+"%",t),o=r.name,s=r.value,a=!1,l=r.alias;l&&(n=l[0],qn(i,Wn([0,1],l)));for(var c=1,u=!0;c=i.length){var f=Mn(s,h);s=(u=!!f)&&"get"in f&&!("originalValue"in f.get)?f.get:s[h]}else u=Zn(s,h),s=s[h];u&&!a&&(jn[o]=s)}}return s},nr=ir,rr=ii,or=oi(),sr=Xt,ar=qt,lr=nr("%Math.floor%"),cr=function(e,t){if("function"!=typeof e)throw new ar("`fn` is not a function");if("number"!=typeof t||t<0||t>4294967295||lr(t)!==t)throw new ar("`length` must be a positive 32-bit integer");var i=arguments.length>2&&!!arguments[2],n=!0,r=!0;if("length"in e&&sr){var o=sr(e,"length");o&&!o.configurable&&(n=!1),o&&!o.writable&&(r=!1)}return(n||r||!i)&&(or?rr(e,"length",t,!0,!0):rr(e,"length",t)),e},ur=Vi,hr=Gi,dr=$i,pr=function(){return dr(ur,hr,arguments)};!function(e){var t=cr,i=Zt,n=Xi,r=pr;e.exports=function(e){var i=n(arguments),r=e.length-(arguments.length-1);return t(i,1+(r>0?r:0),!0)},i?i(e.exports,"apply",{value:r}):e.exports.apply=r}(gi);var fr=ir,mr=Xi,gr=mr([fr("%String.prototype.indexOf%")]),_r=function(e,t){var i=fr(e,!!t);return"function"==typeof i&&gr(e,".prototype.")>-1?mr([i]):i},Ar=Qt,yr=Pi(),vr=_r,xr=_i,br=vr("Array.prototype.push"),wr=vr("Object.prototype.propertyIsEnumerable"),Tr=yr?xr.getOwnPropertySymbols:null,Er=function(e,t){if(null==e)throw new TypeError("target must be an object");var i=xr(e);if(1===arguments.length)return i;for(var n=1;n2&&!!arguments[2]&&!$r||(Qr?Hr(e,"name",t,!0,!0):Hr(e,"name",t)),e},qr=qt,Kr=Object,Xr=Wr(function(){if(null==this||this!==Kr(this))throw new qr("RegExp.prototype.flags getter called on non-object");var e="";return this.hasIndices&&(e+="d"),this.global&&(e+="g"),this.ignoreCase&&(e+="i"),this.multiline&&(e+="m"),this.dotAll&&(e+="s"),this.unicode&&(e+="u"),this.unicodeSets&&(e+="v"),this.sticky&&(e+="y"),e},"get flags",!0),Jr=Xr,Yr=mi.supportsDescriptors,eo=Object.getOwnPropertyDescriptor,to=function(){if(Yr&&"gim"===/a/gim.flags){var e=eo(RegExp.prototype,"flags");if(e&&"function"==typeof e.get&&"dotAll"in RegExp.prototype&&"hasIndices"in RegExp.prototype){var t="",i={};if(Object.defineProperty(i,"hasIndices",{get:function(){t+="d"}}),Object.defineProperty(i,"sticky",{get:function(){t+="y"}}),e.get.call(i),"dy"===t)return e.get}}return Jr},io=mi.supportsDescriptors,no=to,ro=Xt,oo=Object.defineProperty,so=Ai,ao=cn,lo=/a/,co=mi,uo=Xr,ho=to,po=function(){if(!io||!ao)throw new so("RegExp.prototype.flags requires a true ES5 environment that supports property descriptors");var e=no(),t=ao(lo),i=ro(t,"flags");return i&&i.get===e||oo(t,"flags",{configurable:!0,enumerable:!1,get:e}),e},fo=(0,gi.exports)(ho());co(fo,{getPolyfill:ho,implementation:uo,shim:po});var mo=fo,go=Symbol.iterator,_o=Qe(Object.freeze({__proto__:null,default:{}})),Ao="function"==typeof Map&&Map.prototype,yo=Object.getOwnPropertyDescriptor&&Ao?Object.getOwnPropertyDescriptor(Map.prototype,"size"):null,vo=Ao&&yo&&"function"==typeof yo.get?yo.get:null,xo=Ao&&Map.prototype.forEach,bo="function"==typeof Set&&Set.prototype,wo=Object.getOwnPropertyDescriptor&&bo?Object.getOwnPropertyDescriptor(Set.prototype,"size"):null,To=bo&&wo&&"function"==typeof wo.get?wo.get:null,Eo=bo&&Set.prototype.forEach,Co="function"==typeof WeakMap&&WeakMap.prototype?WeakMap.prototype.has:null,So="function"==typeof WeakSet&&WeakSet.prototype?WeakSet.prototype.has:null,Bo="function"==typeof WeakRef&&WeakRef.prototype?WeakRef.prototype.deref:null,Io=Boolean.prototype.valueOf,Mo=Object.prototype.toString,Po=Function.prototype.toString,Ro=String.prototype.match,Lo=String.prototype.slice,Fo=String.prototype.replace,ko=String.prototype.toUpperCase,Do=String.prototype.toLowerCase,Oo=RegExp.prototype.test,zo=Array.prototype.concat,Uo=Array.prototype.join,No=Array.prototype.slice,Vo=Math.floor,jo="function"==typeof BigInt?BigInt.prototype.valueOf:null,Go=Object.getOwnPropertySymbols,Ho="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?Symbol.prototype.toString:null,Qo="function"==typeof Symbol&&"object"==typeof Symbol.iterator,$o="function"==typeof Symbol&&Symbol.toStringTag&&(typeof Symbol.toStringTag===Qo||"symbol")?Symbol.toStringTag:null,Zo=Object.prototype.propertyIsEnumerable,Wo=("function"==typeof Reflect?Reflect.getPrototypeOf:Object.getPrototypeOf)||([].__proto__===Array.prototype?function(e){return e.__proto__}:null);function qo(e,t){if(e===1/0||e===-1/0||e!=e||e&&e>-1e3&&e<1e3||Oo.call(/e/,t))return t;var i=/[0-9](?=(?:[0-9]{3})+(?![0-9]))/g;if("number"==typeof e){var n=e<0?-Vo(-e):Vo(e);if(n!==e){var r=String(n),o=Lo.call(t,r.length+1);return Fo.call(r,i,"$&_")+"."+Fo.call(Fo.call(o,/([0-9]{3})/g,"$&_"),/_$/,"")}}return Fo.call(t,i,"$&_")}var Ko=_o,Xo=Ko.custom,Jo=as(Xo)?Xo:null,Yo={__proto__:null,double:'"',single:"'"},es={__proto__:null,double:/(["\\])/g,single:/(['\\])/g},ts=function e(t,i,n,r){var o=i||{};if(cs(o,"quoteStyle")&&!cs(Yo,o.quoteStyle))throw new TypeError('option "quoteStyle" must be "single" or "double"');if(cs(o,"maxStringLength")&&("number"==typeof o.maxStringLength?o.maxStringLength<0&&o.maxStringLength!==1/0:null!==o.maxStringLength))throw new TypeError('option "maxStringLength", if provided, must be a positive integer, Infinity, or `null`');var s=!cs(o,"customInspect")||o.customInspect;if("boolean"!=typeof s&&"symbol"!==s)throw new TypeError("option \"customInspect\", if provided, must be `true`, `false`, or `'symbol'`");if(cs(o,"indent")&&null!==o.indent&&"\t"!==o.indent&&!(parseInt(o.indent,10)===o.indent&&o.indent>0))throw new TypeError('option "indent" must be "\\t", an integer > 0, or `null`');if(cs(o,"numericSeparator")&&"boolean"!=typeof o.numericSeparator)throw new TypeError('option "numericSeparator", if provided, must be `true` or `false`');var a=o.numericSeparator;if(void 0===t)return"undefined";if(null===t)return"null";if("boolean"==typeof t)return t?"true":"false";if("string"==typeof t)return ds(t,o);if("number"==typeof t){if(0===t)return 1/0/t>0?"0":"-0";var l=String(t);return a?qo(t,l):l}if("bigint"==typeof t){var c=String(t)+"n";return a?qo(t,c):c}var u=void 0===o.depth?5:o.depth;if(void 0===n&&(n=0),n>=u&&u>0&&"object"==typeof t)return os(t)?"[Array]":"[Object]";var h=function(e,t){var i;if("\t"===e.indent)i="\t";else{if(!("number"==typeof e.indent&&e.indent>0))return null;i=Uo.call(Array(e.indent+1)," ")}return{base:i,prev:Uo.call(Array(t+1),i)}}(o,n);if(void 0===r)r=[];else if(hs(r,t)>=0)return"[Circular]";function d(t,i,s){if(i&&(r=No.call(r)).push(i),s){var a={depth:o.depth};return cs(o,"quoteStyle")&&(a.quoteStyle=o.quoteStyle),e(t,a,n+1,r)}return e(t,o,n+1,r)}if("function"==typeof t&&!ss(t)){var p=function(e){if(e.name)return e.name;var t=Ro.call(Po.call(e),/^function\s*([\w$]+)/);if(t)return t[1];return null}(t),f=As(t,d);return"[Function"+(p?": "+p:" (anonymous)")+"]"+(f.length>0?" { "+Uo.call(f,", ")+" }":"")}if(as(t)){var m=Qo?Fo.call(String(t),/^(Symbol\(.*\))_[^)]*$/,"$1"):Ho.call(t);return"object"!=typeof t||Qo?m:fs(m)}if(function(e){if(!e||"object"!=typeof e)return!1;if("undefined"!=typeof HTMLElement&&e instanceof HTMLElement)return!0;return"string"==typeof e.nodeName&&"function"==typeof e.getAttribute}(t)){for(var g="<"+Do.call(String(t.nodeName)),_=t.attributes||[],A=0;A<_.length;A++)g+=" "+_[A].name+"="+is(ns(_[A].value),"double",o);return g+=">",t.childNodes&&t.childNodes.length&&(g+="..."),g+=""}if(os(t)){if(0===t.length)return"[]";var y=As(t,d);return h&&!function(e){for(var t=0;t=0)return!1;return!0}(y)?"["+_s(y,h)+"]":"[ "+Uo.call(y,", ")+" ]"}if(function(e){return"[object Error]"===us(e)&&rs(e)}(t)){var v=As(t,d);return"cause"in Error.prototype||!("cause"in t)||Zo.call(t,"cause")?0===v.length?"["+String(t)+"]":"{ ["+String(t)+"] "+Uo.call(v,", ")+" }":"{ ["+String(t)+"] "+Uo.call(zo.call("[cause]: "+d(t.cause),v),", ")+" }"}if("object"==typeof t&&s){if(Jo&&"function"==typeof t[Jo]&&Ko)return Ko(t,{depth:u-n});if("symbol"!==s&&"function"==typeof t.inspect)return t.inspect()}if(function(e){if(!vo||!e||"object"!=typeof e)return!1;try{vo.call(e);try{To.call(e)}catch(e){return!0}return e instanceof Map}catch(e){}return!1}(t)){var x=[];return xo&&xo.call(t,function(e,i){x.push(d(i,t,!0)+" => "+d(e,t))}),gs("Map",vo.call(t),x,h)}if(function(e){if(!To||!e||"object"!=typeof e)return!1;try{To.call(e);try{vo.call(e)}catch(e){return!0}return e instanceof Set}catch(e){}return!1}(t)){var b=[];return Eo&&Eo.call(t,function(e){b.push(d(e,t))}),gs("Set",To.call(t),b,h)}if(function(e){if(!Co||!e||"object"!=typeof e)return!1;try{Co.call(e,Co);try{So.call(e,So)}catch(e){return!0}return e instanceof WeakMap}catch(e){}return!1}(t))return ms("WeakMap");if(function(e){if(!So||!e||"object"!=typeof e)return!1;try{So.call(e,So);try{Co.call(e,Co)}catch(e){return!0}return e instanceof WeakSet}catch(e){}return!1}(t))return ms("WeakSet");if(function(e){if(!Bo||!e||"object"!=typeof e)return!1;try{return Bo.call(e),!0}catch(e){}return!1}(t))return ms("WeakRef");if(function(e){return"[object Number]"===us(e)&&rs(e)}(t))return fs(d(Number(t)));if(function(e){if(!e||"object"!=typeof e||!jo)return!1;try{return jo.call(e),!0}catch(e){}return!1}(t))return fs(d(jo.call(t)));if(function(e){return"[object Boolean]"===us(e)&&rs(e)}(t))return fs(Io.call(t));if(function(e){return"[object String]"===us(e)&&rs(e)}(t))return fs(d(String(t)));if("undefined"!=typeof window&&t===window)return"{ [object Window] }";if("undefined"!=typeof globalThis&&t===globalThis||void 0!==Ge&&t===Ge)return"{ [object globalThis] }";if(!function(e){return"[object Date]"===us(e)&&rs(e)}(t)&&!ss(t)){var w=As(t,d),T=Wo?Wo(t)===Object.prototype:t instanceof Object||t.constructor===Object,E=t instanceof Object?"":"null prototype",C=!T&&$o&&Object(t)===t&&$o in t?Lo.call(us(t),8,-1):E?"Object":"",S=(T||"function"!=typeof t.constructor?"":t.constructor.name?t.constructor.name+" ":"")+(C||E?"["+Uo.call(zo.call([],C||[],E||[]),": ")+"] ":"");return 0===w.length?S+"{}":h?S+"{"+_s(w,h)+"}":S+"{ "+Uo.call(w,", ")+" }"}return String(t)};function is(e,t,i){var n=i.quoteStyle||t,r=Yo[n];return r+e+r}function ns(e){return Fo.call(String(e),/"/g,""")}function rs(e){return!$o||!("object"==typeof e&&($o in e||void 0!==e[$o]))}function os(e){return"[object Array]"===us(e)&&rs(e)}function ss(e){return"[object RegExp]"===us(e)&&rs(e)}function as(e){if(Qo)return e&&"object"==typeof e&&e instanceof Symbol;if("symbol"==typeof e)return!0;if(!e||"object"!=typeof e||!Ho)return!1;try{return Ho.call(e),!0}catch(e){}return!1}var ls=Object.prototype.hasOwnProperty||function(e){return e in this};function cs(e,t){return ls.call(e,t)}function us(e){return Mo.call(e)}function hs(e,t){if(e.indexOf)return e.indexOf(t);for(var i=0,n=e.length;it.maxStringLength){var i=e.length-t.maxStringLength,n="... "+i+" more character"+(i>1?"s":"");return ds(Lo.call(e,0,t.maxStringLength),t)+n}var r=es[t.quoteStyle||"single"];return r.lastIndex=0,is(Fo.call(Fo.call(e,r,"\\$1"),/[\x00-\x1f]/g,ps),"single",t)}function ps(e){var t=e.charCodeAt(0),i={8:"b",9:"t",10:"n",12:"f",13:"r"}[t];return i?"\\"+i:"\\x"+(t<16?"0":"")+ko.call(t.toString(16))}function fs(e){return"Object("+e+")"}function ms(e){return e+" { ? }"}function gs(e,t,i,n){return e+" ("+t+") {"+(n?_s(i,n):Uo.call(i,", "))+"}"}function _s(e,t){if(0===e.length)return"";var i="\n"+t.prev+t.base;return i+Uo.call(e,","+i)+"\n"+t.prev}function As(e,t){var i=os(e),n=[];if(i){n.length=e.length;for(var r=0;r=0&&"[object Array]"!==sa(e)&&"callee"in e&&"[object Function]"===sa(e.callee)},ca=function(){return aa(arguments)}();aa.isLegacyArguments=la;var ua,ha=ca?aa:la,da={}.toString,pa=Array.isArray||function(e){return"[object Array]"==da.call(e)},fa=gi.exports,ma=_r,ga=ir("%ArrayBuffer%",!0),_a=ma("ArrayBuffer.prototype.byteLength",!0),Aa=ma("Object.prototype.toString"),ya=!!ga&&!_a&&new ga(0).slice,va=!!ya&&fa(ya),xa=_a||va?function(e){if(!e||"object"!=typeof e)return!1;try{return _a?_a(e):va(e,0),!0}catch(e){return!1}}:ga?function(e){return"[object ArrayBuffer]"===Aa(e)}:function(e){return!1},ba=_r,wa=ba("Date.prototype.getDay"),Ta=ba("Object.prototype.toString"),Ea=ra(),Ca=_r,Sa=ra(),Ba=dn,Ia=Xt;if(Sa){var Ma=Ca("RegExp.prototype.exec"),Pa={},Ra=function(){throw Pa},La={toString:Ra,valueOf:Ra};"symbol"==typeof Symbol.toPrimitive&&(La[Symbol.toPrimitive]=Ra),ua=function(e){if(!e||"object"!=typeof e)return!1;var t=Ia(e,"lastIndex");if(!(t&&Ba(t,"value")))return!1;try{Ma(e,La)}catch(e){return e===Pa}}}else{var Fa=Ca("Object.prototype.toString");ua=function(e){return!(!e||"object"!=typeof e&&"function"!=typeof e)&&"[object RegExp]"===Fa(e)}}var ka=ua,Da=_r("SharedArrayBuffer.prototype.byteLength",!0),Oa=Da?function(e){if(!e||"object"!=typeof e)return!1;try{return Da(e),!0}catch(e){return!1}}:function(e){return!1},za=_r,Ua=za("String.prototype.valueOf"),Na=za("Object.prototype.toString"),Va=ra(),ja=_r,Ga=ja("Number.prototype.toString"),Ha=ja("Object.prototype.toString"),Qa=ra(),$a=_r,Za=$a("Boolean.prototype.toString"),Wa=$a("Object.prototype.toString"),qa=ra(),Ka={exports:{}},Xa=ka,Ja=_r("RegExp.prototype.exec"),Ya=qt,el=_r,tl=el("Object.prototype.toString"),il=function(e){if(!Xa(e))throw new Ya("`regex` must be a RegExp");return function(t){return null!==Ja(e,t)}};if(Fi()){var nl=el("Symbol.prototype.toString"),rl=il(/^Symbol\(.*\)$/);Ka.exports=function(e){if("symbol"==typeof e)return!0;if(!e||"object"!=typeof e||"[object Symbol]"!==tl(e))return!1;try{return function(e){return"symbol"==typeof e.valueOf()&&rl(nl(e))}(e)}catch(e){return!1}}}else Ka.exports=function(e){return!1};var ol={exports:{}},sl="undefined"!=typeof BigInt&&BigInt;if("function"==typeof sl&&"function"==typeof BigInt&&"bigint"==typeof sl(42)&&"bigint"==typeof BigInt(42)){var al=BigInt.prototype.valueOf;ol.exports=function(e){return null!=e&&"boolean"!=typeof e&&"string"!=typeof e&&"number"!=typeof e&&"symbol"!=typeof e&&"function"!=typeof e&&("bigint"==typeof e||function(e){try{return al.call(e),!0}catch(e){}return!1}(e))}}else ol.exports=function(e){return!1};var ll,cl=function(e){return"string"==typeof e||!(!e||"object"!=typeof e)&&(Va?function(e){try{return Ua(e),!0}catch(e){return!1}}(e):"[object String]"===Na(e))},ul=function(e){return"number"==typeof e||!(!e||"object"!=typeof e)&&(Qa?function(e){try{return Ga(e),!0}catch(e){return!1}}(e):"[object Number]"===Ha(e))},hl=function(e){return"boolean"==typeof e||null!==e&&"object"==typeof e&&(qa?function(e){try{return Za(e),!0}catch(e){return!1}}(e):"[object Boolean]"===Wa(e))},dl=Ka.exports,pl=ol.exports,fl="function"==typeof Map&&Map.prototype?Map:null,ml="function"==typeof Set&&Set.prototype?Set:null;fl||(ll=function(e){return!1});var gl=fl?Map.prototype.has:null,_l=ml?Set.prototype.has:null;ll||gl||(ll=function(e){return!1});var Al,yl=ll||function(e){if(!e||"object"!=typeof e)return!1;try{if(gl.call(e),_l)try{_l.call(e)}catch(e){return!0}return e instanceof fl}catch(e){}return!1},vl="function"==typeof Map&&Map.prototype?Map:null,xl="function"==typeof Set&&Set.prototype?Set:null;xl||(Al=function(e){return!1});var bl=vl?Map.prototype.has:null,wl=xl?Set.prototype.has:null;Al||wl||(Al=function(e){return!1});var Tl,El=Al||function(e){if(!e||"object"!=typeof e)return!1;try{if(wl.call(e),bl)try{bl.call(e)}catch(e){return!0}return e instanceof xl}catch(e){}return!1},Cl="function"==typeof WeakMap&&WeakMap.prototype?WeakMap:null,Sl="function"==typeof WeakSet&&WeakSet.prototype?WeakSet:null;Cl||(Tl=function(e){return!1});var Bl=Cl?Cl.prototype.has:null,Il=Sl?Sl.prototype.has:null;Tl||Bl||(Tl=function(e){return!1});var Ml=Tl||function(e){if(!e||"object"!=typeof e)return!1;try{if(Bl.call(e,Bl),Il)try{Il.call(e,Il)}catch(e){return!0}return e instanceof Cl}catch(e){}return!1},Pl={exports:{}},Rl=_r,Ll=ir("%WeakSet%",!0),Fl=Rl("WeakSet.prototype.has",!0);if(Fl){var kl=Rl("WeakMap.prototype.has",!0);Pl.exports=function(e){if(!e||"object"!=typeof e)return!1;try{if(Fl(e,Fl),kl)try{kl(e,kl)}catch(e){return!0}return e instanceof Ll}catch(e){}return!1}}else Pl.exports=function(e){return!1};var Dl,Ol,zl=yl,Ul=El,Nl=Ml,Vl=Pl.exports,jl=Function.prototype.toString,Gl="object"==typeof Reflect&&null!==Reflect&&Reflect.apply;if("function"==typeof Gl&&"function"==typeof Object.defineProperty)try{Dl=Object.defineProperty({},"length",{get:function(){throw Ol}}),Ol={},Gl(function(){throw 42},null,Dl)}catch(L8){L8!==Ol&&(Gl=null)}else Gl=null;var Hl=/^\s*class\b/,Ql=function(e){try{var t=jl.call(e);return Hl.test(t)}catch(e){return!1}},$l=function(e){try{return!Ql(e)&&(jl.call(e),!0)}catch(e){return!1}},Zl=Object.prototype.toString,Wl="function"==typeof Symbol&&!!Symbol.toStringTag,ql=!(0 in[,]),Kl=function(){return!1};if("object"==typeof document){var Xl=document.all;Zl.call(Xl)===Zl.call(document.all)&&(Kl=function(e){if((ql||!e)&&(void 0===e||"object"==typeof e))try{var t=Zl.call(e);return("[object HTMLAllCollection]"===t||"[object HTML document.all class]"===t||"[object HTMLCollection]"===t||"[object Object]"===t)&&null==e("")}catch(e){}return!1})}var Jl=Gl?function(e){if(Kl(e))return!0;if(!e)return!1;if("function"!=typeof e&&"object"!=typeof e)return!1;try{Gl(e,null,Dl)}catch(e){if(e!==Ol)return!1}return!Ql(e)&&$l(e)}:function(e){if(Kl(e))return!0;if(!e)return!1;if("function"!=typeof e&&"object"!=typeof e)return!1;if(Wl)return $l(e);if(Ql(e))return!1;var t=Zl.call(e);return!("[object Function]"!==t&&"[object GeneratorFunction]"!==t&&!/^\[object HTML/.test(t))&&$l(e)},Yl=Jl,ec=Object.prototype.toString,tc=Object.prototype.hasOwnProperty;var ic=["Float16Array","Float32Array","Float64Array","Int8Array","Int16Array","Int32Array","Uint8Array","Uint8ClampedArray","Uint16Array","Uint32Array","BigInt64Array","BigUint64Array"],nc="undefined"==typeof globalThis?Ge:globalThis,rc=function(e,t,i){if(!Yl(t))throw new TypeError("iterator must be a function");var n;arguments.length>=3&&(n=i),function(e){return"[object Array]"===ec.call(e)}(e)?function(e,t,i){for(var n=0,r=e.length;n-1?zr(i):i},xc=mo,bc=ir,wc=function(e){if(null!=e&&void 0!==e[go])return e[go]()},Tc=function(){var e,t={assert:function(e){if(!t.has(e))throw new Vs("Side channel does not contain "+js(e))},delete:function(t){return!!e&&e.delete(t)},get:function(t){return e&&e.get(t)},has:function(t){return!!e&&e.has(t)},set:function(t,i){e||(e=Hs()),e.set(t,i)}};return t},Ec=ia,Cc=ha,Sc=pa,Bc=xa,Ic=function(e){return"object"==typeof e&&null!==e&&(Ea?function(e){try{return wa(e),!0}catch(e){return!1}}(e):"[object Date]"===Ta(e))},Mc=ka,Pc=Oa,Rc=Qt,Lc=function(e){return null==e||"object"!=typeof e&&"function"!=typeof e?null:cl(e)?"String":ul(e)?"Number":hl(e)?"Boolean":dl(e)?"Symbol":pl(e)?"BigInt":void 0},Fc=function(e){if(e&&"object"==typeof e){if(zl(e))return"Map";if(Ul(e))return"Set";if(Nl(e))return"WeakMap";if(Vl(e))return"WeakSet"}return!1},kc=function(e){if(!e||"object"!=typeof e)return!1;if(!hc){var t=fc(uc(e),8,-1);return mc(pc,t)>-1?t:"Object"===t&&function(e){var t=!1;return rc(gc,function(i,n){if(!t)try{i(e),t=fc(n,1)}catch(e){}}),t}(e)}return lc?function(e){var t=!1;return rc(gc,function(i,n){if(!t)try{"$"+i(e)===n&&(t=fc(n,1))}catch(e){}}),t}(e):null},Dc=function(e){return Ac(e)?_c?_c(e):e.byteLength:NaN},Oc=vc("SharedArrayBuffer.prototype.byteLength",!0),zc=vc("Date.prototype.getTime"),Uc=Object.getPrototypeOf,Nc=vc("Object.prototype.toString"),Vc=bc("%Set%",!0),jc=vc("Map.prototype.has",!0),Gc=vc("Map.prototype.get",!0),Hc=vc("Map.prototype.size",!0),Qc=vc("Set.prototype.add",!0),$c=vc("Set.prototype.delete",!0),Zc=vc("Set.prototype.has",!0),Wc=vc("Set.prototype.size",!0);function qc(e,t,i,n){for(var r,o=wc(e);(r=o.next())&&!r.done;)if(eu(t,r.value,i,n))return $c(e,r.value),!0;return!1}function Kc(e){return void 0===e?null:"object"!=typeof e?"symbol"!=typeof e&&("string"!=typeof e&&"number"!=typeof e||+e==+e):void 0}function Xc(e,t,i,n,r,o){var s=Kc(i);if(null!=s)return s;var a=Gc(t,s),l=yc({},r,{strict:!1});return!(void 0===a&&!jc(t,s)||!eu(n,a,l,o))&&(!jc(e,s)&&eu(n,a,l,o))}function Jc(e,t,i){var n=Kc(i);return null!=n?n:Zc(t,n)&&!Zc(e,n)}function Yc(e,t,i,n,r,o){for(var s,a,l=wc(e);(s=l.next())&&!s.done;)if(eu(i,a=s.value,r,o)&&eu(n,Gc(t,a),r,o))return $c(e,a),!0;return!1}function eu(e,t,i,n){var r=i||{};if(r.strict?Ec(e,t):e===t)return!0;if(Lc(e)!==Lc(t))return!1;if(!e||!t||"object"!=typeof e&&"object"!=typeof t)return r.strict?Ec(e,t):e==t;var o,s=n.has(e),a=n.has(t);if(s&&a){if(n.get(e)===n.get(t))return!0}else o={};return s||n.set(e,o),a||n.set(t,o),function(e,t,i,n){var r,o;if(typeof e!=typeof t)return!1;if(null==e||null==t)return!1;if(Nc(e)!==Nc(t))return!1;if(Cc(e)!==Cc(t))return!1;var s=Sc(e),a=Sc(t);if(s!==a)return!1;var l=e instanceof Error,c=t instanceof Error;if(l!==c)return!1;if((l||c)&&(e.name!==t.name||e.message!==t.message))return!1;var u=Mc(e),h=Mc(t);if(u!==h)return!1;if((u||h)&&(e.source!==t.source||xc(e)!==xc(t)))return!1;var d=Ic(e),p=Ic(t);if(d!==p)return!1;if((d||p)&&zc(e)!==zc(t))return!1;if(i.strict&&Uc&&Uc(e)!==Uc(t))return!1;var f=kc(e),m=kc(t);if(f!==m)return!1;if(f||m){if(e.length!==t.length)return!1;for(r=0;r=0;r--)if(b[r]!=w[r])return!1;for(r=b.length-1;r>=0;r--)if(!eu(e[o=b[r]],t[o],i,n))return!1;var T=Fc(e),E=Fc(t);if(T!==E)return!1;if("Set"===T||"Set"===E)return function(e,t,i,n){if(Wc(e)!==Wc(t))return!1;var r,o,s,a=wc(e),l=wc(t);for(;(r=a.next())&&!r.done;)if(r.value&&"object"==typeof r.value)s||(s=new Vc),Qc(s,r.value);else if(!Zc(t,r.value)){if(i.strict)return!1;if(!Jc(e,t,r.value))return!1;s||(s=new Vc),Qc(s,r.value)}if(s){for(;(o=l.next())&&!o.done;)if(o.value&&"object"==typeof o.value){if(!qc(s,o.value,i.strict,n))return!1}else if(!i.strict&&!Zc(e,o.value)&&!qc(s,o.value,i.strict,n))return!1;return 0===Wc(s)}return!0}(e,t,i,n);if("Map"===T)return function(e,t,i,n){if(Hc(e)!==Hc(t))return!1;var r,o,s,a,l,c,u=wc(e),h=wc(t);for(;(r=u.next())&&!r.done;)if(a=r.value[0],l=r.value[1],a&&"object"==typeof a)s||(s=new Vc),Qc(s,a);else if(void 0===(c=Gc(t,a))&&!jc(t,a)||!eu(l,c,i,n)){if(i.strict)return!1;if(!Xc(e,t,a,l,i,n))return!1;s||(s=new Vc),Qc(s,a)}if(s){for(;(o=h.next())&&!o.done;)if(a=o.value[0],c=o.value[1],a&&"object"==typeof a){if(!Yc(s,e,a,c,i,n))return!1}else if(!(i.strict||e.has(a)&&eu(Gc(e,a),c,i,n)||Yc(s,e,a,c,yc({},i,{strict:!1}),n)))return!1;return 0===Wc(s)}return!0}(e,t,i,n);return!0}(e,t,r,n)}function tu(e){return!(!e||"object"!=typeof e||"number"!=typeof e.length)&&("function"==typeof e.copy&&"function"==typeof e.slice&&(!(e.length>0&&"number"!=typeof e[0])&&!!(e.constructor&&e.constructor.isBuffer&&e.constructor.isBuffer(e))))}var iu,nu,ru=function(e,t,i){return eu(e,t,i,Tc())};function ou(e,t,i,n){return new(i||(i=Promise))(function(r,o){function s(e){try{l(n.next(e))}catch(e){o(e)}}function a(e){try{l(n.throw(e))}catch(e){o(e)}}function l(e){var t;e.done?r(e.value):(t=e.value,t instanceof i?t:new i(function(e){e(t)})).then(s,a)}l((n=n.apply(e,t||[])).next())})}function su(e){return e&&e.__esModule&&Object.prototype.hasOwnProperty.call(e,"default")?e.default:e}"function"==typeof SuppressedError&&SuppressedError;var au=(nu||(nu=1,iu=function e(t,i){if(t===i)return!0;if(t&&i&&"object"==typeof t&&"object"==typeof i){if(t.constructor!==i.constructor)return!1;var n,r,o;if(Array.isArray(t)){if((n=t.length)!=i.length)return!1;for(r=n;0!==r--;)if(!e(t[r],i[r]))return!1;return!0}if(t.constructor===RegExp)return t.source===i.source&&t.flags===i.flags;if(t.valueOf!==Object.prototype.valueOf)return t.valueOf()===i.valueOf();if(t.toString!==Object.prototype.toString)return t.toString()===i.toString();if((n=(o=Object.keys(t)).length)!==Object.keys(i).length)return!1;for(r=n;0!==r--;)if(!Object.prototype.hasOwnProperty.call(i,o[r]))return!1;for(r=n;0!==r--;){var s=o[r];if(!e(t[s],i[s]))return!1}return!0}return t!=t&&i!=i}),iu),lu=su(au);const cu="__googleMapsScriptId";var uu;!function(e){e[e.INITIALIZED=0]="INITIALIZED",e[e.LOADING=1]="LOADING",e[e.SUCCESS=2]="SUCCESS",e[e.FAILURE=3]="FAILURE"}(uu||(uu={}));class hu{constructor({apiKey:e,authReferrerPolicy:t,channel:i,client:n,id:r=cu,language:o,libraries:s=[],mapIds:a,nonce:l,region:c,retries:u=3,url:h="https://maps.googleapis.com/maps/api/js",version:d}){if(this.callbacks=[],this.done=!1,this.loading=!1,this.errors=[],this.apiKey=e,this.authReferrerPolicy=t,this.channel=i,this.client=n,this.id=r||cu,this.language=o,this.libraries=s,this.mapIds=a,this.nonce=l,this.region=c,this.retries=u,this.url=h,this.version=d,hu.instance){if(!lu(this.options,hu.instance.options))throw new Error(`Loader must not be called again with different options. ${JSON.stringify(this.options)} !== ${JSON.stringify(hu.instance.options)}`);return hu.instance}hu.instance=this}get options(){return{version:this.version,apiKey:this.apiKey,channel:this.channel,client:this.client,id:this.id,libraries:this.libraries,language:this.language,region:this.region,mapIds:this.mapIds,nonce:this.nonce,url:this.url,authReferrerPolicy:this.authReferrerPolicy}}get status(){return this.errors.length?uu.FAILURE:this.done?uu.SUCCESS:this.loading?uu.LOADING:uu.INITIALIZED}get failed(){return this.done&&!this.loading&&this.errors.length>=this.retries+1}createUrl(){let e=this.url;return e+="?callback=__googleMapsCallback&loading=async",this.apiKey&&(e+=`&key=${this.apiKey}`),this.channel&&(e+=`&channel=${this.channel}`),this.client&&(e+=`&client=${this.client}`),this.libraries.length>0&&(e+=`&libraries=${this.libraries.join(",")}`),this.language&&(e+=`&language=${this.language}`),this.region&&(e+=`®ion=${this.region}`),this.version&&(e+=`&v=${this.version}`),this.mapIds&&(e+=`&map_ids=${this.mapIds.join(",")}`),this.authReferrerPolicy&&(e+=`&auth_referrer_policy=${this.authReferrerPolicy}`),e}deleteScript(){const e=document.getElementById(this.id);e&&e.remove()}load(){return this.loadPromise()}loadPromise(){return new Promise((e,t)=>{this.loadCallback(i=>{i?t(i.error):e(window.google)})})}importLibrary(e){return this.execute(),google.maps.importLibrary(e)}loadCallback(e){this.callbacks.push(e),this.execute()}setScript(){var e,t;if(document.getElementById(this.id))return void this.callback();const i={key:this.apiKey,channel:this.channel,client:this.client,libraries:this.libraries.length&&this.libraries,v:this.version,mapIds:this.mapIds,language:this.language,region:this.region,authReferrerPolicy:this.authReferrerPolicy};Object.keys(i).forEach(e=>!i[e]&&delete i[e]),(null===(t=null===(e=null===window||void 0===window?void 0:window.google)||void 0===e?void 0:e.maps)||void 0===t?void 0:t.importLibrary)||(e=>{let t,i,n,r="The Google Maps JavaScript API",o="google",s="importLibrary",a="__ib__",l=document,c=window;c=c[o]||(c[o]={});const u=c.maps||(c.maps={}),h=new Set,d=new URLSearchParams,p=()=>t||(t=new Promise((s,c)=>ou(this,void 0,void 0,function*(){var p;for(n in yield i=l.createElement("script"),i.id=this.id,d.set("libraries",[...h]+""),e)d.set(n.replace(/[A-Z]/g,e=>"_"+e[0].toLowerCase()),e[n]);d.set("callback",o+".maps."+a),i.src=this.url+"?"+d,u[a]=s,i.onerror=()=>t=c(Error(r+" could not load.")),i.nonce=this.nonce||(null===(p=l.querySelector("script[nonce]"))||void 0===p?void 0:p.nonce)||"",l.head.append(i)})));u[s]?console.warn(r+" only loads once. Ignoring:",e):u[s]=(e,...t)=>h.add(e)&&p().then(()=>u[s](e,...t))})(i);const n=this.libraries.map(e=>this.importLibrary(e));n.length||n.push(this.importLibrary("core")),Promise.all(n).then(()=>this.callback(),e=>{const t=new ErrorEvent("error",{error:e});this.loadErrorCallback(t)})}reset(){this.deleteScript(),this.done=!1,this.loading=!1,this.errors=[],this.onerrorEvent=null}resetIfRetryingFailed(){this.failed&&this.reset()}loadErrorCallback(e){if(this.errors.push(e),this.errors.length<=this.retries){const e=this.errors.length*Math.pow(2,this.errors.length);console.error(`Failed to load Google Maps script, retrying in ${e} ms.`),setTimeout(()=>{this.deleteScript(),this.setScript()},e)}else this.onerrorEvent=e,this.callback()}callback(){this.done=!0,this.loading=!1,this.callbacks.forEach(e=>{e(this.onerrorEvent)}),this.callbacks=[]}execute(){if(this.resetIfRetryingFailed(),!this.loading)if(this.done)this.callback();else{if(window.google&&window.google.maps&&window.google.maps.version)return console.warn("Google Maps already loaded outside @googlemaps/js-api-loader. This may result in undesirable behavior as options and script parameters may not match."),void this.callback();this.loading=!0,this.setScript()}}}function du(e){let i;return{c(){i=b("div"),B(i,"id",e[0]),B(i,"class","map svelte-16c2pp7")},m(e,t){y(e,i,t)},p(e,[t]){1&t&&B(i,"id",e[0])},i:t,o:t,d(e){e&&v(i)}}}function pu(e,t,i){let n,r,{id:o}=t,{bearing:s}=t,{center:a}=t,{pitch:l}=t,{zoom:c}=t,{mapStyle:u}=t,{numberOfMaps:h}=t,{onMapMount:d}=t;it.subscribe(e=>({googleMapsAPIKey:r}=e));const p=H();let f,m={};const g=new hu({apiKey:r,version:"beta"}),_=()=>({bearing:f.getHeading(),center:{lng:f.getCenter().lng(),lat:f.getCenter().lat()},pitch:f.getTilt(),zoom:f.getZoom()-1}),A=()=>{const e=y(_()),t=y(m);return!ru(e,t)},y=e=>({bearing:lt(e.bearing,1),pitch:lt(e.pitch,1),center:{lat:lt(e.center.lat,6),lng:lt(e.center.lng,6)},zoom:lt(e.zoom,2)});return j(()=>{g.load().then(()=>{var t;HTMLCanvasElement.prototype.getContext=(t=HTMLCanvasElement.prototype.getContext,function(e,i){return(i=i||{}).preserveDrawingBuffer=!0,t.call(this,e,i)}),i(8,f=new google.maps.Map(document.getElementById(o),{center:m.center,zoom:m.zoom,mapId:n,disableDefaultUI:!0,isFractionalZoomEnabled:!0,fullscreenControl:!1,zoomControl:!1})),d(f);const r=Ct(()=>{document.getElementById(o).querySelector('div[tabindex="0"]').focus()},250);document.getElementById(o).addEventListener("wheel",r,{passive:!0}),f.addListener("center_changed",e),f.addListener("heading_changed",e),f.addListener("tilt_changed",e),f.addListener("zoom_changed",e)});const e=()=>{document.getElementById(o).contains(document.activeElement)&&A()&&p("mapMove",{options:_()})}}),e.$$set=e=>{"id"in e&&i(0,o=e.id),"bearing"in e&&i(1,s=e.bearing),"center"in e&&i(2,a=e.center),"pitch"in e&&i(3,l=e.pitch),"zoom"in e&&i(4,c=e.zoom),"mapStyle"in e&&i(5,u=e.mapStyle),"numberOfMaps"in e&&i(6,h=e.numberOfMaps),"onMapMount"in e&&i(7,d=e.onMapMount)},e.$$.update=()=>{if(32&e.$$.dirty&&(n=u?.mapId),30&e.$$.dirty&&i(9,m={bearing:s,center:a,pitch:l,zoom:c}),768&e.$$.dirty&&(e=>{e&&A()&&e.moveCamera({center:{lat:a.lat,lng:a.lng},zoom:c+1,heading:s,tilt:l})})(f),321&e.$$.dirty&&f&&h){const e=document.getElementById(o);if(e){new ResizeObserver(()=>{google.maps.event.trigger(f,"resize")}).observe(e)}}},[o,s,a,l,c,u,h,d,f,m]}class fu extends ge{constructor(e){super(),me(this,e,pu,du,a,{id:0,bearing:1,center:2,pitch:3,zoom:4,mapStyle:5,numberOfMaps:6,onMapMount:7})}}const mu=e=>{if("string"!=typeof e)return!1;return e.startsWith("mapbox://")},gu=e=>{if(!e)return!1;let t;try{t=new URL(e)}catch(e){return!1}return"api.maptiler.com"===t.host&&!t.searchParams.has("key")},_u=(e,t)=>{const{mapboxKey:i,maptilerKey:n}=t;let r=e;return mu(e)&&i?r=((e,t)=>{if(!mu(e))return e;if(!t)return e;const[,,,i,n]=e.split("/");return`https://api.mapbox.com/styles/v1/${i}/${n}?title=true&access_token=${t}`})(r,i):gu(e)&&n&&(r=((e,t)=>{if(!t)return e;let i=new URL(e);return t&&gu(e)&&i.searchParams.append("key",t),i.toString()})(r,n)),r};let Au,yu;it.subscribe(e=>({mapboxGlAccessToken:Au,maptilerApiKey:yu}=e));const vu=async e=>{const t=mu(e);let i,n=e;try{n=new URL(e);const t={mapboxKey:Au,maptilerKey:yu};n=_u(n.toString(),t)}catch(e){}try{i=await fetch(n)}catch(e){throw{message:e.message}}if(!i.ok)throw{status:i.status,message:i.statusText};const r=await i.json();if(t&&r.message)throw{message:r.message};return r},xu=(e,t,i)=>e.replace("{branch}",t).replace("{style}",i),bu=["swipe","mirror","phone","responsive"];async function wu(e,t,i,n){return n._parse(e,t,i,n)}function Tu(e,t){if(!e)throw new Error(t||"loader assertion failed.")}const Eu=Boolean("object"!=typeof process||"[object process]"!==String(process)||process.browser),Cu="undefined"!=typeof process&&process.version&&/v([0-9]*)/.exec(process.version);Cu&&parseFloat(Cu[1]);const Su=globalThis,Bu=globalThis.process||{},Iu=globalThis.navigator||{};function Mu(e){if("undefined"!=typeof window&&"renderer"===window.process?.type)return!0;if("undefined"!=typeof process&&Boolean(process.versions?.electron))return!0;const t="undefined"!=typeof navigator&&navigator.userAgent,i=e||t;return Boolean(i&&i.indexOf("Electron")>=0)}function Pu(){return!("object"==typeof process&&"[object process]"===String(process)&&!process?.browser)||Mu()}const Ru="4.1.0";class Lu{constructor(e,t,i="sessionStorage"){this.storage=function(e){try{const t=window[e],i="__storage_test__";return t.setItem(i,i),t.removeItem(i),t}catch(e){return null}}(i),this.id=e,this.config=t,this._loadConfiguration()}getConfiguration(){return this.config}setConfiguration(e){if(Object.assign(this.config,e),this.storage){const e=JSON.stringify(this.config);this.storage.setItem(this.id,e)}}_loadConfiguration(){let e={};if(this.storage){const t=this.storage.getItem(this.id);e=t?JSON.parse(t):{}}return Object.assign(this.config,e),this}}var Fu;!function(e){e[e.BLACK=30]="BLACK",e[e.RED=31]="RED",e[e.GREEN=32]="GREEN",e[e.YELLOW=33]="YELLOW",e[e.BLUE=34]="BLUE",e[e.MAGENTA=35]="MAGENTA",e[e.CYAN=36]="CYAN",e[e.WHITE=37]="WHITE",e[e.BRIGHT_BLACK=90]="BRIGHT_BLACK",e[e.BRIGHT_RED=91]="BRIGHT_RED",e[e.BRIGHT_GREEN=92]="BRIGHT_GREEN",e[e.BRIGHT_YELLOW=93]="BRIGHT_YELLOW",e[e.BRIGHT_BLUE=94]="BRIGHT_BLUE",e[e.BRIGHT_MAGENTA=95]="BRIGHT_MAGENTA",e[e.BRIGHT_CYAN=96]="BRIGHT_CYAN",e[e.BRIGHT_WHITE=97]="BRIGHT_WHITE"}(Fu||(Fu={}));function ku(e){return"string"!=typeof e?e:(e=e.toUpperCase(),Fu[e]||Fu.WHITE)}function Du(e,t){if(!e)throw new Error(t||"Assertion failed")}function Ou(){let e;if(Pu()&&Su.performance)e=Su?.performance?.now?.();else if("hrtime"in Bu){const t=Bu?.hrtime?.();e=1e3*t[0]+t[1]/1e6}else e=Date.now();return e}const zu={debug:Pu()&&console.debug||console.log,log:console.log,info:console.info,warn:console.warn,error:console.error},Uu={enabled:!0,level:0};function Nu(){}const Vu={},ju={once:!0};class Gu{constructor({id:e}={id:""}){this.VERSION=Ru,this._startTs=Ou(),this._deltaTs=Ou(),this.userData={},this.LOG_THROTTLE_TIMEOUT=0,this.id=e,this.userData={},this._storage=new Lu(`__probe-${this.id}__`,Uu),this.timeStamp(`${this.id} started`),function(e,t=["constructor"]){const i=Object.getPrototypeOf(e),n=Object.getOwnPropertyNames(i),r=e;for(const i of n){const n=r[i];"function"==typeof n&&(t.find(e=>i===e)||(r[i]=n.bind(e)))}}(this),Object.seal(this)}set level(e){this.setLevel(e)}get level(){return this.getLevel()}isEnabled(){return this._storage.config.enabled}getLevel(){return this._storage.config.level}getTotal(){return Number((Ou()-this._startTs).toPrecision(10))}getDelta(){return Number((Ou()-this._deltaTs).toPrecision(10))}set priority(e){this.level=e}get priority(){return this.level}getPriority(){return this.level}enable(e=!0){return this._storage.setConfiguration({enabled:e}),this}setLevel(e){return this._storage.setConfiguration({level:e}),this}get(e){return this._storage.config[e]}set(e,t){this._storage.setConfiguration({[e]:t})}settings(){console.table?console.table(this._storage.config):console.log(this._storage.config)}assert(e,t){if(!e)throw new Error(t||"Assertion failed")}warn(e){return this._getLogFunction(0,e,zu.warn,arguments,ju)}error(e){return this._getLogFunction(0,e,zu.error,arguments)}deprecated(e,t){return this.warn(`\`${e}\` is deprecated and will be removed in a later version. Use \`${t}\` instead`)}removed(e,t){return this.error(`\`${e}\` has been removed. Use \`${t}\` instead`)}probe(e,t){return this._getLogFunction(e,t,zu.log,arguments,{time:!0,once:!0})}log(e,t){return this._getLogFunction(e,t,zu.debug,arguments)}info(e,t){return this._getLogFunction(e,t,console.info,arguments)}once(e,t){return this._getLogFunction(e,t,zu.debug||zu.info,arguments,ju)}table(e,t,i){return t?this._getLogFunction(e,t,console.table||Nu,i&&[i],{tag:$u(t)}):Nu}time(e,t){return this._getLogFunction(e,t,console.time?console.time:console.info)}timeEnd(e,t){return this._getLogFunction(e,t,console.timeEnd?console.timeEnd:console.info)}timeStamp(e,t){return this._getLogFunction(e,t,console.timeStamp||Nu)}group(e,t,i={collapsed:!1}){const n=Qu({logLevel:e,message:t,opts:i}),{collapsed:r}=i;return n.method=(r?console.groupCollapsed:console.group)||console.info,this._getLogFunction(n)}groupCollapsed(e,t,i={}){return this.group(e,t,Object.assign({},i,{collapsed:!0}))}groupEnd(e){return this._getLogFunction(e,"",console.groupEnd||Nu)}withGroup(e,t,i){this.group(e,t)();try{i()}finally{this.groupEnd(e)()}}trace(){console.trace&&console.trace()}_shouldLog(e){return this.isEnabled()&&this.getLevel()>=Hu(e)}_getLogFunction(e,t,i,n,r){if(this._shouldLog(e)){r=Qu({logLevel:e,message:t,args:n,opts:r}),Du(i=i||r.method),r.total=this.getTotal(),r.delta=this.getDelta(),this._deltaTs=Ou();const o=r.tag||r.message;if(r.once&&o){if(Vu[o])return Nu;Vu[o]=Ou()}return t=function(e,t,i){if("string"==typeof t){const n=i.time?function(e,t=8){const i=Math.max(t-e.length,0);return`${" ".repeat(i)}${e}`}(function(e){let t;return t=e<10?`${e.toFixed(2)}ms`:e<100?`${e.toFixed(1)}ms`:e<1e3?`${e.toFixed(0)}ms`:`${(e/1e3).toFixed(2)}s`,t}(i.total)):"";t=function(e,t,i){Pu||"string"!=typeof e||(t&&(e=`[${ku(t)}m${e}`),i&&(e=`[${ku(i)+10}m${e}`));return e}(t=i.time?`${e}: ${n} ${t}`:`${e}: ${t}`,i.color,i.background)}return t}(this.id,r.message,r),i.bind(console,t,...r.args)}return Nu}}function Hu(e){if(!e)return 0;let t;switch(typeof e){case"number":t=e;break;case"object":t=e.logLevel||e.priority||0;break;default:return 0}return Du(Number.isFinite(t)&&t>=0),t}function Qu(e){const{logLevel:t,message:i}=e;e.logLevel=Hu(t);const n=e.args?Array.from(e.args):[];for(;n.length&&n.shift()!==i;);switch(typeof t){case"string":case"function":void 0!==i&&n.unshift(i),e.message=t;break;case"object":Object.assign(e,t)}"function"==typeof e.message&&(e.message=e.message());const r=typeof e.message;return Du("string"===r||"object"===r),Object.assign(e,{args:n},e.opts)}function $u(e){for(const t in e)for(const i in e[t])return i||"untitled";return"empty"}Gu.VERSION=Ru,globalThis.probe={};var Zu=new Gu({id:"@probe.gl/log"});const Wu="4.3.3",qu=Wu[0]>="0"&&Wu[0]<="9"?`v${Wu}`:"";const Ku=function(){const e=new Gu({id:"loaders.gl"});return globalThis.loaders=globalThis.loaders||{},globalThis.loaders.log=e,globalThis.loaders.version=qu,globalThis.probe=globalThis.probe||{},globalThis.probe.loaders=e,e}();function Xu(e,t){return Ju(e||{},t)}function Ju(e,t,i=0){if(i>3)return t;const n={...e};for(const[e,r]of Object.entries(t))r&&"object"==typeof r&&!Array.isArray(r)?n[e]=Ju(n[e]||{},t[e],i+1):n[e]=t[e];return n}function Yu(e,t){if(!e)throw new Error(t||"loaders.gl assertion failed.")}globalThis._loadersgl_?.version||(globalThis._loadersgl_=globalThis._loadersgl_||{},globalThis._loadersgl_.version="4.3.3"),globalThis._loadersgl_.version;const eh="object"!=typeof process||"[object process]"!==String(process)||process.browser,th="undefined"!=typeof window&&void 0!==window.orientation,ih="undefined"!=typeof process&&process.version&&/v([0-9]*)/.exec(process.version);ih&&parseFloat(ih[1]);class nh{name;workerThread;isRunning=!0;result;_resolve=()=>{};_reject=()=>{};constructor(e,t){this.name=e,this.workerThread=t,this.result=new Promise((e,t)=>{this._resolve=e,this._reject=t})}postMessage(e,t){this.workerThread.postMessage({source:"loaders.gl",type:e,payload:t})}done(e){Yu(this.isRunning),this.isRunning=!1,this._resolve(e)}error(e){Yu(this.isRunning),this.isRunning=!1,this._reject(e)}}class rh{terminate(){}}const oh=new Map;function sh(e){Yu(e.source&&!e.url||!e.source&&e.url);let t=oh.get(e.source||e.url);return t||(e.url&&(t=function(e){if(!e.startsWith("http"))return e;return ah((t=e,`try {\n importScripts('${t}');\n} catch (error) {\n console.error(error);\n throw error;\n}`));var t}(e.url),oh.set(e.url,t)),e.source&&(t=ah(e.source),oh.set(e.source,t))),Yu(t),t}function ah(e){const t=new Blob([e],{type:"application/javascript"});return URL.createObjectURL(t)}function lh(e,t=!0,i){const n=i||new Set;if(e){if(ch(e))n.add(e);else if(ch(e.buffer))n.add(e.buffer);else if(ArrayBuffer.isView(e));else if(t&&"object"==typeof e)for(const i in e)lh(e[i],t,n)}else;return void 0===i?Array.from(n):[]}function ch(e){return!!e&&(e instanceof ArrayBuffer||("undefined"!=typeof MessagePort&&e instanceof MessagePort||("undefined"!=typeof ImageBitmap&&e instanceof ImageBitmap||"undefined"!=typeof OffscreenCanvas&&e instanceof OffscreenCanvas)))}const uh=()=>{};class hh{name;source;url;terminated=!1;worker;onMessage;onError;_loadableURL="";static isSupported(){return"undefined"!=typeof Worker&&eh||void 0!==rh&&!eh}constructor(e){const{name:t,source:i,url:n}=e;Yu(i||n),this.name=t,this.source=i,this.url=n,this.onMessage=uh,this.onError=e=>console.log(e),this.worker=eh?this._createBrowserWorker():this._createNodeWorker()}destroy(){this.onMessage=uh,this.onError=uh,this.worker.terminate(),this.terminated=!0}get isRunning(){return Boolean(this.onMessage)}postMessage(e,t){t=t||lh(e),this.worker.postMessage(e,t)}_getErrorFromErrorEvent(e){let t="Failed to load ";return t+=`worker ${this.name} from ${this.url}. `,e.message&&(t+=`${e.message} in `),e.lineno&&(t+=`:${e.lineno}:${e.colno}`),new Error(t)}_createBrowserWorker(){this._loadableURL=sh({source:this.source,url:this.url});const e=new Worker(this._loadableURL,{name:this.name});return e.onmessage=e=>{e.data?this.onMessage(e.data):this.onError(new Error("No data received"))},e.onerror=e=>{this.onError(this._getErrorFromErrorEvent(e)),this.terminated=!0},e.onmessageerror=e=>console.error(e),e}_createNodeWorker(){let e;if(this.url){const t=this.url.includes(":/")||this.url.startsWith("/")?this.url:`./${this.url}`;e=new rh(t,{eval:!1})}else{if(!this.source)throw new Error("no worker");e=new rh(this.source,{eval:!0})}return e.on("message",e=>{this.onMessage(e)}),e.on("error",e=>{this.onError(e)}),e.on("exit",e=>{}),e}}class dh{name="unnamed";source;url;maxConcurrency=1;maxMobileConcurrency=1;onDebug=()=>{};reuseWorkers=!0;props={};jobQueue=[];idleQueue=[];count=0;isDestroyed=!1;static isSupported(){return hh.isSupported()}constructor(e){this.source=e.source,this.url=e.url,this.setProps(e)}destroy(){this.idleQueue.forEach(e=>e.destroy()),this.isDestroyed=!0}setProps(e){this.props={...this.props,...e},void 0!==e.name&&(this.name=e.name),void 0!==e.maxConcurrency&&(this.maxConcurrency=e.maxConcurrency),void 0!==e.maxMobileConcurrency&&(this.maxMobileConcurrency=e.maxMobileConcurrency),void 0!==e.reuseWorkers&&(this.reuseWorkers=e.reuseWorkers),void 0!==e.onDebug&&(this.onDebug=e.onDebug)}async startJob(e,t=(e,t,i)=>e.done(i),i=(e,t)=>e.error(t)){const n=new Promise(n=>(this.jobQueue.push({name:e,onMessage:t,onError:i,onStart:n}),this));return this._startQueuedJob(),await n}async _startQueuedJob(){if(!this.jobQueue.length)return;const e=this._getAvailableWorker();if(!e)return;const t=this.jobQueue.shift();if(t){this.onDebug({message:"Starting job",name:t.name,workerThread:e,backlog:this.jobQueue.length});const i=new nh(t.name,e);e.onMessage=e=>t.onMessage(i,e.type,e.payload),e.onError=e=>t.onError(i,e),t.onStart(i);try{await i.result}catch(e){console.error(`Worker exception: ${e}`)}finally{this.returnWorkerToQueue(e)}}}returnWorkerToQueue(e){!eh||this.isDestroyed||!this.reuseWorkers||this.count>this._getMaxConcurrency()?(e.destroy(),this.count--):this.idleQueue.push(e),this.isDestroyed||this._startQueuedJob()}_getAvailableWorker(){if(this.idleQueue.length>0)return this.idleQueue.shift()||null;if(this.count{}};class fh{props;workerPools=new Map;static _workerFarm;static isSupported(){return hh.isSupported()}static getWorkerFarm(e={}){return fh._workerFarm=fh._workerFarm||new fh({}),fh._workerFarm.setProps(e),fh._workerFarm}constructor(e){this.props={...ph},this.setProps(e),this.workerPools=new Map}destroy(){for(const e of this.workerPools.values())e.destroy();this.workerPools=new Map}setProps(e){this.props={...this.props,...e};for(const e of this.workerPools.values())e.setProps(this._getWorkerPoolProps())}getWorkerPool(e){const{name:t,source:i,url:n}=e;let r=this.workerPools.get(t);return r||(r=new dh({name:t,source:i,url:n}),r.setProps(this._getWorkerPoolProps()),this.workerPools.set(t,r)),r}_getWorkerPoolProps(){return{maxConcurrency:this.props.maxConcurrency,maxMobileConcurrency:this.props.maxMobileConcurrency,reuseWorkers:this.props.reuseWorkers,onDebug:this.props.onDebug}}}async function mh(e,t,i,n,r){const o=e.id,s=function(e,t={}){const i=t[e.id]||{},n=eh?`${e.id}-worker.js`:`${e.id}-worker-node.js`;let r=i.workerUrl;if(r||"compression"!==e.id||(r=t.workerUrl),"test"===t._workerType&&(r=eh?`modules/${e.module}/dist/${n}`:`modules/${e.module}/src/workers/${e.id}-worker-node.ts`),!r){let t=e.version;"latest"===t&&(t="latest");const i=t?`@${t}`:"";r=`https://unpkg.com/@loaders.gl/${e.module}${i}/dist/${n}`}return Yu(r),r}(e,i),a=fh.getWorkerFarm(i).getWorkerPool({name:o,url:s});i=JSON.parse(JSON.stringify(i)),n=JSON.parse(JSON.stringify(n||{}));const l=await a.startJob("process-on-worker",gh.bind(null,r));l.postMessage("process",{input:t,options:i,context:n});const c=await l.result;return await c.result}async function gh(e,t,i,n){switch(i){case"done":t.done(n);break;case"error":t.error(new Error(n.error));break;case"process":const{id:r,input:o,options:s}=n;try{const i=await e(o,s);t.postMessage("done",{id:r,result:i})}catch(e){const i=e instanceof Error?e.message:"unknown error";t.postMessage("error",{id:r,error:i})}break;default:console.warn(`parse-with-worker unknown message ${i}`)}}function _h(e,t,i){if(e.byteLength<=t+i)return"";const n=new DataView(e);let r="";for(let e=0;ee instanceof ArrayBuffer?new Uint8Array(e):e),i=t.reduce((e,t)=>e+t.byteLength,0),n=new Uint8Array(i);let r=0;for(const e of t)n.set(e,r),r+=e.byteLength;return n.buffer}(e)}function vh(...e){const t=e,i=t&&t.length>1&&t[0].constructor||null;if(!i)throw new Error('"concatenateTypedArrays" - incorrect quantity of arguments or arguments have incompatible data types');const n=new i(t.reduce((e,t)=>e+t.length,0));let r=0;for(const e of t)n.set(e,r),r+=e.length;return n}function xh(e,t,i){const n=void 0!==i?new Uint8Array(e).subarray(t,t+i):new Uint8Array(e).subarray(t);return new Uint8Array(n).buffer}function bh(e,t){return Tu(e>=0),Tu(t>0),e+(t-1)&~(t-1)}function wh(e,t,i){let n;if(e instanceof ArrayBuffer)n=new Uint8Array(e);else{const t=e.byteOffset,i=e.byteLength;n=new Uint8Array(e.buffer||e.arrayBuffer,t,i)}return t.set(n,i),i+bh(n.byteLength,4)}function Th(){let e;if("undefined"!=typeof window&&window.performance)e=window.performance.now();else if("undefined"!=typeof process&&process.hrtime){const t=process.hrtime();e=1e3*t[0]+t[1]/1e6}else e=Date.now();return e}class Eh{constructor(e,t){this.sampleSize=1,this.time=0,this.count=0,this.samples=0,this.lastTiming=0,this.lastSampleTime=0,this.lastSampleCount=0,this._count=0,this._time=0,this._samples=0,this._startTime=0,this._timerPending=!1,this.name=e,this.type=t,this.reset()}reset(){return this.time=0,this.count=0,this.samples=0,this.lastTiming=0,this.lastSampleTime=0,this.lastSampleCount=0,this._count=0,this._time=0,this._samples=0,this._startTime=0,this._timerPending=!1,this}setSampleSize(e){return this.sampleSize=e,this}incrementCount(){return this.addCount(1),this}decrementCount(){return this.subtractCount(1),this}addCount(e){return this._count+=e,this._samples++,this._checkSampling(),this}subtractCount(e){return this._count-=e,this._samples++,this._checkSampling(),this}addTime(e){return this._time+=e,this.lastTiming=e,this._samples++,this._checkSampling(),this}timeStart(){return this._startTime=Th(),this._timerPending=!0,this}timeEnd(){return this._timerPending?(this.addTime(Th()-this._startTime),this._timerPending=!1,this._checkSampling(),this):this}getSampleAverageCount(){return this.sampleSize>0?this.lastSampleCount/this.sampleSize:0}getSampleAverageTime(){return this.sampleSize>0?this.lastSampleTime/this.sampleSize:0}getSampleHz(){return this.lastSampleTime>0?this.sampleSize/(this.lastSampleTime/1e3):0}getAverageCount(){return this.samples>0?this.count/this.samples:0}getAverageTime(){return this.samples>0?this.time/this.samples:0}getHz(){return this.time>0?this.samples/(this.time/1e3):0}_checkSampling(){this._samples===this.sampleSize&&(this.lastSampleTime=this._time,this.lastSampleCount=this._count,this.count+=this._count,this.time+=this._time,this.samples+=this._samples,this._time=0,this._count=0,this._samples=0)}}class Ch{constructor(e){this.stats={},this.id=e.id,this.stats={},this._initializeStats(e.stats),Object.seal(this)}get(e,t="count"){return this._getOrCreate({name:e,type:t})}get size(){return Object.keys(this.stats).length}reset(){for(const e of Object.values(this.stats))e.reset();return this}forEach(e){for(const t of Object.values(this.stats))e(t)}getTable(){const e={};return this.forEach(t=>{e[t.name]={time:t.time||0,count:t.count||0,average:t.getAverageTime()||0,hz:t.getHz()||0}}),e}_initializeStats(e=[]){e.forEach(e=>this._getOrCreate(e))}_getOrCreate(e){const{name:t,type:i}=e;let n=this.stats[t];return n||(n=e instanceof Eh?e:new Eh(t,i),this.stats[t]=n),n}}const Sh={id:"request-scheduler",throttleRequests:!0,maxRequests:6,debounceTime:0};class Bh{props;stats;activeRequestCount=0;requestQueue=[];requestMap=new Map;updateTimer=null;constructor(e={}){this.props={...Sh,...e},this.stats=new Ch({id:this.props.id}),this.stats.get("Queued Requests"),this.stats.get("Active Requests"),this.stats.get("Cancelled Requests"),this.stats.get("Queued Requests Ever"),this.stats.get("Active Requests Ever")}scheduleRequest(e,t=()=>0){if(!this.props.throttleRequests)return Promise.resolve({done:()=>{}});if(this.requestMap.has(e))return this.requestMap.get(e);const i={handle:e,priority:0,getPriority:t},n=new Promise(e=>(i.resolve=e,i));return this.requestQueue.push(i),this.requestMap.set(e,n),this._issueNewRequests(),n}_issueRequest(e){const{handle:t,resolve:i}=e;let n=!1;const r=()=>{n||(n=!0,this.requestMap.delete(t),this.activeRequestCount--,this._issueNewRequests())};return this.activeRequestCount++,i?i({done:r}):Promise.resolve({done:r})}_issueNewRequests(){null!==this.updateTimer&&clearTimeout(this.updateTimer),this.updateTimer=setTimeout(()=>this._issueNewRequestsAsync(),this.props.debounceTime)}_issueNewRequestsAsync(){null!==this.updateTimer&&clearTimeout(this.updateTimer),this.updateTimer=null;const e=Math.max(this.props.maxRequests-this.activeRequestCount,0);if(0!==e){this._updateAllRequests();for(let t=0;te.priority-t.priority)}_updateRequest(e){return e.priority=e.getPriority(e.handle),!(e.priority<0)||(e.resolve(null),!1)}}const Ih={};function Mh(e){if((t=e)&&"object"==typeof t&&t.isBuffer)return e;var t;if(e instanceof ArrayBuffer)return e;if(ArrayBuffer.isView(e))return 0===e.byteOffset&&e.byteLength===e.buffer.byteLength?e.buffer:e.buffer.slice(e.byteOffset,e.byteOffset+e.byteLength);if("string"==typeof e){const t=e;return(new TextEncoder).encode(t).buffer}if(e&&"object"==typeof e&&e._toArrayBuffer)return e._toArrayBuffer();throw new Error("toArrayBuffer")}function Ph(){if("undefined"!=typeof process&&void 0!==process.cwd)return process.cwd();const e=window.location?.pathname;return e?.slice(0,e.lastIndexOf("/")+1)||""}function Rh(e){const t=e?e.lastIndexOf("/"):-1;return t>=0?e.substr(t+1):""}function Lh(e){const t=e?e.lastIndexOf("/"):-1;return t>=0?e.substr(0,t):""}function Fh(...e){const t=[];for(let i=0;i=-1&&!r;e--){let o;e>=0?o=t[e]:(void 0===i&&(i=Ph()),o=i),0!==o.length&&(n=`${o}/${n}`,r=o.charCodeAt(0)===kh)}return n=function(e,t){let i,n="",r=-1,o=0,s=!1;for(let a=0;a<=e.length;++a){if(a2){const e=n.length-1;let t=e;for(;t>=0&&n.charCodeAt(t)!==kh;--t);if(t!==e){n=-1===t?"":n.slice(0,t),r=a,o=0,s=!1;continue}}else if(2===n.length||1===n.length){n="",r=a,o=0,s=!1;continue}t&&(n.length>0?n+="/..":n="..",s=!0)}else{const t=e.slice(r+1,a);n.length>0?n+=`/${t}`:n=t,s=!1}r=a,o=0}else i===Dh&&-1!==o?++o:o=-1}return n}(n,!r),r?`/${n}`:n.length>0?n:"."}const kh=47,Dh=46;const Oh=e=>"function"==typeof e,zh=e=>null!==e&&"object"==typeof e,Uh=e=>zh(e)&&e.constructor==={}.constructor,Nh=e=>"undefined"!=typeof Response&&e instanceof Response||e&&e.arrayBuffer&&e.text&&e.json,Vh=e=>"undefined"!=typeof Blob&&e instanceof Blob,jh=e=>(e=>"undefined"!=typeof ReadableStream&&e instanceof ReadableStream||zh(e)&&Oh(e.tee)&&Oh(e.cancel)&&Oh(e.getReader))(e)||(e=>zh(e)&&Oh(e.read)&&Oh(e.pipe)&&(e=>"boolean"==typeof e)(e.readable))(e);class Gh extends Error{constructor(e,t){super(e),this.reason=t.reason,this.url=t.url,this.response=t.response}reason;url;response}const Hh=/^data:([-\w.]+\/[-\w.+]+)(;|,)/,Qh=/^([-\w.]+\/[-\w.+]+)/;function $h(e,t){return e.toLowerCase()===t.toLowerCase()}function Zh(e){const t=Hh.exec(e);return t?t[1]:""}const Wh=/\?.*/;function qh(e){return e.replace(Wh,"")}function Kh(e){if(Nh(e)){return e.url}if(Vh(e)){return e.name||""}return"string"==typeof e?e:""}function Xh(e){if(Nh(e)){const t=e,i=t.headers.get("content-type")||"",n=qh(t.url);return function(e){const t=Qh.exec(e);return t?t[1]:e}(i)||Zh(n)}if(Vh(e)){return e.type||""}return"string"==typeof e?Zh(e):""}async function Jh(e){if(Nh(e))return e;const t={},i=function(e){if(Nh(e))return e.headers["content-length"]||-1;if(Vh(e))return e.size;return"string"==typeof e?e.length:e instanceof ArrayBuffer||ArrayBuffer.isView(e)?e.byteLength:-1}(e);i>=0&&(t["content-length"]=String(i));const n=Kh(e),r=Xh(e);r&&(t["content-type"]=r);const o=await async function(e){const t=5;if("string"==typeof e)return`data:,${e.slice(0,t)}`;if(e instanceof Blob){const t=e.slice(0,5);return await new Promise(e=>{const i=new FileReader;i.onload=t=>e(t?.target?.result),i.readAsDataURL(t)})}if(e instanceof ArrayBuffer){const i=function(e){let t="";const i=new Uint8Array(e);for(let e=0;e100?`${i.slice(0,100)}...`:i;const n={reason:e.statusText,url:e.url,response:e};try{const t=e.headers.get("Content-Type");n.reason=!e.bodyUsed&&t?.includes("application/json")?await e.json():await e.text()}catch(e){}return new Gh(i,n)}(e);throw t}}async function ed(e,t){if("string"==typeof e){const i=function(e){for(const t in Ih)if(e.startsWith(t)){const i=Ih[t];e=e.replace(t,i)}return e.startsWith("http://")||e.startsWith("https://")||(e=`${e}`),e}(e);return function(e){return!function(e){return e.startsWith("http:")||e.startsWith("https:")}(e)&&!function(e){return e.startsWith("data:")}(e)}(i)&&globalThis.loaders?.fetchNode?globalThis.loaders?.fetchNode(i,t):await fetch(i,t)}return await Jh(e)}const td=new Gu({id:"loaders.gl"});class id{log(){return()=>{}}info(){return()=>{}}warn(){return()=>{}}error(){return()=>{}}}const nd={fetch:null,mimeType:void 0,nothrow:!1,log:new class{console;constructor(){this.console=console}log(...e){return this.console.log.bind(this.console,...e)}info(...e){return this.console.info.bind(this.console,...e)}warn(...e){return this.console.warn.bind(this.console,...e)}error(...e){return this.console.error.bind(this.console,...e)}},useLocalLibraries:!1,CDN:"https://unpkg.com/@loaders.gl",worker:!0,maxConcurrency:3,maxMobileConcurrency:1,reuseWorkers:Eu,_nodeWorkers:!1,_workerType:"",limit:0,_limitMB:0,batchSize:"auto",batchDebounceMs:0,metadata:!1,transforms:[]},rd={throws:"nothrow",dataType:"(no longer used)",uri:"baseUri",method:"fetch.method",headers:"fetch.headers",body:"fetch.body",mode:"fetch.mode",credentials:"fetch.credentials",cache:"fetch.cache",redirect:"fetch.redirect",referrer:"fetch.referrer",referrerPolicy:"fetch.referrerPolicy",integrity:"fetch.integrity",keepalive:"fetch.keepalive",signal:"fetch.signal"};function od(){globalThis.loaders=globalThis.loaders||{};const{loaders:e}=globalThis;return e._state||(e._state={}),e._state}function sd(){const e=od();return e.globalOptions=e.globalOptions||{...nd},e.globalOptions}function ad(e,t,i,n){return i=i||[],function(e,t){ld(e,null,nd,rd,t);for(const i of t){const n=e&&e[i.id]||{},r=i.options&&i.options[i.id]||{},o=i.deprecatedOptions&&i.deprecatedOptions[i.id]||{};ld(n,i.id,r,o,t)}}(e,i=Array.isArray(i)?i:[i]),function(e,t,i){const n=e.options||{},r={...n};(function(e,t){t&&!("baseUri"in e)&&(e.baseUri=t)})(r,i),null===r.log&&(r.log=new id);return ud(r,sd()),ud(r,t),r}(t,e,n)}function ld(e,t,i,n,r){const o=t||"Top level",s=t?`${t}.`:"";for(const a in e){const l=!t&&zh(e[a]);if(!(a in i)&&!("baseUri"===a&&!t)&&!("workerUrl"===a&&t))if(a in n)td.warn(`${o} loader option '${s}${a}' no longer supported, use '${n[a]}'`)();else if(!l){const e=cd(a,r);td.warn(`${o} loader option '${s}${a}' not recognized. ${e}`)()}}}function cd(e,t){const i=e.toLowerCase();let n="";for(const r of t)for(const t in r.options){if(e===t)return`Did you mean '${r.id}.${t}'?`;const o=t.toLowerCase();(i.startsWith(o)||o.startsWith(i))&&(n=n||`Did you mean '${r.id}.${t}'?`)}return n}function ud(e,t){for(const i in t)if(i in t){const n=t[i];Uh(n)&&Uh(e[i])?e[i]={...e[i],...t[i]}:e[i]=t[i]}}function hd(e){if(!e)return!1;Array.isArray(e)&&(e=e[0]);return Array.isArray(e?.extensions)}function dd(e){let t;return Tu(e,"null loader"),Tu(hd(e),"invalid loader"),Array.isArray(e)&&(t=e[1],e=e[0],e={...e,options:{...e.options,...t}}),(e?.parseTextSync||e?.parseText)&&(e.text=!0),e.text||(e.binary=!0),e}const pd=()=>{const e=od();return e.loaderRegistry=e.loaderRegistry||[],e.loaderRegistry};const fd=/\.([^.]+)$/;function md(e,t=[],i,n){if(!gd(e))return null;if(t&&!Array.isArray(t))return dd(t);let r=[];t&&(r=r.concat(t)),i?.ignoreRegisteredLoaders||r.push(...pd()),function(e){for(const t of e)dd(t)}(r);const o=function(e,t,i,n){const r=Kh(e),o=Xh(e),s=qh(r)||n?.url;let a=null,l="";i?.mimeType&&(a=Ad(t,i?.mimeType),l=`match forced by supplied MIME type ${i?.mimeType}`);a=a||function(e,t){const i=t&&fd.exec(t),n=i&&i[1];return n?function(e,t){t=t.toLowerCase();for(const i of e)for(const e of i.extensions)if(e.toLowerCase()===t)return i;return null}(e,n):null}(t,s),l=l||(a?`matched url ${s}`:""),a=a||Ad(t,o),l=l||(a?`matched MIME type ${o}`:""),a=a||function(e,t){if(!t)return null;for(const i of e)if("string"==typeof t){if(yd(t,i))return i}else if(ArrayBuffer.isView(t)){if(vd(t.buffer,t.byteOffset,i))return i}else if(t instanceof ArrayBuffer){if(vd(t,0,i))return i}return null}(t,e),l=l||(a?`matched initial data ${xd(e)}`:""),i?.fallbackMimeType&&(a=a||Ad(t,i?.fallbackMimeType),l=l||(a?`matched fallback MIME type ${o}`:""));l&&Ku.log(1,`selectLoader selected ${a?.name}: ${l}.`);return a}(e,r,i,n);if(!o&&!i?.nothrow)throw new Error(_d(e));return o}function gd(e){return!(e instanceof Response&&204===e.status)}function _d(e){const t=Kh(e),i=Xh(e);let n="No valid loader found (";n+=t?`${Rh(t)}, `:"no url provided, ",n+=`MIME type: ${i?`"${i}"`:"not provided"}, `;const r=e?xd(e):"";return n+=r?` first bytes: "${r}"`:"first bytes: not available",n+=")",n}function Ad(e,t){for(const i of e){if(i.mimeTypes?.some(e=>$h(t,e)))return i;if($h(t,`application/x.${i.id}`))return i}return null}function yd(e,t){if(t.testText)return t.testText(e);return(Array.isArray(t.tests)?t.tests:[t.tests]).some(t=>e.startsWith(t))}function vd(e,t,i){return(Array.isArray(i.tests)?i.tests:[i.tests]).some(i=>function(e,t,i,n){if(n instanceof ArrayBuffer)return function(e,t,i){if(i=i||e.byteLength,e.byteLengthe&&"object"==typeof e&&e.isBuffer)(e)&&(e=e.buffer),e instanceof ArrayBuffer){const i=e;return t.text&&!t.binary?new TextDecoder("utf8").decode(i):i}if(ArrayBuffer.isView(e)){if(t.text&&!t.binary)return new TextDecoder("utf8").decode(e);let i=e.buffer;const n=e.byteLength||e.length;return 0===e.byteOffset&&n===i.byteLength||(i=i.slice(e.byteOffset,e.byteOffset+n)),i}throw new Error(Sd)}(e,t);if(Vh(e)&&(e=await Jh(e)),Nh(e)){const i=e;return await Yh(i),t.binary?await i.arrayBuffer():await i.text()}if(jh(e)&&(e=Cd(e,i)),(e=>Boolean(e)&&"function"==typeof e[Symbol.iterator])(e)||(e=>e&&"function"==typeof e[Symbol.asyncIterator])(e))return async function(e){const t=[];for await(const i of e)t.push(i);return yh(...t)}(e);throw new Error(Sd)}function Id(e,t){const i=sd(),n=e||i;return"function"==typeof n.fetch?n.fetch:zh(n.fetch)?e=>ed(e,n.fetch):t?.fetch?t?.fetch:ed}function Md(e,t,i){if(i)return i;const n={fetch:Id(t,e),...e};if(n.url){const e=qh(n.url);n.baseUrl=e,n.queryString=function(e){const t=e.match(Wh);return t&&t[0]}(n.url),n.filename=Rh(e),n.baseUrl=Lh(e)}return Array.isArray(n.loaders)||(n.loaders=null),n}async function Pd(e,t,i,n){!t||Array.isArray(t)||hd(t)||(n=void 0,i=t,t=void 0),i=i||{};const r=Kh(e=await e),o=function(e,t){if(e&&!Array.isArray(e))return e;let i;if(e&&(i=Array.isArray(e)?e:[e]),t&&t.loaders){const e=Array.isArray(t.loaders)?t.loaders:[t.loaders];i=i?[...i,...e]:e}return i&&i.length?i:void 0}(t,n),s=await async function(e,t=[],i,n){if(!gd(e))return null;let r=md(e,t,{...i,nothrow:!0},n);if(r)return r;if(Vh(e)&&(r=md(e=await e.slice(0,10).arrayBuffer(),t,i,n)),!r&&!i?.nothrow)throw new Error(_d(e));return r}(e,o,i);return s?(n=Md({url:r,_parse:Pd,loaders:o},i=ad(i,s,o,r),n||null),await async function(e,t,i,n){if(function(e){wd(e,"no worker provided");const t=e.version}(e),i=Xu(e.options,i),Nh(t)){const e=t,{ok:i,redirected:r,status:o,statusText:s,type:a,url:l}=e,c=Object.fromEntries(e.headers.entries());n.response={headers:c,ok:i,redirected:r,status:o,statusText:s,type:a,url:l}}t=await Bd(t,e,i);const r=e;if(r.parseTextSync&&"string"==typeof t)return r.parseTextSync(t,i,n);if(function(e,t){return!!fh.isSupported()&&!(!eh&&!t?._nodeWorkers)&&e.worker&&t?.worker}(e,i))return await mh(e,t,i,n,Pd);if(r.parseText&&"string"==typeof t)return await r.parseText(t,i,n);if(r.parse)return await r.parse(t,i,n);throw wd(!r.parseSync),new Error(`${e.id} loader - no parser found and worker is disabled`)}(s,e,i,n)):null}function Rd(e){let t=1/0,i=1/0,n=1/0,r=-1/0,o=-1/0,s=-1/0;const a=e.POSITION?e.POSITION.value:[],l=a&&a.length;for(let e=0;er?l:r,o=c>o?c:o,s=u>s?u:s}return[[t,i,n],[r,o,s]]}function Ld(e,t,i){const n=function(e){switch(e.constructor){case Int8Array:return"int8";case Uint8Array:case Uint8ClampedArray:return"uint8";case Int16Array:return"int16";case Uint16Array:return"uint16";case Int32Array:return"int32";case Uint32Array:return"uint32";case Float32Array:return"float32";case Float64Array:return"float64";default:return"null"}}(t.value),r=i||function(e){const t={};"byteOffset"in e&&(t.byteOffset=e.byteOffset.toString(10));"byteStride"in e&&(t.byteStride=e.byteStride.toString(10));"normalized"in e&&(t.normalized=e.normalized.toString());return t}(t);return{name:e,type:{type:"fixed-size-list",listSize:t.size,children:[{name:"value",type:n}]},nullable:!1,metadata:r}}async function Fd(e,t,i,n){let r,o;Array.isArray(t)||hd(t)?(r=t,o=i):(r=[],o=t);const s=Id(o);let a=e;return"string"==typeof e&&(a=await s(e)),Vh(e)&&(a=await s(e)),Array.isArray(r),await Pd(a,r,o)}const kd=globalThis.loaders?.parseImageNode,Dd="undefined"!=typeof Image,Od="undefined"!=typeof ImageBitmap,zd=Boolean(kd),Ud=!!Eu||zd;function Nd(e){const t=function(e){if("undefined"!=typeof ImageBitmap&&e instanceof ImageBitmap)return"imagebitmap";if("undefined"!=typeof Image&&e instanceof Image)return"image";if(e&&"object"==typeof e&&e.data&&e.width&&e.height)return"data";return null}(e);if(!t)throw new Error("Not an image");return t}function Vd(e){switch(Nd(e)){case"data":return e;case"image":case"imagebitmap":const t=document.createElement("canvas"),i=t.getContext("2d");if(!i)throw new Error("getImageData");return t.width=e.width,t.height=e.height,i.drawImage(e,0,0),i.getImageData(0,0,e.width,e.height);default:throw new Error("getImageData")}}const jd=/^data:image\/svg\+xml/,Gd=/\.svg((\?|#).*)?$/;function Hd(e){return e&&(jd.test(e)||Gd.test(e))}function Qd(e,t){if(Hd(t))throw new Error("SVG cannot be parsed directly to imagebitmap");return new Blob([new Uint8Array(e)])}async function $d(e,t,i){const n=function(e,t){if(Hd(t)){let t=(new TextDecoder).decode(e);try{"function"==typeof unescape&&"function"==typeof encodeURIComponent&&(t=unescape(encodeURIComponent(t)))}catch(e){throw new Error(e.message)}return`data:image/svg+xml;base64,${btoa(t)}`}return Qd(e,t)}(e,i),r=self.URL||self.webkitURL,o="string"!=typeof n&&r.createObjectURL(n);try{return await async function(e,t){const i=new Image;if(i.src=e,t.image&&t.image.decode&&i.decode)return await i.decode(),i;return await new Promise((e,t)=>{try{i.onload=()=>e(i),i.onerror=e=>{const i=e instanceof Error?e.message:"error";t(new Error(i))}}catch(e){t(e)}})}(o||n,t)}finally{o&&r.revokeObjectURL(o)}}const Zd={};let Wd=!0;async function qd(e,t,i){let n;if(Hd(i)){n=await $d(e,t,i)}else n=Qd(e,i);const r=t&&t.imagebitmap;return await async function(e,t=null){!function(e){for(const t in e||Zd)return!1;return!0}(t)&&Wd||(t=null);if(t)try{return await createImageBitmap(e,t)}catch(e){console.warn(e),Wd=!1}return await createImageBitmap(e)}(n,r)}function Kd(e){return function(e,t,i=0){const n=(r=t,[...r].map(e=>e.charCodeAt(0)));var r;for(let t=0;t=24&&2303741511===t.getUint32(0,Xd);if(!i)return null;return{mimeType:"image/png",width:t.getUint32(16,Xd),height:t.getUint32(20,Xd)}}(t)||function(e){const t=ep(e),i=t.byteLength>=3&&65496===t.getUint16(0,Xd)&&255===t.getUint8(2);if(!i)return null;const{tableMarkers:n,sofMarkers:r}=function(){const e=new Set([65499,65476,65484,65501,65534]);for(let t=65504;t<65520;++t)e.add(t);const t=new Set([65472,65473,65474,65475,65477,65478,65479,65481,65482,65483,65485,65486,65487,65502]);return{tableMarkers:e,sofMarkers:t}}();let o=2;for(;o+9=10&&1195984440===t.getUint32(0,Xd);if(!i)return null;return{mimeType:"image/gif",width:t.getUint16(6,Jd),height:t.getUint16(8,Jd)}}(t)||function(e){const t=ep(e),i=t.byteLength>=14&&16973===t.getUint16(0,Xd)&&t.getUint32(2,Jd)===t.byteLength;if(!i)return null;return{mimeType:"image/bmp",width:t.getUint32(18,Jd),height:t.getUint32(22,Jd)}}(t)||function(e){const t=new Uint8Array(e instanceof DataView?e.buffer:e),i=Kd(t);if(!i)return null;return{mimeType:i.mimeType,width:0,height:0}}(t)}function ep(e){if(e instanceof DataView)return e;if(ArrayBuffer.isView(e))return new DataView(e.buffer);if(e instanceof ArrayBuffer)return new DataView(e);throw new Error("toDataView")}const tp={dataType:null,batchType:null,id:"image",module:"images",name:"Images",version:"4.3.3",mimeTypes:["image/png","image/jpeg","image/gif","image/webp","image/avif","image/bmp","image/vnd.microsoft.icon","image/svg+xml"],extensions:["png","jpg","jpeg","gif","webp","bmp","ico","svg","avif"],parse:async function(e,t,i){const n=((t=t||{}).image||{}).type||"auto",{url:r}=i||{},o=function(e){switch(e){case"auto":case"data":return function(){if(Od)return"imagebitmap";if(Dd)return"image";if(Ud)return"data";throw new Error("Install '@loaders.gl/polyfills' to parse images under Node.js")}();default:return function(e){switch(e){case"auto":return Od||Dd||Ud;case"imagebitmap":return Od;case"image":return Dd;case"data":return Ud;default:throw new Error(`@loaders.gl/images: image ${e} not supported in this environment`)}}(e),e}}(n);let s;switch(o){case"imagebitmap":s=await qd(e,t,r);break;case"image":s=await $d(e,t,r);break;case"data":s=await async function(e){const{mimeType:t}=Yd(e)||{},i=globalThis.loaders?.parseImageNode;return Tu(i),await i(e,t)}(e);break;default:Tu(!1)}return"data"===n&&(s=Vd(s)),s},tests:[e=>Boolean(Yd(new DataView(e)))],options:{image:{type:"auto",decode:!0}}},ip={};function np(e){if(void 0===ip[e]){const t=Eu?function(e){switch(e){case"image/avif":case"image/webp":return function(e){try{const t=document.createElement("canvas");return 0===t.toDataURL(e).indexOf(`data:${e}`)}catch{return!1}}(e);default:return!0}}(e):function(e){const t=["image/png","image/jpeg","image/gif"],i=globalThis.loaders?.imageFormatsNode||t,n=globalThis.loaders?.parseImageNode;return Boolean(n)&&i.includes(e)}(e);ip[e]=t}return ip[e]}var rp=new Gu({id:"deck"});const op={attributeUpdateStart:-1,attributeManagerUpdateStart:-1,attributeUpdateMessages:[]};let sp={};function ap(e){sp=e}function lp(e,t,i,n){rp.level>0&&sp[e]&&sp[e].call(null,t,i,n)}sp=(e=>({"layer.changeFlag":(t,i,n)=>{e.log(3,`${t.id} ${i}: `,n[i])()},"layer.initialize":t=>{e.log(1,`Initializing ${t}`)()},"layer.update":(t,i)=>{if(i){const i=t.getChangeFlags();e.log(2,`Updating ${t} because: ${Object.keys(i).filter(e=>i[e]).join(", ")}`)()}else e.log(4,`${t} does not need update`)()},"layer.matched":(t,i)=>{i&&e.log(4,`Matched ${t}, state transfered`)()},"layer.finalize":t=>{e.log(1,`Finalizing ${t}`)()},"compositeLayer.renderLayers":(t,i,n)=>{i?e.log(2,`Composite layer rendered new subLayers ${t}`,n)():e.log(4,`Composite layer reused subLayers ${t}`,n)()},"layerManager.setLayers":(t,i,n)=>{i&&e.log(2,`Updating ${n.length} deck layers`)()},"layerManager.activateViewport":(t,i)=>{e.log(3,"Viewport changed",i)()},"attributeManager.invalidate":(t,i,n)=>{e.log(1,n?`invalidated attributes ${n} (${i}) for ${t.id}`:`invalidated all attributes for ${t.id}`)()},"attributeManager.updateStart":e=>{op.attributeUpdateMessages.length=0,op.attributeManagerUpdateStart=Date.now()},"attributeManager.updateEnd":(t,i)=>{const n=Math.round(Date.now()-op.attributeManagerUpdateStart);e.groupCollapsed(2,`Updated attributes for ${i} instances in ${t.id} in ${n}ms`)();for(const t of op.attributeUpdateMessages)e.log(3,t)();e.groupEnd(2)()},"attribute.updateStart":e=>{op.attributeUpdateStart=Date.now()},"attribute.allocate":(e,t)=>{const i=`${e.id} allocated ${t}`;op.attributeUpdateMessages.push(i)},"attribute.updateEnd":(e,t)=>{const i=Math.round(Date.now()-op.attributeUpdateStart),n=`${e.id} updated ${t} in ${i}ms`;op.attributeUpdateMessages.push(n)},"deckRenderer.renderLayers":(t,i,n)=>{const{pass:r,redrawReason:o,stats:s}=n;for(const n of i){const{totalCount:i,visibleCount:a,compositeCount:l,pickableCount:c}=n,u=i-l-a;e.log(2,`RENDER #${t.renderCount} ${a} (of ${i} layers) to ${r} because ${o} (${u} hidden, ${l} composite ${c} pickable)`)(),s&&s.get("Redraw Layers").add(a)}}}))(rp);var cp={dataType:null,batchType:null,id:"JSON",name:"JSON",module:"",version:"",options:{},extensions:["json","geojson"],mimeTypes:["application/json","application/geo+json"],testText:function(e){const t=e[0],i=e[e.length-1];return"{"===t&&"}"===i||"["===t&&"]"===i},parseTextSync:JSON.parse};const up=function(){const e="9.0.41",t=globalThis.deck&&globalThis.deck.VERSION;if(t&&t!==e)throw new Error(`deck.gl - multiple versions detected: ${t} vs ${e}`);return t||(rp.log(1,`deck.gl ${e}`)(),globalThis.deck={...globalThis.deck,VERSION:e,version:e,log:rp,_registerLoggers:ap},function(e){const t=pd();e=Array.isArray(e)?e:[e];for(const i of e){const e=dd(i);t.find(t=>e===t)||t.unshift(e)}}([cp,[tp,{imagebitmap:{premultiplyAlpha:"none"}}]])),e}();function hp(e,t){if(!e)throw new Error(t||"shadertools: assertion failed.")}const dp={number:{type:"number",validate:(e,t)=>Number.isFinite(e)&&"object"==typeof t&&(void 0===t.max||e<=t.max)&&(void 0===t.min||e>=t.min)},array:{type:"array",validate:(e,t)=>Array.isArray(e)||ArrayBuffer.isView(e)}};function pp(e){let t=fp(e);if("object"!==t)return{value:e,...dp[t],type:t};if("object"==typeof e)return e?void 0!==e.type?{...e,...dp[e.type],type:e.type}:void 0===e.value?{type:"object",value:e}:(t=fp(e.value),{...e,...dp[t],type:t}):{type:"object",value:null};throw new Error("props")}function fp(e){return Array.isArray(e)||ArrayBuffer.isView(e)?"array":typeof e}const mp={vertex:"#ifdef MODULE_LOGDEPTH\nlogdepth_adjustPosition(gl_Position);\n#endif\n",fragment:"#ifdef MODULE_MATERIAL\ngl_FragColor = material_filterColor(gl_FragColor);\n#endif\n#ifdef MODULE_LIGHTING\ngl_FragColor = lighting_filterColor(gl_FragColor);\n#endif\n#ifdef MODULE_FOG\ngl_FragColor = fog_filterColor(gl_FragColor);\n#endif\n#ifdef MODULE_PICKING\ngl_FragColor = picking_filterHighlightColor(gl_FragColor);\ngl_FragColor = picking_filterPickingColor(gl_FragColor);\n#endif\n#ifdef MODULE_LOGDEPTH\nlogdepth_setFragDepth();\n#endif\n"},gp=/void\s+main\s*\([^)]*\)\s*\{\n?/,_p=/}\n?[^{}]*$/,Ap=[],yp="__LUMA_INJECT_DECLARATIONS__";function vp(e){const t=e.slice(0,2);switch(t){case"vs":return"vertex";case"fs":return"fragment";default:throw new Error(t)}}function xp(e,t,i,n=!1){const r="vertex"===t;for(const t in i){const n=i[t];n.sort((e,t)=>e.order-t.order),Ap.length=n.length;for(let e=0,t=n.length;ee+o));break;case"vs:#main-end":r&&(e=e.replace(_p,e=>o+e));break;case"fs:#decl":r||(e=e.replace(yp,o));break;case"fs:#main-start":r||(e=e.replace(gp,e=>e+o));break;case"fs:#main-end":r||(e=e.replace(_p,e=>o+e));break;default:e=e.replace(t,e=>e+o)}}return e=e.replace(yp,""),n&&(e=e.replace(/\}\s*$/,e=>e+mp[t])),e}let bp=1;class wp{name;vs;fs;getModuleUniforms;dependencies;deprecations;defines;injections;uniforms={};uniformTypes={};static instantiateModules(e){return e.map(e=>{if(e instanceof wp)return e;hp("string"!=typeof e,`Shader module use by name is deprecated. Import shader module '${JSON.stringify(e)}' and use it directly.`),e.name||(console.warn("shader module has no name"),e.name="shader-module-"+bp++);const t=new wp(e);return t.dependencies=wp.instantiateModules(e.dependencies||[]),t})}constructor(e){const{name:t,vs:i,fs:n,dependencies:r=[],uniformTypes:o={},uniformPropTypes:s={},getUniforms:a,deprecations:l=[],defines:c={},inject:u={}}=e;hp("string"==typeof t),this.name=t,this.vs=i,this.fs=n,this.getModuleUniforms=a,this.dependencies=wp.instantiateModules(r),this.deprecations=this._parseDeprecationDefinitions(l),this.defines=c,this.injections=function(e){const t={vertex:{},fragment:{}};for(const i in e){let n=e[i];"string"==typeof n&&(n={order:0,injection:n}),t[vp(i)][i]=n}return t}(u),this.uniformTypes=o,s&&(this.uniforms=function(e){const t={};for(const[i,n]of Object.entries(e))t[i]=pp(n);return t}(s))}getModuleSource(e){let t;switch(e){case"vertex":t=this.vs||"";break;case"fragment":t=this.fs||"";break;default:hp(!1)}const i=this.name.toUpperCase().replace(/[^0-9a-z]/gi,"_");return`// ----- MODULE ${this.name} ---------------\n\n#define MODULE_${i}\n${t}\n\n`}getUniforms(e,t){return this.getModuleUniforms?this.getModuleUniforms(e,t):function(e,t,i){const n={};for(const[r,o]of Object.entries(t))e&&r in e&&!o.private?(o.validate&&hp(o.validate(e[r],o),`${i}: invalid ${r}`),n[r]=e[r]):n[r]=o.value;return n}(e,this.uniforms,this.name)}getDefines(){return this.defines}checkDeprecations(e,t){this.deprecations.forEach(i=>{i.regex?.test(e)&&(i.deprecated?t.deprecated(i.old,i.new)():t.removed(i.old,i.new)())})}_parseDeprecationDefinitions(e){return e.forEach(e=>{if("function"===e.type)e.regex=new RegExp(`\\b${e.old}\\(`);else e.regex=new RegExp(`${e.type} ${e.old};`)}),e}_defaultGetUniforms(e={}){const t={},i=this.uniforms;for(const n in i){const r=i[n];n in e&&!r.private?(r.validate&&hp(r.validate(e[n],r),`${this.name}: invalid ${n}`),t[n]=e[n]):t[n]=r.value}return t}}function Tp(e){if(e.source&&"webgpu"===e.platformInfo.type){return{...e,vs:void 0,fs:void 0}}if(!e.vs)throw new Error("no vertex shader");const t=Ep(e.platformInfo,e.vs);let i;return e.fs&&(i=Ep(e.platformInfo,e.fs)),{...e,vs:t,fs:i}}function Ep(e,t){if("string"==typeof t)return t;if("webgpu"===e.type){if(t?.wgsl)return t.wgsl;throw new Error("WebGPU does not support GLSL shaders")}if(t?.glsl)return t.glsl;throw new Error("WebGL does not support WGSL shaders")}function Cp(e){return function(e){const t={},i={};return Sp({modules:e,level:0,moduleMap:t,moduleDepth:i}),Object.keys(i).sort((e,t)=>i[t]-i[e]).map(e=>t[e])}(wp.instantiateModules(e))}function Sp(e){const{modules:t,level:i,moduleMap:n,moduleDepth:r}=e;if(i>=5)throw new Error("Possible loop in shader dependency graph");for(const e of t)n[e.name]=e,(void 0===r[e.name]||r[e.name]e.order-t.order);for(const t of e)i+=` ${t.injection}\n`}r.footer&&(i+=` ${r.footer}`),i+="}\n"}return i}function Fp(e){const t={vertex:{},fragment:{}};for(const i of e){let e,n;"string"!=typeof i?(e=i,n=e.hook):(e={},n=i),n=n.trim();const[r,o]=n.split(":"),s=n.replace(/\(.+/,""),a=Object.assign(e,{signature:o});switch(r){case"vs":t.vertex[s]=a;break;case"fs":t.fragment[s]=a;break;default:throw new Error(r)}}return t}function kp(e,t="unnamed"){const i=/#define[^\S\r\n]*SHADER_NAME[^\S\r\n]*([A-Za-z0-9_-]+)\s*/.exec(e);return i?i[1]:t}function Dp(e){let t=100;const i=e.match(/[^\s]+/g);if(i&&i.length>=2&&"#version"===i[0]){const e=parseInt(i[1],10);Number.isFinite(e)&&(t=e)}if(100!==t&&300!==t)throw new Error(`Invalid GLSL version ${t}`);return t}const Op=`\n\n${yp}\n`;function zp(e,t){const{source:i,stage:n,modules:r,hookFunctions:o=[],inject:s={},log:a}=t;hp("string"==typeof i,"shader source must be a string");const l=i;let c="";const u=Fp(o),h={},d={},p={};for(const e in s){const t="string"==typeof s[e]?{injection:s[e],order:0}:s[e],i=/^(v|f)s:(#)?([\w-]+)$/.exec(e);if(i){const n=i[2],r=i[3];n?"decl"===r?d[e]=[t]:p[e]=[t]:h[e]=[t]}else p[e]=[t]}const f="webgpu"!==e.type?r:[];for(const e of f){a&&e.checkDeprecations(l,a);c+=e.getModuleSource(n,"wgsl");const t=e.injections[n];for(const e in t){const i=/^(v|f)s:#([\w-]+)$/.exec(e);if(i){const n="decl"===i[2]?d:p;n[e]=n[e]||[],n[e].push(t[e])}else h[e]=h[e]||[],h[e].push(t[e])}}return c+=Op,c=xp(c,n,d),c+=Lp(u[n],h),c+=l,c=xp(c,n,p),c}function Up(e,t){const{id:i,source:n,stage:r,language:o="glsl",modules:s,defines:a={},hookFunctions:l=[],inject:c={},prologue:u=!0,log:h}=t;hp("string"==typeof n,"shader source must be a string");const d="glsl"===o?function(e,t){return{name:kp(e,t),language:"glsl",version:Dp(e)}}(n).version:-1,p=e.shaderLanguageVersion,f=100===d?"#version 100":"#version 300 es",m=n.split("\n").slice(1).join("\n"),g={};s.forEach(e=>{Object.assign(g,e.getDefines())}),Object.assign(g,a);let _="";switch(o){case"wgsl":break;case"glsl":_=u?`${f}\n\n// ----- PROLOGUE -------------------------\n${function(e){const{id:t,source:i,stage:n}=e,r=t&&-1===i.indexOf("SHADER_NAME");return r?`\n#define SHADER_NAME ${t}_${n}\n\n`:""}({id:i,source:n,stage:r})}\n#define SHADER_TYPE_${r.toUpperCase()}\n${function(e){switch(e?.gpu.toLowerCase()){case"apple":return"#define APPLE_GPU\n#define LUMA_FP64_CODE_ELIMINATION_WORKAROUND 1\n#define LUMA_FP32_TAN_PRECISION_WORKAROUND 1\n#define LUMA_FP64_HIGH_BITS_OVERFLOW_WORKAROUND 1\n";case"nvidia":return"#define NVIDIA_GPU\n#define LUMA_FP64_CODE_ELIMINATION_WORKAROUND 1\n";case"intel":return"#define INTEL_GPU\n#define LUMA_FP64_CODE_ELIMINATION_WORKAROUND 1\n#define LUMA_FP32_TAN_PRECISION_WORKAROUND 1\n#define LUMA_FP64_HIGH_BITS_OVERFLOW_WORKAROUND 1\n";case"amd":return"#define AMD_GPU\n";default:return"#define DEFAULT_GPU\n#define LUMA_FP64_CODE_ELIMINATION_WORKAROUND 1\n#define LUMA_FP32_TAN_PRECISION_WORKAROUND 1\n#define LUMA_FP64_HIGH_BITS_OVERFLOW_WORKAROUND 1\n"}}(e)}\n${"fragment"===r?"precision highp float;\n":""}\n\n// ----- APPLICATION DEFINES -------------------------\n\n${function(e={}){let t="";for(const i in e){const n=e[i];(n||Number.isFinite(n))&&(t+=`#define ${i.toUpperCase()} ${e[i]}\n`)}return t}(g)}\n\n`:`${f}\n`}const A=Fp(l),y={},v={},x={};for(const e in c){const t="string"==typeof c[e]?{injection:c[e],order:0}:c[e],i=/^(v|f)s:(#)?([\w-]+)$/.exec(e);if(i){const n=i[2],r=i[3];n?"decl"===r?v[e]=[t]:x[e]=[t]:y[e]=[t]}else x[e]=[t]}for(const e of s){h&&e.checkDeprecations(m,h);_+=e.getModuleSource(r);const t=e.injections[r];for(const e in t){const i=/^(v|f)s:#([\w-]+)$/.exec(e);if(i){const n="decl"===i[2]?v:x;n[e]=n[e]||[],n[e].push(t[e])}else y[e]=y[e]||[],y[e].push(t[e])}}return _+="// ----- MAIN SHADER SOURCE -------------------------",_+=Op,_=xp(_,r,v),_+=Lp(A[r],y),_+=m,_=xp(_,r,x),"glsl"===o&&d!==p&&(_=function(e,t){if(300!==Number(e.match(/^#version[ \t]+(\d+)/m)?.[1]||100))throw new Error("luma.gl v9 only supports GLSL 3.00 shader sources");switch(t){case"vertex":return Pp(e,Ip);case"fragment":return Pp(e,Mp);default:throw new Error(t)}}(_,r)),_.trim()}function Np(e){return function(t){const i={};for(const n of e){const e=n.getUniforms(t,i);Object.assign(i,e)}return i}}class Vp{static defaultShaderAssembler;_hookFunctions=[];_defaultModules=[];static getDefaultShaderAssembler(){return Vp.defaultShaderAssembler=Vp.defaultShaderAssembler||new Vp,Vp.defaultShaderAssembler}addDefaultModule(e){this._defaultModules.find(t=>t.name===("string"==typeof e?e:e.name))||this._defaultModules.push(e)}removeDefaultModule(e){const t="string"==typeof e?e:e.name;this._defaultModules=this._defaultModules.filter(e=>e.name!==t)}addShaderHook(e,t){t&&(e=Object.assign(t,{hook:e})),this._hookFunctions.push(e)}assembleShader(e){const t=this._getModuleList(e.modules),i=this._hookFunctions,n=Tp(e),r=function(e){const t=Cp(e.modules||[]);return{source:zp(e.platformInfo,{...e,source:e.source,stage:"vertex",modules:t}),getUniforms:Np(t)}}({platformInfo:e.platformInfo,...n,modules:t,hookFunctions:i});return{...r,modules:t}}assembleShaderPair(e){const t=Tp(e),i=this._getModuleList(e.modules),n=this._hookFunctions,{platformInfo:r}=e,o="wgsl"===e.platformInfo.shaderLanguage?function(e){const t=Cp(e.modules||[]);return{vs:zp(e.platformInfo,{...e,source:e.vs,stage:"vertex",modules:t}),fs:zp(e.platformInfo,{...e,source:e.fs,stage:"fragment",modules:t}),getUniforms:Np(t)}}({platformInfo:r,...t,modules:i,hookFunctions:n}):function(e){const{vs:t,fs:i}=e,n=Cp(e.modules||[]);return{vs:Up(e.platformInfo,{...e,source:t,stage:"vertex",modules:n}),fs:Up(e.platformInfo,{...e,source:i,stage:"fragment",modules:n}),getUniforms:Np(n)}}({platformInfo:r,...t,modules:i,hookFunctions:n});return{...o,modules:i}}_getModuleList(e=[]){const t=new Array(this._defaultModules.length+e.length),i={};let n=0;for(let e=0,r=this._defaultModules.length;eGp.error(e.message)};get[Symbol.toStringTag](){return"Device"}static VERSION=Qp;constructor(e){this.props={...lf.defaultProps,...e},this.id=this.props.id||Wp(this[Symbol.toStringTag].toLowerCase())}id;props;userData={};statsManager=Hp;_lumaData={};isTextureFormatCompressed(e){return t=e,tf.some(e=>t.startsWith(e));var t}loseDevice(){return!1}getCanvasContext(){if(!this.canvasContext)throw new Error("Device has no CanvasContext");return this.canvasContext}createTexture(e){return(e instanceof Promise||"string"==typeof e)&&(e={data:e}),this._createTexture(e)}createCommandEncoder(e={}){throw new Error("not implemented")}readPixelsToArrayWebGL(e,t){throw new Error("not implemented")}readPixelsToBufferWebGL(e,t){throw new Error("not implemented")}setParametersWebGL(e){throw new Error("not implemented")}getParametersWebGL(e){throw new Error("not implemented")}withParametersWebGL(e,t){throw new Error("not implemented")}clearWebGL(e){throw new Error("not implemented")}resetWebGL(){throw new Error("not implemented")}timestamp=0;incrementTimestamp(){return this.timestamp++}onError(e){this.props.onError(e)}_getBufferProps(e){(e instanceof ArrayBuffer||ArrayBuffer.isView(e))&&(e={data:e});const t={...e};return(e.usage||0)&Xp.INDEX&&!e.indexType&&(e.data instanceof Uint32Array?t.indexType="uint32":e.data instanceof Uint16Array?t.indexType="uint16":Gp.warn("indices buffer content must be of integer type")()),t}}function cf(e,t){if(!e)throw new Error(t||"luma.gl: assertion failed.")}const uf=new Map;class hf{static defaultProps={...lf.defaultProps,type:"best-available",devices:void 0};static stats=Hp;static log=Gp;static registerDevices(e){for(const t of e)cf(t.type&&t.isSupported&&t.create),uf.set(t.type,t)}static getAvailableDevices(){return Array.from(uf).map(e=>e.type)}static getSupportedDevices(){return Array.from(uf).filter(e=>e.isSupported()).map(e=>e.type)}static setDefaultDeviceProps(e){Object.assign(lf.defaultProps,e)}static async attachDevice(e){const t=df(e.devices)||uf;if(e.handle instanceof WebGL2RenderingContext){const i=t.get("webgl");if(i)return await i.attach(e.handle)}if(null===e.handle){const e=t.get("unknown");if(e)return await e.attach(null)}throw new Error("Failed to attach device. Ensure `@luma.gl/webgl` and/or `@luma.gl/webgpu` modules are imported.")}static async createDevice(e={}){(e={...hf.defaultProps,...e}).gl&&(e.type="webgl");const t=df(e.devices)||uf;let i,n;switch(e.type){case"webgpu":if(i=t.get("webgpu"),i)return await i.create(e);break;case"webgl":if(n=t.get("webgl"),n)return await n.create(e);break;case"unknown":const r=t.get("unknown");if(r)return await r.create(e);break;case"best-available":if(i=t.get("webgpu"),i?.isSupported?.())return await i.create(e);if(n=t.get("webgl"),n?.isSupported?.())return await n.create(e)}throw new Error("No matching device found. Ensure `@luma.gl/webgl` and/or `@luma.gl/webgpu` modules are imported.")}static enforceWebGL2(e=!0){const t=HTMLCanvasElement.prototype;if(!e&&t.originalGetContext)return t.getContext=t.originalGetContext,void(t.originalGetContext=void 0);t.originalGetContext=t.getContext,t.getContext=function(e,t){return"webgl"===e||"experimental-webgl"===e?this.originalGetContext("webgl2",t):this.originalGetContext(e,t)}}}function df(e){if(!e||0===e?.length)return null;const t=new Map;for(const i of e)t.set(i.type,i);return t}const pf=Pu()&&"undefined"!=typeof document,ff=()=>pf&&"complete"===document.readyState,mf={canvas:null,width:800,height:600,useDevicePixels:!0,autoResize:!0,container:null,visible:!0,colorSpace:"srgb",alphaMode:"opaque"};class gf{id;props;canvas;htmlCanvas;offscreenCanvas;type;width=1;height=1;resizeObserver;_canvasSizeInfo={clientWidth:0,clientHeight:0,devicePixelRatio:1};static get isPageLoaded(){return ff()}static pageLoaded=function(){if(ff()||"undefined"==typeof window)return Promise.resolve();return new Promise(e=>{window.addEventListener("load",()=>e())})}();constructor(e){if(this.props={...mf,...e},e=this.props,!Pu())return this.id="node-canvas-context",this.type="node",this.width=this.props.width,this.height=this.props.height,void(this.canvas=null);if(e.canvas)"string"==typeof e.canvas?this.canvas=function(e){const t=document.getElementById(e);if(!t&&!ff())throw new Error(`Accessing '${e}' before page was loaded`);if(!(t instanceof HTMLCanvasElement))throw new Error("Object is not a canvas element");return t}(e.canvas):this.canvas=e.canvas;else{const t=function(e){const{width:t,height:i}=e,n=document.createElement("canvas");return n.id="lumagl-auto-created-canvas",n.width=t||1,n.height=i||1,n.style.width=Number.isFinite(t)?`${t}px`:"100%",n.style.height=Number.isFinite(i)?`${i}px`:"100%",n}(e),i=function(e){if("string"==typeof e){const t=document.getElementById(e);if(!t&&!ff())throw new Error(`Accessing '${e}' before page was loaded`);if(!t)throw new Error(`${e} is not an HTML element`);return t}if(e)return e;return document.body}(e?.container||null);i.insertBefore(t,i.firstChild),this.canvas=t,e?.visible||(this.canvas.style.visibility="hidden")}this.canvas instanceof HTMLCanvasElement?(this.id=this.canvas.id,this.type="html-canvas",this.htmlCanvas=this.canvas):(this.id="offscreen-canvas",this.type="offscreen-canvas",this.offscreenCanvas=this.canvas),this.canvas instanceof HTMLCanvasElement&&e.autoResize&&(this.resizeObserver=new ResizeObserver(e=>{for(const t of e)t.target===this.canvas&&this.update()}),this.resizeObserver.observe(this.canvas))}getDevicePixelRatio(e){if("undefined"!=typeof OffscreenCanvas&&this.canvas instanceof OffscreenCanvas)return 1;if(!(e=void 0===e?this.props.useDevicePixels:e)||e<=0)return 1;if(!0===e){return"undefined"!=typeof window&&window.devicePixelRatio||1}return e}getPixelSize(){switch(this.type){case"node":return[this.width,this.height];case"offscreen-canvas":return[this.canvas.width,this.canvas.height];case"html-canvas":const e=this.getDevicePixelRatio(),t=this.canvas;return t.parentElement?[t.clientWidth*e,t.clientHeight*e]:[this.canvas.width,this.canvas.height];default:throw new Error(this.type)}}getAspect(){const[e,t]=this.getPixelSize();return e/t}cssToDeviceRatio(){try{const[e]=this.getDrawingBufferSize(),t=this._canvasSizeInfo.clientWidth||this.htmlCanvas?.clientWidth;return t?e/t:1}catch{return 1}}cssToDevicePixels(e,t=!0){const i=this.cssToDeviceRatio(),[n,r]=this.getDrawingBufferSize();return function(e,t,i,n,r){const o=e,s=_f(o[0],t,i);let a=Af(o[1],t,n,r),l=_f(o[0]+1,t,i);const c=l===i-1?l:l-1;let u;l=Af(o[1]+1,t,n,r),r?(l=0===l?l:l+1,u=a,a=l):u=l===n-1?l:l-1;return{x:s,y:a,width:Math.max(c-s+1,1),height:Math.max(u-a+1,1)}}(e,i,n,r,t)}setDevicePixelRatio(e,t={}){if(!this.htmlCanvas)return;let i="width"in t?t.width:this.htmlCanvas.clientWidth,n="height"in t?t.height:this.htmlCanvas.clientHeight;i&&n||(Gp.log(1,"Canvas clientWidth/clientHeight is 0")(),e=1,i=this.htmlCanvas.width||1,n=this.htmlCanvas.height||1);const r=this._canvasSizeInfo;if(r.clientWidth!==i||r.clientHeight!==n||r.devicePixelRatio!==e){let t=e;const r=Math.floor(i*t),o=Math.floor(n*t);this.htmlCanvas.width=r,this.htmlCanvas.height=o;const[s,a]=this.getDrawingBufferSize();s===r&&a===o||(t=Math.min(s/i,a/n),this.htmlCanvas.width=Math.floor(i*t),this.htmlCanvas.height=Math.floor(n*t),Gp.warn("Device pixel ratio clamped")()),this._canvasSizeInfo.clientWidth=i,this._canvasSizeInfo.clientHeight=n,this._canvasSizeInfo.devicePixelRatio=e}}getDrawingBufferSize(){const e=this.device.gl;if(!e)throw new Error("canvas size");return[e.drawingBufferWidth,e.drawingBufferHeight]}_setAutoCreatedCanvasId(e){"lumagl-auto-created-canvas"===this.htmlCanvas?.id&&(this.htmlCanvas.id=e)}}function _f(e,t,i){return Math.min(Math.round(e*t),i-1)}function Af(e,t,i,n){return n?Math.max(0,i-1-Math.round(e*t)):Math.min(Math.round(e*t),i-1)}class yf extends Kp{static defaultProps={...Kp.defaultProps,data:null,dimension:"2d",format:"rgba8unorm",width:void 0,height:void 0,depth:1,mipmaps:!0,compressed:!1,usage:0,mipLevels:void 0,samples:void 0,type:void 0,sampler:{},view:void 0};static COPY_SRC=1;static COPY_DST=2;static TEXTURE_BINDING=4;static STORAGE_BINDING=8;static RENDER_ATTACHMENT=16;get[Symbol.toStringTag](){return"Texture"}dimension;format;width;height;depth;updateTimestamp;constructor(e,t,i=yf.defaultProps){super(e,t,i),this.dimension=this.props.dimension,this.format=this.props.format,this.width=this.props.width,this.height=this.props.height,this.depth=this.props.depth,this.updateTimestamp=e.incrementTimestamp()}}class vf extends Kp{static defaultProps={...Kp.defaultProps,format:void 0,dimension:void 0,aspect:"all",baseMipLevel:0,mipLevelCount:void 0,baseArrayLayer:0,arrayLayerCount:void 0};get[Symbol.toStringTag](){return"TextureView"}constructor(e,t){super(e,t,vf.defaultProps)}}function xf(e,t,i,n){if(n?.inlineSource){const n=function(e,t,i){let n="";for(let r=t-2;r<=t;r++){const o=e[r-1];void 0!==o&&(n+=bf(o,t,i))}return n}(t,i);return`\n${n}${e.linePos>0?`${" ".repeat(e.linePos+5)}^^^\n`:""}${e.type.toUpperCase()}: ${e.message}\n\n`}return n?.html?`
${e.type.toUpperCase()}: ${e.message}
`:`${e.type.toUpperCase()}: ${e.message}`}function bf(e,t,i){const n=i?.html?e.replaceAll("&","&").replaceAll("<","<").replaceAll(">",">").replaceAll('"',""").replaceAll("'","'"):e;return`${function(e,t){let i="";for(let n=e.length;n":"\n"}`}function wf(e,t){return{name:Tf(e,t),language:"glsl",version:Ef(e)}}function Tf(e,t="unnamed"){const i=/#define[\s*]SHADER_NAME[\s*]([A-Za-z0-9_-]+)[\s*]/.exec(e);return i?i[1]:t}function Ef(e){let t=100;const i=e.match(/[^\s]+/g);if(i&&i.length>=2&&"#version"===i[0]){const e=parseInt(i[1],10);Number.isFinite(e)&&(t=e)}return t}class Cf extends Kp{static defaultProps={...Kp.defaultProps,language:"auto",stage:void 0,source:"",sourceMap:null,entryPoint:"main",debug:"errors"};get[Symbol.toStringTag](){return"Shader"}stage;source;compilationStatus="pending";constructor(e,t){super(e,{id:Sf(t),...t},Cf.defaultProps),this.stage=this.props.stage,this.source=this.props.source}getCompilationInfoSync(){return null}getTranslatedSource(){return null}async debugShader(e=this.props.debug){switch(e){case"never":return;case"errors":if("success"===this.compilationStatus)return}const t=await this.getCompilationInfo();"warnings"===this.props.debug&&0===t?.length||this._displayShaderLog(t)}_displayShaderLog(e){if("undefined"==typeof document||!document?.createElement)return;const t=wf(this.source).name,i=`${this.stage} ${t}`;let n=function(e,t,i){let n="";const r=t.split(/\r?\n/),o=e.slice().sort((e,t)=>e.lineNum-t.lineNum);switch(i?.showSourceCode||"no"){case"all":let t=0;for(let e=1;e<=r.length;e++)for(n+=bf(r[e-1],e,i);o.length>t&&o[t].lineNum===e;){const e=o[t++];n+=xf(e,r,e.lineNum,{...i,inlineSource:!1})}return n;case"issues":case"no":for(const t of e)n+=xf(t,r,t.lineNum,{inlineSource:"no"!==i?.showSourceCode});return n}}(e,this.source,{showSourceCode:"all",html:!0});const r=this.getTranslatedSource();r&&(n+=`

Translated Source



${r}
`);const o=document.createElement("Button");o.innerHTML=`\n

Shader Compilation Error in ${i}



\n
\n${n}\n
`,o.style.top="10px",o.style.left="10px",o.style.position="absolute",o.style.zIndex="9999",o.style.width="100%",o.style.textAlign="left",document.body.appendChild(o);const s=document.getElementsByClassName("luma-compiler-log-error");s[0]?.scrollIntoView&&s[0].scrollIntoView(),o.onclick=()=>{const e=`data:text/plain,${encodeURIComponent(this.source)}`;navigator.clipboard.writeText(e)}}}function Sf(e){return wf(e.source).name||e.id||Wp(`unnamed ${e.stage}-shader`)}class Bf extends Kp{static defaultProps={...Kp.defaultProps,type:"color-sampler",addressModeU:"clamp-to-edge",addressModeV:"clamp-to-edge",addressModeW:"clamp-to-edge",magFilter:"nearest",minFilter:"nearest",mipmapFilter:"nearest",lodMinClamp:0,lodMaxClamp:32,compare:"less-equal",maxAnisotropy:1};get[Symbol.toStringTag](){return"Sampler"}constructor(e,t){super(e,t,Bf.defaultProps)}}class If extends Kp{static defaultProps={...Kp.defaultProps,width:1,height:1,colorAttachments:[],depthStencilAttachment:null};get[Symbol.toStringTag](){return"Framebuffer"}width;height;colorAttachments=[];depthStencilAttachment=null;constructor(e,t={}){super(e,t,If.defaultProps),this.width=this.props.width,this.height=this.props.height}resize(e){let t=!e;if(e){const[i,n]=Array.isArray(e)?e:[e.width,e.height];t=t||n!==this.height||i!==this.width,this.width=i,this.height=n}t&&(Gp.log(2,`Resizing framebuffer ${this.id} to ${this.width}x${this.height}`)(),this.resizeAttachments(this.width,this.height))}autoCreateAttachmentTextures(){if(0===this.props.colorAttachments.length&&!this.props.depthStencilAttachment)throw new Error("Framebuffer has noattachments");this.colorAttachments=this.props.colorAttachments.map(e=>{if("string"==typeof e){const t=this.createColorTexture(e);return this.attachResource(t),t.view}return e instanceof yf?e.view:e});const e=this.props.depthStencilAttachment;if(e)if("string"==typeof e){const t=this.createDepthStencilTexture(e);this.attachResource(t),this.depthStencilAttachment=t.view}else this.depthStencilAttachment=e instanceof yf?e.view:e}createColorTexture(e){return this.device.createTexture({id:"color-attachment",usage:yf.RENDER_ATTACHMENT,format:e,width:this.width,height:this.height})}createDepthStencilTexture(e){return this.device.createTexture({id:"depth-stencil-attachment",usage:yf.RENDER_ATTACHMENT,format:e,width:this.width,height:this.height})}resizeAttachments(e,t){for(let i=0;i":["f32",2],"vec3":["f32",3],"vec4":["f32",4],f16:["f16",1],"vec2":["f16",2],"vec3":["f16",3],"vec4":["f16",4],i32:["i32",1],"vec2":["i32",2],"vec3":["i32",3],"vec4":["i32",4],u32:["u32",1],"vec2":["u32",2],"vec3":["u32",3],"vec4":["u32",4]},Df={f32:4,f16:2,i32:4,u32:4};function Of(e){let t;e.endsWith("-webgl")&&(e.replace("-webgl",""),t=!0);const[i,n]=e.split("x"),r=i,o=n?parseInt(n):1,s=Jp(r),a={type:r,components:o,byteLength:s.byteLength*o,integer:s.integer,signed:s.signed,normalized:s.normalized};return t&&(a.webglOnly=!0),a}function zf(e,t){const i={};for(const n of e.attributes)i[n.name]=Uf(e,t,n.name);return i}function Uf(e,t,i){const n=function(e,t){const i=e.attributes.find(e=>e.name===t);i||Gp.warn(`shader layout attribute "${t}" not present in shader`);return i||null}(e,i),r=function(e,t){Nf(e);let i=function(e,t){for(const i of e)if(i.format&&i.name===t)return{attributeName:i.name,bufferName:t,stepMode:i.stepMode,vertexFormat:i.format,byteOffset:0,byteStride:i.byteStride||0};return null}(e,t);if(i)return i;if(i=function(e,t){for(const i of e){let e=i.byteStride;if("number"!=typeof i.byteStride)for(const t of i.attributes||[]){e+=Of(t.format).byteLength}const n=i.attributes?.find(e=>e.attribute===t);if(n)return{attributeName:n.attribute,bufferName:i.name,stepMode:i.stepMode,vertexFormat:n.format,byteOffset:n.byteOffset,byteStride:e}}return null}(e,t),i)return i;return Gp.warn(`layout for attribute "${t}" not present in buffer layout`),null}(t,i);if(!n)return null;const o=function(e){const[t,i]=kf[e],n="i32"===t||"u32"===t,r="u32"!==t,o=Df[t]*i,s=function(e,t){let i;switch(e){case"f32":i="float32";break;case"i32":i="sint32";break;case"u32":i="uint32";break;case"f16":return t<=2?"float16x2":"float16x4"}return 1===t?i:`${i}x${t}`}(t,i);return{dataType:t,components:i,defaultVertexFormat:s,byteLength:o,integer:n,signed:r}}(n.type),s=r?.vertexFormat||o.defaultVertexFormat,a=Of(s);return{attributeName:r?.attributeName||n.name,bufferName:r?.bufferName||n.name,location:n.location,shaderType:n.type,shaderDataType:o.dataType,shaderComponents:o.components,vertexFormat:s,bufferDataType:a.type,bufferComponents:a.components,normalized:a.normalized,integer:o.integer,stepMode:r?.stepMode||n.stepMode,byteOffset:r?.byteOffset||0,byteStride:r?.byteStride||0}}function Nf(e){for(const t of e)(t.attributes&&t.format||!t.attributes&&!t.format)&&Gp.warn(`BufferLayout ${name} must have either 'attributes' or 'format' field`)}class Vf extends Kp{static defaultProps={...Kp.defaultProps,renderPipeline:null};get[Symbol.toStringTag](){return"VertexArray"}maxVertexAttributes;attributeInfos;indexBuffer=null;attributes;constructor(e,t){super(e,t,Vf.defaultProps),this.maxVertexAttributes=e.limits.maxVertexAttributes,this.attributes=new Array(this.maxVertexAttributes).fill(null),this.attributeInfos=function(e,t,i=16){const n=zf(e,t),r=new Array(i).fill(null);for(const e of Object.values(n))r[e.location]=e;return r}(t.renderPipeline.shaderLayout,t.renderPipeline.bufferLayout,this.maxVertexAttributes)}setConstantWebGL(e,t){throw new Error("constant attributes not supported")}}class jf extends Kp{static defaultProps={...Kp.defaultProps,layout:void 0,buffers:{}};get[Symbol.toStringTag](){return"TransformFeedback"}constructor(e,t){super(e,t,jf.defaultProps)}}class Gf extends Kp{static defaultProps={...Kp.defaultProps,type:void 0,count:void 0};get[Symbol.toStringTag](){return"QuerySet"}constructor(e,t){super(e,t,Gf.defaultProps)}}const Hf={f32:{type:"f32",components:1},i32:{type:"i32",components:1},u32:{type:"u32",components:1},"vec2":{type:"f32",components:2},"vec3":{type:"f32",components:3},"vec4":{type:"f32",components:4},"vec2":{type:"i32",components:2},"vec3":{type:"i32",components:3},"vec4":{type:"i32",components:4},"vec2":{type:"u32",components:2},"vec3":{type:"u32",components:3},"vec4":{type:"u32",components:4},"mat2x2":{type:"f32",components:4},"mat2x3":{type:"f32",components:6},"mat2x4":{type:"f32",components:8},"mat3x2":{type:"f32",components:6},"mat3x3":{type:"f32",components:9},"mat3x4":{type:"f32",components:12},"mat4x2":{type:"f32",components:8},"mat4x3":{type:"f32",components:12},"mat4x4":{type:"f32",components:16}};function Qf(e){const t=Hf[e];return cf(e),t}function $f(e,t){switch(t){case 1:return e;case 2:return e+e%2;default:return e+(4-e%4)%4}}let Zf;function Wf(e){return(!Zf||Zf.byteLength"uniform"===t.type&&t.name===e?.name);if(!t)throw new Error(e?.name);const i=t;for(const e of i.uniforms||[])this.bindingLayout[e.name]=e}}setUniforms(e){for(const[t,i]of Object.entries(e))this._setUniform(t,i),this.needsRedraw||this.setNeedsRedraw(`${this.name}.${t}=${i}`)}setNeedsRedraw(e){this.needsRedraw=this.needsRedraw||e}getAllUniforms(){return this.modifiedUniforms={},this.needsRedraw=!1,this.uniforms||{}}_setUniform(e,t){(function(e,t){if(e!==t)return!1;const i=$p(e);if(!i)return!1;const n=$p(t);if(n&&i.length===n.length)for(let e=0;e4)throw new Error(`size ${t}`);const n=t;let r=Jf(e);if("uint8"===r&&i&&1===n)return"unorm8-webgl";if("uint8"===r&&i&&3===n)return"unorm8x3-webgl";if("uint8"===r||"sint8"===r){if(1===n||3===n)throw new Error(`size: ${t}`);return i&&(r=r.replace("int","norm")),`${r}x${n}`}if("uint16"===r||"sint16"===r){if(1===n||3===n)throw new Error(`size: ${t}`);return i&&(r=r.replace("int","norm")),`${r}x${n}`}return 1===n?r:`${r}x${n}`}function tm(e){const t={bindings:{},uniforms:{}};return Object.keys(e).forEach(i=>{const n=e[i];var r;null!==$p(r=n)||"number"==typeof r||"boolean"==typeof r?t.uniforms[i]=n:t.bindings[i]=n}),t}async function im(e,t){return await new Promise((i,n)=>{try{const r=new Image;r.onload=()=>i(r),r.onerror=()=>n(new Error(`Could not load image ${e}.`)),r.crossOrigin=t?.crossOrigin||"anonymous",r.src=e.startsWith("http")?e:""+e}catch(e){n(e)}})}async function nm(e,t){const i=document.getElementsByTagName("head")[0];if(!i)throw new Error("loadScript");const n=document.createElement("script");return n.setAttribute("type","text/javascript"),n.setAttribute("src",e),t&&(n.id=t),new Promise((t,r)=>{n.onload=t,n.onerror=t=>r(new Error(`Unable to load script '${e}': ${t}`)),i.appendChild(n)})}function rm(e,t,i){if(e===t)return!0;if(!i||!e||!t)return!1;if(Array.isArray(e)){if(!Array.isArray(t)||e.length!==t.length)return!1;for(let n=0;n`}}class cm extends om{constructor(e,t,i){super(e,i),this.format=t}get isPointer(){return!0}getTypeName(){return`&${this.format.getTypeName()}`}}class um extends om{constructor(e,t,i,n){super(e,i),this.format=t,this.access=n}get isTemplate(){return!0}getTypeName(){let e=this.name;if(null!==this.format){if("vec2"===e||"vec3"===e||"vec4"===e||"mat2x2"===e||"mat2x3"===e||"mat2x4"===e||"mat3x2"===e||"mat3x3"===e||"mat3x4"===e||"mat4x2"===e||"mat4x3"===e||"mat4x4"===e){if("f32"===this.format.name)return e+="f",e;if("i32"===this.format.name)return e+="i",e;if("u32"===this.format.name)return e+="u",e;if("bool"===this.format.name)return e+="b",e;if("f16"===this.format.name)return e+="h",e}e+=`<${this.format.name}>`}else if("vec2"===e||"vec3"===e||"vec4"===e)return e;return e}}var hm;(e=>{e[e.Uniform=0]="Uniform",e[e.Storage=1]="Storage",e[e.Texture=2]="Texture",e[e.Sampler=3]="Sampler",e[e.StorageTexture=4]="StorageTexture"})(hm||(hm={}));class dm{constructor(e,t,i,n,r,o,s){this.name=e,this.type=t,this.group=i,this.binding=n,this.attributes=r,this.resourceType=o,this.access=s}get isArray(){return this.type.isArray}get isStruct(){return this.type.isStruct}get isTemplate(){return this.type.isTemplate}get size(){return this.type.size}get align(){return this.type.isStruct?this.type.align:0}get members(){return this.type.isStruct?this.type.members:null}get format(){return this.type.isArray||this.type.isTemplate?this.type.format:null}get count(){return this.type.isArray?this.type.count:0}get stride(){return this.type.isArray?this.type.stride:this.size}}class pm{constructor(e,t){this.name=e,this.type=t}}class fm{constructor(e,t,i,n){this.name=e,this.type=t,this.locationType=i,this.location=n,this.interpolation=null}}class mm{constructor(e,t,i,n){this.name=e,this.type=t,this.locationType=i,this.location=n}}class gm{constructor(e,t,i,n){this.name=e,this.type=t,this.attributes=i,this.id=n}}class _m{constructor(e,t,i){this.name=e,this.type=t,this.attributes=i}}class Am{constructor(e,t=null,i){this.stage=null,this.inputs=[],this.outputs=[],this.arguments=[],this.returnType=null,this.resources=[],this.overrides=[],this.startLine=-1,this.endLine=-1,this.inUse=!1,this.calls=new Set,this.name=e,this.stage=t,this.attributes=i}}class ym{constructor(){this.vertex=[],this.fragment=[],this.compute=[]}}function vm(e){var t=(32768&e)>>15,i=(31744&e)>>10,n=1023&e;return 0==i?(t?-1:1)*Math.pow(2,-14)*(n/Math.pow(2,10)):31==i?n?NaN:1/0*(t?-1:1):(t?-1:1)*Math.pow(2,i-15)*(1+n/Math.pow(2,10))}const xm=new Float32Array(1),bm=new Int32Array(xm.buffer),wm=new Uint16Array(1);function Tm(e){xm[0]=e;const t=bm[0],i=t>>31&1;let n=t>>23&255,r=8388607&t;if(255===n)return wm[0]=i<<15|31744|(0!==r?512:0),wm[0];if(0===n){if(0===r)return wm[0]=i<<15,wm[0];r|=8388608;let e=113;for(;!(8388608&r);)r<<=1,e--;return n=127-e,r&=8388607,n>0?(r=(r>>126-n)+(r>>127-n&1),wm[0]=i<<15|n<<10|r>>13,wm[0]):(wm[0]=i<<15,wm[0])}return n=n-127+15,n>=31?(wm[0]=i<<15|31744,wm[0]):n<=0?n<-10?(wm[0]=i<<15,wm[0]):(r=(8388608|r)>>1-n,wm[0]=i<<15|r>>13,wm[0]):(r>>=13,wm[0]=i<<15|n<<10|r,wm[0])}const Em=new Uint32Array(1),Cm=new Float32Array(Em.buffer,0,1);function Sm(e){const t=112+(e>>6&31)<<23|(63&e)<<17;return Em[0]=t,Cm[0]}function Bm(e,t,i,n){const r=[0,0,0,0];for(let o=0;o{e.increment="++",e.decrement="--"})(Qm||(Qm={})),(e=>{e.parse=function(t){const i=t;if("parse"==i)throw new Error("Invalid value for IncrementOperator");return e[i]}})(Qm||(Qm={}));class qm extends km{constructor(e,t){super(),this.operator=e,this.variable=t}get astNodeType(){return"increment"}search(e){this.variable.search(e)}}(e=>{e.assign="=",e.addAssign="+=",e.subtractAssin="-=",e.multiplyAssign="*=",e.divideAssign="/=",e.moduloAssign="%=",e.andAssign="&=",e.orAssign="|=",e.xorAssign="^=",e.shiftLeftAssign="<<=",e.shiftRightAssign=">>="})($m||($m={})),($m||($m={})).parse=function(e){const t=e;if("parse"==t)throw new Error("Invalid value for AssignOperator");return t};class Km extends km{constructor(e,t,i){super(),this.operator=e,this.variable=t,this.value=i}get astNodeType(){return"assign"}search(e){this.variable.search(e),this.value.search(e)}}class Xm extends km{constructor(e,t){super(),this.name=e,this.args=t}get astNodeType(){return"call"}isBuiltin(){return Fm.has(this.name)}search(e){for(const t of this.args)t.search(e);e(this)}}class Jm extends km{constructor(e,t){super(),this.body=e,this.continuing=t}get astNodeType(){return"loop"}search(e){var t;this.searchBlock(this.body,e),null===(t=this.continuing)||void 0===t||t.search(e)}}class Ym extends km{constructor(e,t){super(),this.condition=e,this.cases=t}get astNodeType(){return"switch"}search(e){e(this);for(const t of this.cases)t.search(e)}}class eg extends km{constructor(e,t,i,n){super(),this.condition=e,this.body=t,this.elseif=i,this.else=n}get astNodeType(){return"if"}search(e){this.condition.search(e),this.searchBlock(this.body,e),this.searchBlock(this.elseif,e),this.searchBlock(this.else,e)}}class tg extends km{constructor(e){super(),this.value=e}get astNodeType(){return"return"}search(e){var t;null===(t=this.value)||void 0===t||t.search(e)}}class ig extends km{constructor(e){super(),this.name=e}get astNodeType(){return"enable"}}class ng extends km{constructor(e){super(),this.extensions=e}get astNodeType(){return"requires"}}class rg extends km{constructor(e,t){super(),this.severity=e,this.rule=t}get astNodeType(){return"diagnostic"}}class og extends km{constructor(e,t){super(),this.name=e,this.type=t}get astNodeType(){return"alias"}}class sg extends km{constructor(){super()}get astNodeType(){return"discard"}}class ag extends km{constructor(){super(),this.condition=null,this.loopId=-1}get astNodeType(){return"break"}}class lg extends km{constructor(){super(),this.loopId=-1}get astNodeType(){return"continue"}}class cg extends km{constructor(e){super(),this.attributes=null,this.name=e}get astNodeType(){return"type"}get isStruct(){return!1}get isArray(){return!1}static maxFormatType(e){let t=e[0];if("f32"===t.name)return t;for(let i=1;i`}else if("vec2"===e||"vec3"===e||"vec4"===e)return e;return e}}dg.vec2f=new dg("vec2",cg.f32,null),dg.vec3f=new dg("vec3",cg.f32,null),dg.vec4f=new dg("vec4",cg.f32,null),dg.vec2i=new dg("vec2",cg.i32,null),dg.vec3i=new dg("vec3",cg.i32,null),dg.vec4i=new dg("vec4",cg.i32,null),dg.vec2u=new dg("vec2",cg.u32,null),dg.vec3u=new dg("vec3",cg.u32,null),dg.vec4u=new dg("vec4",cg.u32,null),dg.vec2h=new dg("vec2",cg.f16,null),dg.vec3h=new dg("vec3",cg.f16,null),dg.vec4h=new dg("vec4",cg.f16,null),dg.vec2b=new dg("vec2",cg.bool,null),dg.vec3b=new dg("vec3",cg.bool,null),dg.vec4b=new dg("vec4",cg.bool,null),dg.mat2x2f=new dg("mat2x2",cg.f32,null),dg.mat2x3f=new dg("mat2x3",cg.f32,null),dg.mat2x4f=new dg("mat2x4",cg.f32,null),dg.mat3x2f=new dg("mat3x2",cg.f32,null),dg.mat3x3f=new dg("mat3x3",cg.f32,null),dg.mat3x4f=new dg("mat3x4",cg.f32,null),dg.mat4x2f=new dg("mat4x2",cg.f32,null),dg.mat4x3f=new dg("mat4x3",cg.f32,null),dg.mat4x4f=new dg("mat4x4",cg.f32,null),dg.mat2x2h=new dg("mat2x2",cg.f16,null),dg.mat2x3h=new dg("mat2x3",cg.f16,null),dg.mat2x4h=new dg("mat2x4",cg.f16,null),dg.mat3x2h=new dg("mat3x2",cg.f16,null),dg.mat3x3h=new dg("mat3x3",cg.f16,null),dg.mat3x4h=new dg("mat3x4",cg.f16,null),dg.mat4x2h=new dg("mat4x2",cg.f16,null),dg.mat4x3h=new dg("mat4x3",cg.f16,null),dg.mat4x4h=new dg("mat4x4",cg.f16,null),dg.mat2x2i=new dg("mat2x2",cg.i32,null),dg.mat2x3i=new dg("mat2x3",cg.i32,null),dg.mat2x4i=new dg("mat2x4",cg.i32,null),dg.mat3x2i=new dg("mat3x2",cg.i32,null),dg.mat3x3i=new dg("mat3x3",cg.i32,null),dg.mat3x4i=new dg("mat3x4",cg.i32,null),dg.mat4x2i=new dg("mat4x2",cg.i32,null),dg.mat4x3i=new dg("mat4x3",cg.i32,null),dg.mat4x4i=new dg("mat4x4",cg.i32,null),dg.mat2x2u=new dg("mat2x2",cg.u32,null),dg.mat2x3u=new dg("mat2x3",cg.u32,null),dg.mat2x4u=new dg("mat2x4",cg.u32,null),dg.mat3x2u=new dg("mat3x2",cg.u32,null),dg.mat3x3u=new dg("mat3x3",cg.u32,null),dg.mat3x4u=new dg("mat3x4",cg.u32,null),dg.mat4x2u=new dg("mat4x2",cg.u32,null),dg.mat4x3u=new dg("mat4x3",cg.u32,null),dg.mat4x4u=new dg("mat4x4",cg.u32,null);class pg extends cg{constructor(e,t,i,n){super(e),this.storage=t,this.type=i,this.access=n}get astNodeType(){return"pointer"}}class fg extends cg{constructor(e,t,i,n){super(e),this.attributes=t,this.format=i,this.count=n}get astNodeType(){return"array"}get isArray(){return!0}}class mg extends cg{constructor(e,t,i){super(e),this.format=t,this.access=i}get astNodeType(){return"sampler"}}class gg extends Pm{constructor(){super(),this.postfix=null}}class _g extends gg{constructor(e){super(),this.value=e}get astNodeType(){return"stringExpr"}toString(){return this.value}constEvaluateString(){return this.value}}class Ag extends gg{constructor(e,t){super(),this.type=e,this.args=t}get astNodeType(){return"createExpr"}search(e){if(e(this),this.args)for(const t of this.args)t.search(e)}constEvaluate(e,t){return t&&(t[0]=this.type),e.evalExpression(this,e.context)}}class yg extends gg{constructor(e,t){super(),this.cachedReturnValue=null,this.name=e,this.args=t}get astNodeType(){return"callExpr"}setCachedReturnValue(e){this.cachedReturnValue=e}get isBuiltin(){return Fm.has(this.name)}constEvaluate(e,t){return e.evalExpression(this,e.context)}search(e){for(const t of this.args)t.search(e);e(this)}}class vg extends gg{constructor(e){super(),this.name=e}get astNodeType(){return"varExpr"}search(e){e(this),this.postfix&&this.postfix.search(e)}constEvaluate(e,t){return e.evalExpression(this,e.context)}}class xg extends gg{constructor(e,t){super(),this.name=e,this.initializer=t}get astNodeType(){return"constExpr"}constEvaluate(e,t){if(this.initializer){const t=e.evalExpression(this.initializer,e.context);return null!==t&&this.postfix?t.getSubData(e,this.postfix,e.context):t}return null}search(e){this.initializer.search(e)}}class bg extends gg{constructor(e,t){super(),this.value=e,this.type=t}get astNodeType(){return"literalExpr"}constEvaluate(e,t){return void 0!==t&&(t[0]=this.type),this.value}get isScalar(){return this.value instanceof Ug}get isVector(){return this.value instanceof Vg||this.value instanceof jg}get scalarValue(){return this.value instanceof Ug?this.value.value:(console.error("Value is not scalar."),0)}get vectorValue(){return this.value instanceof Vg||this.value instanceof jg?this.value.data:(console.error("Value is not a vector or matrix."),new Float32Array(0))}}class wg extends gg{constructor(e,t){super(),this.type=e,this.value=t}get astNodeType(){return"bitcastExpr"}search(e){this.value.search(e)}}class Tg extends gg{constructor(e){super(),this.index=e}search(e){this.index.search(e)}}class Eg extends gg{constructor(){super()}}class Cg extends Eg{constructor(e,t){super(),this.operator=e,this.right=t}get astNodeType(){return"unaryOp"}constEvaluate(e,t){return e.evalExpression(this,e.context)}search(e){this.right.search(e)}}class Sg extends Eg{constructor(e,t,i){super(),this.operator=e,this.left=t,this.right=i}get astNodeType(){return"binaryOp"}_getPromotedType(e,t){return e.name===t.name?e:"f32"===e.name||"f32"===t.name?cg.f32:"u32"===e.name||"u32"===t.name?cg.u32:cg.i32}constEvaluate(e,t){return e.evalExpression(this,e.context)}search(e){this.left.search(e),this.right.search(e)}}class Bg extends Pm{constructor(e){super(),this.body=e}search(e){e(this),this.searchBlock(this.body,e)}}class Ig extends gg{constructor(){super()}get astNodeType(){return"default"}}class Mg extends Bg{constructor(e,t){super(t),this.selectors=e}get astNodeType(){return"case"}search(e){this.searchBlock(this.body,e)}}class Pg extends Bg{constructor(e){super(e)}get astNodeType(){return"default"}search(e){this.searchBlock(this.body,e)}}class Rg extends Pm{constructor(e,t,i){super(),this.name=e,this.type=t,this.attributes=i}get astNodeType(){return"argument"}}class Lg extends Pm{constructor(e,t){super(),this.condition=e,this.body=t}get astNodeType(){return"elseif"}search(e){this.condition.search(e),this.searchBlock(this.body,e)}}class Fg extends Pm{constructor(e,t,i){super(),this.name=e,this.type=t,this.attributes=i}get astNodeType(){return"member"}}class kg extends Pm{constructor(e,t){super(),this.name=e,this.value=t}get astNodeType(){return"attribute"}}class Dg{constructor(e,t){this.parent=null,this.typeInfo=e,this.parent=t,this.id=Dg._id++}clone(){throw`Clone: Not implemented for ${this.constructor.name}`}setDataValue(e,t,i,n){console.error(`SetDataValue: Not implemented for ${this.constructor.name}`)}getSubData(e,t,i){return console.error(`GetDataValue: Not implemented for ${this.constructor.name}`),null}toString(){return`<${this.typeInfo.getTypeName()}>`}}Dg._id=0;class Og extends Dg{constructor(){super(new om("void",null),null)}toString(){return"void"}}Og.void=new Og;class zg extends Dg{constructor(e){super(new cm("pointer",e.typeInfo,null),null),this.reference=e}clone(){return this}setDataValue(e,t,i,n){this.reference.setDataValue(e,t,i,n)}getSubData(e,t,i){return t?this.reference.getSubData(e,t,i):this}toString(){return`&${this.reference.toString()}`}}class Ug extends Dg{constructor(e,t,i=null){super(t,i),e instanceof Int32Array||e instanceof Uint32Array||e instanceof Float32Array?this.data=e:"x32"===this.typeInfo.name?e-Math.floor(e)!==0?this.data=new Float32Array([e]):this.data=e>=0?new Uint32Array([e]):new Int32Array([e]):"i32"===this.typeInfo.name||"bool"===this.typeInfo.name?this.data=new Int32Array([e]):"u32"===this.typeInfo.name?this.data=new Uint32Array([e]):"f32"===this.typeInfo.name||"f16"===this.typeInfo.name?this.data=new Float32Array([e]):console.error("ScalarData2: Invalid type",t)}clone(){if(this.data instanceof Float32Array)return new Ug(new Float32Array(this.data),this.typeInfo,null);if(this.data instanceof Int32Array)return new Ug(new Int32Array(this.data),this.typeInfo,null);if(this.data instanceof Uint32Array)return new Ug(new Uint32Array(this.data),this.typeInfo,null);throw"ScalarData: Invalid data type"}get value(){return this.data[0]}set value(e){this.data[0]=e}setDataValue(e,t,i,n){if(i)return void console.error("SetDataValue: Scalar data does not support postfix",i);if(!(t instanceof Ug))return void console.error("SetDataValue: Invalid value",t);let r=t.data[0];"i32"===this.typeInfo.name||"u32"===this.typeInfo.name?r=Math.floor(r):"bool"===this.typeInfo.name&&(r=r?1:0),this.data[0]=r}getSubData(e,t,i){return t?(console.error("getSubData: Scalar data does not support postfix",t),null):this}toString(){return`${this.value}`}}function Ng(e,t,i){const n=t.length;return 2===n?"f32"===i?new Vg(new Float32Array(t),e.getTypeInfo("vec2f")):"i32"===i||"bool"===i?new Vg(new Int32Array(t),e.getTypeInfo("vec2i")):"u32"===i?new Vg(new Uint32Array(t),e.getTypeInfo("vec2u")):"f16"===i?new Vg(new Float32Array(t),e.getTypeInfo("vec2h")):(console.error(`getSubData: Unknown format ${i}`),null):3===n?"f32"===i?new Vg(new Float32Array(t),e.getTypeInfo("vec3f")):"i32"===i||"bool"===i?new Vg(new Int32Array(t),e.getTypeInfo("vec3i")):"u32"===i?new Vg(new Uint32Array(t),e.getTypeInfo("vec3u")):"f16"===i?new Vg(new Float32Array(t),e.getTypeInfo("vec3h")):(console.error(`getSubData: Unknown format ${i}`),null):4===n?"f32"===i?new Vg(new Float32Array(t),e.getTypeInfo("vec4f")):"i32"===i||"bool"===i?new Vg(new Int32Array(t),e.getTypeInfo("vec4i")):"u32"===i?new Vg(new Uint32Array(t),e.getTypeInfo("vec4u")):"f16"===i?new Vg(new Float32Array(t),e.getTypeInfo("vec4h")):(console.error(`getSubData: Unknown format ${i}`),null):(console.error(`getSubData: Invalid vector size ${t.length}`),null)}class Vg extends Dg{constructor(e,t,i=null){if(super(t,i),e instanceof Float32Array||e instanceof Uint32Array||e instanceof Int32Array)this.data=e;else{const t=this.typeInfo.name;"vec2f"===t||"vec3f"===t||"vec4f"===t?this.data=new Float32Array(e):"vec2i"===t||"vec3i"===t||"vec4i"===t?this.data=new Int32Array(e):"vec2u"===t||"vec3u"===t||"vec4u"===t?this.data=new Uint32Array(e):"vec2h"===t||"vec3h"===t||"vec4h"===t?this.data=new Float32Array(e):"vec2b"===t||"vec3b"===t||"vec4b"===t?this.data=new Int32Array(e):"vec2"===t||"vec3"===t||"vec4"===t?this.data=new Float32Array(e):console.error(`VectorData: Invalid type ${t}`)}}clone(){if(this.data instanceof Float32Array)return new Vg(new Float32Array(this.data),this.typeInfo,null);if(this.data instanceof Int32Array)return new Vg(new Int32Array(this.data),this.typeInfo,null);if(this.data instanceof Uint32Array)return new Vg(new Uint32Array(this.data),this.typeInfo,null);throw"VectorData: Invalid data type"}setDataValue(e,t,i,n){i instanceof _g?console.error("TODO: Set vector postfix"):t instanceof Vg?this.data=t.data:console.error("SetDataValue: Invalid value",t)}getSubData(e,t,i){if(null===t)return this;let n=e.getTypeInfo("f32");if(this.typeInfo instanceof um)n=this.typeInfo.format||n;else{const t=this.typeInfo.name;"vec2f"===t||"vec3f"===t||"vec4f"===t?n=e.getTypeInfo("f32"):"vec2i"===t||"vec3i"===t||"vec4i"===t?n=e.getTypeInfo("i32"):"vec2b"===t||"vec3b"===t||"vec4b"===t?n=e.getTypeInfo("bool"):"vec2u"===t||"vec3u"===t||"vec4u"===t?n=e.getTypeInfo("u32"):"vec2h"===t||"vec3h"===t||"vec4h"===t?n=e.getTypeInfo("f16"):console.error(`GetSubData: Unknown type ${t}`)}let r=this;for(;null!==t&&null!==r;){if(t instanceof Tg){const o=t.index;let s=-1;if(o instanceof bg){if(!(o.value instanceof Ug))return console.error(`GetSubData: Invalid array index ${o.value}`),null;s=o.value.value}else{const t=e.evalExpression(o,i);if(!(t instanceof Ug))return console.error("GetSubData: Unknown index type",o),null;s=t.value}if(s<0||s>=r.data.length)return console.error("GetSubData: Index out of range",s),null;if(r.data instanceof Float32Array){const e=new Float32Array(r.data.buffer,r.data.byteOffset+4*s,1);return new Ug(e,n)}if(r.data instanceof Int32Array){const e=new Int32Array(r.data.buffer,r.data.byteOffset+4*s,1);return new Ug(e,n)}if(r.data instanceof Uint32Array){const e=new Uint32Array(r.data.buffer,r.data.byteOffset+4*s,1);return new Ug(e,n)}throw"GetSubData: Invalid data type"}if(!(t instanceof _g))return console.error("GetSubData: Unknown postfix",t),null;{const i=t.value.toLowerCase();if(1===i.length){let e=0;if("x"===i||"r"===i)e=0;else if("y"===i||"g"===i)e=1;else if("z"===i||"b"===i)e=2;else{if("w"!==i&&"a"!==i)return console.error(`GetSubData: Unknown member ${i}`),null;e=3}if(this.data instanceof Float32Array){let t=new Float32Array(this.data.buffer,this.data.byteOffset+4*e,1);return new Ug(t,n,this)}if(this.data instanceof Int32Array){let t=new Int32Array(this.data.buffer,this.data.byteOffset+4*e,1);return new Ug(t,n,this)}if(this.data instanceof Uint32Array){let t=new Uint32Array(this.data.buffer,this.data.byteOffset+4*e,1);return new Ug(t,n,this)}}const o=[];for(const e of i)"x"===e||"r"===e?o.push(this.data[0]):"y"===e||"g"===e?o.push(this.data[1]):"z"===e||"b"===e?o.push(this.data[2]):"w"===e||"a"===e?o.push(this.data[3]):console.error(`GetDataValue: Unknown member ${e}`);r=Ng(e,o,n.name)}t=t.postfix}return r}toString(){let e=`${this.data[0]}`;for(let t=1;t=this.data.length)return console.error("GetDataValue: Index out of range",o),null;const s=n.endsWith("h")?"h":"f";let a;if("mat2x2"===n||"mat2x2f"===n||"mat2x2h"===n||"mat3x2"===n||"mat3x2f"===n||"mat3x2h"===n||"mat4x2"===n||"mat4x2f"===n||"mat4x2h"===n)a=new Vg(new Float32Array(this.data.buffer,this.data.byteOffset+2*o*4,2),e.getTypeInfo(`vec2${s}`));else if("mat2x3"===n||"mat2x3f"===n||"mat2x3h"===n||"mat3x3"===n||"mat3x3f"===n||"mat3x3h"===n||"mat4x3"===n||"mat4x3f"===n||"mat4x3h"===n)a=new Vg(new Float32Array(this.data.buffer,this.data.byteOffset+3*o*4,3),e.getTypeInfo(`vec3${s}`));else{if("mat2x4"!==n&&"mat2x4f"!==n&&"mat2x4h"!==n&&"mat3x4"!==n&&"mat3x4f"!==n&&"mat3x4h"!==n&&"mat4x4"!==n&&"mat4x4f"!==n&&"mat4x4h"!==n)return console.error(`GetDataValue: Unknown type ${n}`),null;a=new Vg(new Float32Array(this.data.buffer,this.data.byteOffset+4*o*4,4),e.getTypeInfo(`vec4${s}`))}return t.postfix?a.getSubData(e,t.postfix,i):a}return console.error("GetDataValue: Invalid postfix",t),null}toString(){let e=`${this.data[0]}`;for(let t=1;t"!==o&&"x32"!==o)if("u32"!==o&&"atomic"!==o)if("bool"!==o){if("vec2f"===o||"vec2h"===o){const e=new Float32Array(this.buffer,n,2);return void(t instanceof Vg?(e[0]=t.data[0],e[1]=t.data[1]):(e[0]=t[0],e[1]=t[1]))}if("vec3f"===o||"vec3h"===o){const e=new Float32Array(this.buffer,n,3);return void(t instanceof Vg?(e[0]=t.data[0],e[1]=t.data[1],e[2]=t.data[2]):(e[0]=t[0],e[1]=t[1],e[2]=t[2]))}if("vec4f"===o||"vec4h"===o){const e=new Float32Array(this.buffer,n,4);return void(t instanceof Vg?(e[0]=t.data[0],e[1]=t.data[1],e[2]=t.data[2],e[3]=t.data[3]):(e[0]=t[0],e[1]=t[1],e[2]=t[2],e[3]=t[3]))}if("vec2i"===o){const e=new Int32Array(this.buffer,n,2);return void(t instanceof Vg?(e[0]=t.data[0],e[1]=t.data[1]):(e[0]=t[0],e[1]=t[1]))}if("vec3i"===o){const e=new Int32Array(this.buffer,n,3);return void(t instanceof Vg?(e[0]=t.data[0],e[1]=t.data[1],e[2]=t.data[2]):(e[0]=t[0],e[1]=t[1],e[2]=t[2]))}if("vec4i"===o){const e=new Int32Array(this.buffer,n,4);return void(t instanceof Vg?(e[0]=t.data[0],e[1]=t.data[1],e[2]=t.data[2],e[3]=t.data[3]):(e[0]=t[0],e[1]=t[1],e[2]=t[2],e[3]=t[3]))}if("vec2u"===o){const e=new Uint32Array(this.buffer,n,2);return void(t instanceof Vg?(e[0]=t.data[0],e[1]=t.data[1]):(e[0]=t[0],e[1]=t[1]))}if("vec3u"===o){const e=new Uint32Array(this.buffer,n,3);return void(t instanceof Vg?(e[0]=t.data[0],e[1]=t.data[1],e[2]=t.data[2]):(e[0]=t[0],e[1]=t[1],e[2]=t[2]))}if("vec4u"===o){const e=new Uint32Array(this.buffer,n,4);return void(t instanceof Vg?(e[0]=t.data[0],e[1]=t.data[1],e[2]=t.data[2],e[3]=t.data[3]):(e[0]=t[0],e[1]=t[1],e[2]=t[2],e[3]=t[3]))}if("vec2b"===o){const e=new Uint32Array(this.buffer,n,2);return void(t instanceof Vg?(e[0]=t.data[0],e[1]=t.data[1]):(e[0]=t[0],e[1]=t[1]))}if("vec3b"===o){const e=new Uint32Array(this.buffer,n,3);return void(t instanceof Vg?(e[0]=t.data[0],e[1]=t.data[1],e[2]=t.data[2]):(e[0]=t[0],e[1]=t[1],e[2]=t[2]))}if("vec4b"===o){const e=new Uint32Array(this.buffer,n,4);return void(t instanceof Vg?(e[0]=t.data[0],e[1]=t.data[1],e[2]=t.data[2],e[3]=t.data[3]):(e[0]=t[0],e[1]=t[1],e[2]=t[2],e[3]=t[3]))}if("mat2x2f"===o||"mat2x2h"===o){const e=new Float32Array(this.buffer,n,4);return void(t instanceof jg?(e[0]=t.data[0],e[1]=t.data[1],e[2]=t.data[2],e[3]=t.data[3]):(e[0]=t[0],e[1]=t[1],e[2]=t[2],e[3]=t[3]))}if("mat2x3f"===o||"mat2x3h"===o){const e=new Float32Array(this.buffer,n,6);return void(t instanceof jg?(e[0]=t.data[0],e[1]=t.data[1],e[2]=t.data[2],e[3]=t.data[3],e[4]=t.data[4],e[5]=t.data[5]):(e[0]=t[0],e[1]=t[1],e[2]=t[2],e[3]=t[3],e[4]=t[4],e[5]=t[5]))}if("mat2x4f"===o||"mat2x4h"===o){const e=new Float32Array(this.buffer,n,8);return void(t instanceof jg?(e[0]=t.data[0],e[1]=t.data[1],e[2]=t.data[2],e[3]=t.data[3],e[4]=t.data[4],e[5]=t.data[5],e[6]=t.data[6],e[7]=t.data[7]):(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]))}if("mat3x2f"===o||"mat3x2h"===o){const e=new Float32Array(this.buffer,n,6);return void(t instanceof jg?(e[0]=t.data[0],e[1]=t.data[1],e[2]=t.data[2],e[3]=t.data[3],e[4]=t.data[4],e[5]=t.data[5]):(e[0]=t[0],e[1]=t[1],e[2]=t[2],e[3]=t[3],e[4]=t[4],e[5]=t[5]))}if("mat3x3f"===o||"mat3x3h"===o){const e=new Float32Array(this.buffer,n,9);return void(t instanceof jg?(e[0]=t.data[0],e[1]=t.data[1],e[2]=t.data[2],e[3]=t.data[3],e[4]=t.data[4],e[5]=t.data[5],e[6]=t.data[6],e[7]=t.data[7],e[8]=t.data[8]):(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]))}if("mat3x4f"===o||"mat3x4h"===o){const e=new Float32Array(this.buffer,n,12);return void(t instanceof jg?(e[0]=t.data[0],e[1]=t.data[1],e[2]=t.data[2],e[3]=t.data[3],e[4]=t.data[4],e[5]=t.data[5],e[6]=t.data[6],e[7]=t.data[7],e[8]=t.data[8],e[9]=t.data[9],e[10]=t.data[10],e[11]=t.data[11]):(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]))}if("mat4x2f"===o||"mat4x2h"===o){const e=new Float32Array(this.buffer,n,8);return void(t instanceof jg?(e[0]=t.data[0],e[1]=t.data[1],e[2]=t.data[2],e[3]=t.data[3],e[4]=t.data[4],e[5]=t.data[5],e[6]=t.data[6],e[7]=t.data[7]):(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]))}if("mat4x3f"===o||"mat4x3h"===o){const e=new Float32Array(this.buffer,n,12);return void(t instanceof jg?(e[0]=t.data[0],e[1]=t.data[1],e[2]=t.data[2],e[3]=t.data[3],e[4]=t.data[4],e[5]=t.data[5],e[6]=t.data[6],e[7]=t.data[7],e[8]=t.data[8],e[9]=t.data[9],e[10]=t.data[10],e[11]=t.data[11]):(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]))}if("mat4x4f"===o||"mat4x4h"===o){const e=new Float32Array(this.buffer,n,16);return void(t instanceof jg?(e[0]=t.data[0],e[1]=t.data[1],e[2]=t.data[2],e[3]=t.data[3],e[4]=t.data[4],e[5]=t.data[5],e[6]=t.data[6],e[7]=t.data[7],e[8]=t.data[8],e[9]=t.data[9],e[10]=t.data[10],e[11]=t.data[11],e[12]=t.data[12],e[13]=t.data[13],e[14]=t.data[14],e[15]=t.data[15]):(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]))}if(t instanceof Gg){if(i===t.typeInfo)return void new Uint8Array(this.buffer,n,t.buffer.byteLength).set(new Uint8Array(t.buffer));console.error("SetDataValue: Type mismatch",o,t.typeInfo.getTypeName())}else console.error(`SetData: Unknown type ${o}`)}else t instanceof Ug&&(new Int32Array(this.buffer,n,1)[0]=t.value);else t instanceof Ug&&(new Uint32Array(this.buffer,n,1)[0]=t.value);else t instanceof Ug&&(new Int32Array(this.buffer,n,1)[0]=t.value);else t instanceof Ug&&(new Float32Array(this.buffer,n,1)[0]=t.value)}getSubData(e,t,i){var n,r,o;if(null===t)return this;let s=this.offset,a=this.typeInfo;for(;t;){if(t instanceof Tg){const n=t.index,r=n instanceof gg?e.evalExpression(n,i):n;let o=0;if(r instanceof Ug?o=r.value:"number"==typeof r?o=r:console.error("GetDataValue: Invalid index type",n),a instanceof lm)s+=o*a.stride,a=a.format;else{const t=a.getTypeName();"mat4x4"===t||"mat4x4f"===t||"mat4x4h"===t?(s+=16*o,a=e.getTypeInfo("vec4f")):console.error(`getDataValue: Type ${a.getTypeName()} is not an array`)}}else{if(!(t instanceof _g))return console.error("GetDataValue: Unknown postfix type",t),null;{const i=t.value;if(a instanceof am){let e=!1;for(const t of a.members)if(t.name===i){s+=t.offset,a=t.type,e=!0;break}if(!e)return console.error(`GetDataValue: Member ${i} not found`),null}else if(a instanceof om){const t=a.getTypeName();if("vec2f"===t||"vec3f"===t||"vec4f"===t||"vec2i"===t||"vec3i"===t||"vec4i"===t||"vec2u"===t||"vec3u"===t||"vec4u"===t||"vec2b"===t||"vec3b"===t||"vec4b"===t||"vec2h"===t||"vec3h"===t||"vec4h"===t||"vec2"===t||"vec3"===t||"vec4"===t){if(i.length>0&&i.length<5){let n="f";const r=[];for(let o=0;o=this.buffer.byteLength)return console.log("Insufficient buffer data"),null;const e=new Float32Array(this.buffer,s,3);r.push(e[l])}else if("vec4f"===t)r.push(new Float32Array(this.buffer,s,4)[l]);else if("vec2i"===t)n="i",r.push(new Int32Array(this.buffer,s,2)[l]);else if("vec3i"===t)n="i",r.push(new Int32Array(this.buffer,s,3)[l]);else if("vec4i"===t)n="i",r.push(new Int32Array(this.buffer,s,4)[l]);else if("vec2u"===t){n="u";const e=new Uint32Array(this.buffer,s,2);r.push(e[l])}else"vec3u"===t?(n="u",r.push(new Uint32Array(this.buffer,s,3)[l])):"vec4u"===t&&(n="u",r.push(new Uint32Array(this.buffer,s,4)[l]))}return 2===r.length?a=e.getTypeInfo(`vec2${n}`):3===r.length?a=e.getTypeInfo(`vec3${n}`):4===r.length?a=e.getTypeInfo(`vec4${n}`):console.error(`GetDataValue: Invalid vector length ${r.length}`),new Vg(r,a,null)}return console.error(`GetDataValue: Unknown member ${i}`),null}return console.error(`GetDataValue: Type ${t} is not a struct`),null}}}t=t.postfix}const l=a.getTypeName();return"f32"===l?new Ug(new Float32Array(this.buffer,s,1),a,this):"i32"===l?new Ug(new Int32Array(this.buffer,s,1),a,this):"u32"===l?new Ug(new Uint32Array(this.buffer,s,1),a,this):"vec2f"===l?new Vg(new Float32Array(this.buffer,s,2),a,this):"vec3f"===l?new Vg(new Float32Array(this.buffer,s,3),a,this):"vec4f"===l?new Vg(new Float32Array(this.buffer,s,4),a,this):"vec2i"===l?new Vg(new Int32Array(this.buffer,s,2),a,this):"vec3i"===l?new Vg(new Int32Array(this.buffer,s,3),a,this):"vec4i"===l?new Vg(new Int32Array(this.buffer,s,4),a,this):"vec2u"===l?new Vg(new Uint32Array(this.buffer,s,2),a,this):"vec3u"===l?new Vg(new Uint32Array(this.buffer,s,3),a,this):"vec4u"===l?new Vg(new Uint32Array(this.buffer,s,4),a,this):a instanceof um&&"atomic"===a.name?"u32"===(null===(n=a.format)||void 0===n?void 0:n.name)?new Ug(new Uint32Array(this.buffer,s,1)[0],a.format,this):"i32"===(null===(r=a.format)||void 0===r?void 0:r.name)?new Ug(new Int32Array(this.buffer,s,1)[0],a.format,this):(console.error(`GetDataValue: Invalid atomic format ${null===(o=a.format)||void 0===o?void 0:o.name}`),null):new Gg(this.buffer,a,s,this)}toString(){let e="";if(this.typeInfo instanceof lm)if("f32"===this.typeInfo.format.name){const t=new Float32Array(this.buffer,this.offset);e=`[${t[0]}`;for(let i=1;i0?null!==(e=i[0])&&void 0!==e?e:0:i instanceof Object&&null!==(t=i.width)&&void 0!==t?t:0}get height(){var e,t;const i=this.descriptor.size;return i instanceof Array&&i.length>1?null!==(e=i[1])&&void 0!==e?e:0:i instanceof Object&&null!==(t=i.height)&&void 0!==t?t:0}get depthOrArrayLayers(){var e,t;const i=this.descriptor.size;return i instanceof Array&&i.length>2?null!==(e=i[2])&&void 0!==e?e:0:i instanceof Object&&null!==(t=i.depthOrArrayLayers)&&void 0!==t?t:0}get format(){var e;return this.descriptor&&null!==(e=this.descriptor.format)&&void 0!==e?e:"rgba8unorm"}get sampleCount(){var e;return this.descriptor&&null!==(e=this.descriptor.sampleCount)&&void 0!==e?e:1}get mipLevelCount(){var e;return this.descriptor&&null!==(e=this.descriptor.mipLevelCount)&&void 0!==e?e:1}get dimension(){var e;return this.descriptor&&null!==(e=this.descriptor.dimension)&&void 0!==e?e:"2d"}getMipLevelSize(e){if(e>=this.mipLevelCount)return[0,0,0];const t=[this.width,this.height,this.depthOrArrayLayers];for(let i=0;i>e);return t}get texelByteSize(){const e=this.format,t=Mm[e];return t?t.isDepthStencil?4:t.bytesPerBlock:0}get bytesPerRow(){return this.width*this.texelByteSize}get isDepthStencil(){const e=this.format,t=Mm[e];return!!t&&t.isDepthStencil}getGpuSize(){const e=this.format,t=Mm[e],i=this.width;if(!e||i<=0||!t)return-1;const n=this.height,r=this.depthOrArrayLayers,o=this.dimension;return i/t.blockWidth*("1d"===o?1:n/t.blockHeight)*t.bytesPerBlock*r}getPixel(e,t,i=0,n=0){const r=this.texelByteSize,o=this.bytesPerRow,s=this.height,a=this.data[n];return function(e,t,i,n,r,o,s,a,l){const c=n*(s>>=r)*(o>>=r)+i*s+t*a;switch(l){case"r8unorm":return[Bm(e,c,"8unorm",1)[0]];case"r8snorm":return[Bm(e,c,"8snorm",1)[0]];case"r8uint":return[Bm(e,c,"8uint",1)[0]];case"r8sint":return[Bm(e,c,"8sint",1)[0]];case"rg8unorm":{const t=Bm(e,c,"8unorm",2);return[t[0],t[1]]}case"rg8snorm":{const t=Bm(e,c,"8snorm",2);return[t[0],t[1]]}case"rg8uint":{const t=Bm(e,c,"8uint",2);return[t[0],t[1]]}case"rg8sint":{const t=Bm(e,c,"8sint",2);return[t[0],t[1]]}case"rgba8unorm-srgb":case"rgba8unorm":{const t=Bm(e,c,"8unorm",4);return[t[0],t[1],t[2],t[3]]}case"rgba8snorm":{const t=Bm(e,c,"8snorm",4);return[t[0],t[1],t[2],t[3]]}case"rgba8uint":{const t=Bm(e,c,"8uint",4);return[t[0],t[1],t[2],t[3]]}case"rgba8sint":{const t=Bm(e,c,"8sint",4);return[t[0],t[1],t[2],t[3]]}case"bgra8unorm-srgb":case"bgra8unorm":{const t=Bm(e,c,"8unorm",4);return[t[2],t[1],t[0],t[3]]}case"r16uint":return[Bm(e,c,"16uint",1)[0]];case"r16sint":return[Bm(e,c,"16sint",1)[0]];case"r16float":return[Bm(e,c,"16float",1)[0]];case"rg16uint":{const t=Bm(e,c,"16uint",2);return[t[0],t[1]]}case"rg16sint":{const t=Bm(e,c,"16sint",2);return[t[0],t[1]]}case"rg16float":{const t=Bm(e,c,"16float",2);return[t[0],t[1]]}case"rgba16uint":{const t=Bm(e,c,"16uint",4);return[t[0],t[1],t[2],t[3]]}case"rgba16sint":{const t=Bm(e,c,"16sint",4);return[t[0],t[1],t[2],t[3]]}case"rgba16float":{const t=Bm(e,c,"16float",4);return[t[0],t[1],t[2],t[3]]}case"r32uint":return[Bm(e,c,"32uint",1)[0]];case"r32sint":return[Bm(e,c,"32sint",1)[0]];case"depth16unorm":case"depth24plus":case"depth24plus-stencil8":case"depth32float":case"depth32float-stencil8":case"r32float":return[Bm(e,c,"32float",1)[0]];case"rg32uint":{const t=Bm(e,c,"32uint",2);return[t[0],t[1]]}case"rg32sint":{const t=Bm(e,c,"32sint",2);return[t[0],t[1]]}case"rg32float":{const t=Bm(e,c,"32float",2);return[t[0],t[1]]}case"rgba32uint":{const t=Bm(e,c,"32uint",4);return[t[0],t[1],t[2],t[3]]}case"rgba32sint":{const t=Bm(e,c,"32sint",4);return[t[0],t[1],t[2],t[3]]}case"rgba32float":{const t=Bm(e,c,"32float",4);return[t[0],t[1],t[2],t[3]]}case"rg11b10ufloat":{const t=new Uint32Array(e.buffer,c,1)[0],i=(4192256&t)>>11,n=(4290772992&t)>>22;return[Sm(2047&t),Sm(i),function(e){const t=112+(e>>5&31)<<23|(31&e)<<18;return Em[0]=t,Cm[0]}(n),1]}}return null}(new Uint8Array(a),e,t,i,n,s,o,r,this.format)}setPixel(e,t,i,n,r){const o=this.texelByteSize,s=this.bytesPerRow,a=this.height,l=this.data[n];!function(e,t,i,n,r,o,s,a,l,c){const u=n*(s>>=r)*(o>>=r)+i*s+t*a;switch(l){case"r8unorm":return void Im(e,u,"8unorm",1,c);case"r8snorm":return void Im(e,u,"8snorm",1,c);case"r8uint":return void Im(e,u,"8uint",1,c);case"r8sint":return void Im(e,u,"8sint",1,c);case"rg8unorm":return void Im(e,u,"8unorm",2,c);case"rg8snorm":return void Im(e,u,"8snorm",2,c);case"rg8uint":return void Im(e,u,"8uint",2,c);case"rg8sint":return void Im(e,u,"8sint",2,c);case"rgba8unorm-srgb":case"rgba8unorm":case"bgra8unorm-srgb":case"bgra8unorm":return void Im(e,u,"8unorm",4,c);case"rgba8snorm":return void Im(e,u,"8snorm",4,c);case"rgba8uint":return void Im(e,u,"8uint",4,c);case"rgba8sint":return void Im(e,u,"8sint",4,c);case"r16uint":return void Im(e,u,"16uint",1,c);case"r16sint":return void Im(e,u,"16sint",1,c);case"r16float":return void Im(e,u,"16float",1,c);case"rg16uint":return void Im(e,u,"16uint",2,c);case"rg16sint":return void Im(e,u,"16sint",2,c);case"rg16float":return void Im(e,u,"16float",2,c);case"rgba16uint":return void Im(e,u,"16uint",4,c);case"rgba16sint":return void Im(e,u,"16sint",4,c);case"rgba16float":return void Im(e,u,"16float",4,c);case"r32uint":return void Im(e,u,"32uint",1,c);case"r32sint":return void Im(e,u,"32sint",1,c);case"depth16unorm":case"depth24plus":case"depth24plus-stencil8":case"depth32float":case"depth32float-stencil8":case"r32float":return void Im(e,u,"32float",1,c);case"rg32uint":return void Im(e,u,"32uint",2,c);case"rg32sint":return void Im(e,u,"32sint",2,c);case"rg32float":return void Im(e,u,"32float",2,c);case"rgba32uint":return void Im(e,u,"32uint",4,c);case"rgba32sint":return void Im(e,u,"32sint",4,c);case"rgba32float":return void Im(e,u,"32float",4,c);case"rg11b10ufloat":console.error("TODO: rg11b10ufloat not supported for writing")}}(new Uint8Array(l),e,t,i,n,a,s,o,this.format,r)}}(e=>{e[e.token=0]="token",e[e.keyword=1]="keyword",e[e.reserved=2]="reserved"})(Wm||(Wm={}));class Qg{constructor(e,t,i){this.name=e,this.type=t,this.rule=i}toString(){return this.name}}class $g{}Zm=$g,$g.none=new Qg("",Wm.reserved,""),$g.eof=new Qg("EOF",Wm.token,""),$g.reserved={asm:new Qg("asm",Wm.reserved,"asm"),bf16:new Qg("bf16",Wm.reserved,"bf16"),do:new Qg("do",Wm.reserved,"do"),enum:new Qg("enum",Wm.reserved,"enum"),f16:new Qg("f16",Wm.reserved,"f16"),f64:new Qg("f64",Wm.reserved,"f64"),handle:new Qg("handle",Wm.reserved,"handle"),i8:new Qg("i8",Wm.reserved,"i8"),i16:new Qg("i16",Wm.reserved,"i16"),i64:new Qg("i64",Wm.reserved,"i64"),mat:new Qg("mat",Wm.reserved,"mat"),premerge:new Qg("premerge",Wm.reserved,"premerge"),regardless:new Qg("regardless",Wm.reserved,"regardless"),typedef:new Qg("typedef",Wm.reserved,"typedef"),u8:new Qg("u8",Wm.reserved,"u8"),u16:new Qg("u16",Wm.reserved,"u16"),u64:new Qg("u64",Wm.reserved,"u64"),unless:new Qg("unless",Wm.reserved,"unless"),using:new Qg("using",Wm.reserved,"using"),vec:new Qg("vec",Wm.reserved,"vec"),void:new Qg("void",Wm.reserved,"void")},$g.keywords={array:new Qg("array",Wm.keyword,"array"),atomic:new Qg("atomic",Wm.keyword,"atomic"),bool:new Qg("bool",Wm.keyword,"bool"),f32:new Qg("f32",Wm.keyword,"f32"),i32:new Qg("i32",Wm.keyword,"i32"),mat2x2:new Qg("mat2x2",Wm.keyword,"mat2x2"),mat2x3:new Qg("mat2x3",Wm.keyword,"mat2x3"),mat2x4:new Qg("mat2x4",Wm.keyword,"mat2x4"),mat3x2:new Qg("mat3x2",Wm.keyword,"mat3x2"),mat3x3:new Qg("mat3x3",Wm.keyword,"mat3x3"),mat3x4:new Qg("mat3x4",Wm.keyword,"mat3x4"),mat4x2:new Qg("mat4x2",Wm.keyword,"mat4x2"),mat4x3:new Qg("mat4x3",Wm.keyword,"mat4x3"),mat4x4:new Qg("mat4x4",Wm.keyword,"mat4x4"),ptr:new Qg("ptr",Wm.keyword,"ptr"),sampler:new Qg("sampler",Wm.keyword,"sampler"),sampler_comparison:new Qg("sampler_comparison",Wm.keyword,"sampler_comparison"),struct:new Qg("struct",Wm.keyword,"struct"),texture_1d:new Qg("texture_1d",Wm.keyword,"texture_1d"),texture_2d:new Qg("texture_2d",Wm.keyword,"texture_2d"),texture_2d_array:new Qg("texture_2d_array",Wm.keyword,"texture_2d_array"),texture_3d:new Qg("texture_3d",Wm.keyword,"texture_3d"),texture_cube:new Qg("texture_cube",Wm.keyword,"texture_cube"),texture_cube_array:new Qg("texture_cube_array",Wm.keyword,"texture_cube_array"),texture_multisampled_2d:new Qg("texture_multisampled_2d",Wm.keyword,"texture_multisampled_2d"),texture_storage_1d:new Qg("texture_storage_1d",Wm.keyword,"texture_storage_1d"),texture_storage_2d:new Qg("texture_storage_2d",Wm.keyword,"texture_storage_2d"),texture_storage_2d_array:new Qg("texture_storage_2d_array",Wm.keyword,"texture_storage_2d_array"),texture_storage_3d:new Qg("texture_storage_3d",Wm.keyword,"texture_storage_3d"),texture_depth_2d:new Qg("texture_depth_2d",Wm.keyword,"texture_depth_2d"),texture_depth_2d_array:new Qg("texture_depth_2d_array",Wm.keyword,"texture_depth_2d_array"),texture_depth_cube:new Qg("texture_depth_cube",Wm.keyword,"texture_depth_cube"),texture_depth_cube_array:new Qg("texture_depth_cube_array",Wm.keyword,"texture_depth_cube_array"),texture_depth_multisampled_2d:new Qg("texture_depth_multisampled_2d",Wm.keyword,"texture_depth_multisampled_2d"),texture_external:new Qg("texture_external",Wm.keyword,"texture_external"),u32:new Qg("u32",Wm.keyword,"u32"),vec2:new Qg("vec2",Wm.keyword,"vec2"),vec3:new Qg("vec3",Wm.keyword,"vec3"),vec4:new Qg("vec4",Wm.keyword,"vec4"),bitcast:new Qg("bitcast",Wm.keyword,"bitcast"),block:new Qg("block",Wm.keyword,"block"),break:new Qg("break",Wm.keyword,"break"),case:new Qg("case",Wm.keyword,"case"),continue:new Qg("continue",Wm.keyword,"continue"),continuing:new Qg("continuing",Wm.keyword,"continuing"),default:new Qg("default",Wm.keyword,"default"),diagnostic:new Qg("diagnostic",Wm.keyword,"diagnostic"),discard:new Qg("discard",Wm.keyword,"discard"),else:new Qg("else",Wm.keyword,"else"),enable:new Qg("enable",Wm.keyword,"enable"),fallthrough:new Qg("fallthrough",Wm.keyword,"fallthrough"),false:new Qg("false",Wm.keyword,"false"),fn:new Qg("fn",Wm.keyword,"fn"),for:new Qg("for",Wm.keyword,"for"),function:new Qg("function",Wm.keyword,"function"),if:new Qg("if",Wm.keyword,"if"),let:new Qg("let",Wm.keyword,"let"),const:new Qg("const",Wm.keyword,"const"),loop:new Qg("loop",Wm.keyword,"loop"),while:new Qg("while",Wm.keyword,"while"),private:new Qg("private",Wm.keyword,"private"),read:new Qg("read",Wm.keyword,"read"),read_write:new Qg("read_write",Wm.keyword,"read_write"),return:new Qg("return",Wm.keyword,"return"),requires:new Qg("requires",Wm.keyword,"requires"),storage:new Qg("storage",Wm.keyword,"storage"),switch:new Qg("switch",Wm.keyword,"switch"),true:new Qg("true",Wm.keyword,"true"),alias:new Qg("alias",Wm.keyword,"alias"),type:new Qg("type",Wm.keyword,"type"),uniform:new Qg("uniform",Wm.keyword,"uniform"),var:new Qg("var",Wm.keyword,"var"),override:new Qg("override",Wm.keyword,"override"),workgroup:new Qg("workgroup",Wm.keyword,"workgroup"),write:new Qg("write",Wm.keyword,"write"),r8unorm:new Qg("r8unorm",Wm.keyword,"r8unorm"),r8snorm:new Qg("r8snorm",Wm.keyword,"r8snorm"),r8uint:new Qg("r8uint",Wm.keyword,"r8uint"),r8sint:new Qg("r8sint",Wm.keyword,"r8sint"),r16uint:new Qg("r16uint",Wm.keyword,"r16uint"),r16sint:new Qg("r16sint",Wm.keyword,"r16sint"),r16float:new Qg("r16float",Wm.keyword,"r16float"),rg8unorm:new Qg("rg8unorm",Wm.keyword,"rg8unorm"),rg8snorm:new Qg("rg8snorm",Wm.keyword,"rg8snorm"),rg8uint:new Qg("rg8uint",Wm.keyword,"rg8uint"),rg8sint:new Qg("rg8sint",Wm.keyword,"rg8sint"),r32uint:new Qg("r32uint",Wm.keyword,"r32uint"),r32sint:new Qg("r32sint",Wm.keyword,"r32sint"),r32float:new Qg("r32float",Wm.keyword,"r32float"),rg16uint:new Qg("rg16uint",Wm.keyword,"rg16uint"),rg16sint:new Qg("rg16sint",Wm.keyword,"rg16sint"),rg16float:new Qg("rg16float",Wm.keyword,"rg16float"),rgba8unorm:new Qg("rgba8unorm",Wm.keyword,"rgba8unorm"),rgba8unorm_srgb:new Qg("rgba8unorm_srgb",Wm.keyword,"rgba8unorm_srgb"),rgba8snorm:new Qg("rgba8snorm",Wm.keyword,"rgba8snorm"),rgba8uint:new Qg("rgba8uint",Wm.keyword,"rgba8uint"),rgba8sint:new Qg("rgba8sint",Wm.keyword,"rgba8sint"),bgra8unorm:new Qg("bgra8unorm",Wm.keyword,"bgra8unorm"),bgra8unorm_srgb:new Qg("bgra8unorm_srgb",Wm.keyword,"bgra8unorm_srgb"),rgb10a2unorm:new Qg("rgb10a2unorm",Wm.keyword,"rgb10a2unorm"),rg11b10float:new Qg("rg11b10float",Wm.keyword,"rg11b10float"),rg32uint:new Qg("rg32uint",Wm.keyword,"rg32uint"),rg32sint:new Qg("rg32sint",Wm.keyword,"rg32sint"),rg32float:new Qg("rg32float",Wm.keyword,"rg32float"),rgba16uint:new Qg("rgba16uint",Wm.keyword,"rgba16uint"),rgba16sint:new Qg("rgba16sint",Wm.keyword,"rgba16sint"),rgba16float:new Qg("rgba16float",Wm.keyword,"rgba16float"),rgba32uint:new Qg("rgba32uint",Wm.keyword,"rgba32uint"),rgba32sint:new Qg("rgba32sint",Wm.keyword,"rgba32sint"),rgba32float:new Qg("rgba32float",Wm.keyword,"rgba32float"),static_assert:new Qg("static_assert",Wm.keyword,"static_assert")},$g.tokens={decimal_float_literal:new Qg("decimal_float_literal",Wm.token,/((-?[0-9]*\.[0-9]+|-?[0-9]+\.[0-9]*)((e|E)(\+|-)?[0-9]+)?[fh]?)|(-?[0-9]+(e|E)(\+|-)?[0-9]+[fh]?)|(-?[0-9]+[fh])/),hex_float_literal:new Qg("hex_float_literal",Wm.token,/-?0x((([0-9a-fA-F]*\.[0-9a-fA-F]+|[0-9a-fA-F]+\.[0-9a-fA-F]*)((p|P)(\+|-)?[0-9]+[fh]?)?)|([0-9a-fA-F]+(p|P)(\+|-)?[0-9]+[fh]?))/),int_literal:new Qg("int_literal",Wm.token,/-?0x[0-9a-fA-F]+|0i?|-?[1-9][0-9]*i?/),uint_literal:new Qg("uint_literal",Wm.token,/0x[0-9a-fA-F]+u|0u|[1-9][0-9]*u/),name:new Qg("name",Wm.token,/([_\p{XID_Start}][\p{XID_Continue}]+)|([\p{XID_Start}])/u),ident:new Qg("ident",Wm.token,/[_a-zA-Z][0-9a-zA-Z_]*/),and:new Qg("and",Wm.token,"&"),and_and:new Qg("and_and",Wm.token,"&&"),arrow:new Qg("arrow ",Wm.token,"->"),attr:new Qg("attr",Wm.token,"@"),forward_slash:new Qg("forward_slash",Wm.token,"/"),bang:new Qg("bang",Wm.token,"!"),bracket_left:new Qg("bracket_left",Wm.token,"["),bracket_right:new Qg("bracket_right",Wm.token,"]"),brace_left:new Qg("brace_left",Wm.token,"{"),brace_right:new Qg("brace_right",Wm.token,"}"),colon:new Qg("colon",Wm.token,":"),comma:new Qg("comma",Wm.token,","),equal:new Qg("equal",Wm.token,"="),equal_equal:new Qg("equal_equal",Wm.token,"=="),not_equal:new Qg("not_equal",Wm.token,"!="),greater_than:new Qg("greater_than",Wm.token,">"),greater_than_equal:new Qg("greater_than_equal",Wm.token,">="),shift_right:new Qg("shift_right",Wm.token,">>"),less_than:new Qg("less_than",Wm.token,"<"),less_than_equal:new Qg("less_than_equal",Wm.token,"<="),shift_left:new Qg("shift_left",Wm.token,"<<"),modulo:new Qg("modulo",Wm.token,"%"),minus:new Qg("minus",Wm.token,"-"),minus_minus:new Qg("minus_minus",Wm.token,"--"),period:new Qg("period",Wm.token,"."),plus:new Qg("plus",Wm.token,"+"),plus_plus:new Qg("plus_plus",Wm.token,"++"),or:new Qg("or",Wm.token,"|"),or_or:new Qg("or_or",Wm.token,"||"),paren_left:new Qg("paren_left",Wm.token,"("),paren_right:new Qg("paren_right",Wm.token,")"),semicolon:new Qg("semicolon",Wm.token,";"),star:new Qg("star",Wm.token,"*"),tilde:new Qg("tilde",Wm.token,"~"),underscore:new Qg("underscore",Wm.token,"_"),xor:new Qg("xor",Wm.token,"^"),plus_equal:new Qg("plus_equal",Wm.token,"+="),minus_equal:new Qg("minus_equal",Wm.token,"-="),times_equal:new Qg("times_equal",Wm.token,"*="),division_equal:new Qg("division_equal",Wm.token,"/="),modulo_equal:new Qg("modulo_equal",Wm.token,"%="),and_equal:new Qg("and_equal",Wm.token,"&="),or_equal:new Qg("or_equal",Wm.token,"|="),xor_equal:new Qg("xor_equal",Wm.token,"^="),shift_right_equal:new Qg("shift_right_equal",Wm.token,">>="),shift_left_equal:new Qg("shift_left_equal",Wm.token,"<<=")},$g.simpleTokens={"@":Zm.tokens.attr,"{":Zm.tokens.brace_left,"}":Zm.tokens.brace_right,":":Zm.tokens.colon,",":Zm.tokens.comma,"(":Zm.tokens.paren_left,")":Zm.tokens.paren_right,";":Zm.tokens.semicolon},$g.literalTokens={"&":Zm.tokens.and,"&&":Zm.tokens.and_and,"->":Zm.tokens.arrow,"/":Zm.tokens.forward_slash,"!":Zm.tokens.bang,"[":Zm.tokens.bracket_left,"]":Zm.tokens.bracket_right,"=":Zm.tokens.equal,"==":Zm.tokens.equal_equal,"!=":Zm.tokens.not_equal,">":Zm.tokens.greater_than,">=":Zm.tokens.greater_than_equal,">>":Zm.tokens.shift_right,"<":Zm.tokens.less_than,"<=":Zm.tokens.less_than_equal,"<<":Zm.tokens.shift_left,"%":Zm.tokens.modulo,"-":Zm.tokens.minus,"--":Zm.tokens.minus_minus,".":Zm.tokens.period,"+":Zm.tokens.plus,"++":Zm.tokens.plus_plus,"|":Zm.tokens.or,"||":Zm.tokens.or_or,"*":Zm.tokens.star,"~":Zm.tokens.tilde,_:Zm.tokens.underscore,"^":Zm.tokens.xor,"+=":Zm.tokens.plus_equal,"-=":Zm.tokens.minus_equal,"*=":Zm.tokens.times_equal,"/=":Zm.tokens.division_equal,"%=":Zm.tokens.modulo_equal,"&=":Zm.tokens.and_equal,"|=":Zm.tokens.or_equal,"^=":Zm.tokens.xor_equal,">>=":Zm.tokens.shift_right_equal,"<<=":Zm.tokens.shift_left_equal},$g.regexTokens={decimal_float_literal:Zm.tokens.decimal_float_literal,hex_float_literal:Zm.tokens.hex_float_literal,int_literal:Zm.tokens.int_literal,uint_literal:Zm.tokens.uint_literal,ident:Zm.tokens.ident},$g.storage_class=[Zm.keywords.function,Zm.keywords.private,Zm.keywords.workgroup,Zm.keywords.uniform,Zm.keywords.storage],$g.access_mode=[Zm.keywords.read,Zm.keywords.write,Zm.keywords.read_write],$g.sampler_type=[Zm.keywords.sampler,Zm.keywords.sampler_comparison],$g.sampled_texture_type=[Zm.keywords.texture_1d,Zm.keywords.texture_2d,Zm.keywords.texture_2d_array,Zm.keywords.texture_3d,Zm.keywords.texture_cube,Zm.keywords.texture_cube_array],$g.multisampled_texture_type=[Zm.keywords.texture_multisampled_2d],$g.storage_texture_type=[Zm.keywords.texture_storage_1d,Zm.keywords.texture_storage_2d,Zm.keywords.texture_storage_2d_array,Zm.keywords.texture_storage_3d],$g.depth_texture_type=[Zm.keywords.texture_depth_2d,Zm.keywords.texture_depth_2d_array,Zm.keywords.texture_depth_cube,Zm.keywords.texture_depth_cube_array,Zm.keywords.texture_depth_multisampled_2d],$g.texture_external_type=[Zm.keywords.texture_external],$g.any_texture_type=[...Zm.sampled_texture_type,...Zm.multisampled_texture_type,...Zm.storage_texture_type,...Zm.depth_texture_type,...Zm.texture_external_type],$g.texel_format=[Zm.keywords.r8unorm,Zm.keywords.r8snorm,Zm.keywords.r8uint,Zm.keywords.r8sint,Zm.keywords.r16uint,Zm.keywords.r16sint,Zm.keywords.r16float,Zm.keywords.rg8unorm,Zm.keywords.rg8snorm,Zm.keywords.rg8uint,Zm.keywords.rg8sint,Zm.keywords.r32uint,Zm.keywords.r32sint,Zm.keywords.r32float,Zm.keywords.rg16uint,Zm.keywords.rg16sint,Zm.keywords.rg16float,Zm.keywords.rgba8unorm,Zm.keywords.rgba8unorm_srgb,Zm.keywords.rgba8snorm,Zm.keywords.rgba8uint,Zm.keywords.rgba8sint,Zm.keywords.bgra8unorm,Zm.keywords.bgra8unorm_srgb,Zm.keywords.rgb10a2unorm,Zm.keywords.rg11b10float,Zm.keywords.rg32uint,Zm.keywords.rg32sint,Zm.keywords.rg32float,Zm.keywords.rgba16uint,Zm.keywords.rgba16sint,Zm.keywords.rgba16float,Zm.keywords.rgba32uint,Zm.keywords.rgba32sint,Zm.keywords.rgba32float],$g.const_literal=[Zm.tokens.int_literal,Zm.tokens.uint_literal,Zm.tokens.decimal_float_literal,Zm.tokens.hex_float_literal,Zm.keywords.true,Zm.keywords.false],$g.literal_or_ident=[Zm.tokens.ident,Zm.tokens.int_literal,Zm.tokens.uint_literal,Zm.tokens.decimal_float_literal,Zm.tokens.hex_float_literal,Zm.tokens.name],$g.element_count_expression=[Zm.tokens.int_literal,Zm.tokens.uint_literal,Zm.tokens.ident],$g.template_types=[Zm.keywords.vec2,Zm.keywords.vec3,Zm.keywords.vec4,Zm.keywords.mat2x2,Zm.keywords.mat2x3,Zm.keywords.mat2x4,Zm.keywords.mat3x2,Zm.keywords.mat3x3,Zm.keywords.mat3x4,Zm.keywords.mat4x2,Zm.keywords.mat4x3,Zm.keywords.mat4x4,Zm.keywords.atomic,Zm.keywords.bitcast,...Zm.any_texture_type],$g.attribute_name=[Zm.tokens.ident,Zm.keywords.block,Zm.keywords.diagnostic],$g.assignment_operators=[Zm.tokens.equal,Zm.tokens.plus_equal,Zm.tokens.minus_equal,Zm.tokens.times_equal,Zm.tokens.division_equal,Zm.tokens.modulo_equal,Zm.tokens.and_equal,Zm.tokens.or_equal,Zm.tokens.xor_equal,Zm.tokens.shift_right_equal,Zm.tokens.shift_left_equal],$g.increment_operators=[Zm.tokens.plus_plus,Zm.tokens.minus_minus];class Zg{constructor(e,t,i,n,r){this.type=e,this.lexeme=t,this.line=i,this.start=n,this.end=r}toString(){return this.lexeme}isTemplateType(){return-1!=$g.template_types.indexOf(this.type)}isArrayType(){return this.type==$g.keywords.array}isArrayOrTemplateType(){return this.isArrayType()||this.isTemplateType()}}class Wg{constructor(e){this._tokens=[],this._start=0,this._current=0,this._line=1,this._source=null!=e?e:""}scanTokens(){for(;!this._isAtEnd();)if(this._start=this._current,!this.scanToken())throw`Invalid syntax at line ${this._line}`;return this._tokens.push(new Zg($g.eof,"",this._line,this._current,this._current)),this._tokens}scanToken(){let e=this._advance();if("\n"==e)return this._line++,!0;if(this._isWhitespace(e))return!0;if("/"==e){if("/"==this._peekAhead()){for(;"\n"!=e;){if(this._isAtEnd())return!0;e=this._advance()}return this._line++,!0}if("*"==this._peekAhead()){this._advance();let t=1;for(;t>0;){if(this._isAtEnd())return!0;if(e=this._advance(),"\n"==e)this._line++;else if("*"==e){if("/"==this._peekAhead()&&(this._advance(),t--,0==t))return!0}else"/"==e&&"*"==this._peekAhead()&&(this._advance(),t++)}return!0}}const t=$g.simpleTokens[e];if(t)return this._addToken(t),!0;let i=$g.none;const n=this._isAlpha(e),r="_"===e;if(this._isAlphaNumeric(e)){let t=this._peekAhead();for(;this._isAlphaNumeric(t);)e+=this._advance(),t=this._peekAhead()}if(n){const t=$g.keywords[e];if(t)return this._addToken(t),!0}if(n||r)return this._addToken($g.tokens.ident),!0;for(;;){let t=this._findType(e);const n=this._peekAhead();if("-"==e&&this._tokens.length>0){if("="==n)return this._current++,e+=n,this._addToken($g.tokens.minus_equal),!0;if("-"==n)return this._current++,e+=n,this._addToken($g.tokens.minus_minus),!0;const i=this._tokens.length-1;if((-1!=$g.literal_or_ident.indexOf(this._tokens[i].type)||this._tokens[i].type==$g.tokens.paren_right)&&">"!=n)return this._addToken(t),!0}if(">"==e&&(">"==n||"="==n)){let e=!1,i=this._tokens.length-1;for(let t=0;t<5&&i>=0&&-1===$g.assignment_operators.indexOf(this._tokens[i].type);++t,--i)if(this._tokens[i].type===$g.tokens.less_than){i>0&&this._tokens[i-1].isArrayOrTemplateType()&&(e=!0);break}if(e)return this._addToken(t),!0}if(t===$g.none){let n=e,r=0;const o=2;for(let e=0;e=this._source.length}_isAlpha(e){return!this._isNumeric(e)&&!this._isWhitespace(e)&&"_"!==e&&"."!==e&&"("!==e&&")"!==e&&"["!==e&&"]"!==e&&"{"!==e&&"}"!==e&&","!==e&&";"!==e&&":"!==e&&"="!==e&&"!"!==e&&"<"!==e&&">"!==e&&"+"!==e&&"-"!==e&&"*"!==e&&"/"!==e&&"%"!==e&&"&"!==e&&"|"!==e&&"^"!==e&&"~"!==e&&"@"!==e&&"#"!==e&&"?"!==e&&"'"!==e&&"`"!==e&&'"'!==e&&"\\"!==e&&"\n"!==e&&"\r"!==e&&"\t"!==e&&"\0"!==e}_isNumeric(e){return e>="0"&&e<="9"}_isAlphaNumeric(e){return this._isAlpha(e)||this._isNumeric(e)||"_"===e}_isWhitespace(e){return" "==e||"\t"==e||"\r"==e}_advance(e=0){let t=this._source[this._current];return e=e||0,e++,this._current+=e,t}_peekAhead(e=0){return e=e||0,this._current+e>=this._source.length?"\0":this._source[this._current+e]}_addToken(e){const t=this._source.substring(this._start,this._current);this._tokens.push(new Zg(e,t,this._line,this._start,this._current))}}function qg(e){return Array.isArray(e)||(null==e?void 0:e.buffer)instanceof ArrayBuffer}const Kg=new Float32Array(1),Xg=new Uint32Array(Kg.buffer),Jg=new Uint32Array(Kg.buffer),Yg=new Int32Array(1),e_=new Float32Array(Yg.buffer),t_=new Uint32Array(Yg.buffer),i_=new Uint32Array(1),n_=new Float32Array(i_.buffer),r_=new Int32Array(i_.buffer);function o_(e,t,i){if(t===i)return e;if("f32"===t){if("i32"===i||"x32"===i)return Kg[0]=e,Xg[0];if("u32"===i)return Kg[0]=e,Jg[0]}else if("i32"===t||"x32"===t){if("f32"===i)return Yg[0]=e,e_[0];if("u32"===i)return Yg[0]=e,t_[0]}else if("u32"===t){if("f32"===i)return i_[0]=e,n_[0];if("i32"===i||"x32"===i)return i_[0]=e,r_[0]}return console.error(`Unsupported cast from ${t} to ${i}`),e}class s_{constructor(e){this.resources=null,this.inUse=!1,this.info=null,this.node=e}}class a_{constructor(e,t){this.align=e,this.size=t}}class l_{constructor(){this.uniforms=[],this.storage=[],this.textures=[],this.samplers=[],this.aliases=[],this.overrides=[],this.structs=[],this.entry=new ym,this.functions=[],this._types=new Map,this._functions=new Map}_isStorageTexture(e){return"texture_storage_1d"==e.name||"texture_storage_2d"==e.name||"texture_storage_2d_array"==e.name||"texture_storage_3d"==e.name}updateAST(e){for(const t of e)t instanceof Dm&&this._functions.set(t.name,new s_(t));for(const t of e)if(t instanceof hg){const e=this.getTypeInfo(t,null);e instanceof am&&this.structs.push(e)}for(const t of e)if(t instanceof og)this.aliases.push(this._getAliasInfo(t));else{if(t instanceof jm){const e=t,i=this._getAttributeNum(e.attributes,"id",0),n=null!=e.type?this.getTypeInfo(e.type,e.attributes):null;this.overrides.push(new gm(e.name,n,e.attributes,i));continue}if(this._isUniformVar(t)){const e=t,i=this._getAttributeNum(e.attributes,"group",0),n=this._getAttributeNum(e.attributes,"binding",0),r=this.getTypeInfo(e.type,e.attributes),o=new dm(e.name,r,i,n,e.attributes,hm.Uniform,e.access);o.access||(o.access="read"),this.uniforms.push(o);continue}if(this._isStorageVar(t)){const e=t,i=this._getAttributeNum(e.attributes,"group",0),n=this._getAttributeNum(e.attributes,"binding",0),r=this.getTypeInfo(e.type,e.attributes),o=this._isStorageTexture(r),s=new dm(e.name,r,i,n,e.attributes,o?hm.StorageTexture:hm.Storage,e.access);s.access||(s.access="read"),this.storage.push(s);continue}if(this._isTextureVar(t)){const e=t,i=this._getAttributeNum(e.attributes,"group",0),n=this._getAttributeNum(e.attributes,"binding",0),r=this.getTypeInfo(e.type,e.attributes),o=this._isStorageTexture(r),s=new dm(e.name,r,i,n,e.attributes,o?hm.StorageTexture:hm.Texture,e.access);s.access||(s.access="read"),o?this.storage.push(s):this.textures.push(s);continue}if(this._isSamplerVar(t)){const e=t,i=this._getAttributeNum(e.attributes,"group",0),n=this._getAttributeNum(e.attributes,"binding",0),r=this.getTypeInfo(e.type,e.attributes),o=new dm(e.name,r,i,n,e.attributes,hm.Sampler,e.access);this.samplers.push(o);continue}}for(const t of e)if(t instanceof Dm){const e=this._getAttribute(t,"vertex"),i=this._getAttribute(t,"fragment"),n=this._getAttribute(t,"compute"),r=e||i||n,o=new Am(t.name,null==r?void 0:r.name,t.attributes);o.attributes=t.attributes,o.startLine=t.startLine,o.endLine=t.endLine,this.functions.push(o),this._functions.get(t.name).info=o,r&&(this._functions.get(t.name).inUse=!0,o.inUse=!0,o.resources=this._findResources(t,!!r),o.inputs=this._getInputs(t.args),o.outputs=this._getOutputs(t.returnType),this.entry[r.name].push(o)),o.arguments=t.args.map(e=>new _m(e.name,this.getTypeInfo(e.type,e.attributes),e.attributes)),o.returnType=t.returnType?this.getTypeInfo(t.returnType,t.attributes):null;continue}for(const e of this._functions.values())e.info&&(e.info.inUse=e.inUse,this._addCalls(e.node,e.info.calls));for(const e of this._functions.values())e.node.search(t=>{var i,n,r;if(t instanceof kg){if(t.value)if(qg(t.value))for(const n of t.value)for(const t of this.overrides)n===t.name&&(null===(i=e.info)||void 0===i||i.overrides.push(t));else for(const i of this.overrides)t.value===i.name&&(null===(n=e.info)||void 0===n||n.overrides.push(i))}else if(t instanceof vg)for(const i of this.overrides)t.name===i.name&&(null===(r=e.info)||void 0===r||r.overrides.push(i))});for(const e of this.uniforms)this._markStructsInUse(e.type);for(const e of this.storage)this._markStructsInUse(e.type)}getFunctionInfo(e){for(const t of this.functions)if(t.name==e)return t;return null}getStructInfo(e){for(const t of this.structs)if(t.name==e)return t;return null}getOverrideInfo(e){for(const t of this.overrides)if(t.name==e)return t;return null}_markStructsInUse(e){if(e)if(e.isStruct){if(e.inUse=!0,e.members)for(const t of e.members)this._markStructsInUse(t.type)}else if(e.isArray)this._markStructsInUse(e.format);else if(e.isTemplate)e.format&&this._markStructsInUse(e.format);else{const t=this._getAlias(e.name);t&&this._markStructsInUse(t)}}_addCalls(e,t){var i;for(const n of e.calls){const e=null===(i=this._functions.get(n.name))||void 0===i?void 0:i.info;e&&t.add(e)}}findResource(e,t,i){if(i){for(const n of this.entry.compute)if(n.name===i)for(const i of n.resources)if(i.group==e&&i.binding==t)return i;for(const n of this.entry.vertex)if(n.name===i)for(const i of n.resources)if(i.group==e&&i.binding==t)return i;for(const n of this.entry.fragment)if(n.name===i)for(const i of n.resources)if(i.group==e&&i.binding==t)return i}for(const i of this.uniforms)if(i.group==e&&i.binding==t)return i;for(const i of this.storage)if(i.group==e&&i.binding==t)return i;for(const i of this.textures)if(i.group==e&&i.binding==t)return i;for(const i of this.samplers)if(i.group==e&&i.binding==t)return i;return null}_findResource(e){for(const t of this.uniforms)if(t.name==e)return t;for(const t of this.storage)if(t.name==e)return t;for(const t of this.textures)if(t.name==e)return t;for(const t of this.samplers)if(t.name==e)return t;return null}_markStructsFromAST(e){const t=this.getTypeInfo(e,null);this._markStructsInUse(t)}_findResources(e,t){const i=[],n=this,r=[];return e.search(o=>{if(o instanceof Rm)r.push({});else if(o instanceof Lm)r.pop();else if(o instanceof Vm){const e=o;t&&null!==e.type&&this._markStructsFromAST(e.type),r.length>0&&(r[r.length-1][e.name]=e)}else if(o instanceof Ag){const e=o;t&&null!==e.type&&this._markStructsFromAST(e.type)}else if(o instanceof Gm){const e=o;t&&null!==e.type&&this._markStructsFromAST(e.type),r.length>0&&(r[r.length-1][e.name]=e)}else if(o instanceof vg){const e=o;if(r.length>0&&r[r.length-1][e.name])return;const t=n._findResource(e.name);t&&i.push(t)}else if(o instanceof yg){const r=o,s=n._functions.get(r.name);s&&(t&&(s.inUse=!0),e.calls.add(s.node),null===s.resources&&(s.resources=n._findResources(s.node,t)),i.push(...s.resources))}else if(o instanceof Xm){const r=o,s=n._functions.get(r.name);s&&(t&&(s.inUse=!0),e.calls.add(s.node),null===s.resources&&(s.resources=n._findResources(s.node,t)),i.push(...s.resources))}}),[...new Map(i.map(e=>[e.name,e])).values()]}getBindGroups(){const e=[];function t(t,i){t>=e.length&&(e.length=t+1),void 0===e[t]&&(e[t]=[]),i>=e[t].length&&(e[t].length=i+1)}for(const i of this.uniforms)t(i.group,i.binding),e[i.group][i.binding]=i;for(const i of this.storage)t(i.group,i.binding),e[i.group][i.binding]=i;for(const i of this.textures)t(i.group,i.binding),e[i.group][i.binding]=i;for(const i of this.samplers)t(i.group,i.binding),e[i.group][i.binding]=i;return e}_getOutputs(e,t=void 0){if(void 0===t&&(t=[]),e instanceof hg)this._getStructOutputs(e,t);else{const i=this._getOutputInfo(e);null!==i&&t.push(i)}return t}_getStructOutputs(e,t){for(const i of e.members)if(i.type instanceof hg)this._getStructOutputs(i.type,t);else{const e=this._getAttribute(i,"location")||this._getAttribute(i,"builtin");if(null!==e){const n=this.getTypeInfo(i.type,i.type.attributes),r=this._parseInt(e.value),o=new mm(i.name,n,e.name,r);t.push(o)}}}_getOutputInfo(e){const t=this._getAttribute(e,"location")||this._getAttribute(e,"builtin");if(null!==t){const i=this.getTypeInfo(e,e.attributes),n=this._parseInt(t.value);return new mm("",i,t.name,n)}return null}_getInputs(e,t=void 0){void 0===t&&(t=[]);for(const i of e)if(i.type instanceof hg)this._getStructInputs(i.type,t);else{const e=this._getInputInfo(i);null!==e&&t.push(e)}return t}_getStructInputs(e,t){for(const i of e.members)if(i.type instanceof hg)this._getStructInputs(i.type,t);else{const e=this._getInputInfo(i);null!==e&&t.push(e)}}_getInputInfo(e){const t=this._getAttribute(e,"location")||this._getAttribute(e,"builtin");if(null!==t){const i=this._getAttribute(e,"interpolation"),n=this.getTypeInfo(e.type,e.attributes),r=this._parseInt(t.value),o=new fm(e.name,n,t.name,r);return null!==i&&(o.interpolation=this._parseString(i.value)),o}return null}_parseString(e){return e instanceof Array&&(e=e[0]),e}_parseInt(e){e instanceof Array&&(e=e[0]);const t=parseInt(e);return isNaN(t)?e:t}_getAlias(e){for(const t of this.aliases)if(t.name==e)return t.type;return null}_getAliasInfo(e){return new pm(e.name,this.getTypeInfo(e.type,null))}getTypeInfoByName(e){for(const t of this.structs)if(t.name==e)return t;for(const t of this.aliases)if(t.name==e)return t.type;return null}getTypeInfo(e,t=null){if(this._types.has(e))return this._types.get(e);if(e instanceof pg){const i=e.type?this.getTypeInfo(e.type,e.attributes):null,n=new cm(e.name,i,t);return this._types.set(e,n),this._updateTypeInfo(n),n}if(e instanceof fg){const i=e,n=i.format?this.getTypeInfo(i.format,i.attributes):null,r=new lm(i.name,t);return r.format=n,r.count=i.count,this._types.set(e,r),this._updateTypeInfo(r),r}if(e instanceof hg){const i=e,n=new am(i.name,t);n.startLine=i.startLine,n.endLine=i.endLine;for(const e of i.members){const t=this.getTypeInfo(e.type,e.attributes);n.members.push(new sm(e.name,t,e.attributes))}return this._types.set(e,n),this._updateTypeInfo(n),n}if(e instanceof mg){const i=e,n=i.format instanceof cg,r=i.format?n?this.getTypeInfo(i.format,null):new om(i.format,null):null,o=new um(i.name,r,t,i.access);return this._types.set(e,o),this._updateTypeInfo(o),o}if(e instanceof dg){const i=e,n=i.format?this.getTypeInfo(i.format,null):null,r=new um(i.name,n,t,i.access);return this._types.set(e,r),this._updateTypeInfo(r),r}const i=new om(e.name,t);return this._types.set(e,i),this._updateTypeInfo(i),i}_updateTypeInfo(e){var t,i,n;const r=this._getTypeSize(e);if(e.size=null!==(t=null==r?void 0:r.size)&&void 0!==t?t:0,e instanceof lm&&e.format){const t=this._getTypeSize(e.format);e.stride=Math.max(null!==(i=null==t?void 0:t.size)&&void 0!==i?i:0,null!==(n=null==t?void 0:t.align)&&void 0!==n?n:0),this._updateTypeInfo(e.format)}e instanceof cm&&this._updateTypeInfo(e.format),e instanceof am&&this._updateStructInfo(e)}_updateStructInfo(e){var t;let i=0,n=0,r=0,o=0;for(let s=0,a=e.members.length;se.name),l_._samplerTypes=$g.sampler_type.map(e=>e.name);let c_=0;class u_{constructor(e,t,i){this.id=c_++,this.name=e,this.value=t,this.node=i}clone(){return new u_(this.name,this.value,this.node)}}class h_{constructor(e){this.id=c_++,this.name=e.name,this.node=e}clone(){return new h_(this.node)}}class d_{constructor(e){this.parent=null,this.variables=new Map,this.functions=new Map,this.currentFunctionName="",this.id=c_++,e&&(this.parent=e,this.currentFunctionName=e.currentFunctionName)}getVariable(e){var t;return this.variables.has(e)?null!==(t=this.variables.get(e))&&void 0!==t?t:null:this.parent?this.parent.getVariable(e):null}getFunction(e){var t;return this.functions.has(e)?null!==(t=this.functions.get(e))&&void 0!==t?t:null:this.parent?this.parent.getFunction(e):null}createVariable(e,t,i){this.variables.set(e,new u_(e,t,null!=i?i:null))}setVariable(e,t,i){const n=this.getVariable(e);null!==n?n.value=t:this.createVariable(e,t,i)}getVariableValue(e){var t;const i=this.getVariable(e);return null!==(t=null==i?void 0:i.value)&&void 0!==t?t:null}clone(){return new d_(this)}}class p_{evalExpression(e,t){return null}getTypeInfo(e){return null}getVariableName(e,t){return""}}class f_{constructor(e){this.exec=e}getTypeInfo(e){return this.exec.getTypeInfo(e)}All(e,t){const i=this.exec.evalExpression(e.args[0],t);let n=!0;if(i instanceof Vg)return i.data.forEach(e=>{e||(n=!1)}),new Ug(n?1:0,this.getTypeInfo("bool"));throw new Error(`All() expects a vector argument. Line ${e.line}`)}Any(e,t){const i=this.exec.evalExpression(e.args[0],t);if(i instanceof Vg){const e=i.data.some(e=>e);return new Ug(e?1:0,this.getTypeInfo("bool"))}throw new Error(`Any() expects a vector argument. Line ${e.line}`)}Select(e,t){const i=this.exec.evalExpression(e.args[2],t);if(!(i instanceof Ug))throw new Error(`Select() expects a bool condition. Line ${e.line}`);return i.value?this.exec.evalExpression(e.args[1],t):this.exec.evalExpression(e.args[0],t)}ArrayLength(e,t){let i=e.args[0];i instanceof Cg&&(i=i.right);const n=this.exec.evalExpression(i,t);if(n instanceof Gg&&0===n.typeInfo.size){const e=n.typeInfo,t=n.buffer.byteLength/e.stride;return new Ug(t,this.getTypeInfo("u32"))}return new Ug(n.typeInfo.size,this.getTypeInfo("u32"))}Abs(e,t){const i=this.exec.evalExpression(e.args[0],t);if(i instanceof Vg)return new Vg(i.data.map(e=>Math.abs(e)),i.typeInfo);const n=i;return new Ug(Math.abs(n.value),n.typeInfo)}Acos(e,t){const i=this.exec.evalExpression(e.args[0],t);if(i instanceof Vg)return new Vg(i.data.map(e=>Math.acos(e)),i.typeInfo);const n=i;return new Ug(Math.acos(n.value),i.typeInfo)}Acosh(e,t){const i=this.exec.evalExpression(e.args[0],t);if(i instanceof Vg)return new Vg(i.data.map(e=>Math.acosh(e)),i.typeInfo);const n=i;return new Ug(Math.acosh(n.value),i.typeInfo)}Asin(e,t){const i=this.exec.evalExpression(e.args[0],t);if(i instanceof Vg)return new Vg(i.data.map(e=>Math.asin(e)),i.typeInfo);const n=i;return new Ug(Math.asin(n.value),i.typeInfo)}Asinh(e,t){const i=this.exec.evalExpression(e.args[0],t);if(i instanceof Vg)return new Vg(i.data.map(e=>Math.asinh(e)),i.typeInfo);const n=i;return new Ug(Math.asinh(n.value),i.typeInfo)}Atan(e,t){const i=this.exec.evalExpression(e.args[0],t);if(i instanceof Vg)return new Vg(i.data.map(e=>Math.atan(e)),i.typeInfo);const n=i;return new Ug(Math.atan(n.value),i.typeInfo)}Atanh(e,t){const i=this.exec.evalExpression(e.args[0],t);if(i instanceof Vg)return new Vg(i.data.map(e=>Math.atanh(e)),i.typeInfo);const n=i;return new Ug(Math.atanh(n.value),i.typeInfo)}Atan2(e,t){const i=this.exec.evalExpression(e.args[0],t),n=this.exec.evalExpression(e.args[1],t);if(i instanceof Vg&&n instanceof Vg)return new Vg(i.data.map((e,t)=>Math.atan2(e,n.data[t])),i.typeInfo);const r=i,o=n;return new Ug(Math.atan2(r.value,o.value),i.typeInfo)}Ceil(e,t){const i=this.exec.evalExpression(e.args[0],t);if(i instanceof Vg)return new Vg(i.data.map(e=>Math.ceil(e)),i.typeInfo);const n=i;return new Ug(Math.ceil(n.value),i.typeInfo)}_clamp(e,t,i){return Math.min(Math.max(e,t),i)}Clamp(e,t){const i=this.exec.evalExpression(e.args[0],t),n=this.exec.evalExpression(e.args[1],t),r=this.exec.evalExpression(e.args[2],t);if(i instanceof Vg&&n instanceof Vg&&r instanceof Vg)return new Vg(i.data.map((e,t)=>this._clamp(e,n.data[t],r.data[t])),i.typeInfo);const o=i,s=n,a=r;return new Ug(this._clamp(o.value,s.value,a.value),i.typeInfo)}Cos(e,t){const i=this.exec.evalExpression(e.args[0],t);if(i instanceof Vg)return new Vg(i.data.map(e=>Math.cos(e)),i.typeInfo);const n=i;return new Ug(Math.cos(n.value),i.typeInfo)}Cosh(e,t){const i=this.exec.evalExpression(e.args[0],t);if(i instanceof Vg)return new Vg(i.data.map(e=>Math.cosh(e)),i.typeInfo);const n=i;return new Ug(Math.cos(n.value),i.typeInfo)}CountLeadingZeros(e,t){const i=this.exec.evalExpression(e.args[0],t);if(i instanceof Vg)return new Vg(i.data.map(e=>Math.clz32(e)),i.typeInfo);const n=i;return new Ug(Math.clz32(n.value),i.typeInfo)}_countOneBits(e){let t=0;for(;0!==e;)1&e&&t++,e>>=1;return t}CountOneBits(e,t){const i=this.exec.evalExpression(e.args[0],t);if(i instanceof Vg)return new Vg(i.data.map(e=>this._countOneBits(e)),i.typeInfo);const n=i;return new Ug(this._countOneBits(n.value),i.typeInfo)}_countTrailingZeros(e){if(0===e)return 32;let t=0;for(;!(1&e);)e>>=1,t++;return t}CountTrailingZeros(e,t){const i=this.exec.evalExpression(e.args[0],t);if(i instanceof Vg)return new Vg(i.data.map(e=>this._countTrailingZeros(e)),i.typeInfo);const n=i;return new Ug(this._countTrailingZeros(n.value),i.typeInfo)}Cross(e,t){const i=this.exec.evalExpression(e.args[0],t),n=this.exec.evalExpression(e.args[1],t);if(i instanceof Vg&&n instanceof Vg){if(3!==i.data.length||3!==n.data.length)return console.error(`Cross() expects 3D vectors. Line ${e.line}`),null;const t=i.data,r=n.data;return new Vg([t[1]*r[2]-r[1]*t[2],t[2]*r[0]-r[2]*t[0],t[0]*r[1]-r[0]*t[1]],i.typeInfo)}return console.error(`Cross() expects vector arguments. Line ${e.line}`),null}Degrees(e,t){const i=this.exec.evalExpression(e.args[0],t),n=180/Math.PI;return i instanceof Vg?new Vg(i.data.map(e=>e*n),i.typeInfo):new Ug(i.value*n,this.getTypeInfo("f32"))}Determinant(e,t){const i=this.exec.evalExpression(e.args[0],t);if(i instanceof jg){const e=i.data,t=i.typeInfo.getTypeName(),n=t.endsWith("h")?this.getTypeInfo("f16"):this.getTypeInfo("f32");if("mat2x2"===t||"mat2x2f"===t||"mat2x2h"===t)return new Ug(e[0]*e[3]-e[1]*e[2],n);if("mat2x3"===t||"mat2x3f"===t||"mat2x3h"===t)return new Ug(e[0]*(e[4]*e[8]-e[5]*e[7])-e[1]*(e[3]*e[8]-e[5]*e[6])+e[2]*(e[3]*e[7]-e[4]*e[6]),n);if("mat2x4"===t||"mat2x4f"===t||"mat2x4h"===t)console.error(`TODO: Determinant for ${t}`);else if("mat3x2"===t||"mat3x2f"===t||"mat3x2h"===t)console.error(`TODO: Determinant for ${t}`);else{if("mat3x3"===t||"mat3x3f"===t||"mat3x3h"===t)return new Ug(e[0]*(e[4]*e[8]-e[5]*e[7])-e[1]*(e[3]*e[8]-e[5]*e[6])+e[2]*(e[3]*e[7]-e[4]*e[6]),n);"mat3x4"===t||"mat3x4f"===t||"mat3x4h"===t||"mat4x2"===t||"mat4x2f"===t||"mat4x2h"===t||"mat4x3"===t||"mat4x3f"===t||"mat4x3h"===t?console.error(`TODO: Determinant for ${t}`):"mat4x4"!==t&&"mat4x4f"!==t&&"mat4x4h"!==t||console.error(`TODO: Determinant for ${t}`)}}return console.error(`Determinant expects a matrix argument. Line ${e.line}`),null}Distance(e,t){const i=this.exec.evalExpression(e.args[0],t),n=this.exec.evalExpression(e.args[1],t);if(i instanceof Vg&&n instanceof Vg){let e=0;for(let t=0;tMath.exp(e)),i.typeInfo);const n=i;return new Ug(Math.exp(n.value),i.typeInfo)}Exp2(e,t){const i=this.exec.evalExpression(e.args[0],t);if(i instanceof Vg)return new Vg(i.data.map(e=>Math.pow(2,e)),i.typeInfo);const n=i;return new Ug(Math.pow(2,n.value),i.typeInfo)}ExtractBits(e,t){const i=this.exec.evalExpression(e.args[0],t),n=this.exec.evalExpression(e.args[1],t),r=this.exec.evalExpression(e.args[2],t);if("u32"!==n.typeInfo.name&&"x32"!==n.typeInfo.name)return console.error(`ExtractBits() expects an i32 offset argument. Line ${e.line}`),null;if("u32"!==r.typeInfo.name&&"x32"!==r.typeInfo.name)return console.error(`ExtractBits() expects an i32 count argument. Line ${e.line}`),null;const o=n.value,s=r.value;if(i instanceof Vg)return new Vg(i.data.map(e=>e>>o&(1<>o&(1<-e),i.typeInfo)}return console.error(`FaceForward() expects vector arguments. Line ${e.line}`),null}_firstLeadingBit(e){return 0===e?-1:31-Math.clz32(e)}FirstLeadingBit(e,t){const i=this.exec.evalExpression(e.args[0],t);if(i instanceof Vg)return new Vg(i.data.map(e=>this._firstLeadingBit(e)),i.typeInfo);const n=i;return new Ug(this._firstLeadingBit(n.value),i.typeInfo)}_firstTrailingBit(e){return 0===e?-1:Math.log2(e&-e)}FirstTrailingBit(e,t){const i=this.exec.evalExpression(e.args[0],t);if(i instanceof Vg)return new Vg(i.data.map(e=>this._firstTrailingBit(e)),i.typeInfo);const n=i;return new Ug(this._firstTrailingBit(n.value),i.typeInfo)}Floor(e,t){const i=this.exec.evalExpression(e.args[0],t);if(i instanceof Vg)return new Vg(i.data.map(e=>Math.floor(e)),i.typeInfo);const n=i;return new Ug(Math.floor(n.value),i.typeInfo)}Fma(e,t){const i=this.exec.evalExpression(e.args[0],t),n=this.exec.evalExpression(e.args[1],t),r=this.exec.evalExpression(e.args[2],t);if(i instanceof Vg&&n instanceof Vg&&r instanceof Vg)return i.data.length!==n.data.length||i.data.length!==r.data.length?(console.error(`Fma() expects vectors of the same length. Line ${e.line}`),null):new Vg(i.data.map((e,t)=>e*n.data[t]+r.data[t]),i.typeInfo);const o=i,s=n,a=r;return new Ug(o.value*s.value+a.value,o.typeInfo)}Fract(e,t){const i=this.exec.evalExpression(e.args[0],t);if(i instanceof Vg)return new Vg(i.data.map(e=>e-Math.floor(e)),i.typeInfo);const n=i;return new Ug(n.value-Math.floor(n.value),i.typeInfo)}Frexp(e,t){return console.error(`TODO: frexp. Line ${e.line}`),null}InsertBits(e,t){const i=this.exec.evalExpression(e.args[0],t),n=this.exec.evalExpression(e.args[1],t),r=this.exec.evalExpression(e.args[2],t),o=this.exec.evalExpression(e.args[3],t);if("u32"!==r.typeInfo.name&&"x32"!==r.typeInfo.name)return console.error(`InsertBits() expects an i32 offset argument. Line ${e.line}`),null;const s=r.value,a=(1<e&l|n.data[t]<1/Math.sqrt(e)),i.typeInfo);const n=i;return new Ug(1/Math.sqrt(n.value),i.typeInfo)}Ldexp(e,t){return console.error(`TODO: ldexp. Line ${e.line}`),null}Length(e,t){const i=this.exec.evalExpression(e.args[0],t);if(i instanceof Vg){let e=0;return i.data.forEach(t=>{e+=t*t}),new Ug(Math.sqrt(e),this.getTypeInfo("f32"))}const n=i;return new Ug(Math.abs(n.value),i.typeInfo)}Log(e,t){const i=this.exec.evalExpression(e.args[0],t);if(i instanceof Vg)return new Vg(i.data.map(e=>Math.log(e)),i.typeInfo);const n=i;return new Ug(Math.log(n.value),i.typeInfo)}Log2(e,t){const i=this.exec.evalExpression(e.args[0],t);if(i instanceof Vg)return new Vg(i.data.map(e=>Math.log2(e)),i.typeInfo);const n=i;return new Ug(Math.log2(n.value),i.typeInfo)}Max(e,t){const i=this.exec.evalExpression(e.args[0],t),n=this.exec.evalExpression(e.args[1],t);if(i instanceof Vg&&n instanceof Vg)return new Vg(i.data.map((e,t)=>Math.max(e,n.data[t])),i.typeInfo);const r=i,o=n;return new Ug(Math.max(r.value,o.value),i.typeInfo)}Min(e,t){const i=this.exec.evalExpression(e.args[0],t),n=this.exec.evalExpression(e.args[1],t);if(i instanceof Vg&&n instanceof Vg)return new Vg(i.data.map((e,t)=>Math.min(e,n.data[t])),i.typeInfo);const r=i,o=n;return new Ug(Math.min(r.value,o.value),i.typeInfo)}Mix(e,t){const i=this.exec.evalExpression(e.args[0],t),n=this.exec.evalExpression(e.args[1],t),r=this.exec.evalExpression(e.args[2],t);if(i instanceof Vg&&n instanceof Vg&&r instanceof Vg)return new Vg(i.data.map((e,t)=>i.data[t]*(1-r.data[t])+n.data[t]*r.data[t]),i.typeInfo);const o=n,s=r;return new Ug(i.value*(1-s.value)+o.value*s.value,i.typeInfo)}Modf(e,t){const i=this.exec.evalExpression(e.args[0],t),n=this.exec.evalExpression(e.args[1],t);if(i instanceof Vg&&n instanceof Vg)return new Vg(i.data.map((e,t)=>e%n.data[t]),i.typeInfo);const r=n;return new Ug(i.value%r.value,i.typeInfo)}Normalize(e,t){const i=this.exec.evalExpression(e.args[0],t);if(i instanceof Vg){const n=this.Length(e,t).value;return new Vg(i.data.map(e=>e/n),i.typeInfo)}return console.error(`Normalize() expects a vector argument. Line ${e.line}`),null}Pow(e,t){const i=this.exec.evalExpression(e.args[0],t),n=this.exec.evalExpression(e.args[1],t);if(i instanceof Vg&&n instanceof Vg)return new Vg(i.data.map((e,t)=>Math.pow(e,n.data[t])),i.typeInfo);const r=i,o=n;return new Ug(Math.pow(r.value,o.value),i.typeInfo)}QuantizeToF16(e,t){const i=this.exec.evalExpression(e.args[0],t);return i instanceof Vg?new Vg(i.data.map(e=>e),i.typeInfo):new Ug(i.value,i.typeInfo)}Radians(e,t){const i=this.exec.evalExpression(e.args[0],t);return i instanceof Vg?new Vg(i.data.map(e=>e*Math.PI/180),i.typeInfo):new Ug(i.value*Math.PI/180,this.getTypeInfo("f32"))}Reflect(e,t){let i=this.exec.evalExpression(e.args[0],t),n=this.exec.evalExpression(e.args[1],t);if(i instanceof Vg&&n instanceof Vg){const e=this._dot(i.data,n.data);return new Vg(i.data.map((t,i)=>t-2*e*n.data[i]),i.typeInfo)}return console.error(`Reflect() expects vector arguments. Line ${e.line}`),null}Refract(e,t){let i=this.exec.evalExpression(e.args[0],t),n=this.exec.evalExpression(e.args[1],t),r=this.exec.evalExpression(e.args[2],t);if(i instanceof Vg&&n instanceof Vg&&r instanceof Ug){const e=this._dot(n.data,i.data);return new Vg(i.data.map((t,i)=>{const o=1-r.value*r.value*(1-e*e);if(o<0)return 0;const s=Math.sqrt(o);return r.value*t-(r.value*e+s)*n.data[i]}),i.typeInfo)}return console.error(`Refract() expects vector arguments and a scalar argument. Line ${e.line}`),null}ReverseBits(e,t){return console.error(`TODO: reverseBits. Line ${e.line}`),null}Round(e,t){const i=this.exec.evalExpression(e.args[0],t);if(i instanceof Vg)return new Vg(i.data.map(e=>Math.round(e)),i.typeInfo);const n=i;return new Ug(Math.round(n.value),i.typeInfo)}Saturate(e,t){const i=this.exec.evalExpression(e.args[0],t);if(i instanceof Vg)return new Vg(i.data.map(e=>Math.min(Math.max(e,0),1)),i.typeInfo);const n=i;return new Ug(Math.min(Math.max(n.value,0),1),i.typeInfo)}Sign(e,t){const i=this.exec.evalExpression(e.args[0],t);if(i instanceof Vg)return new Vg(i.data.map(e=>Math.sign(e)),i.typeInfo);const n=i;return new Ug(Math.sign(n.value),i.typeInfo)}Sin(e,t){const i=this.exec.evalExpression(e.args[0],t);if(i instanceof Vg)return new Vg(i.data.map(e=>Math.sin(e)),i.typeInfo);const n=i;return new Ug(Math.sin(n.value),i.typeInfo)}Sinh(e,t){const i=this.exec.evalExpression(e.args[0],t);if(i instanceof Vg)return new Vg(i.data.map(e=>Math.sinh(e)),i.typeInfo);const n=i;return new Ug(Math.sinh(n.value),i.typeInfo)}_smoothstep(e,t,i){const n=Math.min(Math.max((i-e)/(t-e),0),1);return n*n*(3-2*n)}SmoothStep(e,t){const i=this.exec.evalExpression(e.args[0],t),n=this.exec.evalExpression(e.args[1],t),r=this.exec.evalExpression(e.args[2],t);if(r instanceof Vg&&i instanceof Vg&&n instanceof Vg)return new Vg(r.data.map((e,t)=>this._smoothstep(i.data[t],n.data[t],e)),r.typeInfo);const o=i,s=n,a=r;return new Ug(this._smoothstep(o.value,s.value,a.value),r.typeInfo)}Sqrt(e,t){const i=this.exec.evalExpression(e.args[0],t);if(i instanceof Vg)return new Vg(i.data.map(e=>Math.sqrt(e)),i.typeInfo);const n=i;return new Ug(Math.sqrt(n.value),i.typeInfo)}Step(e,t){const i=this.exec.evalExpression(e.args[0],t),n=this.exec.evalExpression(e.args[1],t);if(n instanceof Vg&&i instanceof Vg)return new Vg(n.data.map((e,t)=>eMath.tan(e)),i.typeInfo);const n=i;return new Ug(Math.tan(n.value),i.typeInfo)}Tanh(e,t){const i=this.exec.evalExpression(e.args[0],t);if(i instanceof Vg)return new Vg(i.data.map(e=>Math.tanh(e)),i.typeInfo);const n=i;return new Ug(Math.tanh(n.value),i.typeInfo)}_getTransposeType(e){const t=e.getTypeName();return"mat2x2f"===t||"mat2x2h"===t?e:"mat2x3f"===t?this.getTypeInfo("mat3x2f"):"mat2x3h"===t?this.getTypeInfo("mat3x2h"):"mat2x4f"===t?this.getTypeInfo("mat4x2f"):"mat2x4h"===t?this.getTypeInfo("mat4x2h"):"mat3x2f"===t?this.getTypeInfo("mat2x3f"):"mat3x2h"===t?this.getTypeInfo("mat2x3h"):"mat3x3f"===t||"mat3x3h"===t?e:"mat3x4f"===t?this.getTypeInfo("mat4x3f"):"mat3x4h"===t?this.getTypeInfo("mat4x3h"):"mat4x2f"===t?this.getTypeInfo("mat2x4f"):"mat4x2h"===t?this.getTypeInfo("mat2x4h"):"mat4x3f"===t?this.getTypeInfo("mat3x4f"):"mat4x3h"===t?this.getTypeInfo("mat3x4h"):("mat4x4f"===t||"mat4x4h"===t||console.error(`Invalid matrix type ${t}`),e)}Transpose(e,t){const i=this.exec.evalExpression(e.args[0],t);if(!(i instanceof jg))return console.error(`Transpose() expects a matrix argument. Line ${e.line}`),null;const n=this._getTransposeType(i.typeInfo);if("mat2x2"===i.typeInfo.name||"mat2x2f"===i.typeInfo.name||"mat2x2h"===i.typeInfo.name){const e=i.data;return new jg([e[0],e[2],e[1],e[3]],n)}if("mat2x3"===i.typeInfo.name||"mat2x3f"===i.typeInfo.name||"mat2x3h"===i.typeInfo.name){const e=i.data;return new jg([e[0],e[3],e[6],e[1],e[4],e[7]],n)}if("mat2x4"===i.typeInfo.name||"mat2x4f"===i.typeInfo.name||"mat2x4h"===i.typeInfo.name){const e=i.data;return new jg([e[0],e[4],e[8],e[12],e[1],e[5],e[9],e[13]],n)}if("mat3x2"===i.typeInfo.name||"mat3x2f"===i.typeInfo.name||"mat3x2h"===i.typeInfo.name){const e=i.data;return new jg([e[0],e[3],e[1],e[4],e[2],e[5]],n)}if("mat3x3"===i.typeInfo.name||"mat3x3f"===i.typeInfo.name||"mat3x3h"===i.typeInfo.name){const e=i.data;return new jg([e[0],e[3],e[6],e[1],e[4],e[7],e[2],e[5],e[8]],n)}if("mat3x4"===i.typeInfo.name||"mat3x4f"===i.typeInfo.name||"mat3x4h"===i.typeInfo.name){const e=i.data;return new jg([e[0],e[4],e[8],e[12],e[1],e[5],e[9],e[13],e[2],e[6],e[10],e[14]],n)}if("mat4x2"===i.typeInfo.name||"mat4x2f"===i.typeInfo.name||"mat4x2h"===i.typeInfo.name){const e=i.data;return new jg([e[0],e[4],e[1],e[5],e[2],e[6]],n)}if("mat4x3"===i.typeInfo.name||"mat4x3f"===i.typeInfo.name||"mat4x3h"===i.typeInfo.name){const e=i.data;return new jg([e[0],e[4],e[8],e[1],e[5],e[9],e[2],e[6],e[10]],n)}if("mat4x4"===i.typeInfo.name||"mat4x4f"===i.typeInfo.name||"mat4x4h"===i.typeInfo.name){const e=i.data;return new jg([e[0],e[4],e[8],e[12],e[1],e[5],e[9],e[13],e[2],e[6],e[10],e[14],e[3],e[7],e[11],e[15]],n)}return console.error(`Invalid matrix type ${i.typeInfo.name}`),null}Trunc(e,t){const i=this.exec.evalExpression(e.args[0],t);if(i instanceof Vg)return new Vg(i.data.map(e=>Math.trunc(e)),i.typeInfo);const n=i;return new Ug(Math.trunc(n.value),i.typeInfo)}Dpdx(e,t){return console.error(`TODO: dpdx. Line ${e.line}`),null}DpdxCoarse(e,t){return console.error(`TODO: dpdxCoarse. Line ${e.line}`),null}DpdxFine(e,t){return console.error("TODO: dpdxFine"),null}Dpdy(e,t){return console.error("TODO: dpdy"),null}DpdyCoarse(e,t){return console.error("TODO: dpdyCoarse"),null}DpdyFine(e,t){return console.error("TODO: dpdyFine"),null}Fwidth(e,t){return console.error("TODO: fwidth"),null}FwidthCoarse(e,t){return console.error("TODO: fwidthCoarse"),null}FwidthFine(e,t){return console.error("TODO: fwidthFine"),null}TextureDimensions(e,t){const i=e.args[0],n=e.args.length>1?this.exec.evalExpression(e.args[1],t).value:0;if(i instanceof vg){const r=i.name,o=t.getVariableValue(r);if(o instanceof Hg){if(n<0||n>=o.mipLevelCount)return console.error(`Invalid mip level for textureDimensions. Line ${e.line}`),null;const t=o.getMipLevelSize(n),i=o.dimension;return"1d"===i?new Ug(t[0],this.getTypeInfo("u32")):"3d"===i?new Vg(t,this.getTypeInfo("vec3u")):"2d"===i?new Vg(t.slice(0,2),this.getTypeInfo("vec2u")):(console.error(`Invalid texture dimension ${i} not found. Line ${e.line}`),null)}return console.error(`Texture ${r} not found. Line ${e.line}`),null}return console.error(`Invalid texture argument for textureDimensions. Line ${e.line}`),null}TextureGather(e,t){return console.error("TODO: textureGather"),null}TextureGatherCompare(e,t){return console.error("TODO: textureGatherCompare"),null}TextureLoad(e,t){const i=e.args[0],n=this.exec.evalExpression(e.args[1],t),r=e.args.length>2?this.exec.evalExpression(e.args[2],t).value:0;if(!(n instanceof Vg)||2!==n.data.length)return console.error(`Invalid UV argument for textureLoad. Line ${e.line}`),null;if(i instanceof vg){const o=i.name,s=t.getVariableValue(o);if(s instanceof Hg){const t=Math.floor(n.data[0]),i=Math.floor(n.data[1]);if(t<0||t>=s.width||i<0||i>=s.height)return console.error(`Texture ${o} out of bounds. Line ${e.line}`),null;const a=s.getPixel(t,i,0,r);return null===a?(console.error(`Invalid texture format for textureLoad. Line ${e.line}`),null):new Vg(a,this.getTypeInfo("vec4f"))}return console.error(`Texture ${o} not found. Line ${e.line}`),null}return console.error(`Invalid texture argument for textureLoad. Line ${e.line}`),null}TextureNumLayers(e,t){const i=e.args[0];if(i instanceof vg){const n=i.name,r=t.getVariableValue(n);return r instanceof Hg?new Ug(r.depthOrArrayLayers,this.getTypeInfo("u32")):(console.error(`Texture ${n} not found. Line ${e.line}`),null)}return console.error(`Invalid texture argument for textureNumLayers. Line ${e.line}`),null}TextureNumLevels(e,t){const i=e.args[0];if(i instanceof vg){const n=i.name,r=t.getVariableValue(n);return r instanceof Hg?new Ug(r.mipLevelCount,this.getTypeInfo("u32")):(console.error(`Texture ${n} not found. Line ${e.line}`),null)}return console.error(`Invalid texture argument for textureNumLevels. Line ${e.line}`),null}TextureNumSamples(e,t){const i=e.args[0];if(i instanceof vg){const n=i.name,r=t.getVariableValue(n);return r instanceof Hg?new Ug(r.sampleCount,this.getTypeInfo("u32")):(console.error(`Texture ${n} not found. Line ${e.line}`),null)}return console.error(`Invalid texture argument for textureNumSamples. Line ${e.line}`),null}TextureSample(e,t){return console.error("TODO: textureSample"),null}TextureSampleBias(e,t){return console.error("TODO: textureSampleBias"),null}TextureSampleCompare(e,t){return console.error("TODO: textureSampleCompare"),null}TextureSampleCompareLevel(e,t){return console.error("TODO: textureSampleCompareLevel"),null}TextureSampleGrad(e,t){return console.error("TODO: textureSampleGrad"),null}TextureSampleLevel(e,t){return console.error("TODO: textureSampleLevel"),null}TextureSampleBaseClampToEdge(e,t){return console.error("TODO: textureSampleBaseClampToEdge"),null}TextureStore(e,t){const i=e.args[0],n=this.exec.evalExpression(e.args[1],t),r=4===e.args.length?this.exec.evalExpression(e.args[2],t).value:0,o=4===e.args.length?this.exec.evalExpression(e.args[3],t).data:this.exec.evalExpression(e.args[2],t).data;if(4!==o.length)return console.error(`Invalid value argument for textureStore. Line ${e.line}`),null;if(!(n instanceof Vg)||2!==n.data.length)return console.error(`Invalid UV argument for textureStore. Line ${e.line}`),null;if(i instanceof vg){const s=i.name,a=t.getVariableValue(s);if(a instanceof Hg){const t=a.getMipLevelSize(0),i=Math.floor(n.data[0]),l=Math.floor(n.data[1]);return i<0||i>=t[0]||l<0||l>=t[1]?(console.error(`Texture ${s} out of bounds. Line ${e.line}`),null):(a.setPixel(i,l,0,r,Array.from(o)),null)}return console.error(`Texture ${s} not found. Line ${e.line}`),null}return console.error(`Invalid texture argument for textureStore. Line ${e.line}`),null}AtomicLoad(e,t){let i=e.args[0];i instanceof Cg&&(i=i.right);const n=this.exec.getVariableName(i,t);return t.getVariable(n).value.getSubData(this.exec,i.postfix,t)}AtomicStore(e,t){let i=e.args[0];i instanceof Cg&&(i=i.right);const n=this.exec.getVariableName(i,t),r=t.getVariable(n);let o=e.args[1];const s=this.exec.evalExpression(o,t),a=r.value.getSubData(this.exec,i.postfix,t);return a instanceof Ug&&s instanceof Ug&&(a.value=s.value),r.value instanceof Gg&&r.value.setDataValue(this.exec,a,i.postfix,t),null}AtomicAdd(e,t){let i=e.args[0];i instanceof Cg&&(i=i.right);const n=this.exec.getVariableName(i,t),r=t.getVariable(n);let o=e.args[1];const s=this.exec.evalExpression(o,t),a=r.value.getSubData(this.exec,i.postfix,t),l=new Ug(a.value,a.typeInfo);return a instanceof Ug&&s instanceof Ug&&(a.value+=s.value),r.value instanceof Gg&&r.value.setDataValue(this.exec,a,i.postfix,t),l}AtomicSub(e,t){let i=e.args[0];i instanceof Cg&&(i=i.right);const n=this.exec.getVariableName(i,t),r=t.getVariable(n);let o=e.args[1];const s=this.exec.evalExpression(o,t),a=r.value.getSubData(this.exec,i.postfix,t),l=new Ug(a.value,a.typeInfo);return a instanceof Ug&&s instanceof Ug&&(a.value-=s.value),r.value instanceof Gg&&r.value.setDataValue(this.exec,a,i.postfix,t),l}AtomicMax(e,t){let i=e.args[0];i instanceof Cg&&(i=i.right);const n=this.exec.getVariableName(i,t),r=t.getVariable(n);let o=e.args[1];const s=this.exec.evalExpression(o,t),a=r.value.getSubData(this.exec,i.postfix,t),l=new Ug(a.value,a.typeInfo);return a instanceof Ug&&s instanceof Ug&&(a.value=Math.max(a.value,s.value)),r.value instanceof Gg&&r.value.setDataValue(this.exec,a,i.postfix,t),l}AtomicMin(e,t){let i=e.args[0];i instanceof Cg&&(i=i.right);const n=this.exec.getVariableName(i,t),r=t.getVariable(n);let o=e.args[1];const s=this.exec.evalExpression(o,t),a=r.value.getSubData(this.exec,i.postfix,t),l=new Ug(a.value,a.typeInfo);return a instanceof Ug&&s instanceof Ug&&(a.value=Math.min(a.value,s.value)),r.value instanceof Gg&&r.value.setDataValue(this.exec,a,i.postfix,t),l}AtomicAnd(e,t){let i=e.args[0];i instanceof Cg&&(i=i.right);const n=this.exec.getVariableName(i,t),r=t.getVariable(n);let o=e.args[1];const s=this.exec.evalExpression(o,t),a=r.value.getSubData(this.exec,i.postfix,t),l=new Ug(a.value,a.typeInfo);return a instanceof Ug&&s instanceof Ug&&(a.value=a.value&s.value),r.value instanceof Gg&&r.value.setDataValue(this.exec,a,i.postfix,t),l}AtomicOr(e,t){let i=e.args[0];i instanceof Cg&&(i=i.right);const n=this.exec.getVariableName(i,t),r=t.getVariable(n);let o=e.args[1];const s=this.exec.evalExpression(o,t),a=r.value.getSubData(this.exec,i.postfix,t),l=new Ug(a.value,a.typeInfo);return a instanceof Ug&&s instanceof Ug&&(a.value=a.value|s.value),r.value instanceof Gg&&r.value.setDataValue(this.exec,a,i.postfix,t),l}AtomicXor(e,t){let i=e.args[0];i instanceof Cg&&(i=i.right);const n=this.exec.getVariableName(i,t),r=t.getVariable(n);let o=e.args[1];const s=this.exec.evalExpression(o,t),a=r.value.getSubData(this.exec,i.postfix,t),l=new Ug(a.value,a.typeInfo);return a instanceof Ug&&s instanceof Ug&&(a.value=a.value^s.value),r.value instanceof Gg&&r.value.setDataValue(this.exec,a,i.postfix,t),l}AtomicExchange(e,t){let i=e.args[0];i instanceof Cg&&(i=i.right);const n=this.exec.getVariableName(i,t),r=t.getVariable(n);let o=e.args[1];const s=this.exec.evalExpression(o,t),a=r.value.getSubData(this.exec,i.postfix,t),l=new Ug(a.value,a.typeInfo);return a instanceof Ug&&s instanceof Ug&&(a.value=s.value),r.value instanceof Gg&&r.value.setDataValue(this.exec,a,i.postfix,t),l}AtomicCompareExchangeWeak(e,t){return console.error("TODO: atomicCompareExchangeWeak"),null}Pack4x8snorm(e,t){return console.error("TODO: pack4x8snorm"),null}Pack4x8unorm(e,t){return console.error("TODO: pack4x8unorm"),null}Pack4xI8(e,t){return console.error("TODO: pack4xI8"),null}Pack4xU8(e,t){return console.error("TODO: pack4xU8"),null}Pack4x8Clamp(e,t){return console.error("TODO: pack4x8Clamp"),null}Pack4xU8Clamp(e,t){return console.error("TODO: pack4xU8Clamp"),null}Pack2x16snorm(e,t){return console.error("TODO: pack2x16snorm"),null}Pack2x16unorm(e,t){return console.error("TODO: pack2x16unorm"),null}Pack2x16float(e,t){return console.error("TODO: pack2x16float"),null}Unpack4x8snorm(e,t){return console.error("TODO: unpack4x8snorm"),null}Unpack4x8unorm(e,t){return console.error("TODO: unpack4x8unorm"),null}Unpack4xI8(e,t){return console.error("TODO: unpack4xI8"),null}Unpack4xU8(e,t){return console.error("TODO: unpack4xU8"),null}Unpack2x16snorm(e,t){return console.error("TODO: unpack2x16snorm"),null}Unpack2x16unorm(e,t){return console.error("TODO: unpack2x16unorm"),null}Unpack2x16float(e,t){return console.error("TODO: unpack2x16float"),null}StorageBarrier(e,t){return null}TextureBarrier(e,t){return null}WorkgroupBarrier(e,t){return null}WorkgroupUniformLoad(e,t){return null}SubgroupAdd(e,t){return console.error("TODO: subgroupAdd"),null}SubgroupExclusiveAdd(e,t){return console.error("TODO: subgroupExclusiveAdd"),null}SubgroupInclusiveAdd(e,t){return console.error("TODO: subgroupInclusiveAdd"),null}SubgroupAll(e,t){return console.error("TODO: subgroupAll"),null}SubgroupAnd(e,t){return console.error("TODO: subgroupAnd"),null}SubgroupAny(e,t){return console.error("TODO: subgroupAny"),null}SubgroupBallot(e,t){return console.error("TODO: subgroupBallot"),null}SubgroupBroadcast(e,t){return console.error("TODO: subgroupBroadcast"),null}SubgroupBroadcastFirst(e,t){return console.error("TODO: subgroupBroadcastFirst"),null}SubgroupElect(e,t){return console.error("TODO: subgroupElect"),null}SubgroupMax(e,t){return console.error("TODO: subgroupMax"),null}SubgroupMin(e,t){return console.error("TODO: subgroupMin"),null}SubgroupMul(e,t){return console.error("TODO: subgroupMul"),null}SubgroupExclusiveMul(e,t){return console.error("TODO: subgroupExclusiveMul"),null}SubgroupInclusiveMul(e,t){return console.error("TODO: subgroupInclusiveMul"),null}SubgroupOr(e,t){return console.error("TODO: subgroupOr"),null}SubgroupShuffle(e,t){return console.error("TODO: subgroupShuffle"),null}SubgroupShuffleDown(e,t){return console.error("TODO: subgroupShuffleDown"),null}SubgroupShuffleUp(e,t){return console.error("TODO: subgroupShuffleUp"),null}SubgroupShuffleXor(e,t){return console.error("TODO: subgroupShuffleXor"),null}SubgroupXor(e,t){return console.error("TODO: subgroupXor"),null}QuadBroadcast(e,t){return console.error("TODO: quadBroadcast"),null}QuadSwapDiagonal(e,t){return console.error("TODO: quadSwapDiagonal"),null}QuadSwapX(e,t){return console.error("TODO: quadSwapX"),null}QuadSwapY(e,t){return console.error("TODO: quadSwapY"),null}}const m_={vec2:2,vec2f:2,vec2i:2,vec2u:2,vec2b:2,vec2h:2,vec3:3,vec3f:3,vec3i:3,vec3u:3,vec3b:3,vec3h:3,vec4:4,vec4f:4,vec4i:4,vec4u:4,vec4b:4,vec4h:4},g_={mat2x2:[2,2,4],mat2x2f:[2,2,4],mat2x2h:[2,2,4],mat2x3:[2,3,6],mat2x3f:[2,3,6],mat2x3h:[2,3,6],mat2x4:[2,4,8],mat2x4f:[2,4,8],mat2x4h:[2,4,8],mat3x2:[3,2,6],mat3x2f:[3,2,6],mat3x2h:[3,2,6],mat3x3:[3,3,9],mat3x3f:[3,3,9],mat3x3h:[3,3,9],mat3x4:[3,4,12],mat3x4f:[3,4,12],mat3x4h:[3,4,12],mat4x2:[4,2,8],mat4x2f:[4,2,8],mat4x2h:[4,2,8],mat4x3:[4,3,12],mat4x3f:[4,3,12],mat4x3h:[4,3,12],mat4x4:[4,4,16],mat4x4f:[4,4,16],mat4x4h:[4,4,16]};class __ extends p_{constructor(e,t){var i;super(),this.ast=null!=e?e:[],this.reflection=new l_,this.reflection.updateAST(this.ast),this.context=null!==(i=null==t?void 0:t.clone())&&void 0!==i?i:new d_,this.builtins=new f_(this),this.typeInfo={bool:this.getTypeInfo(cg.bool),i32:this.getTypeInfo(cg.i32),u32:this.getTypeInfo(cg.u32),f32:this.getTypeInfo(cg.f32),f16:this.getTypeInfo(cg.f16),vec2f:this.getTypeInfo(dg.vec2f),vec2u:this.getTypeInfo(dg.vec2u),vec2i:this.getTypeInfo(dg.vec2i),vec2h:this.getTypeInfo(dg.vec2h),vec3f:this.getTypeInfo(dg.vec3f),vec3u:this.getTypeInfo(dg.vec3u),vec3i:this.getTypeInfo(dg.vec3i),vec3h:this.getTypeInfo(dg.vec3h),vec4f:this.getTypeInfo(dg.vec4f),vec4u:this.getTypeInfo(dg.vec4u),vec4i:this.getTypeInfo(dg.vec4i),vec4h:this.getTypeInfo(dg.vec4h),mat2x2f:this.getTypeInfo(dg.mat2x2f),mat2x3f:this.getTypeInfo(dg.mat2x3f),mat2x4f:this.getTypeInfo(dg.mat2x4f),mat3x2f:this.getTypeInfo(dg.mat3x2f),mat3x3f:this.getTypeInfo(dg.mat3x3f),mat3x4f:this.getTypeInfo(dg.mat3x4f),mat4x2f:this.getTypeInfo(dg.mat4x2f),mat4x3f:this.getTypeInfo(dg.mat4x3f),mat4x4f:this.getTypeInfo(dg.mat4x4f)}}getVariableValue(e){var t,i;const n=null!==(i=null===(t=this.context.getVariable(e))||void 0===t?void 0:t.value)&&void 0!==i?i:null;if(null===n)return null;if(n instanceof Ug)return n.value;if(n instanceof Vg)return Array.from(n.data);if(n instanceof jg)return Array.from(n.data);if(n instanceof Gg&&n.typeInfo instanceof lm){if("u32"===n.typeInfo.format.name)return Array.from(new Uint32Array(n.buffer,n.offset,n.typeInfo.count));if("i32"===n.typeInfo.format.name)return Array.from(new Int32Array(n.buffer,n.offset,n.typeInfo.count));if("f32"===n.typeInfo.format.name)return Array.from(new Float32Array(n.buffer,n.offset,n.typeInfo.count))}return console.error(`Unsupported return variable type ${n.typeInfo.name}`),null}execute(e){(e=null!=e?e:{}).constants&&this._setOverrides(e.constants,this.context),this._execStatements(this.ast,this.context)}dispatchWorkgroups(e,t,i,n){const r=this.context.clone();(n=null!=n?n:{}).constants&&this._setOverrides(n.constants,r),this._execStatements(this.ast,r);const o=r.getFunction(e);if(!o)return void console.error(`Function ${e} not found`);if("number"==typeof t)t=[t,1,1];else{if(0===t.length)return void console.error("Invalid dispatch count");1===t.length?t=[t[0],1,1]:2===t.length?t=[t[0],t[1],1]:t.length>3&&(t=[t[0],t[1],t[2]])}const s=t[0],a=t[1],l=t[2],c=this.getTypeInfo("vec3u");r.setVariable("@num_workgroups",new Vg(t,c));const u=this.reflection.getFunctionInfo(e);null===u&&console.error(`Function ${e} not found in reflection data`);for(const e in i)for(const t in i[e]){const n=i[e][t];r.variables.forEach(i=>{var r;const o=i.node;if(null==o?void 0:o.attributes){let s=null,a=null;for(const e of o.attributes)"binding"===e.name?s=e.value:"group"===e.name&&(a=e.value);if(t==s&&e==a){let s=!1;for(const n of u.resources)if(n.name===i.name&&n.group===parseInt(e)&&n.binding===parseInt(t)){s=!0;break}if(s)if(void 0!==n.texture&&void 0!==n.descriptor){const e=new Hg(n.texture,this.getTypeInfo(o.type),n.descriptor,null!==(r=n.texture.view)&&void 0!==r?r:null);i.value=e}else void 0!==n.uniform?i.value=new Gg(n.uniform,this.getTypeInfo(o.type)):i.value=new Gg(n,this.getTypeInfo(o.type))}}})}for(let e=0;e0){const e=i.getVariableValue(t.value[0]);n[0]=e instanceof Ug?e.value:parseInt(t.value[0])}if(t.value.length>1){const e=i.getVariableValue(t.value[1]);n[1]=e instanceof Ug?e.value:parseInt(t.value[1])}if(t.value.length>2){const e=i.getVariableValue(t.value[2]);n[2]=e instanceof Ug?e.value:parseInt(t.value[2])}}const r=this.getTypeInfo("vec3u"),o=this.getTypeInfo("u32");i.setVariable("@workgroup_size",new Vg(n,r));const s=n[0],a=n[1],l=n[2];for(let c=0,u=0;c",r=null;if(e.variable instanceof Cg){const i=this._getVariableData(e.variable,t),n=this.evalExpression(e.value,t),r=e.operator;if("="===r){if(i instanceof Ug||i instanceof Vg||i instanceof jg){if(n instanceof Ug||n instanceof Vg||n instanceof jg&&i.data.length===n.data.length)return void i.data.set(n.data);console.error(`Invalid assignment. Line ${e.line}`)}else if(i instanceof Gg&&n instanceof Gg&&i.buffer.byteLength-i.offset>=n.buffer.byteLength-n.offset)return void(i.buffer.byteLength%4==0?new Uint32Array(i.buffer,i.offset,i.typeInfo.size/4).set(new Uint32Array(n.buffer,n.offset,n.typeInfo.size/4)):new Uint8Array(i.buffer,i.offset,i.typeInfo.size).set(new Uint8Array(n.buffer,n.offset,n.typeInfo.size)));return console.error(`Invalid assignment. Line ${e.line}`),null}if("+="===r)return i instanceof Ug||i instanceof Vg||i instanceof jg?n instanceof Ug||n instanceof Vg||n instanceof jg?void i.data.set(n.data.map((e,t)=>i.data[t]+e)):void console.error(`Invalid assignment . Line ${e.line}`):void console.error(`Invalid assignment. Line ${e.line}`);if("-="===r)return(i instanceof Ug||i instanceof Vg||i instanceof jg)&&(n instanceof Ug||n instanceof Vg||n instanceof jg)?void i.data.set(n.data.map((e,t)=>i.data[t]-e)):void console.error(`Invalid assignment. Line ${e.line}`)}if(e.variable instanceof Cg){if("*"===e.variable.operator){n=this.getVariableName(e.variable.right,t);const r=t.getVariable(n);if(!(r&&r.value instanceof zg))return void console.error(`Variable ${n} is not a pointer. Line ${e.line}`);i=r.value.reference;let o=e.variable.postfix;if(!o){let t=e.variable.right;for(;t instanceof Cg;){if(t.postfix){o=t.postfix;break}t=t.right}}o&&(i=i.getSubData(this,o,t))}}else{r=e.variable.postfix,n=this.getVariableName(e.variable,t);const o=t.getVariable(n);if(null===o)return void console.error(`Variable ${n} not found. Line ${e.line}`);i=o.value}if(i instanceof zg&&(i=i.reference),null===i)return void console.error(`Variable ${n} not found. Line ${e.line}`);const o=this.evalExpression(e.value,t),s=e.operator;if("="!==s){const n=i.getSubData(this,r,t);if(n instanceof Vg&&o instanceof Ug){const t=n.data,i=o.value;if("+="===s)for(let e=0;e>="===s)for(let e=0;e>=i;else console.error(`Invalid operator ${s}. Line ${e.line}`)}else if(n instanceof Vg&&o instanceof Vg){const t=n.data,i=o.data;if(t.length!==i.length)return void console.error(`Vector length mismatch. Line ${e.line}`);if("+="===s)for(let e=0;e>="===s)for(let e=0;e>=i[e];else console.error(`Invalid operator ${s}. Line ${e.line}`)}else{if(!(n instanceof Ug&&o instanceof Ug))return void console.error(`Invalid type for ${e.operator} operator. Line ${e.line}`);"+="===s?n.value+=o.value:"-="===s?n.value-=o.value:"*="===s?n.value*=o.value:"/="===s?n.value/=o.value:"%="===s?n.value%=o.value:"&="===s?n.value&=o.value:"|="===s?n.value|=o.value:"^="===s?n.value^=o.value:"<<="===s?n.value<<=o.value:">>="===s?n.value>>=o.value:console.error(`Invalid operator ${s}. Line ${e.line}`)}return void(i instanceof Gg&&i.setDataValue(this,n,r,t))}if(i instanceof Gg)i.setDataValue(this,o,r,t);else if(r){if(!(i instanceof Vg||i instanceof jg))return void console.error(`Variable ${n} is not a vector or matrix. Line ${e.line}`);if(r instanceof Tg){const s=this.evalExpression(r.index,t).value;if(i instanceof Vg){if(!(o instanceof Ug))return void console.error(`Invalid assignment to ${n}. Line ${e.line}`);i.data[s]=o.value}else{if(!(i instanceof jg))return void console.error(`Invalid assignment to ${n}. Line ${e.line}`);{const s=this.evalExpression(r.index,t).value;if(s<0)return void console.error(`Invalid assignment to ${n}. Line ${e.line}`);if(!(o instanceof Vg))return void console.error(`Invalid assignment to ${n}. Line ${e.line}`);{const t=i.typeInfo.getTypeName();if("mat2x2"===t||"mat2x2f"===t||"mat2x2h"===t){if(!(s<2&&2===o.data.length))return void console.error(`Invalid assignment to ${n}. Line ${e.line}`);i.data[2*s]=o.data[0],i.data[2*s+1]=o.data[1]}else if("mat2x3"===t||"mat2x3f"===t||"mat2x3h"===t){if(!(s<2&&3===o.data.length))return void console.error(`Invalid assignment to ${n}. Line ${e.line}`);i.data[3*s]=o.data[0],i.data[3*s+1]=o.data[1],i.data[3*s+2]=o.data[2]}else if("mat2x4"===t||"mat2x4f"===t||"mat2x4h"===t){if(!(s<2&&4===o.data.length))return void console.error(`Invalid assignment to ${n}. Line ${e.line}`);i.data[4*s]=o.data[0],i.data[4*s+1]=o.data[1],i.data[4*s+2]=o.data[2],i.data[4*s+3]=o.data[3]}else if("mat3x2"===t||"mat3x2f"===t||"mat3x2h"===t){if(!(s<3&&2===o.data.length))return void console.error(`Invalid assignment to ${n}. Line ${e.line}`);i.data[2*s]=o.data[0],i.data[2*s+1]=o.data[1]}else if("mat3x3"===t||"mat3x3f"===t||"mat3x3h"===t){if(!(s<3&&3===o.data.length))return void console.error(`Invalid assignment to ${n}. Line ${e.line}`);i.data[3*s]=o.data[0],i.data[3*s+1]=o.data[1],i.data[3*s+2]=o.data[2]}else if("mat3x4"===t||"mat3x4f"===t||"mat3x4h"===t){if(!(s<3&&4===o.data.length))return void console.error(`Invalid assignment to ${n}. Line ${e.line}`);i.data[4*s]=o.data[0],i.data[4*s+1]=o.data[1],i.data[4*s+2]=o.data[2],i.data[4*s+3]=o.data[3]}else if("mat4x2"===t||"mat4x2f"===t||"mat4x2h"===t){if(!(s<4&&2===o.data.length))return void console.error(`Invalid assignment to ${n}. Line ${e.line}`);i.data[2*s]=o.data[0],i.data[2*s+1]=o.data[1]}else if("mat4x3"===t||"mat4x3f"===t||"mat4x3h"===t){if(!(s<4&&3===o.data.length))return void console.error(`Invalid assignment to ${n}. Line ${e.line}`);i.data[3*s]=o.data[0],i.data[3*s+1]=o.data[1],i.data[3*s+2]=o.data[2]}else{if("mat4x4"!==t&&"mat4x4f"!==t&&"mat4x4h"!==t)return void console.error(`Invalid assignment to ${n}. Line ${e.line}`);if(!(s<4&&4===o.data.length))return void console.error(`Invalid assignment to ${n}. Line ${e.line}`);i.data[4*s]=o.data[0],i.data[4*s+1]=o.data[1],i.data[4*s+2]=o.data[2],i.data[4*s+3]=o.data[3]}}}}}else if(r instanceof _g){const t=r.value;if(!(i instanceof Vg))return void console.error(`Invalid assignment to ${t}. Variable ${n} is not a vector. Line ${e.line}`);if(o instanceof Ug){if(t.length>1)return void console.error(`Invalid assignment to ${t} for variable ${n}. Line ${e.line}`);if("x"===t)i.data[0]=o.value;else if("y"===t){if(i.data.length<2)return void console.error(`Invalid assignment to ${t} for variable ${n}. Line ${e.line}`);i.data[1]=o.value}else if("z"===t){if(i.data.length<3)return void console.error(`Invalid assignment to ${t} for variable ${n}. Line ${e.line}`);i.data[2]=o.value}else if("w"===t){if(i.data.length<4)return void console.error(`Invalid assignment to ${t} for variable ${n}. Line ${e.line}`);i.data[3]=o.value}}else{if(!(o instanceof Vg))return void console.error(`Invalid assignment to ${n}. Line ${e.line}`);if(t.length!==o.data.length)return void console.error(`Invalid assignment to ${t} for variable ${n}. Line ${e.line}`);for(let r=0;r+e);return new Vg(e,i.typeInfo)}const e=n,t=this._maxFormatTypeInfo([i.typeInfo,i.typeInfo]);return new Ug(+e,t)}case"-":{if(qg(n)){const e=n.map((e,t)=>-e);return new Vg(e,i.typeInfo)}const e=n,t=this._maxFormatTypeInfo([i.typeInfo,i.typeInfo]);return new Ug(-e,t)}case"!":{if(qg(n)){const e=n.map((e,t)=>e?0:1);return new Vg(e,i.typeInfo)}const e=n,t=this._maxFormatTypeInfo([i.typeInfo,i.typeInfo]);return new Ug(e?0:1,t)}case"~":{if(qg(n)){const e=n.map((e,t)=>~e);return new Vg(e,i.typeInfo)}const e=n,t=this._maxFormatTypeInfo([i.typeInfo,i.typeInfo]);return new Ug(~e,t)}}return console.error(`Invalid unary operator ${e.operator}. Line ${e.line}`),null}_evalBinaryOp(e,t){const i=this.evalExpression(e.left,t),n=this.evalExpression(e.right,t),r=i instanceof Ug?i.value:i instanceof Vg||i instanceof jg?Array.from(i.data):null,o=n instanceof Ug?n.value:n instanceof Vg||n instanceof jg?Array.from(n.data):null;switch(e.operator){case"+":{if(qg(r)&&qg(o)){const t=r,n=o;if(t.length!==n.length)return console.error(`Vector length mismatch. Line ${e.line}.`),null;const s=t.map((e,t)=>e+n[t]);return new Vg(s,i.typeInfo)}if(qg(r)){const e=o,t=r.map((t,i)=>t+e);return new Vg(t,i.typeInfo)}if(qg(o)){const e=r,t=o.map((t,i)=>e+t);return new Vg(t,n.typeInfo)}const t=r,s=o,a=this._maxFormatTypeInfo([i.typeInfo,n.typeInfo]);return new Ug(t+s,a)}case"-":{if(qg(r)&&qg(o)){const t=r,n=o;if(t.length!==n.length)return console.error(`Vector length mismatch. Line ${e.line}.`),null;const s=t.map((e,t)=>e-n[t]);return new Vg(s,i.typeInfo)}if(qg(r)){const e=o,t=r.map((t,i)=>t-e);return new Vg(t,i.typeInfo)}if(qg(o)){const e=r,t=o.map((t,i)=>e-t);return new Vg(t,n.typeInfo)}const t=r,s=o,a=this._maxFormatTypeInfo([i.typeInfo,n.typeInfo]);return new Ug(t-s,a)}case"*":{if(qg(r)&&qg(o)){const t=r,s=o;if(i instanceof jg&&n instanceof jg){const r=function(e,t,i,n){if(void 0===g_[t.name]||void 0===g_[n.name])return null;const r=g_[t.name][0],o=g_[t.name][1],s=g_[n.name][0];if(r!==g_[n.name][1])return null;const a=new Array(s*o);for(let t=0;te*s[t]);return new Vg(n,i.typeInfo)}}if(qg(r)){const e=o,t=r.map((t,i)=>t*e);return i instanceof jg?new jg(t,i.typeInfo):new Vg(t,i.typeInfo)}if(qg(o)){const e=r,t=o.map((t,i)=>e*t);return n instanceof jg?new jg(t,n.typeInfo):new Vg(t,n.typeInfo)}const t=r,s=o,a=this._maxFormatTypeInfo([i.typeInfo,n.typeInfo]);return new Ug(t*s,a)}case"%":{if(qg(r)&&qg(o)){const t=r,n=o;if(t.length!==n.length)return console.error(`Vector length mismatch. Line ${e.line}.`),null;const s=t.map((e,t)=>e%n[t]);return new Vg(s,i.typeInfo)}if(qg(r)){const e=o,t=r.map((t,i)=>t%e);return new Vg(t,i.typeInfo)}if(qg(o)){const e=r,t=o.map((t,i)=>e%t);return new Vg(t,n.typeInfo)}const t=r,s=o,a=this._maxFormatTypeInfo([i.typeInfo,n.typeInfo]);return new Ug(t%s,a)}case"/":{if(qg(r)&&qg(o)){const t=r,n=o;if(t.length!==n.length)return console.error(`Vector length mismatch. Line ${e.line}.`),null;const s=t.map((e,t)=>e/n[t]);return new Vg(s,i.typeInfo)}if(qg(r)){const e=o,t=r.map((t,i)=>t/e);return new Vg(t,i.typeInfo)}if(qg(o)){const e=r,t=o.map((t,i)=>e/t);return new Vg(t,n.typeInfo)}const t=r,s=o,a=this._maxFormatTypeInfo([i.typeInfo,n.typeInfo]);return new Ug(t/s,a)}case"&":{if(qg(r)&&qg(o)){const t=r,n=o;if(t.length!==n.length)return console.error(`Vector length mismatch. Line ${e.line}.`),null;const s=t.map((e,t)=>e&n[t]);return new Vg(s,i.typeInfo)}if(qg(r)){const e=o,t=r.map((t,i)=>t&e);return new Vg(t,i.typeInfo)}if(qg(o)){const e=r,t=o.map((t,i)=>e&t);return new Vg(t,n.typeInfo)}const t=r,s=o,a=this._maxFormatTypeInfo([i.typeInfo,n.typeInfo]);return new Ug(t&s,a)}case"|":{if(qg(r)&&qg(o)){const t=r,n=o;if(t.length!==n.length)return console.error(`Vector length mismatch. Line ${e.line}.`),null;const s=t.map((e,t)=>e|n[t]);return new Vg(s,i.typeInfo)}if(qg(r)){const e=o,t=r.map((t,i)=>t|e);return new Vg(t,i.typeInfo)}if(qg(o)){const e=r,t=o.map((t,i)=>e|t);return new Vg(t,n.typeInfo)}const t=r,s=o,a=this._maxFormatTypeInfo([i.typeInfo,n.typeInfo]);return new Ug(t|s,a)}case"^":{if(qg(r)&&qg(o)){const t=r,n=o;if(t.length!==n.length)return console.error(`Vector length mismatch. Line ${e.line}.`),null;const s=t.map((e,t)=>e^n[t]);return new Vg(s,i.typeInfo)}if(qg(r)){const e=o,t=r.map((t,i)=>t^e);return new Vg(t,i.typeInfo)}if(qg(o)){const e=r,t=o.map((t,i)=>e^t);return new Vg(t,n.typeInfo)}const t=r,s=o,a=this._maxFormatTypeInfo([i.typeInfo,n.typeInfo]);return new Ug(t^s,a)}case"<<":{if(qg(r)&&qg(o)){const t=r,n=o;if(t.length!==n.length)return console.error(`Vector length mismatch. Line ${e.line}.`),null;const s=t.map((e,t)=>e<t<e<>":{if(qg(r)&&qg(o)){const t=r,n=o;if(t.length!==n.length)return console.error(`Vector length mismatch. Line ${e.line}.`),null;const s=t.map((e,t)=>e>>n[t]);return new Vg(s,i.typeInfo)}if(qg(r)){const e=o,t=r.map((t,i)=>t>>e);return new Vg(t,i.typeInfo)}if(qg(o)){const e=r,t=o.map((t,i)=>e>>t);return new Vg(t,n.typeInfo)}const t=r,s=o,a=this._maxFormatTypeInfo([i.typeInfo,n.typeInfo]);return new Ug(t>>s,a)}case">":if(qg(r)&&qg(o)){const t=r,n=o;if(t.length!==n.length)return console.error(`Vector length mismatch. Line ${e.line}.`),null;const s=t.map((e,t)=>e>n[t]?1:0);return new Vg(s,i.typeInfo)}if(qg(r)){const e=o,t=r.map((t,i)=>t>e?1:0);return new Vg(t,i.typeInfo)}if(qg(o)){const e=r,t=o.map((t,i)=>e>t?1:0);return new Vg(t,n.typeInfo)}return new Ug(r>o?1:0,this.getTypeInfo("bool"));case"<":if(qg(r)&&qg(o)){const t=r,n=o;if(t.length!==n.length)return console.error(`Vector length mismatch. Line ${e.line}.`),null;const s=t.map((e,t)=>etee===n[t]?1:0);return new Vg(s,i.typeInfo)}if(qg(r)){const e=o,t=r.map((t,i)=>t==e?1:0);return new Vg(t,i.typeInfo)}if(qg(o)){const e=r,t=o.map((t,i)=>e==t?1:0);return new Vg(t,n.typeInfo)}return new Ug(r===o?1:0,this.getTypeInfo("bool"));case"!=":if(qg(r)&&qg(o)){const t=r,n=o;if(t.length!==n.length)return console.error(`Vector length mismatch. Line ${e.line}.`),null;const s=t.map((e,t)=>e!==n[t]?1:0);return new Vg(s,i.typeInfo)}if(qg(r)){const e=o,t=r.map((t,i)=>t!==e?1:0);return new Vg(t,i.typeInfo)}if(qg(o)){const e=r,t=o.map((t,i)=>e!==t?1:0);return new Vg(t,n.typeInfo)}return new Ug(r!==o?1:0,this.getTypeInfo("bool"));case">=":if(qg(r)&&qg(o)){const t=r,n=o;if(t.length!==n.length)return console.error(`Vector length mismatch. Line ${e.line}.`),null;const s=t.map((e,t)=>e>=n[t]?1:0);return new Vg(s,i.typeInfo)}if(qg(r)){const e=o,t=r.map((t,i)=>t>=e?1:0);return new Vg(t,i.typeInfo)}if(qg(o)){const e=r,t=o.map((t,i)=>e>=t?1:0);return new Vg(t,n.typeInfo)}return new Ug(r>=o?1:0,this.getTypeInfo("bool"));case"<=":if(qg(r)&&qg(o)){const t=r,n=o;if(t.length!==n.length)return console.error(`Vector length mismatch. Line ${e.line}.`),null;const s=t.map((e,t)=>e<=n[t]?1:0);return new Vg(s,i.typeInfo)}if(qg(r)){const e=o,t=r.map((t,i)=>t<=e?1:0);return new Vg(t,i.typeInfo)}if(qg(o)){const e=r,t=o.map((t,i)=>e<=t?1:0);return new Vg(t,n.typeInfo)}return new Ug(r<=o?1:0,this.getTypeInfo("bool"));case"&&":if(qg(r)&&qg(o)){const t=r,n=o;if(t.length!==n.length)return console.error(`Vector length mismatch. Line ${e.line}.`),null;const s=t.map((e,t)=>e&&n[t]?1:0);return new Vg(s,i.typeInfo)}if(qg(r)){const e=o,t=r.map((t,i)=>t&&e?1:0);return new Vg(t,i.typeInfo)}if(qg(o)){const e=r,t=o.map((t,i)=>e&&t?1:0);return new Vg(t,n.typeInfo)}return new Ug(r&&o?1:0,this.getTypeInfo("bool"));case"||":if(qg(r)&&qg(o)){const t=r,n=o;if(t.length!==n.length)return console.error(`Vector length mismatch. Line ${e.line}.`),null;const s=t.map((e,t)=>e||n[t]?1:0);return new Vg(s,i.typeInfo)}if(qg(r)){const e=o,t=r.map((t,i)=>t||e?1:0);return new Vg(t,i.typeInfo)}if(qg(o)){const e=r,t=o.map((t,i)=>e||t?1:0);return new Vg(t,n.typeInfo)}return new Ug(r||o?1:0,this.getTypeInfo("bool"))}return console.error(`Unknown operator ${e.operator}. Line ${e.line}`),null}_evalCall(e,t){if(null!==e.cachedReturnValue)return e.cachedReturnValue;const i=t.clone();i.currentFunctionName=e.name;const n=t.getFunction(e.name);if(!n)return e.isBuiltin?this._callBuiltinFunction(e,i):this.getTypeInfo(e.name)?this._evalCreate(e,t):(console.error(`Unknown function "${e.name}". Line ${e.line}`),null);for(let t=0;tr?o.slice(0,r):o,i).getSubData(this,e.postfix,t)}_callConstructorMatrix(e,t){const i=this.getTypeInfo(e.type),n=e.type.getTypeName(),r=g_[n];if(void 0===r)return console.error(`Invalid matrix constructor ${n}. Line ${e.line}`),null;const o=[];if(e instanceof bg)if(e.isVector){const t=e.vectorValue;for(const e of t)o.push(e)}else o.push(e.scalarValue);else if(e.args)for(const i of e.args){const e=this.evalExpression(i,t);e instanceof Vg?o.push(...e.data):e instanceof Ug?o.push(e.value):e instanceof jg&&o.push(...e.data)}if(i instanceof um&&null===i.format&&(i.format=this.getTypeInfo("f32")),0===o.length){const n=new Array(r[2]).fill(0);return new jg(n,i).getSubData(this,e.postfix,t)}return o.length!==r[2]?(console.error(`Invalid matrix constructor. Line ${e.line}`),null):new jg(o,i).getSubData(this,e.postfix,t)}}__._breakObj=new Dg(new om("BREAK",null),null),__._continueObj=new Dg(new om("CONTINUE",null),null),__._priority=new Map([["f32",0],["f16",1],["u32",2],["i32",3],["x32",3]]);class A_{constructor(){this.constants=new Map,this.aliases=new Map,this.structs=new Map}}class y_{constructor(){this._tokens=[],this._current=0,this._currentLine=1,this._deferArrayCountEval=[],this._currentLoop=[],this._context=new A_,this._exec=new __,this._forwardTypeCount=0}parse(e){this._initialize(e),this._deferArrayCountEval.length=0;const t=[];for(;!this._isAtEnd();){const e=this._global_decl_or_directive();if(!e)break;t.push(e)}if(this._deferArrayCountEval.length>0){for(const t of this._deferArrayCountEval){const i=t.arrayType,n=t.countNode;if(n instanceof vg){const t=n.name,r=this._context.constants.get(t);if(r)try{const e=r.constEvaluate(this._exec);i.count=e}catch(e){}}}this._deferArrayCountEval.length=0}if(this._forwardTypeCount>0)for(const e of t)e.search(e=>{e instanceof Fg||e instanceof pg?e.type=this._forwardType(e.type):e instanceof fg?e.format=this._forwardType(e.format):e instanceof Vm||e instanceof Gm||e instanceof Hm?e.type=this._forwardType(e.type):e instanceof Dm?e.returnType=this._forwardType(e.returnType):e instanceof Rg&&(e.type=this._forwardType(e.type))});return t}_forwardType(e){if(e instanceof ug){const t=this._getType(e.name);if(t)return t}else e instanceof pg?e.type=this._forwardType(e.type):e instanceof fg&&(e.format=this._forwardType(e.format));return e}_initialize(e){if(e)if("string"==typeof e){const t=new Wg(e);this._tokens=t.scanTokens()}else this._tokens=e;else this._tokens=[];this._current=0}_updateNode(e,t){return e.line=null!=t?t:this._currentLine,e}_error(e,t){return{token:e,message:t,toString:()=>`${t}`}}_isAtEnd(){return this._current>=this._tokens.length||this._peek().type==$g.eof}_match(e){if(e instanceof Qg)return!!this._check(e)&&(this._advance(),!0);for(let t=0,i=e.length;t0){const e=this._currentLoop[this._currentLoop.length-1];t.loopId=e.id}e=t,this._check($g.keywords.if)&&(this._advance(),t.condition=this._optional_paren_expression())}else if(this._match($g.keywords.continue)){const t=this._updateNode(new lg);if(!(this._currentLoop.length>0))throw this._error(this._peek(),`Continue statement must be inside a loop. Line: ${t.line}`);{const e=this._currentLoop[this._currentLoop.length-1];t.loopId=e.id}e=t}else e=this._increment_decrement_statement()||this._func_call_statement()||this._assignment_statement();return null!=e&&this._consume($g.tokens.semicolon,"Expected ';' after statement."),e}_static_assert_statement(){if(!this._match($g.keywords.static_assert))return null;const e=this._currentLine,t=this._optional_paren_expression();return this._updateNode(new Om(t),e)}_while_statement(){if(!this._match($g.keywords.while))return null;const e=this._updateNode(new zm(null,null));return this._currentLoop.push(e),e.condition=this._optional_paren_expression(),this._check($g.tokens.attr)&&this._attribute(),e.body=this._compound_statement(),this._currentLoop.pop(),e}_continuing_statement(){const e=this._currentLoop.length>0?this._currentLoop[this._currentLoop.length-1].id:-1;if(!this._match($g.keywords.continuing))return null;const t=this._currentLine,i=this._compound_statement();return this._updateNode(new Um(i,e),t)}_for_statement(){if(!this._match($g.keywords.for))return null;this._consume($g.tokens.paren_left,"Expected '('.");const e=this._updateNode(new Nm(null,null,null,null));return this._currentLoop.push(e),e.init=this._check($g.tokens.semicolon)?null:this._for_init(),this._consume($g.tokens.semicolon,"Expected ';'."),e.condition=this._check($g.tokens.semicolon)?null:this._short_circuit_or_expression(),this._consume($g.tokens.semicolon,"Expected ';'."),e.increment=this._check($g.tokens.paren_right)?null:this._for_increment(),this._consume($g.tokens.paren_right,"Expected ')'."),this._check($g.tokens.attr)&&this._attribute(),e.body=this._compound_statement(),this._currentLoop.pop(),e}_for_init(){return this._variable_statement()||this._func_call_statement()||this._assignment_statement()}_for_increment(){return this._func_call_statement()||this._increment_decrement_statement()||this._assignment_statement()}_variable_statement(){if(this._check($g.keywords.var)){const e=this._variable_decl();if(null===e)throw this._error(this._peek(),"Variable declaration expected.");let t=null;return this._match($g.tokens.equal)&&(t=this._short_circuit_or_expression()),this._updateNode(new Vm(e.name,e.type,e.storage,e.access,t),e.line)}if(this._match($g.keywords.let)){const e=this._currentLine,t=this._consume($g.tokens.name,"Expected name for let.").toString();let i=null;if(this._match($g.tokens.colon)){const e=this._attribute();i=this._type_decl(),null!=i&&(i.attributes=e)}this._consume($g.tokens.equal,"Expected '=' for let.");const n=this._short_circuit_or_expression();return this._updateNode(new Gm(t,i,null,null,n),e)}if(this._match($g.keywords.const)){const e=this._currentLine,t=this._consume($g.tokens.name,"Expected name for const.").toString();let i=null;if(this._match($g.tokens.colon)){const e=this._attribute();i=this._type_decl(),null!=i&&(i.attributes=e)}this._consume($g.tokens.equal,"Expected '=' for const.");const n=this._short_circuit_or_expression();return null===i&&n instanceof bg&&(i=n.type),this._updateNode(new Hm(t,i,null,null,n),e)}return null}_increment_decrement_statement(){const e=this._current,t=this._unary_expression();if(null==t)return null;if(!this._check($g.increment_operators))return this._current=e,null;const i=this._consume($g.increment_operators,"Expected increment operator");return this._updateNode(new qm(i.type===$g.tokens.plus_plus?Qm.increment:Qm.decrement,t))}_assignment_statement(){let e=null;const t=this._currentLine;if(this._check($g.tokens.brace_right))return null;let i=this._match($g.tokens.underscore);if(i||(e=this._unary_expression()),!i&&null==e)return null;const n=this._consume($g.assignment_operators,"Expected assignment operator."),r=this._short_circuit_or_expression();return this._updateNode(new Km($m.parse(n.lexeme),e,r),t)}_func_call_statement(){if(!this._check($g.tokens.ident))return null;const e=this._currentLine,t=this._current,i=this._consume($g.tokens.ident,"Expected function name."),n=this._argument_expression_list();return null===n?(this._current=t,null):this._updateNode(new Xm(i.lexeme,n),e)}_loop_statement(){if(!this._match($g.keywords.loop))return null;this._check($g.tokens.attr)&&this._attribute(),this._consume($g.tokens.brace_left,"Expected '{' for loop.");const e=this._updateNode(new Jm([],null));this._currentLoop.push(e);let t=this._statement();for(;null!==t;){if(Array.isArray(t))for(let i of t)e.body.push(i);else e.body.push(t);if(t instanceof Um){e.continuing=t;break}t=this._statement()}return this._currentLoop.pop(),this._consume($g.tokens.brace_right,"Expected '}' for loop."),e}_switch_statement(){if(!this._match($g.keywords.switch))return null;const e=this._updateNode(new Ym(null,[]));if(this._currentLoop.push(e),e.condition=this._optional_paren_expression(),this._check($g.tokens.attr)&&this._attribute(),this._consume($g.tokens.brace_left,"Expected '{' for switch."),e.cases=this._switch_body(),null==e.cases||0==e.cases.length)throw this._error(this._previous(),"Expected 'case' or 'default'.");return this._consume($g.tokens.brace_right,"Expected '}' for switch."),this._currentLoop.pop(),e}_switch_body(){const e=[];let t=!1;for(;this._check([$g.keywords.default,$g.keywords.case]);){if(this._match($g.keywords.case)){const i=this._case_selectors();for(const e of i)if(e instanceof Ig){if(t)throw this._error(this._previous(),"Multiple default cases in switch statement.");t=!0;break}this._match($g.tokens.colon),this._check($g.tokens.attr)&&this._attribute(),this._consume($g.tokens.brace_left,"Exected '{' for switch case.");const n=this._case_body();this._consume($g.tokens.brace_right,"Exected '}' for switch case."),e.push(this._updateNode(new Mg(i,n)))}if(this._match($g.keywords.default)){if(t)throw this._error(this._previous(),"Multiple default cases in switch statement.");this._match($g.tokens.colon),this._check($g.tokens.attr)&&this._attribute(),this._consume($g.tokens.brace_left,"Exected '{' for switch default.");const i=this._case_body();this._consume($g.tokens.brace_right,"Exected '}' for switch default."),e.push(this._updateNode(new Pg(i)))}}return e}_case_selectors(){const e=[];for(this._match($g.keywords.default)?e.push(this._updateNode(new Ig)):e.push(this._shift_expression());this._match($g.tokens.comma);)this._match($g.keywords.default)?e.push(this._updateNode(new Ig)):e.push(this._shift_expression());return e}_case_body(){if(this._match($g.keywords.fallthrough))return this._consume($g.tokens.semicolon,"Expected ';'"),[];let e=this._statement();if(null==e)return[];e instanceof Array||(e=[e]);const t=this._case_body();return 0==t.length?e:[...e,t[0]]}_if_statement(){if(!this._match($g.keywords.if))return null;const e=this._currentLine,t=this._optional_paren_expression();this._check($g.tokens.attr)&&this._attribute();const i=this._compound_statement();let n=[];this._match_elseif()&&(this._check($g.tokens.attr)&&this._attribute(),n=this._elseif_statement(n));let r=null;return this._match($g.keywords.else)&&(this._check($g.tokens.attr)&&this._attribute(),r=this._compound_statement()),this._updateNode(new eg(t,i,n,r),e)}_match_elseif(){return this._tokens[this._current].type===$g.keywords.else&&this._tokens[this._current+1].type===$g.keywords.if&&(this._advance(),this._advance(),!0)}_elseif_statement(e=[]){const t=this._optional_paren_expression(),i=this._compound_statement();return e.push(this._updateNode(new Lg(t,i))),this._match_elseif()&&(this._check($g.tokens.attr)&&this._attribute(),this._elseif_statement(e)),e}_return_statement(){if(!this._match($g.keywords.return))return null;const e=this._short_circuit_or_expression();return this._updateNode(new tg(e))}_short_circuit_or_expression(){let e=this._short_circuit_and_expr();for(;this._match($g.tokens.or_or);)e=this._updateNode(new Sg(this._previous().toString(),e,this._short_circuit_and_expr()));return e}_short_circuit_and_expr(){let e=this._inclusive_or_expression();for(;this._match($g.tokens.and_and);)e=this._updateNode(new Sg(this._previous().toString(),e,this._inclusive_or_expression()));return e}_inclusive_or_expression(){let e=this._exclusive_or_expression();for(;this._match($g.tokens.or);)e=this._updateNode(new Sg(this._previous().toString(),e,this._exclusive_or_expression()));return e}_exclusive_or_expression(){let e=this._and_expression();for(;this._match($g.tokens.xor);)e=this._updateNode(new Sg(this._previous().toString(),e,this._and_expression()));return e}_and_expression(){let e=this._equality_expression();for(;this._match($g.tokens.and);)e=this._updateNode(new Sg(this._previous().toString(),e,this._equality_expression()));return e}_equality_expression(){const e=this._relational_expression();return this._match([$g.tokens.equal_equal,$g.tokens.not_equal])?this._updateNode(new Sg(this._previous().toString(),e,this._relational_expression())):e}_relational_expression(){let e=this._shift_expression();for(;this._match([$g.tokens.less_than,$g.tokens.greater_than,$g.tokens.less_than_equal,$g.tokens.greater_than_equal]);)e=this._updateNode(new Sg(this._previous().toString(),e,this._shift_expression()));return e}_shift_expression(){let e=this._additive_expression();for(;this._match([$g.tokens.shift_left,$g.tokens.shift_right]);)e=this._updateNode(new Sg(this._previous().toString(),e,this._additive_expression()));return e}_additive_expression(){let e=this._multiplicative_expression();for(;this._match([$g.tokens.plus,$g.tokens.minus]);)e=this._updateNode(new Sg(this._previous().toString(),e,this._multiplicative_expression()));return e}_multiplicative_expression(){let e=this._unary_expression();for(;this._match([$g.tokens.star,$g.tokens.forward_slash,$g.tokens.modulo]);)e=this._updateNode(new Sg(this._previous().toString(),e,this._unary_expression()));return e}_unary_expression(){return this._match([$g.tokens.minus,$g.tokens.bang,$g.tokens.tilde,$g.tokens.star,$g.tokens.and])?this._updateNode(new Cg(this._previous().toString(),this._unary_expression())):this._singular_expression()}_singular_expression(){const e=this._primary_expression(),t=this._postfix_expression();return t&&(e.postfix=t),e}_postfix_expression(){if(this._match($g.tokens.bracket_left)){const e=this._short_circuit_or_expression();this._consume($g.tokens.bracket_right,"Expected ']'.");const t=this._updateNode(new Tg(e)),i=this._postfix_expression();return i&&(t.postfix=i),t}if(this._match($g.tokens.period)){const e=this._consume($g.tokens.name,"Expected member name."),t=this._postfix_expression(),i=this._updateNode(new _g(e.lexeme));return t&&(i.postfix=t),i}return null}_getStruct(e){return this._context.aliases.has(e)?this._context.aliases.get(e).type:this._context.structs.has(e)?this._context.structs.get(e):null}_getType(e){const t=this._getStruct(e);if(null!==t)return t;switch(e){case"void":return cg.void;case"bool":return cg.bool;case"i32":return cg.i32;case"u32":return cg.u32;case"f32":return cg.f32;case"f16":return cg.f16;case"vec2f":return dg.vec2f;case"vec3f":return dg.vec3f;case"vec4f":return dg.vec4f;case"vec2i":return dg.vec2i;case"vec3i":return dg.vec3i;case"vec4i":return dg.vec4i;case"vec2u":return dg.vec2u;case"vec3u":return dg.vec3u;case"vec4u":return dg.vec4u;case"vec2h":return dg.vec2h;case"vec3h":return dg.vec3h;case"vec4h":return dg.vec4h;case"mat2x2f":return dg.mat2x2f;case"mat2x3f":return dg.mat2x3f;case"mat2x4f":return dg.mat2x4f;case"mat3x2f":return dg.mat3x2f;case"mat3x3f":return dg.mat3x3f;case"mat3x4f":return dg.mat3x4f;case"mat4x2f":return dg.mat4x2f;case"mat4x3f":return dg.mat4x3f;case"mat4x4f":return dg.mat4x4f;case"mat2x2h":return dg.mat2x2h;case"mat2x3h":return dg.mat2x3h;case"mat2x4h":return dg.mat2x4h;case"mat3x2h":return dg.mat3x2h;case"mat3x3h":return dg.mat3x3h;case"mat3x4h":return dg.mat3x4h;case"mat4x2h":return dg.mat4x2h;case"mat4x3h":return dg.mat4x3h;case"mat4x4h":return dg.mat4x4h;case"mat2x2i":return dg.mat2x2i;case"mat2x3i":return dg.mat2x3i;case"mat2x4i":return dg.mat2x4i;case"mat3x2i":return dg.mat3x2i;case"mat3x3i":return dg.mat3x3i;case"mat3x4i":return dg.mat3x4i;case"mat4x2i":return dg.mat4x2i;case"mat4x3i":return dg.mat4x3i;case"mat4x4i":return dg.mat4x4i;case"mat2x2u":return dg.mat2x2u;case"mat2x3u":return dg.mat2x3u;case"mat2x4u":return dg.mat2x4u;case"mat3x2u":return dg.mat3x2u;case"mat3x3u":return dg.mat3x3u;case"mat3x4u":return dg.mat3x4u;case"mat4x2u":return dg.mat4x2u;case"mat4x3u":return dg.mat4x3u;case"mat4x4u":return dg.mat4x4u}return null}_validateTypeRange(e,t){if("i32"===t.name){if(e<-2147483648||e>2147483647)throw this._error(this._previous(),`Value out of range for i32: ${e}. Line: ${this._currentLine}.`)}else if("u32"===t.name&&(e<0||e>4294967295))throw this._error(this._previous(),`Value out of range for u32: ${e}. Line: ${this._currentLine}.`)}_primary_expression(){if(this._match($g.tokens.ident)){const e=this._previous().toString();if(this._check($g.tokens.paren_left)){const t=this._argument_expression_list(),i=this._getType(e);return null!==i?this._updateNode(new Ag(i,t)):this._updateNode(new yg(e,t))}if(this._context.constants.has(e)){const t=this._context.constants.get(e);return this._updateNode(new xg(e,t.value))}return this._updateNode(new vg(e))}if(this._match($g.tokens.int_literal)){const e=this._previous().toString();let t=e.endsWith("i")||e.endsWith("i")?cg.i32:e.endsWith("u")||e.endsWith("U")?cg.u32:cg.x32;const i=parseInt(e);return this._validateTypeRange(i,t),this._updateNode(new bg(new Ug(i,this._exec.getTypeInfo(t)),t))}if(this._match($g.tokens.uint_literal)){const e=parseInt(this._previous().toString());return this._validateTypeRange(e,cg.u32),this._updateNode(new bg(new Ug(e,this._exec.getTypeInfo(cg.u32)),cg.u32))}if(this._match([$g.tokens.decimal_float_literal,$g.tokens.hex_float_literal])){let e=this._previous().toString(),t=e.endsWith("h");t&&(e=e.substring(0,e.length-1));const i=parseFloat(e);this._validateTypeRange(i,t?cg.f16:cg.f32);const n=t?cg.f16:cg.f32;return this._updateNode(new bg(new Ug(i,this._exec.getTypeInfo(n)),n))}if(this._match([$g.keywords.true,$g.keywords.false])){let e=this._previous().toString()===$g.keywords.true.rule;return this._updateNode(new bg(new Ug(e?1:0,this._exec.getTypeInfo(cg.bool)),cg.bool))}if(this._check($g.tokens.paren_left))return this._paren_expression();if(this._match($g.keywords.bitcast)){this._consume($g.tokens.less_than,"Expected '<'.");const e=this._type_decl();this._consume($g.tokens.greater_than,"Expected '>'.");const t=this._paren_expression();return this._updateNode(new wg(e,t))}const e=this._type_decl(),t=this._argument_expression_list();return this._updateNode(new Ag(e,t))}_argument_expression_list(){if(!this._match($g.tokens.paren_left))return null;const e=[];do{if(this._check($g.tokens.paren_right))break;const t=this._short_circuit_or_expression();e.push(t)}while(this._match($g.tokens.comma));return this._consume($g.tokens.paren_right,"Expected ')' for agument list"),e}_optional_paren_expression(){this._match($g.tokens.paren_left);const e=this._short_circuit_or_expression();return this._match($g.tokens.paren_right),e}_paren_expression(){this._consume($g.tokens.paren_left,"Expected '('.");const e=this._short_circuit_or_expression();return this._consume($g.tokens.paren_right,"Expected ')'."),e}_struct_decl(){if(!this._match($g.keywords.struct))return null;const e=this._currentLine,t=this._consume($g.tokens.ident,"Expected name for struct.").toString();this._consume($g.tokens.brace_left,"Expected '{' for struct body.");const i=[];for(;!this._check($g.tokens.brace_right);){const e=this._attribute(),t=this._consume($g.tokens.name,"Expected variable name.").toString();this._consume($g.tokens.colon,"Expected ':' for struct member type.");const n=this._attribute(),r=this._type_decl();null!=r&&(r.attributes=n),this._check($g.tokens.brace_right)?this._match($g.tokens.comma):this._consume($g.tokens.comma,"Expected ',' for struct member."),i.push(this._updateNode(new Fg(t,r,e)))}this._consume($g.tokens.brace_right,"Expected '}' after struct body.");const n=this._currentLine,r=this._updateNode(new hg(t,i,e,n),e);return this._context.structs.set(t,r),r}_global_variable_decl(){const e=this._variable_decl();if(!e)return null;if(this._match($g.tokens.equal)){const t=this._const_expression();e.value=t}if(null!==e.type&&e.value instanceof bg){if("x32"!==e.value.type.name&&e.type.getTypeName()!==e.value.type.getTypeName())throw this._error(this._peek(),`Invalid cast from ${e.value.type.name} to ${e.type.name}. Line:${this._currentLine}`);e.value.isScalar&&this._validateTypeRange(e.value.scalarValue,e.type),e.value.type=e.type}else null===e.type&&e.value instanceof bg&&(e.type="x32"===e.value.type.name?cg.i32:e.value.type,e.value.isScalar&&this._validateTypeRange(e.value.scalarValue,e.type));return e}_override_variable_decl(){const e=this._override_decl();return e&&this._match($g.tokens.equal)&&(e.value=this._const_expression()),e}_global_const_decl(){var e;if(!this._match($g.keywords.const))return null;const t=this._consume($g.tokens.name,"Expected variable name"),i=this._currentLine;let n=null;if(this._match($g.tokens.colon)){const e=this._attribute();n=this._type_decl(),null!=n&&(n.attributes=e)}let r=null;this._consume($g.tokens.equal,"const declarations require an assignment");const o=this._short_circuit_or_expression();try{let e=[cg.f32],i=o.constEvaluate(this._exec,e);i instanceof Ug&&this._validateTypeRange(i.value,e[0]),e[0]instanceof dg&&null===e[0].format&&i.typeInfo instanceof um&&null!==i.typeInfo.format&&("f16"===i.typeInfo.format.name?e[0].format=cg.f16:"f32"===i.typeInfo.format.name?e[0].format=cg.f32:"i32"===i.typeInfo.format.name?e[0].format=cg.i32:"u32"===i.typeInfo.format.name?e[0].format=cg.u32:"bool"===i.typeInfo.format.name?e[0].format=cg.bool:console.error(`TODO: impelement template format type ${i.typeInfo.format.name}`)),r=this._updateNode(new bg(i,e[0])),this._exec.context.setVariable(t.toString(),i)}catch(e){r=o}if(null!==n&&r instanceof bg){if("x32"!==r.type.name&&n.getTypeName()!==r.type.getTypeName())throw this._error(this._peek(),`Invalid cast from ${r.type.name} to ${n.name}. Line:${this._currentLine}`);r.type=n,r.isScalar&&this._validateTypeRange(r.scalarValue,r.type)}else null===n&&r instanceof bg&&(n=null!==(e=null==r?void 0:r.type)&&void 0!==e?e:cg.f32,n===cg.x32&&(n=cg.i32));const s=this._updateNode(new Hm(t.toString(),n,"","",r),i);return this._context.constants.set(s.name,s),s}_global_let_decl(){if(!this._match($g.keywords.let))return null;const e=this._currentLine,t=this._consume($g.tokens.name,"Expected variable name");let i=null;if(this._match($g.tokens.colon)){const e=this._attribute();i=this._type_decl(),null!=i&&(i.attributes=e)}let n=null;if(this._match($g.tokens.equal)&&(n=this._const_expression()),null!==i&&n instanceof bg){if("x32"!==n.type.name&&i.getTypeName()!==n.type.getTypeName())throw this._error(this._peek(),`Invalid cast from ${n.type.name} to ${i.name}. Line:${this._currentLine}`);n.type=i}else null===i&&n instanceof bg&&(i="x32"===n.type.name?cg.i32:n.type);return n instanceof bg&&n.isScalar&&this._validateTypeRange(n.scalarValue,i),this._updateNode(new Gm(t.toString(),i,"","",n),e)}_const_expression(){return this._short_circuit_or_expression()}_variable_decl(){if(!this._match($g.keywords.var))return null;const e=this._currentLine;let t="",i="";this._match($g.tokens.less_than)&&(t=this._consume($g.storage_class,"Expected storage_class.").toString(),this._match($g.tokens.comma)&&(i=this._consume($g.access_mode,"Expected access_mode.").toString()),this._consume($g.tokens.greater_than,"Expected '>'."));const n=this._consume($g.tokens.name,"Expected variable name");let r=null;if(this._match($g.tokens.colon)){const e=this._attribute();r=this._type_decl(),null!=r&&(r.attributes=e)}return this._updateNode(new Vm(n.toString(),r,t,i,null),e)}_override_decl(){if(!this._match($g.keywords.override))return null;const e=this._consume($g.tokens.name,"Expected variable name");let t=null;if(this._match($g.tokens.colon)){const e=this._attribute();t=this._type_decl(),null!=t&&(t.attributes=e)}return this._updateNode(new jm(e.toString(),t,null))}_diagnostic(){this._consume($g.tokens.paren_left,"Expected '('");const e=this._consume($g.tokens.ident,"Expected severity control name.");this._consume($g.tokens.comma,"Expected ','");let t=this._consume($g.tokens.ident,"Expected diagnostic rule name.").toString();return this._match($g.tokens.period)&&(t+=`.${this._consume($g.tokens.ident,"Expected diagnostic message.").toString()}`),this._consume($g.tokens.paren_right,"Expected ')'"),this._updateNode(new rg(e.toString(),t))}_enable_directive(){const e=this._consume($g.tokens.ident,"identity expected.");return this._updateNode(new ig(e.toString()))}_requires_directive(){const e=[this._consume($g.tokens.ident,"identity expected.").toString()];for(;this._match($g.tokens.comma);){const t=this._consume($g.tokens.ident,"identity expected.");e.push(t.toString())}return this._updateNode(new ng(e))}_type_alias(){const e=this._consume($g.tokens.ident,"identity expected.");this._consume($g.tokens.equal,"Expected '=' for type alias.");let t=this._type_decl();if(null===t)throw this._error(this._peek(),"Expected Type for Alias.");this._context.aliases.has(t.name)&&(t=this._context.aliases.get(t.name).type);const i=this._updateNode(new og(e.toString(),t));return this._context.aliases.set(i.name,i),i}_type_decl(){if(this._check([$g.tokens.ident,...$g.texel_format,$g.keywords.bool,$g.keywords.f32,$g.keywords.i32,$g.keywords.u32])){const e=this._advance().toString();if(this._context.structs.has(e))return this._context.structs.get(e);if(this._context.aliases.has(e))return this._context.aliases.get(e).type;if(!this._getType(e)){const t=this._updateNode(new ug(e));return this._forwardTypeCount++,t}return this._updateNode(new cg(e))}let e=this._texture_sampler_types();if(e)return e;if(this._check($g.template_types)){let e=this._advance().toString(),t=null,i=null;return this._match($g.tokens.less_than)&&(t=this._type_decl(),i=null,this._match($g.tokens.comma)&&(i=this._consume($g.access_mode,"Expected access_mode for pointer").toString()),this._consume($g.tokens.greater_than,"Expected '>' for type.")),this._updateNode(new dg(e,t,i))}if(this._match($g.keywords.ptr)){let e=this._previous().toString();this._consume($g.tokens.less_than,"Expected '<' for pointer.");const t=this._consume($g.storage_class,"Expected storage_class for pointer");this._consume($g.tokens.comma,"Expected ',' for pointer.");const i=this._type_decl();let n=null;return this._match($g.tokens.comma)&&(n=this._consume($g.access_mode,"Expected access_mode for pointer").toString()),this._consume($g.tokens.greater_than,"Expected '>' for pointer."),this._updateNode(new pg(e,t.toString(),i,n))}const t=this._attribute();if(this._match($g.keywords.array)){let i=null,n=-1;const r=this._previous();let o=null;if(this._match($g.tokens.less_than)){i=this._type_decl(),this._context.aliases.has(i.name)&&(i=this._context.aliases.get(i.name).type);let t="";if(this._match($g.tokens.comma)){o=this._shift_expression();try{t=o.constEvaluate(this._exec).toString(),o=null}catch(e){t="1"}}this._consume($g.tokens.greater_than,"Expected '>' for array."),n=t?parseInt(t):0}const s=this._updateNode(new fg(r.toString(),t,i,n));return o&&this._deferArrayCountEval.push({arrayType:s,countNode:o}),s}return null}_texture_sampler_types(){if(this._match($g.sampler_type))return this._updateNode(new mg(this._previous().toString(),null,null));if(this._match($g.depth_texture_type))return this._updateNode(new mg(this._previous().toString(),null,null));if(this._match($g.sampled_texture_type)||this._match($g.multisampled_texture_type)){const e=this._previous();this._consume($g.tokens.less_than,"Expected '<' for sampler type.");const t=this._type_decl();return this._consume($g.tokens.greater_than,"Expected '>' for sampler type."),this._updateNode(new mg(e.toString(),t,null))}if(this._match($g.storage_texture_type)){const e=this._previous();this._consume($g.tokens.less_than,"Expected '<' for sampler type.");const t=this._consume($g.texel_format,"Invalid texel format.").toString();this._consume($g.tokens.comma,"Expected ',' after texel format.");const i=this._consume($g.access_mode,"Expected access mode for storage texture type.").toString();return this._consume($g.tokens.greater_than,"Expected '>' for sampler type."),this._updateNode(new mg(e.toString(),t,i))}return null}_attribute(){let e=[];for(;this._match($g.tokens.attr);){const t=this._consume($g.attribute_name,"Expected attribute name"),i=this._updateNode(new kg(t.toString(),null));if(this._match($g.tokens.paren_left)){if(i.value=this._consume($g.literal_or_ident,"Expected attribute value").toString(),this._check($g.tokens.comma)){this._advance();do{const e=this._consume($g.literal_or_ident,"Expected attribute value").toString();i.value instanceof Array||(i.value=[i.value]),i.value.push(e)}while(this._match($g.tokens.comma))}this._consume($g.tokens.paren_right,"Expected ')'")}e.push(i)}return 0==e.length?null:e}}class v_ extends l_{constructor(e){super(),e&&this.update(e)}update(e){const t=(new y_).parse(e);this.updateAST(t)}}function x_(e){const t={attributes:[],bindings:[]};let i;try{i=function(e){try{return new v_(e)}catch(e){if(e instanceof Error)throw e;let t="WGSL parse error";throw"object"==typeof e&&e?.message&&(t+=`: ${e.message} `),"object"==typeof e&&e?.token&&(t+=e.token.line||""),new Error(t,{cause:e})}}(e)}catch(e){return Gp.error(e.message)(),t}for(const e of i.uniforms){const i=[];for(const t of e.type?.members||[])i.push({name:t.name,type:b_(t.type)});t.bindings.push({type:"uniform",name:e.name,location:e.binding,group:e.group,members:i})}const n=i.entry.vertex[0],r=n?.inputs.length||0;for(let e=0;e`:e.name}const w_={name:"fp32",vs:"#ifdef LUMA_FP32_TAN_PRECISION_WORKAROUND\nconst float TWO_PI = 6.2831854820251465;\nconst float PI_2 = 1.5707963705062866;\nconst float PI_16 = 0.1963495463132858;\nconst float SIN_TABLE_0 = 0.19509032368659973;\nconst float SIN_TABLE_1 = 0.3826834261417389;\nconst float SIN_TABLE_2 = 0.5555702447891235;\nconst float SIN_TABLE_3 = 0.7071067690849304;\nconst float COS_TABLE_0 = 0.9807852506637573;\nconst float COS_TABLE_1 = 0.9238795042037964;\nconst float COS_TABLE_2 = 0.8314695954322815;\nconst float COS_TABLE_3 = 0.7071067690849304;\nconst float INVERSE_FACTORIAL_3 = 1.666666716337204e-01;\nconst float INVERSE_FACTORIAL_5 = 8.333333767950535e-03;\nconst float INVERSE_FACTORIAL_7 = 1.9841270113829523e-04;\nconst float INVERSE_FACTORIAL_9 = 2.75573188446287533e-06;\nfloat sin_taylor_fp32(float a) {\nfloat r, s, t, x;\nif (a == 0.0) {\nreturn 0.0;\n}\nx = -a * a;\ns = a;\nr = a;\nr = r * x;\nt = r * INVERSE_FACTORIAL_3;\ns = s + t;\nr = r * x;\nt = r * INVERSE_FACTORIAL_5;\ns = s + t;\nr = r * x;\nt = r * INVERSE_FACTORIAL_7;\ns = s + t;\nr = r * x;\nt = r * INVERSE_FACTORIAL_9;\ns = s + t;\nreturn s;\n}\nvoid sincos_taylor_fp32(float a, out float sin_t, out float cos_t) {\nif (a == 0.0) {\nsin_t = 0.0;\ncos_t = 1.0;\n}\nsin_t = sin_taylor_fp32(a);\ncos_t = sqrt(1.0 - sin_t * sin_t);\n}\nfloat tan_taylor_fp32(float a) {\nfloat sin_a;\nfloat cos_a;\nif (a == 0.0) {\nreturn 0.0;\n}\nfloat z = floor(a / TWO_PI);\nfloat r = a - TWO_PI * z;\nfloat t;\nfloat q = floor(r / PI_2 + 0.5);\nint j = int(q);\nif (j < -2 || j > 2) {\nreturn 1.0 / 0.0;\n}\nt = r - PI_2 * q;\nq = floor(t / PI_16 + 0.5);\nint k = int(q);\nint abs_k = int(abs(float(k)));\nif (abs_k > 4) {\nreturn 1.0 / 0.0;\n} else {\nt = t - PI_16 * q;\n}\nfloat u = 0.0;\nfloat v = 0.0;\nfloat sin_t, cos_t;\nfloat s, c;\nsincos_taylor_fp32(t, sin_t, cos_t);\nif (k == 0) {\ns = sin_t;\nc = cos_t;\n} else {\nif (abs(float(abs_k) - 1.0) < 0.5) {\nu = COS_TABLE_0;\nv = SIN_TABLE_0;\n} else if (abs(float(abs_k) - 2.0) < 0.5) {\nu = COS_TABLE_1;\nv = SIN_TABLE_1;\n} else if (abs(float(abs_k) - 3.0) < 0.5) {\nu = COS_TABLE_2;\nv = SIN_TABLE_2;\n} else if (abs(float(abs_k) - 4.0) < 0.5) {\nu = COS_TABLE_3;\nv = SIN_TABLE_3;\n}\nif (k > 0) {\ns = u * sin_t + v * cos_t;\nc = u * cos_t - v * sin_t;\n} else {\ns = u * sin_t - v * cos_t;\nc = u * cos_t + v * sin_t;\n}\n}\nif (j == 0) {\nsin_a = s;\ncos_a = c;\n} else if (j == 1) {\nsin_a = c;\ncos_a = -s;\n} else if (j == -1) {\nsin_a = -c;\ncos_a = s;\n} else {\nsin_a = -s;\ncos_a = -c;\n}\nreturn sin_a / cos_a;\n}\n#endif\nfloat tan_fp32(float a) {\n#ifdef LUMA_FP32_TAN_PRECISION_WORKAROUND\nreturn tan_taylor_fp32(a);\n#else\nreturn tan(a);\n#endif\n}\n"},T_={name:"picking",vs:"uniform pickingUniforms {\nfloat isActive;\nfloat isAttribute;\nfloat isHighlightActive;\nfloat useFloatColors;\nvec3 highlightedObjectColor;\nvec4 highlightColor;\n} picking;\nout vec4 picking_vRGBcolor_Avalid;\nvec3 picking_normalizeColor(vec3 color) {\nreturn picking.useFloatColors > 0.5 ? color : color / 255.0;\n}\nvec4 picking_normalizeColor(vec4 color) {\nreturn picking.useFloatColors > 0.5 ? color : color / 255.0;\n}\nbool picking_isColorZero(vec3 color) {\nreturn dot(color, vec3(1.0)) < 0.00001;\n}\nbool picking_isColorValid(vec3 color) {\nreturn dot(color, vec3(1.0)) > 0.00001;\n}\nbool isVertexHighlighted(vec3 vertexColor) {\nvec3 highlightedObjectColor = picking_normalizeColor(picking.highlightedObjectColor);\nreturn\nbool(picking.isHighlightActive) && picking_isColorZero(abs(vertexColor - highlightedObjectColor));\n}\nvoid picking_setPickingColor(vec3 pickingColor) {\npickingColor = picking_normalizeColor(pickingColor);\nif (bool(picking.isActive)) {\npicking_vRGBcolor_Avalid.a = float(picking_isColorValid(pickingColor));\nif (!bool(picking.isAttribute)) {\npicking_vRGBcolor_Avalid.rgb = pickingColor;\n}\n} else {\npicking_vRGBcolor_Avalid.a = float(isVertexHighlighted(pickingColor));\n}\n}\nvoid picking_setPickingAttribute(float value) {\nif (bool(picking.isAttribute)) {\npicking_vRGBcolor_Avalid.r = value;\n}\n}\nvoid picking_setPickingAttribute(vec2 value) {\nif (bool(picking.isAttribute)) {\npicking_vRGBcolor_Avalid.rg = value;\n}\n}\nvoid picking_setPickingAttribute(vec3 value) {\nif (bool(picking.isAttribute)) {\npicking_vRGBcolor_Avalid.rgb = value;\n}\n}\n",fs:"uniform pickingUniforms {\nfloat isActive;\nfloat isAttribute;\nfloat isHighlightActive;\nfloat useFloatColors;\nvec3 highlightedObjectColor;\nvec4 highlightColor;\n} picking;\nin vec4 picking_vRGBcolor_Avalid;\nvec4 picking_filterHighlightColor(vec4 color) {\nif (picking.isActive > 0.5) {\nreturn color;\n}\nbool selected = bool(picking_vRGBcolor_Avalid.a);\nif (selected) {\nfloat highLightAlpha = picking.highlightColor.a;\nfloat blendedAlpha = highLightAlpha + color.a * (1.0 - highLightAlpha);\nfloat highLightRatio = highLightAlpha / blendedAlpha;\nvec3 blendedRGB = mix(color.rgb, picking.highlightColor.rgb, highLightRatio);\nreturn vec4(blendedRGB, blendedAlpha);\n} else {\nreturn color;\n}\n}\nvec4 picking_filterPickingColor(vec4 color) {\nif (bool(picking.isActive)) {\nif (picking_vRGBcolor_Avalid.a == 0.0) {\ndiscard;\n}\nreturn picking_vRGBcolor_Avalid;\n}\nreturn color;\n}\nvec4 picking_filterColor(vec4 color) {\nvec4 highlightColor = picking_filterHighlightColor(color);\nreturn picking_filterPickingColor(highlightColor);\n}\n",uniformTypes:{isActive:"f32",isAttribute:"f32",isHighlightActive:"f32",useFloatColors:"f32",highlightedObjectColor:"vec3",highlightColor:"vec4"},defaultUniforms:{isActive:!1,isAttribute:!1,isHighlightActive:!1,useFloatColors:!0,highlightedObjectColor:[0,0,0],highlightColor:[0,1,1,1]},getUniforms:function(e={},t){const i={};if(void 0===e.highlightedObjectColor);else if(null===e.highlightedObjectColor)i.isHighlightActive=!1;else{i.isHighlightActive=!0;const t=e.highlightedObjectColor.slice(0,3);i.highlightedObjectColor=t}if(e.highlightColor){const t=Array.from(e.highlightColor,e=>e/255);Number.isFinite(t[3])||(t[3]=1),i.highlightColor=t}void 0!==e.isActive&&(i.isActive=Boolean(e.isActive),i.isAttribute=Boolean(e.isAttribute));void 0!==e.useFloatColors&&(i.useFloatColors=Boolean(e.useFloatColors));return i}};function E_(e,t=[],i=0){const n=Math.fround(e),r=e-n;return t[i]=n,t[i+1]=r,t}function C_(e){return e-Math.fround(e)}function S_(e){const t=new Float32Array(32);for(let i=0;i<4;++i)for(let n=0;n<4;++n){const r=4*i+n;E_(e[4*n+i],t,2*r)}return t}const B_={ONE:1};const I_={name:"fp64-arithmetic",vs:"uniform float ONE;\nvec2 split(float a) {\nconst float SPLIT = 4097.0;\nfloat t = a * SPLIT;\n#if defined(LUMA_FP64_CODE_ELIMINATION_WORKAROUND)\nfloat a_hi = t * ONE - (t - a);\nfloat a_lo = a * ONE - a_hi;\n#else\nfloat a_hi = t - (t - a);\nfloat a_lo = a - a_hi;\n#endif\nreturn vec2(a_hi, a_lo);\n}\nvec2 split2(vec2 a) {\nvec2 b = split(a.x);\nb.y += a.y;\nreturn b;\n}\nvec2 quickTwoSum(float a, float b) {\n#if defined(LUMA_FP64_CODE_ELIMINATION_WORKAROUND)\nfloat sum = (a + b) * ONE;\nfloat err = b - (sum - a) * ONE;\n#else\nfloat sum = a + b;\nfloat err = b - (sum - a);\n#endif\nreturn vec2(sum, err);\n}\nvec2 twoSum(float a, float b) {\nfloat s = (a + b);\n#if defined(LUMA_FP64_CODE_ELIMINATION_WORKAROUND)\nfloat v = (s * ONE - a) * ONE;\nfloat err = (a - (s - v) * ONE) * ONE * ONE * ONE + (b - v);\n#else\nfloat v = s - a;\nfloat err = (a - (s - v)) + (b - v);\n#endif\nreturn vec2(s, err);\n}\nvec2 twoSub(float a, float b) {\nfloat s = (a - b);\n#if defined(LUMA_FP64_CODE_ELIMINATION_WORKAROUND)\nfloat v = (s * ONE - a) * ONE;\nfloat err = (a - (s - v) * ONE) * ONE * ONE * ONE - (b + v);\n#else\nfloat v = s - a;\nfloat err = (a - (s - v)) - (b + v);\n#endif\nreturn vec2(s, err);\n}\nvec2 twoSqr(float a) {\nfloat prod = a * a;\nvec2 a_fp64 = split(a);\n#if defined(LUMA_FP64_CODE_ELIMINATION_WORKAROUND)\nfloat err = ((a_fp64.x * a_fp64.x - prod) * ONE + 2.0 * a_fp64.x *\na_fp64.y * ONE * ONE) + a_fp64.y * a_fp64.y * ONE * ONE * ONE;\n#else\nfloat err = ((a_fp64.x * a_fp64.x - prod) + 2.0 * a_fp64.x * a_fp64.y) + a_fp64.y * a_fp64.y;\n#endif\nreturn vec2(prod, err);\n}\nvec2 twoProd(float a, float b) {\nfloat prod = a * b;\nvec2 a_fp64 = split(a);\nvec2 b_fp64 = split(b);\nfloat err = ((a_fp64.x * b_fp64.x - prod) + a_fp64.x * b_fp64.y +\na_fp64.y * b_fp64.x) + a_fp64.y * b_fp64.y;\nreturn vec2(prod, err);\n}\nvec2 sum_fp64(vec2 a, vec2 b) {\nvec2 s, t;\ns = twoSum(a.x, b.x);\nt = twoSum(a.y, b.y);\ns.y += t.x;\ns = quickTwoSum(s.x, s.y);\ns.y += t.y;\ns = quickTwoSum(s.x, s.y);\nreturn s;\n}\nvec2 sub_fp64(vec2 a, vec2 b) {\nvec2 s, t;\ns = twoSub(a.x, b.x);\nt = twoSub(a.y, b.y);\ns.y += t.x;\ns = quickTwoSum(s.x, s.y);\ns.y += t.y;\ns = quickTwoSum(s.x, s.y);\nreturn s;\n}\nvec2 mul_fp64(vec2 a, vec2 b) {\nvec2 prod = twoProd(a.x, b.x);\nprod.y += a.x * b.y;\n#if defined(LUMA_FP64_HIGH_BITS_OVERFLOW_WORKAROUND)\nprod = split2(prod);\n#endif\nprod = quickTwoSum(prod.x, prod.y);\nprod.y += a.y * b.x;\n#if defined(LUMA_FP64_HIGH_BITS_OVERFLOW_WORKAROUND)\nprod = split2(prod);\n#endif\nprod = quickTwoSum(prod.x, prod.y);\nreturn prod;\n}\nvec2 div_fp64(vec2 a, vec2 b) {\nfloat xn = 1.0 / b.x;\n#if defined(LUMA_FP64_HIGH_BITS_OVERFLOW_WORKAROUND)\nvec2 yn = mul_fp64(a, vec2(xn, 0));\n#else\nvec2 yn = a * xn;\n#endif\nfloat diff = (sub_fp64(a, mul_fp64(b, yn))).x;\nvec2 prod = twoProd(xn, diff);\nreturn sum_fp64(yn, prod);\n}\nvec2 sqrt_fp64(vec2 a) {\nif (a.x == 0.0 && a.y == 0.0) return vec2(0.0, 0.0);\nif (a.x < 0.0) return vec2(0.0 / 0.0, 0.0 / 0.0);\nfloat x = 1.0 / sqrt(a.x);\nfloat yn = a.x * x;\n#if defined(LUMA_FP64_CODE_ELIMINATION_WORKAROUND)\nvec2 yn_sqr = twoSqr(yn) * ONE;\n#else\nvec2 yn_sqr = twoSqr(yn);\n#endif\nfloat diff = sub_fp64(a, yn_sqr).x;\nvec2 prod = twoProd(x * 0.5, diff);\n#if defined(LUMA_FP64_HIGH_BITS_OVERFLOW_WORKAROUND)\nreturn sum_fp64(split(yn), prod);\n#else\nreturn sum_fp64(vec2(yn, 0.0), prod);\n#endif\n}\n",getUniforms:function(){return B_},fp64ify:E_,fp64LowPart:C_,fp64ifyMatrix4:S_},M_=1/Math.PI*180,P_=1/180*Math.PI;globalThis.mathgl=globalThis.mathgl||{config:{EPSILON:1e-12,debug:!1,precision:4,printTypes:!1,printDegrees:!1,printRowMajor:!0,_cartographicRadians:!1}};const R_=globalThis.mathgl.config;function L_(e,{precision:t=R_.precision}={}){return e=function(e){return Math.round(e/R_.EPSILON)*R_.EPSILON}(e),`${parseFloat(e.toPrecision(t))}`}function F_(e){return Array.isArray(e)||ArrayBuffer.isView(e)&&!(e instanceof DataView)}function k_(e){return function(e,t){return V_(e,e=>e*P_,t)}(e)}function D_(e){return O_(e)}function O_(e,t){return V_(e,e=>e*M_,t)}function z_(e,t,i){return V_(e,e=>Math.max(t,Math.min(i,e)))}function U_(e,t,i){return F_(e)?e.map((e,n)=>U_(e,t[n],i)):i*t+(1-i)*e}function N_(e,t,i){const n=R_.EPSILON;i&&(R_.EPSILON=i);try{if(e===t)return!0;if(F_(e)&&F_(t)){if(e.length!==t.length)return!1;for(let i=0;i0?", ":"")+L_(this[i],e);return`${e.printTypes?this.constructor.name:""}[${t}]`}equals(e){if(!e||this.length!==e.length)return!1;for(let t=0;t=0&&e=0&&e0?this.copy([e,...t]):this.identity()}copy(e){return this[0]=e[0],this[1]=e[1],this[2]=e[2],this[3]=e[3],this[4]=e[4],this[5]=e[5],this[6]=e[6],this[7]=e[7],this[8]=e[8],this.check()}identity(){return this.copy(TA)}fromObject(e){return this.check()}fromQuaternion(e){return function(e,t){const i=t[0],n=t[1],r=t[2],o=t[3],s=i+i,a=n+n,l=r+r,c=i*s,u=n*s,h=n*a,d=r*s,p=r*a,f=r*l,m=o*s,g=o*a,_=o*l;e[0]=1-h-f,e[3]=u-_,e[6]=d+g,e[1]=u+_,e[4]=1-c-f,e[7]=p-m,e[2]=d-g,e[5]=p+m,e[8]=1-c-h}(this,e),this.check()}set(e,t,i,n,r,o,s,a,l){return this[0]=e,this[1]=t,this[2]=i,this[3]=n,this[4]=r,this[5]=o,this[6]=s,this[7]=a,this[8]=l,this.check()}setRowMajor(e,t,i,n,r,o,s,a,l){return this[0]=e,this[1]=n,this[2]=s,this[3]=t,this[4]=r,this[5]=a,this[6]=i,this[7]=o,this[8]=l,this.check()}determinant(){return function(e){const t=e[0],i=e[1],n=e[2],r=e[3],o=e[4],s=e[5],a=e[6],l=e[7],c=e[8];return t*(c*o-s*l)+i*(-c*r+s*a)+n*(l*r-o*a)}(this)}transpose(){return function(e,t){if(e===t){const i=t[1],n=t[2],r=t[5];e[1]=t[3],e[2]=t[6],e[3]=i,e[5]=t[7],e[6]=n,e[7]=r}else e[0]=t[0],e[1]=t[3],e[2]=t[6],e[3]=t[1],e[4]=t[4],e[5]=t[7],e[6]=t[2],e[7]=t[5],e[8]=t[8]}(this,this),this.check()}invert(){return function(e,t){const i=t[0],n=t[1],r=t[2],o=t[3],s=t[4],a=t[5],l=t[6],c=t[7],u=t[8],h=u*s-a*c,d=-u*o+a*l,p=c*o-s*l;let f=i*h+n*d+r*p;f&&(f=1/f,e[0]=h*f,e[1]=(-u*n+r*c)*f,e[2]=(a*n-r*s)*f,e[3]=d*f,e[4]=(u*i-r*l)*f,e[5]=(-a*i+r*o)*f,e[6]=p*f,e[7]=(-c*i+n*l)*f,e[8]=(s*i-n*o)*f)}(this,this),this.check()}multiplyLeft(e){return xA(this,e,this),this.check()}multiplyRight(e){return xA(this,this,e),this.check()}rotate(e){return function(e,t,i){const n=t[0],r=t[1],o=t[2],s=t[3],a=t[4],l=t[5],c=t[6],u=t[7],h=t[8],d=Math.sin(i),p=Math.cos(i);e[0]=p*n+d*s,e[1]=p*r+d*a,e[2]=p*o+d*l,e[3]=p*s-d*n,e[4]=p*a-d*r,e[5]=p*l-d*o,e[6]=c,e[7]=u,e[8]=h}(this,this,e),this.check()}scale(e){return Array.isArray(e)?bA(this,this,e):bA(this,this,[e,e]),this.check()}translate(e){return function(e,t,i){const n=t[0],r=t[1],o=t[2],s=t[3],a=t[4],l=t[5],c=t[6],u=t[7],h=t[8],d=i[0],p=i[1];e[0]=n,e[1]=r,e[2]=o,e[3]=s,e[4]=a,e[5]=l,e[6]=d*n+p*s+c,e[7]=d*r+p*a+u,e[8]=d*o+p*l+h}(this,this,e),this.check()}transform(e,t){let i;switch(e.length){case 2:i=J_(t||[-0,-0],e,this);break;case 3:i=uA(t||[-0,-0,-0],e,this);break;case 4:i=iA(t||[-0,-0,-0,-0],e,this);break;default:throw new Error("Illegal vector")}return H_(i,e.length),i}transformVector(e,t){return this.transform(e,t)}transformVector2(e,t){return this.transform(e,t)}transformVector3(e,t){return this.transform(e,t)}}let CA,SA=null;function BA(e,t){const i=t[0],n=t[1],r=t[2],o=t[3],s=t[4],a=t[5],l=t[6],c=t[7],u=t[8],h=t[9],d=t[10],p=t[11],f=t[12],m=t[13],g=t[14],_=t[15],A=i*a-n*s,y=i*l-r*s,v=i*c-o*s,x=n*l-r*a,b=n*c-o*a,w=r*c-o*l,T=u*m-h*f,E=u*g-d*f,C=u*_-p*f,S=h*g-d*m,B=h*_-p*m,I=d*_-p*g;let M=A*I-y*B+v*S+x*C-b*E+w*T;return M?(M=1/M,e[0]=(a*I-l*B+c*S)*M,e[1]=(r*B-n*I-o*S)*M,e[2]=(m*w-g*b+_*x)*M,e[3]=(d*b-h*w-p*x)*M,e[4]=(l*C-s*I-c*E)*M,e[5]=(i*I-r*C+o*E)*M,e[6]=(g*v-f*w-_*y)*M,e[7]=(u*w-d*v+p*y)*M,e[8]=(s*B-a*C+c*T)*M,e[9]=(n*C-i*B-o*T)*M,e[10]=(f*b-m*v+_*A)*M,e[11]=(h*v-u*b-p*A)*M,e[12]=(a*E-s*S-l*T)*M,e[13]=(i*S-n*E+r*T)*M,e[14]=(m*y-f*x-g*A)*M,e[15]=(u*x-h*y+d*A)*M,e):null}function IA(e,t,i){const n=t[0],r=t[1],o=t[2],s=t[3],a=t[4],l=t[5],c=t[6],u=t[7],h=t[8],d=t[9],p=t[10],f=t[11],m=t[12],g=t[13],_=t[14],A=t[15];let y=i[0],v=i[1],x=i[2],b=i[3];return e[0]=y*n+v*a+x*h+b*m,e[1]=y*r+v*l+x*d+b*g,e[2]=y*o+v*c+x*p+b*_,e[3]=y*s+v*u+x*f+b*A,y=i[4],v=i[5],x=i[6],b=i[7],e[4]=y*n+v*a+x*h+b*m,e[5]=y*r+v*l+x*d+b*g,e[6]=y*o+v*c+x*p+b*_,e[7]=y*s+v*u+x*f+b*A,y=i[8],v=i[9],x=i[10],b=i[11],e[8]=y*n+v*a+x*h+b*m,e[9]=y*r+v*l+x*d+b*g,e[10]=y*o+v*c+x*p+b*_,e[11]=y*s+v*u+x*f+b*A,y=i[12],v=i[13],x=i[14],b=i[15],e[12]=y*n+v*a+x*h+b*m,e[13]=y*r+v*l+x*d+b*g,e[14]=y*o+v*c+x*p+b*_,e[15]=y*s+v*u+x*f+b*A,e}function MA(e,t,i){const n=i[0],r=i[1],o=i[2];let s,a,l,c,u,h,d,p,f,m,g,_;return t===e?(e[12]=t[0]*n+t[4]*r+t[8]*o+t[12],e[13]=t[1]*n+t[5]*r+t[9]*o+t[13],e[14]=t[2]*n+t[6]*r+t[10]*o+t[14],e[15]=t[3]*n+t[7]*r+t[11]*o+t[15]):(s=t[0],a=t[1],l=t[2],c=t[3],u=t[4],h=t[5],d=t[6],p=t[7],f=t[8],m=t[9],g=t[10],_=t[11],e[0]=s,e[1]=a,e[2]=l,e[3]=c,e[4]=u,e[5]=h,e[6]=d,e[7]=p,e[8]=f,e[9]=m,e[10]=g,e[11]=_,e[12]=s*n+u*r+f*o+t[12],e[13]=a*n+h*r+m*o+t[13],e[14]=l*n+d*r+g*o+t[14],e[15]=c*n+p*r+_*o+t[15]),e}function PA(e,t,i){const 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 RA(e,t,i){const n=Math.sin(i),r=Math.cos(i),o=t[4],s=t[5],a=t[6],l=t[7],c=t[8],u=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+c*n,e[5]=s*r+u*n,e[6]=a*r+h*n,e[7]=l*r+d*n,e[8]=c*r-o*n,e[9]=u*r-s*n,e[10]=h*r-a*n,e[11]=d*r-l*n,e}function LA(e,t,i){const n=Math.sin(i),r=Math.cos(i),o=t[0],s=t[1],a=t[2],l=t[3],c=t[4],u=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+c*n,e[1]=s*r+u*n,e[2]=a*r+h*n,e[3]=l*r+d*n,e[4]=c*r-o*n,e[5]=u*r-s*n,e[6]=h*r-a*n,e[7]=d*r-l*n,e}const FA=function(e,t,i,n,r){const 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){const t=1/(n-r);e[10]=(r+n)*t,e[14]=2*r*n*t}else e[10]=-1,e[14]=-2*n;return e};const kA=function(e,t,i,n,r,o,s){const a=1/(t-i),l=1/(n-r),c=1/(o-s);return e[0]=-2*a,e[1]=0,e[2]=0,e[3]=0,e[4]=0,e[5]=-2*l,e[6]=0,e[7]=0,e[8]=0,e[9]=0,e[10]=2*c,e[11]=0,e[12]=(t+i)*a,e[13]=(r+n)*l,e[14]=(s+o)*c,e[15]=1,e};function DA(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 OA(e,t,i){const n=t[0],r=t[1],o=t[2],s=t[3];return e[0]=i[0]*n+i[4]*r+i[8]*o+i[12]*s,e[1]=i[1]*n+i[5]*r+i[9]*o+i[13]*s,e[2]=i[2]*n+i[6]*r+i[10]*o+i[14]*s,e[3]=i[3]*n+i[7]*r+i[11]*o+i[15]*s,e}var zA;!function(){const e=function(){const e=new W_(4);return W_!=Float32Array&&(e[0]=0,e[1]=0,e[2]=0,e[3]=0),e}()}(),function(e){e[e.COL0ROW0=0]="COL0ROW0",e[e.COL0ROW1=1]="COL0ROW1",e[e.COL0ROW2=2]="COL0ROW2",e[e.COL0ROW3=3]="COL0ROW3",e[e.COL1ROW0=4]="COL1ROW0",e[e.COL1ROW1=5]="COL1ROW1",e[e.COL1ROW2=6]="COL1ROW2",e[e.COL1ROW3=7]="COL1ROW3",e[e.COL2ROW0=8]="COL2ROW0",e[e.COL2ROW1=9]="COL2ROW1",e[e.COL2ROW2=10]="COL2ROW2",e[e.COL2ROW3=11]="COL2ROW3",e[e.COL3ROW0=12]="COL3ROW0",e[e.COL3ROW1=13]="COL3ROW1",e[e.COL3ROW2=14]="COL3ROW2",e[e.COL3ROW3=15]="COL3ROW3"}(zA||(zA={}));const UA=45*Math.PI/180,NA=1,VA=.1,jA=500,GA=Object.freeze([1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1]);class HA extends vA{static get IDENTITY(){return function(){$A||($A=new HA,Object.freeze($A));return $A}()}static get ZERO(){return function(){QA||(QA=new HA([0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0]),Object.freeze(QA));return QA}()}get ELEMENTS(){return 16}get RANK(){return 4}get INDICES(){return zA}constructor(e){super(-0,-0,-0,-0,-0,-0,-0,-0,-0,-0,-0,-0,-0,-0,-0,-0),1===arguments.length&&Array.isArray(e)?this.copy(e):this.identity()}copy(e){return this[0]=e[0],this[1]=e[1],this[2]=e[2],this[3]=e[3],this[4]=e[4],this[5]=e[5],this[6]=e[6],this[7]=e[7],this[8]=e[8],this[9]=e[9],this[10]=e[10],this[11]=e[11],this[12]=e[12],this[13]=e[13],this[14]=e[14],this[15]=e[15],this.check()}set(e,t,i,n,r,o,s,a,l,c,u,h,d,p,f,m){return this[0]=e,this[1]=t,this[2]=i,this[3]=n,this[4]=r,this[5]=o,this[6]=s,this[7]=a,this[8]=l,this[9]=c,this[10]=u,this[11]=h,this[12]=d,this[13]=p,this[14]=f,this[15]=m,this.check()}setRowMajor(e,t,i,n,r,o,s,a,l,c,u,h,d,p,f,m){return this[0]=e,this[1]=r,this[2]=l,this[3]=d,this[4]=t,this[5]=o,this[6]=c,this[7]=p,this[8]=i,this[9]=s,this[10]=u,this[11]=f,this[12]=n,this[13]=a,this[14]=h,this[15]=m,this.check()}toRowMajor(e){return e[0]=this[0],e[1]=this[4],e[2]=this[8],e[3]=this[12],e[4]=this[1],e[5]=this[5],e[6]=this[9],e[7]=this[13],e[8]=this[2],e[9]=this[6],e[10]=this[10],e[11]=this[14],e[12]=this[3],e[13]=this[7],e[14]=this[11],e[15]=this[15],e}identity(){return this.copy(GA)}fromObject(e){return this.check()}fromQuaternion(e){return function(e,t){const i=t[0],n=t[1],r=t[2],o=t[3],s=i+i,a=n+n,l=r+r,c=i*s,u=n*s,h=n*a,d=r*s,p=r*a,f=r*l,m=o*s,g=o*a,_=o*l;e[0]=1-h-f,e[1]=u+_,e[2]=d-g,e[3]=0,e[4]=u-_,e[5]=1-c-f,e[6]=p+m,e[7]=0,e[8]=d+g,e[9]=p-m,e[10]=1-c-h,e[11]=0,e[12]=0,e[13]=0,e[14]=0,e[15]=1}(this,e),this.check()}frustum(e){const{left:t,right:i,bottom:n,top:r,near:o=VA,far:s=jA}=e;return s===1/0?function(e,t,i,n,r,o){const s=2*o/(i-t),a=2*o/(r-n),l=(i+t)/(i-t),c=(r+n)/(r-n),u=-1,h=-1,d=-2*o;e[0]=s,e[1]=0,e[2]=0,e[3]=0,e[4]=0,e[5]=a,e[6]=0,e[7]=0,e[8]=l,e[9]=c,e[10]=u,e[11]=h,e[12]=0,e[13]=0,e[14]=d,e[15]=0}(this,t,i,n,r,o):function(e,t,i,n,r,o,s){const a=1/(i-t),l=1/(r-n),c=1/(o-s);e[0]=2*o*a,e[1]=0,e[2]=0,e[3]=0,e[4]=0,e[5]=2*o*l,e[6]=0,e[7]=0,e[8]=(i+t)*a,e[9]=(r+n)*l,e[10]=(s+o)*c,e[11]=-1,e[12]=0,e[13]=0,e[14]=s*o*2*c,e[15]=0}(this,t,i,n,r,o,s),this.check()}lookAt(e){const{eye:t,center:i=[0,0,0],up:n=[0,1,0]}=e;return function(e,t,i,n){let r,o,s,a,l,c,u,h,d,p;const f=t[0],m=t[1],g=t[2],_=n[0],A=n[1],y=n[2],v=i[0],x=i[1],b=i[2];Math.abs(f-v)2*Math.PI)throw Error("expected radians")}function WA(){const e=new W_(4);return W_!=Float32Array&&(e[0]=0,e[1]=0,e[2]=0),e[3]=1,e}function qA(e,t,i){i*=.5;const n=Math.sin(i);return e[0]=n*t[0],e[1]=n*t[1],e[2]=n*t[2],e[3]=Math.cos(i),e}function KA(e,t,i){const n=t[0],r=t[1],o=t[2],s=t[3],a=i[0],l=i[1],c=i[2],u=i[3];return e[0]=n*u+s*a+r*c-o*l,e[1]=r*u+s*l+o*a-n*c,e[2]=o*u+s*c+n*l-r*a,e[3]=s*u-n*a-r*l-o*c,e}function XA(e,t,i,n){const r=t[0],o=t[1],s=t[2],a=t[3];let l,c,u,h,d,p=i[0],f=i[1],m=i[2],g=i[3];return l=r*p+o*f+s*m+a*g,l<0&&(l=-l,p=-p,f=-f,m=-m,g=-g),1-l>Z_?(c=Math.acos(l),d=Math.sin(c),u=Math.sin((1-n)*c)/d,h=Math.sin(n*c)/d):(u=1-n,h=n),e[0]=u*r+h*p,e[1]=u*o+h*f,e[2]=u*s+h*m,e[3]=u*a+h*g,e}function JA(e,t){const i=t[0]+t[4]+t[8];let n;if(i>0)n=Math.sqrt(i+1),e[3]=.5*n,n=.5/n,e[0]=(t[5]-t[7])*n,e[1]=(t[6]-t[2])*n,e[2]=(t[1]-t[3])*n;else{let i=0;t[4]>t[0]&&(i=1),t[8]>t[3*i+i]&&(i=2);const r=(i+1)%3,o=(i+2)%3;n=Math.sqrt(t[3*i+i]-t[3*r+r]-t[3*o+o]+1),e[i]=.5*n,n=.5/n,e[3]=(t[3*r+o]-t[3*o+r])*n,e[r]=(t[3*r+i]+t[3*i+r])*n,e[o]=(t[3*o+i]+t[3*i+o])*n}return e}const YA=function(e,t,i){return e[0]=t[0]+i[0],e[1]=t[1]+i[1],e[2]=t[2]+i[2],e[3]=t[3]+i[3],e},ey=DA,ty=function(e,t){return e[0]*t[0]+e[1]*t[1]+e[2]*t[2]+e[3]*t[3]},iy=function(e,t,i,n){const r=t[0],o=t[1],s=t[2],a=t[3];return e[0]=r+n*(i[0]-r),e[1]=o+n*(i[1]-o),e[2]=s+n*(i[2]-s),e[3]=a+n*(i[3]-a),e},ny=function(e){const t=e[0],i=e[1],n=e[2],r=e[3];return Math.sqrt(t*t+i*i+n*n+r*r)},ry=function(e){const t=e[0],i=e[1],n=e[2],r=e[3];return t*t+i*i+n*n+r*r},oy=function(e,t){const i=t[0],n=t[1],r=t[2],o=t[3];let s=i*i+n*n+r*r+o*o;return s>0&&(s=1/Math.sqrt(s)),e[0]=i*s,e[1]=n*s,e[2]=r*s,e[3]=o*s,e},sy=function(){const e=rA(),t=sA(1,0,0),i=sA(0,1,0);return function(n,r,o){const s=aA(r,o);return s<-.999999?(lA(e,t,r),pA(e)<1e-6&&lA(e,i,r),function(e,t){const i=t[0],n=t[1],r=t[2];let o=i*i+n*n+r*r;o>0&&(o=1/Math.sqrt(o)),e[0]=t[0]*o,e[1]=t[1]*o,e[2]=t[2]*o}(e,e),qA(n,e,Math.PI),n):s>.999999?(n[0]=0,n[1]=0,n[2]=0,n[3]=1,n):(lA(e,r,o),n[0]=e[0],n[1]=e[1],n[2]=e[2],n[3]=1+s,oy(n,n))}}();!function(){const e=WA(),t=WA()}(),function(){const e=function(){const e=new W_(9);return W_!=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}()}();const ay=[0,0,0,1];class ly extends j_{constructor(e=0,t=0,i=0,n=1){super(-0,-0,-0,-0),Array.isArray(e)&&1===arguments.length?this.copy(e):this.set(e,t,i,n)}copy(e){return this[0]=e[0],this[1]=e[1],this[2]=e[2],this[3]=e[3],this.check()}set(e,t,i,n){return this[0]=e,this[1]=t,this[2]=i,this[3]=n,this.check()}fromObject(e){return this[0]=e.x,this[1]=e.y,this[2]=e.z,this[3]=e.w,this.check()}fromMatrix3(e){return JA(this,e),this.check()}fromAxisRotation(e,t){return qA(this,e,t),this.check()}identity(){var e;return(e=this)[0]=0,e[1]=0,e[2]=0,e[3]=1,this.check()}setAxisAngle(e,t){return this.fromAxisRotation(e,t)}get ELEMENTS(){return 4}get x(){return this[0]}set x(e){this[0]=G_(e)}get y(){return this[1]}set y(e){this[1]=G_(e)}get z(){return this[2]}set z(e){this[2]=G_(e)}get w(){return this[3]}set w(e){this[3]=G_(e)}len(){return ny(this)}lengthSquared(){return ry(this)}dot(e){return ty(this,e)}rotationTo(e,t){return sy(this,e,t),this.check()}add(e){return YA(this,this,e),this.check()}calculateW(){return function(e,t){const i=t[0],n=t[1],r=t[2];e[0]=i,e[1]=n,e[2]=r,e[3]=Math.sqrt(Math.abs(1-i*i-n*n-r*r))}(this,this),this.check()}conjugate(){return function(e,t){e[0]=-t[0],e[1]=-t[1],e[2]=-t[2],e[3]=t[3]}(this,this),this.check()}invert(){return function(e,t){const i=t[0],n=t[1],r=t[2],o=t[3],s=i*i+n*n+r*r+o*o,a=s?1/s:0;e[0]=-i*a,e[1]=-n*a,e[2]=-r*a,e[3]=o*a}(this,this),this.check()}lerp(e,t,i){return void 0===i?this.lerp(this,e,t):(iy(this,e,t,i),this.check())}multiplyRight(e){return KA(this,this,e),this.check()}multiplyLeft(e){return KA(this,e,this),this.check()}normalize(){const e=this.len(),t=e>0?1/e:0;return this[0]=this[0]*t,this[1]=this[1]*t,this[2]=this[2]*t,this[3]=this[3]*t,0===e&&(this[3]=1),this.check()}rotateX(e){return function(e,t,i){i*=.5;const n=t[0],r=t[1],o=t[2],s=t[3],a=Math.sin(i),l=Math.cos(i);e[0]=n*l+s*a,e[1]=r*l+o*a,e[2]=o*l-r*a,e[3]=s*l-n*a}(this,this,e),this.check()}rotateY(e){return function(e,t,i){i*=.5;const n=t[0],r=t[1],o=t[2],s=t[3],a=Math.sin(i),l=Math.cos(i);e[0]=n*l-o*a,e[1]=r*l+s*a,e[2]=o*l+n*a,e[3]=s*l-r*a}(this,this,e),this.check()}rotateZ(e){return function(e,t,i){i*=.5;const n=t[0],r=t[1],o=t[2],s=t[3],a=Math.sin(i),l=Math.cos(i);e[0]=n*l+r*a,e[1]=r*l-n*a,e[2]=o*l+s*a,e[3]=s*l-o*a}(this,this,e),this.check()}scale(e){return ey(this,this,e),this.check()}slerp(e,t,i){let n,r,o;switch(arguments.length){case 1:({start:n=ay,target:r,ratio:o}=e);break;case 2:n=this,r=e,o=t;break;default:n=e,r=t,o=i}return XA(this,n,r,o),this.check()}transformVector4(e,t=new yA){return function(e,t,i){const n=t[0],r=t[1],o=t[2],s=i[0],a=i[1],l=i[2],c=i[3],u=c*n+a*o-l*r,h=c*r+l*n-s*o,d=c*o+s*r-a*n,p=-s*n-a*r-l*o;e[0]=u*c+p*-s+h*-l-d*-a,e[1]=h*c+p*-a+d*-s-u*-l,e[2]=d*c+p*-l+u*-a-h*-s,e[3]=t[3]}(t,e,this),H_(t,4)}lengthSq(){return this.lengthSquared()}setFromAxisAngle(e,t){return this.setAxisAngle(e,t)}premultiply(e){return this.multiplyLeft(e)}multiply(e){return this.multiplyRight(e)}}const cy="#if (defined(SHADER_TYPE_FRAGMENT) && defined(LIGHTING_FRAGMENT)) || (defined(SHADER_TYPE_VERTEX) && defined(LIGHTING_VERTEX))\nstruct AmbientLight {\nvec3 color;\n};\nstruct PointLight {\nvec3 color;\nvec3 position;\nvec3 attenuation;\n};\nstruct DirectionalLight {\nvec3 color;\nvec3 direction;\n};\nuniform AmbientLight lighting_uAmbientLight;\nuniform PointLight lighting_uPointLight[MAX_LIGHTS];\nuniform DirectionalLight lighting_uDirectionalLight[MAX_LIGHTS];\nuniform int lighting_uPointLightCount;\nuniform int lighting_uDirectionalLightCount;\nuniform bool lighting_uEnabled;\nfloat getPointLightAttenuation(PointLight pointLight, float distance) {\nreturn pointLight.attenuation.x\n+ pointLight.attenuation.y * distance\n+ pointLight.attenuation.z * distance * distance;\n}\n#endif\n",uy={lightSources:{}};function hy(e={}){const{color:t=[0,0,0],intensity:i=1}=e;return t.map(e=>e*i/255)}const dy={name:"lights",vs:cy,fs:cy,getUniforms:function e(t=uy){if("lightSources"in t){const{ambientLight:e,pointLights:i,directionalLights:n}=t.lightSources||{};return e||i&&i.length>0||n&&n.length>0?Object.assign({},function({ambientLight:e,pointLights:t=[],directionalLights:i=[]}){const n={};return n["lighting_uAmbientLight.color"]=e?hy(e):[0,0,0],t.forEach((e,t)=>{n[`lighting_uPointLight[${t}].color`]=hy(e),n[`lighting_uPointLight[${t}].position`]=e.position,n[`lighting_uPointLight[${t}].attenuation`]=e.attenuation||[1,0,0]}),n.lighting_uPointLightCount=t.length,i.forEach((e,t)=>{n[`lighting_uDirectionalLight[${t}].color`]=hy(e),n[`lighting_uDirectionalLight[${t}].direction`]=e.direction}),n.lighting_uDirectionalLightCount=i.length,n}({ambientLight:e,pointLights:i,directionalLights:n}),{lighting_uEnabled:!0}):{lighting_uEnabled:!1}}if("lights"in t){const i={pointLights:[],directionalLights:[]};for(const e of t.lights||[])switch(e.type){case"ambient":i.ambientLight=e;break;case"directional":i.directionalLights?.push(e);break;case"point":i.pointLights?.push(e)}return e({lightSources:i})}return{}},defines:{MAX_LIGHTS:3}},py="uniform float lighting_uAmbient;\nuniform float lighting_uDiffuse;\nuniform float lighting_uShininess;\nuniform vec3 lighting_uSpecularColor;\nvec3 lighting_getLightColor(vec3 surfaceColor, vec3 light_direction, vec3 view_direction, vec3 normal_worldspace, vec3 color) {\nvec3 halfway_direction = normalize(light_direction + view_direction);\nfloat lambertian = dot(light_direction, normal_worldspace);\nfloat specular = 0.0;\nif (lambertian > 0.0) {\nfloat specular_angle = max(dot(normal_worldspace, halfway_direction), 0.0);\nspecular = pow(specular_angle, lighting_uShininess);\n}\nlambertian = max(lambertian, 0.0);\nreturn (lambertian * lighting_uDiffuse * surfaceColor + specular * lighting_uSpecularColor) * color;\n}\nvec3 lighting_getLightColor(vec3 surfaceColor, vec3 cameraPosition, vec3 position_worldspace, vec3 normal_worldspace) {\nvec3 lightColor = surfaceColor;\nif (lighting_uEnabled) {\nvec3 view_direction = normalize(cameraPosition - position_worldspace);\nlightColor = lighting_uAmbient * surfaceColor * lighting_uAmbientLight.color;\nfor (int i = 0; i < MAX_LIGHTS; i++) {\nif (i >= lighting_uPointLightCount) {\nbreak;\n}\nPointLight pointLight = lighting_uPointLight[i];\nvec3 light_position_worldspace = pointLight.position;\nvec3 light_direction = normalize(light_position_worldspace - position_worldspace);\nlightColor += lighting_getLightColor(surfaceColor, light_direction, view_direction, normal_worldspace, pointLight.color);\n}\nfor (int i = 0; i < MAX_LIGHTS; i++) {\nif (i >= lighting_uDirectionalLightCount) {\nbreak;\n}\nDirectionalLight directionalLight = lighting_uDirectionalLight[i];\nlightColor += lighting_getLightColor(surfaceColor, -directionalLight.direction, view_direction, normal_worldspace, directionalLight.color);\n}\n}\nreturn lightColor;\n}\nvec3 lighting_getSpecularLightColor(vec3 cameraPosition, vec3 position_worldspace, vec3 normal_worldspace) {\nvec3 lightColor = vec3(0, 0, 0);\nvec3 surfaceColor = vec3(0, 0, 0);\nif (lighting_uEnabled) {\nvec3 view_direction = normalize(cameraPosition - position_worldspace);\nfor (int i = 0; i < MAX_LIGHTS; i++) {\nif (i >= lighting_uPointLightCount) {\nbreak;\n}\nPointLight pointLight = lighting_uPointLight[i];\nvec3 light_position_worldspace = pointLight.position;\nvec3 light_direction = normalize(light_position_worldspace - position_worldspace);\nlightColor += lighting_getLightColor(surfaceColor, light_direction, view_direction, normal_worldspace, pointLight.color);\n}\nfor (int i = 0; i < MAX_LIGHTS; i++) {\nif (i >= lighting_uDirectionalLightCount) {\nbreak;\n}\nDirectionalLight directionalLight = lighting_uDirectionalLight[i];\nlightColor += lighting_getLightColor(surfaceColor, -directionalLight.direction, view_direction, normal_worldspace, directionalLight.color);\n}\n}\nreturn lightColor;\n}\n",fy={};function my(e=fy){if(!("material"in e))return{};const{material:t}=e;return t?function(e){const{ambient:t=.35,diffuse:i=.6,shininess:n=32,specularColor:r=[30,30,30]}=e;return{lighting_uAmbient:t,lighting_uDiffuse:i,lighting_uShininess:n,lighting_uSpecularColor:r.map(e=>e/255)}}(t):{lighting_uEnabled:!1}}const gy={name:"gouraud-lighting",dependencies:[dy],vs:py,defines:{LIGHTING_VERTEX:1},getUniforms:my},_y={name:"phong-lighting",dependencies:[dy],fs:py,defines:{LIGHTING_FRAGMENT:1},getUniforms:my},Ay={name:"pbr",vs:"uniform mat4 u_MVPMatrix;\nuniform mat4 u_ModelMatrix;\nuniform mat4 u_NormalMatrix;\nout vec3 pbr_vPosition;\nout vec2 pbr_vUV;\n#ifdef HAS_NORMALS\n# ifdef HAS_TANGENTS\nout mat3 pbr_vTBN;\n# else\nout vec3 pbr_vNormal;\n# endif\n#endif\nvoid pbr_setPositionNormalTangentUV(vec4 position, vec4 normal, vec4 tangent, vec2 uv)\n{\nvec4 pos = u_ModelMatrix * position;\npbr_vPosition = vec3(pos.xyz) / pos.w;\n#ifdef HAS_NORMALS\n#ifdef HAS_TANGENTS\nvec3 normalW = normalize(vec3(u_NormalMatrix * vec4(normal.xyz, 0.0)));\nvec3 tangentW = normalize(vec3(u_ModelMatrix * vec4(tangent.xyz, 0.0)));\nvec3 bitangentW = cross(normalW, tangentW) * tangent.w;\npbr_vTBN = mat3(tangentW, bitangentW, normalW);\n#else\npbr_vNormal = normalize(vec3(u_ModelMatrix * vec4(normal.xyz, 0.0)));\n#endif\n#endif\n#ifdef HAS_UV\npbr_vUV = uv;\n#else\npbr_vUV = vec2(0.,0.);\n#endif\n}\n",fs:"precision highp float;\nuniform bool pbr_uUnlit;\n#ifdef USE_IBL\nuniform samplerCube u_DiffuseEnvSampler;\nuniform samplerCube u_SpecularEnvSampler;\nuniform sampler2D u_brdfLUT;\nuniform vec2 u_ScaleIBLAmbient;\n#endif\n#ifdef HAS_BASECOLORMAP\nuniform sampler2D u_BaseColorSampler;\n#endif\n#ifdef HAS_NORMALMAP\nuniform sampler2D u_NormalSampler;\nuniform float u_NormalScale;\n#endif\n#ifdef HAS_EMISSIVEMAP\nuniform sampler2D u_EmissiveSampler;\nuniform vec3 u_EmissiveFactor;\n#endif\n#ifdef HAS_METALROUGHNESSMAP\nuniform sampler2D u_MetallicRoughnessSampler;\n#endif\n#ifdef HAS_OCCLUSIONMAP\nuniform sampler2D u_OcclusionSampler;\nuniform float u_OcclusionStrength;\n#endif\n#ifdef ALPHA_CUTOFF\nuniform float u_AlphaCutoff;\n#endif\nuniform vec2 u_MetallicRoughnessValues;\nuniform vec4 u_BaseColorFactor;\nuniform vec3 u_Camera;\n#ifdef PBR_DEBUG\nuniform vec4 u_ScaleDiffBaseMR;\nuniform vec4 u_ScaleFGDSpec;\n#endif\nin vec3 pbr_vPosition;\nin vec2 pbr_vUV;\n#ifdef HAS_NORMALS\n#ifdef HAS_TANGENTS\nin mat3 pbr_vTBN;\n#else\nin vec3 pbr_vNormal;\n#endif\n#endif\nstruct PBRInfo\n{\nfloat NdotL;\nfloat NdotV;\nfloat NdotH;\nfloat LdotH;\nfloat VdotH;\nfloat perceptualRoughness;\nfloat metalness;\nvec3 reflectance0;\nvec3 reflectance90;\nfloat alphaRoughness;\nvec3 diffuseColor;\nvec3 specularColor;\nvec3 n;\nvec3 v;\n};\nconst float M_PI = 3.141592653589793;\nconst float c_MinRoughness = 0.04;\nvec4 SRGBtoLINEAR(vec4 srgbIn)\n{\n#ifdef MANUAL_SRGB\n#ifdef SRGB_FAST_APPROXIMATION\nvec3 linOut = pow(srgbIn.xyz,vec3(2.2));\n#else\nvec3 bLess = step(vec3(0.04045),srgbIn.xyz);\nvec3 linOut = mix( srgbIn.xyz/vec3(12.92), pow((srgbIn.xyz+vec3(0.055))/vec3(1.055),vec3(2.4)), bLess );\n#endif\nreturn vec4(linOut,srgbIn.w);;\n#else\nreturn srgbIn;\n#endif\n}\nvec3 getNormal()\n{\n#ifndef HAS_TANGENTS\nvec3 pos_dx = dFdx(pbr_vPosition);\nvec3 pos_dy = dFdy(pbr_vPosition);\nvec3 tex_dx = dFdx(vec3(pbr_vUV, 0.0));\nvec3 tex_dy = dFdy(vec3(pbr_vUV, 0.0));\nvec3 t = (tex_dy.t * pos_dx - tex_dx.t * pos_dy) / (tex_dx.s * tex_dy.t - tex_dy.s * tex_dx.t);\n#ifdef HAS_NORMALS\nvec3 ng = normalize(pbr_vNormal);\n#else\nvec3 ng = cross(pos_dx, pos_dy);\n#endif\nt = normalize(t - ng * dot(ng, t));\nvec3 b = normalize(cross(ng, t));\nmat3 tbn = mat3(t, b, ng);\n#else\nmat3 tbn = pbr_vTBN;\n#endif\n#ifdef HAS_NORMALMAP\nvec3 n = texture(u_NormalSampler, pbr_vUV).rgb;\nn = normalize(tbn * ((2.0 * n - 1.0) * vec3(u_NormalScale, u_NormalScale, 1.0)));\n#else\nvec3 n = normalize(tbn[2].xyz);\n#endif\nreturn n;\n}\n#ifdef USE_IBL\nvec3 getIBLContribution(PBRInfo pbrInputs, vec3 n, vec3 reflection)\n{\nfloat mipCount = 9.0;\nfloat lod = (pbrInputs.perceptualRoughness * mipCount);\nvec3 brdf = SRGBtoLINEAR(texture(u_brdfLUT,\nvec2(pbrInputs.NdotV, 1.0 - pbrInputs.perceptualRoughness))).rgb;\nvec3 diffuseLight = SRGBtoLINEAR(textureCube(u_DiffuseEnvSampler, n)).rgb;\n#ifdef USE_TEX_LOD\nvec3 specularLight = SRGBtoLINEAR(textureCubeLod(u_SpecularEnvSampler, reflection, lod)).rgb;\n#else\nvec3 specularLight = SRGBtoLINEAR(textureCube(u_SpecularEnvSampler, reflection)).rgb;\n#endif\nvec3 diffuse = diffuseLight * pbrInputs.diffuseColor;\nvec3 specular = specularLight * (pbrInputs.specularColor * brdf.x + brdf.y);\ndiffuse *= u_ScaleIBLAmbient.x;\nspecular *= u_ScaleIBLAmbient.y;\nreturn diffuse + specular;\n}\n#endif\nvec3 diffuse(PBRInfo pbrInputs)\n{\nreturn pbrInputs.diffuseColor / M_PI;\n}\nvec3 specularReflection(PBRInfo pbrInputs)\n{\nreturn pbrInputs.reflectance0 +\n(pbrInputs.reflectance90 - pbrInputs.reflectance0) *\npow(clamp(1.0 - pbrInputs.VdotH, 0.0, 1.0), 5.0);\n}\nfloat geometricOcclusion(PBRInfo pbrInputs)\n{\nfloat NdotL = pbrInputs.NdotL;\nfloat NdotV = pbrInputs.NdotV;\nfloat r = pbrInputs.alphaRoughness;\nfloat attenuationL = 2.0 * NdotL / (NdotL + sqrt(r * r + (1.0 - r * r) * (NdotL * NdotL)));\nfloat attenuationV = 2.0 * NdotV / (NdotV + sqrt(r * r + (1.0 - r * r) * (NdotV * NdotV)));\nreturn attenuationL * attenuationV;\n}\nfloat microfacetDistribution(PBRInfo pbrInputs)\n{\nfloat roughnessSq = pbrInputs.alphaRoughness * pbrInputs.alphaRoughness;\nfloat f = (pbrInputs.NdotH * roughnessSq - pbrInputs.NdotH) * pbrInputs.NdotH + 1.0;\nreturn roughnessSq / (M_PI * f * f);\n}\nvoid PBRInfo_setAmbientLight(inout PBRInfo pbrInputs) {\npbrInputs.NdotL = 1.0;\npbrInputs.NdotH = 0.0;\npbrInputs.LdotH = 0.0;\npbrInputs.VdotH = 1.0;\n}\nvoid PBRInfo_setDirectionalLight(inout PBRInfo pbrInputs, vec3 lightDirection) {\nvec3 n = pbrInputs.n;\nvec3 v = pbrInputs.v;\nvec3 l = normalize(lightDirection);\nvec3 h = normalize(l+v);\npbrInputs.NdotL = clamp(dot(n, l), 0.001, 1.0);\npbrInputs.NdotH = clamp(dot(n, h), 0.0, 1.0);\npbrInputs.LdotH = clamp(dot(l, h), 0.0, 1.0);\npbrInputs.VdotH = clamp(dot(v, h), 0.0, 1.0);\n}\nvoid PBRInfo_setPointLight(inout PBRInfo pbrInputs, PointLight pointLight) {\nvec3 light_direction = normalize(pointLight.position - pbr_vPosition);\nPBRInfo_setDirectionalLight(pbrInputs, light_direction);\n}\nvec3 calculateFinalColor(PBRInfo pbrInputs, vec3 lightColor) {\nvec3 F = specularReflection(pbrInputs);\nfloat G = geometricOcclusion(pbrInputs);\nfloat D = microfacetDistribution(pbrInputs);\nvec3 diffuseContrib = (1.0 - F) * diffuse(pbrInputs);\nvec3 specContrib = F * G * D / (4.0 * pbrInputs.NdotL * pbrInputs.NdotV);\nreturn pbrInputs.NdotL * lightColor * (diffuseContrib + specContrib);\n}\nvec4 pbr_filterColor(vec4 colorUnused)\n{\n#ifdef HAS_BASECOLORMAP\nvec4 baseColor = SRGBtoLINEAR(texture(u_BaseColorSampler, pbr_vUV)) * u_BaseColorFactor;\n#else\nvec4 baseColor = u_BaseColorFactor;\n#endif\n#ifdef ALPHA_CUTOFF\nif (baseColor.a < u_AlphaCutoff) {\ndiscard;\n}\n#endif\nvec3 color = vec3(0, 0, 0);\nif(pbr_uUnlit){\ncolor.rgb = baseColor.rgb;\n}\nelse{\nfloat perceptualRoughness = u_MetallicRoughnessValues.y;\nfloat metallic = u_MetallicRoughnessValues.x;\n#ifdef HAS_METALROUGHNESSMAP\nvec4 mrSample = texture(u_MetallicRoughnessSampler, pbr_vUV);\nperceptualRoughness = mrSample.g * perceptualRoughness;\nmetallic = mrSample.b * metallic;\n#endif\nperceptualRoughness = clamp(perceptualRoughness, c_MinRoughness, 1.0);\nmetallic = clamp(metallic, 0.0, 1.0);\nfloat alphaRoughness = perceptualRoughness * perceptualRoughness;\nvec3 f0 = vec3(0.04);\nvec3 diffuseColor = baseColor.rgb * (vec3(1.0) - f0);\ndiffuseColor *= 1.0 - metallic;\nvec3 specularColor = mix(f0, baseColor.rgb, metallic);\nfloat reflectance = max(max(specularColor.r, specularColor.g), specularColor.b);\nfloat reflectance90 = clamp(reflectance * 25.0, 0.0, 1.0);\nvec3 specularEnvironmentR0 = specularColor.rgb;\nvec3 specularEnvironmentR90 = vec3(1.0, 1.0, 1.0) * reflectance90;\nvec3 n = getNormal();\nvec3 v = normalize(u_Camera - pbr_vPosition);\nfloat NdotV = clamp(abs(dot(n, v)), 0.001, 1.0);\nvec3 reflection = -normalize(reflect(v, n));\nPBRInfo pbrInputs = PBRInfo(\n0.0,\nNdotV,\n0.0,\n0.0,\n0.0,\nperceptualRoughness,\nmetallic,\nspecularEnvironmentR0,\nspecularEnvironmentR90,\nalphaRoughness,\ndiffuseColor,\nspecularColor,\nn,\nv\n);\n#ifdef USE_LIGHTS\nPBRInfo_setAmbientLight(pbrInputs);\ncolor += calculateFinalColor(pbrInputs, lighting_uAmbientLight.color);\nfor(int i = 0; i < lighting_uDirectionalLightCount; i++) {\nif (i < lighting_uDirectionalLightCount) {\nPBRInfo_setDirectionalLight(pbrInputs, lighting_uDirectionalLight[i].direction);\ncolor += calculateFinalColor(pbrInputs, lighting_uDirectionalLight[i].color);\n}\n}\nfor(int i = 0; i < lighting_uPointLightCount; i++) {\nif (i < lighting_uPointLightCount) {\nPBRInfo_setPointLight(pbrInputs, lighting_uPointLight[i]);\nfloat attenuation = getPointLightAttenuation(lighting_uPointLight[i], distance(lighting_uPointLight[i].position, pbr_vPosition));\ncolor += calculateFinalColor(pbrInputs, lighting_uPointLight[i].color / attenuation);\n}\n}\n#endif\n#ifdef USE_IBL\ncolor += getIBLContribution(pbrInputs, n, reflection);\n#endif\n#ifdef HAS_OCCLUSIONMAP\nfloat ao = texture(u_OcclusionSampler, pbr_vUV).r;\ncolor = mix(color, color * ao, u_OcclusionStrength);\n#endif\n#ifdef HAS_EMISSIVEMAP\nvec3 emissive = SRGBtoLINEAR(texture(u_EmissiveSampler, pbr_vUV)).rgb * u_EmissiveFactor;\ncolor += emissive;\n#endif\n#ifdef PBR_DEBUG\ncolor = mix(color, baseColor.rgb, u_ScaleDiffBaseMR.y);\ncolor = mix(color, vec3(metallic), u_ScaleDiffBaseMR.z);\ncolor = mix(color, vec3(perceptualRoughness), u_ScaleDiffBaseMR.w);\n#endif\n}\nreturn vec4(pow(color,vec3(1.0/2.2)), baseColor.a);\n}\n",defines:{LIGHTING_FRAGMENT:1},dependencies:[dy]},yy="#define SMOOTH_EDGE_RADIUS 0.5";var vy={name:"geometry",vs:`\n${yy}\n\nstruct VertexGeometry {\n vec4 position;\n vec3 worldPosition;\n vec3 worldPositionAlt;\n vec3 normal;\n vec2 uv;\n vec3 pickingColor;\n} geometry = VertexGeometry(\n vec4(0.0, 0.0, 1.0, 0.0),\n vec3(0.0),\n vec3(0.0),\n vec3(0.0),\n vec2(0.0),\n vec3(0.0)\n);\n`,fs:`\n${yy}\n\nstruct FragmentGeometry {\n vec2 uv;\n} geometry;\n\nfloat smoothedge(float edge, float x) {\n return smoothstep(edge - SMOOTH_EDGE_RADIUS, edge + SMOOTH_EDGE_RADIUS, x);\n}\n`};const xy={DEFAULT:-1,LNGLAT:1,METER_OFFSETS:2,LNGLAT_OFFSETS:3,CARTESIAN:0};Object.defineProperty(xy,"IDENTITY",{get:()=>(rp.deprecated("COORDINATE_SYSTEM.IDENTITY","COORDINATE_SYSTEM.CARTESIAN")(),0)});const by={WEB_MERCATOR:1,GLOBE:2,WEB_MERCATOR_AUTO_OFFSET:4,IDENTITY:0},wy={common:0,meters:1,pixels:2},Ty={click:{handler:"onClick"},panstart:{handler:"onDragStart"},panmove:{handler:"onDrag"},panend:{handler:"onDragEnd"}};var Ey=`${Object.keys(xy).map(e=>`const int COORDINATE_SYSTEM_${e} = ${xy[e]};`).join("")}\n${Object.keys(by).map(e=>`const int PROJECTION_MODE_${e} = ${by[e]};`).join("")}\n${Object.keys(wy).map(e=>`const int UNIT_${e.toUpperCase()} = ${wy[e]};`).join("")}\nuniform int project_uCoordinateSystem;\nuniform int project_uProjectionMode;\nuniform float project_uScale;\nuniform bool project_uWrapLongitude;\nuniform vec3 project_uCommonUnitsPerMeter;\nuniform vec3 project_uCommonUnitsPerWorldUnit;\nuniform vec3 project_uCommonUnitsPerWorldUnit2;\nuniform vec4 project_uCenter;\nuniform mat4 project_uModelMatrix;\nuniform mat4 project_uViewProjectionMatrix;\nuniform vec2 project_uViewportSize;\nuniform float project_uDevicePixelRatio;\nuniform float project_uFocalDistance;\nuniform vec3 project_uCameraPosition;\nuniform vec3 project_uCoordinateOrigin;\nuniform vec3 project_uCommonOrigin;\nuniform bool project_uPseudoMeters;\nconst float TILE_SIZE = 512.0;\nconst float PI = 3.1415926536;\nconst float WORLD_SCALE = TILE_SIZE / (PI * 2.0);\nconst vec3 ZERO_64_LOW = vec3(0.0);\nconst float EARTH_RADIUS = 6370972.0;\nconst float GLOBE_RADIUS = 256.0;\nfloat project_size_at_latitude(float lat) {\nfloat y = clamp(lat, -89.9, 89.9);\nreturn 1.0 / cos(radians(y));\n}\nfloat project_size() {\nif (project_uProjectionMode == PROJECTION_MODE_WEB_MERCATOR &&\nproject_uCoordinateSystem == COORDINATE_SYSTEM_LNGLAT &&\nproject_uPseudoMeters == false) {\nif (geometry.position.w == 0.0) {\nreturn project_size_at_latitude(geometry.worldPosition.y);\n}\nfloat y = geometry.position.y / TILE_SIZE * 2.0 - 1.0;\nfloat y2 = y * y;\nfloat y4 = y2 * y2;\nfloat y6 = y4 * y2;\nreturn 1.0 + 4.9348 * y2 + 4.0587 * y4 + 1.5642 * y6;\n}\nreturn 1.0;\n}\nfloat project_size_at_latitude(float meters, float lat) {\nreturn meters * project_uCommonUnitsPerMeter.z * project_size_at_latitude(lat);\n}\nfloat project_size(float meters) {\nreturn meters * project_uCommonUnitsPerMeter.z * project_size();\n}\nvec2 project_size(vec2 meters) {\nreturn meters * project_uCommonUnitsPerMeter.xy * project_size();\n}\nvec3 project_size(vec3 meters) {\nreturn meters * project_uCommonUnitsPerMeter * project_size();\n}\nvec4 project_size(vec4 meters) {\nreturn vec4(meters.xyz * project_uCommonUnitsPerMeter, meters.w);\n}\nmat3 project_get_orientation_matrix(vec3 up) {\nvec3 uz = normalize(up);\nvec3 ux = abs(uz.z) == 1.0 ? vec3(1.0, 0.0, 0.0) : normalize(vec3(uz.y, -uz.x, 0));\nvec3 uy = cross(uz, ux);\nreturn mat3(ux, uy, uz);\n}\nbool project_needs_rotation(vec3 commonPosition, out mat3 transform) {\nif (project_uProjectionMode == PROJECTION_MODE_GLOBE) {\ntransform = project_get_orientation_matrix(commonPosition);\nreturn true;\n}\nreturn false;\n}\nvec3 project_normal(vec3 vector) {\nvec4 normal_modelspace = project_uModelMatrix * vec4(vector, 0.0);\nvec3 n = normalize(normal_modelspace.xyz * project_uCommonUnitsPerMeter);\nmat3 rotation;\nif (project_needs_rotation(geometry.position.xyz, rotation)) {\nn = rotation * n;\n}\nreturn n;\n}\nvec4 project_offset_(vec4 offset) {\nfloat dy = offset.y;\nvec3 commonUnitsPerWorldUnit = project_uCommonUnitsPerWorldUnit + project_uCommonUnitsPerWorldUnit2 * dy;\nreturn vec4(offset.xyz * commonUnitsPerWorldUnit, offset.w);\n}\nvec2 project_mercator_(vec2 lnglat) {\nfloat x = lnglat.x;\nif (project_uWrapLongitude) {\nx = mod(x + 180., 360.0) - 180.;\n}\nfloat y = clamp(lnglat.y, -89.9, 89.9);\nreturn vec2(\nradians(x) + PI,\nPI + log(tan_fp32(PI * 0.25 + radians(y) * 0.5))\n) * WORLD_SCALE;\n}\nvec3 project_globe_(vec3 lnglatz) {\nfloat lambda = radians(lnglatz.x);\nfloat phi = radians(lnglatz.y);\nfloat cosPhi = cos(phi);\nfloat D = (lnglatz.z / EARTH_RADIUS + 1.0) * GLOBE_RADIUS;\nreturn vec3(\nsin(lambda) * cosPhi,\n-cos(lambda) * cosPhi,\nsin(phi)\n) * D;\n}\nvec4 project_position(vec4 position, vec3 position64Low) {\nvec4 position_world = project_uModelMatrix * position;\nif (project_uProjectionMode == PROJECTION_MODE_WEB_MERCATOR) {\nif (project_uCoordinateSystem == COORDINATE_SYSTEM_LNGLAT) {\nreturn vec4(\nproject_mercator_(position_world.xy),\nproject_size_at_latitude(position_world.z, position_world.y),\nposition_world.w\n);\n}\nif (project_uCoordinateSystem == COORDINATE_SYSTEM_CARTESIAN) {\nposition_world.xyz += project_uCoordinateOrigin;\n}\n}\nif (project_uProjectionMode == PROJECTION_MODE_GLOBE) {\nif (project_uCoordinateSystem == COORDINATE_SYSTEM_LNGLAT) {\nreturn vec4(\nproject_globe_(position_world.xyz),\nposition_world.w\n);\n}\n}\nif (project_uProjectionMode == PROJECTION_MODE_WEB_MERCATOR_AUTO_OFFSET) {\nif (project_uCoordinateSystem == COORDINATE_SYSTEM_LNGLAT) {\nif (abs(position_world.y - project_uCoordinateOrigin.y) > 0.25) {\nreturn vec4(\nproject_mercator_(position_world.xy) - project_uCommonOrigin.xy,\nproject_size(position_world.z),\nposition_world.w\n);\n}\n}\n}\nif (project_uProjectionMode == PROJECTION_MODE_IDENTITY ||\n(project_uProjectionMode == PROJECTION_MODE_WEB_MERCATOR_AUTO_OFFSET &&\n(project_uCoordinateSystem == COORDINATE_SYSTEM_LNGLAT ||\nproject_uCoordinateSystem == COORDINATE_SYSTEM_CARTESIAN))) {\nposition_world.xyz -= project_uCoordinateOrigin;\n}\nreturn project_offset_(position_world) + project_offset_(project_uModelMatrix * vec4(position64Low, 0.0));\n}\nvec4 project_position(vec4 position) {\nreturn project_position(position, ZERO_64_LOW);\n}\nvec3 project_position(vec3 position, vec3 position64Low) {\nvec4 projected_position = project_position(vec4(position, 1.0), position64Low);\nreturn projected_position.xyz;\n}\nvec3 project_position(vec3 position) {\nvec4 projected_position = project_position(vec4(position, 1.0), ZERO_64_LOW);\nreturn projected_position.xyz;\n}\nvec2 project_position(vec2 position) {\nvec4 projected_position = project_position(vec4(position, 0.0, 1.0), ZERO_64_LOW);\nreturn projected_position.xy;\n}\nvec4 project_common_position_to_clipspace(vec4 position, mat4 viewProjectionMatrix, vec4 center) {\nreturn viewProjectionMatrix * position + center;\n}\nvec4 project_common_position_to_clipspace(vec4 position) {\nreturn project_common_position_to_clipspace(position, project_uViewProjectionMatrix, project_uCenter);\n}\nvec2 project_pixel_size_to_clipspace(vec2 pixels) {\nvec2 offset = pixels / project_uViewportSize * project_uDevicePixelRatio * 2.0;\nreturn offset * project_uFocalDistance;\n}\nfloat project_size_to_pixel(float meters) {\nreturn project_size(meters) * project_uScale;\n}\nfloat project_size_to_pixel(float size, int unit) {\nif (unit == UNIT_METERS) return project_size_to_pixel(size);\nif (unit == UNIT_COMMON) return size * project_uScale;\nreturn size;\n}\nfloat project_pixel_size(float pixels) {\nreturn pixels / project_uScale;\n}\nvec2 project_pixel_size(vec2 pixels) {\nreturn pixels / project_uScale;\n}\n`;function Cy(e,t){if(e===t)return!0;if(Array.isArray(e)){const i=e.length;if(!t||t.length!==i)return!1;for(let n=0;n{for(const r in n)if(!Cy(n[r],i[r])){t=e(n),i=n;break}return t}}const By=[0,0,0,0],Iy=[1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,0],My=[1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1],Py=[0,0,0],Ry=[0,0,0],Ly=Sy(function({viewport:e,devicePixelRatio:t,coordinateSystem:i,coordinateOrigin:n}){const{projectionCenter:r,viewProjectionMatrix:o,originCommon:s,cameraPosCommon:a,shaderCoordinateOrigin:l,geospatialOrigin:c}=function(e,t,i){const{viewMatrixUncentered:n,projectionMatrix:r}=e;let{viewMatrix:o,viewProjectionMatrix:s}=e,a=By,l=By,c=e.cameraPosition;const{geospatialOrigin:u,shaderCoordinateOrigin:h,offsetMode:d}=Fy(e,t,i);d&&(l=e.projectPosition(u||h),c=[c[0]-l[0],c[1]-l[1],c[2]-l[2]],l[3]=1,a=OA([],l,s),o=n||o,s=IA([],r,o),s=IA([],s,Iy));return{viewMatrix:o,viewProjectionMatrix:s,projectionCenter:a,originCommon:l,cameraPosCommon:c,shaderCoordinateOrigin:h,geospatialOrigin:u}}(e,i,n),u=e.getDistanceScales(),h=[e.width*t,e.height*t],d=OA([],[0,0,-e.focalDistance,1],e.projectionMatrix)[3]||1,p={project_uCoordinateSystem:i,project_uProjectionMode:e.projectionMode,project_uCoordinateOrigin:l,project_uCommonOrigin:s.slice(0,3),project_uCenter:r,project_uPseudoMeters:Boolean(e._pseudoMeters),project_uViewportSize:h,project_uDevicePixelRatio:t,project_uFocalDistance:d,project_uCommonUnitsPerMeter:u.unitsPerMeter,project_uCommonUnitsPerWorldUnit:u.unitsPerMeter,project_uCommonUnitsPerWorldUnit2:Py,project_uScale:e.scale,project_uWrapLongitude:!1,project_uViewProjectionMatrix:o,project_uModelMatrix:My,project_uCameraPosition:a};if(c){const t=e.getDistanceScales(c);switch(i){case xy.METER_OFFSETS:p.project_uCommonUnitsPerWorldUnit=t.unitsPerMeter,p.project_uCommonUnitsPerWorldUnit2=t.unitsPerMeter2;break;case xy.LNGLAT:case xy.LNGLAT_OFFSETS:e._pseudoMeters||(p.project_uCommonUnitsPerMeter=t.unitsPerMeter),p.project_uCommonUnitsPerWorldUnit=t.unitsPerDegree,p.project_uCommonUnitsPerWorldUnit2=t.unitsPerDegree2;break;case xy.CARTESIAN:p.project_uCommonUnitsPerWorldUnit=[1,1,t.unitsPerMeter[2]],p.project_uCommonUnitsPerWorldUnit2=[0,0,t.unitsPerMeter2[2]]}}return p});function Fy(e,t,i=Ry){i.length<3&&(i=[i[0],i[1],0]);let n,r=i,o=!0;switch(n=t===xy.LNGLAT_OFFSETS||t===xy.METER_OFFSETS?i:e.isGeospatial?[Math.fround(e.longitude),Math.fround(e.latitude),0]:null,e.projectionMode){case by.WEB_MERCATOR:t!==xy.LNGLAT&&t!==xy.CARTESIAN||(n=[0,0,0],o=!1);break;case by.WEB_MERCATOR_AUTO_OFFSET:t===xy.LNGLAT?r=n:t===xy.CARTESIAN&&(r=[Math.fround(e.center[0]),Math.fround(e.center[1]),0],n=e.unprojectPosition(r),r[0]-=i[0],r[1]-=i[1],r[2]-=i[2]);break;case by.IDENTITY:r=e.position.map(Math.fround),r[2]=r[2]||0;break;case by.GLOBE:o=!1,n=null;break;default:o=!1}return{geospatialOrigin:n,shaderCoordinateOrigin:r,offsetMode:o}}function ky({viewport:e,devicePixelRatio:t=1,modelMatrix:i=null,coordinateSystem:n=xy.DEFAULT,coordinateOrigin:r=Ry,autoWrapLongitude:o=!1}){n===xy.DEFAULT&&(n=e.isGeospatial?xy.LNGLAT:xy.CARTESIAN);const s=Ly({viewport:e,devicePixelRatio:t,coordinateSystem:n,coordinateOrigin:r});return s.project_uWrapLongitude=o,s.project_uModelMatrix=i||My,s}const Dy={};var Oy={name:"project",dependencies:[w_,vy],vs:Ey,getUniforms:function(e=Dy){return"viewport"in e?ky(e):{}}};var zy={name:"project32",dependencies:[Oy],vs:"\nvec4 project_position_to_clipspace(\n vec3 position, vec3 position64Low, vec3 offset, out vec4 commonPosition\n) {\n vec3 projectedPosition = project_position(position, position64Low);\n mat3 rotation;\n if (project_needs_rotation(projectedPosition, rotation)) {\n // offset is specified as ENU\n // when in globe projection, rotate offset so that the ground alighs with the surface of the globe\n offset = rotation * offset;\n }\n commonPosition = vec4(projectedPosition + offset, 1.0);\n return project_common_position_to_clipspace(commonPosition);\n}\n\nvec4 project_position_to_clipspace(\n vec3 position, vec3 position64Low, vec3 offset\n) {\n vec4 commonPosition;\n return project_position_to_clipspace(position, position64Low, offset, commonPosition);\n}\n"};function Uy(e,t){const i=OA([],t,e);return DA(i,i,1/i[3]),i}function Ny(e,t){const i=e%t;return i<0?t+i:i}function Vy(e,t,i){return ei?i:e}const jy=Math.log2||function(e){return Math.log(e)*Math.LOG2E};function Gy(e,t){if(!e)throw new Error(t||"@math.gl/web-mercator: assertion failed.")}const Hy=Math.PI,Qy=Hy/4,$y=Hy/180,Zy=180/Hy,Wy=512,qy=4003e4,Ky=85.051129,Xy=1.5;function Jy(e){const[t,i]=e;Gy(Number.isFinite(t)),Gy(Number.isFinite(i)&&i>=-90&&i<=90,"invalid latitude");const n=i*$y;return[Wy*(t*$y+Hy)/(2*Hy),Wy*(Hy+Math.log(Math.tan(Qy+.5*n)))/(2*Hy)]}function Yy(e){const[t,i]=e,n=t/Wy*(2*Hy)-Hy,r=2*(Math.atan(Math.exp(i/Wy*(2*Hy)-Hy))-Qy);return[n*Zy,r*Zy]}function ev(e){const{latitude:t}=e;Gy(Number.isFinite(t));const i=Math.cos(t*$y);return function(e){return jy(e)}(qy*i)-9}function tv(e){return 12790407194604047e-21/Math.cos(e*$y)}function iv(e){const{latitude:t,longitude:i,highPrecision:n=!1}=e;Gy(Number.isFinite(t)&&Number.isFinite(i));const r=Wy,o=Math.cos(t*$y),s=r/360,a=s/o,l=12790407194604047e-21/o,c={unitsPerMeter:[l,l,l],metersPerUnit:[1/l,1/l,1/l],unitsPerDegree:[s,a,l],degreesPerUnit:[.703125,1/a,1/l]};if(n){const e=$y*Math.tan(t*$y)/o,i=s*e/2,n=12790407194604047e-21*e,r=n/a*l;c.unitsPerDegree2=[0,i,n],c.unitsPerMeter2=[r,0,r]}return c}function nv(e,t){const[i,n,r]=e,[o,s,a]=t,{unitsPerMeter:l,unitsPerMeter2:c}=iv({longitude:i,latitude:n,highPrecision:!0}),u=Jy(e);u[0]+=o*(l[0]+c[0]*s),u[1]+=s*(l[1]+c[1]*s);const h=Yy(u),d=(r||0)+(a||0);return Number.isFinite(r)||Number.isFinite(a)?[h[0],h[1],d]:h}function rv(e){return 2*Math.atan(.5/e)*Zy}function ov(e){return.5/Math.tan(.5*e*$y)}function sv(e,t){const[i,n,r=0]=e;return Gy(Number.isFinite(i)&&Number.isFinite(n)&&Number.isFinite(r)),Uy(t,[i,n,r,1])}function av(e,t,i=0){const[n,r,o]=e;if(Gy(Number.isFinite(n)&&Number.isFinite(r),"invalid pixel coordinate"),Number.isFinite(o)){return Uy(t,[n,r,o,1])}const s=Uy(t,[n,r,0,1]),a=Uy(t,[n,r,1,1]),l=s[2],c=a[2];return X_([],s,a,l===c?0:((i||0)-l)/(c-l))}function lv(e){const{width:t,height:i,bounds:n,minExtent:r=0,maxZoom:o=24,offset:s=[0,0]}=e,[[a,l],[c,u]]=n,h=function(e=0){if("number"==typeof e)return{top:e,bottom:e,left:e,right:e};return Gy(Number.isFinite(e.top)&&Number.isFinite(e.bottom)&&Number.isFinite(e.left)&&Number.isFinite(e.right)),e}(e.padding),d=Jy([a,Vy(u,-85.051129,Ky)]),p=Jy([c,Vy(l,-85.051129,Ky)]),f=[Math.max(Math.abs(p[0]-d[0]),r),Math.max(Math.abs(p[1]-d[1]),r)],m=[t-h.left-h.right-2*Math.abs(s[0]),i-h.top-h.bottom-2*Math.abs(s[1])];Gy(m[0]>0&&m[1]>0);const g=m[0]/f[0],_=m[1]/f[1],A=(h.right-h.left)/2/g,y=(h.top-h.bottom)/2/_,v=Yy([(p[0]+d[0])/2+A,(p[1]+d[1])/2+y]),x=Math.min(o,jy(Math.abs(Math.min(g,_))));return Gy(Number.isFinite(x)),{longitude:v[0],latitude:v[1],zoom:x}}const cv=Math.PI/180;function uv(e,t,i){const{pixelUnprojectionMatrix:n}=e,r=Uy(n,[t,0,1,1]),o=Uy(n,[t,e.height,1,1]),s=Yy(X_([],r,o,(i*e.distanceScales.unitsPerMeter[2]-r[2])/(o[2]-r[2])));return s.push(i),s}const hv=Sy(function({viewport:e,center:t}){return new HA(e.viewProjectionMatrix).invert().transform(t)}),dv=Sy(function({viewport:e,shadowMatrices:t}){const i=[],n=e.pixelUnprojectionMatrix,r=e.isGeospatial?void 0:1,o=[[0,0,r],[e.width,0,r],[0,e.height,r],[e.width,e.height,r],[0,0,-1],[e.width,0,-1],[0,e.height,-1],[e.width,e.height,-1]].map(e=>function(e,t){const[i,n,r]=e,o=av([i,n,r],t);if(Number.isFinite(r))return o;return[o[0],o[1],0]}(e,n));for(const n of t){const t=n.clone().translate(new AA(e.center).negate()),r=o.map(e=>t.transform(e)),s=(new HA).ortho({left:Math.min(...r.map(e=>e[0])),right:Math.max(...r.map(e=>e[0])),bottom:Math.min(...r.map(e=>e[1])),top:Math.max(...r.map(e=>e[1])),near:Math.min(...r.map(e=>-e[2])),far:Math.max(...r.map(e=>-e[2]))});i.push(s.multiplyRight(n))}return i}),pv=[0,0,0,1],fv=[1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,0];var mv={name:"shadow",dependencies:[Oy],vs:"\nconst int max_lights = 2;\nuniform mat4 shadow_uViewProjectionMatrices[max_lights];\nuniform vec4 shadow_uProjectCenters[max_lights];\nuniform bool shadow_uDrawShadowMap;\nuniform bool shadow_uUseShadowMap;\nuniform int shadow_uLightId;\nuniform float shadow_uLightCount;\n\nout vec3 shadow_vPosition[max_lights];\n\nvec4 shadow_setVertexPosition(vec4 position_commonspace) {\n if (shadow_uDrawShadowMap) {\n return project_common_position_to_clipspace(position_commonspace, shadow_uViewProjectionMatrices[shadow_uLightId], shadow_uProjectCenters[shadow_uLightId]);\n }\n if (shadow_uUseShadowMap) {\n for (int i = 0; i < max_lights; i++) {\n if(i < int(shadow_uLightCount)) {\n vec4 shadowMap_position = project_common_position_to_clipspace(position_commonspace, shadow_uViewProjectionMatrices[i], shadow_uProjectCenters[i]);\n shadow_vPosition[i] = (shadowMap_position.xyz / shadowMap_position.w + 1.0) / 2.0;\n }\n }\n }\n return gl_Position;\n}\n",fs:"\nconst int max_lights = 2;\nuniform bool shadow_uDrawShadowMap;\nuniform bool shadow_uUseShadowMap;\nuniform sampler2D shadow_uShadowMap0;\nuniform sampler2D shadow_uShadowMap1;\nuniform vec4 shadow_uColor;\nuniform float shadow_uLightCount;\n\nin vec3 shadow_vPosition[max_lights];\n\nconst vec4 bitPackShift = vec4(1.0, 255.0, 65025.0, 16581375.0);\nconst vec4 bitUnpackShift = 1.0 / bitPackShift;\nconst vec4 bitMask = vec4(1.0 / 255.0, 1.0 / 255.0, 1.0 / 255.0, 0.0);\n\nfloat shadow_getShadowWeight(vec3 position, sampler2D shadowMap) {\n vec4 rgbaDepth = texture(shadowMap, position.xy);\n\n float z = dot(rgbaDepth, bitUnpackShift);\n return smoothstep(0.001, 0.01, position.z - z);\n}\n\nvec4 shadow_filterShadowColor(vec4 color) {\n if (shadow_uDrawShadowMap) {\n vec4 rgbaDepth = fract(gl_FragCoord.z * bitPackShift);\n rgbaDepth -= rgbaDepth.gbaa * bitMask;\n return rgbaDepth;\n }\n if (shadow_uUseShadowMap) {\n float shadowAlpha = 0.0;\n shadowAlpha += shadow_getShadowWeight(shadow_vPosition[0], shadow_uShadowMap0);\n if(shadow_uLightCount > 1.0) {\n shadowAlpha += shadow_getShadowWeight(shadow_vPosition[1], shadow_uShadowMap1);\n }\n shadowAlpha *= shadow_uColor.a / shadow_uLightCount;\n float blendedAlpha = shadowAlpha + color.a * (1.0 - shadowAlpha);\n\n return vec4(\n mix(color.rgb, shadow_uColor.rgb, shadowAlpha / blendedAlpha),\n blendedAlpha\n );\n }\n return color;\n}\n",inject:{"vs:DECKGL_FILTER_GL_POSITION":"\n position = shadow_setVertexPosition(geometry.position);\n ","fs:DECKGL_FILTER_COLOR":"\n color = shadow_filterShadowColor(color);\n "},getUniforms:(e={},t={})=>"viewport"in e&&(e.drawToShadowMap||e.shadowMaps&&e.shadowMaps.length>0)?function(e,t){const{shadowEnabled:i=!0}=e;if(!i||!e.shadowMatrices||!e.shadowMatrices.length)return{shadow_uDrawShadowMap:!1,shadow_uUseShadowMap:!1,shadow_uShadowMap0:e.dummyShadowMap,shadow_uShadowMap1:e.dummyShadowMap};const n={shadow_uDrawShadowMap:Boolean(e.drawToShadowMap),shadow_uUseShadowMap:!!e.shadowMaps&&e.shadowMaps.length>0,shadow_uColor:e.shadowColor||pv,shadow_uLightId:e.shadowLightId||0,shadow_uLightCount:e.shadowMatrices.length},r=hv({viewport:e.viewport,center:t.project_uCenter}),o=[],s=dv({shadowMatrices:e.shadowMatrices,viewport:e.viewport}).slice();for(let i=0;ithis.device.clearWebGL(e))}const c={totalCount:t.length,visibleCount:0,compositeCount:0,pickableCount:0};e.setParameters({viewport:l});for(let i=0;i{const s=r.props._offset,a=r.id,l=r.parent&&r.parent.id;let c;if(l&&!(l in t)&&n(r.parent,!1),l in i){const e=i[l]=i[l]||Pv(t[l],t);c=e(r,o),i[a]=e}else Number.isFinite(s)?(c=s+(t[l]||0),i[a]=null):c=e;return o&&c>=e&&(e=c+1),t[a]=c,c};return n}class Rv extends Mv{constructor(e,t){super(e,t),this.shadowMap=e.createTexture({width:1,height:1,sampler:{minFilter:"linear",magFilter:"linear",addressModeU:"clamp-to-edge",addressModeV:"clamp-to-edge"}}),this.depthBuffer=e.createTexture({format:"depth16unorm",width:1,height:1,mipmaps:!1,dataFormat:6402,type:5125}),this.fbo=e.createFramebuffer({id:"shadowmap",width:1,height:1,colorAttachments:[this.shadowMap],depthStencilAttachment:this.depthBuffer})}render(e){const t=this.fbo,i=this.device.canvasContext.cssToDeviceRatio(),n=e.viewports[0],r=n.width*i,o=n.height*i;r===t.width&&o===t.height||t.resize({width:r,height:o}),super.render({...e,clearColor:[1,1,1,1],target:t,pass:"shadow"})}getLayerParameters(e,t,i){return{...e.props.parameters,blend:!1,depthRange:[0,1],depthTest:!0}}shouldDrawLayer(e){return!1!==e.props.shadowEnabled}getModuleParameters(){return{drawToShadowMap:!0}}delete(){this.fbo&&(this.fbo.destroy(),this.fbo=null),this.shadowMap&&(this.shadowMap.destroy(),this.shadowMap=null),this.depthBuffer&&(this.depthBuffer.destroy(),this.depthBuffer=null)}}const Lv={color:[255,255,255],intensity:1},Fv=[{color:[255,255,255],intensity:1,direction:[-1,3,-1]},{color:[255,255,255],intensity:.9,direction:[1,-8,-2.5]}],kv=[0,0,0,200/255];class Dv{constructor(e={}){this.id="lighting-effect",this.shadowColor=kv,this.shadow=!1,this.ambientLight=null,this.directionalLights=[],this.pointLights=[],this.shadowPasses=[],this.shadowMaps=[],this.dummyShadowMap=null,this.setProps(e)}setup(e){this.context=e;const{device:t,deck:i}=e;this.shadow&&!this.dummyShadowMap&&(this._createShadowPasses(t),i._addDefaultShaderModule(mv),this.dummyShadowMap=t.createTexture({width:1,height:1}))}setProps(e){this.ambientLight=null,this.directionalLights=[],this.pointLights=[];for(const t in e){const i=e[t];switch(i.type){case"ambient":this.ambientLight=i;break;case"directional":this.directionalLights.push(i);break;case"point":this.pointLights.push(i)}}this._applyDefaultLights(),this.shadow=this.directionalLights.some(e=>e.shadow),this.context&&this.setup(this.context),this.props=e}preRender({layers:e,layerFilter:t,viewports:i,onViewportActive:n,views:r}){if(this.shadow){this.shadowMatrices=this._calculateMatrices();for(let o=0;ot.getProjectedLight({layer:e})),pointLights:this.pointLights.map(t=>t.getProjectedLight({layer:e}))},t}cleanup(e){for(const e of this.shadowPasses)e.delete();this.shadowPasses.length=0,this.shadowMaps.length=0,this.dummyShadowMap&&(this.dummyShadowMap.destroy(),this.dummyShadowMap=null,e.deck._removeDefaultShaderModule(mv))}_calculateMatrices(){const e=[];for(const t of this.directionalLights){const i=(new HA).lookAt({eye:new AA(t.direction).negate()});e.push(i)}return e}_createShadowPasses(e){for(let t=0;tn&&(r=n);const o=this._pool,s=e.BYTES_PER_ELEMENT*r,a=o.findIndex(e=>e.byteLength>=s);if(a>=0){const t=new e(o.splice(a,1)[0],0,r);return i&&t.fill(0),t}return new e(r)}_release(e){if(!ArrayBuffer.isView(e))return;const t=this._pool,{buffer:i}=e,{byteLength:n}=i,r=t.findIndex(e=>e.byteLength>=n);r<0?t.push(i):(r>0||t.lengththis.opts.poolSize&&t.shift()}};const zv=new AA;function Uv(e,t,i,n){zv.set(e,t,i);const r=zv.len();return{distance:n/r,normal:new AA(-e/r,-t/r,-i/r)}}function Nv(e){return e-Math.fround(e)}let Vv;function jv(e,t){const{size:i=1,startIndex:n=0}=t,r=void 0!==t.endIndex?t.endIndex:e.length,o=(r-n)/i;Vv=Ov.allocate(Vv,o,{type:Float32Array,size:2*i});let s=n,a=0;for(;s(90-e.pitch)*cv-.01?(l=uv(e,0,t),c=uv(e,i,t)):(l=r([0,0],o),c=r([i,0],o)),[s,a,c,l]}(this,e.z||0);return[Math.min(t[0][0],t[1][0],t[2][0],t[3][0]),Math.min(t[0][1],t[1][1],t[2][1],t[3][1]),Math.max(t[0][0],t[1][0],t[2][0],t[3][0]),Math.max(t[0][1],t[1][1],t[2][1],t[3][1])]}fitBounds(e,t={}){const{width:i,height:n}=this,{longitude:r,latitude:o,zoom:s}=lv({width:i,height:n,bounds:e,...t});return new Kv({width:i,height:n,longitude:r,latitude:o,zoom:s})}}Kv.displayName="WebMercatorViewport";var Xv=Kv;const Jv=[0,0,0];function Yv(e,t,i=!1){const n=t.projectPosition(e);if(i&&t instanceof Xv){const[i,r,o=0]=e,s=t.getDistanceScales([i,r]);n[2]=o*s.unitsPerMeter[2]}return n}function ex(e,{viewport:t,modelMatrix:i,coordinateSystem:n,coordinateOrigin:r,offsetMode:o}){let[s,a,l=0]=e;switch(i&&([s,a,l]=OA([],[s,a,l,1],i)),n){case xy.LNGLAT:return Yv([s,a,l],t,o);case xy.LNGLAT_OFFSETS:return Yv([s+r[0],a+r[1],l+(r[2]||0)],t,o);case xy.METER_OFFSETS:return Yv(nv(r,[s,a,l]),t,o);case xy.CARTESIAN:default:return t.isGeospatial?[s+r[0],a+r[1],l+r[2]]:t.projectPosition([s,a,l])}}function tx(e,t){const{viewport:i,coordinateSystem:n,coordinateOrigin:r,modelMatrix:o,fromCoordinateSystem:s,fromCoordinateOrigin:a}=function(e){const{viewport:t,modelMatrix:i,coordinateOrigin:n}=e;let{coordinateSystem:r,fromCoordinateSystem:o,fromCoordinateOrigin:s}=e;return r===xy.DEFAULT&&(r=t.isGeospatial?xy.LNGLAT:xy.CARTESIAN),void 0===o&&(o=r),void 0===s&&(s=n),{viewport:t,coordinateSystem:r,coordinateOrigin:n,modelMatrix:i,fromCoordinateSystem:o,fromCoordinateOrigin:s}}(t),{autoOffset:l=!0}=t,{geospatialOrigin:c=Jv,shaderCoordinateOrigin:u=Jv,offsetMode:h=!1}=l?Fy(i,n,r):{},d=ex(e,{viewport:i,modelMatrix:o,coordinateSystem:s,coordinateOrigin:a,offsetMode:h});if(h){const e=i.projectPosition(c||u);dA(d,d,e)}return d}const ix=[255,255,255],nx=1,rx=[0,0,1],ox=[0,0,1];let sx=0;class ax{constructor(e={}){this.type="point";const{color:t=ix}=e,{intensity:i=nx}=e,{position:n=ox}=e;this.id=e.id||"point-"+sx++,this.color=t,this.intensity=i,this.type="point",this.position=n,this.attenuation=function(e){if(e.attenuation)return e.attenuation;if("intensity"in e)return[0,0,e.intensity||0];return rx}(e),this.projectedLight={...this}}getProjectedLight({layer:e}){const{projectedLight:t}=this,i=e.context.viewport,{coordinateSystem:n,coordinateOrigin:r}=e.props,o=tx(this.position,{viewport:i,coordinateSystem:n,coordinateOrigin:r,fromCoordinateSystem:i.isGeospatial?xy.LNGLAT:xy.CARTESIAN,fromCoordinateOrigin:[0,0,0]});return t.color=this.color,t.intensity=this.intensity,t.position=o,t}}class lx extends ax{getProjectedLight({layer:e}){const{projectedLight:t}=this,i=e.context.viewport,{coordinateSystem:n,coordinateOrigin:r,modelMatrix:o}=e.props,{project_uCameraPosition:s}=ky({viewport:i,modelMatrix:o,coordinateSystem:n,coordinateOrigin:r});return t.color=this.color,t.intensity=this.intensity,t.position=s,t}}let cx=1,ux=1;class hx{time=0;channels=new Map;animations=new Map;playing=!1;lastEngineTime=-1;constructor(){}addChannel(e){const{delay:t=0,duration:i=Number.POSITIVE_INFINITY,rate:n=1,repeat:r=1}=e,o=cx++,s={time:0,delay:t,duration:i,rate:n,repeat:r};return this._setChannelTime(s,this.time),this.channels.set(o,s),o}removeChannel(e){this.channels.delete(e);for(const[t,i]of this.animations)i.channel===e&&this.detachAnimation(t)}isFinished(e){const t=this.channels.get(e);return void 0!==t&&this.time>=t.delay+t.duration*t.repeat}getTime(e){if(void 0===e)return this.time;const t=this.channels.get(e);return void 0===t?-1:t.time}setTime(e){this.time=Math.max(0,e);const t=this.channels.values();for(const e of t)this._setChannelTime(e,this.time);const i=this.animations.values();for(const e of i){const{animation:t,channel:i}=e;t.setTime(this.getTime(i))}}play(){this.playing=!0}pause(){this.playing=!1,this.lastEngineTime=-1}reset(){this.setTime(0)}attachAnimation(e,t){const i=ux++;return this.animations.set(i,{animation:e,channel:t}),e.setTime(this.getTime(t)),i}detachAnimation(e){this.animations.delete(e)}update(e){this.playing&&(-1===this.lastEngineTime&&(this.lastEngineTime=e),this.setTime(this.time+(e-this.lastEngineTime)),this.lastEngineTime=e)}_setChannelTime(e,t){const i=t-e.delay;i>=e.duration*e.repeat?e.time=e.duration*e.rate:(e.time=Math.max(0,i)%e.duration,e.time*=e.rate)}}let dx=0;const px={device:null,onAddHTML:()=>"",onInitialize:async()=>null,onRender:()=>{},onFinalize:()=>{},onError:e=>console.error(e),stats:hf.stats.get("animation-loop-"+dx++),useDevicePixels:!0,autoResizeViewport:!1,autoResizeDrawingBuffer:!1};class fx{device=null;canvas=null;props;animationProps=null;timeline=null;stats;cpuTime;gpuTime;frameRate;display;needsRedraw="initialized";_initialized=!1;_running=!1;_animationFrameId=null;_nextFramePromise=null;_resolveNextFrame=null;_cpuStartTime=0;constructor(e){if(this.props={...px,...e},!(e=this.props).device)throw new Error("No device provided");const{useDevicePixels:t=!0}=this.props;this.stats=e.stats||new Ch({id:"animation-loop-stats"}),this.cpuTime=this.stats.get("CPU Time"),this.gpuTime=this.stats.get("GPU Time"),this.frameRate=this.stats.get("Frame Rate"),this.setProps({autoResizeViewport:e.autoResizeViewport,autoResizeDrawingBuffer:e.autoResizeDrawingBuffer,useDevicePixels:t}),this.start=this.start.bind(this),this.stop=this.stop.bind(this),this._onMousemove=this._onMousemove.bind(this),this._onMouseleave=this._onMouseleave.bind(this)}destroy(){this.stop(),this._setDisplay(null)}delete(){this.destroy()}setNeedsRedraw(e){return this.needsRedraw=this.needsRedraw||e,this}setProps(e){return"autoResizeViewport"in e&&(this.props.autoResizeViewport=e.autoResizeViewport||!1),"autoResizeDrawingBuffer"in e&&(this.props.autoResizeDrawingBuffer=e.autoResizeDrawingBuffer||!1),"useDevicePixels"in e&&(this.props.useDevicePixels=e.useDevicePixels||!1),this}async start(){if(this._running)return this;this._running=!0;try{let e;return this._initialized||(this._initialized=!0,await this._initDevice(),this._initialize(),await this.props.onInitialize(this._getAnimationProps())),this._running?(!1!==e&&(this._cancelAnimationFrame(),this._requestAnimationFrame()),this):null}catch(e){const t=e instanceof Error?e:new Error("Unknown error");throw this.props.onError(t),t}}stop(){return this._running&&(this.animationProps&&this.props.onFinalize(this.animationProps),this._cancelAnimationFrame(),this._nextFramePromise=null,this._resolveNextFrame=null,this._running=!1),this}redraw(){return this.device?.isLost||(this._beginFrameTimers(),this._setupFrame(),this._updateAnimationProps(),this._renderFrame(this._getAnimationProps()),this._clearNeedsRedraw(),this._resolveNextFrame&&(this._resolveNextFrame(this),this._nextFramePromise=null,this._resolveNextFrame=null),this._endFrameTimers()),this}attachTimeline(e){return this.timeline=e,this.timeline}detachTimeline(){this.timeline=null}waitForRender(){return this.setNeedsRedraw("waitForRender"),this._nextFramePromise||(this._nextFramePromise=new Promise(e=>{this._resolveNextFrame=e})),this._nextFramePromise}async toDataURL(){if(this.setNeedsRedraw("toDataURL"),await this.waitForRender(),this.canvas instanceof HTMLCanvasElement)return this.canvas.toDataURL();throw new Error("OffscreenCanvas")}_initialize(){this._startEventHandling(),this._initializeAnimationProps(),this._updateAnimationProps(),this._resizeCanvasDrawingBuffer(),this._resizeViewport()}_setDisplay(e){this.display&&(this.display.destroy(),this.display.animationLoop=null),e&&(e.animationLoop=this),this.display=e}_requestAnimationFrame(){var e;this._running&&(this._animationFrameId=(e=this._animationFrame.bind(this),"undefined"!=typeof window&&window.requestAnimationFrame?window.requestAnimationFrame(e):setTimeout(e,1e3/60)))}_cancelAnimationFrame(){var e;null!==this._animationFrameId&&(e=this._animationFrameId,"undefined"!=typeof window&&window.cancelAnimationFrame?window.cancelAnimationFrame(e):clearTimeout(e),this._animationFrameId=null)}_animationFrame(){this._running&&(this.redraw(),this._requestAnimationFrame())}_renderFrame(e){this.display?this.display._renderFrame(e):(this.props.onRender(this._getAnimationProps()),this.device.submit())}_clearNeedsRedraw(){this.needsRedraw=!1}_setupFrame(){this._resizeCanvasDrawingBuffer(),this._resizeViewport()}_initializeAnimationProps(){if(!this.device)throw new Error("loop");this.animationProps={animationLoop:this,device:this.device,canvas:this.device?.canvasContext?.canvas,timeline:this.timeline,useDevicePixels:this.props.useDevicePixels,needsRedraw:!1,width:1,height:1,aspect:1,time:0,startTime:Date.now(),engineTime:0,tick:0,tock:0,_mousePosition:null}}_getAnimationProps(){if(!this.animationProps)throw new Error("animationProps");return this.animationProps}_updateAnimationProps(){if(!this.animationProps)return;const{width:e,height:t,aspect:i}=this._getSizeAndAspect();e===this.animationProps.width&&t===this.animationProps.height||this.setNeedsRedraw("drawing buffer resized"),i!==this.animationProps.aspect&&this.setNeedsRedraw("drawing buffer aspect changed"),this.animationProps.width=e,this.animationProps.height=t,this.animationProps.aspect=i,this.animationProps.needsRedraw=this.needsRedraw,this.animationProps.engineTime=Date.now()-this.animationProps.startTime,this.timeline&&this.timeline.update(this.animationProps.engineTime),this.animationProps.tick=Math.floor(this.animationProps.time/1e3*60),this.animationProps.tock++,this.animationProps.time=this.timeline?this.timeline.getTime():this.animationProps.engineTime}async _initDevice(){if(this.device=await this.props.device,!this.device)throw new Error("No device provided");this.canvas=this.device.canvasContext?.canvas||null}_createInfoDiv(){if(this.canvas&&this.props.onAddHTML){const e=document.createElement("div");document.body.appendChild(e),e.style.position="relative";const t=document.createElement("div");t.style.position="absolute",t.style.left="10px",t.style.bottom="10px",t.style.width="300px",t.style.background="white",this.canvas instanceof HTMLCanvasElement&&e.appendChild(this.canvas),e.appendChild(t);const i=this.props.onAddHTML(t);i&&(t.innerHTML=i)}}_getSizeAndAspect(){if(!this.device)return{width:1,height:1,aspect:1};const[e,t]=this.device?.canvasContext?.getPixelSize()||[1,1];let i=1;const n=this.device?.canvasContext?.canvas;return n&&n.clientHeight?i=n.clientWidth/n.clientHeight:e>0&&t>0&&(i=e/t),{width:e,height:t,aspect:i}}_resizeViewport(){this.props.autoResizeViewport&&this.device.gl&&this.device.gl.viewport(0,0,this.device.gl.drawingBufferWidth,this.device.gl.drawingBufferHeight)}_resizeCanvasDrawingBuffer(){this.props.autoResizeDrawingBuffer&&this.device?.canvasContext?.resize({useDevicePixels:this.props.useDevicePixels})}_beginFrameTimers(){this.frameRate.timeEnd(),this.frameRate.timeStart(),this.cpuTime.timeStart()}_endFrameTimers(){this.cpuTime.timeEnd()}_startEventHandling(){this.canvas&&(this.canvas.addEventListener("mousemove",this._onMousemove.bind(this)),this.canvas.addEventListener("mouseleave",this._onMouseleave.bind(this)))}_onMousemove(e){e instanceof MouseEvent&&(this._getAnimationProps()._mousePosition=[e.offsetX,e.offsetY])}_onMouseleave(e){this._getAnimationProps()._mousePosition=null}}class mx{id;userData={};topology;bufferLayout=[];vertexCount;indices;attributes;constructor(e){this.id=e.id||Wp("geometry"),this.topology=e.topology,this.indices=e.indices||null,this.attributes=e.attributes,this.vertexCount=e.vertexCount,this.bufferLayout=e.bufferLayout||[],this.indices&&cf(this.indices.usage===Xp.INDEX)}destroy(){this.indices?.destroy();for(const e of Object.values(this.attributes))e.destroy()}getVertexCount(){return this.vertexCount}getAttributes(){return this.attributes}getIndexes(){return this.indices}_calculateVertexCount(e){return e.byteLength/12}}function gx(e,t){if(t instanceof mx)return t;const i=function(e,t){if(!t.indices)return;const i=t.indices.value;return e.createBuffer({usage:Xp.INDEX,data:i})}(e,t),{attributes:n,bufferLayout:r}=function(e,t){const i=[],n={};for(const[r,o]of Object.entries(t.attributes)){let t=r;switch(r){case"POSITION":t="positions";break;case"NORMAL":t="normals";break;case"TEXCOORD_0":t="texCoords";break;case"COLOR_0":t="colors"}n[t]=e.createBuffer({data:o.value,id:`${r}-buffer`});const{value:s,size:a,normalized:l}=o;i.push({name:t,format:em(s,a,l)})}const r=t._calculateVertexCount(t.attributes,t.indices);return{attributes:n,bufferLayout:i,vertexCount:r}}(e,t);return new mx({topology:t.topology||"triangle-list",bufferLayout:r,vertexCount:t.vertexCount,indices:i,attributes:n})}class _x{modules;moduleUniforms;moduleBindings;moduleUniformsChanged;constructor(e){const t=Cp(Object.values(e).filter(e=>e.dependencies));for(const i of t)e[i.name]=i;Gp.log(1,"Creating ShaderInputs with modules",Object.keys(e))(),this.modules=e,this.moduleUniforms={},this.moduleBindings={};for(const[t,i]of Object.entries(e)){const e=t;this.moduleUniforms[e]=i.defaultUniforms||{},this.moduleBindings[e]={}}}destroy(){}setProps(e){for(const t of Object.keys(e)){const i=t,n=e[i],r=this.modules[i];if(!r){Gp.warn(`Module ${t} not found`)();continue}const o=this.moduleUniforms[i],s=this.moduleBindings[i],a=r.getUniforms?.(n,o)||n,{uniforms:l,bindings:c}=tm(a);this.moduleUniforms[i]={...o,...l},this.moduleBindings[i]={...s,...c}}}getModules(){return Object.values(this.modules)}getUniformValues(){return this.moduleUniforms}getBindings(){const e={};for(const t of Object.values(this.moduleBindings))Object.assign(e,t);return e}getDebugTable(){const e={};for(const[t,i]of Object.entries(this.moduleUniforms))for(const[n,r]of Object.entries(i))e[`${t}.${n}`]={type:this.modules[t].uniformTypes?.[n],value:String(r)};return e}}class Ax{static defaultProps={...Mf.defaultProps};device;_hashCounter=0;_hashes={};_renderPipelineCache={};_computePipelineCache={};static getDefaultPipelineFactory(e){return e._lumaData.defaultPipelineFactory=e._lumaData.defaultPipelineFactory||new Ax(e),e._lumaData.defaultPipelineFactory}constructor(e){this.device=e}createRenderPipeline(e){const t={...Mf.defaultProps,...e},i=this._hashRenderPipeline(t);if(!this._renderPipelineCache[i]){const e=this.device.createRenderPipeline({...t,id:t.id?`${t.id}-cached`:void 0});e.hash=i,this._renderPipelineCache[i]={pipeline:e,useCount:0}}return this._renderPipelineCache[i].useCount++,this._renderPipelineCache[i].pipeline}createComputePipeline(e){const t={...Rf.defaultProps,...e},i=this._hashComputePipeline(t);if(!this._computePipelineCache[i]){const e=this.device.createComputePipeline({...t,id:t.id?`${t.id}-cached`:void 0});e.hash=i,this._computePipelineCache[i]={pipeline:e,useCount:0}}return this._computePipelineCache[i].useCount++,this._computePipelineCache[i].pipeline}release(e){const t=e.hash,i=e instanceof Rf?this._computePipelineCache:this._renderPipelineCache;i[t].useCount--,0===i[t].useCount&&(i[t].pipeline.destroy(),delete i[t])}_hashComputePipeline(e){return`${this._getHash(e.shader.source)}`}_hashRenderPipeline(e){const t=this._getHash(e.vs.source),i=e.fs?this._getHash(e.fs.source):0,n=this._getHash(JSON.stringify(e.bufferLayout));if("webgl"===this.device.type)return`${t}/${i}V-BL${n}`;{const r=this._getHash(JSON.stringify(e.parameters));return`${t}/${i}V-T${e.topology}P${r}BL${n}`}}_getHash(e){return void 0===this._hashes[e]&&(this._hashes[e]=this._hashCounter++),this._hashes[e]}}class yx{static defaultProps={...Cf.defaultProps};device;_cache={};static getDefaultShaderFactory(e){return e._lumaData.defaultShaderFactory||=new yx(e),e._lumaData.defaultShaderFactory}constructor(e){this.device=e}createShader(e){const t=this._hashShader(e);let i=this._cache[t];if(!i){const n=this.device.createShader({...e,id:e.id?`${e.id}-cached`:void 0});this._cache[t]=i={shader:n,useCount:0}}return i.useCount++,i.shader}release(e){const t=this._hashShader(e),i=this._cache[t];i&&(i.useCount--,0===i.useCount&&(delete this._cache[t],i.shader.destroy()))}_hashShader(e){return`${e.stage}:${e.source}`}}let vx=null,xx=null;class bx{static defaultProps={...Mf.defaultProps,source:null,vs:null,fs:null,id:"unnamed",handle:void 0,userData:{},defines:{},modules:[],moduleSettings:void 0,geometry:null,indexBuffer:null,attributes:{},constantAttributes:{},varyings:[],isInstanced:void 0,instanceCount:0,vertexCount:0,shaderInputs:void 0,pipelineFactory:void 0,shaderFactory:void 0,transformFeedback:void 0,shaderAssembler:Vp.getDefaultShaderAssembler(),debugShaders:void 0,disableWarnings:void 0};device;id;source;vs;fs;pipelineFactory;shaderFactory;userData={};parameters;topology;bufferLayout;isInstanced=void 0;instanceCount=0;vertexCount;indexBuffer=null;bufferAttributes={};constantAttributes={};bindings={};uniforms={};vertexArray;transformFeedback=null;pipeline;shaderInputs;_uniformStore;_attributeInfos={};_gpuGeometry=null;_getModuleUniforms;props;_pipelineNeedsUpdate="newly created";_needsRedraw="initializing";_destroyed=!1;_lastDrawTimestamp=-1;constructor(e,t){this.props={...bx.defaultProps,...t},t=this.props,this.id=t.id||Wp("model"),this.device=e,Object.assign(this.userData,t.userData);const i=Object.fromEntries(this.props.modules?.map(e=>[e.name,e])||[]);this.setShaderInputs(t.shaderInputs||new _x(i));const n=function(e){return{type:e.type,shaderLanguage:e.info.shadingLanguage,shaderLanguageVersion:e.info.shadingLanguageVersion,gpu:e.info.gpu,features:e.features}}(e),r=(this.props.modules?.length>0?this.props.modules:this.shaderInputs?.getModules())||[];if("webgpu"===this.device.type&&this.props.source){this.props.shaderLayout||=x_(this.props.source);const{source:e,getUniforms:t}=this.props.shaderAssembler.assembleShader({platformInfo:n,...this.props,modules:r});this.source=e,this._getModuleUniforms=t}else{const{vs:e,fs:t,getUniforms:i}=this.props.shaderAssembler.assembleShaderPair({platformInfo:n,...this.props,modules:r});this.vs=e,this.fs=t,this._getModuleUniforms=i}this.vertexCount=this.props.vertexCount,this.instanceCount=this.props.instanceCount,this.topology=this.props.topology,this.bufferLayout=this.props.bufferLayout,this.parameters=this.props.parameters,t.geometry&&this.setGeometry(t.geometry),this.pipelineFactory=t.pipelineFactory||Ax.getDefaultPipelineFactory(this.device),this.shaderFactory=t.shaderFactory||yx.getDefaultShaderFactory(this.device),this.pipeline=this._updatePipeline(),this.vertexArray=e.createVertexArray({renderPipeline:this.pipeline}),this._gpuGeometry&&this._setGeometryAttributes(this._gpuGeometry),"isInstanced"in t&&(this.isInstanced=t.isInstanced),t.instanceCount&&this.setInstanceCount(t.instanceCount),t.vertexCount&&this.setVertexCount(t.vertexCount),t.indexBuffer&&this.setIndexBuffer(t.indexBuffer),t.attributes&&this.setAttributes(t.attributes),t.constantAttributes&&this.setConstantAttributes(t.constantAttributes),t.bindings&&this.setBindings(t.bindings),t.uniforms&&this.setUniforms(t.uniforms),t.moduleSettings&&this.updateModuleSettings(t.moduleSettings),t.transformFeedback&&(this.transformFeedback=t.transformFeedback),Object.seal(this)}destroy(){this._destroyed||(this.pipelineFactory.release(this.pipeline),this.shaderFactory.release(this.pipeline.vs),this.pipeline.fs&&this.shaderFactory.release(this.pipeline.fs),this._uniformStore.destroy(),this._gpuGeometry?.destroy(),this._destroyed=!0)}needsRedraw(){this._getBindingsUpdateTimestamp()>this._lastDrawTimestamp&&this.setNeedsRedraw("contents of bound textures or buffers updated");const e=this._needsRedraw;return this._needsRedraw=!1,e}setNeedsRedraw(e){this._needsRedraw||=e}predraw(){this.updateShaderInputs(),this.pipeline=this._updatePipeline()}draw(e){let t;this.predraw();try{this._logDrawCallStart(),this.pipeline=this._updatePipeline(),this.pipeline.setBindings(this.bindings,{disableWarnings:this.props.disableWarnings}),qp(this.uniforms)||this.pipeline.setUniformsWebGL(this.uniforms);const{indexBuffer:i}=this.vertexArray,n=i?i.byteLength/("uint32"===i.indexType?4:2):void 0;t=this.pipeline.draw({renderPass:e,vertexArray:this.vertexArray,isInstanced:this.isInstanced,vertexCount:this.vertexCount,instanceCount:this.instanceCount,indexCount:n,transformFeedback:this.transformFeedback||void 0,parameters:this.parameters,topology:this.topology})}finally{this._logDrawCallEnd()}return this._logFramebuffer(e),t?(this._lastDrawTimestamp=this.device.timestamp,this._needsRedraw=!1):this._needsRedraw="waiting for resource initialization",t}setGeometry(e){this._gpuGeometry?.destroy();const t=e&&gx(this.device,e);t&&(this.setTopology(t.topology||"triangle-list"),this.bufferLayout=wx(t.bufferLayout,this.bufferLayout),this.vertexArray&&this._setGeometryAttributes(t)),this._gpuGeometry=t}setTopology(e){e!==this.topology&&(this.topology=e,this._setPipelineNeedsUpdate("topology"))}setBufferLayout(e){this.bufferLayout=this._gpuGeometry?wx(e,this._gpuGeometry.bufferLayout):e,this._setPipelineNeedsUpdate("bufferLayout"),this.pipeline=this._updatePipeline(),this.vertexArray=this.device.createVertexArray({renderPipeline:this.pipeline}),this._gpuGeometry&&this._setGeometryAttributes(this._gpuGeometry)}setParameters(e){rm(e,this.parameters,2)||(this.parameters=e,this._setPipelineNeedsUpdate("parameters"))}setInstanceCount(e){this.instanceCount=e,void 0===this.isInstanced&&e>0&&(this.isInstanced=!0),this.setNeedsRedraw("instanceCount")}setVertexCount(e){this.vertexCount=e,this.setNeedsRedraw("vertexCount")}setShaderInputs(e){this.shaderInputs=e,this._uniformStore=new Xf(this.shaderInputs.modules);for(const e of Object.keys(this.shaderInputs.modules)){const t=this._uniformStore.getManagedUniformBuffer(this.device,e);this.bindings[`${e}Uniforms`]=t}this.setNeedsRedraw("shaderInputs")}updateShaderInputs(){this._uniformStore.setUniforms(this.shaderInputs.getUniformValues()),this.setBindings(this.shaderInputs.getBindings()),this.setNeedsRedraw("shaderInputs")}setBindings(e){Object.assign(this.bindings,e),this.setNeedsRedraw("bindings")}setTransformFeedback(e){this.transformFeedback=e,this.setNeedsRedraw("transformFeedback")}setIndexBuffer(e){this.vertexArray.setIndexBuffer(e),this.setNeedsRedraw("indexBuffer")}setAttributes(e,t){e.indices&&Gp.warn(`Model:${this.id} setAttributes() - indexBuffer should be set using setIndexBuffer()`)();for(const[i,n]of Object.entries(e)){const e=this.bufferLayout.find(e=>Tx(e).includes(i));if(!e){Gp.warn(`Model(${this.id}): Missing layout for buffer "${i}".`)();continue}const r=Tx(e);let o=!1;for(const e of r){const t=this._attributeInfos[e];t&&(this.vertexArray.setBuffer(t.location,n),o=!0)}o||(t?.disableWarnings??this.props.disableWarnings)||Gp.warn(`Model(${this.id}): Ignoring buffer "${n.id}" for unknown attribute "${i}"`)()}this.setNeedsRedraw("attributes")}setConstantAttributes(e,t){for(const[i,n]of Object.entries(e)){const e=this._attributeInfos[i];e?this.vertexArray.setConstantWebGL(e.location,n):(t?.disableWarnings??this.props.disableWarnings)||Gp.warn(`Model "${this.id}: Ignoring constant supplied for unknown attribute "${i}"`)()}this.setNeedsRedraw("constants")}setUniforms(e){qp(e)||(this.pipeline.setUniformsWebGL(e),Object.assign(this.uniforms,e)),this.setNeedsRedraw("uniforms")}updateModuleSettings(e){const{bindings:t,uniforms:i}=tm(this._getModuleUniforms(e));Object.assign(this.bindings,t),Object.assign(this.uniforms,i),this.setNeedsRedraw("moduleSettings")}_getBindingsUpdateTimestamp(){let e=0;for(const t of Object.values(this.bindings))t instanceof vf?e=Math.max(e,t.texture.updateTimestamp):t instanceof Xp||t instanceof yf?e=Math.max(e,t.updateTimestamp):t instanceof Bf||(e=Math.max(e,t.buffer.updateTimestamp));return e}_setGeometryAttributes(e){const t={...e.attributes};for(const[e]of Object.entries(t))this.pipeline.shaderLayout.attributes.find(t=>t.name===e)||"positions"===e||delete t[e];this.vertexCount=e.vertexCount,this.setIndexBuffer(e.indices||null),this.setAttributes(e.attributes,{disableWarnings:!0}),this.setAttributes(t,{disableWarnings:this.props.disableWarnings}),this.setNeedsRedraw("geometry attributes")}_setPipelineNeedsUpdate(e){this._pipelineNeedsUpdate||=e,this.setNeedsRedraw(e)}_updatePipeline(){if(this._pipelineNeedsUpdate){let e=null,t=null;this.pipeline&&(Gp.log(1,`Model ${this.id}: Recreating pipeline because "${this._pipelineNeedsUpdate}".`)(),e=this.pipeline.vs,t=this.pipeline.fs),this._pipelineNeedsUpdate=!1;const i=this.shaderFactory.createShader({id:`${this.id}-vertex`,stage:"vertex",source:this.source||this.vs,debug:this.props.debugShaders});let n=null;this.source?n=i:this.fs&&(n=this.shaderFactory.createShader({id:`${this.id}-fragment`,stage:"fragment",source:this.source||this.fs,debug:this.props.debugShaders})),this.pipeline=this.pipelineFactory.createRenderPipeline({...this.props,bufferLayout:this.bufferLayout,topology:this.topology,parameters:this.parameters,vs:i,fs:n}),this._attributeInfos=zf(this.pipeline.shaderLayout,this.bufferLayout),e&&this.shaderFactory.release(e),t&&this.shaderFactory.release(t)}return this.pipeline}_lastLogTime=0;_logOpen=!1;_logDrawCallStart(){const e=Gp.level>3?0:1e4;Gp.level<2||Date.now()-this._lastLogTime>> DRAWING MODEL ${this.id}`,{collapsed:Gp.level<=2})())}_logDrawCallEnd(){if(this._logOpen){const e=function(e){const t={},i="Values";if(0===e.attributes.length&&!e.varyings?.length)return{"No attributes or varyings":{[i]:"N/A"}};for(const n of e.attributes)n&&(t[`in ${n.location} ${n.name}: ${n.type}`]={[i]:n.stepMode||"vertex"});for(const n of e.varyings||[])t[`out ${n.location} ${n.name}`]={[i]:JSON.stringify(n.accessor)};return t}(this.pipeline.shaderLayout,this.id);Gp.table(2,e)();const t=this.shaderInputs.getDebugTable();for(const[e,i]of Object.entries(this.uniforms))t[e]={value:i};Gp.table(2,t)();const i=this._getAttributeDebugTable();Gp.table(2,this._attributeInfos)(),Gp.table(2,i)(),Gp.groupEnd(2)(),this._logOpen=!1}}_drawCount=0;_logFramebuffer(e){const t=Gp.get("framebuffer");if(this._drawCount++,!t||this._drawCount++>3&&this._drawCount%60)return;const i=e.props.framebuffer;i&&function(e,{id:t,minimap:i,opaque:n,top:r="0",left:o="0",rgbaScale:s=1}){vx||(vx=document.createElement("canvas"),vx.id=t,vx.title=t,vx.style.zIndex="100",vx.style.position="absolute",vx.style.top=r,vx.style.left=o,vx.style.border="blue 1px solid",vx.style.transform="scaleY(-1)",document.body.appendChild(vx),xx=vx.getContext("2d")),vx.width===e.width&&vx.height===e.height||(vx.width=e.width/2,vx.height=e.height/2,vx.style.width="400px",vx.style.height="400px");const a=e.device.readPixelsToArrayWebGL(e),l=xx.createImageData(e.width,e.height);for(let e=0;et.name===e.name);t<0?i.push(e):i[t]=e}return i}function Tx(e){return e.attributes?e.attributes?.map(e=>e.attribute):[e.name]}class Ex{device;model;transformFeedback;static isSupported(e){return"webgl"===e?.info?.type}constructor(e,t=bx.defaultProps){cf(Ex.isSupported(e),"BufferTransform not yet implemented on WebGPU"),this.device=e,this.model=new bx(this.device,{id:t.id||"buffer-transform-model",fs:t.fs||jp(),topology:t.topology||"point-list",...t}),this.transformFeedback=this.device.createTransformFeedback({layout:this.model.pipeline.shaderLayout,buffers:t.feedbackBuffers}),this.model.setTransformFeedback(this.transformFeedback),Object.seal(this)}destroy(){this.model&&this.model.destroy()}delete(){this.destroy()}run(e){const t=this.device.beginRenderPass(e);this.model.draw(t),t.end()}update(...e){console.warn("TextureTransform#update() not implemented")}getBuffer(e){return this.transformFeedback.getBuffer(e)}readAsync(e){const t=this.getBuffer(e);if(t instanceof Xp)return t.readAsync();const{buffer:i,byteOffset:n=0,byteLength:r=i.byteLength}=t;return i.readAsync(n,r)}}class Cx{id;topology;vertexCount;indices;attributes;userData={};constructor(e){const{attributes:t={},indices:i=null,vertexCount:n=null}=e;this.id=e.id||Wp("geometry"),this.topology=e.topology,i&&(this.indices=ArrayBuffer.isView(i)?{value:i,size:1}:i),this.attributes={};for(const[e,i]of Object.entries(t)){const t=ArrayBuffer.isView(i)?{value:i}:i;cf(ArrayBuffer.isView(t.value),`${this._print(e)}: must be typed array or object with value as typed array`),"POSITION"!==e&&"positions"!==e||t.size||(t.size=3),"indices"===e?(cf(!this.indices),this.indices=t):this.attributes[e]=t}this.indices&&void 0!==this.indices.isIndexed&&(this.indices=Object.assign({},this.indices),delete this.indices.isIndexed),this.vertexCount=n||this._calculateVertexCount(this.attributes,this.indices)}getVertexCount(){return this.vertexCount}getAttributes(){return this.indices?{indices:this.indices,...this.attributes}:this.attributes}_print(e){return`Geometry ${this.id} attribute ${e}`}_setAttributes(e,t){return this}_calculateVertexCount(e,t){if(t)return t.value.length;let i=1/0;for(const t of Object.values(e)){const{value:e,size:n,constant:r}=t;!r&&e&&n>=1&&(i=Math.min(i,e.length/n))}return cf(Number.isFinite(i)),i}}class Sx{id;matrix=new HA;display=!0;position=new AA;rotation=new AA;scale=new AA(1,1,1);userData={};props={};constructor(e={}){const{id:t}=e;this.id=t||Wp(this.constructor.name),this._setScenegraphNodeProps(e)}getBounds(){return null}destroy(){}delete(){this.destroy()}setProps(e){return this._setScenegraphNodeProps(e),this}toString(){return`{type: ScenegraphNode, id: ${this.id})}`}setPosition(e){return cf(3===e.length,"setPosition requires vector argument"),this.position=e,this}setRotation(e){return cf(3===e.length,"setRotation requires vector argument"),this.rotation=e,this}setScale(e){return cf(3===e.length,"setScale requires vector argument"),this.scale=e,this}setMatrix(e,t=!0){t?this.matrix.copy(e):this.matrix=e}setMatrixComponents(e){const{position:t,rotation:i,scale:n,update:r=!0}=e;return t&&this.setPosition(t),i&&this.setRotation(i),n&&this.setScale(n),r&&this.updateMatrix(),this}updateMatrix(){const e=this.position,t=this.rotation,i=this.scale;return this.matrix.identity(),this.matrix.translate(e),this.matrix.rotateXYZ(t),this.matrix.scale(i),this}update(e={}){const{position:t,rotation:i,scale:n}=e;return t&&this.setPosition(t),i&&this.setRotation(i),n&&this.setScale(n),this.updateMatrix(),this}getCoordinateUniforms(e,t){cf(e),t=t||this.matrix;const i=new HA(e).multiplyRight(t),n=i.invert(),r=n.transpose();return{viewMatrix:e,modelMatrix:t,objectMatrix:t,worldMatrix:i,worldInverseMatrix:n,worldInverseTransposeMatrix:r}}_setScenegraphNodeProps(e){"display"in e&&(this.display=e.display),"position"in e&&this.setPosition(e.position),"rotation"in e&&this.setRotation(e.rotation),"scale"in e&&this.setScale(e.scale),"matrix"in e&&this.setMatrix(e.matrix),Object.assign(this.props,e)}}class Bx extends Sx{children;constructor(e={}){e=Array.isArray(e)?{children:e}:e;const{children:t=[]}=e;Gp.assert(t.every(e=>e instanceof Sx),"every child must an instance of ScenegraphNode"),super(e),this.children=t}getBounds(){const e=[[1/0,1/0,1/0],[-1/0,-1/0,-1/0]];return this.traverse((t,{worldMatrix:i})=>{const n=t.getBounds();if(!n)return;const[r,o]=n,s=new AA(r).add(o).divide([2,2,2]);i.transformAsPoint(s,s);const a=new AA(o).subtract(r).divide([2,2,2]);i.transformAsVector(a,a);for(let t=0;t<8;t++){const i=new AA(1&t?-1:1,2&t?-1:1,4&t?-1:1).multiply(a).add(s);for(let t=0;t<3;t++)e[0][t]=Math.min(e[0][t],i[t]),e[1][t]=Math.max(e[1][t],i[t])}}),Number.isFinite(e[0][0])?e:null}destroy(){this.children.forEach(e=>e.destroy()),this.removeAll(),super.destroy()}add(...e){for(const t of e)Array.isArray(t)?this.add(...t):this.children.push(t);return this}remove(e){const t=this.children,i=t.indexOf(e);return i>-1&&t.splice(i,1),this}removeAll(){return this.children=[],this}traverse(e,{worldMatrix:t=new HA}={}){const i=new HA(t).multiplyRight(this.matrix);for(const t of this.children)t instanceof Bx?t.traverse(e,{worldMatrix:i}):e(t,{worldMatrix:i})}}class Ix extends Sx{model;bounds=null;managedResources;constructor(e){super(e),this.model=e.model,this.managedResources=e.managedResources||[],this.bounds=e.bounds||null,this.setProps(e)}getBounds(){return this.bounds}destroy(){this.model&&(this.model.destroy(),this.model=null),this.managedResources.forEach(e=>e.destroy()),this.managedResources=[]}draw(e){return this.model.draw(e)}}const Mx={blendColorOperation:"add",blendColorSrcFactor:"one",blendColorDstFactor:"zero",blendAlphaOperation:"add",blendAlphaSrcFactor:"constant-alpha",blendAlphaDstFactor:"zero"};class Px extends Mv{constructor(){super(...arguments),this._colorEncoderState=null}render(e){return"pickingFBO"in e?this._drawPickingBuffer(e):super.render(e)}_drawPickingBuffer({layers:e,layerFilter:t,views:i,viewports:n,onViewportActive:r,pickingFBO:o,deviceRect:{x:s,y:a,width:l,height:c},cullRect:u,effects:h,pass:d="picking",pickZ:p,moduleParameters:f}){this.pickZ=p;const m=this._resetColorEncoder(p),g=[s,a,l,c],_=super.render({target:o,layers:e,layerFilter:t,views:i,viewports:n,onViewportActive:r,cullRect:u,effects:h?.filter(e=>e.useInPicking),pass:d,isPicking:!0,moduleParameters:f,clearColor:[0,0,0,0],colorMask:15,scissorRect:g});this._colorEncoderState=null;return{decodePickingColor:m&&Rx.bind(null,m),stats:_}}shouldDrawLayer(e){const{pickable:t,operation:i}=e.props;return t&&i.includes("draw")||i.includes("terrain")||i.includes("mask")}getModuleParameters(){return{picking:{isActive:1,isAttribute:this.pickZ},lightSources:{}}}getLayerParameters(e,t,i){const n={depthMask:!0,depthTest:!0,depthRange:[0,1],...e.props.parameters},{pickable:r,operation:o}=e.props;return!this._colorEncoderState||o.includes("terrain")?n.blend=!1:r&&o.includes("draw")&&(Object.assign(n,Mx),n.blend=!0,n.blendColor=function(e,t,i){const{byLayer:n,byAlpha:r}=e;let o,s=n.get(t);s?(s.viewports.push(i),o=s.a):(o=n.size+1,o<=255?(s={a:o,layer:t,viewports:[i]},n.set(t,s),r[o]=s):(rp.warn("Too many pickable layers, only picking the first 255")(),o=0));return[0,0,0,o/255]}(this._colorEncoderState,e,i)),n}_resetColorEncoder(e){return this._colorEncoderState=e?null:{byLayer:new Map,byAlpha:[]},this._colorEncoderState}}function Rx(e,t){const i=e.byAlpha[t[3]];return i&&{pickedLayer:i.layer,pickedViewports:i.viewports,pickedObjectIndex:i.layer.decodePickingColor(t)}}const Lx="Awaiting state",Fx="Matched. State transferred from previous layer",kx="Initialized",Dx="Discarded. Awaiting garbage collection",Ox="No longer matched. Awaiting garbage collection",zx="Finalized! Awaiting garbage collection",Ux=Symbol.for("component"),Nx=Symbol.for("propTypes"),Vx=Symbol.for("deprecatedProps"),jx=Symbol.for("asyncPropDefaults"),Gx=Symbol.for("asyncPropOriginal"),Hx=Symbol.for("asyncPropResolved");function Qx(e,t=()=>!0){return Array.isArray(e)?$x(e,t,[]):t(e)?[e]:[]}function $x(e,t,i){let n=-1;for(;++n0}delete(){}getData(){return this.isLoaded?this._error?Promise.reject(this._error):this._content:this._loader.then(()=>this.getData())}setData(e,t){if(e===this._data&&!t)return;this._data=e;const i=++this._loadCount;let n=e;"string"==typeof e&&(n=Fd(e)),n instanceof Promise?(this.isLoaded=!1,this._loader=n.then(e=>{this._loadCount===i&&(this.isLoaded=!0,this._error=void 0,this._content=e)}).catch(e=>{this._loadCount===i&&(this.isLoaded=!0,this._error=e||!0)})):(this.isLoaded=!0,this._error=void 0,this._content=e);for(const e of this._subscribers)e.onChange(this.getData())}}class qx{constructor(e){this.protocol=e.protocol||"resource://",this._context={device:e.device,gl:e.device?.gl,resourceManager:this},this._resources={},this._consumers={},this._pruneRequest=null}contains(e){return!!e.startsWith(this.protocol)||e in this._resources}add({resourceId:e,data:t,forceUpdate:i=!1,persistent:n=!0}){let r=this._resources[e];r?r.setData(t,i):(r=new Wx(e,t,this._context),this._resources[e]=r),r.persistent=n}remove(e){const t=this._resources[e];t&&(t.delete(),delete this._resources[e])}unsubscribe({consumerId:e}){const t=this._consumers[e];if(t){for(const e in t){const i=t[e],n=this._resources[i.resourceId];n&&n.unsubscribe(i)}delete this._consumers[e],this.prune()}}subscribe({resourceId:e,onChange:t,consumerId:i,requestId:n="default"}){const{_resources:r,protocol:o}=this;e.startsWith(o)&&(r[e=e.replace(o,"")]||this.add({resourceId:e,data:null,persistent:!1}));const s=r[e];if(this._track(i,n,s,t),s)return s.getData()}prune(){this._pruneRequest||(this._pruneRequest=setTimeout(()=>this._prune(),0))}finalize(){for(const e in this._resources)this._resources[e].delete()}_track(e,t,i,n){const r=this._consumers,o=r[e]=r[e]||{};let s=o[t];const a=s&&s.resourceId&&this._resources[s.resourceId];a&&(a.unsubscribe(s),this.prune()),i&&(s?(s.onChange=n,s.resourceId=i.id):s={onChange:n,resourceId:i.id},o[t]=s,i.subscribe(s))}_prune(){this._pruneRequest=null;for(const e of Object.keys(this._resources)){const t=this._resources[e];t.persistent||t.inUse()||(t.delete(),delete this._resources[e])}}}class Kx{constructor(e,t){this._lastRenderedLayers=[],this._needsRedraw=!1,this._needsUpdate=!1,this._nextLayers=null,this._debug=!1,this._defaultShaderModulesChanged=!1,this.activateViewport=e=>{lp("layerManager.activateViewport",this,e),e&&(this.context.viewport=e)};const{deck:i,stats:n,viewport:r,timeline:o}=t||{};this.layers=[],this.resourceManager=new qx({device:e,protocol:"deck://"}),this.context={mousePosition:null,userData:{},layerManager:this,device:e,gl:e?.gl,deck:i,shaderAssembler:yv(),defaultShaderModules:[],renderPass:void 0,stats:n||new Ch({id:"deck.gl"}),viewport:r||new qv({id:"DEFAULT-INITIAL-VIEWPORT"}),timeline:o||new hx,resourceManager:this.resourceManager,onError:void 0},Object.seal(this)}finalize(){this.resourceManager.finalize();for(const e of this.layers)this._finalizeLayer(e)}needsRedraw(e={clearRedrawFlags:!1}){let t=this._needsRedraw;e.clearRedrawFlags&&(this._needsRedraw=!1);for(const i of this.layers){const n=i.getNeedsRedraw(e);t=t||n}return t}needsUpdate(){return this._nextLayers&&this._nextLayers!==this._lastRenderedLayers?"layers changed":this._defaultShaderModulesChanged?"shader modules changed":this._needsUpdate}setNeedsRedraw(e){this._needsRedraw=this._needsRedraw||e}setNeedsUpdate(e){this._needsUpdate=this._needsUpdate||e}getLayers({layerIds:e}={}){return e?this.layers.filter(t=>e.find(e=>0===t.id.indexOf(e))):this.layers}setProps(e){"debug"in e&&(this._debug=e.debug),"userData"in e&&(this.context.userData=e.userData),"layers"in e&&(this._nextLayers=e.layers),"onError"in e&&(this.context.onError=e.onError)}setLayers(e,t){lp("layerManager.setLayers",this,t,e),this._lastRenderedLayers=e;const i=Qx(e,Boolean);for(const e of i)e.context=this.context;this._updateLayers(this.layers,i)}updateLayers(){const e=this.needsUpdate();e&&(this.setNeedsRedraw(`updating layers: ${e}`),this.setLayers(this._nextLayers||this._lastRenderedLayers,e)),this._nextLayers=null}addDefaultShaderModule(e){const{defaultShaderModules:t}=this.context;t.find(t=>t.name===e.name)||(t.push(e),this._defaultShaderModulesChanged=!0)}removeDefaultShaderModule(e){const{defaultShaderModules:t}=this.context,i=t.findIndex(t=>t.name===e.name);i>=0&&(t.splice(i,1),this._defaultShaderModulesChanged=!0)}_handleError(e,t,i){i.raiseError(t,`${e} of ${i}`)}_updateLayers(e,t){const i={};for(const t of e)i[t.id]?rp.warn(`Multiple old layers with same id ${t.id}`)():i[t.id]=t;if(this._defaultShaderModulesChanged){for(const t of e)t.setNeedsUpdate(),t.setChangeFlags({extensionsChanged:!0});this._defaultShaderModulesChanged=!1}const n=[];this._updateSublayersRecursively(t,i,n),this._finalizeOldLayers(i);let r=!1;for(const e of n)if(e.hasUniformTransition()){r=`Uniform transition in ${e}`;break}this._needsUpdate=r,this.layers=n}_updateSublayersRecursively(e,t,i){for(const n of e){n.context=this.context;const e=t[n.id];null===e&&rp.warn(`Multiple new layers with same id ${n.id}`)(),t[n.id]=null;let r=null;try{this._debug&&e!==n&&n.validateProps(),e?(this._transferLayerState(e,n),this._updateLayer(n)):this._initializeLayer(n),i.push(n),r=n.isComposite?n.getSubLayers():null}catch(e){this._handleError("matching",e,n)}r&&this._updateSublayersRecursively(r,t,i)}}_finalizeOldLayers(e){for(const t in e){const i=e[t];i&&this._finalizeLayer(i)}}_initializeLayer(e){try{e._initialize(),e.lifecycle=kx}catch(t){this._handleError("initialization",t,e)}}_transferLayerState(e,t){t._transferState(e),t.lifecycle=Fx,t!==e&&(e.lifecycle=Dx)}_updateLayer(e){try{e._update()}catch(t){this._handleError("update",t,e)}}_finalizeLayer(e){this._needsRedraw=this._needsRedraw||`finalized ${e}`,e.lifecycle=Ox;try{e._finalize(),e.lifecycle=zx}catch(t){this._handleError("finalization",t,e)}}}function Xx(e,t,i){if(e===t)return!0;if(!i||!e||!t)return!1;if(Array.isArray(e)){if(!Array.isArray(t)||e.length!==t.length)return!1;for(let n=0;nt.containsPixel(e)):this._viewports}getViews(){const e={};return this.views.forEach(t=>{e[t.id]=t}),e}getView(e){return this.views.find(t=>t.id===e)}getViewState(e){const t="string"==typeof e?this.getView(e):e,i=t&&this.viewState[t.getViewStateId()]||this.viewState;return t?t.filterViewState(i):i}getViewport(e){return this._viewportMap[e]}unproject(e,t){const i=this.getViewports(),n={x:e[0],y:e[1]};for(let r=i.length-1;r>=0;--r){const o=i[r];if(o.containsPixel(n)){const i=e.slice();return i[0]-=o.x,i[1]-=o.y,o.unproject(i,t)}}return null}setProps(e){e.views&&this._setViews(e.views),e.viewState&&this._setViewState(e.viewState),("width"in e||"height"in e)&&this._setSize(e.width,e.height),this._isUpdating||this._update()}_update(){this._isUpdating=!0,this._needsUpdate&&(this._needsUpdate=!1,this._rebuildViewports()),this._needsUpdate&&(this._needsUpdate=!1,this._rebuildViewports()),this._isUpdating=!1}_setSize(e,t){e===this.width&&t===this.height||(this.width=e,this.height=t,this.setNeedsUpdate("Size changed"))}_setViews(e){e=Qx(e,Boolean);this._diffViews(e,this.views)&&this.setNeedsUpdate("views changed"),this.views=e}_setViewState(e){if(e){!Xx(e,this.viewState,3)&&this.setNeedsUpdate("viewState changed"),this.viewState=e}else rp.warn("missing `viewState` or `initialViewState`")()}_createController(e,t){return new(0,t.type)({timeline:this.timeline,eventManager:this._eventManager,onViewStateChange:this._eventCallbacks.onViewStateChange,onStateChange:this._eventCallbacks.onInteractionStateChange,makeViewport:t=>this.getView(e.id)?.makeViewport({viewState:t,width:this.width,height:this.height})})}_updateController(e,t,i,n){const r=e.controller;if(r&&i){const o={...t,...r,id:e.id,x:i.x,y:i.y,width:i.width,height:i.height};return n&&n.constructor===r.type||(n=this._createController(e,o)),n&&n.setProps(o),n}return null}_rebuildViewports(){const{views:e}=this,t=this.controllers;this._viewports=[],this.controllers={};let i=!1;for(let n=e.length;n--;){const r=e[n],o=this.getViewState(r),s=r.makeViewport({viewState:o,width:this.width,height:this.height});let a=t[r.id];const l=Boolean(r.controller);l&&!a&&(i=!0),!i&&l||!a||(a.finalize(),a=null),this.controllers[r.id]=this._updateController(r,o,s,a),s&&this._viewports.unshift(s)}for(const e in t){const i=t[e];i&&!this.controllers[e]&&i.finalize()}this._buildViewportMap()}_buildViewportMap(){this._viewportMap={},this._viewports.forEach(e=>{e.id&&(this._viewportMap[e.id]=this._viewportMap[e.id]||e)})}_diffViews(e,t){return e.length!==t.length||e.some((i,n)=>!e[n].equals(t[n]))}}const Yx=/([0-9]+\.?[0-9]*)(%|px)/;function eb(e){switch(typeof e){case"number":return{position:e,relative:!1};case"string":const t=Yx.exec(e);if(t&&t.length>=3){const e="%"===t[2],i=parseFloat(t[1]);return{position:e?i/100:i,relative:e}}default:throw new Error(`Could not parse position string ${e}`)}}function tb(e,t){return e.relative?Math.round(e.position*t):e.position}class ib{constructor(e){const{id:t,x:i=0,y:n=0,width:r="100%",height:o="100%",padding:s=null}=e;this.id=t||this.constructor.displayName||"view",this.props={...e,id:this.id},this._x=eb(i),this._y=eb(n),this._width=eb(r),this._height=eb(o),this._padding=s&&{left:eb(s.left||0),right:eb(s.right||0),top:eb(s.top||0),bottom:eb(s.bottom||0)},this.equals=this.equals.bind(this),Object.seal(this)}equals(e){return this===e||this.ViewportType===e.ViewportType&&Xx(this.props,e.props,2)}makeViewport({width:e,height:t,viewState:i}){i=this.filterViewState(i);const n=this.getDimensions({width:e,height:t});return n.height&&n.width?new this.ViewportType({...i,...this.props,...n}):null}getViewStateId(){const{viewState:e}=this.props;return"string"==typeof e?e:e?.id||this.id}filterViewState(e){if(this.props.viewState&&"object"==typeof this.props.viewState){if(!this.props.viewState.id)return this.props.viewState;const t={...e};for(const e in this.props.viewState)"id"!==e&&(t[e]=this.props.viewState[e]);return t}return e}getDimensions({width:e,height:t}){const i={x:tb(this._x,e),y:tb(this._y,t),width:tb(this._width,e),height:tb(this._height,t)};return this._padding&&(i.padding={left:tb(this._padding.left,e),top:tb(this._padding.top,t),right:tb(this._padding.right,e),bottom:tb(this._padding.bottom,t)}),i}get controller(){const e=this.props.controller;return e?!0===e?{type:this.ControllerType}:"function"==typeof e?{type:e}:{type:this.ControllerType,...e}:null}}class nb{constructor(e){this._inProgress=!1,this._handle=null,this.time=0,this.settings={duration:0},this._timeline=e}get inProgress(){return this._inProgress}start(e){this.cancel(),this.settings=e,this._inProgress=!0,this.settings.onStart?.(this)}end(){this._inProgress&&(this._timeline.removeChannel(this._handle),this._handle=null,this._inProgress=!1,this.settings.onEnd?.(this))}cancel(){this._inProgress&&(this.settings.onInterrupt?.(this),this._timeline.removeChannel(this._handle),this._handle=null,this._inProgress=!1)}update(){if(!this._inProgress)return!1;if(null===this._handle){const{_timeline:e,settings:t}=this;this._handle=e.addChannel({delay:e.getTime(),duration:t.duration})}return this.time=this._timeline.getTime(this._handle),this._onUpdate(),this.settings.onUpdate?.(this),this._timeline.isFinished(this._handle)&&this.end(),!0}_onUpdate(){}}const rb=()=>{},ob=2,sb=3,ab=e=>e,lb=1;class cb{constructor(e){this._onTransitionUpdate=e=>{const{time:t,settings:{interpolator:i,startProps:n,endProps:r,duration:o,easing:s}}=e,a=s(t/o),l=i.interpolateProps(n,r,a);this.propsInTransition=this.getControllerState({...this.props,...l}).getViewportProps(),this.onViewStateChange({viewState:this.propsInTransition,oldViewState:this.props})},this.getControllerState=e.getControllerState,this.propsInTransition=null,this.transition=new nb(e.timeline),this.onViewStateChange=e.onViewStateChange||rb,this.onStateChange=e.onStateChange||rb}finalize(){this.transition.cancel()}getViewportInTransition(){return this.propsInTransition}processViewStateChange(e){let t=!1;const i=this.props;if(this.props=e,!i||this._shouldIgnoreViewportChange(i,e))return!1;if(this._isTransitionEnabled(e)){let n=i;if(this.transition.inProgress){const{interruption:e,endProps:t}=this.transition.settings;n={...i,...e===ob?t:this.propsInTransition||i}}this._triggerTransition(n,e),t=!0}else this.transition.cancel();return t}updateTransition(){this.transition.update()}_isTransitionEnabled(e){const{transitionDuration:t,transitionInterpolator:i}=e;return(t>0||"auto"===t)&&Boolean(i)}_isUpdateDueToCurrentTransition(e){return!(!this.transition.inProgress||!this.propsInTransition)&&this.transition.settings.interpolator.arePropsEqual(e,this.propsInTransition)}_shouldIgnoreViewportChange(e,t){if(this.transition.inProgress){return this.transition.settings.interruption===sb||this._isUpdateDueToCurrentTransition(t)}return!this._isTransitionEnabled(t)||t.transitionInterpolator.arePropsEqual(e,t)}_triggerTransition(e,t){const i=this.getControllerState(e),n=this.getControllerState(t).shortestPathFrom(i),r=t.transitionInterpolator,o=r.getDuration?r.getDuration(e,t):t.transitionDuration;if(0===o)return;const s=r.initializeProps(e,n);this.propsInTransition={};const a={duration:o,easing:t.transitionEasing||ab,interpolator:r,interruption:t.transitionInterruption||lb,startProps:s.start,endProps:s.end,onStart:t.onTransitionStart,onUpdate:this._onTransitionUpdate,onInterrupt:this._onTransitionEnd(t.onTransitionInterrupt),onEnd:this._onTransitionEnd(t.onTransitionEnd)};this.transition.start(a),this.onStateChange({inTransition:!0}),this.updateTransition()}_onTransitionEnd(e){return t=>{this.propsInTransition=null,this.onStateChange({inTransition:!1,isZooming:!1,isPanning:!1,isRotating:!1}),e?.(t)}}}function ub(e,t){if(!e)throw new Error(t||"deck.gl: assertion failed.")}class hb{constructor(e){const{compare:t,extract:i,required:n}=e;this._propsToCompare=t,this._propsToExtract=i||t,this._requiredProps=n}arePropsEqual(e,t){for(const i of this._propsToCompare)if(!(i in e)||!(i in t)||!N_(e[i],t[i]))return!1;return!0}initializeProps(e,t){const i={},n={};for(const r of this._propsToExtract)(r in e||r in t)&&(i[r]=e[r],n[r]=t[r]);return this._checkRequiredProps(i),this._checkRequiredProps(n),{start:i,end:n}}getDuration(e,t){return t.transitionDuration}_checkRequiredProps(e){this._requiredProps&&this._requiredProps.forEach(t=>{const i=e[t];ub(Number.isFinite(i)||Array.isArray(i),`${t} is required for transition`)})}}const db=["longitude","latitude","zoom","bearing","pitch"],pb=["longitude","latitude","zoom"];class fb extends hb{constructor(e={}){const t=Array.isArray(e)?e:e.transitionProps,i=Array.isArray(e)?{}:e;i.transitionProps=Array.isArray(t)?{compare:t,required:t}:t||{compare:db,required:pb},super(i.transitionProps),this.opts=i}initializeProps(e,t){const i=super.initializeProps(e,t),{makeViewport:n,around:r}=this.opts;if(n&&r){const o=n(e),s=n(t),a=o.unproject(r);i.start.around=r,Object.assign(i.end,{around:s.project(a),aroundPosition:a,width:t.width,height:t.height})}return i}interpolateProps(e,t,i){const n={};for(const r of this._propsToExtract)n[r]=U_(e[r]||0,t[r]||0,i);if(t.aroundPosition&&this.opts.makeViewport){const r=this.opts.makeViewport({...t,...n});Object.assign(n,r.panByPosition(t.aroundPosition,U_(e.around,t.around,i)))}return n}}const mb={transitionDuration:0},gb=e=>1-(1-e)*(1-e),_b=["wheel"],Ab=["panstart","panmove","panend"],yb=["pinchstart","pinchmove","pinchend"],vb=["tripanstart","tripanmove","tripanend"],xb=["doubletap"],bb=["keydown"],wb={};class Tb{constructor(e){this.state={},this._events={},this._interactionState={isDragging:!1},this._customEvents=[],this._eventStartBlocked=null,this._panMove=!1,this.invertPan=!1,this.dragMode="rotate",this.inertia=0,this.scrollZoom=!0,this.dragPan=!0,this.dragRotate=!0,this.doubleClickZoom=!0,this.touchZoom=!0,this.touchRotate=!1,this.keyboard=!0,this.transitionManager=new cb({...e,getControllerState:e=>new this.ControllerState(e),onViewStateChange:this._onTransition.bind(this),onStateChange:this._setInteractionState.bind(this)}),this.handleEvent=this.handleEvent.bind(this),this.eventManager=e.eventManager,this.onViewStateChange=e.onViewStateChange||(()=>{}),this.onStateChange=e.onStateChange||(()=>{}),this.makeViewport=e.makeViewport}set events(e){this.toggleEvents(this._customEvents,!1),this.toggleEvents(e,!0),this._customEvents=e,this.props&&this.setProps(this.props)}finalize(){for(const e in this._events)this._events[e]&&this.eventManager?.off(e,this.handleEvent);this.transitionManager.finalize()}handleEvent(e){this._controllerState=void 0;const t=this._eventStartBlocked;switch(e.type){case"panstart":return!t&&this._onPanStart(e);case"panmove":return this._onPan(e);case"panend":return this._onPanEnd(e);case"pinchstart":return!t&&this._onPinchStart(e);case"pinchmove":return this._onPinch(e);case"pinchend":return this._onPinchEnd(e);case"tripanstart":return!t&&this._onTriplePanStart(e);case"tripanmove":return this._onTriplePan(e);case"tripanend":return this._onTriplePanEnd(e);case"doubletap":return this._onDoubleTap(e);case"wheel":return this._onWheel(e);case"keydown":return this._onKeyDown(e);default:return!1}}get controllerState(){return this._controllerState=this._controllerState||new this.ControllerState({makeViewport:this.makeViewport,...this.props,...this.state}),this._controllerState}getCenter(e){const{x:t,y:i}=this.props,{offsetCenter:n}=e;return[n.x-t,n.y-i]}isPointInBounds(e,t){const{width:i,height:n}=this.props;if(t&&t.handled)return!1;const r=e[0]>=0&&e[0]<=i&&e[1]>=0&&e[1]<=n;return r&&t&&t.stopPropagation(),r}isFunctionKeyPressed(e){const{srcEvent:t}=e;return Boolean(t.metaKey||t.altKey||t.ctrlKey||t.shiftKey)}isDragging(){return this._interactionState.isDragging||!1}blockEvents(e){const t=setTimeout(()=>{this._eventStartBlocked===t&&(this._eventStartBlocked=null)},e);this._eventStartBlocked=t}setProps(e){e.dragMode&&(this.dragMode=e.dragMode),this.props=e,"transitionInterpolator"in e||(e.transitionInterpolator=this._getTransitionProps().transitionInterpolator),this.transitionManager.processViewStateChange(e);const{inertia:t}=e;this.inertia=Number.isFinite(t)?t:!0===t?300:0;const{scrollZoom:i=!0,dragPan:n=!0,dragRotate:r=!0,doubleClickZoom:o=!0,touchZoom:s=!0,touchRotate:a=!1,keyboard:l=!0}=e,c=Boolean(this.onViewStateChange);this.toggleEvents(_b,c&&i),this.toggleEvents(Ab,c),this.toggleEvents(yb,c&&(s||a)),this.toggleEvents(vb,c&&a),this.toggleEvents(xb,c&&o),this.toggleEvents(bb,c&&l),this.scrollZoom=i,this.dragPan=n,this.dragRotate=r,this.doubleClickZoom=o,this.touchZoom=s,this.touchRotate=a,this.keyboard=l}updateTransition(){this.transitionManager.updateTransition()}toggleEvents(e,t){this.eventManager&&e.forEach(e=>{this._events[e]!==t&&(this._events[e]=t,t?this.eventManager.on(e,this.handleEvent):this.eventManager.off(e,this.handleEvent))})}updateViewport(e,t=null,i={}){const n={...e.getViewportProps(),...t},r=this.controllerState!==e;if(this.state=e.getState(),this._setInteractionState(i),r){const e=this.controllerState&&this.controllerState.getViewportProps();this.onViewStateChange&&this.onViewStateChange({viewState:n,interactionState:this._interactionState,oldViewState:e,viewId:this.props.id})}}_onTransition(e){this.onViewStateChange({...e,interactionState:this._interactionState,viewId:this.props.id})}_setInteractionState(e){Object.assign(this._interactionState,e),this.onStateChange(this._interactionState)}_onPanStart(e){const t=this.getCenter(e);if(!this.isPointInBounds(t,e))return!1;let i=this.isFunctionKeyPressed(e)||e.rightButton||!1;(this.invertPan||"pan"===this.dragMode)&&(i=!i);const n=this.controllerState[i?"panStart":"rotateStart"]({pos:t});return this._panMove=i,this.updateViewport(n,mb,{isDragging:!0}),!0}_onPan(e){return!!this.isDragging()&&(this._panMove?this._onPanMove(e):this._onPanRotate(e))}_onPanEnd(e){return!!this.isDragging()&&(this._panMove?this._onPanMoveEnd(e):this._onPanRotateEnd(e))}_onPanMove(e){if(!this.dragPan)return!1;const t=this.getCenter(e),i=this.controllerState.pan({pos:t});return this.updateViewport(i,mb,{isDragging:!0,isPanning:!0}),!0}_onPanMoveEnd(e){const{inertia:t}=this;if(this.dragPan&&t&&e.velocity){const i=this.getCenter(e),n=[i[0]+e.velocityX*t/2,i[1]+e.velocityY*t/2],r=this.controllerState.pan({pos:n}).panEnd();this.updateViewport(r,{...this._getTransitionProps(),transitionDuration:t,transitionEasing:gb},{isDragging:!1,isPanning:!0})}else{const e=this.controllerState.panEnd();this.updateViewport(e,null,{isDragging:!1,isPanning:!1})}return!0}_onPanRotate(e){if(!this.dragRotate)return!1;const t=this.getCenter(e),i=this.controllerState.rotate({pos:t});return this.updateViewport(i,mb,{isDragging:!0,isRotating:!0}),!0}_onPanRotateEnd(e){const{inertia:t}=this;if(this.dragRotate&&t&&e.velocity){const i=this.getCenter(e),n=[i[0]+e.velocityX*t/2,i[1]+e.velocityY*t/2],r=this.controllerState.rotate({pos:n}).rotateEnd();this.updateViewport(r,{...this._getTransitionProps(),transitionDuration:t,transitionEasing:gb},{isDragging:!1,isRotating:!0})}else{const e=this.controllerState.rotateEnd();this.updateViewport(e,null,{isDragging:!1,isRotating:!1})}return!0}_onWheel(e){if(!this.scrollZoom)return!1;const t=this.getCenter(e);if(!this.isPointInBounds(t,e))return!1;e.srcEvent.preventDefault();const{speed:i=.01,smooth:n=!1}=!0===this.scrollZoom?{}:this.scrollZoom,{delta:r}=e;let o=2/(1+Math.exp(-Math.abs(r*i)));r<0&&0!==o&&(o=1/o);const s=this.controllerState.zoom({pos:t,scale:o});return this.updateViewport(s,{...this._getTransitionProps({around:t}),transitionDuration:n?250:1},{isZooming:!0,isPanning:!0}),!0}_onTriplePanStart(e){const t=this.getCenter(e);if(!this.isPointInBounds(t,e))return!1;const i=this.controllerState.rotateStart({pos:t});return this.updateViewport(i,mb,{isDragging:!0}),!0}_onTriplePan(e){if(!this.touchRotate)return!1;if(!this.isDragging())return!1;const t=this.getCenter(e);t[0]-=e.deltaX;const i=this.controllerState.rotate({pos:t});return this.updateViewport(i,mb,{isDragging:!0,isRotating:!0}),!0}_onTriplePanEnd(e){if(!this.isDragging())return!1;const{inertia:t}=this;if(this.touchRotate&&t&&e.velocityY){const i=this.getCenter(e),n=[i[0],i[1]+=e.velocityY*t/2],r=this.controllerState.rotate({pos:n});this.updateViewport(r,{...this._getTransitionProps(),transitionDuration:t,transitionEasing:gb},{isDragging:!1,isRotating:!0}),this.blockEvents(t)}else{const e=this.controllerState.rotateEnd();this.updateViewport(e,null,{isDragging:!1,isRotating:!1})}return!0}_onPinchStart(e){const t=this.getCenter(e);if(!this.isPointInBounds(t,e))return!1;const i=this.controllerState.zoomStart({pos:t}).rotateStart({pos:t});return wb._startPinchRotation=e.rotation,wb._lastPinchEvent=e,this.updateViewport(i,mb,{isDragging:!0}),!0}_onPinch(e){if(!this.touchZoom&&!this.touchRotate)return!1;if(!this.isDragging())return!1;let t=this.controllerState;if(this.touchZoom){const{scale:i}=e,n=this.getCenter(e);t=t.zoom({pos:n,scale:i})}if(this.touchRotate){const{rotation:i}=e;t=t.rotate({deltaAngleX:wb._startPinchRotation-i})}return this.updateViewport(t,mb,{isDragging:!0,isPanning:this.touchZoom,isZooming:this.touchZoom,isRotating:this.touchRotate}),wb._lastPinchEvent=e,!0}_onPinchEnd(e){if(!this.isDragging())return!1;const{inertia:t}=this,{_lastPinchEvent:i}=wb;if(this.touchZoom&&t&&i&&e.scale!==i.scale){const n=this.getCenter(e);let r=this.controllerState.rotateEnd();const o=Math.log2(e.scale),s=(o-Math.log2(i.scale))/(e.deltaTime-i.deltaTime),a=Math.pow(2,o+s*t/2);r=r.zoom({pos:n,scale:a}).zoomEnd(),this.updateViewport(r,{...this._getTransitionProps({around:n}),transitionDuration:t,transitionEasing:gb},{isDragging:!1,isPanning:this.touchZoom,isZooming:this.touchZoom,isRotating:!1}),this.blockEvents(t)}else{const e=this.controllerState.zoomEnd().rotateEnd();this.updateViewport(e,null,{isDragging:!1,isPanning:!1,isZooming:!1,isRotating:!1})}return wb._startPinchRotation=null,wb._lastPinchEvent=null,!0}_onDoubleTap(e){if(!this.doubleClickZoom)return!1;const t=this.getCenter(e);if(!this.isPointInBounds(t,e))return!1;const i=this.isFunctionKeyPressed(e),n=this.controllerState.zoom({pos:t,scale:i?.5:2});return this.updateViewport(n,this._getTransitionProps({around:t}),{isZooming:!0,isPanning:!0}),this.blockEvents(100),!0}_onKeyDown(e){if(!this.keyboard)return!1;const t=this.isFunctionKeyPressed(e),{zoomSpeed:i,moveSpeed:n,rotateSpeedX:r,rotateSpeedY:o}=!0===this.keyboard?{}:this.keyboard,{controllerState:s}=this;let a;const l={};switch(e.srcEvent.code){case"Minus":a=t?s.zoomOut(i).zoomOut(i):s.zoomOut(i),l.isZooming=!0;break;case"Equal":a=t?s.zoomIn(i).zoomIn(i):s.zoomIn(i),l.isZooming=!0;break;case"ArrowLeft":t?(a=s.rotateLeft(r),l.isRotating=!0):(a=s.moveLeft(n),l.isPanning=!0);break;case"ArrowRight":t?(a=s.rotateRight(r),l.isRotating=!0):(a=s.moveRight(n),l.isPanning=!0);break;case"ArrowUp":t?(a=s.rotateUp(o),l.isRotating=!0):(a=s.moveUp(n),l.isPanning=!0);break;case"ArrowDown":t?(a=s.rotateDown(o),l.isRotating=!0):(a=s.moveDown(n),l.isPanning=!0);break;default:return!1}return this.updateViewport(a,this._getTransitionProps(),l),!0}_getTransitionProps(e){const{transition:t}=this;return t&&t.transitionInterpolator?e?{...t,transitionInterpolator:new fb({...e,...t.transitionInterpolator.opts,makeViewport:this.controllerState.makeViewport})}:t:mb}}class Eb{constructor(e,t){this._viewportProps=this.applyConstraints(e),this._state=t}getViewportProps(){return this._viewportProps}getState(){return this._state}}class Cb extends Eb{constructor(e){const{width:t,height:i,latitude:n,longitude:r,zoom:o,bearing:s=0,pitch:a=0,altitude:l=1.5,position:c=[0,0,0],maxZoom:u=20,minZoom:h=0,maxPitch:d=60,minPitch:p=0,startPanLngLat:f,startZoomLngLat:m,startRotatePos:g,startBearing:_,startPitch:A,startZoom:y,normalize:v=!0}=e;ub(Number.isFinite(r)),ub(Number.isFinite(n)),ub(Number.isFinite(o)),super({width:t,height:i,latitude:n,longitude:r,zoom:o,bearing:s,pitch:a,altitude:l,maxZoom:u,minZoom:h,maxPitch:d,minPitch:p,normalize:v,position:c},{startPanLngLat:f,startZoomLngLat:m,startRotatePos:g,startBearing:_,startPitch:A,startZoom:y}),this.makeViewport=e.makeViewport}panStart({pos:e}){return this._getUpdatedState({startPanLngLat:this._unproject(e)})}pan({pos:e,startPos:t}){const i=this.getState().startPanLngLat||this._unproject(t);if(!i)return this;const n=this.makeViewport(this.getViewportProps()).panByPosition(i,e);return this._getUpdatedState(n)}panEnd(){return this._getUpdatedState({startPanLngLat:null})}rotateStart({pos:e}){return this._getUpdatedState({startRotatePos:e,startBearing:this.getViewportProps().bearing,startPitch:this.getViewportProps().pitch})}rotate({pos:e,deltaAngleX:t=0,deltaAngleY:i=0}){const{startRotatePos:n,startBearing:r,startPitch:o}=this.getState();if(!n||void 0===r||void 0===o)return this;let s;return s=e?this._getNewRotation(e,n,o,r):{bearing:r+t,pitch:o+i},this._getUpdatedState(s)}rotateEnd(){return this._getUpdatedState({startBearing:null,startPitch:null})}zoomStart({pos:e}){return this._getUpdatedState({startZoomLngLat:this._unproject(e),startZoom:this.getViewportProps().zoom})}zoom({pos:e,startPos:t,scale:i}){let{startZoom:n,startZoomLngLat:r}=this.getState();if(r||(n=this.getViewportProps().zoom,r=this._unproject(t)||this._unproject(e)),!r)return this;const{maxZoom:o,minZoom:s}=this.getViewportProps();let a=n+Math.log2(i);a=z_(a,s,o);const l=this.makeViewport({...this.getViewportProps(),zoom:a});return this._getUpdatedState({zoom:a,...l.panByPosition(r,e)})}zoomEnd(){return this._getUpdatedState({startZoomLngLat:null,startZoom:null})}zoomIn(e=2){return this._zoomFromCenter(e)}zoomOut(e=2){return this._zoomFromCenter(1/e)}moveLeft(e=100){return this._panFromCenter([e,0])}moveRight(e=100){return this._panFromCenter([-e,0])}moveUp(e=100){return this._panFromCenter([0,e])}moveDown(e=100){return this._panFromCenter([0,-e])}rotateLeft(e=15){return this._getUpdatedState({bearing:this.getViewportProps().bearing-e})}rotateRight(e=15){return this._getUpdatedState({bearing:this.getViewportProps().bearing+e})}rotateUp(e=10){return this._getUpdatedState({pitch:this.getViewportProps().pitch+e})}rotateDown(e=10){return this._getUpdatedState({pitch:this.getViewportProps().pitch-e})}shortestPathFrom(e){const t=e.getViewportProps(),i={...this.getViewportProps()},{bearing:n,longitude:r}=i;return Math.abs(n-t.bearing)>180&&(i.bearing=n<0?n+360:n-360),Math.abs(r-t.longitude)>180&&(i.longitude=r<0?r+360:r-360),i}applyConstraints(e){const{maxZoom:t,minZoom:i,zoom:n}=e;e.zoom=z_(n,i,t);const{maxPitch:r,minPitch:o,pitch:s}=e;e.pitch=z_(s,o,r);const{normalize:a=!0}=e;return a&&Object.assign(e,function(e){const{width:t,height:i,pitch:n=0}=e;let{longitude:r,latitude:o,zoom:s,bearing:a=0}=e;(r<-180||r>180)&&(r=Ny(r+180,360)-180),(a<-180||a>180)&&(a=Ny(a+180,360)-180);const l=jy(i/512);if(s<=l)s=l,o=0;else{const e=i/2/Math.pow(2,s),t=Yy([0,e])[1];if(ot&&(o=t)}}return{width:t,height:i,longitude:r,latitude:o,zoom:s,pitch:n,bearing:a}}(e)),e}_zoomFromCenter(e){const{width:t,height:i}=this.getViewportProps();return this.zoom({pos:[t/2,i/2],scale:e})}_panFromCenter(e){const{width:t,height:i}=this.getViewportProps();return this.pan({startPos:[t/2,i/2],pos:[t/2+e[0],i/2+e[1]]})}_getUpdatedState(e){return new this.constructor({makeViewport:this.makeViewport,...this.getViewportProps(),...this.getState(),...e})}_unproject(e){const t=this.makeViewport(this.getViewportProps());return e&&t.unproject(e)}_getNewRotation(e,t,i,n){const r=e[0]-t[0],o=e[1]-t[1],s=e[1],a=t[1],{width:l,height:c}=this.getViewportProps(),u=r/l;let h=0;o>0?Math.abs(c-a)>5&&(h=o/(a-c)*1.2):o<0&&a>5&&(h=1-s/a),h=z_(h,-1,1);const{minPitch:d,maxPitch:p}=this.getViewportProps();let f=i;return h>0?f=i+h*(p-i):h<0&&(f=i-h*(d-i)),{pitch:f,bearing:n+180*u}}}class Sb extends Tb{constructor(){super(...arguments),this.ControllerState=Cb,this.transition={transitionDuration:300,transitionInterpolator:new fb({transitionProps:{compare:["longitude","latitude","zoom","bearing","pitch","position"],required:["longitude","latitude","zoom"]}})},this.dragMode="pan"}setProps(e){e.position=e.position||[0,0,0];const t=this.props;super.setProps(e);(!t||t.height!==e.height)&&this.updateViewport(new this.ControllerState({makeViewport:this.makeViewport,...e,...this.state}))}}class Bb extends ib{constructor(e={}){super(e)}get ViewportType(){return Xv}get ControllerType(){return Sb}}Bb.displayName="MapView";var Ib=Bb;const Mb=new Dv;class Pb{constructor(e){this._resolvedEffects=[],this._defaultEffects=[],this.effects=[],this._context=e,this._needsRedraw="Initial render",this._setEffects([])}addDefaultEffect(e){const t=this._defaultEffects;if(!t.find(t=>t.id===e.id)){const i=t.findIndex(t=>{return i=e,(t.order??1/0)-(i.order??1/0)>0;var i});i<0?t.push(e):t.splice(i,0,e),e.setup(this._context),this._setEffects(this.effects)}}setProps(e){"effects"in e&&(Xx(e.effects,this.effects,1)||this._setEffects(e.effects))}needsRedraw(e={clearRedrawFlags:!1}){const t=this._needsRedraw;return e.clearRedrawFlags&&(this._needsRedraw=!1),t}getEffects(){return this._resolvedEffects}_setEffects(e){const t={};for(const e of this.effects)t[e.id]=e;const i=[];for(const n of e){const e=t[n.id];let r=n;e&&e!==n?e.setProps?(e.setProps(n.props),r=e):e.cleanup(this._context):e||n.setup(this._context),i.push(r),delete t[n.id]}for(const e in t)t[e].cleanup(this._context);this.effects=i,this._resolvedEffects=i.concat(this._defaultEffects),e.some(e=>e instanceof Dv)||this._resolvedEffects.push(Mb),this._needsRedraw="effects changed"}finalize(){for(const e of this._resolvedEffects)e.cleanup(this._context);this.effects.length=0,this._resolvedEffects.length=0,this._defaultEffects.length=0}}class Rb extends Mv{shouldDrawLayer(e){const{operation:t}=e.props;return t.includes("draw")||t.includes("terrain")}}class Lb{constructor(e){this.device=e,this.layerFilter=null,this.drawPickingColors=!1,this.drawLayersPass=new Rb(e),this.pickLayersPass=new Px(e),this.renderCount=0,this._needsRedraw="Initial render",this.renderBuffers=[],this.lastPostProcessEffect=null}setProps(e){this.layerFilter!==e.layerFilter&&(this.layerFilter=e.layerFilter,this._needsRedraw="layerFilter changed"),this.drawPickingColors!==e.drawPickingColors&&(this.drawPickingColors=e.drawPickingColors,this._needsRedraw="drawPickingColors changed")}renderLayers(e){if(!e.viewports.length)return;const t=this.drawPickingColors?this.pickLayersPass:this.drawLayersPass,i={layerFilter:this.layerFilter,isPicking:this.drawPickingColors,...e};i.effects&&this._preRender(i.effects,i);const n=this.lastPostProcessEffect?this.renderBuffers[0]:i.target;this.lastPostProcessEffect&&(i.clearColor=[0,0,0,0],i.clearCanvas=!0);const r=t.render({...i,target:n});i.effects&&this._postRender(i.effects,i),this.renderCount++,lp("deckRenderer.renderLayers",this,r,e)}needsRedraw(e={clearRedrawFlags:!1}){const t=this._needsRedraw;return e.clearRedrawFlags&&(this._needsRedraw=!1),t}finalize(){const{renderBuffers:e}=this;for(const t of e)t.delete();e.length=0}_preRender(e,t){this.lastPostProcessEffect=null,t.preRenderStats=t.preRenderStats||{};for(const i of e)t.preRenderStats[i.id]=i.preRender(t),i.postRender&&(this.lastPostProcessEffect=i.id);this.lastPostProcessEffect&&this._resizeRenderBuffers()}_resizeRenderBuffers(){const{renderBuffers:e}=this,t=this.device.canvasContext.getDrawingBufferSize();0===e.length&&[0,1].map(t=>{const i=this.device.createTexture({sampler:{minFilter:"linear",magFilter:"linear"}});e.push(this.device.createFramebuffer({id:`deck-renderbuffer-${t}`,colorAttachments:[i]}))});for(const i of e)i.resize(t)}_postRender(e,t){const{renderBuffers:i}=this,n={...t,inputBuffer:i[0],swapBuffer:i[1]};for(const r of e)if(r.postRender){n.target=r.id===this.lastPostProcessEffect?t.target:void 0;const e=r.postRender(n);n.inputBuffer=e,n.swapBuffer=e===i[0]?i[1]:i[0]}}}const Fb={pickedColor:null,pickedObjectIndex:-1};function kb({pickedColors:e,decodePickingColor:t,deviceX:i,deviceY:n,deviceRadius:r,deviceRect:o}){const{x:s,y:a,width:l,height:c}=o;let u=r*r,h=-1,d=0;for(let t=0;tu)d+=4*l;else for(let t=0;t=0){const e=t+s-i,n=e*e+o;n<=u&&(u=n,h=d)}d+=4}}if(h>=0){const i=e.slice(h,h+4),n=t(i);if(n){const e=Math.floor(h/4/l),t=h/4-e*l;return{...n,pickedColor:i,pickedX:s+t,pickedY:a+e}}rp.error("Picked non-existent layer. Is picking buffer corrupt?")()}return Fb}function Db({pickInfo:e,viewports:t,pixelRatio:i,x:n,y:r,z:o}){let s,a=t[0];if(t.length>1&&(a=function(e,t){for(let i=e.length-1;i>=0;i--){const n=e[i];if(n.containsPixel(t))return n}return e[0]}(e?.pickedViewports||t,{x:n,y:r})),a){const e=[n-a.x,r-a.y];void 0!==o&&(e[2]=o),s=a.unproject(e)}return{color:null,layer:null,viewport:a,index:-1,picked:!1,x:n,y:r,pixel:[n,r],coordinate:s,devicePixel:e&&"pickedX"in e?[e.pickedX,e.pickedY]:void 0,pixelRatio:i}}function Ob(e){const{pickInfo:t,lastPickedInfo:i,mode:n,layers:r}=e,{pickedColor:o,pickedLayer:s,pickedObjectIndex:a}=t,l=s?[s]:[];if("hover"===n){const e=i.index,t=i.layerId,n=s?s.props.id:null;if(n!==t||a!==e){if(n!==t){const e=r.find(e=>e.props.id===t);e&&l.unshift(e)}i.layerId=n,i.index=a,i.info=null}}const c=Db(e),u=new Map;return u.set(null,c),l.forEach(e=>{let t={...c};e===s&&(t.color=o,t.index=a,t.picked=!0),t=zb({layer:e,info:t,mode:n});const r=t.layer;e===s&&"hover"===n&&(i.info=t),u.set(r.id,t),"hover"===n&&r.updateAutoHighlight(t)}),u}function zb({layer:e,info:t,mode:i}){for(;e&&t;){const n=t.layer||null;t.sourceLayer=n,t.layer=e,t=e.getPickingInfo({info:t,mode:i,sourceLayer:n}),e=e.parent}return t}class Ub{constructor(e){this._pickable=!0,this.device=e,this.pickLayersPass=new Px(e),this.lastPickedInfo={index:-1,layerId:null,info:null}}setProps(e){"layerFilter"in e&&(this.layerFilter=e.layerFilter),"_pickable"in e&&(this._pickable=e._pickable)}finalize(){this.pickingFBO&&this.pickingFBO.destroy(),this.depthFBO&&this.depthFBO.destroy()}pickObject(e){return this._pickClosestObject(e)}pickObjects(e){return this._pickVisibleObjects(e)}getLastPickedObject({x:e,y:t,layers:i,viewports:n},r=this.lastPickedInfo.info){const o=r&&r.layer&&r.layer.id,s=r&&r.viewport&&r.viewport.id,a=o?i.find(e=>e.id===o):null,l=s&&n.find(e=>e.id===s)||n[0],c=l&&l.unproject([e-l.x,t-l.y]),u={x:e,y:t,viewport:l,coordinate:c,layer:a};return{...r,...u}}_resizeBuffer(){if(!this.pickingFBO&&(this.pickingFBO=this.device.createFramebuffer({colorAttachments:["rgba8unorm"],depthStencilAttachment:"depth16unorm"}),this.device.isTextureFormatRenderable("rgba32float"))){const e=this.device.createFramebuffer({colorAttachments:["rgba32float"],depthStencilAttachment:"depth16unorm"});this.depthFBO=e}const{canvas:e}=this.device.getCanvasContext();this.pickingFBO?.resize({width:e.width,height:e.height}),this.depthFBO?.resize({width:e.width,height:e.height})}_getPickable(e){if(!1===this._pickable)return null;const t=e.filter(e=>this.pickLayersPass.shouldDrawLayer(e)&&!e.isComposite);return t.length?t:null}_pickClosestObject({layers:e,views:t,viewports:i,x:n,y:r,radius:o=0,depth:s=1,mode:a="query",unproject3D:l,onViewportActive:c,effects:u}){const h=this.device.canvasContext.cssToDeviceRatio(),d=this._getPickable(e);if(!d||0===i.length)return{result:[],emptyInfo:Db({viewports:i,x:n,y:r,pixelRatio:h})};this._resizeBuffer();const p=this.device.canvasContext.cssToDevicePixels([n,r],!0),f=[p.x+Math.floor(p.width/2),p.y+Math.floor(p.height/2)],m=Math.round(o*h),{width:g,height:_}=this.pickingFBO,A=this._getPickingRect({deviceX:f[0],deviceY:f[1],deviceRadius:m,deviceWidth:g,deviceHeight:_}),y={x:n-o,y:r-o,width:2*o+1,height:2*o+1};let v;const x=[],b=new Set;for(let e=0;e=0){const r=e.slice(n,n+4),o=r.join(",");if(!i.has(o)){const e=t(r);e?i.set(o,{...e,color:r}):rp.error("Picked non-existent layer. Is picking buffer corrupt?")()}}return Array.from(i.values())}(this._drawAndSample({layers:h,views:t,viewports:i,onViewportActive:c,deviceRect:y,cullRect:{x:n,y:r,width:o,height:s},effects:u,pass:`picking:${a}`})),x=new Map,b=[],w=Number.isFinite(l);for(let e=0;e=l);e++){const t=v[e];let i={color:t.pickedColor,layer:null,index:t.pickedObjectIndex,picked:!0,x:n,y:r,pixelRatio:d};i=zb({layer:t.pickedLayer,info:i,mode:a});const o=i.layer.id;x.has(o)||x.set(o,new Set);const s=x.get(o),l=i.object??i.index;s.has(l)||(s.add(l),b.push(i))}return b}_drawAndSample({layers:e,views:t,viewports:i,onViewportActive:n,deviceRect:r,cullRect:o,effects:s,pass:a},l=!1){const c=l?this.depthFBO:this.pickingFBO,u={layers:e,layerFilter:this.layerFilter,views:t,viewports:i,onViewportActive:n,pickingFBO:c,deviceRect:r,cullRect:o,effects:s,pass:a,pickZ:l,preRenderStats:{},isPicking:!0};for(const e of s)e.useInPicking&&(u.preRenderStats[e.id]=e.preRender(u));const{decodePickingColor:h}=this.pickLayersPass.render(u),{x:d,y:p,width:f,height:m}=r,g=new(l?Float32Array:Uint8Array)(f*m*4);return this.device.readPixelsToArrayWebGL(c,{sourceX:d,sourceY:p,sourceWidth:f,sourceHeight:m,target:g}),{pickedColors:g,decodePickingColor:h}}_getPickingRect({deviceX:e,deviceY:t,deviceRadius:i,deviceWidth:n,deviceHeight:r}){const o=Math.max(0,e-i),s=Math.max(0,t-i),a=Math.min(n,e+i+1)-o,l=Math.min(r,t+i+1)-s;return a<=0||l<=0?null:{x:o,y:s,width:a,height:l}}}const Nb={"top-left":{top:0,left:0},"top-right":{top:0,right:0},"bottom-left":{bottom:0,left:0},"bottom-right":{bottom:0,right:0},fill:{top:0,left:0,bottom:0,right:0}},Vb="top-left",jb="__root";class Gb{constructor({deck:e,parentElement:t}){this.defaultWidgets=[],this.widgets=[],this.resolvedWidgets=[],this.containers={},this.lastViewports={},this.deck=e,this.parentElement=t}getWidgets(){return this.resolvedWidgets}setProps(e){e.widgets&&!Xx(e.widgets,this.widgets,1)&&this._setWidgets(e.widgets)}finalize(){for(const e of this.getWidgets())this._remove(e);this.defaultWidgets.length=0,this.resolvedWidgets.length=0;for(const e in this.containers)this.containers[e].remove()}addDefault(e){this.defaultWidgets.find(t=>t.id===e.id)||(this._add(e),this.defaultWidgets.push(e),this._setWidgets(this.widgets))}_setWidgets(e){const t={};for(const e of this.resolvedWidgets)t[e.id]=e;this.resolvedWidgets.length=0;for(const e of this.defaultWidgets)t[e.id]=null,this.resolvedWidgets.push(e);for(let i of e){const e=t[i.id];e?e.viewId!==i.viewId||e.placement!==i.placement?(this._remove(e),this._add(i)):i!==e&&(e.setProps(i.props),i=e):this._add(i),t[i.id]=null,this.resolvedWidgets.push(i)}for(const e in t){const i=t[e];i&&this._remove(i)}this.widgets=e}_add(e){const{viewId:t=null,placement:i=Vb}=e,n=e.onAdd({deck:this.deck,viewId:t});n&&this._getContainer(t,i).append(n),e._element=n}_remove(e){e.onRemove(),e._element&&e._element.remove(),e._element=void 0}_getContainer(e,t){const i=e||jb;let n=this.containers[i];n||(n=document.createElement("div"),n.style.pointerEvents="none",n.style.position="absolute",n.style.overflow="hidden",this.parentElement?.append(n),this.containers[i]=n);let r=n.querySelector(`.${t}`);return r||(r=document.createElement("div"),r.className=t,r.style.position="absolute",r.style.zIndex="2",Object.assign(r.style,Nb[t]),n.append(r)),r}_updateContainers(){const e=this.deck.width,t=this.deck.height;for(const i in this.containers){const n=this.lastViewports[i]||null,r=i===jb||n,o=this.containers[i];r?(o.style.display="block",o.style.left=`${n?n.x:0}px`,o.style.top=`${n?n.y:0}px`,o.style.width=`${n?n.width:e}px`,o.style.height=`${n?n.height:t}px`):o.style.display="none"}}onRedraw({viewports:e,layers:t}){const i=e.reduce((e,t)=>(e[t.id]=t,e),{}),{lastViewports:n}=this;for(const r of this.getWidgets()){const{viewId:o}=r;if(o){const e=i[o];e&&(r.onViewportChange&&!e.equals(n[o])&&r.onViewportChange(e),r.onRedraw?.({viewports:[e],layers:t}))}else{if(r.onViewportChange)for(const t of e)t.equals(n[t.id])||r.onViewportChange(t);r.onRedraw?.({viewports:e,layers:t})}}this.lastViewports=i,this._updateContainers()}onHover(e,t){for(const i of this.getWidgets()){const{viewId:n}=i;n&&n!==e.viewport?.id||i.onHover?.(e,t)}}onEvent(e,t){const i=Ty[t.type];if(i)for(const n of this.getWidgets()){const{viewId:r}=n;r&&r!==e.viewport?.id||n[i.handler]?.(e,t)}}}const Hb={zIndex:"1",position:"absolute",pointerEvents:"none",color:"#a0a7b4",backgroundColor:"#29323c",padding:"10px",top:"0",left:"0",display:"none"};class Qb{constructor(){this.id="default-tooltip",this.placement="fill",this.props={},this.isVisible=!1}onAdd({deck:e}){const t=document.createElement("div");return t.className="deck-tooltip",Object.assign(t.style,Hb),this.deck=e,this.element=t,t}onRemove(){this.deck=void 0,this.element=void 0}setProps(){}onViewportChange(e){this.isVisible&&e.id===this.lastViewport?.id&&e!==this.lastViewport&&this.setTooltip(null)}onHover(e){const{deck:t}=this,i=t&&t.props.getTooltip;if(!i)return;const n=i(e);this.lastViewport=e.viewport,this.setTooltip(n,e.x,e.y)}setTooltip(e,t,i){const n=this.element;if(n){if("string"==typeof e)n.innerText=e;else{if(!e)return this.isVisible=!1,void(n.style.display="none");e.text&&(n.innerText=e.text),e.html&&(n.innerHTML=e.html),e.className&&(n.className=e.className)}this.isVisible=!0,n.style.display="block",n.style.transform=`translate(${t}px, ${i}px)`,e&&"object"==typeof e&&"style"in e&&Object.assign(n.style,e.style)}}}var $b;!function(e){e[e.DEPTH_BUFFER_BIT=256]="DEPTH_BUFFER_BIT",e[e.STENCIL_BUFFER_BIT=1024]="STENCIL_BUFFER_BIT",e[e.COLOR_BUFFER_BIT=16384]="COLOR_BUFFER_BIT",e[e.POINTS=0]="POINTS",e[e.LINES=1]="LINES",e[e.LINE_LOOP=2]="LINE_LOOP",e[e.LINE_STRIP=3]="LINE_STRIP",e[e.TRIANGLES=4]="TRIANGLES",e[e.TRIANGLE_STRIP=5]="TRIANGLE_STRIP",e[e.TRIANGLE_FAN=6]="TRIANGLE_FAN",e[e.ZERO=0]="ZERO",e[e.ONE=1]="ONE",e[e.SRC_COLOR=768]="SRC_COLOR",e[e.ONE_MINUS_SRC_COLOR=769]="ONE_MINUS_SRC_COLOR",e[e.SRC_ALPHA=770]="SRC_ALPHA",e[e.ONE_MINUS_SRC_ALPHA=771]="ONE_MINUS_SRC_ALPHA",e[e.DST_ALPHA=772]="DST_ALPHA",e[e.ONE_MINUS_DST_ALPHA=773]="ONE_MINUS_DST_ALPHA",e[e.DST_COLOR=774]="DST_COLOR",e[e.ONE_MINUS_DST_COLOR=775]="ONE_MINUS_DST_COLOR",e[e.SRC_ALPHA_SATURATE=776]="SRC_ALPHA_SATURATE",e[e.CONSTANT_COLOR=32769]="CONSTANT_COLOR",e[e.ONE_MINUS_CONSTANT_COLOR=32770]="ONE_MINUS_CONSTANT_COLOR",e[e.CONSTANT_ALPHA=32771]="CONSTANT_ALPHA",e[e.ONE_MINUS_CONSTANT_ALPHA=32772]="ONE_MINUS_CONSTANT_ALPHA",e[e.FUNC_ADD=32774]="FUNC_ADD",e[e.FUNC_SUBTRACT=32778]="FUNC_SUBTRACT",e[e.FUNC_REVERSE_SUBTRACT=32779]="FUNC_REVERSE_SUBTRACT",e[e.BLEND_EQUATION=32777]="BLEND_EQUATION",e[e.BLEND_EQUATION_RGB=32777]="BLEND_EQUATION_RGB",e[e.BLEND_EQUATION_ALPHA=34877]="BLEND_EQUATION_ALPHA",e[e.BLEND_DST_RGB=32968]="BLEND_DST_RGB",e[e.BLEND_SRC_RGB=32969]="BLEND_SRC_RGB",e[e.BLEND_DST_ALPHA=32970]="BLEND_DST_ALPHA",e[e.BLEND_SRC_ALPHA=32971]="BLEND_SRC_ALPHA",e[e.BLEND_COLOR=32773]="BLEND_COLOR",e[e.ARRAY_BUFFER_BINDING=34964]="ARRAY_BUFFER_BINDING",e[e.ELEMENT_ARRAY_BUFFER_BINDING=34965]="ELEMENT_ARRAY_BUFFER_BINDING",e[e.LINE_WIDTH=2849]="LINE_WIDTH",e[e.ALIASED_POINT_SIZE_RANGE=33901]="ALIASED_POINT_SIZE_RANGE",e[e.ALIASED_LINE_WIDTH_RANGE=33902]="ALIASED_LINE_WIDTH_RANGE",e[e.CULL_FACE_MODE=2885]="CULL_FACE_MODE",e[e.FRONT_FACE=2886]="FRONT_FACE",e[e.DEPTH_RANGE=2928]="DEPTH_RANGE",e[e.DEPTH_WRITEMASK=2930]="DEPTH_WRITEMASK",e[e.DEPTH_CLEAR_VALUE=2931]="DEPTH_CLEAR_VALUE",e[e.DEPTH_FUNC=2932]="DEPTH_FUNC",e[e.STENCIL_CLEAR_VALUE=2961]="STENCIL_CLEAR_VALUE",e[e.STENCIL_FUNC=2962]="STENCIL_FUNC",e[e.STENCIL_FAIL=2964]="STENCIL_FAIL",e[e.STENCIL_PASS_DEPTH_FAIL=2965]="STENCIL_PASS_DEPTH_FAIL",e[e.STENCIL_PASS_DEPTH_PASS=2966]="STENCIL_PASS_DEPTH_PASS",e[e.STENCIL_REF=2967]="STENCIL_REF",e[e.STENCIL_VALUE_MASK=2963]="STENCIL_VALUE_MASK",e[e.STENCIL_WRITEMASK=2968]="STENCIL_WRITEMASK",e[e.STENCIL_BACK_FUNC=34816]="STENCIL_BACK_FUNC",e[e.STENCIL_BACK_FAIL=34817]="STENCIL_BACK_FAIL",e[e.STENCIL_BACK_PASS_DEPTH_FAIL=34818]="STENCIL_BACK_PASS_DEPTH_FAIL",e[e.STENCIL_BACK_PASS_DEPTH_PASS=34819]="STENCIL_BACK_PASS_DEPTH_PASS",e[e.STENCIL_BACK_REF=36003]="STENCIL_BACK_REF",e[e.STENCIL_BACK_VALUE_MASK=36004]="STENCIL_BACK_VALUE_MASK",e[e.STENCIL_BACK_WRITEMASK=36005]="STENCIL_BACK_WRITEMASK",e[e.VIEWPORT=2978]="VIEWPORT",e[e.SCISSOR_BOX=3088]="SCISSOR_BOX",e[e.COLOR_CLEAR_VALUE=3106]="COLOR_CLEAR_VALUE",e[e.COLOR_WRITEMASK=3107]="COLOR_WRITEMASK",e[e.UNPACK_ALIGNMENT=3317]="UNPACK_ALIGNMENT",e[e.PACK_ALIGNMENT=3333]="PACK_ALIGNMENT",e[e.MAX_TEXTURE_SIZE=3379]="MAX_TEXTURE_SIZE",e[e.MAX_VIEWPORT_DIMS=3386]="MAX_VIEWPORT_DIMS",e[e.SUBPIXEL_BITS=3408]="SUBPIXEL_BITS",e[e.RED_BITS=3410]="RED_BITS",e[e.GREEN_BITS=3411]="GREEN_BITS",e[e.BLUE_BITS=3412]="BLUE_BITS",e[e.ALPHA_BITS=3413]="ALPHA_BITS",e[e.DEPTH_BITS=3414]="DEPTH_BITS",e[e.STENCIL_BITS=3415]="STENCIL_BITS",e[e.POLYGON_OFFSET_UNITS=10752]="POLYGON_OFFSET_UNITS",e[e.POLYGON_OFFSET_FACTOR=32824]="POLYGON_OFFSET_FACTOR",e[e.TEXTURE_BINDING_2D=32873]="TEXTURE_BINDING_2D",e[e.SAMPLE_BUFFERS=32936]="SAMPLE_BUFFERS",e[e.SAMPLES=32937]="SAMPLES",e[e.SAMPLE_COVERAGE_VALUE=32938]="SAMPLE_COVERAGE_VALUE",e[e.SAMPLE_COVERAGE_INVERT=32939]="SAMPLE_COVERAGE_INVERT",e[e.COMPRESSED_TEXTURE_FORMATS=34467]="COMPRESSED_TEXTURE_FORMATS",e[e.VENDOR=7936]="VENDOR",e[e.RENDERER=7937]="RENDERER",e[e.VERSION=7938]="VERSION",e[e.IMPLEMENTATION_COLOR_READ_TYPE=35738]="IMPLEMENTATION_COLOR_READ_TYPE",e[e.IMPLEMENTATION_COLOR_READ_FORMAT=35739]="IMPLEMENTATION_COLOR_READ_FORMAT",e[e.BROWSER_DEFAULT_WEBGL=37444]="BROWSER_DEFAULT_WEBGL",e[e.STATIC_DRAW=35044]="STATIC_DRAW",e[e.STREAM_DRAW=35040]="STREAM_DRAW",e[e.DYNAMIC_DRAW=35048]="DYNAMIC_DRAW",e[e.ARRAY_BUFFER=34962]="ARRAY_BUFFER",e[e.ELEMENT_ARRAY_BUFFER=34963]="ELEMENT_ARRAY_BUFFER",e[e.BUFFER_SIZE=34660]="BUFFER_SIZE",e[e.BUFFER_USAGE=34661]="BUFFER_USAGE",e[e.CURRENT_VERTEX_ATTRIB=34342]="CURRENT_VERTEX_ATTRIB",e[e.VERTEX_ATTRIB_ARRAY_ENABLED=34338]="VERTEX_ATTRIB_ARRAY_ENABLED",e[e.VERTEX_ATTRIB_ARRAY_SIZE=34339]="VERTEX_ATTRIB_ARRAY_SIZE",e[e.VERTEX_ATTRIB_ARRAY_STRIDE=34340]="VERTEX_ATTRIB_ARRAY_STRIDE",e[e.VERTEX_ATTRIB_ARRAY_TYPE=34341]="VERTEX_ATTRIB_ARRAY_TYPE",e[e.VERTEX_ATTRIB_ARRAY_NORMALIZED=34922]="VERTEX_ATTRIB_ARRAY_NORMALIZED",e[e.VERTEX_ATTRIB_ARRAY_POINTER=34373]="VERTEX_ATTRIB_ARRAY_POINTER",e[e.VERTEX_ATTRIB_ARRAY_BUFFER_BINDING=34975]="VERTEX_ATTRIB_ARRAY_BUFFER_BINDING",e[e.CULL_FACE=2884]="CULL_FACE",e[e.FRONT=1028]="FRONT",e[e.BACK=1029]="BACK",e[e.FRONT_AND_BACK=1032]="FRONT_AND_BACK",e[e.BLEND=3042]="BLEND",e[e.DEPTH_TEST=2929]="DEPTH_TEST",e[e.DITHER=3024]="DITHER",e[e.POLYGON_OFFSET_FILL=32823]="POLYGON_OFFSET_FILL",e[e.SAMPLE_ALPHA_TO_COVERAGE=32926]="SAMPLE_ALPHA_TO_COVERAGE",e[e.SAMPLE_COVERAGE=32928]="SAMPLE_COVERAGE",e[e.SCISSOR_TEST=3089]="SCISSOR_TEST",e[e.STENCIL_TEST=2960]="STENCIL_TEST",e[e.NO_ERROR=0]="NO_ERROR",e[e.INVALID_ENUM=1280]="INVALID_ENUM",e[e.INVALID_VALUE=1281]="INVALID_VALUE",e[e.INVALID_OPERATION=1282]="INVALID_OPERATION",e[e.OUT_OF_MEMORY=1285]="OUT_OF_MEMORY",e[e.CONTEXT_LOST_WEBGL=37442]="CONTEXT_LOST_WEBGL",e[e.CW=2304]="CW",e[e.CCW=2305]="CCW",e[e.DONT_CARE=4352]="DONT_CARE",e[e.FASTEST=4353]="FASTEST",e[e.NICEST=4354]="NICEST",e[e.GENERATE_MIPMAP_HINT=33170]="GENERATE_MIPMAP_HINT",e[e.BYTE=5120]="BYTE",e[e.UNSIGNED_BYTE=5121]="UNSIGNED_BYTE",e[e.SHORT=5122]="SHORT",e[e.UNSIGNED_SHORT=5123]="UNSIGNED_SHORT",e[e.INT=5124]="INT",e[e.UNSIGNED_INT=5125]="UNSIGNED_INT",e[e.FLOAT=5126]="FLOAT",e[e.DOUBLE=5130]="DOUBLE",e[e.DEPTH_COMPONENT=6402]="DEPTH_COMPONENT",e[e.ALPHA=6406]="ALPHA",e[e.RGB=6407]="RGB",e[e.RGBA=6408]="RGBA",e[e.LUMINANCE=6409]="LUMINANCE",e[e.LUMINANCE_ALPHA=6410]="LUMINANCE_ALPHA",e[e.UNSIGNED_SHORT_4_4_4_4=32819]="UNSIGNED_SHORT_4_4_4_4",e[e.UNSIGNED_SHORT_5_5_5_1=32820]="UNSIGNED_SHORT_5_5_5_1",e[e.UNSIGNED_SHORT_5_6_5=33635]="UNSIGNED_SHORT_5_6_5",e[e.FRAGMENT_SHADER=35632]="FRAGMENT_SHADER",e[e.VERTEX_SHADER=35633]="VERTEX_SHADER",e[e.COMPILE_STATUS=35713]="COMPILE_STATUS",e[e.DELETE_STATUS=35712]="DELETE_STATUS",e[e.LINK_STATUS=35714]="LINK_STATUS",e[e.VALIDATE_STATUS=35715]="VALIDATE_STATUS",e[e.ATTACHED_SHADERS=35717]="ATTACHED_SHADERS",e[e.ACTIVE_ATTRIBUTES=35721]="ACTIVE_ATTRIBUTES",e[e.ACTIVE_UNIFORMS=35718]="ACTIVE_UNIFORMS",e[e.MAX_VERTEX_ATTRIBS=34921]="MAX_VERTEX_ATTRIBS",e[e.MAX_VERTEX_UNIFORM_VECTORS=36347]="MAX_VERTEX_UNIFORM_VECTORS",e[e.MAX_VARYING_VECTORS=36348]="MAX_VARYING_VECTORS",e[e.MAX_COMBINED_TEXTURE_IMAGE_UNITS=35661]="MAX_COMBINED_TEXTURE_IMAGE_UNITS",e[e.MAX_VERTEX_TEXTURE_IMAGE_UNITS=35660]="MAX_VERTEX_TEXTURE_IMAGE_UNITS",e[e.MAX_TEXTURE_IMAGE_UNITS=34930]="MAX_TEXTURE_IMAGE_UNITS",e[e.MAX_FRAGMENT_UNIFORM_VECTORS=36349]="MAX_FRAGMENT_UNIFORM_VECTORS",e[e.SHADER_TYPE=35663]="SHADER_TYPE",e[e.SHADING_LANGUAGE_VERSION=35724]="SHADING_LANGUAGE_VERSION",e[e.CURRENT_PROGRAM=35725]="CURRENT_PROGRAM",e[e.NEVER=512]="NEVER",e[e.LESS=513]="LESS",e[e.EQUAL=514]="EQUAL",e[e.LEQUAL=515]="LEQUAL",e[e.GREATER=516]="GREATER",e[e.NOTEQUAL=517]="NOTEQUAL",e[e.GEQUAL=518]="GEQUAL",e[e.ALWAYS=519]="ALWAYS",e[e.KEEP=7680]="KEEP",e[e.REPLACE=7681]="REPLACE",e[e.INCR=7682]="INCR",e[e.DECR=7683]="DECR",e[e.INVERT=5386]="INVERT",e[e.INCR_WRAP=34055]="INCR_WRAP",e[e.DECR_WRAP=34056]="DECR_WRAP",e[e.NEAREST=9728]="NEAREST",e[e.LINEAR=9729]="LINEAR",e[e.NEAREST_MIPMAP_NEAREST=9984]="NEAREST_MIPMAP_NEAREST",e[e.LINEAR_MIPMAP_NEAREST=9985]="LINEAR_MIPMAP_NEAREST",e[e.NEAREST_MIPMAP_LINEAR=9986]="NEAREST_MIPMAP_LINEAR",e[e.LINEAR_MIPMAP_LINEAR=9987]="LINEAR_MIPMAP_LINEAR",e[e.TEXTURE_MAG_FILTER=10240]="TEXTURE_MAG_FILTER",e[e.TEXTURE_MIN_FILTER=10241]="TEXTURE_MIN_FILTER",e[e.TEXTURE_WRAP_S=10242]="TEXTURE_WRAP_S",e[e.TEXTURE_WRAP_T=10243]="TEXTURE_WRAP_T",e[e.TEXTURE_2D=3553]="TEXTURE_2D",e[e.TEXTURE=5890]="TEXTURE",e[e.TEXTURE_CUBE_MAP=34067]="TEXTURE_CUBE_MAP",e[e.TEXTURE_BINDING_CUBE_MAP=34068]="TEXTURE_BINDING_CUBE_MAP",e[e.TEXTURE_CUBE_MAP_POSITIVE_X=34069]="TEXTURE_CUBE_MAP_POSITIVE_X",e[e.TEXTURE_CUBE_MAP_NEGATIVE_X=34070]="TEXTURE_CUBE_MAP_NEGATIVE_X",e[e.TEXTURE_CUBE_MAP_POSITIVE_Y=34071]="TEXTURE_CUBE_MAP_POSITIVE_Y",e[e.TEXTURE_CUBE_MAP_NEGATIVE_Y=34072]="TEXTURE_CUBE_MAP_NEGATIVE_Y",e[e.TEXTURE_CUBE_MAP_POSITIVE_Z=34073]="TEXTURE_CUBE_MAP_POSITIVE_Z",e[e.TEXTURE_CUBE_MAP_NEGATIVE_Z=34074]="TEXTURE_CUBE_MAP_NEGATIVE_Z",e[e.MAX_CUBE_MAP_TEXTURE_SIZE=34076]="MAX_CUBE_MAP_TEXTURE_SIZE",e[e.TEXTURE0=33984]="TEXTURE0",e[e.ACTIVE_TEXTURE=34016]="ACTIVE_TEXTURE",e[e.REPEAT=10497]="REPEAT",e[e.CLAMP_TO_EDGE=33071]="CLAMP_TO_EDGE",e[e.MIRRORED_REPEAT=33648]="MIRRORED_REPEAT",e[e.TEXTURE_WIDTH=4096]="TEXTURE_WIDTH",e[e.TEXTURE_HEIGHT=4097]="TEXTURE_HEIGHT",e[e.FLOAT_VEC2=35664]="FLOAT_VEC2",e[e.FLOAT_VEC3=35665]="FLOAT_VEC3",e[e.FLOAT_VEC4=35666]="FLOAT_VEC4",e[e.INT_VEC2=35667]="INT_VEC2",e[e.INT_VEC3=35668]="INT_VEC3",e[e.INT_VEC4=35669]="INT_VEC4",e[e.BOOL=35670]="BOOL",e[e.BOOL_VEC2=35671]="BOOL_VEC2",e[e.BOOL_VEC3=35672]="BOOL_VEC3",e[e.BOOL_VEC4=35673]="BOOL_VEC4",e[e.FLOAT_MAT2=35674]="FLOAT_MAT2",e[e.FLOAT_MAT3=35675]="FLOAT_MAT3",e[e.FLOAT_MAT4=35676]="FLOAT_MAT4",e[e.SAMPLER_2D=35678]="SAMPLER_2D",e[e.SAMPLER_CUBE=35680]="SAMPLER_CUBE",e[e.LOW_FLOAT=36336]="LOW_FLOAT",e[e.MEDIUM_FLOAT=36337]="MEDIUM_FLOAT",e[e.HIGH_FLOAT=36338]="HIGH_FLOAT",e[e.LOW_INT=36339]="LOW_INT",e[e.MEDIUM_INT=36340]="MEDIUM_INT",e[e.HIGH_INT=36341]="HIGH_INT",e[e.FRAMEBUFFER=36160]="FRAMEBUFFER",e[e.RENDERBUFFER=36161]="RENDERBUFFER",e[e.RGBA4=32854]="RGBA4",e[e.RGB5_A1=32855]="RGB5_A1",e[e.RGB565=36194]="RGB565",e[e.DEPTH_COMPONENT16=33189]="DEPTH_COMPONENT16",e[e.STENCIL_INDEX=6401]="STENCIL_INDEX",e[e.STENCIL_INDEX8=36168]="STENCIL_INDEX8",e[e.DEPTH_STENCIL=34041]="DEPTH_STENCIL",e[e.RENDERBUFFER_WIDTH=36162]="RENDERBUFFER_WIDTH",e[e.RENDERBUFFER_HEIGHT=36163]="RENDERBUFFER_HEIGHT",e[e.RENDERBUFFER_INTERNAL_FORMAT=36164]="RENDERBUFFER_INTERNAL_FORMAT",e[e.RENDERBUFFER_RED_SIZE=36176]="RENDERBUFFER_RED_SIZE",e[e.RENDERBUFFER_GREEN_SIZE=36177]="RENDERBUFFER_GREEN_SIZE",e[e.RENDERBUFFER_BLUE_SIZE=36178]="RENDERBUFFER_BLUE_SIZE",e[e.RENDERBUFFER_ALPHA_SIZE=36179]="RENDERBUFFER_ALPHA_SIZE",e[e.RENDERBUFFER_DEPTH_SIZE=36180]="RENDERBUFFER_DEPTH_SIZE",e[e.RENDERBUFFER_STENCIL_SIZE=36181]="RENDERBUFFER_STENCIL_SIZE",e[e.FRAMEBUFFER_ATTACHMENT_OBJECT_TYPE=36048]="FRAMEBUFFER_ATTACHMENT_OBJECT_TYPE",e[e.FRAMEBUFFER_ATTACHMENT_OBJECT_NAME=36049]="FRAMEBUFFER_ATTACHMENT_OBJECT_NAME",e[e.FRAMEBUFFER_ATTACHMENT_TEXTURE_LEVEL=36050]="FRAMEBUFFER_ATTACHMENT_TEXTURE_LEVEL",e[e.FRAMEBUFFER_ATTACHMENT_TEXTURE_CUBE_MAP_FACE=36051]="FRAMEBUFFER_ATTACHMENT_TEXTURE_CUBE_MAP_FACE",e[e.COLOR_ATTACHMENT0=36064]="COLOR_ATTACHMENT0",e[e.DEPTH_ATTACHMENT=36096]="DEPTH_ATTACHMENT",e[e.STENCIL_ATTACHMENT=36128]="STENCIL_ATTACHMENT",e[e.DEPTH_STENCIL_ATTACHMENT=33306]="DEPTH_STENCIL_ATTACHMENT",e[e.NONE=0]="NONE",e[e.FRAMEBUFFER_COMPLETE=36053]="FRAMEBUFFER_COMPLETE",e[e.FRAMEBUFFER_INCOMPLETE_ATTACHMENT=36054]="FRAMEBUFFER_INCOMPLETE_ATTACHMENT",e[e.FRAMEBUFFER_INCOMPLETE_MISSING_ATTACHMENT=36055]="FRAMEBUFFER_INCOMPLETE_MISSING_ATTACHMENT",e[e.FRAMEBUFFER_INCOMPLETE_DIMENSIONS=36057]="FRAMEBUFFER_INCOMPLETE_DIMENSIONS",e[e.FRAMEBUFFER_UNSUPPORTED=36061]="FRAMEBUFFER_UNSUPPORTED",e[e.FRAMEBUFFER_BINDING=36006]="FRAMEBUFFER_BINDING",e[e.RENDERBUFFER_BINDING=36007]="RENDERBUFFER_BINDING",e[e.READ_FRAMEBUFFER=36008]="READ_FRAMEBUFFER",e[e.DRAW_FRAMEBUFFER=36009]="DRAW_FRAMEBUFFER",e[e.MAX_RENDERBUFFER_SIZE=34024]="MAX_RENDERBUFFER_SIZE",e[e.INVALID_FRAMEBUFFER_OPERATION=1286]="INVALID_FRAMEBUFFER_OPERATION",e[e.UNPACK_FLIP_Y_WEBGL=37440]="UNPACK_FLIP_Y_WEBGL",e[e.UNPACK_PREMULTIPLY_ALPHA_WEBGL=37441]="UNPACK_PREMULTIPLY_ALPHA_WEBGL",e[e.UNPACK_COLORSPACE_CONVERSION_WEBGL=37443]="UNPACK_COLORSPACE_CONVERSION_WEBGL",e[e.READ_BUFFER=3074]="READ_BUFFER",e[e.UNPACK_ROW_LENGTH=3314]="UNPACK_ROW_LENGTH",e[e.UNPACK_SKIP_ROWS=3315]="UNPACK_SKIP_ROWS",e[e.UNPACK_SKIP_PIXELS=3316]="UNPACK_SKIP_PIXELS",e[e.PACK_ROW_LENGTH=3330]="PACK_ROW_LENGTH",e[e.PACK_SKIP_ROWS=3331]="PACK_SKIP_ROWS",e[e.PACK_SKIP_PIXELS=3332]="PACK_SKIP_PIXELS",e[e.TEXTURE_BINDING_3D=32874]="TEXTURE_BINDING_3D",e[e.UNPACK_SKIP_IMAGES=32877]="UNPACK_SKIP_IMAGES",e[e.UNPACK_IMAGE_HEIGHT=32878]="UNPACK_IMAGE_HEIGHT",e[e.MAX_3D_TEXTURE_SIZE=32883]="MAX_3D_TEXTURE_SIZE",e[e.MAX_ELEMENTS_VERTICES=33e3]="MAX_ELEMENTS_VERTICES",e[e.MAX_ELEMENTS_INDICES=33001]="MAX_ELEMENTS_INDICES",e[e.MAX_TEXTURE_LOD_BIAS=34045]="MAX_TEXTURE_LOD_BIAS",e[e.MAX_FRAGMENT_UNIFORM_COMPONENTS=35657]="MAX_FRAGMENT_UNIFORM_COMPONENTS",e[e.MAX_VERTEX_UNIFORM_COMPONENTS=35658]="MAX_VERTEX_UNIFORM_COMPONENTS",e[e.MAX_ARRAY_TEXTURE_LAYERS=35071]="MAX_ARRAY_TEXTURE_LAYERS",e[e.MIN_PROGRAM_TEXEL_OFFSET=35076]="MIN_PROGRAM_TEXEL_OFFSET",e[e.MAX_PROGRAM_TEXEL_OFFSET=35077]="MAX_PROGRAM_TEXEL_OFFSET",e[e.MAX_VARYING_COMPONENTS=35659]="MAX_VARYING_COMPONENTS",e[e.FRAGMENT_SHADER_DERIVATIVE_HINT=35723]="FRAGMENT_SHADER_DERIVATIVE_HINT",e[e.RASTERIZER_DISCARD=35977]="RASTERIZER_DISCARD",e[e.VERTEX_ARRAY_BINDING=34229]="VERTEX_ARRAY_BINDING",e[e.MAX_VERTEX_OUTPUT_COMPONENTS=37154]="MAX_VERTEX_OUTPUT_COMPONENTS",e[e.MAX_FRAGMENT_INPUT_COMPONENTS=37157]="MAX_FRAGMENT_INPUT_COMPONENTS",e[e.MAX_SERVER_WAIT_TIMEOUT=37137]="MAX_SERVER_WAIT_TIMEOUT",e[e.MAX_ELEMENT_INDEX=36203]="MAX_ELEMENT_INDEX",e[e.RED=6403]="RED",e[e.RGB8=32849]="RGB8",e[e.RGBA8=32856]="RGBA8",e[e.RGB10_A2=32857]="RGB10_A2",e[e.TEXTURE_3D=32879]="TEXTURE_3D",e[e.TEXTURE_WRAP_R=32882]="TEXTURE_WRAP_R",e[e.TEXTURE_MIN_LOD=33082]="TEXTURE_MIN_LOD",e[e.TEXTURE_MAX_LOD=33083]="TEXTURE_MAX_LOD",e[e.TEXTURE_BASE_LEVEL=33084]="TEXTURE_BASE_LEVEL",e[e.TEXTURE_MAX_LEVEL=33085]="TEXTURE_MAX_LEVEL",e[e.TEXTURE_COMPARE_MODE=34892]="TEXTURE_COMPARE_MODE",e[e.TEXTURE_COMPARE_FUNC=34893]="TEXTURE_COMPARE_FUNC",e[e.SRGB=35904]="SRGB",e[e.SRGB8=35905]="SRGB8",e[e.SRGB8_ALPHA8=35907]="SRGB8_ALPHA8",e[e.COMPARE_REF_TO_TEXTURE=34894]="COMPARE_REF_TO_TEXTURE",e[e.RGBA32F=34836]="RGBA32F",e[e.RGB32F=34837]="RGB32F",e[e.RGBA16F=34842]="RGBA16F",e[e.RGB16F=34843]="RGB16F",e[e.TEXTURE_2D_ARRAY=35866]="TEXTURE_2D_ARRAY",e[e.TEXTURE_BINDING_2D_ARRAY=35869]="TEXTURE_BINDING_2D_ARRAY",e[e.R11F_G11F_B10F=35898]="R11F_G11F_B10F",e[e.RGB9_E5=35901]="RGB9_E5",e[e.RGBA32UI=36208]="RGBA32UI",e[e.RGB32UI=36209]="RGB32UI",e[e.RGBA16UI=36214]="RGBA16UI",e[e.RGB16UI=36215]="RGB16UI",e[e.RGBA8UI=36220]="RGBA8UI",e[e.RGB8UI=36221]="RGB8UI",e[e.RGBA32I=36226]="RGBA32I",e[e.RGB32I=36227]="RGB32I",e[e.RGBA16I=36232]="RGBA16I",e[e.RGB16I=36233]="RGB16I",e[e.RGBA8I=36238]="RGBA8I",e[e.RGB8I=36239]="RGB8I",e[e.RED_INTEGER=36244]="RED_INTEGER",e[e.RGB_INTEGER=36248]="RGB_INTEGER",e[e.RGBA_INTEGER=36249]="RGBA_INTEGER",e[e.R8=33321]="R8",e[e.RG8=33323]="RG8",e[e.R16F=33325]="R16F",e[e.R32F=33326]="R32F",e[e.RG16F=33327]="RG16F",e[e.RG32F=33328]="RG32F",e[e.R8I=33329]="R8I",e[e.R8UI=33330]="R8UI",e[e.R16I=33331]="R16I",e[e.R16UI=33332]="R16UI",e[e.R32I=33333]="R32I",e[e.R32UI=33334]="R32UI",e[e.RG8I=33335]="RG8I",e[e.RG8UI=33336]="RG8UI",e[e.RG16I=33337]="RG16I",e[e.RG16UI=33338]="RG16UI",e[e.RG32I=33339]="RG32I",e[e.RG32UI=33340]="RG32UI",e[e.R8_SNORM=36756]="R8_SNORM",e[e.RG8_SNORM=36757]="RG8_SNORM",e[e.RGB8_SNORM=36758]="RGB8_SNORM",e[e.RGBA8_SNORM=36759]="RGBA8_SNORM",e[e.RGB10_A2UI=36975]="RGB10_A2UI",e[e.TEXTURE_IMMUTABLE_FORMAT=37167]="TEXTURE_IMMUTABLE_FORMAT",e[e.TEXTURE_IMMUTABLE_LEVELS=33503]="TEXTURE_IMMUTABLE_LEVELS",e[e.UNSIGNED_INT_2_10_10_10_REV=33640]="UNSIGNED_INT_2_10_10_10_REV",e[e.UNSIGNED_INT_10F_11F_11F_REV=35899]="UNSIGNED_INT_10F_11F_11F_REV",e[e.UNSIGNED_INT_5_9_9_9_REV=35902]="UNSIGNED_INT_5_9_9_9_REV",e[e.FLOAT_32_UNSIGNED_INT_24_8_REV=36269]="FLOAT_32_UNSIGNED_INT_24_8_REV",e[e.UNSIGNED_INT_24_8=34042]="UNSIGNED_INT_24_8",e[e.HALF_FLOAT=5131]="HALF_FLOAT",e[e.RG=33319]="RG",e[e.RG_INTEGER=33320]="RG_INTEGER",e[e.INT_2_10_10_10_REV=36255]="INT_2_10_10_10_REV",e[e.CURRENT_QUERY=34917]="CURRENT_QUERY",e[e.QUERY_RESULT=34918]="QUERY_RESULT",e[e.QUERY_RESULT_AVAILABLE=34919]="QUERY_RESULT_AVAILABLE",e[e.ANY_SAMPLES_PASSED=35887]="ANY_SAMPLES_PASSED",e[e.ANY_SAMPLES_PASSED_CONSERVATIVE=36202]="ANY_SAMPLES_PASSED_CONSERVATIVE",e[e.MAX_DRAW_BUFFERS=34852]="MAX_DRAW_BUFFERS",e[e.DRAW_BUFFER0=34853]="DRAW_BUFFER0",e[e.DRAW_BUFFER1=34854]="DRAW_BUFFER1",e[e.DRAW_BUFFER2=34855]="DRAW_BUFFER2",e[e.DRAW_BUFFER3=34856]="DRAW_BUFFER3",e[e.DRAW_BUFFER4=34857]="DRAW_BUFFER4",e[e.DRAW_BUFFER5=34858]="DRAW_BUFFER5",e[e.DRAW_BUFFER6=34859]="DRAW_BUFFER6",e[e.DRAW_BUFFER7=34860]="DRAW_BUFFER7",e[e.DRAW_BUFFER8=34861]="DRAW_BUFFER8",e[e.DRAW_BUFFER9=34862]="DRAW_BUFFER9",e[e.DRAW_BUFFER10=34863]="DRAW_BUFFER10",e[e.DRAW_BUFFER11=34864]="DRAW_BUFFER11",e[e.DRAW_BUFFER12=34865]="DRAW_BUFFER12",e[e.DRAW_BUFFER13=34866]="DRAW_BUFFER13",e[e.DRAW_BUFFER14=34867]="DRAW_BUFFER14",e[e.DRAW_BUFFER15=34868]="DRAW_BUFFER15",e[e.MAX_COLOR_ATTACHMENTS=36063]="MAX_COLOR_ATTACHMENTS",e[e.COLOR_ATTACHMENT1=36065]="COLOR_ATTACHMENT1",e[e.COLOR_ATTACHMENT2=36066]="COLOR_ATTACHMENT2",e[e.COLOR_ATTACHMENT3=36067]="COLOR_ATTACHMENT3",e[e.COLOR_ATTACHMENT4=36068]="COLOR_ATTACHMENT4",e[e.COLOR_ATTACHMENT5=36069]="COLOR_ATTACHMENT5",e[e.COLOR_ATTACHMENT6=36070]="COLOR_ATTACHMENT6",e[e.COLOR_ATTACHMENT7=36071]="COLOR_ATTACHMENT7",e[e.COLOR_ATTACHMENT8=36072]="COLOR_ATTACHMENT8",e[e.COLOR_ATTACHMENT9=36073]="COLOR_ATTACHMENT9",e[e.COLOR_ATTACHMENT10=36074]="COLOR_ATTACHMENT10",e[e.COLOR_ATTACHMENT11=36075]="COLOR_ATTACHMENT11",e[e.COLOR_ATTACHMENT12=36076]="COLOR_ATTACHMENT12",e[e.COLOR_ATTACHMENT13=36077]="COLOR_ATTACHMENT13",e[e.COLOR_ATTACHMENT14=36078]="COLOR_ATTACHMENT14",e[e.COLOR_ATTACHMENT15=36079]="COLOR_ATTACHMENT15",e[e.SAMPLER_3D=35679]="SAMPLER_3D",e[e.SAMPLER_2D_SHADOW=35682]="SAMPLER_2D_SHADOW",e[e.SAMPLER_2D_ARRAY=36289]="SAMPLER_2D_ARRAY",e[e.SAMPLER_2D_ARRAY_SHADOW=36292]="SAMPLER_2D_ARRAY_SHADOW",e[e.SAMPLER_CUBE_SHADOW=36293]="SAMPLER_CUBE_SHADOW",e[e.INT_SAMPLER_2D=36298]="INT_SAMPLER_2D",e[e.INT_SAMPLER_3D=36299]="INT_SAMPLER_3D",e[e.INT_SAMPLER_CUBE=36300]="INT_SAMPLER_CUBE",e[e.INT_SAMPLER_2D_ARRAY=36303]="INT_SAMPLER_2D_ARRAY",e[e.UNSIGNED_INT_SAMPLER_2D=36306]="UNSIGNED_INT_SAMPLER_2D",e[e.UNSIGNED_INT_SAMPLER_3D=36307]="UNSIGNED_INT_SAMPLER_3D",e[e.UNSIGNED_INT_SAMPLER_CUBE=36308]="UNSIGNED_INT_SAMPLER_CUBE",e[e.UNSIGNED_INT_SAMPLER_2D_ARRAY=36311]="UNSIGNED_INT_SAMPLER_2D_ARRAY",e[e.MAX_SAMPLES=36183]="MAX_SAMPLES",e[e.SAMPLER_BINDING=35097]="SAMPLER_BINDING",e[e.PIXEL_PACK_BUFFER=35051]="PIXEL_PACK_BUFFER",e[e.PIXEL_UNPACK_BUFFER=35052]="PIXEL_UNPACK_BUFFER",e[e.PIXEL_PACK_BUFFER_BINDING=35053]="PIXEL_PACK_BUFFER_BINDING",e[e.PIXEL_UNPACK_BUFFER_BINDING=35055]="PIXEL_UNPACK_BUFFER_BINDING",e[e.COPY_READ_BUFFER=36662]="COPY_READ_BUFFER",e[e.COPY_WRITE_BUFFER=36663]="COPY_WRITE_BUFFER",e[e.COPY_READ_BUFFER_BINDING=36662]="COPY_READ_BUFFER_BINDING",e[e.COPY_WRITE_BUFFER_BINDING=36663]="COPY_WRITE_BUFFER_BINDING",e[e.FLOAT_MAT2x3=35685]="FLOAT_MAT2x3",e[e.FLOAT_MAT2x4=35686]="FLOAT_MAT2x4",e[e.FLOAT_MAT3x2=35687]="FLOAT_MAT3x2",e[e.FLOAT_MAT3x4=35688]="FLOAT_MAT3x4",e[e.FLOAT_MAT4x2=35689]="FLOAT_MAT4x2",e[e.FLOAT_MAT4x3=35690]="FLOAT_MAT4x3",e[e.UNSIGNED_INT_VEC2=36294]="UNSIGNED_INT_VEC2",e[e.UNSIGNED_INT_VEC3=36295]="UNSIGNED_INT_VEC3",e[e.UNSIGNED_INT_VEC4=36296]="UNSIGNED_INT_VEC4",e[e.UNSIGNED_NORMALIZED=35863]="UNSIGNED_NORMALIZED",e[e.SIGNED_NORMALIZED=36764]="SIGNED_NORMALIZED",e[e.VERTEX_ATTRIB_ARRAY_INTEGER=35069]="VERTEX_ATTRIB_ARRAY_INTEGER",e[e.VERTEX_ATTRIB_ARRAY_DIVISOR=35070]="VERTEX_ATTRIB_ARRAY_DIVISOR",e[e.TRANSFORM_FEEDBACK_BUFFER_MODE=35967]="TRANSFORM_FEEDBACK_BUFFER_MODE",e[e.MAX_TRANSFORM_FEEDBACK_SEPARATE_COMPONENTS=35968]="MAX_TRANSFORM_FEEDBACK_SEPARATE_COMPONENTS",e[e.TRANSFORM_FEEDBACK_VARYINGS=35971]="TRANSFORM_FEEDBACK_VARYINGS",e[e.TRANSFORM_FEEDBACK_BUFFER_START=35972]="TRANSFORM_FEEDBACK_BUFFER_START",e[e.TRANSFORM_FEEDBACK_BUFFER_SIZE=35973]="TRANSFORM_FEEDBACK_BUFFER_SIZE",e[e.TRANSFORM_FEEDBACK_PRIMITIVES_WRITTEN=35976]="TRANSFORM_FEEDBACK_PRIMITIVES_WRITTEN",e[e.MAX_TRANSFORM_FEEDBACK_INTERLEAVED_COMPONENTS=35978]="MAX_TRANSFORM_FEEDBACK_INTERLEAVED_COMPONENTS",e[e.MAX_TRANSFORM_FEEDBACK_SEPARATE_ATTRIBS=35979]="MAX_TRANSFORM_FEEDBACK_SEPARATE_ATTRIBS",e[e.INTERLEAVED_ATTRIBS=35980]="INTERLEAVED_ATTRIBS",e[e.SEPARATE_ATTRIBS=35981]="SEPARATE_ATTRIBS",e[e.TRANSFORM_FEEDBACK_BUFFER=35982]="TRANSFORM_FEEDBACK_BUFFER",e[e.TRANSFORM_FEEDBACK_BUFFER_BINDING=35983]="TRANSFORM_FEEDBACK_BUFFER_BINDING",e[e.TRANSFORM_FEEDBACK=36386]="TRANSFORM_FEEDBACK",e[e.TRANSFORM_FEEDBACK_PAUSED=36387]="TRANSFORM_FEEDBACK_PAUSED",e[e.TRANSFORM_FEEDBACK_ACTIVE=36388]="TRANSFORM_FEEDBACK_ACTIVE",e[e.TRANSFORM_FEEDBACK_BINDING=36389]="TRANSFORM_FEEDBACK_BINDING",e[e.FRAMEBUFFER_ATTACHMENT_COLOR_ENCODING=33296]="FRAMEBUFFER_ATTACHMENT_COLOR_ENCODING",e[e.FRAMEBUFFER_ATTACHMENT_COMPONENT_TYPE=33297]="FRAMEBUFFER_ATTACHMENT_COMPONENT_TYPE",e[e.FRAMEBUFFER_ATTACHMENT_RED_SIZE=33298]="FRAMEBUFFER_ATTACHMENT_RED_SIZE",e[e.FRAMEBUFFER_ATTACHMENT_GREEN_SIZE=33299]="FRAMEBUFFER_ATTACHMENT_GREEN_SIZE",e[e.FRAMEBUFFER_ATTACHMENT_BLUE_SIZE=33300]="FRAMEBUFFER_ATTACHMENT_BLUE_SIZE",e[e.FRAMEBUFFER_ATTACHMENT_ALPHA_SIZE=33301]="FRAMEBUFFER_ATTACHMENT_ALPHA_SIZE",e[e.FRAMEBUFFER_ATTACHMENT_DEPTH_SIZE=33302]="FRAMEBUFFER_ATTACHMENT_DEPTH_SIZE",e[e.FRAMEBUFFER_ATTACHMENT_STENCIL_SIZE=33303]="FRAMEBUFFER_ATTACHMENT_STENCIL_SIZE",e[e.FRAMEBUFFER_DEFAULT=33304]="FRAMEBUFFER_DEFAULT",e[e.DEPTH24_STENCIL8=35056]="DEPTH24_STENCIL8",e[e.DRAW_FRAMEBUFFER_BINDING=36006]="DRAW_FRAMEBUFFER_BINDING",e[e.READ_FRAMEBUFFER_BINDING=36010]="READ_FRAMEBUFFER_BINDING",e[e.RENDERBUFFER_SAMPLES=36011]="RENDERBUFFER_SAMPLES",e[e.FRAMEBUFFER_ATTACHMENT_TEXTURE_LAYER=36052]="FRAMEBUFFER_ATTACHMENT_TEXTURE_LAYER",e[e.FRAMEBUFFER_INCOMPLETE_MULTISAMPLE=36182]="FRAMEBUFFER_INCOMPLETE_MULTISAMPLE",e[e.UNIFORM_BUFFER=35345]="UNIFORM_BUFFER",e[e.UNIFORM_BUFFER_BINDING=35368]="UNIFORM_BUFFER_BINDING",e[e.UNIFORM_BUFFER_START=35369]="UNIFORM_BUFFER_START",e[e.UNIFORM_BUFFER_SIZE=35370]="UNIFORM_BUFFER_SIZE",e[e.MAX_VERTEX_UNIFORM_BLOCKS=35371]="MAX_VERTEX_UNIFORM_BLOCKS",e[e.MAX_FRAGMENT_UNIFORM_BLOCKS=35373]="MAX_FRAGMENT_UNIFORM_BLOCKS",e[e.MAX_COMBINED_UNIFORM_BLOCKS=35374]="MAX_COMBINED_UNIFORM_BLOCKS",e[e.MAX_UNIFORM_BUFFER_BINDINGS=35375]="MAX_UNIFORM_BUFFER_BINDINGS",e[e.MAX_UNIFORM_BLOCK_SIZE=35376]="MAX_UNIFORM_BLOCK_SIZE",e[e.MAX_COMBINED_VERTEX_UNIFORM_COMPONENTS=35377]="MAX_COMBINED_VERTEX_UNIFORM_COMPONENTS",e[e.MAX_COMBINED_FRAGMENT_UNIFORM_COMPONENTS=35379]="MAX_COMBINED_FRAGMENT_UNIFORM_COMPONENTS",e[e.UNIFORM_BUFFER_OFFSET_ALIGNMENT=35380]="UNIFORM_BUFFER_OFFSET_ALIGNMENT",e[e.ACTIVE_UNIFORM_BLOCKS=35382]="ACTIVE_UNIFORM_BLOCKS",e[e.UNIFORM_TYPE=35383]="UNIFORM_TYPE",e[e.UNIFORM_SIZE=35384]="UNIFORM_SIZE",e[e.UNIFORM_BLOCK_INDEX=35386]="UNIFORM_BLOCK_INDEX",e[e.UNIFORM_OFFSET=35387]="UNIFORM_OFFSET",e[e.UNIFORM_ARRAY_STRIDE=35388]="UNIFORM_ARRAY_STRIDE",e[e.UNIFORM_MATRIX_STRIDE=35389]="UNIFORM_MATRIX_STRIDE",e[e.UNIFORM_IS_ROW_MAJOR=35390]="UNIFORM_IS_ROW_MAJOR",e[e.UNIFORM_BLOCK_BINDING=35391]="UNIFORM_BLOCK_BINDING",e[e.UNIFORM_BLOCK_DATA_SIZE=35392]="UNIFORM_BLOCK_DATA_SIZE",e[e.UNIFORM_BLOCK_ACTIVE_UNIFORMS=35394]="UNIFORM_BLOCK_ACTIVE_UNIFORMS",e[e.UNIFORM_BLOCK_ACTIVE_UNIFORM_INDICES=35395]="UNIFORM_BLOCK_ACTIVE_UNIFORM_INDICES",e[e.UNIFORM_BLOCK_REFERENCED_BY_VERTEX_SHADER=35396]="UNIFORM_BLOCK_REFERENCED_BY_VERTEX_SHADER",e[e.UNIFORM_BLOCK_REFERENCED_BY_FRAGMENT_SHADER=35398]="UNIFORM_BLOCK_REFERENCED_BY_FRAGMENT_SHADER",e[e.OBJECT_TYPE=37138]="OBJECT_TYPE",e[e.SYNC_CONDITION=37139]="SYNC_CONDITION",e[e.SYNC_STATUS=37140]="SYNC_STATUS",e[e.SYNC_FLAGS=37141]="SYNC_FLAGS",e[e.SYNC_FENCE=37142]="SYNC_FENCE",e[e.SYNC_GPU_COMMANDS_COMPLETE=37143]="SYNC_GPU_COMMANDS_COMPLETE",e[e.UNSIGNALED=37144]="UNSIGNALED",e[e.SIGNALED=37145]="SIGNALED",e[e.ALREADY_SIGNALED=37146]="ALREADY_SIGNALED",e[e.TIMEOUT_EXPIRED=37147]="TIMEOUT_EXPIRED",e[e.CONDITION_SATISFIED=37148]="CONDITION_SATISFIED",e[e.WAIT_FAILED=37149]="WAIT_FAILED",e[e.SYNC_FLUSH_COMMANDS_BIT=1]="SYNC_FLUSH_COMMANDS_BIT",e[e.COLOR=6144]="COLOR",e[e.DEPTH=6145]="DEPTH",e[e.STENCIL=6146]="STENCIL",e[e.MIN=32775]="MIN",e[e.MAX=32776]="MAX",e[e.DEPTH_COMPONENT24=33190]="DEPTH_COMPONENT24",e[e.STREAM_READ=35041]="STREAM_READ",e[e.STREAM_COPY=35042]="STREAM_COPY",e[e.STATIC_READ=35045]="STATIC_READ",e[e.STATIC_COPY=35046]="STATIC_COPY",e[e.DYNAMIC_READ=35049]="DYNAMIC_READ",e[e.DYNAMIC_COPY=35050]="DYNAMIC_COPY",e[e.DEPTH_COMPONENT32F=36012]="DEPTH_COMPONENT32F",e[e.DEPTH32F_STENCIL8=36013]="DEPTH32F_STENCIL8",e[e.INVALID_INDEX=4294967295]="INVALID_INDEX",e[e.TIMEOUT_IGNORED=-1]="TIMEOUT_IGNORED",e[e.MAX_CLIENT_WAIT_TIMEOUT_WEBGL=37447]="MAX_CLIENT_WAIT_TIMEOUT_WEBGL",e[e.UNMASKED_VENDOR_WEBGL=37445]="UNMASKED_VENDOR_WEBGL",e[e.UNMASKED_RENDERER_WEBGL=37446]="UNMASKED_RENDERER_WEBGL",e[e.MAX_TEXTURE_MAX_ANISOTROPY_EXT=34047]="MAX_TEXTURE_MAX_ANISOTROPY_EXT",e[e.TEXTURE_MAX_ANISOTROPY_EXT=34046]="TEXTURE_MAX_ANISOTROPY_EXT",e[e.R16_EXT=33322]="R16_EXT",e[e.RG16_EXT=33324]="RG16_EXT",e[e.RGB16_EXT=32852]="RGB16_EXT",e[e.RGBA16_EXT=32859]="RGBA16_EXT",e[e.R16_SNORM_EXT=36760]="R16_SNORM_EXT",e[e.RG16_SNORM_EXT=36761]="RG16_SNORM_EXT",e[e.RGB16_SNORM_EXT=36762]="RGB16_SNORM_EXT",e[e.RGBA16_SNORM_EXT=36763]="RGBA16_SNORM_EXT",e[e.COMPRESSED_RGB_S3TC_DXT1_EXT=33776]="COMPRESSED_RGB_S3TC_DXT1_EXT",e[e.COMPRESSED_RGBA_S3TC_DXT1_EXT=33777]="COMPRESSED_RGBA_S3TC_DXT1_EXT",e[e.COMPRESSED_RGBA_S3TC_DXT3_EXT=33778]="COMPRESSED_RGBA_S3TC_DXT3_EXT",e[e.COMPRESSED_RGBA_S3TC_DXT5_EXT=33779]="COMPRESSED_RGBA_S3TC_DXT5_EXT",e[e.COMPRESSED_SRGB_S3TC_DXT1_EXT=35916]="COMPRESSED_SRGB_S3TC_DXT1_EXT",e[e.COMPRESSED_SRGB_ALPHA_S3TC_DXT1_EXT=35917]="COMPRESSED_SRGB_ALPHA_S3TC_DXT1_EXT",e[e.COMPRESSED_SRGB_ALPHA_S3TC_DXT3_EXT=35918]="COMPRESSED_SRGB_ALPHA_S3TC_DXT3_EXT",e[e.COMPRESSED_SRGB_ALPHA_S3TC_DXT5_EXT=35919]="COMPRESSED_SRGB_ALPHA_S3TC_DXT5_EXT",e[e.COMPRESSED_RED_RGTC1_EXT=36283]="COMPRESSED_RED_RGTC1_EXT",e[e.COMPRESSED_SIGNED_RED_RGTC1_EXT=36284]="COMPRESSED_SIGNED_RED_RGTC1_EXT",e[e.COMPRESSED_RED_GREEN_RGTC2_EXT=36285]="COMPRESSED_RED_GREEN_RGTC2_EXT",e[e.COMPRESSED_SIGNED_RED_GREEN_RGTC2_EXT=36286]="COMPRESSED_SIGNED_RED_GREEN_RGTC2_EXT",e[e.COMPRESSED_RGBA_BPTC_UNORM_EXT=36492]="COMPRESSED_RGBA_BPTC_UNORM_EXT",e[e.COMPRESSED_SRGB_ALPHA_BPTC_UNORM_EXT=36493]="COMPRESSED_SRGB_ALPHA_BPTC_UNORM_EXT",e[e.COMPRESSED_RGB_BPTC_SIGNED_FLOAT_EXT=36494]="COMPRESSED_RGB_BPTC_SIGNED_FLOAT_EXT",e[e.COMPRESSED_RGB_BPTC_UNSIGNED_FLOAT_EXT=36495]="COMPRESSED_RGB_BPTC_UNSIGNED_FLOAT_EXT",e[e.COMPRESSED_R11_EAC=37488]="COMPRESSED_R11_EAC",e[e.COMPRESSED_SIGNED_R11_EAC=37489]="COMPRESSED_SIGNED_R11_EAC",e[e.COMPRESSED_RG11_EAC=37490]="COMPRESSED_RG11_EAC",e[e.COMPRESSED_SIGNED_RG11_EAC=37491]="COMPRESSED_SIGNED_RG11_EAC",e[e.COMPRESSED_RGB8_ETC2=37492]="COMPRESSED_RGB8_ETC2",e[e.COMPRESSED_RGBA8_ETC2_EAC=37493]="COMPRESSED_RGBA8_ETC2_EAC",e[e.COMPRESSED_SRGB8_ETC2=37494]="COMPRESSED_SRGB8_ETC2",e[e.COMPRESSED_SRGB8_ALPHA8_ETC2_EAC=37495]="COMPRESSED_SRGB8_ALPHA8_ETC2_EAC",e[e.COMPRESSED_RGB8_PUNCHTHROUGH_ALPHA1_ETC2=37496]="COMPRESSED_RGB8_PUNCHTHROUGH_ALPHA1_ETC2",e[e.COMPRESSED_SRGB8_PUNCHTHROUGH_ALPHA1_ETC2=37497]="COMPRESSED_SRGB8_PUNCHTHROUGH_ALPHA1_ETC2",e[e.COMPRESSED_RGB_PVRTC_4BPPV1_IMG=35840]="COMPRESSED_RGB_PVRTC_4BPPV1_IMG",e[e.COMPRESSED_RGBA_PVRTC_4BPPV1_IMG=35842]="COMPRESSED_RGBA_PVRTC_4BPPV1_IMG",e[e.COMPRESSED_RGB_PVRTC_2BPPV1_IMG=35841]="COMPRESSED_RGB_PVRTC_2BPPV1_IMG",e[e.COMPRESSED_RGBA_PVRTC_2BPPV1_IMG=35843]="COMPRESSED_RGBA_PVRTC_2BPPV1_IMG",e[e.COMPRESSED_RGB_ETC1_WEBGL=36196]="COMPRESSED_RGB_ETC1_WEBGL",e[e.COMPRESSED_RGB_ATC_WEBGL=35986]="COMPRESSED_RGB_ATC_WEBGL",e[e.COMPRESSED_RGBA_ATC_EXPLICIT_ALPHA_WEBGL=35986]="COMPRESSED_RGBA_ATC_EXPLICIT_ALPHA_WEBGL",e[e.COMPRESSED_RGBA_ATC_INTERPOLATED_ALPHA_WEBGL=34798]="COMPRESSED_RGBA_ATC_INTERPOLATED_ALPHA_WEBGL",e[e.COMPRESSED_RGBA_ASTC_4x4_KHR=37808]="COMPRESSED_RGBA_ASTC_4x4_KHR",e[e.COMPRESSED_RGBA_ASTC_5x4_KHR=37809]="COMPRESSED_RGBA_ASTC_5x4_KHR",e[e.COMPRESSED_RGBA_ASTC_5x5_KHR=37810]="COMPRESSED_RGBA_ASTC_5x5_KHR",e[e.COMPRESSED_RGBA_ASTC_6x5_KHR=37811]="COMPRESSED_RGBA_ASTC_6x5_KHR",e[e.COMPRESSED_RGBA_ASTC_6x6_KHR=37812]="COMPRESSED_RGBA_ASTC_6x6_KHR",e[e.COMPRESSED_RGBA_ASTC_8x5_KHR=37813]="COMPRESSED_RGBA_ASTC_8x5_KHR",e[e.COMPRESSED_RGBA_ASTC_8x6_KHR=37814]="COMPRESSED_RGBA_ASTC_8x6_KHR",e[e.COMPRESSED_RGBA_ASTC_8x8_KHR=37815]="COMPRESSED_RGBA_ASTC_8x8_KHR",e[e.COMPRESSED_RGBA_ASTC_10x5_KHR=37816]="COMPRESSED_RGBA_ASTC_10x5_KHR",e[e.COMPRESSED_RGBA_ASTC_10x6_KHR=37817]="COMPRESSED_RGBA_ASTC_10x6_KHR",e[e.COMPRESSED_RGBA_ASTC_10x8_KHR=37818]="COMPRESSED_RGBA_ASTC_10x8_KHR",e[e.COMPRESSED_RGBA_ASTC_10x10_KHR=37819]="COMPRESSED_RGBA_ASTC_10x10_KHR",e[e.COMPRESSED_RGBA_ASTC_12x10_KHR=37820]="COMPRESSED_RGBA_ASTC_12x10_KHR",e[e.COMPRESSED_RGBA_ASTC_12x12_KHR=37821]="COMPRESSED_RGBA_ASTC_12x12_KHR",e[e.COMPRESSED_SRGB8_ALPHA8_ASTC_4x4_KHR=37840]="COMPRESSED_SRGB8_ALPHA8_ASTC_4x4_KHR",e[e.COMPRESSED_SRGB8_ALPHA8_ASTC_5x4_KHR=37841]="COMPRESSED_SRGB8_ALPHA8_ASTC_5x4_KHR",e[e.COMPRESSED_SRGB8_ALPHA8_ASTC_5x5_KHR=37842]="COMPRESSED_SRGB8_ALPHA8_ASTC_5x5_KHR",e[e.COMPRESSED_SRGB8_ALPHA8_ASTC_6x5_KHR=37843]="COMPRESSED_SRGB8_ALPHA8_ASTC_6x5_KHR",e[e.COMPRESSED_SRGB8_ALPHA8_ASTC_6x6_KHR=37844]="COMPRESSED_SRGB8_ALPHA8_ASTC_6x6_KHR",e[e.COMPRESSED_SRGB8_ALPHA8_ASTC_8x5_KHR=37845]="COMPRESSED_SRGB8_ALPHA8_ASTC_8x5_KHR",e[e.COMPRESSED_SRGB8_ALPHA8_ASTC_8x6_KHR=37846]="COMPRESSED_SRGB8_ALPHA8_ASTC_8x6_KHR",e[e.COMPRESSED_SRGB8_ALPHA8_ASTC_8x8_KHR=37847]="COMPRESSED_SRGB8_ALPHA8_ASTC_8x8_KHR",e[e.COMPRESSED_SRGB8_ALPHA8_ASTC_10x5_KHR=37848]="COMPRESSED_SRGB8_ALPHA8_ASTC_10x5_KHR",e[e.COMPRESSED_SRGB8_ALPHA8_ASTC_10x6_KHR=37849]="COMPRESSED_SRGB8_ALPHA8_ASTC_10x6_KHR",e[e.COMPRESSED_SRGB8_ALPHA8_ASTC_10x8_KHR=37850]="COMPRESSED_SRGB8_ALPHA8_ASTC_10x8_KHR",e[e.COMPRESSED_SRGB8_ALPHA8_ASTC_10x10_KHR=37851]="COMPRESSED_SRGB8_ALPHA8_ASTC_10x10_KHR",e[e.COMPRESSED_SRGB8_ALPHA8_ASTC_12x10_KHR=37852]="COMPRESSED_SRGB8_ALPHA8_ASTC_12x10_KHR",e[e.COMPRESSED_SRGB8_ALPHA8_ASTC_12x12_KHR=37853]="COMPRESSED_SRGB8_ALPHA8_ASTC_12x12_KHR",e[e.QUERY_COUNTER_BITS_EXT=34916]="QUERY_COUNTER_BITS_EXT",e[e.CURRENT_QUERY_EXT=34917]="CURRENT_QUERY_EXT",e[e.QUERY_RESULT_EXT=34918]="QUERY_RESULT_EXT",e[e.QUERY_RESULT_AVAILABLE_EXT=34919]="QUERY_RESULT_AVAILABLE_EXT",e[e.TIME_ELAPSED_EXT=35007]="TIME_ELAPSED_EXT",e[e.TIMESTAMP_EXT=36392]="TIMESTAMP_EXT",e[e.GPU_DISJOINT_EXT=36795]="GPU_DISJOINT_EXT",e[e.COMPLETION_STATUS_KHR=37297]="COMPLETION_STATUS_KHR",e[e.DEPTH_CLAMP_EXT=34383]="DEPTH_CLAMP_EXT",e[e.FIRST_VERTEX_CONVENTION_WEBGL=36429]="FIRST_VERTEX_CONVENTION_WEBGL",e[e.LAST_VERTEX_CONVENTION_WEBGL=36430]="LAST_VERTEX_CONVENTION_WEBGL",e[e.PROVOKING_VERTEX_WEBL=36431]="PROVOKING_VERTEX_WEBL",e[e.POLYGON_MODE_WEBGL=2880]="POLYGON_MODE_WEBGL",e[e.POLYGON_OFFSET_LINE_WEBGL=10754]="POLYGON_OFFSET_LINE_WEBGL",e[e.LINE_WEBGL=6913]="LINE_WEBGL",e[e.FILL_WEBGL=6914]="FILL_WEBGL",e[e.MAX_CLIP_DISTANCES_WEBGL=3378]="MAX_CLIP_DISTANCES_WEBGL",e[e.MAX_CULL_DISTANCES_WEBGL=33529]="MAX_CULL_DISTANCES_WEBGL",e[e.MAX_COMBINED_CLIP_AND_CULL_DISTANCES_WEBGL=33530]="MAX_COMBINED_CLIP_AND_CULL_DISTANCES_WEBGL",e[e.CLIP_DISTANCE0_WEBGL=12288]="CLIP_DISTANCE0_WEBGL",e[e.CLIP_DISTANCE1_WEBGL=12289]="CLIP_DISTANCE1_WEBGL",e[e.CLIP_DISTANCE2_WEBGL=12290]="CLIP_DISTANCE2_WEBGL",e[e.CLIP_DISTANCE3_WEBGL=12291]="CLIP_DISTANCE3_WEBGL",e[e.CLIP_DISTANCE4_WEBGL=12292]="CLIP_DISTANCE4_WEBGL",e[e.CLIP_DISTANCE5_WEBGL=12293]="CLIP_DISTANCE5_WEBGL",e[e.CLIP_DISTANCE6_WEBGL=12294]="CLIP_DISTANCE6_WEBGL",e[e.CLIP_DISTANCE7_WEBGL=12295]="CLIP_DISTANCE7_WEBGL",e[e.POLYGON_OFFSET_CLAMP_EXT=36379]="POLYGON_OFFSET_CLAMP_EXT",e[e.LOWER_LEFT_EXT=36001]="LOWER_LEFT_EXT",e[e.UPPER_LEFT_EXT=36002]="UPPER_LEFT_EXT",e[e.NEGATIVE_ONE_TO_ONE_EXT=37726]="NEGATIVE_ONE_TO_ONE_EXT",e[e.ZERO_TO_ONE_EXT=37727]="ZERO_TO_ONE_EXT",e[e.CLIP_ORIGIN_EXT=37724]="CLIP_ORIGIN_EXT",e[e.CLIP_DEPTH_MODE_EXT=37725]="CLIP_DEPTH_MODE_EXT",e[e.SRC1_COLOR_WEBGL=35065]="SRC1_COLOR_WEBGL",e[e.SRC1_ALPHA_WEBGL=34185]="SRC1_ALPHA_WEBGL",e[e.ONE_MINUS_SRC1_COLOR_WEBGL=35066]="ONE_MINUS_SRC1_COLOR_WEBGL",e[e.ONE_MINUS_SRC1_ALPHA_WEBGL=35067]="ONE_MINUS_SRC1_ALPHA_WEBGL",e[e.MAX_DUAL_SOURCE_DRAW_BUFFERS_WEBGL=35068]="MAX_DUAL_SOURCE_DRAW_BUFFERS_WEBGL",e[e.MIRROR_CLAMP_TO_EDGE_EXT=34627]="MIRROR_CLAMP_TO_EDGE_EXT"}($b||($b={}));const Zb={3042:!1,32773:new Float32Array([0,0,0,0]),32777:32774,34877:32774,32969:1,32968:0,32971:1,32970:0,3106:new Float32Array([0,0,0,0]),3107:[!0,!0,!0,!0],2884:!1,2885:1029,2929:!1,2931:1,2932:513,2928:new Float32Array([0,1]),2930:!0,3024:!0,35725:null,36006:null,36007:null,34229:null,34964:null,2886:2305,33170:4352,2849:1,32823:!1,32824:0,10752:0,32926:!1,32928:!1,32938:1,32939:!1,3089:!1,3088:new Int32Array([0,0,1024,1024]),2960:!1,2961:0,2968:4294967295,36005:4294967295,2962:519,2967:0,2963:4294967295,34816:519,36003:0,36004:4294967295,2964:7680,2965:7680,2966:7680,34817:7680,34818:7680,34819:7680,2978:[0,0,1024,1024],36389:null,36662:null,36663:null,35053:null,35055:null,35723:4352,36010:null,35977:!1,3333:4,3317:4,37440:!1,37441:!1,37443:37444,3330:0,3332:0,3331:0,3314:0,32878:0,3316:0,3315:0,32877:0},Wb=(e,t,i)=>t?e.enable(i):e.disable(i),qb=(e,t,i)=>e.hint(i,t),Kb=(e,t,i)=>e.pixelStorei(i,t),Xb=(e,t,i)=>{const n=36006===i?36009:36008;return e.bindFramebuffer(n,t)},Jb=(e,t,i)=>{const n={34964:34962,36662:36662,36663:36663,35053:35051,35055:35052}[i];e.bindBuffer(n,t)};function Yb(e){return Array.isArray(e)||ArrayBuffer.isView(e)&&!(e instanceof DataView)}const ew={3042:Wb,32773:(e,t)=>e.blendColor(...t),32777:"blendEquation",34877:"blendEquation",32969:"blendFunc",32968:"blendFunc",32971:"blendFunc",32970:"blendFunc",3106:(e,t)=>e.clearColor(...t),3107:(e,t)=>e.colorMask(...t),2884:Wb,2885:(e,t)=>e.cullFace(t),2929:Wb,2931:(e,t)=>e.clearDepth(t),2932:(e,t)=>e.depthFunc(t),2928:(e,t)=>e.depthRange(...t),2930:(e,t)=>e.depthMask(t),3024:Wb,35723:qb,35725:(e,t)=>e.useProgram(t),36007:(e,t)=>e.bindRenderbuffer(36161,t),36389:(e,t)=>e.bindTransformFeedback?.(36386,t),34229:(e,t)=>e.bindVertexArray(t),36006:Xb,36010:Xb,34964:Jb,36662:Jb,36663:Jb,35053:Jb,35055:Jb,2886:(e,t)=>e.frontFace(t),33170:qb,2849:(e,t)=>e.lineWidth(t),32823:Wb,32824:"polygonOffset",10752:"polygonOffset",35977:Wb,32926:Wb,32928:Wb,32938:"sampleCoverage",32939:"sampleCoverage",3089:Wb,3088:(e,t)=>e.scissor(...t),2960:Wb,2961:(e,t)=>e.clearStencil(t),2968:(e,t)=>e.stencilMaskSeparate(1028,t),36005:(e,t)=>e.stencilMaskSeparate(1029,t),2962:"stencilFuncFront",2967:"stencilFuncFront",2963:"stencilFuncFront",34816:"stencilFuncBack",36003:"stencilFuncBack",36004:"stencilFuncBack",2964:"stencilOpFront",2965:"stencilOpFront",2966:"stencilOpFront",34817:"stencilOpBack",34818:"stencilOpBack",34819:"stencilOpBack",2978:(e,t)=>e.viewport(...t),34383:Wb,10754:Wb,12288:Wb,12289:Wb,12290:Wb,12291:Wb,12292:Wb,12293:Wb,12294:Wb,12295:Wb,3333:Kb,3317:Kb,37440:Kb,37441:Kb,37443:Kb,3330:Kb,3332:Kb,3331:Kb,3314:Kb,32878:Kb,3316:Kb,3315:Kb,32877:Kb,framebuffer:(e,t)=>{const i=t&&"handle"in t?t.handle:t;return e.bindFramebuffer(36160,i)},blend:(e,t)=>t?e.enable(3042):e.disable(3042),blendColor:(e,t)=>e.blendColor(...t),blendEquation:(e,t)=>{const i="number"==typeof t?[t,t]:t;e.blendEquationSeparate(...i)},blendFunc:(e,t)=>{const i=2===t?.length?[...t,...t]:t;e.blendFuncSeparate(...i)},clearColor:(e,t)=>e.clearColor(...t),clearDepth:(e,t)=>e.clearDepth(t),clearStencil:(e,t)=>e.clearStencil(t),colorMask:(e,t)=>e.colorMask(...t),cull:(e,t)=>t?e.enable(2884):e.disable(2884),cullFace:(e,t)=>e.cullFace(t),depthTest:(e,t)=>t?e.enable(2929):e.disable(2929),depthFunc:(e,t)=>e.depthFunc(t),depthMask:(e,t)=>e.depthMask(t),depthRange:(e,t)=>e.depthRange(...t),dither:(e,t)=>t?e.enable(3024):e.disable(3024),derivativeHint:(e,t)=>{e.hint(35723,t)},frontFace:(e,t)=>e.frontFace(t),mipmapHint:(e,t)=>e.hint(33170,t),lineWidth:(e,t)=>e.lineWidth(t),polygonOffsetFill:(e,t)=>t?e.enable(32823):e.disable(32823),polygonOffset:(e,t)=>e.polygonOffset(...t),sampleCoverage:(e,t)=>e.sampleCoverage(...t),scissorTest:(e,t)=>t?e.enable(3089):e.disable(3089),scissor:(e,t)=>e.scissor(...t),stencilTest:(e,t)=>t?e.enable(2960):e.disable(2960),stencilMask:(e,t)=>{t=Yb(t)?t:[t,t];const[i,n]=t;e.stencilMaskSeparate(1028,i),e.stencilMaskSeparate(1029,n)},stencilFunc:(e,t)=>{t=Yb(t)&&3===t.length?[...t,...t]:t;const[i,n,r,o,s,a]=t;e.stencilFuncSeparate(1028,i,n,r),e.stencilFuncSeparate(1029,o,s,a)},stencilOp:(e,t)=>{t=Yb(t)&&3===t.length?[...t,...t]:t;const[i,n,r,o,s,a]=t;e.stencilOpSeparate(1028,i,n,r),e.stencilOpSeparate(1029,o,s,a)},viewport:(e,t)=>e.viewport(...t)};function tw(e,t,i){return void 0!==t[e]?t[e]:i[e]}const iw={blendEquation:(e,t,i)=>e.blendEquationSeparate(tw(32777,t,i),tw(34877,t,i)),blendFunc:(e,t,i)=>e.blendFuncSeparate(tw(32969,t,i),tw(32968,t,i),tw(32971,t,i),tw(32970,t,i)),polygonOffset:(e,t,i)=>e.polygonOffset(tw(32824,t,i),tw(10752,t,i)),sampleCoverage:(e,t,i)=>e.sampleCoverage(tw(32938,t,i),tw(32939,t,i)),stencilFuncFront:(e,t,i)=>e.stencilFuncSeparate(1028,tw(2962,t,i),tw(2967,t,i),tw(2963,t,i)),stencilFuncBack:(e,t,i)=>e.stencilFuncSeparate(1029,tw(34816,t,i),tw(36003,t,i),tw(36004,t,i)),stencilOpFront:(e,t,i)=>e.stencilOpSeparate(1028,tw(2964,t,i),tw(2965,t,i),tw(2966,t,i)),stencilOpBack:(e,t,i)=>e.stencilOpSeparate(1029,tw(34817,t,i),tw(34818,t,i),tw(34819,t,i))},nw={enable:(e,t)=>e({[t]:!0}),disable:(e,t)=>e({[t]:!1}),pixelStorei:(e,t,i)=>e({[t]:i}),hint:(e,t,i)=>e({[t]:i}),useProgram:(e,t)=>e({35725:t}),bindRenderbuffer:(e,t,i)=>e({36007:i}),bindTransformFeedback:(e,t,i)=>e({36389:i}),bindVertexArray:(e,t)=>e({34229:t}),bindFramebuffer:(e,t,i)=>{switch(t){case 36160:return e({36006:i,36010:i});case 36009:return e({36006:i});case 36008:return e({36010:i});default:return null}},bindBuffer:(e,t,i)=>{const n={34962:[34964],36662:[36662],36663:[36663],35051:[35053],35052:[35055]}[t];return n?e({[n]:i}):{valueChanged:!0}},blendColor:(e,t,i,n,r)=>e({32773:new Float32Array([t,i,n,r])}),blendEquation:(e,t)=>e({32777:t,34877:t}),blendEquationSeparate:(e,t,i)=>e({32777:t,34877:i}),blendFunc:(e,t,i)=>e({32969:t,32968:i,32971:t,32970:i}),blendFuncSeparate:(e,t,i,n,r)=>e({32969:t,32968:i,32971:n,32970:r}),clearColor:(e,t,i,n,r)=>e({3106:new Float32Array([t,i,n,r])}),clearDepth:(e,t)=>e({2931:t}),clearStencil:(e,t)=>e({2961:t}),colorMask:(e,t,i,n,r)=>e({3107:[t,i,n,r]}),cullFace:(e,t)=>e({2885:t}),depthFunc:(e,t)=>e({2932:t}),depthRange:(e,t,i)=>e({2928:new Float32Array([t,i])}),depthMask:(e,t)=>e({2930:t}),frontFace:(e,t)=>e({2886:t}),lineWidth:(e,t)=>e({2849:t}),polygonOffset:(e,t,i)=>e({32824:t,10752:i}),sampleCoverage:(e,t,i)=>e({32938:t,32939:i}),scissor:(e,t,i,n,r)=>e({3088:new Int32Array([t,i,n,r])}),stencilMask:(e,t)=>e({2968:t,36005:t}),stencilMaskSeparate:(e,t,i)=>e({[1028===t?2968:36005]:i}),stencilFunc:(e,t,i,n)=>e({2962:t,2967:i,2963:n,34816:t,36003:i,36004:n}),stencilFuncSeparate:(e,t,i,n,r)=>e({[1028===t?2962:34816]:i,[1028===t?2967:36003]:n,[1028===t?2963:36004]:r}),stencilOp:(e,t,i,n)=>e({2964:t,2965:i,2966:n,34817:t,34818:i,34819:n}),stencilOpSeparate:(e,t,i,n,r)=>e({[1028===t?2964:34817]:i,[1028===t?2965:34818]:n,[1028===t?2966:34819]:r}),viewport:(e,t,i,n,r)=>e({2978:[t,i,n,r]})},rw=(e,t)=>e.isEnabled(t),ow={3042:rw,2884:rw,2929:rw,3024:rw,32823:rw,32926:rw,32928:rw,3089:rw,2960:rw,35977:rw},sw=new Set([34016,36388,36387,35983,35368,34965,35739,35738,3074,34853,34854,34855,34856,34857,34858,34859,34860,34861,34862,34863,34864,34865,34866,34867,34868,35097,32873,35869,32874,34068]);function aw(e,t){if(function(e){for(const t in e)return!1;return!0}(t))return;const i={};for(const n in t){const r=Number(n),o=ew[n];o&&("string"==typeof o?i[o]=!0:o(e,t[n],r))}const n=e.state&&e.state.cache;if(n)for(const r in i){(0,iw[r])(e,t,n)}}function lw(e,t=Zb){if("number"==typeof t){const i=t,n=ow[i];return n?n(e,i):e.getParameter(i)}const i=Array.isArray(t)?t:Object.keys(t),n={};for(const t of i){const i=ow[t];n[t]=i?i(e,Number(t)):e.getParameter(Number(t))}return n}function cw(e,t){if(e===t)return!0;const i=Array.isArray(e)||ArrayBuffer.isView(e),n=Array.isArray(t)||ArrayBuffer.isView(t);if(i&&n&&e.length===t.length){for(let i=0;i{}}={}){this.gl=e,this.cache=t?lw(e):Object.assign({},Zb),this.log=i,this._updateCache=this._updateCache.bind(this),Object.seal(this)}push(e={}){this.stateStack.push({})}pop(){cf(this.stateStack.length>0);const e=this.stateStack[this.stateStack.length-1];aw(this.gl,e),this.stateStack.pop()}_updateCache(e){let t,i=!1;const n=this.stateStack.length>0?this.stateStack[this.stateStack.length-1]:null;for(const r in e){cf(void 0!==r);const o=e[r],s=this.cache[r];cw(o,s)||(i=!0,t=s,n&&!(r in n)&&(n[r]=s),this.cache[r]=o)}return{valueChanged:i,oldValue:t}}}function hw(e){return e.state}function dw(e,t){const{enable:i=!0,copyState:n}=t;if(cf(void 0!==n),!e.state){e.state=new uw(e,{copyState:n}),function(e){const t=e.useProgram.bind(e);e.useProgram=function(i){const n=hw(e);n.program!==i&&(t(i),n.program=i)}}(e);for(const t in nw){gw(e,t,nw[t])}mw(e,"getParameter"),mw(e,"isEnabled")}return hw(e).enable=i,e}function pw(e){let t=hw(e);t||(dw(e,{copyState:!1}),t=hw(e)),t.push()}function fw(e){const t=hw(e);cf(t),t.pop()}function mw(e,t){const i=e[t].bind(e);e[t]=function(t){if(void 0===t||sw.has(t))return i(t);const n=hw(e);return t in n.cache||(n.cache[t]=i(t)),n.enable?n.cache[t]:i(t)},Object.defineProperty(e[t],"name",{value:`${t}-from-cache`,configurable:!1})}function gw(e,t,i){if(!e[t])return;const n=e[t].bind(e);e[t]=function(...t){const r=hw(e),{valueChanged:o,oldValue:s}=i(r._updateCache,...t);return o&&n(...t),s},Object.defineProperty(e[t],"name",{value:`${t}-to-cache`,configurable:!1})}const _w={powerPreference:"high-performance",onContextLost:()=>console.error("WebGL context lost"),onContextRestored:()=>console.info("WebGL context restored")};function Aw(e,t,i){return void 0===i[t]&&(i[t]=e.getExtension(t)||null),i[t]}function yw(e,t){const i=e.getParameter(7936),n=e.getParameter(7937);Aw(e,"WEBGL_debug_renderer_info",t);const r=t.WEBGL_debug_renderer_info,o=e.getParameter(r?r.UNMASKED_VENDOR_WEBGL:7936)||i,s=e.getParameter(r?r.UNMASKED_RENDERER_WEBGL:7937)||n,a=e.getParameter(7938),l=vw(o,s),c=function(e,t){if(/Metal/i.exec(e)||/Metal/i.exec(t))return"metal";if(/ANGLE/i.exec(e)||/ANGLE/i.exec(t))return"opengl";return"unknown"}(o,s),u=function(e,t){if(/SwiftShader/i.exec(e)||/SwiftShader/i.exec(t))return"cpu";switch(vw(e,t)){case"intel":return"integrated";case"software":return"cpu";case"unknown":return"unknown";default:return"discrete"}}(o,s);return{type:"webgl",gpu:l,gpuType:u,gpuBackend:c,vendor:o,renderer:s,version:a,shadingLanguage:"glsl",shadingLanguageVersion:300}}function vw(e,t){return/NVIDIA/i.exec(e)||/NVIDIA/i.exec(t)?"nvidia":/INTEL/i.exec(e)||/INTEL/i.exec(t)?"intel":/Apple/i.exec(e)||/Apple/i.exec(t)?"apple":/AMD/i.exec(e)||/AMD/i.exec(t)||/ATI/i.exec(e)||/ATI/i.exec(t)?"amd":/SwiftShader/i.exec(e)||/SwiftShader/i.exec(t)?"software":"unknown"}function xw(e){switch(e){case"uint8":case"unorm8":return 5121;case"sint8":case"snorm8":return 5120;case"uint16":case"unorm16":return 5123;case"sint16":case"snorm16":return 5122;case"uint32":return 5125;case"sint32":return 5124;case"float16":return 5131;case"float32":return 5126}throw new Error(String(e))}const bw="texture-compression-bc",ww="texture-compression-astc",Tw="texture-compression-etc2",Ew="texture-compression-pvrtc-webgl",Cw="texture-compression-atc-webgl",Sw="float32-renderable-webgl",Bw="float16-renderable-webgl",Iw="snorm8-renderable-webgl",Mw="norm16-renderable-webgl",Pw="snorm16-renderable-webgl",Rw="float32-filterable",Lw="float16-filterable-webgl",Fw="WEBGL_compressed_texture_s3tc",kw="WEBGL_compressed_texture_s3tc_srgb",Dw="EXT_texture_compression_rgtc",Ow="EXT_texture_compression_bptc",zw="EXT_texture_norm16",Uw="EXT_render_snorm",Nw={"float32-renderable-webgl":["EXT_color_buffer_float"],"float16-renderable-webgl":["EXT_color_buffer_half_float"],"rgb9e5ufloat_renderable-webgl":["WEBGL_render_shared_exponent"],"snorm8-renderable-webgl":[Uw],"norm16-renderable-webgl":[zw],"snorm16-renderable-webgl":[zw,Uw],"float32-filterable":["OES_texture_float_linear"],"float16-filterable-webgl":["OES_texture_half_float_linear"],"texture-filterable-anisotropic-webgl":["EXT_texture_filter_anisotropic"],"texture-blend-float-webgl":["EXT_float_blend"],"texture-compression-bc":[Fw,kw,Dw,Ow],"texture-compression-bc5-webgl":[Dw],"texture-compression-bc7-webgl":[Ow],"texture-compression-etc2":["WEBGL_compressed_texture_etc"],"texture-compression-astc":["WEBGL_compressed_texture_astc"],"texture-compression-etc1-webgl":["WEBGL_compressed_texture_etc1"],"texture-compression-pvrtc-webgl":["WEBGL_compressed_texture_pvrtc"],"texture-compression-atc-webgl":["WEBGL_compressed_texture_atc"]};const Vw={"rgb8unorm-unsized":{gl:6407,b:4,c:2,bpp:4,dataFormat:6407,types:[5121,33635]},"rgba8unorm-unsized":{gl:6408,b:4,c:2,bpp:4,dataFormat:6408,types:[5121,32819,32820]},r8unorm:{gl:33321,b:1,c:1,rb:!0},r8snorm:{gl:36756,b:1,c:1,render:Iw},r8uint:{gl:33330,b:1,c:1,rb:!0},r8sint:{gl:33329,b:1,c:1,rb:!0},rg8unorm:{gl:33323,b:2,c:2,rb:!0},rg8snorm:{gl:36757,b:2,c:2,render:Iw},rg8uint:{gl:33336,b:2,c:2,rb:!0},rg8sint:{gl:33335,b:2,c:2,rb:!0},r16uint:{gl:33332,b:2,c:1,rb:!0},r16sint:{gl:33331,b:2,c:1,rb:!0},r16float:{gl:33325,b:2,c:1,render:Bw,filter:"float16-filterable-webgl",rb:!0},"r16unorm-webgl":{gl:33322,b:2,c:1,f:Mw,rb:!0},"r16snorm-webgl":{gl:36760,b:2,c:1,f:Pw},"rgba4unorm-webgl":{gl:32854,b:2,c:4,wgpu:!1,rb:!0},"rgb565unorm-webgl":{gl:36194,b:2,c:4,wgpu:!1,rb:!0},"rgb5a1unorm-webgl":{gl:32855,b:2,c:4,wgpu:!1,rb:!0},"rgb8unorm-webgl":{gl:32849,b:3,c:3,wgpu:!1},"rgb8snorm-webgl":{gl:36758,b:3,c:3,wgpu:!1},rgba8unorm:{gl:32856,b:4,c:2,bpp:4},"rgba8unorm-srgb":{gl:35907,b:4,c:4,bpp:4},rgba8snorm:{gl:36759,b:4,c:4,render:Iw},rgba8uint:{gl:36220,b:4,c:4,bpp:4},rgba8sint:{gl:36238,b:4,c:4,bpp:4},bgra8unorm:{b:4,c:4},"bgra8unorm-srgb":{b:4,c:4},rg16uint:{gl:33338,b:4,c:1,bpp:4},rg16sint:{gl:33337,b:4,c:2,bpp:4},rg16float:{gl:33327,bpp:4,b:4,c:2,render:Bw,filter:Lw,rb:!0},"rg16unorm-webgl":{gl:33324,b:2,c:2,render:Mw},"rg16snorm-webgl":{gl:36761,b:2,c:2,render:Pw},r32uint:{gl:33334,b:4,c:1,bpp:4,rb:!0},r32sint:{gl:33333,b:4,c:1,bpp:4,rb:!0},r32float:{gl:33326,bpp:4,b:4,c:1,render:Sw,filter:Rw},rgb9e5ufloat:{gl:35901,b:4,c:3,p:1,render:"rgb9e5ufloat_renderable-webgl"},rg11b10ufloat:{gl:35898,b:4,c:3,p:1,render:Sw,rb:!0},rgb10a2unorm:{gl:32857,b:4,c:4,p:1,rb:!0},"rgb10a2uint-webgl":{b:4,c:4,gl:36975,p:1,wgpu:!1,bpp:4,rb:!0},"rgb16unorm-webgl":{gl:32852,b:2,c:3,f:Mw},"rgb16snorm-webgl":{gl:36762,b:2,c:3,f:Mw},rg32uint:{gl:33340,b:8,c:2,rb:!0},rg32sint:{gl:33339,b:8,c:2,rb:!0},rg32float:{gl:33328,b:8,c:2,render:Sw,filter:Rw,rb:!0},rgba16uint:{gl:36214,b:8,c:4,rb:!0},rgba16sint:{gl:36232,b:8,c:4,rb:!0},rgba16float:{gl:34842,b:8,c:4,render:Bw,filter:Lw},"rgba16unorm-webgl":{gl:32859,b:2,c:4,render:Mw,rb:!0},"rgba16snorm-webgl":{gl:36763,b:2,c:4,render:Pw},"rgb32float-webgl":{gl:34837,render:Sw,filter:Rw,gl2ext:"EXT_color_buffer_float",dataFormat:6407,types:[5126]},rgba32uint:{gl:36208,b:16,c:4,rb:!0},rgba32sint:{gl:36226,b:16,c:4,rb:!0},rgba32float:{gl:34836,b:16,c:4,render:Sw,filter:Rw,rb:!0},stencil8:{gl:36168,b:1,c:1,attachment:36128,rb:!0},depth16unorm:{gl:33189,b:2,c:1,attachment:36096,dataFormat:6402,types:[5123],rb:!0},depth24plus:{gl:33190,b:3,c:1,attachment:36096,dataFormat:6402,types:[5125]},depth32float:{gl:36012,b:4,c:1,attachment:36096,dataFormat:6402,types:[5126],rb:!0},"depth24plus-stencil8":{gl:35056,b:4,c:2,p:1,attachment:33306,rb:!0,depthTexture:!0,dataFormat:34041,types:[34042]},"depth24unorm-stencil8":{gl:35056,b:4,c:2,p:1,attachment:33306,dataFormat:34041,types:[34042],rb:!0},"depth32float-stencil8":{gl:36013,b:5,c:2,p:1,attachment:33306,dataFormat:34041,types:[36269],rb:!0},"bc1-rgb-unorm-webgl":{gl:33776,x:Fw,f:bw},"bc1-rgb-unorm-srgb-webgl":{gl:35916,x:kw,f:bw},"bc1-rgba-unorm":{gl:33777,x:Fw,f:bw},"bc1-rgba-unorm-srgb":{gl:35916,x:kw,f:bw},"bc2-rgba-unorm":{gl:33778,x:Fw,f:bw},"bc2-rgba-unorm-srgb":{gl:35918,x:kw,f:bw},"bc3-rgba-unorm":{gl:33779,x:Fw,f:bw},"bc3-rgba-unorm-srgb":{gl:35919,x:kw,f:bw},"bc4-r-unorm":{gl:36283,x:Dw,f:bw},"bc4-r-snorm":{gl:36284,x:Dw,f:bw},"bc5-rg-unorm":{gl:36285,x:Dw,f:bw},"bc5-rg-snorm":{gl:36286,x:Dw,f:bw},"bc6h-rgb-ufloat":{gl:36495,x:Ow,f:bw},"bc6h-rgb-float":{gl:36494,x:Ow,f:bw},"bc7-rgba-unorm":{gl:36492,x:Ow,f:bw},"bc7-rgba-unorm-srgb":{gl:36493,x:Ow,f:bw},"etc2-rgb8unorm":{gl:37492,f:Tw},"etc2-rgb8unorm-srgb":{gl:37494,f:Tw},"etc2-rgb8a1unorm":{gl:37496,f:Tw},"etc2-rgb8a1unorm-srgb":{gl:37497,f:Tw},"etc2-rgba8unorm":{gl:37493,f:Tw},"etc2-rgba8unorm-srgb":{gl:37495,f:Tw},"eac-r11unorm":{gl:37488,f:Tw},"eac-r11snorm":{gl:37489,f:Tw},"eac-rg11unorm":{gl:37490,f:Tw},"eac-rg11snorm":{gl:37491,f:Tw},"astc-4x4-unorm":{gl:37808,f:ww},"astc-4x4-unorm-srgb":{gl:37840,f:ww},"astc-5x4-unorm":{gl:37809,f:ww},"astc-5x4-unorm-srgb":{gl:37841,f:ww},"astc-5x5-unorm":{gl:37810,f:ww},"astc-5x5-unorm-srgb":{gl:37842,f:ww},"astc-6x5-unorm":{gl:37811,f:ww},"astc-6x5-unorm-srgb":{gl:37843,f:ww},"astc-6x6-unorm":{gl:37812,f:ww},"astc-6x6-unorm-srgb":{gl:37844,f:ww},"astc-8x5-unorm":{gl:37813,f:ww},"astc-8x5-unorm-srgb":{gl:37845,f:ww},"astc-8x6-unorm":{gl:37814,f:ww},"astc-8x6-unorm-srgb":{gl:37846,f:ww},"astc-8x8-unorm":{gl:37815,f:ww},"astc-8x8-unorm-srgb":{gl:37847,f:ww},"astc-10x5-unorm":{gl:37819,f:ww},"astc-10x5-unorm-srgb":{gl:37851,f:ww},"astc-10x6-unorm":{gl:37817,f:ww},"astc-10x6-unorm-srgb":{gl:37849,f:ww},"astc-10x8-unorm":{gl:37818,f:ww},"astc-10x8-unorm-srgb":{gl:37850,f:ww},"astc-10x10-unorm":{gl:37819,f:ww},"astc-10x10-unorm-srgb":{gl:37851,f:ww},"astc-12x10-unorm":{gl:37820,f:ww},"astc-12x10-unorm-srgb":{gl:37852,f:ww},"astc-12x12-unorm":{gl:37821,f:ww},"astc-12x12-unorm-srgb":{gl:37853,f:ww},"pvrtc-rgb4unorm-webgl":{gl:35840,f:Ew},"pvrtc-rgba4unorm-webgl":{gl:35842,f:Ew},"pvrtc-rbg2unorm-webgl":{gl:35841,f:Ew},"pvrtc-rgba2unorm-webgl":{gl:35843,f:Ew},"etc1-rbg-unorm-webgl":{gl:36196,f:"texture-compression-etc1-webgl"},"atc-rgb-unorm-webgl":{gl:35986,f:Cw},"atc-rgba-unorm-webgl":{gl:35986,f:Cw},"atc-rgbai-unorm-webgl":{gl:34798,f:Cw}},jw={6403:1,36244:1,33319:2,33320:2,6407:3,36248:3,6408:4,36249:4,6402:1,34041:1,6406:1,6409:1,6410:2},Gw={5126:4,5125:4,5124:4,5123:2,5122:2,5131:2,5120:1,5121:1};function Hw(e,t,i){const n=Vw[t];if(!n)return!1;if(void 0===n.gl)return!1;const r=n.x||n.gl2ext;return!r||Boolean(Aw(e,r,i))}function Qw(e){const t=Vw[e],i=t?.gl;if(void 0===i)throw new Error(`Unsupported texture format ${e}`);return i}function $w(e){const t=Vw[e],i=Qw(e),n=rf(e);return{format:i,dataFormat:t?.dataFormat||Ww(n.format,n.integer,n.normalized,i),type:n.dataType?xw(n.dataType):t?.types?.[0]||5121,compressed:n.compressed}}function Zw(e){const t=$w(e);return(jw[t.dataFormat]||4)*(Gw[t.type]||1)}function Ww(e,t,i,n){if(6408===n||6407===n)return n;switch(e){case"r":return t&&!i?36244:6403;case"rg":return t&&!i?33320:33319;case"rgb":return t&&!i?36248:6407;case"rgba":return t&&!i?36249:6408;default:return 6408}}const qw={"depth-clip-control":"EXT_depth_clamp","timer-query-webgl":"EXT_disjoint_timer_query_webgl2","compilation-status-async-webgl":"KHR_parallel_shader_compile","polygon-mode-webgl":"WEBGL_polygon_mode","provoking-vertex-webgl":"WEBGL_provoking_vertex","shader-clip-cull-distance-webgl":"WEBGL_clip_cull_distance","shader-noperspective-interpolation-webgl":"NV_shader_noperspective_interpolation","shader-conservative-depth-webgl":"EXT_conservative_depth"};class Kw extends af{gl;extensions;testedFeatures=new Set;constructor(e,t,i){super([],i),this.gl=e,this.extensions=t,Aw(e,"EXT_color_buffer_float",t)}*[Symbol.iterator](){const e=this.getFeatures();for(const t of e)this.has(t)&&(yield t);return[]}has(e){return!this.disabledFeatures[e]&&(this.testedFeatures.has(e)||(this.testedFeatures.add(e),function(e){return e in Nw}(e)&&function(e,t,i){return(Nw[t]||[]).every(t=>Aw(e,t,i))}(this.gl,e,this.extensions)&&this.features.add(e),this.getWebGLFeature(e)&&this.features.add(e)),this.features.has(e))}initializeFeatures(){const e=this.getFeatures().filter(e=>"polygon-mode-webgl"!==e);for(const t of e)this.has(t)}getFeatures(){return[...Object.keys(qw),...Object.keys(Nw)]}getWebGLFeature(e){const t=qw[e];return"string"==typeof t?Boolean(Aw(this.gl,t,this.extensions)):Boolean(t)}}class Xw extends sf{get maxTextureDimension1D(){return 0}get maxTextureDimension2D(){return this.getParameter(3379)}get maxTextureDimension3D(){return this.getParameter(32883)}get maxTextureArrayLayers(){return this.getParameter(35071)}get maxBindGroups(){return 0}get maxDynamicUniformBuffersPerPipelineLayout(){return 0}get maxDynamicStorageBuffersPerPipelineLayout(){return 0}get maxSampledTexturesPerShaderStage(){return this.getParameter(35660)}get maxSamplersPerShaderStage(){return this.getParameter(35661)}get maxStorageBuffersPerShaderStage(){return 0}get maxStorageTexturesPerShaderStage(){return 0}get maxUniformBuffersPerShaderStage(){return this.getParameter(35375)}get maxUniformBufferBindingSize(){return this.getParameter(35376)}get maxStorageBufferBindingSize(){return 0}get minUniformBufferOffsetAlignment(){return this.getParameter(35380)}get minStorageBufferOffsetAlignment(){return 0}get maxVertexBuffers(){return 16}get maxVertexAttributes(){return this.getParameter(34921)}get maxVertexBufferArrayStride(){return 2048}get maxInterStageShaderComponents(){return this.getParameter(35659)}get maxComputeWorkgroupStorageSize(){return 0}get maxComputeInvocationsPerWorkgroup(){return 0}get maxComputeWorkgroupSizeX(){return 0}get maxComputeWorkgroupSizeY(){return 0}get maxComputeWorkgroupSizeZ(){return 0}get maxComputeWorkgroupsPerDimension(){return 0}gl;limits={};constructor(e){super(),this.gl=e}getParameter(e){return void 0===this.limits[e]&&(this.limits[e]=this.gl.getParameter(e)),this.limits[e]}}function Jw(e,t,i){if(function(e){for(const t in e)return!1;return!0}(t))return i(e);const{nocatch:n=!0}=t;let r;if(pw(e),aw(e,t),n)r=i(e),fw(e);else try{r=i(e)}finally{fw(e)}return r}function Yw(e,t,i,n){if(qp(t))return n(e);const r=e;pw(r.gl);try{return function(e,t){const i=e,{gl:n}=i;if(t.cullMode)switch(t.cullMode){case"none":n.disable(2884);break;case"front":n.enable(2884),n.cullFace(1028);break;case"back":n.enable(2884),n.cullFace(1029)}t.frontFace&&n.frontFace(rT("frontFace",t.frontFace,{ccw:2305,cw:2304}));t.unclippedDepth&&e.features.has("depth-clip-control")&&n.enable(34383);void 0!==t.depthBias&&(n.enable(32823),n.polygonOffset(t.depthBias,t.depthBiasSlopeScale||0));if(t.provokingVertex&&e.features.has("provoking-vertex-webgl")){const e=i.getExtension("WEBGL_provoking_vertex").WEBGL_provoking_vertex,n=rT("provokingVertex",t.provokingVertex,{first:36429,last:36430});e?.provokingVertexWEBGL(n)}if((t.polygonMode||t.polygonOffsetLine)&&e.features.has("polygon-mode-webgl")){if(t.polygonMode){const e=i.getExtension("WEBGL_polygon_mode").WEBGL_polygon_mode,n=rT("polygonMode",t.polygonMode,{fill:6914,line:6913});e?.polygonModeWEBGL(1028,n),e?.polygonModeWEBGL(1029,n)}t.polygonOffsetLine&&n.enable(10754)}e.features.has("shader-clip-cull-distance-webgl")&&(t.clipDistance0&&n.enable(12288),t.clipDistance1&&n.enable(12289),t.clipDistance2&&n.enable(12290),t.clipDistance3&&n.enable(12291),t.clipDistance4&&n.enable(12292),t.clipDistance5&&n.enable(12293),t.clipDistance6&&n.enable(12294),t.clipDistance7&&n.enable(12295));void 0!==t.depthWriteEnabled&&n.depthMask(t.depthWriteEnabled);t.depthCompare&&("always"!==t.depthCompare?n.enable(2929):n.disable(2929),n.depthFunc(eT("depthCompare",t.depthCompare)));if(t.stencilWriteMask){const e=t.stencilWriteMask;n.stencilMaskSeparate(1028,e),n.stencilMaskSeparate(1029,e)}t.stencilReadMask&&Gp.warn("stencilReadMask not supported under WebGL");if(t.stencilCompare){const e=t.stencilReadMask||4294967295,i=eT("depthCompare",t.stencilCompare);"always"!==t.stencilCompare?n.enable(2960):n.disable(2960),n.stencilFuncSeparate(1028,i,0,e),n.stencilFuncSeparate(1029,i,0,e)}if(t.stencilPassOperation&&t.stencilFailOperation&&t.stencilDepthFailOperation){const e=tT("stencilPassOperation",t.stencilPassOperation),i=tT("stencilFailOperation",t.stencilFailOperation),r=tT("stencilDepthFailOperation",t.stencilDepthFailOperation);n.stencilOpSeparate(1028,i,r,e),n.stencilOpSeparate(1029,i,r,e)}if(t.blendColorOperation||t.blendAlphaOperation){n.enable(3042);const e=iT("blendColorOperation",t.blendColorOperation||"add"),i=iT("blendAlphaOperation",t.blendAlphaOperation||"add");n.blendEquationSeparate(e,i);const r=nT("blendColorSrcFactor",t.blendColorSrcFactor||"one"),o=nT("blendColorDstFactor",t.blendColorDstFactor||"zero"),s=nT("blendAlphaSrcFactor",t.blendAlphaSrcFactor||"one"),a=nT("blendAlphaDstFactor",t.blendAlphaDstFactor||"zero");n.blendFuncSeparate(r,o,s,a)}}(e,t),aw(r.gl,i),n(e)}finally{fw(r.gl)}}function eT(e,t){return rT(e,t,{never:512,less:513,equal:514,"less-equal":515,greater:516,"not-equal":517,"greater-equal":518,always:519})}function tT(e,t){return rT(e,t,{keep:7680,zero:0,replace:7681,invert:5386,"increment-clamp":7682,"decrement-clamp":7683,"increment-wrap":34055,"decrement-wrap":34056})}function iT(e,t){return rT(e,t,{add:32774,subtract:32778,"reverse-subtract":32779,min:32775,max:32776})}function nT(e,t){return rT(e,t,{one:1,zero:0,"src-color":768,"one-minus-src-color":769,"dst-color":774,"one-minus-dst-color":775,"src-alpha":770,"one-minus-src-alpha":771,"dst-alpha":772,"one-minus-dst-alpha":773,"src-alpha-saturated":776,"constant-color":32769,"one-minus-constant-color":32770,"constant-alpha":32771,"one-minus-constant-alpha":32772})}function rT(e,t,i){if(!(t in i))throw new Error(function(e,t){return`Illegal parameter ${t} for ${e}`}(e,t));return i[t]}function oT(e){const t={};return e.addressModeU&&(t[10242]=sT(e.addressModeU)),e.addressModeV&&(t[10243]=sT(e.addressModeV)),e.addressModeW&&(t[32882]=sT(e.addressModeW)),e.magFilter&&(t[10240]=aT(e.magFilter)),(e.minFilter||e.mipmapFilter)&&(t[10241]=function(e,t){if(!t)return aT(e);switch(e){case"nearest":return"nearest"===t?9984:9986;case"linear":return"nearest"===t?9985:9987}}(e.minFilter||"linear",e.mipmapFilter)),void 0!==e.lodMinClamp&&(t[33082]=e.lodMinClamp),void 0!==e.lodMaxClamp&&(t[33083]=e.lodMaxClamp),"comparison-sampler"===e.type&&(t[34892]=34894),e.compare&&(t[34893]=eT("compare",e.compare)),e.maxAnisotropy&&(t[34046]=e.maxAnisotropy),t}function sT(e){switch(e){case"clamp-to-edge":return 33071;case"repeat":return 10497;case"mirror-repeat":return 33648}}function aT(e){switch(e){case"nearest":return 9728;case"linear":return 9729}}class lT extends Xp{device;gl;handle;glTarget;glUsage;glIndexType=5123;byteLength;bytesUsed;constructor(e,t={}){super(e,t),this.device=e,this.gl=this.device.gl;const i="object"==typeof t?t.handle:void 0;this.handle=i||this.gl.createBuffer(),e.setSpectorMetadata(this.handle,{...this.props,data:typeof this.props.data}),this.glTarget=function(e){if(e&Xp.INDEX)return 34963;if(e&Xp.VERTEX)return 34962;if(e&Xp.UNIFORM)return 35345;return 34962}(this.props.usage),this.glUsage=function(e){if(e&Xp.INDEX)return 35044;if(e&Xp.VERTEX)return 35044;if(e&Xp.UNIFORM)return 35048;return 35044}(this.props.usage),this.glIndexType="uint32"===this.props.indexType?5125:5123,t.data?this._initWithData(t.data,t.byteOffset,t.byteLength):this._initWithByteLength(t.byteLength||0)}_initWithData(e,t=0,i=e.byteLength+t){const n=this.glTarget;this.gl.bindBuffer(n,this.handle),this.gl.bufferData(n,i,this.glUsage),this.gl.bufferSubData(n,t,e),this.gl.bindBuffer(n,null),this.bytesUsed=i,this.byteLength=i,this._setDebugData(e,t,i),this.trackAllocatedMemory(i)}_initWithByteLength(e){cf(e>=0);let t=e;0===e&&(t=new Float32Array(0));const i=this.glTarget;return this.gl.bindBuffer(i,this.handle),this.gl.bufferData(i,t,this.glUsage),this.gl.bindBuffer(i,null),this.bytesUsed=e,this.byteLength=e,this._setDebugData(null,0,e),this.trackAllocatedMemory(e),this}destroy(){!this.destroyed&&this.handle&&(this.removeStats(),this.trackDeallocatedMemory(),this.gl.deleteBuffer(this.handle),this.destroyed=!0,this.handle=null)}write(e,t=0){const i=36663;this.gl.bindBuffer(i,this.handle),this.gl.bufferSubData(i,t,e),this.gl.bindBuffer(i,null),this._setDebugData(e,t,e.byteLength)}async readAsync(e=0,t){return this.readSyncWebGL(e,t)}readSyncWebGL(e=0,t){t=t??this.byteLength-e;const i=new Uint8Array(t);return this.gl.bindBuffer(36662,this.handle),this.gl.getBufferSubData(36662,e,i,0,t),this.gl.bindBuffer(36662,null),this._setDebugData(i,e,t),i}}class cT extends Bf{device;handle;parameters;constructor(e,t){super(e,t),this.device=e,this.parameters=oT(t),this.handle=this.handle||this.device.gl.createSampler(),this._setSamplerParameters(this.parameters)}destroy(){this.handle&&(this.device.gl.deleteSampler(this.handle),this.handle=void 0)}toString(){return`Sampler(${this.id},${JSON.stringify(this.props)})`}_setSamplerParameters(e){for(const[t,i]of Object.entries(e)){const e=Number(t);switch(e){case 33082:case 33083:this.device.gl.samplerParameterf(this.handle,e,i);break;default:this.device.gl.samplerParameteri(this.handle,e,i)}}}}class uT extends vf{device;gl;handle;texture;constructor(e,t){super(e,{...yf.defaultProps,...t}),this.device=e,this.gl=this.device.gl,this.handle=null,this.texture=t.texture}}const hT={parameters:{},pixelStore:{},pixels:null,border:0,dataFormat:void 0,textureUnit:void 0,target:void 0};class dT extends yf{static FACES=[34069,34070,34071,34072,34073,34074];MAX_ATTRIBUTES;device;gl;handle;sampler=void 0;view=void 0;glFormat=void 0;type=void 0;dataFormat=void 0;mipmaps=void 0;target;textureUnit=void 0;loaded=!1;_video;constructor(e,t){super(e,{...hT,format:"rgba8unorm",...t}),this.device=e,this.gl=this.device.gl,this.handle=this.props.handle||this.gl.createTexture(),this.device.setSpectorMetadata(this.handle,{...this.props,data:typeof this.props.data}),this.glFormat=6408,this.target=function(e){switch(e.dimension){case"2d":return 3553;case"cube":return 34067;case"2d-array":return 35866;case"3d":return 32879;default:throw new Error(e.dimension)}}(this.props),this.loaded=!1,"string"==typeof this.props?.data&&Object.assign(this.props,{data:im(this.props.data)}),this.initialize(this.props),Object.seal(this)}destroy(){this.handle&&(this.gl.deleteTexture(this.handle),this.removeStats(),this.trackDeallocatedMemory("Texture"),this.destroyed=!0)}toString(){return`Texture(${this.id},${this.width}x${this.height})`}createView(e){return new uT(this.device,{...e,texture:this})}initialize(e={}){if("cube"===this.props.dimension)return this.initializeCube(e);let t=e.data;if(t instanceof Promise)return t.then(t=>this.initialize(Object.assign({},e,{pixels:t,data:t}))),this;const i="undefined"!=typeof HTMLVideoElement&&t instanceof HTMLVideoElement;if(i&&t.readyStatethis.initialize(e)),this;const{parameters:n={}}=e,{pixels:r=null,pixelStore:o={},textureUnit:s,mipmaps:a=!0}=e;t||(t=r);let{width:l,height:c,dataFormat:u,type:h,compressed:d=!1}=e;const{depth:p=0}=e,f=Qw(e.format);return({width:l,height:c,compressed:d,dataFormat:u,type:h}=this._deduceParameters({format:e.format,type:h,dataFormat:u,compressed:d,data:t,width:l,height:c})),this.width=l,this.height=c,this.glFormat=f,this.type=h,this.dataFormat=u,this.textureUnit=s,Number.isFinite(this.textureUnit)&&(this.gl.activeTexture(33984+this.textureUnit),this.gl.bindTexture(this.target,this.handle)),this.mipmaps=a,this.setImageData({data:t,width:l,height:c,depth:p,format:e.format,type:h,dataFormat:u,parameters:o,compressed:d}),this.setSampler(e.sampler),this._setSamplerParameters(n),this.view=this.createView({...this.props,mipLevelCount:1,arrayLayerCount:1}),a&&this.device.isTextureFormatFilterable(e.format)&&this.generateMipmap(),i&&(this._video={video:t,parameters:n,lastTime:t.readyState>=HTMLVideoElement.HAVE_CURRENT_DATA?t.currentTime:-1}),this}initializeCube(e){const{mipmaps:t=!0,parameters:i={}}=e;return this.setCubeMapImageData(e).then(()=>{this.loaded=!0,t&&this.generateMipmap(e),this.setSampler(e.sampler),this._setSamplerParameters(i)}),this}setSampler(e={}){let t;e instanceof cT?(this.sampler=e,t=e.props):(this.sampler=new cT(this.device,e),t=e);const i=oT(t);return this._setSamplerParameters(i),this}resize(e){const{height:t,width:i,mipmaps:n=!1}=e;return i!==this.width||t!==this.height?this.initialize({width:i,height:t,format:this.format,type:this.type,dataFormat:this.dataFormat,mipmaps:n}):this}update(){if(this._video){const{video:e,parameters:t,lastTime:i}=this._video;if(i===e.currentTime||e.readyState{this.gl.generateMipmap(this.target)}),this.gl.bindTexture(this.target,null),this}setImageData(e){if("3d"===this.props.dimension||"2d-array"===this.props.dimension)return this.setImageData3D(e);this.trackDeallocatedMemory("Texture");const{target:t=this.target,pixels:i=null,level:n=0,glFormat:r=this.glFormat,offset:o=0,parameters:s={}}=e;let{data:a=null,type:l=this.type,width:c=this.width,height:u=this.height,dataFormat:h=this.dataFormat,compressed:d=!1}=e;a||(a=i),({type:l,dataFormat:h,compressed:d,width:c,height:u}=this._deduceParameters({format:this.props.format,type:l,dataFormat:h,compressed:d,data:a,width:c,height:u}));const{gl:p}=this;p.bindTexture(this.target,this.handle);let f=null;if(({data:a,dataType:f}=this._getDataType({data:a,compressed:d})),Jw(this.gl,s,()=>{switch(f){case"null":case"browser-object":p.texImage2D(t,n,r,c,u,0,h,l,a);break;case"typed-array":p.texImage2D(t,n,r,c,u,0,h,l,a,o);break;case"buffer":this.device.gl.bindBuffer(35052,a.handle||a),this.device.gl.texImage2D(t,n,r,c,u,0,h,l,o),this.device.gl.bindBuffer(35052,null);break;case"compressed":for(const[e,i]of a.entries())p.compressedTexImage2D(t,e,i.format,i.width,i.height,0,i.data);break;default:cf(!1,"Unknown image data type")}}),a&&a.byteLength)this.trackAllocatedMemory(a.byteLength,"Texture");else{const e=Zw(this.props.format);this.trackAllocatedMemory(this.width*this.height*e,"Texture")}return this.loaded=!0,this}setSubImageData({target:e=this.target,pixels:t=null,data:i=null,x:n=0,y:r=0,width:o=this.width,height:s=this.height,level:a=0,glFormat:l=this.glFormat,type:c=this.type,dataFormat:u=this.dataFormat,compressed:h=!1,offset:d=0,parameters:p={}}){if(({type:c,dataFormat:u,compressed:h,width:o,height:s}=this._deduceParameters({format:this.props.format,type:c,dataFormat:u,compressed:h,data:i,width:o,height:s})),cf(1===this.depth,"texSubImage not supported for 3D textures"),i||(i=t),i&&i.data){const e=i;i=e.data,o=e.shape[0],s=e.shape[1]}i instanceof lT&&(i=i.handle),this.gl.bindTexture(this.target,this.handle),Jw(this.gl,p,()=>{h?this.gl.compressedTexSubImage2D(e,a,n,r,o,s,l,i):null===i?this.gl.texSubImage2D(e,a,n,r,o,s,u,c,null):ArrayBuffer.isView(i)?this.gl.texSubImage2D(e,a,n,r,o,s,u,c,i,d):"undefined"!=typeof WebGLBuffer&&i instanceof WebGLBuffer?(this.device.gl.bindBuffer(35052,i),this.device.gl.texSubImage2D(e,a,n,r,o,s,u,c,d),this.device.gl.bindBuffer(35052,null)):this.device.gl.texSubImage2D(e,a,n,r,o,s,u,c,i)}),this.gl.bindTexture(this.target,null)}copyFramebuffer(e={}){return Gp.error("Texture.copyFramebuffer({...}) is no logner supported, use copyToTexture(source, target, opts})")(),null}getActiveUnit(){return this.gl.getParameter(34016)-33984}bind(e=this.textureUnit){const{gl:t}=this;return void 0!==e&&(this.textureUnit=e,t.activeTexture(33984+e)),t.bindTexture(this.target,this.handle),e}unbind(e=this.textureUnit){const{gl:t}=this;return void 0!==e&&(this.textureUnit=e,t.activeTexture(33984+e)),t.bindTexture(this.target,null),e}_getDataType({data:e,compressed:t=!1}){return t?{data:e,dataType:"compressed"}:null===e?{data:e,dataType:"null"}:ArrayBuffer.isView(e)?{data:e,dataType:"typed-array"}:e instanceof lT?{data:e.handle,dataType:"buffer"}:"undefined"!=typeof WebGLBuffer&&e instanceof WebGLBuffer?{data:e,dataType:"buffer"}:{data:e,dataType:"browser-object"}}_deduceParameters(e){const{format:t,data:i}=e;let{width:n,height:r,dataFormat:o,type:s,compressed:a}=e;const l=$w(t);return o=o||l.dataFormat,s=s||l.type,a=a||l.compressed,({width:n,height:r}=this._deduceImageSize(i,n,r)),{dataFormat:o,type:s,compressed:a,width:n,height:r,format:t,data:i}}_deduceImageSize(e,t,i){let n;return n="undefined"!=typeof ImageData&&e instanceof ImageData?{width:e.width,height:e.height}:"undefined"!=typeof HTMLImageElement&&e instanceof HTMLImageElement?{width:e.naturalWidth,height:e.naturalHeight}:"undefined"!=typeof HTMLCanvasElement&&e instanceof HTMLCanvasElement||"undefined"!=typeof ImageBitmap&&e instanceof ImageBitmap?{width:e.width,height:e.height}:"undefined"!=typeof HTMLVideoElement&&e instanceof HTMLVideoElement?{width:e.videoWidth,height:e.videoHeight}:e?{width:t,height:i}:{width:t>=0?t:1,height:i>=0?i:1},cf(n,"Could not deduced texture size"),cf(void 0===t||n.width===t,"Deduced texture width does not match supplied width"),cf(void 0===i||n.height===i,"Deduced texture height does not match supplied height"),n}async setCubeMapImageData(e){const{gl:t}=this,{width:i,height:n,pixels:r,data:o,format:s=6408,type:a=5121}=e,l=r||o,c=await Promise.all(dT.FACES.map(e=>{const t=l[e];return Promise.all(Array.isArray(t)?t:[t])}));this.bind(),dT.FACES.forEach((e,r)=>{c[r].length>1&&!1!==this.props.mipmaps&&Gp.warn(`${this.id} has mipmap and multiple LODs.`)(),c[r].forEach((r,o)=>{i&&n?t.texImage2D(e,o,s,i,n,0,s,a,r):t.texImage2D(e,o,s,s,a,r)})}),this.unbind()}setImageDataForFace(e){const{face:t,width:i,height:n,pixels:r,data:o,format:s=6408,type:a=5121}=e,{gl:l}=this,c=r||o;return this.bind(),c instanceof Promise?c.then(i=>this.setImageDataForFace(Object.assign({},e,{face:t,data:i,pixels:i}))):this.width||this.height?l.texImage2D(t,0,s,i,n,0,s,a,c):l.texImage2D(t,0,s,s,a,c),this}setImageData3D(e){const{level:t=0,dataFormat:i,format:n,type:r,width:o,height:s,depth:a=1,offset:l=0,data:c,parameters:u={}}=e;this.trackDeallocatedMemory("Texture"),this.gl.bindTexture(this.target,this.handle);const h=$w(n);if(Jw(this.gl,u,()=>{ArrayBuffer.isView(c)&&this.gl.texImage3D(this.target,t,h.format,o,s,a,0,h.dataFormat,h.type,c),c instanceof lT&&(this.gl.bindBuffer(35052,c.handle),this.gl.texImage3D(this.target,t,i,o,s,a,0,n,r,l))}),c&&c.byteLength)this.trackAllocatedMemory(c.byteLength,"Texture");else{const e=Zw(this.props.format);this.trackAllocatedMemory(this.width*this.height*this.depth*e,"Texture")}return this.loaded=!0,this}_setSamplerParameters(e){if(!qp(e)){!function(e){Gp.log(1,"texture sampler parameters",e)()}(e),this.gl.bindTexture(this.target,this.handle);for(const[t,i]of Object.entries(e)){const e=Number(t),n=i;switch(e){case 33082:case 33083:this.gl.texParameterf(this.target,e,n);break;default:this.gl.texParameteri(this.target,e,n)}}this.gl.bindTexture(this.target,null)}}}class pT extends If{device;gl;handle;get texture(){return this.colorAttachments[0]}constructor(e,t){super(e,t);const i=null===t.handle;if(this.device=e,this.gl=e.gl,this.handle=this.props.handle||i?this.props.handle:this.gl.createFramebuffer(),!i){e.setSpectorMetadata(this.handle,{id:this.props.id,props:this.props}),this.autoCreateAttachmentTextures();const i=this.gl.bindFramebuffer(36160,this.handle);for(let e=0;evoid 0===e?"undefined":e);let i=globalThis.WebGLDebugUtils.glFunctionArgsToString(e,t);return i=`${i.slice(0,100)}${i.length>100?"...":""}`,`gl.${e}(${i})`}function xT(e,t,i,n){n=Array.from(n).map(e=>void 0===e?"undefined":e);const r=`${globalThis.WebGLDebugUtils.glEnumToString(t)} in gl.${i}(${globalThis.WebGLDebugUtils.glFunctionArgsToString(i,n)})`;if(Gp.error(r)(),e.throwOnError)throw new Error(r)}function bT(e,t,i){let n="";if(Gp.level>=1&&(n=vT(t,i),Gp.log(1,n)()),e.break&&e.break.length>0){n=n||vT(t,i);e.break.every(e=>-1!==n.indexOf(e))}for(const r of i)if(void 0===r){if(n=n||vT(t,i),e.throwOnError)throw new Error(`Undefined argument: ${n}`);Gp.error(`Undefined argument: ${n}`)()}}function wT(e){const t=e.toLowerCase();return["warning","error","info"].includes(t)?t:"info"}class TT extends Cf{device;handle;constructor(e,t){switch(super(e,t),this.device=e,this.props.stage){case"vertex":this.handle=this.props.handle||this.device.gl.createShader(35633);break;case"fragment":this.handle=this.props.handle||this.device.gl.createShader(35632);break;default:throw new Error(this.props.stage)}this._compile(this.source)}destroy(){this.handle&&(this.removeStats(),this.device.gl.deleteShader(this.handle),this.destroyed=!0)}async getCompilationInfo(){return await this._waitForCompilationComplete(),this.getCompilationInfoSync()}getCompilationInfoSync(){return function(e){const t=e.split(/\r?\n/),i=[];for(const e of t){if(e.length<=1)continue;const t=e.split(":");if(2===t.length){const[e,n]=t;i.push({message:n.trim(),type:wT(e),lineNum:0,linePos:0});continue}const[n,r,o,...s]=t;let a=parseInt(o,10);isNaN(a)&&(a=0);let l=parseInt(r,10);isNaN(l)&&(l=0),i.push({message:s.join(":").trim(),type:wT(n),lineNum:a,linePos:l})}return i}(this.device.gl.getShaderInfoLog(this.handle))}getTranslatedSource(){const e=this.device.getExtension("WEBGL_debug_shaders").WEBGL_debug_shaders;return e?.getTranslatedShaderSource(this.handle)}async _compile(e){e=(e=>e.startsWith("#version ")?e:`#version 100\n${e}`)(e);const{gl:t}=this.device;if(t.shaderSource(this.handle,e),t.compileShader(this.handle),0!==Gp.level){if(this.device.features.has("compilation-status-async-webgl"))Gp.once(1,"Shader compilation is asynchronous")(),await this._waitForCompilationComplete(),Gp.info(2,`Shader ${this.id} - async compilation complete: ${this.compilationStatus}`)(),this._getCompilationStatus(),this.debugShader();else if(this._getCompilationStatus(),this.debugShader(),"error"===this.compilationStatus)throw new Error(`GLSL compilation errors in ${this.props.stage} shader ${this.props.id}`)}else this.compilationStatus="pending"}async _waitForCompilationComplete(){const e=async e=>await new Promise(t=>setTimeout(t,e));if(!this.device.features.has("compilation-status-async-webgl"))return void await e(10);const{gl:t}=this.device;for(;;){if(t.getShaderParameter(this.handle,37297))return;await e(10)}}_getCompilationStatus(){this.compilationStatus=this.device.gl.getShaderParameter(this.handle,35713)?"success":"error"}}const ET=6144,CT=[1,2,4,8];class ST extends Pf{device;glParameters;constructor(e,t){super(e,t),this.device=e,pw(this.device.gl),this.setParameters(this.props.parameters),this.clear()}end(){fw(this.device.gl)}pushDebugGroup(e){}popDebugGroup(){}insertDebugMarker(e){}setParameters(e={}){const t={...this.glParameters};this.props.framebuffer&&(t.framebuffer=this.props.framebuffer),this.props.depthReadOnly&&(t.depthMask=!this.props.depthReadOnly),t.stencilMask=this.props.stencilReadOnly?0:1,t[35977]=this.props.discard,e.viewport&&(e.viewport.length>=6?(t.viewport=e.viewport.slice(0,4),t.depthRange=[e.viewport[4],e.viewport[5]]):t.viewport=e.viewport),e.scissorRect&&(t.scissorTest=!0,t.scissor=e.scissorRect),e.blendConstant&&(t.blendColor=e.blendConstant),e.stencilReference&&(console.warn("RenderPassParameters.stencilReference not yet implemented in WebGL"),e[2967]=e.stencilReference),e.colorMask&&(t.colorMask=CT.map(t=>Boolean(t&e.colorMask))),this.glParameters=t,aw(this.device.gl,t)}beginOcclusionQuery(e){const t=this.props.occlusionQuerySet;t?.beginOcclusionQuery()}endOcclusionQuery(){const e=this.props.occlusionQuerySet;e?.endOcclusionQuery()}clear(){const e={...this.glParameters};let t=0;!1!==this.props.clearColor&&(t|=16384,e.clearColor=this.props.clearColor),!1!==this.props.clearDepth&&(t|=256,e.clearDepth=this.props.clearDepth),!1!==this.props.clearStencil&&(t|=1024,e.clearStencil=this.props.clearStencil),0!==t&&Jw(this.device.gl,e,()=>{this.device.gl.clear(t)})}clearColorBuffer(e=0,t=[0,0,0,0]){Jw(this.device.gl,{framebuffer:this.props.framebuffer},()=>{switch(t.constructor){case Int32Array:this.device.gl.clearBufferiv(ET,e,t);break;case Uint32Array:this.device.gl.clearBufferuiv(ET,e,t);break;case Float32Array:default:this.device.gl.clearBufferfv(ET,e,t)}})}}function BT(e,t){const{clamped:i=!0}=t||{};switch(e){case 5126:return Float32Array;case 5123:case 33635:case 32819:case 32820:return Uint16Array;case 5125:return Uint32Array;case 5121:return i?Uint8ClampedArray:Uint8Array;case 5120:return Int8Array;case 5122:return Int16Array;case 5124:return Int32Array;default:throw new Error("Failed to deduce typed array type from GL constant")}}const IT={offset:0,stride:0,type:5126,size:1,divisor:0,normalized:!1,integer:!1},MT={deprecatedProps:{instanced:"divisor",isInstanced:"divisor"}};class PT{offset;stride;type;size;divisor;normalized;integer;buffer;index;static getBytesPerElement(e){return BT(e.type||5126).BYTES_PER_ELEMENT}static getBytesPerVertex(e){cf(e.size);return BT(e.type||5126).BYTES_PER_ELEMENT*e.size}static resolve(...e){return new PT(...[IT,...e])}constructor(...e){e.forEach(e=>this._assign(e)),Object.freeze(this)}toString(){return JSON.stringify(this)}get BYTES_PER_ELEMENT(){return PT.getBytesPerElement(this)}get BYTES_PER_VERTEX(){return PT.getBytesPerVertex(this)}_assign(e={}){return void 0!==(e=function(e,t,i){const{removedProps:n={},deprecatedProps:r={},replacedProps:o={}}=i;for(const i in n)if(i in t){const t=n[i]?`${e}.${n[i]}`:"N/A";Gp.removed(`${e}.${i}`,t)()}for(const i in r)if(i in t){const t=r[i];Gp.deprecated(`${e}.${i}`,`${e}.${t}`)()}let s=null;for(const[i,n]of Object.entries(o))i in t&&(Gp.deprecated(`${e}.${i}`,`${e}.${n}`)(),s=s||Object.assign({},t),s[n]=t[i],delete s[i]);return s||t}("Accessor",e,MT)).type&&(this.type=e.type,5124!==e.type&&5125!==e.type||(this.integer=!0)),void 0!==e.size&&(this.size=e.size),void 0!==e.offset&&(this.offset=e.offset),void 0!==e.stride&&(this.stride=e.stride),void 0!==e.normalize&&(this.normalized=e.normalize),void 0!==e.normalized&&(this.normalized=e.normalized),void 0!==e.integer&&(this.integer=e.integer),void 0!==e.divisor&&(this.divisor=e.divisor),void 0!==e.buffer&&(this.buffer=e.buffer),void 0!==e.index&&("boolean"==typeof e.index?this.index=e.index?1:0:this.index=e.index),void 0!==e.instanced&&(this.divisor=e.instanced?1:0),void 0!==e.isInstanced&&(this.divisor=e.isInstanced?1:0),void 0===this.offset&&delete this.offset,void 0===this.stride&&delete this.stride,void 0===this.type&&delete this.type,void 0===this.size&&delete this.size,void 0===this.divisor&&delete this.divisor,void 0===this.normalized&&delete this.normalized,void 0===this.integer&&delete this.integer,void 0===this.buffer&&delete this.buffer,void 0===this.index&&delete this.index,this}}function RT(e){return LT.includes(e)}const LT=[35678,35680,35679,35682,36289,36292,36293,36298,36299,36300,36303,36306,36307,36308,36311],FT={5126:[5126,1,"float","f32","float32"],35664:[5126,2,"vec2","vec2","float32x2"],35665:[5126,3,"vec3","vec3","float32x3"],35666:[5126,4,"vec4","vec4","float32x4"],5124:[5124,1,"int","i32","sint32"],35667:[5124,2,"ivec2","vec2","sint32x2"],35668:[5124,3,"ivec3","vec3","sint32x3"],35669:[5124,4,"ivec4","vec4","sint32x4"],5125:[5125,1,"uint","u32","uint32"],36294:[5125,2,"uvec2","vec2","uint32x2"],36295:[5125,3,"uvec3","vec3","uint32x3"],36296:[5125,4,"uvec4","vec4","uint32x4"],35670:[5126,1,"bool","f32","float32"],35671:[5126,2,"bvec2","vec2","float32x2"],35672:[5126,3,"bvec3","vec3","float32x3"],35673:[5126,4,"bvec4","vec4","float32x4"],35674:[5126,8,"mat2","mat2x2"],35685:[5126,8,"mat2x3","mat2x3"],35686:[5126,8,"mat2x4","mat2x4"],35687:[5126,12,"mat3x2","mat3x2"],35675:[5126,12,"mat3","mat3x3"],35688:[5126,12,"mat3x4","mat3x4"],35689:[5126,16,"mat4x2","mat4x2"],35690:[5126,16,"mat4x3","mat4x3"],35676:[5126,16,"mat4","mat4x4"]};function kT(e){const t=FT[e];if(!t)throw new Error("uniform");const[i,n,,r]=t;return{format:r,components:n,glType:i}}function DT(e){const t=FT[e];if(!t)throw new Error("attribute");const[,i,,n,r]=t;return{attributeType:n,vertexFormat:r,components:i}}function OT(e,t){const i={attributes:[],bindings:[]};i.attributes=function(e,t){const i=[],n=e.getProgramParameter(t,35721);for(let r=0;r=0){const{attributeType:e}=DT(s),t=/instance/i.test(o)?"instance":"vertex";i.push({name:o,location:a,stepMode:t,type:e})}}return i.sort((e,t)=>e.location-t.location),i}(e,t);const n=function(e,t){const i=(i,n)=>e.getActiveUniformBlockParameter(t,i,n),n=[],r=e.getProgramParameter(t,35382);for(let o=0;oe.location-t.location),n}(e,t);for(const e of n){const t=e.uniforms.map(e=>({name:e.name,format:e.format,byteOffset:e.byteOffset,byteStride:e.byteStride,arrayLength:e.arrayLength}));i.bindings.push({type:"uniform",name:e.name,location:e.location,visibility:(e.vertex?1:0)&(e.fragment?2:0),minBindingSize:e.byteLength,uniforms:t})}const r=function(e,t){const i=[],n=e.getProgramParameter(t,35718);for(let r=0;r1)for(let n=0;ne.location-t.location),i}(e,t);return s?.length&&(i.varyings=s),i}const zT={35678:["2d","float"],35680:["cube","float"],35679:["3d","float"],35682:["3d","depth"],36289:["2d-array","float"],36292:["2d-array","depth"],36293:["cube","float"],36298:["2d","sint"],36299:["3d","sint"],36300:["cube","sint"],36303:["2d-array","uint"],36306:["2d","uint"],36307:["3d","uint"],36308:["cube","uint"],36311:["2d-array","uint"]};function UT(e){const t=zT[e];if(!t)throw new Error("sampler");const[i,n]=t;return{viewDimension:i,sampleType:n}}function NT(e){if("]"!==e[e.length-1])return{name:e,length:1,isArray:!1};const t=/([^[]*)(\[[0-9]+\])?/.exec(e);if(!t||t.length<2)throw new Error(`Failed to parse GLSL uniform name ${e}`);return{name:t[1],length:t[2]?1:0,isArray:Boolean(t[2])}}function VT(e,t,i,n){const r=e;let o=n;!0===o&&(o=1),!1===o&&(o=0);const s="number"==typeof o?[o]:o;switch(i){case 35678:case 35680:case 35679:case 35682:case 36289:case 36292:case 36293:case 36298:case 36299:case 36300:case 36303:case 36306:case 36307:case 36308:case 36311:if("number"!=typeof n)throw new Error("samplers must be set to integers");return e.uniform1i(t,n);case 5126:return e.uniform1fv(t,s);case 35664:return e.uniform2fv(t,s);case 35665:return e.uniform3fv(t,s);case 35666:return e.uniform4fv(t,s);case 5124:case 35670:return e.uniform1iv(t,s);case 35667:case 35671:return e.uniform2iv(t,s);case 35668:case 35672:return e.uniform3iv(t,s);case 35669:case 35673:return e.uniform4iv(t,s);case 5125:return r.uniform1uiv(t,s,1);case 36294:return r.uniform2uiv(t,s,2);case 36295:return r.uniform3uiv(t,s,3);case 36296:return r.uniform4uiv(t,s,4);case 35674:return e.uniformMatrix2fv(t,!1,s);case 35675:return e.uniformMatrix3fv(t,!1,s);case 35676:return e.uniformMatrix4fv(t,!1,s);case 35685:return r.uniformMatrix2x3fv(t,!1,s);case 35686:return r.uniformMatrix2x4fv(t,!1,s);case 35687:return r.uniformMatrix3x2fv(t,!1,s);case 35688:return r.uniformMatrix3x4fv(t,!1,s);case 35689:return r.uniformMatrix4x2fv(t,!1,s);case 35690:return r.uniformMatrix4x3fv(t,!1,s)}throw new Error("Illegal uniform")}class jT extends Mf{device;handle;vs;fs;introspectedLayout;uniforms={};bindings={};varyings=null;_uniformCount=0;_uniformSetters={};constructor(e,t){super(e,t),this.device=e,this.handle=this.props.handle||this.device.gl.createProgram(),this.device.setSpectorMetadata(this.handle,{id:this.props.id}),this.vs=t.vs,this.fs=t.fs;const{varyings:i,bufferMode:n=35981}=t;switch(i&&i.length>0&&(this.varyings=i,this.device.gl.transformFeedbackVaryings(this.handle,i,n)),this._linkShaders(),Gp.time(1,`RenderPipeline ${this.id} - shaderLayout introspection`)(),this.introspectedLayout=OT(this.device.gl,this.handle),Gp.timeEnd(1,`RenderPipeline ${this.id} - shaderLayout introspection`)(),this.shaderLayout=function(e,t){const i={...e,attributes:e.attributes.map(e=>({...e}))};for(const e of t?.attributes||[]){const t=i.attributes.find(t=>t.name===e.name);t?(t.type=e.type||t.type,t.stepMode=e.stepMode||t.stepMode):Gp.warn(`shader layout attribute ${e.name} not present in shader`)}return i}(this.introspectedLayout,t.shaderLayout),this.props.topology){case"triangle-fan-webgl":case"line-loop-webgl":Gp.warn(`Primitive topology ${this.props.topology} is deprecated and will be removed in v9.1`)}}destroy(){this.handle&&(this.device.gl.deleteProgram(this.handle),this.destroyed=!0)}setBindings(e,t){for(const[i,n]of Object.entries(e)){const e=this.shaderLayout.bindings.find(e=>e.name===i)||this.shaderLayout.bindings.find(e=>e.name===`${i}Uniforms`);if(!e){const e=this.shaderLayout.bindings.map(e=>`"${e.name}"`).join(", ");t?.disableWarnings||Gp.warn(`Unknown binding "${i}" in render pipeline "${this.id}", expected one of ${e}`)();continue}switch(n||Gp.warn(`Unsetting binding "${i}" in render pipeline "${this.id}"`)(),e.type){case"uniform":if(!(n instanceof lT||n.buffer instanceof lT))throw new Error("buffer value");break;case"texture":if(!(n instanceof uT||n instanceof dT||n instanceof pT))throw new Error("texture value");break;case"sampler":Gp.warn(`Ignoring sampler ${i}`)();break;default:throw new Error(e.type)}this.bindings[i]=n}}draw(e){const{renderPass:t,parameters:i=this.props.parameters,topology:n=this.props.topology,vertexArray:r,vertexCount:o,instanceCount:s,isInstanced:a=!1,firstVertex:l=0,transformFeedback:c}=e,u=function(e){switch(e){case"point-list":return 0;case"line-list":return 1;case"line-strip":return 3;case"line-loop-webgl":return 2;case"triangle-list":return 4;case"triangle-strip":return 5;case"triangle-fan-webgl":return 6;default:throw new Error(e)}}(n),h=Boolean(r.indexBuffer),d=r.indexBuffer?.glIndexType;if("success"!==this.linkStatus)return Gp.info(2,`RenderPipeline:${this.id}.draw() aborted - waiting for shader linking`)(),!1;if(!this._areTexturesRenderable()||0===o)return Gp.info(2,`RenderPipeline:${this.id}.draw() aborted - textures not yet loaded`)(),!1;if(0===o)return Gp.info(2,`RenderPipeline:${this.id}.draw() aborted - no vertices to draw`)(),!0;this.device.gl.useProgram(this.handle),r.bindBeforeRender(t),c&&c.begin(this.props.topology),this._applyBindings(),this._applyUniforms();const p=t;return Yw(this.device,i,p.glParameters,()=>{h&&a?this.device.gl.drawElementsInstanced(u,o||0,d,l,s||0):h?this.device.gl.drawElements(u,o||0,d,l):a?this.device.gl.drawArraysInstanced(u,l,o||0,s||0):this.device.gl.drawArrays(u,l,o||0),c&&c.end()}),r.unbindAfterRender(t),!0}setUniformsWebGL(e){const{bindings:t}=tm(e);Object.keys(t).forEach(e=>{Gp.warn(`Unsupported value "${JSON.stringify(t[e])}" used in setUniforms() for key ${e}. Use setBindings() instead?`)()}),Object.assign(this.uniforms,e)}async _linkShaders(){const{gl:e}=this.device;if(e.attachShader(this.handle,this.vs.handle),e.attachShader(this.handle,this.fs.handle),Gp.time(4,`linkProgram for ${this.id}`)(),e.linkProgram(this.handle),Gp.timeEnd(4,`linkProgram for ${this.id}`)(),Gp.level,!this.device.features.has("compilation-status-async-webgl")){const e=this._getLinkStatus();return void this._reportLinkStatus(e)}Gp.once(1,"RenderPipeline linking is asynchronous")(),await this._waitForLinkComplete(),Gp.info(2,`RenderPipeline ${this.id} - async linking complete: ${this.linkStatus}`)();const t=this._getLinkStatus();this._reportLinkStatus(t)}_reportLinkStatus(e){if("success"!==e){if("error"===this.vs.compilationStatus)throw this.vs.debugShader(),new Error(`Error during compilation of shader ${this.vs.id}`);if("error"===this.fs?.compilationStatus)throw this.fs.debugShader(),new Error(`Error during compilation of shader ${this.fs.id}`);throw new Error(`Error during ${e}: ${this.device.gl.getProgramInfoLog(this.handle)}`)}}_getLinkStatus(){const{gl:e}=this.device;if(!e.getProgramParameter(this.handle,35714))return this.linkStatus="error","linking";e.validateProgram(this.handle);return e.getProgramParameter(this.handle,35715)?(this.linkStatus="success","success"):(this.linkStatus="error","validation")}async _waitForLinkComplete(){const e=async e=>await new Promise(t=>setTimeout(t,e));if(!this.device.features.has("compilation-status-async-webgl"))return void await e(10);const{gl:t}=this.device;for(;;){if(t.getProgramParameter(this.handle,37297))return;await e(10)}}_areTexturesRenderable(){let e=!0;for(const[,t]of Object.entries(this.bindings))t instanceof dT&&(t.update(),e=e&&t.loaded);return e}_applyBindings(){if("success"!==this.linkStatus)return;const{gl:e}=this.device;e.useProgram(this.handle);let t=0,i=0;for(const n of this.shaderLayout.bindings){const r=this.bindings[n.name]||this.bindings[n.name.replace(/Uniforms$/,"")];if(!r)throw new Error(`No value for binding ${n.name} in ${this.id}`);switch(n.type){case"uniform":const{name:o}=n,s=e.getUniformBlockIndex(this.handle,o);if(4294967295===s)throw new Error(`Invalid uniform block name ${o}`);e.uniformBlockBinding(this.handle,i,s),r instanceof lT?e.bindBufferBase(35345,i,r.handle):e.bindBufferRange(35345,i,r.buffer.handle,r.offset||0,r.size||r.buffer.byteLength-r.offset),i+=1;break;case"texture":if(!(r instanceof uT||r instanceof dT||r instanceof pT))throw new Error("texture");let a;if(r instanceof uT)a=r.texture;else if(r instanceof dT)a=r;else{if(!(r instanceof pT&&r.colorAttachments[0]instanceof uT))throw new Error("No texture");Gp.warn("Passing framebuffer in texture binding may be deprecated. Use fbo.colorAttachments[0] instead")(),a=r.colorAttachments[0].texture}e.activeTexture(33984+t),e.bindTexture(a.target,a.handle),t+=1;break;case"sampler":break;case"storage":case"read-only-storage":throw new Error(`binding type '${n.type}' not supported in WebGL`)}}}_applyUniforms(){for(const e of this.shaderLayout.uniforms||[]){const{name:t,location:i,type:n,textureUnit:r}=e,o=this.uniforms[t]??r;void 0!==o&&VT(this.device.gl,i,n,o)}}}class GT extends Ff{device;commands=[];constructor(e){super(e,{}),this.device=e}submitCommands(e=this.commands){for(const t of e)switch(t.name){case"copy-buffer-to-buffer":HT(this.device,t.options);break;case"copy-buffer-to-texture":QT(this.device,t.options);break;case"copy-texture-to-buffer":$T(this.device,t.options);break;case"copy-texture-to-texture":ZT(this.device,t.options)}}}function HT(e,t){const i=t.source,n=t.destination;e.gl.bindBuffer(36662,i.handle),e.gl.bindBuffer(36663,n.handle),e.gl.copyBufferSubData(36662,36663,t.sourceOffset??0,t.destinationOffset??0,t.size),e.gl.bindBuffer(36662,null),e.gl.bindBuffer(36663,null)}function QT(e,t){throw new Error("Not implemented")}function $T(e,t){const{source:i,mipLevel:n=0,aspect:r="all",width:o=t.source.width,height:s=t.source.height,depthOrArrayLayers:a=0,origin:l=[0,0],destination:c,byteOffset:u=0,bytesPerRow:h,rowsPerImage:d}=t;if("all"!==r)throw new Error("not supported");if(0!==n||0!==a||h||d)throw new Error("not implemented");const{framebuffer:p,destroyFramebuffer:f}=WT(i);let m;try{const t=c,i=o||p.width,n=s||p.height,r=$w(p.texture.props.format),a=r.dataFormat,h=r.type;e.gl.bindBuffer(35051,t.handle),m=e.gl.bindFramebuffer(36160,p.handle),e.gl.readPixels(l[0],l[1],i,n,a,h,u)}finally{e.gl.bindBuffer(35051,null),void 0!==m&&e.gl.bindFramebuffer(36160,m),f&&p.destroy()}}function ZT(e,t){const{source:i,destinationMipLevel:n=0,origin:r=[0,0],destinationOrigin:o=[0,0],destination:s}=t;let{width:a=t.destination.width,height:l=t.destination.height}=t;const{framebuffer:c,destroyFramebuffer:u}=WT(i),[h,d]=r,[p,f,m]=o,g=e.gl.bindFramebuffer(36160,c.handle);let _,A=null;if(!(s instanceof dT))throw new Error("invalid destination");switch(A=s,a=Number.isFinite(a)?a:A.width,l=Number.isFinite(l)?l:A.height,A.bind(0),_=A.target,_){case 3553:case 34067:e.gl.copyTexSubImage2D(_,n,p,f,h,d,a,l);break;case 35866:case 32879:e.gl.copyTexSubImage3D(_,n,p,f,m,h,d,a,l)}A&&A.unbind(),e.gl.bindFramebuffer(36160,g),u&&c.destroy()}function WT(e){if(e instanceof yf){const{width:t,height:i,id:n}=e;return{framebuffer:e.device.createFramebuffer({id:`framebuffer-for-${n}`,width:t,height:i,colorAttachments:[e]}),destroyFramebuffer:!0}}return{framebuffer:e,destroyFramebuffer:!1}}class qT extends Lf{device;commandBuffer;constructor(e,t){super(e,t),this.device=e,this.commandBuffer=new GT(e)}destroy(){}finish(){this.commandBuffer.submitCommands()}copyBufferToBuffer(e){this.commandBuffer.commands.push({name:"copy-buffer-to-buffer",options:e})}copyBufferToTexture(e){this.commandBuffer.commands.push({name:"copy-buffer-to-texture",options:e})}copyTextureToBuffer(e){this.commandBuffer.commands.push({name:"copy-texture-to-buffer",options:e})}copyTextureToTexture(e){this.commandBuffer.commands.push({name:"copy-texture-to-texture",options:e})}pushDebugGroup(e){}popDebugGroup(){}insertDebugMarker(e){}resolveQuerySet(e,t,i){}}class KT extends Vf{get[Symbol.toStringTag](){return"VertexArray"}device;handle;buffer=null;bufferValue=null;static isConstantAttributeZeroSupported(e){return"Chrome"==(t||Pu()?Mu(t)?"Electron":(t||Iu.userAgent||"").indexOf("Edge")>-1?"Edge":globalThis.chrome?"Chrome":globalThis.safari?"Safari":globalThis.mozInnerScreenX?"Firefox":"Unknown":"Node");var t}constructor(e,t){super(e,t),this.device=e,this.handle=this.device.gl.createVertexArray()}destroy(){super.destroy(),this.buffer&&this.buffer?.destroy(),this.handle&&(this.device.gl.deleteVertexArray(this.handle),this.handle=void 0)}setIndexBuffer(e){const t=e;if(t&&34963!==t.glTarget)throw new Error("Use .setBuffer()");this.device.gl.bindVertexArray(this.handle),this.device.gl.bindBuffer(34963,t?t.handle:null),this.indexBuffer=t,this.device.gl.bindVertexArray(null)}setBuffer(e,t){const i=t;if(34963===i.glTarget)throw new Error("Use .setIndexBuffer()");const{size:n,type:r,stride:o,offset:s,normalized:a,integer:l,divisor:c}=this._getAccessor(e);this.device.gl.bindVertexArray(this.handle),this.device.gl.bindBuffer(34962,i.handle),l?this.device.gl.vertexAttribIPointer(e,n,r,o,s):this.device.gl.vertexAttribPointer(e,n,r,a,o,s),this.device.gl.bindBuffer(34962,null),this.device.gl.enableVertexAttribArray(e),this.device.gl.vertexAttribDivisor(e,c||0),this.attributes[e]=i,this.device.gl.bindVertexArray(null)}setConstantWebGL(e,t){this._enable(e,!1),this.attributes[e]=t}bindBeforeRender(){this.device.gl.bindVertexArray(this.handle),this._applyConstantAttributes()}unbindAfterRender(){this.device.gl.bindVertexArray(null)}_applyConstantAttributes(){for(let e=0;e{for(const t in e)this.setBuffer(t,e[t])})}setBuffer(e,t){const i=this._getVaryingIndex(e),{buffer:n,byteLength:r,byteOffset:o}=this._getBufferRange(t);if(i<0)return this.unusedBuffers[e]=n,void Gp.warn(`${this.id} unusedBuffers varying buffer ${e}`)();this.buffers[i]={buffer:n,byteLength:r,byteOffset:o},this.bindOnUse||this._bindBuffer(i,n,o,r)}getBuffer(e){if(JT(e))return this.buffers[e]||null;const t=this._getVaryingIndex(e);return t>=0?this.buffers[t]:null}bind(e=this.handle){if("function"!=typeof e)return this.gl.bindTransformFeedback(36386,e),this;let t;return this._bound?t=e():(this.gl.bindTransformFeedback(36386,this.handle),this._bound=!0,t=e(),this._bound=!1,this.gl.bindTransformFeedback(36386,null)),t}unbind(){this.bind(null)}_getBufferRange(e){if(e instanceof lT)return{buffer:e,byteOffset:0,byteLength:e.byteLength};const{buffer:t,byteOffset:i=0,byteLength:n=e.buffer.byteLength}=e;return{buffer:t,byteOffset:i,byteLength:n}}_getVaryingIndex(e){if(JT(e))return Number(e);for(const t of this.layout.varyings)if(e===t.name)return t.location;return-1}_bindBuffers(){for(const e in this.buffers){const{buffer:t,byteLength:i,byteOffset:n}=this._getBufferRange(this.buffers[e]);this._bindBuffer(Number(e),t,n,i)}}_unbindBuffers(){for(const e in this.buffers)this.gl.bindBufferBase(35982,Number(e),null)}_bindBuffer(e,t,i=0,n){const r=t&&t.handle;r&&void 0!==n?this.gl.bindBufferRange(35982,e,r,i,n):this.gl.bindBufferBase(35982,e,r)}}function JT(e){return"number"==typeof e?Number.isInteger(e):/^\d+$/.test(e)}class YT extends Gf{device;handle;target=null;_queryPending=!1;_pollingPromise=null;get[Symbol.toStringTag](){return"Query"}constructor(e,t){if(super(e,t),this.device=e,t.count>1)throw new Error("WebGL QuerySet can only have one value");this.handle=this.device.gl.createQuery(),Object.seal(this)}destroy(){this.device.gl.deleteQuery(this.handle)}beginTimestampQuery(){return this._begin(35007)}endTimestampQuery(){this._end()}beginOcclusionQuery(e){return this._begin(e?.conservative?36202:35887)}endOcclusionQuery(){this._end()}beginTransformFeedbackQuery(){return this._begin(35976)}endTransformFeedbackQuery(){this._end()}async resolveQuery(){return[await this.pollQuery()]}_begin(e){this._queryPending||(this.target=e,this.device.gl.beginQuery(this.target,this.handle))}_end(){this._queryPending||this.target&&(this.device.gl.endQuery(this.target),this.target=null,this._queryPending=!0)}isResultAvailable(){if(!this._queryPending)return!1;const e=this.device.gl.getQueryParameter(this.handle,34919);return e&&(this._queryPending=!1),e}isTimerDisjoint(){return this.device.gl.getParameter(36795)}getResult(){return this.device.gl.getQueryParameter(this.handle,34918)}getTimerMilliseconds(){return this.getResult()/1e6}pollQuery(e=Number.POSITIVE_INFINITY){if(this._pollingPromise)return this._pollingPromise;let t=0;return this._pollingPromise=new Promise((i,n)=>{const r=()=>{this.isResultAvailable()?(i(this.getResult()),this._pollingPromise=null):t++>e?(n("Timed out"),this._pollingPromise=null):requestAnimationFrame(r)};requestAnimationFrame(r)}),this._pollingPromise}}function eE(e){switch(e){case 6406:case 33326:case 6403:return 1;case 33328:case 33319:return 2;case 6407:case 34837:return 3;case 6408:case 34836:return 4;default:return cf(!1),0}}function tE(e,t){const{sourceX:i=0,sourceY:n=0,sourceFormat:r=6408,sourceAttachment:o=36064}=t||{};let{target:s=null,sourceWidth:a,sourceHeight:l,sourceType:c}=t||{};const{framebuffer:u,deleteFramebuffer:h}=nE(e);cf(u);const{gl:d,handle:p}=u;a=a||u.width,l=l||u.height;const f=o-36064;c=c||u.colorAttachments[f]?.texture?.type||5121,s=function(e,t,i,n,r){if(e)return e;t=t||5121;const o=BT(t,{clamped:!1}),s=eE(i);return new o(n*r*s)}(s,c,r,a,l),c=c||function(e){switch(ArrayBuffer.isView(e)?e.constructor:e){case Float32Array:return 5126;case Uint16Array:return 5123;case Uint32Array:return 5125;case Uint8Array:case Uint8ClampedArray:return 5121;case Int8Array:return 5120;case Int16Array:return 5122;case Int32Array:return 5124;default:throw new Error("Failed to deduce GL constant from typed array")}}(s);const m=d.bindFramebuffer(36160,p);return d.readPixels(i,n,a,l,r,c,s),d.bindFramebuffer(36160,m||null),h&&u.destroy(),s}function iE(e,t){const{target:i,sourceX:n=0,sourceY:r=0,sourceFormat:o=6408,targetByteOffset:s=0}=t||{};let{sourceWidth:a,sourceHeight:l,sourceType:c}=t||{};const{framebuffer:u,deleteFramebuffer:h}=nE(e);cf(u),a=a||u.width,l=l||u.height;const d=u;c=c||5121;let p=i;if(!p){const e=eE(o),t=function(e){switch(e){case 5121:return 1;case 33635:case 32819:case 32820:return 2;case 5126:return 4;default:return cf(!1),0}}(c),i=s+a*l*e*t;p=d.device.createBuffer({byteLength:i})}const f=e.device.createCommandEncoder();return f.copyTextureToBuffer({source:e,width:a,height:l,origin:[n,r],destination:p,byteOffset:s}),f.destroy(),h&&u.destroy(),p}function nE(e){return e instanceof If?{framebuffer:e,deleteFramebuffer:!1}:{framebuffer:rE(e),deleteFramebuffer:!0}}function rE(e,t){const{device:i,width:n,height:r,id:o}=e;return i.createFramebuffer({...t,id:`framebuffer-for-${o}`,width:n,height:r,colorAttachments:[e]})}class oE extends lf{static type="webgl";type="webgl";handle;features;limits;info;canvasContext;lost;_resolveContextLost;static isSupported(){return"undefined"!=typeof WebGL2RenderingContext}static attach(e){if(e instanceof oE)return e;if(e?.device instanceof lf)return e.device;if(!function(e){if("undefined"!=typeof WebGL2RenderingContext&&e instanceof WebGL2RenderingContext)return!0;return Boolean(e&&Number.isFinite(e._version))}(e))throw new Error("Invalid WebGL2RenderingContext");return new oE({gl:e})}static async create(e={}){Gp.groupCollapsed(1,"WebGLDevice created")();const t=[];e.debug&&t.push(async function(){Pu()&&!globalThis.WebGLDebugUtils&&(globalThis.global=globalThis.global||globalThis,globalThis.global.module={},await nm("https://unpkg.com/webgl-debug@2.0.1/index.js"))}()),e.spector&&t.push(async function(){if(!globalThis.SPECTOR)try{await nm("https://cdn.jsdelivr.net/npm/spectorjs@0.9.30/dist/spector.bundle.js")}catch(e){Gp.warn(String(e))}}()),"string"==typeof e.canvas&&t.push(gf.pageLoaded);const i=await Promise.allSettled(t);for(const e of i)"rejected"===e.status&&Gp.error(`Failed to initialize debug libraries ${e.reason}`)();if(Gp.probe(2,"DOM is loaded")(),e.gl?.device)return Gp.warn("reattaching existing device")(),oE.attach(e.gl);const n=new oE(e),r=`Created ${n.type}${n.debug?" debug":""} context: ${n.info.vendor}, ${n.info.renderer} for canvas: ${n.canvasContext.id}`;return Gp.probe(1,r)(),Gp.table(1,n.info)(),Gp.groupEnd(1)(),n}constructor(e){super({...e,id:e.id||Wp("webgl-device")});const t=e.gl?.device;if(t)throw new Error(`WebGL context already attached to device ${t.id}`);const i=e.gl?.canvas||e.canvas,n=!e.gl;this.canvasContext=new fT(this,{...e,autoResize:n,canvas:i}),this.lost=new Promise(e=>{this._resolveContextLost=e});let r=e.gl||null;if(r||=function(e,t){t={..._w,...t};let i=null;const n=e=>i=e.statusMessage||i;e.addEventListener("webglcontextcreationerror",n,!1);let r=null;if(r||=e.getContext("webgl2",t),e.removeEventListener("webglcontextcreationerror",n,!1),!r)throw new Error(`Failed to create WebGL context: ${i||"Unknown error"}`);if(t.onContextLost){const{onContextLost:i}=t;e.addEventListener("webglcontextlost",e=>i(e),!1)}if(t.onContextRestored){const{onContextRestored:i}=t;e.addEventListener("webglcontextrestored",e=>i(e),!1)}return r}(this.canvasContext.canvas,{...e,onContextLost:e=>this._resolveContextLost?.({reason:"destroyed",message:"Entered sleep mode, or too many apps or browser tabs are using the GPU."})}),!r)throw new Error("WebGL context creation failed");this.handle=r,this.gl=r,this.gl.device=this,this.gl._version=2,e.spector&&(this.spectorJS=function(e){if(e={...mT,...e},!e?.spector)return null;if(!gT&&globalThis.SPECTOR&&(Gp.probe(1,"SPECTOR found and initialized")(),gT=new globalThis.SPECTOR.Spector,globalThis.luma&&(globalThis.luma.spector=gT)),!gT)return null;if(_T||(_T=!0,gT.spyCanvases(),gT?.onCaptureStarted.add(e=>Gp.info("Spector capture started:",e)()),gT?.onCapture.add(e=>{Gp.info("Spector capture complete:",e)(),gT?.getResultUI(),gT?.resultView.display(),gT?.resultView.addCapture(e)})),e?.canvas){if("string"==typeof e.spector&&e.spector!==e.canvas.id)return gT;gT?.startCapture(e?.canvas,500),new Promise(e=>setTimeout(e,2e3)).then(e=>{Gp.info("Spector capture stopped after 2 seconds")(),gT?.stopCapture()})}return gT}({...this.props,canvas:this.handle.canvas})),this.info=yw(this.gl,this._extensions),this.limits=new Xw(this.gl),this.features=new Kw(this.gl,this._extensions,this.props.disabledFeatures),this.props.initalizeFeatures&&this.features.initializeFeatures(),n&&this.canvasContext.resize();const{enable:o=!0,copyState:s=!1}=e;dw(this.gl,{enable:o,copyState:s,log:(...e)=>Gp.log(1,...e)()}),e.debug&&(this.gl=yT(this.gl,{...e,throwOnError:!0}),this.debug=!0,Gp.level=Math.max(Gp.level,1),Gp.warn("WebGL debug mode activated. Performance reduced.")())}destroy(){}get isLost(){return this.gl.isContextLost()}getSize(){return[this.gl.drawingBufferWidth,this.gl.drawingBufferHeight]}isTextureFormatSupported(e){return Hw(this.gl,e,this._extensions)}isTextureFormatFilterable(e){return function(e,t,i){if(!Hw(e,t,i))return!1;if(t.startsWith("depth")||t.startsWith("stencil"))return!1;try{if(rf(t).signed)return!1}catch{return!1}return t.endsWith("32float")?Boolean(Aw(e,"OES_texture_float_linear, extensions",i)):!t.endsWith("16float")||Boolean(Aw(e,"OES_texture_half_float_linear, extensions",i))}(this.gl,e,this._extensions)}isTextureFormatRenderable(e){return function(e,t,i){return!!Hw(e,t,i)&&"number"!=typeof t}(this.gl,e,this._extensions)}createCanvasContext(e){throw new Error("WebGL only supports a single canvas")}createBuffer(e){const t=this._getBufferProps(e);return new lT(this,t)}_createTexture(e){return new dT(this,e)}createExternalTexture(e){throw new Error("createExternalTexture() not implemented")}createSampler(e){return new cT(this,e)}createShader(e){return new TT(this,e)}createFramebuffer(e){return new pT(this,e)}createVertexArray(e){return new KT(this,e)}createTransformFeedback(e){return new XT(this,e)}createQuerySet(e){return new YT(this,e)}createRenderPipeline(e){return new jT(this,e)}beginRenderPass(e){return new ST(this,e)}createComputePipeline(e){throw new Error("ComputePipeline not supported in WebGL")}beginComputePass(e){throw new Error("ComputePass not supported in WebGL")}renderPass=null;createCommandEncoder(e){return new qT(this,e)}submit(){this.renderPass?.end(),this.renderPass=null}readPixelsToArrayWebGL(e,t){return tE(e,t)}readPixelsToBufferWebGL(e,t){return iE(e,t)}setParametersWebGL(e){aw(this.gl,e)}getParametersWebGL(e){return lw(this.gl,e)}withParametersWebGL(e,t){return Jw(this.gl,e,t)}clearWebGL(e){!function(e,t){const{framebuffer:i=null,color:n=null,depth:r=null,stencil:o=null}=t||{},s={};i&&(s.framebuffer=i);let a=0;n&&(a|=16384,!0!==n&&(s.clearColor=n)),r&&(a|=256,!0!==r&&(s.clearDepth=r)),o&&(a|=1024,!0!==r&&(s.clearStencil=r)),cf(0!==a,"clear: bad arguments");const l=e.gl;Jw(l,s,()=>{l.clear(a)})}(this,e)}resetWebGL(){Gp.warn("WebGLDevice.resetWebGL is deprecated, use only for debugging")(),function(e){aw(e,Zb)}(this.gl)}gl;debug=!1;_canvasSizeInfo={clientWidth:0,clientHeight:0,devicePixelRatio:1};_extensions={};_polyfilled=!1;spectorJS;loseDevice(){let e=!1;const t=this.getExtension("WEBGL_lose_context").WEBGL_lose_context;return t&&(e=!0,t.loseContext()),this._resolveContextLost?.({reason:"destroyed",message:"Application triggered context loss"}),e}pushState(){pw(this.gl)}popState(){fw(this.gl)}setSpectorMetadata(e,t){e.__SPECTOR_Metadata=t}getGLKey(e,t){t=t||this.gl2||this.gl;const i=Number(e);for(const e in t)if(t[e]===i)return`GL.${e}`;return String(e)}_constants;setConstantAttributeWebGL(e,t){const i=this.limits.maxVertexAttributes;this._constants=this._constants||new Array(i).fill(null);const n=this._constants[e];switch(n&&function(e,t){if(!e||!t||e.length!==t.length||e.constructor!==t.constructor)return!1;for(let i=0;i\s*\(/gm,"{anonymous}()@"):"Unknown Stack Trace",o=e.console&&(e.console.warn||e.console.log);return o&&o.call(e.console,n,r),t.apply(this,arguments)}}n="function"!=typeof Object.assign?function(e){if(e===r||null===e)throw new TypeError("Cannot convert undefined or null to object");for(var t=Object(e),i=1;i-1}function T(e){return e.trim().split(/\s+/g)}function E(e,t,i){if(e.indexOf&&!i)return e.indexOf(t);for(var r=0;ri[t]}):r.sort()),r}function S(e,t){for(var i,n,s=t[0].toUpperCase()+t.slice(1),a=0;a1&&!i.firstMultiple?i.firstMultiple=V(t):1===o&&(i.firstMultiple=!1);var s=i.firstInput,a=i.firstMultiple,u=a?a.center:s.center,h=t.center=j(n);t.timeStamp=c(),t.deltaTime=t.timeStamp-s.timeStamp,t.angle=$(u,h),t.distance=Q(u,h),function(e,t){var i=t.center,r=e.offsetDelta||{},n=e.prevDelta||{},o=e.prevInput||{};1!==t.eventType&&4!==o.eventType||(n=e.prevDelta={x:o.deltaX||0,y:o.deltaY||0},r=e.offsetDelta={x:i.x,y:i.y}),t.deltaX=n.x+(i.x-r.x),t.deltaY=n.y+(i.y-r.y)}(i,t),t.offsetDirection=H(t.deltaX,t.deltaY);var d,p,f=G(t.deltaTime,t.deltaX,t.deltaY);t.overallVelocityX=f.x,t.overallVelocityY=f.y,t.overallVelocity=l(f.x)>l(f.y)?f.x:f.y,t.scale=a?(d=a.pointers,Q((p=n)[0],p[1],z)/Q(d[0],d[1],z)):1,t.rotation=a?function(e,t){return $(t[1],t[0],z)+$(e[1],e[0],z)}(a.pointers,n):0,t.maxPointers=i.prevInput?t.pointers.length>i.prevInput.maxPointers?t.pointers.length:i.prevInput.maxPointers:t.pointers.length,function(e,t){var i,n,o,s,a=e.lastInterval||t,c=t.timeStamp-a.timeStamp;if(8!=t.eventType&&(c>25||a.velocity===r)){var u=t.deltaX-a.deltaX,h=t.deltaY-a.deltaY,d=G(c,u,h);n=d.x,o=d.y,i=l(d.x)>l(d.y)?d.x:d.y,s=H(u,h),e.lastInterval=t}else i=a.velocity,n=a.velocityX,o=a.velocityY,s=a.direction;t.velocity=i,t.velocityX=n,t.velocityY=o,t.direction=s}(i,t);var m=e.element;b(t.srcEvent.target,m)&&(m=t.srcEvent.target),t.target=m}(e,i),e.emit("hammer.input",i),e.recognize(i),e.session.prevInput=i}function V(e){for(var t=[],i=0;i=l(t)?e<0?2:4:t<0?8:16}function Q(e,t,i){i||(i=O);var r=t[i[0]]-e[i[0]],n=t[i[1]]-e[i[1]];return Math.sqrt(r*r+n*n)}function $(e,t,i){i||(i=O);var r=t[i[0]]-e[i[0]],n=t[i[1]]-e[i[1]];return 180*Math.atan2(n,r)/Math.PI}U.prototype={handler:function(){},init:function(){this.evEl&&v(this.element,this.evEl,this.domHandler),this.evTarget&&v(this.target,this.evTarget,this.domHandler),this.evWin&&v(M(this.element),this.evWin,this.domHandler)},destroy:function(){this.evEl&&x(this.element,this.evEl,this.domHandler),this.evTarget&&x(this.target,this.evTarget,this.domHandler),this.evWin&&x(M(this.element),this.evWin,this.domHandler)}};var Z={mousedown:1,mousemove:2,mouseup:4},W="mousedown",q="mousemove mouseup";function K(){this.evEl=W,this.evWin=q,this.pressed=!1,U.apply(this,arguments)}g(K,U,{handler:function(e){var t=Z[e.type];1&t&&0===e.button&&(this.pressed=!0),2&t&&1!==e.which&&(t=4),this.pressed&&(4&t&&(this.pressed=!1),this.callback(this.manager,t,{pointers:[e],changedPointers:[e],pointerType:k,srcEvent:e}))}});var X={pointerdown:1,pointermove:2,pointerup:4,pointercancel:8,pointerout:8},J={2:F,3:"pen",4:k,5:"kinect"},Y="pointerdown",ee="pointermove pointerup pointercancel";function te(){this.evEl=Y,this.evWin=ee,U.apply(this,arguments),this.store=this.manager.session.pointerEvents=[]}e.MSPointerEvent&&!e.PointerEvent&&(Y="MSPointerDown",ee="MSPointerMove MSPointerUp MSPointerCancel"),g(te,U,{handler:function(e){var t=this.store,i=!1,r=e.type.toLowerCase().replace("ms",""),n=X[r],o=J[e.pointerType]||e.pointerType,s=o==F,a=E(t,e.pointerId,"pointerId");1&n&&(0===e.button||s)?a<0&&(t.push(e),a=t.length-1):12&n&&(i=!0),a<0||(t[a]=e,this.callback(this.manager,n,{pointers:t,changedPointers:[e],pointerType:o,srcEvent:e}),i&&t.splice(a,1))}});var ie={touchstart:1,touchmove:2,touchend:4,touchcancel:8};function re(){this.evTarget="touchstart",this.evWin="touchstart touchmove touchend touchcancel",this.started=!1,U.apply(this,arguments)}function ne(e,t){var i=C(e.touches),r=C(e.changedTouches);return 12&t&&(i=B(i.concat(r),"identifier",!0)),[i,r]}g(re,U,{handler:function(e){var t=ie[e.type];if(1===t&&(this.started=!0),this.started){var i=ne.call(this,e,t);12&t&&i[0].length-i[1].length===0&&(this.started=!1),this.callback(this.manager,t,{pointers:i[0],changedPointers:i[1],pointerType:F,srcEvent:e})}}});var oe={touchstart:1,touchmove:2,touchend:4,touchcancel:8},se="touchstart touchmove touchend touchcancel";function ae(){this.evTarget=se,this.targetIds={},U.apply(this,arguments)}function le(e,t){var i=C(e.touches),r=this.targetIds;if(3&t&&1===i.length)return r[i[0].identifier]=!0,[i,i];var n,o,s=C(e.changedTouches),a=[],l=this.target;if(o=i.filter(function(e){return b(e.target,l)}),1===t)for(n=0;n-1&&r.splice(e,1)},2500)}}function de(e){for(var t=e.srcEvent.clientX,i=e.srcEvent.clientY,r=0;r-1&&this.requireFail.splice(t,1),this},hasRequireFailures:function(){return this.requireFail.length>0},canRecognizeWith:function(e){return!!this.simultaneous[e.id]},emit:function(e){var t=this,i=this.state;function r(i){t.manager.emit(i,e)}i<8&&r(t.options.event+Ee(i)),r(t.options.event),e.additionalEvent&&r(e.additionalEvent),i>=8&&r(t.options.event+Ee(i))},tryEmit:function(e){if(this.canEmit())return this.emit(e);this.state=we},canEmit:function(){for(var e=0;et.threshold&&n&t.direction},attrTest:function(e){return Se.prototype.attrTest.call(this,e)&&(2&this.state||!(2&this.state)&&this.directionTest(e))},emit:function(e){this.pX=e.deltaX,this.pY=e.deltaY;var t=Ce(e.direction);t&&(e.additionalEvent=this.options.event+t),this._super.emit.call(this,e)}}),g(Me,Se,{defaults:{event:"pinch",threshold:0,pointers:2},getTouchAction:function(){return[Ae]},attrTest:function(e){return this._super.attrTest.call(this,e)&&(Math.abs(e.scale-1)>this.options.threshold||2&this.state)},emit:function(e){if(1!==e.scale){var t=e.scale<1?"in":"out";e.additionalEvent=this.options.event+t}this._super.emit.call(this,e)}}),g(Pe,Te,{defaults:{event:"press",pointers:1,time:251,threshold:9},getTouchAction:function(){return[ge]},process:function(e){var t=this.options,i=e.pointers.length===t.pointers,r=e.distancet.time;if(this._input=e,!r||!i||12&e.eventType&&!n)this.reset();else if(1&e.eventType)this.reset(),this._timer=u(function(){this.state=8,this.tryEmit()},t.time,this);else if(4&e.eventType)return 8;return we},reset:function(){clearTimeout(this._timer)},emit:function(e){8===this.state&&(e&&4&e.eventType?this.manager.emit(this.options.event+"up",e):(this._input.timeStamp=c(),this.manager.emit(this.options.event,this._input)))}}),g(Re,Se,{defaults:{event:"rotate",threshold:0,pointers:2},getTouchAction:function(){return[Ae]},attrTest:function(e){return this._super.attrTest.call(this,e)&&(Math.abs(e.rotation)>this.options.threshold||2&this.state)}}),g(Le,Se,{defaults:{event:"swipe",threshold:10,velocity:.3,direction:30,pointers:1},getTouchAction:function(){return Ie.prototype.getTouchAction.call(this)},attrTest:function(e){var t,i=this.options.direction;return 30&i?t=e.overallVelocity:6&i?t=e.overallVelocityX:i&D&&(t=e.overallVelocityY),this._super.attrTest.call(this,e)&&i&e.offsetDirection&&e.distance>this.options.threshold&&e.maxPointers==this.options.pointers&&l(t)>this.options.velocity&&4&e.eventType},emit:function(e){var t=Ce(e.offsetDirection);t&&this.manager.emit(this.options.event+t,e),this.manager.emit(this.options.event,e)}}),g(Fe,Te,{defaults:{event:"tap",pointers:1,taps:1,interval:300,time:250,threshold:9,posThreshold:10},getTouchAction:function(){return[_e]},process:function(e){var t=this.options,i=e.pointers.length===t.pointers,r=e.distance0&&"pointerdown"===e.type&&(function(e,t){for(let i=0;it.pointerId===e.pointerId)||i.push(e)),t.call(this,e)}}(KT.exports.PointerEventInput),KT.exports.MouseInput.prototype.handler=function(e){let t=JT[e.type];1&t&&e.button>=0&&(this.pressed=!0),2&t&&0===e.buttons&&(t=4),this.pressed&&(4&t&&(this.pressed=!1),this.callback(this.manager,t,{pointers:[e],changedPointers:[e],pointerType:"mouse",srcEvent:e}))};const YT=KT.exports.Manager;class eE{constructor(e,t,i){this.element=e,this.callback=t,this.options={enable:!0,...i}}}const tE=XT?[[XT.Pan,{event:"tripan",pointers:3,threshold:0,enable:!1}],[XT.Rotate,{enable:!1}],[XT.Pinch,{enable:!1}],[XT.Swipe,{enable:!1}],[XT.Pan,{threshold:0,enable:!1}],[XT.Press,{enable:!1}],[XT.Tap,{event:"doubletap",taps:2,enable:!1}],[XT.Tap,{event:"anytap",enable:!1}],[XT.Tap,{enable:!1}]]:null,iE={tripan:["rotate","pinch","pan"],rotate:["pinch"],pinch:["pan"],pan:["press","doubletap","anytap","tap"],doubletap:["anytap"],anytap:["tap"]},rE={doubletap:["tap"]},nE={pointerdown:"pointerdown",pointermove:"pointermove",pointerup:"pointerup",touchstart:"pointerdown",touchmove:"pointermove",touchend:"pointerup",mousedown:"pointerdown",mousemove:"pointermove",mouseup:"pointerup"},oE={KEY_EVENTS:["keydown","keyup"],MOUSE_EVENTS:["mousedown","mousemove","mouseup","mouseover","mouseout","mouseleave"],WHEEL_EVENTS:["wheel","mousewheel"]},sE={tap:"tap",anytap:"anytap",doubletap:"doubletap",press:"press",pinch:"pinch",pinchin:"pinch",pinchout:"pinch",pinchstart:"pinch",pinchmove:"pinch",pinchend:"pinch",pinchcancel:"pinch",rotate:"rotate",rotatestart:"rotate",rotatemove:"rotate",rotateend:"rotate",rotatecancel:"rotate",tripan:"tripan",tripanstart:"tripan",tripanmove:"tripan",tripanup:"tripan",tripandown:"tripan",tripanleft:"tripan",tripanright:"tripan",tripanend:"tripan",tripancancel:"tripan",pan:"pan",panstart:"pan",panmove:"pan",panup:"pan",pandown:"pan",panleft:"pan",panright:"pan",panend:"pan",pancancel:"pan",swipe:"swipe",swipeleft:"swipe",swiperight:"swipe",swipeup:"swipe",swipedown:"swipe"},aE={click:"tap",anyclick:"anytap",dblclick:"doubletap",mousedown:"pointerdown",mousemove:"pointermove",mouseup:"pointerup",mouseover:"pointerover",mouseout:"pointerout",mouseleave:"pointerleave"},lE="undefined"!=typeof navigator&&navigator.userAgent?navigator.userAgent.toLowerCase():"",cE="undefined"!=typeof window?window:global;let uE=!1;try{const e={get passive(){return uE=!0,!0}};cE.addEventListener("test",null,e),cE.removeEventListener("test",null)}catch(e){uE=!1}const hE=-1!==lE.indexOf("firefox"),{WHEEL_EVENTS:dE}=oE,pE="wheel",fE=4.000244140625;class mE extends eE{constructor(e,t,i){super(e,t,i),this.handleEvent=e=>{if(!this.options.enable)return;let t=e.deltaY;cE.WheelEvent&&(hE&&e.deltaMode===cE.WheelEvent.DOM_DELTA_PIXEL&&(t/=cE.devicePixelRatio),e.deltaMode===cE.WheelEvent.DOM_DELTA_LINE&&(t*=40)),0!==t&&t%fE===0&&(t=Math.floor(t/fE)),e.shiftKey&&t&&(t*=.25),this.callback({type:pE,center:{x:e.clientX,y:e.clientY},delta:-t,srcEvent:e,pointerType:"mouse",target:e.target})},this.events=(this.options.events||[]).concat(dE),this.events.forEach(t=>e.addEventListener(t,this.handleEvent,!!uE&&{passive:!1}))}destroy(){this.events.forEach(e=>this.element.removeEventListener(e,this.handleEvent))}enableEventType(e,t){e===pE&&(this.options.enable=t)}}const{MOUSE_EVENTS:gE}=oE,_E="pointermove",AE="pointerover",yE="pointerout",vE="pointerenter",xE="pointerleave";class bE extends eE{constructor(e,t,i){super(e,t,i),this.handleEvent=e=>{this.handleOverEvent(e),this.handleOutEvent(e),this.handleEnterEvent(e),this.handleLeaveEvent(e),this.handleMoveEvent(e)},this.pressed=!1;const{enable:r}=this.options;this.enableMoveEvent=r,this.enableLeaveEvent=r,this.enableEnterEvent=r,this.enableOutEvent=r,this.enableOverEvent=r,this.events=(this.options.events||[]).concat(gE),this.events.forEach(t=>e.addEventListener(t,this.handleEvent))}destroy(){this.events.forEach(e=>this.element.removeEventListener(e,this.handleEvent))}enableEventType(e,t){e===_E&&(this.enableMoveEvent=t),e===AE&&(this.enableOverEvent=t),e===yE&&(this.enableOutEvent=t),e===vE&&(this.enableEnterEvent=t),e===xE&&(this.enableLeaveEvent=t)}handleOverEvent(e){this.enableOverEvent&&"mouseover"===e.type&&this._emit(AE,e)}handleOutEvent(e){this.enableOutEvent&&"mouseout"===e.type&&this._emit(yE,e)}handleEnterEvent(e){this.enableEnterEvent&&"mouseenter"===e.type&&this._emit(vE,e)}handleLeaveEvent(e){this.enableLeaveEvent&&"mouseleave"===e.type&&this._emit(xE,e)}handleMoveEvent(e){if(this.enableMoveEvent)switch(e.type){case"mousedown":e.button>=0&&(this.pressed=!0);break;case"mousemove":0===e.buttons&&(this.pressed=!1),this.pressed||this._emit(_E,e);break;case"mouseup":this.pressed=!1}}_emit(e,t){this.callback({type:e,center:{x:t.clientX,y:t.clientY},srcEvent:t,pointerType:"mouse",target:t.target})}}const{KEY_EVENTS:wE}=oE,TE="keydown",EE="keyup";class CE extends eE{constructor(e,t,i){super(e,t,i),this.handleEvent=e=>{const t=e.target||e.srcElement;"INPUT"===t.tagName&&"text"===t.type||"TEXTAREA"===t.tagName||(this.enableDownEvent&&"keydown"===e.type&&this.callback({type:TE,srcEvent:e,key:e.key,target:e.target}),this.enableUpEvent&&"keyup"===e.type&&this.callback({type:EE,srcEvent:e,key:e.key,target:e.target}))},this.enableDownEvent=this.options.enable,this.enableUpEvent=this.options.enable,this.events=(this.options.events||[]).concat(wE),e.tabIndex=this.options.tabIndex||0,e.style.outline="none",this.events.forEach(t=>e.addEventListener(t,this.handleEvent))}destroy(){this.events.forEach(e=>this.element.removeEventListener(e,this.handleEvent))}enableEventType(e,t){e===TE&&(this.enableDownEvent=t),e===EE&&(this.enableUpEvent=t)}}const BE="contextmenu";class SE extends eE{constructor(e,t,i){super(e,t,i),this.handleEvent=e=>{this.options.enable&&this.callback({type:BE,center:{x:e.clientX,y:e.clientY},srcEvent:e,pointerType:"mouse",target:e.target})},e.addEventListener("contextmenu",this.handleEvent)}destroy(){this.element.removeEventListener("contextmenu",this.handleEvent)}enableEventType(e,t){e===BE&&(this.options.enable=t)}}const IE={pointerdown:1,pointermove:2,pointerup:4,mousedown:1,mousemove:2,mouseup:4};function ME(e){const t=IE[e.srcEvent.type];if(!t)return null;const{buttons:i,button:r}=e.srcEvent;let n=!1,o=!1,s=!1;return 2===t?(n=Boolean(1&i),o=Boolean(4&i),s=Boolean(2&i)):(n=0===r,o=1===r,s=2===r),{leftButton:n,middleButton:o,rightButton:s}}function PE(e,t){const i=e.center;if(!i)return null;const r=t.getBoundingClientRect(),n=r.width/t.offsetWidth||1,o=r.height/t.offsetHeight||1;return{center:i,offsetCenter:{x:(i.x-r.left-t.clientLeft)/n,y:(i.y-r.top-t.clientTop)/o}}}const RE={srcElement:"root",priority:0};class LE{constructor(e){this.handleEvent=e=>{if(this.isEmpty())return;const t=this._normalizeEvent(e);let i=e.srcEvent.target;for(;i&&i!==t.rootElement;){if(this._emit(t,i),t.handled)return;i=i.parentNode}this._emit(t,"root")},this.eventManager=e,this.handlers=[],this.handlersByElement=new Map,this._active=!1}isEmpty(){return!this._active}add(e,t,i,r=!1,n=!1){const{handlers:o,handlersByElement:s}=this;let a=RE;"string"==typeof i||i&&i.addEventListener?a={...RE,srcElement:i}:i&&(a={...RE,...i});let l=s.get(a.srcElement);l||(l=[],s.set(a.srcElement,l));const c={type:e,handler:t,srcElement:a.srcElement,priority:a.priority};r&&(c.once=!0),n&&(c.passive=!0),o.push(c),this._active=this._active||!c.passive;let u=l.length-1;for(;u>=0&&!(l[u].priority>=c.priority);)u--;l.splice(u+1,0,c)}remove(e,t){const{handlers:i,handlersByElement:r}=this;for(let n=i.length-1;n>=0;n--){const o=i[n];if(o.type===e&&o.handler===t){i.splice(n,1);const e=r.get(o.srcElement);e.splice(e.indexOf(o),1),0===e.length&&r.delete(o.srcElement)}}this._active=i.some(e=>!e.passive)}_emit(e,t){const i=this.handlersByElement.get(t);if(i){let t=!1;const r=()=>{e.handled=!0},n=()=>{e.handled=!0,t=!0},o=[];for(let s=0;s{e.srcEvent.preventDefault()},stopImmediatePropagation:null,stopPropagation:null,handled:!1,rootElement:t}}}const FE={events:null,recognizers:null,recognizerOptions:{},Manager:YT,touchAction:"none",tabIndex:0};class kE{constructor(e=null,t){this._onBasicInput=e=>{const{srcEvent:t}=e,i=nE[t.type];i&&this.manager.emit(i,e)},this._onOtherEvent=e=>{this.manager.emit(e.type,e)},this.options={...FE,...t},this.events=new Map,this.setElement(e);const{events:i}=this.options;i&&this.on(i)}getElement(){return this.element}setElement(e){if(this.element&&this.destroy(),this.element=e,!e)return;const{options:t}=this,i=t.Manager;this.manager=new i(e,{touchAction:t.touchAction,recognizers:t.recognizers||tE}).on("hammer.input",this._onBasicInput),t.recognizers||Object.keys(iE).forEach(e=>{const t=this.manager.get(e);t&&iE[e].forEach(e=>{t.recognizeWith(e)})});for(const e in t.recognizerOptions){const i=this.manager.get(e);if(i){const r=t.recognizerOptions[e];delete r.enable,i.set(r)}}this.wheelInput=new mE(e,this._onOtherEvent,{enable:!1}),this.moveInput=new bE(e,this._onOtherEvent,{enable:!1}),this.keyInput=new CE(e,this._onOtherEvent,{enable:!1,tabIndex:t.tabIndex}),this.contextmenuInput=new SE(e,this._onOtherEvent,{enable:!1});for(const[e,t]of this.events)t.isEmpty()||(this._toggleRecognizer(t.recognizerName,!0),this.manager.on(e,t.handleEvent))}destroy(){this.element&&(this.wheelInput.destroy(),this.moveInput.destroy(),this.keyInput.destroy(),this.contextmenuInput.destroy(),this.manager.destroy(),this.wheelInput=null,this.moveInput=null,this.keyInput=null,this.contextmenuInput=null,this.manager=null,this.element=null)}on(e,t,i){this._addEventHandler(e,t,i,!1)}once(e,t,i){this._addEventHandler(e,t,i,!0)}watch(e,t,i){this._addEventHandler(e,t,i,!1,!0)}off(e,t){this._removeEventHandler(e,t)}_toggleRecognizer(e,t){const{manager:i}=this;if(!i)return;const r=i.get(e);if(r&&r.options.enable!==t){r.set({enable:t});const n=rE[e];n&&!this.options.recognizers&&n.forEach(n=>{const o=i.get(n);t?(o.requireFailure(e),r.dropRequireFailure(n)):o.dropRequireFailure(e)})}this.wheelInput.enableEventType(e,t),this.moveInput.enableEventType(e,t),this.keyInput.enableEventType(e,t),this.contextmenuInput.enableEventType(e,t)}_addEventHandler(e,t,i,r,n){if("string"!=typeof e){i=t;for(const t in e)this._addEventHandler(t,e[t],i,r,n);return}const{manager:o,events:s}=this,a=aE[e]||e;let l=s.get(a);l||(l=new LE(this),s.set(a,l),l.recognizerName=sE[a]||a,o&&o.on(a,l.handleEvent)),l.add(e,t,i,r,n),l.isEmpty()||this._toggleRecognizer(l.recognizerName,!0)}_removeEventHandler(e,t){if("string"!=typeof e){for(const t in e)this._removeEventHandler(t,e[t]);return}const{events:i}=this,r=aE[e]||e,n=i.get(r);if(n&&(n.remove(e,t),n.isEmpty())){const{recognizerName:e}=n;let t=!1;for(const r of i.values())if(r.recognizerName===e&&!r.isEmpty()){t=!0;break}t||this._toggleRecognizer(e,!1)}}}function DE(){}const OE={id:"",width:"100%",height:"100%",style:null,viewState:null,initialViewState:null,pickingRadius:0,layerFilter:null,parameters:{},parent:null,device:null,deviceProps:{type:"webgl"},gl:null,glOptions:{},canvas:null,layers:[],effects:[],views:null,controller:null,useDevicePixels:!0,touchAction:"none",eventRecognizerOptions:{},_framebuffer:null,_animate:!1,_pickable:!0,_typedArrayManagerProps:{},_customRender:null,widgets:[],onDeviceInitialized:DE,onWebGLInitialized:DE,onResize:DE,onViewStateChange:DE,onInteractionStateChange:DE,onBeforeRender:DE,onAfterRender:DE,onLoad:DE,onError:e=>rp.error(e.message,e.cause)(),onHover:null,onClick:null,onDragStart:null,onDrag:null,onDragEnd:null,_onMetrics:null,getCursor:({isDragging:e})=>e?"grabbing":"grab",getTooltip:null,debug:!1,drawPickingColors:!1};class zE{constructor(e){this.width=0,this.height=0,this.userData={},this.device=null,this.canvas=null,this.viewManager=null,this.layerManager=null,this.effectManager=null,this.deckRenderer=null,this.deckPicker=null,this.eventManager=null,this.widgetManager=null,this.tooltip=null,this.animationLoop=null,this.cursorState={isHovering:!1,isDragging:!1},this.stats=new Eh({id:"deck.gl"}),this.metrics={fps:0,setPropsTime:0,updateAttributesTime:0,framesRedrawn:0,pickTime:0,pickCount:0,gpuTime:0,gpuTimePerFrame:0,cpuTime:0,cpuTimePerFrame:0,bufferMemory:0,textureMemory:0,renderbufferMemory:0,gpuMemory:0},this._metricsCounter=0,this._needsRedraw="Initial render",this._pickRequest={mode:"hover",x:-1,y:-1,radius:0,event:null},this._lastPointerDownInfo=null,this._onPointerMove=e=>{const{_pickRequest:t}=this;if("pointerleave"===e.type)t.x=-1,t.y=-1,t.radius=0;else{if(e.leftButton||e.rightButton)return;{const i=e.offsetCenter;if(!i)return;t.x=i.x,t.y=i.y,t.radius=this.props.pickingRadius}}this.layerManager&&(this.layerManager.context.mousePosition={x:t.x,y:t.y}),t.event=e},this._onEvent=e=>{const t=xy[e.type],i=e.offsetCenter;if(!t||!i||!this.layerManager)return;const r=this.layerManager.getLayers(),n=this.deckPicker.getLastPickedObject({x:i.x,y:i.y,layers:r,viewports:this.getViewports(i)},this._lastPointerDownInfo),{layer:o}=n,s=o&&(o[t.handler]||o.props[t.handler]),a=this.props[t.handler];let l=!1;s&&(l=s.call(o,n,e)),l||(a?.(n,e),this.widgetManager.onEvent(n,e))},this._onPointerDown=e=>{const t=e.offsetCenter,i=this._pick("pickObject","pickObject Time",{x:t.x,y:t.y,radius:this.props.pickingRadius});this._lastPointerDownInfo=i.result[0]||i.emptyInfo},this.props={...OE,...e},(e=this.props).viewState&&e.initialViewState&&rp.warn("View state tracking is disabled. Use either `initialViewState` for auto update or `viewState` for manual update.")(),this.viewState=this.props.initialViewState,e.device?this.device=e.device:e.gl&&(e.gl instanceof WebGLRenderingContext&&rp.error("WebGL1 context not supported.")(),this.device=WT.attach(e.gl));let t=this.device;t||(uf.registerDevices([WT]),t=uf.createDevice({...e.deviceProps,canvas:this._createCanvas(e)})),this.animationLoop=this._createAnimationLoop(t,e),this.setProps(e),e._typedArrayManagerProps&&Lv.setOptions(e._typedArrayManagerProps),this.animationLoop.start()}finalize(){this.animationLoop?.stop(),this.animationLoop?.destroy(),this.animationLoop=null,this._lastPointerDownInfo=null,this.layerManager?.finalize(),this.layerManager=null,this.viewManager?.finalize(),this.viewManager=null,this.effectManager?.finalize(),this.effectManager=null,this.deckRenderer?.finalize(),this.deckRenderer=null,this.deckPicker?.finalize(),this.deckPicker=null,this.eventManager?.destroy(),this.eventManager=null,this.widgetManager?.finalize(),this.widgetManager=null,this.props.canvas||this.props.device||this.props.gl||!this.canvas||(this.canvas.parentElement?.removeChild(this.canvas),this.canvas=null)}setProps(e){this.stats.get("setProps Time").timeStart(),"onLayerHover"in e&&rp.removed("onLayerHover","onHover")(),"onLayerClick"in e&&rp.removed("onLayerClick","onClick")(),e.initialViewState&&!Nx(this.props.initialViewState,e.initialViewState,3)&&(this.viewState=e.initialViewState),Object.assign(this.props,e),this._setCanvasSize(this.props);const t=Object.create(this.props);Object.assign(t,{views:this._getViews(),width:this.width,height:this.height,viewState:this._getViewState()}),this.animationLoop?.setProps(t),this.layerManager&&(this.viewManager.setProps(t),this.layerManager.activateViewport(this.getViewports()[0]),this.layerManager.setProps(t),this.effectManager.setProps(t),this.deckRenderer.setProps(t),this.deckPicker.setProps(t),this.widgetManager.setProps(t)),this.stats.get("setProps Time").timeEnd()}needsRedraw(e={clearRedrawFlags:!1}){if(!this.layerManager)return!1;if(this.props._animate)return"Deck._animate";let t=this._needsRedraw;e.clearRedrawFlags&&(this._needsRedraw=!1);const i=this.viewManager.needsRedraw(e),r=this.layerManager.needsRedraw(e),n=this.effectManager.needsRedraw(e),o=this.deckRenderer.needsRedraw(e);return t=t||i||r||n||o,t}redraw(e){if(!this.layerManager)return;let t=this.needsRedraw({clearRedrawFlags:!0});t=e||t,t&&(this.stats.get("Redraw Count").incrementCount(),this.props._customRender?this.props._customRender(t):this._drawLayers(t))}get isInitialized(){return null!==this.viewManager}getViews(){return Yx(this.viewManager),this.viewManager.views}getViewports(e){return Yx(this.viewManager),this.viewManager.getViewports(e)}getCanvas(){return this.canvas}pickObject(e){const t=this._pick("pickObject","pickObject Time",e).result;return t.length?t[0]:null}pickMultipleObjects(e){return e.depth=e.depth||10,this._pick("pickObject","pickMultipleObjects Time",e).result}pickObjects(e){return this._pick("pickObjects","pickObjects Time",e)}_addResources(e,t=!1){for(const i in e)this.layerManager.resourceManager.add({resourceId:i,data:e[i],forceUpdate:t})}_removeResources(e){for(const t of e)this.layerManager.resourceManager.remove(t)}_addDefaultEffect(e){this.effectManager.addDefaultEffect(e)}_addDefaultShaderModule(e){this.layerManager.addDefaultShaderModule(e)}_removeDefaultShaderModule(e){this.layerManager?.removeDefaultShaderModule(e)}_pick(e,t,i){Yx(this.deckPicker);const{stats:r}=this;r.get("Pick Count").incrementCount(),r.get(t).timeStart();const n=this.deckPicker[e]({layers:this.layerManager.getLayers(i),views:this.viewManager.getViews(),viewports:this.getViewports(i),onViewportActive:this.layerManager.activateViewport,effects:this.effectManager.getEffects(),...i});return r.get(t).timeEnd(),n}_createCanvas(e){let t=e.canvas;if("string"==typeof t&&(t=document.getElementById(t),Yx(t)),!t){t=document.createElement("canvas"),t.id=e.id||"deckgl-overlay";(e.parent||document.body).appendChild(t)}return Object.assign(t.style,e.style),t}_setCanvasSize(e){if(!this.canvas)return;const{width:t,height:i}=e;if(t||0===t){const e=Number.isFinite(t)?`${t}px`:t;this.canvas.style.width=e}if(i||0===i){const t=Number.isFinite(i)?`${i}px`:i;this.canvas.style.position=e.style?.position||"absolute",this.canvas.style.height=t}}_updateCanvasSize(){const{canvas:e}=this;if(!e)return;const t=e.clientWidth??e.width,i=e.clientHeight??e.height;t===this.width&&i===this.height||(this.width=t,this.height=i,this.viewManager?.setProps({width:t,height:i}),this.layerManager?.activateViewport(this.getViewports()[0]),this.props.onResize({width:t,height:i}))}_createAnimationLoop(e,t){const{gl:i,onError:r,useDevicePixels:n}=t;return new rx({device:e,useDevicePixels:n,autoResizeDrawingBuffer:!i,autoResizeViewport:!1,onInitialize:e=>this._setDevice(e.device),onRender:this._onRenderFrame.bind(this),onError:r})}_getViewState(){return this.props.viewState||this.viewState}_getViews(){const{views:e}=this.props,t=Array.isArray(e)?e:e?[e]:[new Ab({id:"default-view"})];return t.length&&this.props.controller&&(t[0].props.controller=this.props.controller),t}_onContextLost(){const{onError:e}=this.props;this.animationLoop&&e&&e(new Error("WebGL context is lost"))}_pickAndCallback(){const{_pickRequest:e}=this;if(e.event){const{result:t,emptyInfo:i}=this._pick("pickObject","pickObject Time",e);this.cursorState.isHovering=t.length>0;let r=i,n=!1;for(const i of t)r=i,n=i.layer?.onHover(i,e.event)||n;n||(this.props.onHover?.(r,e.event),this.widgetManager.onHover(r,e.event)),e.event=null}}_updateCursor(){const e=this.props.parent||this.canvas;e&&(e.style.cursor=this.props.getCursor(this.cursorState))}_setDevice(e){if(this.device=e,!this.animationLoop)return;this.canvas||(this.canvas=this.device.canvasContext?.canvas),this.device.setParametersWebGL({blend:!0,blendFunc:[770,771,1,771],polygonOffsetFill:!0,depthTest:!0,depthFunc:515}),this.props.onDeviceInitialized(this.device),this.device instanceof WT&&this.props.onWebGLInitialized(this.device.gl);const t=new ex;t.play(),this.animationLoop.attachTimeline(t),this.eventManager=new kE(this.props.parent||this.canvas,{touchAction:this.props.touchAction,recognizerOptions:this.props.eventRecognizerOptions,events:{pointerdown:this._onPointerDown,pointermove:this._onPointerMove,pointerleave:this._onPointerMove}});for(const e in xy)this.eventManager.on(e,this._onEvent);this.viewManager=new Vx({timeline:t,eventManager:this.eventManager,onViewStateChange:this._onViewStateChange.bind(this),onInteractionStateChange:this._onInteractionStateChange.bind(this),views:this._getViews(),viewState:this._getViewState(),width:this.width,height:this.height});const i=this.viewManager.getViewports()[0];this.layerManager=new Ux(this.device,{deck:this,stats:this.stats,viewport:i,timeline:t}),this.effectManager=new vb({deck:this,device:this.device}),this.deckRenderer=new bb(this.device),this.deckPicker=new Sb(this.device),this.widgetManager=new Rb({deck:this,parentElement:this.canvas?.parentElement}),this.widgetManager.addDefault(new Fb),this.setProps(this.props),this._updateCanvasSize(),this.props.onLoad()}_drawLayers(e,t){const{device:i,gl:r}=this.layerManager.context;this.props.onBeforeRender({device:i,gl:r});const n={target:this.props._framebuffer,layers:this.layerManager.getLayers(),viewports:this.viewManager.getViewports(),onViewportActive:this.layerManager.activateViewport,views:this.viewManager.getViews(),pass:"screen",effects:this.effectManager.getEffects(),...t};this.deckRenderer?.renderLayers(n),"screen"===n.pass&&this.widgetManager.onRedraw({viewports:n.viewports,layers:n.layers}),this.props.onAfterRender({device:i,gl:r})}_onRenderFrame(){this._getFrameStats(),this._metricsCounter++%60==0&&(this._getMetrics(),this.stats.reset(),rp.table(4,this.metrics)(),this.props._onMetrics&&this.props._onMetrics(this.metrics)),this._updateCanvasSize(),this._updateCursor(),this.layerManager.updateLayers(),this._pickAndCallback(),this.redraw(),this.viewManager&&this.viewManager.updateViewStates()}_onViewStateChange(e){const t=this.props.onViewStateChange(e)||e.viewState;this.viewState&&(this.viewState={...this.viewState,[e.viewId]:t},this.props.viewState||this.viewManager&&this.viewManager.setProps({viewState:this.viewState}))}_onInteractionStateChange(e){this.cursorState.isDragging=e.isDragging||!1,this.props.onInteractionStateChange(e)}_getFrameStats(){const{stats:e}=this;e.get("frameRate").timeEnd(),e.get("frameRate").timeStart();const t=this.animationLoop.stats;e.get("GPU Time").addTime(t.get("GPU Time").lastTiming),e.get("CPU Time").addTime(t.get("CPU Time").lastTiming)}_getMetrics(){const{metrics:e,stats:t}=this;e.fps=t.get("frameRate").getHz(),e.setPropsTime=t.get("setProps Time").time,e.updateAttributesTime=t.get("Update Attributes").time,e.framesRedrawn=t.get("Redraw Count").count,e.pickTime=t.get("pickObject Time").time+t.get("pickMultipleObjects Time").time+t.get("pickObjects Time").time,e.pickCount=t.get("Pick Count").count,e.gpuTime=t.get("GPU Time").time,e.cpuTime=t.get("CPU Time").time,e.gpuTimePerFrame=t.get("GPU Time").getAverageTime(),e.cpuTimePerFrame=t.get("CPU Time").getAverageTime();const i=uf.stats.get("Memory Usage");e.bufferMemory=i.get("Buffer Memory").count,e.textureMemory=i.get("Texture Memory").count,e.renderbufferMemory=i.get("Renderbuffer Memory").count,e.gpuMemory=i.get("GPU Memory").count}}zE.defaultProps=OE,zE.VERSION=cp;var UE=zE;const NE=Xf;function VE(e,t){return{attribute:e,format:t.size>1?`${t.type}x${t.size}`:t.type,byteOffset:t.offset||0}}function jE(e){return e.stride||e.size*e.bytesPerElement}function GE(e,t){t.offset&&rp.removed("shaderAttribute.offset","vertexOffset, elementOffset")();const i=jE(e),r=(void 0!==t.vertexOffset?t.vertexOffset:e.vertexOffset||0)*i+(t.elementOffset||0)*e.bytesPerElement+(e.offset||0);return{...t,offset:r,stride:i}}class HE{constructor(e,t,i){this._buffer=null,this.device=e,this.id=t.id||"",this.size=t.size||1;const r=t.logicalType||t.type,n="float64"===r;let o,{defaultValue:s}=t;s=Number.isFinite(s)?[s]:s||new Array(this.size).fill(0),o=n?"float32":!r&&t.isIndexed?"uint32":r||"float32";let a=function(e){switch(e){case"float64":return Float64Array;case"uint8":case"unorm8":return Uint8ClampedArray;default:return Jf(e)}}(r||o);this.doublePrecision=n,n&&!1===t.fp64&&(a=Float32Array),this.value=null,this.settings={...t,defaultType:a,defaultValue:s,logicalType:r,type:o,normalized:o.includes("norm"),size:this.size,bytesPerElement:a.BYTES_PER_ELEMENT},this.state={...i,externalBuffer:null,bufferAccessor:this.settings,allocatedValue:null,numInstances:0,bounds:null,constant:!1}}get isConstant(){return this.state.constant}get buffer(){return this._buffer}get byteOffset(){const e=this.getAccessor();return e.vertexOffset?e.vertexOffset*jE(e):0}get numInstances(){return this.state.numInstances}set numInstances(e){this.state.numInstances=e}delete(){this._buffer&&(this._buffer.delete(),this._buffer=null),Lv.release(this.state.allocatedValue)}getBuffer(){return this.state.constant?null:this.state.externalBuffer||this._buffer}getValue(e=this.id,t=null){const i={};if(this.state.constant){const r=this.value;if(t){const n=GE(this.getAccessor(),t),o=n.offset/r.BYTES_PER_ELEMENT,s=n.size||this.size;i[e]=r.subarray(o,o+s)}else i[e]=r}else i[e]=this.getBuffer();return this.doublePrecision&&(this.value instanceof Float64Array?i[`${e}64Low`]=i[e]:i[`${e}64Low`]=new Float32Array(this.size)),i}_getBufferLayout(e=this.id,t=null){const i=this.getAccessor(),r=[],n={name:this.id,byteStride:jE(i),attributes:r};if(this.doublePrecision){const n=function(e,t){const i=GE(e,t);return{high:i,low:{...i,offset:i.offset+4*e.size}}}(i,t||{});r.push(VE(e,{...i,...n.high}),VE(`${e}64Low`,{...i,...n.low}))}else if(t){const n=GE(i,t);r.push(VE(e,{...i,...n}))}else r.push(VE(e,i));return n}setAccessor(e){this.state.bufferAccessor=e}getAccessor(){return this.state.bufferAccessor}getBounds(){if(this.state.bounds)return this.state.bounds;let e=null;if(this.state.constant&&this.value){const t=Array.from(this.value);e=[t,t]}else{const{value:t,numInstances:i,size:r}=this,n=i*r;if(t&&n&&t.length>=n){const i=new Array(r).fill(1/0),o=new Array(r).fill(-1/0);for(let e=0;eo[n]&&(o[n]=r)}e=[i,o]}}return this.state.bounds=e,e}setData(e){const{state:t}=this;let i;i=ArrayBuffer.isView(e)?{value:e}:e instanceof Kp?{buffer:e}:e;const r={...this.settings,...i};if(ArrayBuffer.isView(i.value)){if(!i.type){if(this.doublePrecision&&i.value instanceof Float64Array)r.type="float32";else{const e=NE(i.value);r.type=r.normalized?e.replace("int","norm"):e}}r.bytesPerElement=i.value.BYTES_PER_ELEMENT,r.stride=jE(r)}if(t.bounds=null,i.constant){let e=i.value;e=this._normalizeValue(e,[],0),this.settings.normalized&&(e=this.normalizeConstant(e));if(!(!t.constant||!this._areValuesEqual(e,this.value)))return!1;t.externalBuffer=null,t.constant=!0,this.value=ArrayBuffer.isView(e)?e:new Float32Array(e)}else if(i.buffer){const e=i.buffer;t.externalBuffer=e,t.constant=!1,this.value=i.value||null}else if(i.value){this._checkExternalBuffer(i);let e=i.value;t.externalBuffer=null,t.constant=!1,this.value=e;let{buffer:n}=this;const o=jE(r),s=(r.vertexOffset||0)*o;if(this.doublePrecision&&e instanceof Float64Array&&(e=zv(e,r)),this.settings.isIndexed){const t=this.settings.defaultType;e.constructor!==t&&(e=new t(e))}const a=e.byteLength+s+2*o;(!n||n.byteLength(e+128)/255*2-1);case"snorm16":return new Float32Array(e).map(e=>(e+32768)/65535*2-1);case"unorm8":return new Float32Array(e).map(e=>e/255);case"unorm16":return new Float32Array(e).map(e=>e/65535);default:return e}}_normalizeValue(e,t,i){const{defaultValue:r,size:n}=this.settings;if(Number.isFinite(e))return t[i]=e,t;if(!e){let e=n;for(;--e>=0;)t[i+e]=r[e];return t}switch(n){case 4:t[i+3]=Number.isFinite(e[3])?e[3]:r[3];case 3:t[i+2]=Number.isFinite(e[2])?e[2]:r[2];case 2:t[i+1]=Number.isFinite(e[1])?e[1]:r[1];case 1:t[i+0]=Number.isFinite(e[0])?e[0]:r[0];break;default:let o=n;for(;--o>=0;)t[i+o]=Number.isFinite(e[o])?e[o]:r[o]}return t}_areValuesEqual(e,t){if(!e||!t)return!1;const{size:i}=this;for(let r=0;r0&&($E.length=e.length,r=$E):r=QE,(t>0||Number.isFinite(i))&&(r=(Array.isArray(r)?r:Array.from(r)).slice(t,i),n.index=t-1),{iterable:r,objectInfo:n}}function WE(e){return e&&e[Symbol.asyncIterator]}const qE=[],KE=[[0,1/0]];const XE={interpolation:{duration:0,easing:e=>e},spring:{stiffness:.05,damping:.5}};function JE(e,t){if(!e)return null;Number.isFinite(e)&&(e={type:"interpolation",duration:e});const i=e.type||"interpolation";return{...XE[i],...t,...e,type:i}}class YE extends HE{constructor(e,t){super(e,t,{startIndices:null,lastExternalBuffer:null,binaryValue:null,binaryAccessor:null,needsUpdate:!0,needsRedraw:!1,layoutChanged:!1,updateRanges:KE}),this.constant=!1,this.settings.update=t.update||(t.accessor?this._autoUpdater:void 0),Object.seal(this.settings),Object.seal(this.state),this._validateAttributeUpdaters()}get startIndices(){return this.state.startIndices}set startIndices(e){this.state.startIndices=e}needsUpdate(){return this.state.needsUpdate}needsRedraw({clearChangedFlags:e=!1}={}){const t=this.state.needsRedraw;return this.state.needsRedraw=t&&!e,t}layoutChanged(){return this.state.layoutChanged}setAccessor(e){var t,i,r;(t=this.state).layoutChanged||(t.layoutChanged=(i=e,r=this.getAccessor(),!(i.type===r.type&&i.size===r.size&&jE(i)===jE(r)&&(i.offset||0)===(r.offset||0)))),super.setAccessor(e)}getUpdateTriggers(){const{accessor:e}=this.settings;return[this.id].concat("function"!=typeof e&&e||[])}supportsTransition(){return Boolean(this.settings.transition)}getTransitionSetting(e){if(!e||!this.supportsTransition())return null;const{accessor:t}=this.settings,i=this.settings.transition,r=Array.isArray(t)?e[t.find(t=>e[t])]:e[t];return JE(r,i)}setNeedsUpdate(e=this.id,t){if(this.state.needsUpdate=this.state.needsUpdate||e,this.setNeedsRedraw(e),t){const{startRow:e=0,endRow:i=1/0}=t;this.state.updateRanges=function(e,t){if(e===KE)return e;if(t[0]<0&&(t[0]=0),t[0]>=t[1])return e;const i=[],r=e.length;let n=0;for(let o=0;ot[1]?i.push(r):t=[Math.min(r[0],t[0]),Math.max(r[1],t[1])]}return i.splice(n,0,t),i}(this.state.updateRanges,[e,i])}else this.state.updateRanges=KE}clearNeedsUpdate(){this.state.needsUpdate=!1,this.state.updateRanges=qE}setNeedsRedraw(e=this.id){this.state.needsRedraw=this.state.needsRedraw||e}allocate(e){const{state:t,settings:i}=this;return!i.noAlloc&&(!!i.update&&(super.allocate(e,t.updateRanges!==KE),!0))}updateBuffer({numInstances:e,data:t,props:i,context:r}){if(!this.needsUpdate())return!1;const{state:{updateRanges:n},settings:{update:o,noAlloc:s}}=this;let a=!0;if(o){for(const[s,a]of n)o.call(r,this,{data:t,startRow:s,endRow:a,props:i,numInstances:e});if(this.value)if(this.constant||!this.buffer||this.buffer.byteLength{if(!o){const t=r*l+c;for(let r=0;rc?l.set(i,f):(e._normalizeValue(i,g.target,0),Dx({target:l,source:g.target,start:f,count:t}));f+=t*c}else e._normalizeValue(i,l,f),f+=c}}_validateAttributeUpdaters(){const{settings:e}=this;if(!(e.noAlloc||"function"==typeof e.update))throw new Error(`Attribute ${this.id} missing update or accessor`)}_checkAttributeArray(){const{value:e}=this,t=Math.min(4,this.size);if(e&&e.length>=t){let i=!0;switch(t){case 4:i=i&&Number.isFinite(e[3]);case 3:i=i&&Number.isFinite(e[2]);case 2:i=i&&Number.isFinite(e[1]);case 1:i=i&&Number.isFinite(e[0]);break;default:i=!1}if(!i)throw new Error(`Illegal attribute generated for ${this.id}`)}}}function eC(e){const{source:t,target:i,start:r=0,size:n,getData:o}=e,s=e.end||i.length,a=t.length,l=s-r;if(a>l)return void i.set(t.subarray(0,l),r);if(i.set(t,r),!o)return;let c=a;for(;ce}){const a=i.doublePrecision&&i.value instanceof Float64Array?2:1,l=i.size*a,c=i.byteOffset,u=i.settings.bytesPerElement<4?c/i.settings.bytesPerElement*4:c,h=i.startIndices,d=o&&h,p=i.isConstant;if(!d&&t&&r>=n)return t;const f=i.value instanceof Float64Array?Float32Array:i.value.constructor,m=p?i.value:new f(i.getBuffer().readSyncWebGL(c,n*f.BYTES_PER_ELEMENT).buffer);if(i.settings.normalized&&!p){const e=s;s=(t,r)=>i.normalizeConstant(e(t,r))}const g=p?(e,t)=>s(m,t):(e,t)=>s(m.subarray(e+c,e+c+l),t),_=t?new Float32Array(t.readSyncWebGL(u,4*r).buffer):new Float32Array(0),A=new Float32Array(n);return function({source:e,target:t,size:i,getData:r,sourceStartIndices:n,targetStartIndices:o}){if(!n||!o)return eC({source:e,target:t,size:i,getData:r}),t;let s=0,a=0;const l=r&&((e,t)=>r(e+a,t)),c=Math.min(n.length,o.length);for(let r=1;r0||r.end()}delete(){super.delete(),this.transform.destroy(),this.texture.destroy(),this.framebuffer.destroy()}}};class pC{constructor(e,{id:t,timeline:i}){if(!e)throw new Error("AttributeTransitionManager is constructed without device");this.id=t,this.device=e,this.timeline=i,this.transitions={},this.needsRedraw=!1,this.numInstances=1}finalize(){for(const e in this.transitions)this._removeTransition(e)}update({attributes:e,transitions:t,numInstances:i}){this.numInstances=i||1;for(const i in e){const r=e[i],n=r.getTransitionSetting(t);n&&this._updateAttribute(i,r,n)}for(const i in this.transitions){const r=e[i];r&&r.getTransitionSetting(t)||this._removeTransition(i)}}hasAttribute(e){const t=this.transitions[e];return t&&t.inProgress}getAttributes(){const e={};for(const t in this.transitions){const i=this.transitions[t];i.inProgress&&(e[t]=i.attributeInTransition)}return e}run(){if(0===this.numInstances)return!1;for(const e in this.transitions){this.transitions[e].update()&&(this.needsRedraw=!0)}const e=this.needsRedraw;return this.needsRedraw=!1,e}_removeTransition(e){this.transitions[e].delete(),delete this.transitions[e]}_updateAttribute(e,t,i){const r=this.transitions[e];let n=!r||r.type!==i.type;if(n){r&&this._removeTransition(e);const o=dC[i.type];o?this.transitions[e]=new o({attribute:t,timeline:this.timeline,device:this.device}):(rp.error(`unsupported transition type '${i.type}'`)(),n=!1)}(n||t.needsRedraw())&&(this.needsRedraw=!0,this.transitions[e].start(i,this.numInstances))}}const fC="attributeManager.invalidate";class mC{constructor(e,{id:t="attribute-manager",stats:i,timeline:r}={}){this.mergeBoundsMemoized=Ty(Uv),this.id=t,this.device=e,this.attributes={},this.updateTriggers={},this.needsRedraw=!0,this.userData={},this.stats=i,this.attributeTransitionManager=new pC(e,{id:`${t}-transitions`,timeline:r}),Object.seal(this)}finalize(){for(const e in this.attributes)this.attributes[e].delete();this.attributeTransitionManager.finalize()}getNeedsRedraw(e={clearRedrawFlags:!1}){const t=this.needsRedraw;return this.needsRedraw=this.needsRedraw&&!e.clearRedrawFlags,t&&this.id}setNeedsRedraw(){this.needsRedraw=!0}add(e){this._add(e)}addInstanced(e){this._add(e,{stepMode:"instance"})}remove(e){for(const t of e)void 0!==this.attributes[t]&&(this.attributes[t].delete(),delete this.attributes[t])}invalidate(e,t){const i=this._invalidateTrigger(e,t);ap(fC,this,e,i)}invalidateAll(e){for(const t in this.attributes)this.attributes[t].setNeedsUpdate(t,e);ap(fC,this,"all")}update({data:e,numInstances:t,startIndices:i=null,transitions:r,props:n={},buffers:o={},context:s={}}){let a=!1;ap("attributeManager.updateStart",this),this.stats&&this.stats.get("Update Attributes").timeStart();for(const r in this.attributes){const l=this.attributes[r],c=l.settings.accessor;l.startIndices=i,l.numInstances=t,n[r]&&rp.removed(`props.${r}`,`data.attributes.${r}`)(),l.setExternalBuffer(o[r])||l.setBinaryValue("string"==typeof c?o[c]:void 0,e.startIndices)||"string"==typeof c&&!o[c]&&l.setConstantValue(n[c])||l.needsUpdate()&&(a=!0,this._updateAttribute({attribute:l,numInstances:t,data:e,props:n,context:s})),this.needsRedraw=this.needsRedraw||l.needsRedraw()}a&&ap("attributeManager.updateEnd",this,t),this.stats&&this.stats.get("Update Attributes").timeEnd(),this.attributeTransitionManager.update({attributes:this.attributes,numInstances:t,transitions:r})}updateTransition(){const{attributeTransitionManager:e}=this,t=e.run();return this.needsRedraw=this.needsRedraw||t,t}getAttributes(){return{...this.attributes,...this.attributeTransitionManager.getAttributes()}}getBounds(e){const t=e.map(e=>this.attributes[e]?.getBounds());return this.mergeBoundsMemoized(t)}getChangedAttributes(e={clearChangedFlags:!1}){const{attributes:t,attributeTransitionManager:i}=this,r={...i.getAttributes()};for(const n in t){const o=t[n];o.needsRedraw(e)&&!i.hasAttribute(n)&&(r[n]=o)}return r}getBufferLayouts(e){return Object.values(this.getAttributes()).map(t=>t.getBufferLayout(e))}_add(e,t){for(const i in e){const r=e[i],n={...r,id:i,size:(r.isIndexed?1:r.size)||1,...t};this.attributes[i]=new YE(this.device,n)}this._mapUpdateTriggersToAttributes()}_mapUpdateTriggersToAttributes(){const e={};for(const t in this.attributes){this.attributes[t].getUpdateTriggers().forEach(i=>{e[i]||(e[i]=[]),e[i].push(t)})}this.updateTriggers=e}_invalidateTrigger(e,t){const{attributes:i,updateTriggers:r}=this,n=r[e];return n&&n.forEach(e=>{const r=i[e];r&&r.setNeedsUpdate(r.id,t)}),n}_updateAttribute(e){const{attribute:t,numInstances:i}=e;if(ap("attribute.updateStart",t),t.constant)return void t.setConstantValue(t.value);t.allocate(i)&&ap("attribute.allocate",t,i);t.updateBuffer(e)&&(this.needsRedraw=!0,ap("attribute.updateEnd",t,i))}}const gC=1e-5;function _C(e,t,i,r,n){const o=t-e;return(i-t)*n+-o*r+o+t}function AC(e,t){if(Array.isArray(e)){let i=0;for(let r=0;r0}add(e,t,i,r){const{transitions:n}=this;if(n.has(e)){const i=n.get(e),{value:r=i.settings.fromValue}=i;t=r,this.remove(e)}if(!(r=JE(r)))return;const o=yC[r.type];if(!o)return void rp.error(`unsupported transition type '${r.type}'`)();const s=new o(this.timeline);s.start({...r,fromValue:t,toValue:i}),n.set(e,s)}remove(e){const{transitions:t}=this;t.has(e)&&(t.get(e).cancel(),t.delete(e))}update(){const e={};for(const[t,i]of this.transitions)i.update(),e[t]=i.value,i.inProgress||this.remove(t);return e}clear(){for(const e of this.transitions.keys())this.remove(e)}}function xC(e,t){const i=wC({newProps:e,oldProps:t,propTypes:e[Ix],ignoreProps:{data:null,updateTriggers:null,extensions:null,transitions:null}}),r=function(e,t){if(null===t)return"oldProps is null, initial diff";let i=!1;const{dataComparator:r,_dataDiff:n}=e;r?r(e.data,t.data)||(i="Data comparator detected a change"):e.data!==t.data&&(i="A new data container was supplied");i&&n&&(i=n(e.data,t.data)||i);return i}(e,t);let n=!1;return r||(n=function(e,t){if(null===t)return{all:!0};if("all"in e.updateTriggers){if(CC(e,t,"all"))return{all:!0}}const i={};let r=!1;for(const n in e.updateTriggers)if("all"!==n){CC(e,t,n)&&(i[n]=!0,r=!0)}return!!r&&i}(e,t)),{dataChanged:r,propsChanged:i,updateTriggersChanged:n,extensionsChanged:EC(e,t),transitionsChanged:bC(e,t)}}function bC(e,t){if(!e.transitions)return!1;const i={},r=e[Ix];let n=!1;for(const o in e.transitions){const s=r[o],a=s&&s.type;("number"===a||"color"===a||"array"===a)&&TC(e[o],t[o],s)&&(i[o]=!0,n=!0)}return!!n&&i}function wC({newProps:e,oldProps:t,ignoreProps:i={},propTypes:r={},triggerName:n="props"}){if(t===e)return!1;if("object"!=typeof e||null===e)return`${n} changed shallowly`;if("object"!=typeof t||null===t)return`${n} changed shallowly`;for(const o of Object.keys(e))if(!(o in i)){if(!(o in t))return`${n}.${o} added`;const i=TC(e[o],t[o],r[o]);if(i)return`${n}.${o} ${i}`}for(const o of Object.keys(t))if(!(o in i)){if(!(o in e))return`${n}.${o} dropped`;if(!Object.hasOwnProperty.call(e,o)){const i=TC(e[o],t[o],r[o]);if(i)return`${n}.${o} ${i}`}}return!1}function TC(e,t,i){let r=i&&i.equal;return r&&!r(e,t,i)?"changed deeply":r||(r=e&&t&&e.equals,!r||r.call(e,t))?r||t===e?null:"changed shallowly":"changed deeply"}function EC(e,t){if(null===t)return!0;const i=t.extensions,{extensions:r}=e;if(r===i)return!1;if(!i||!r)return!0;if(r.length!==i.length)return!0;for(let e=0;e"project64"===e.name))){const e=i.modules.findIndex(e=>"project32"===e.name);e>=0&&i.modules.splice(e,1)}if("inject"in t)if(e.inject){const r={...e.inject};for(const e in t.inject)r[e]=(r[e]||"")+t.inject[e];i.inject=r}else i.inject=t.inject;return i}const IC={minFilter:"linear",mipmapFilter:"linear",magFilter:"linear",addressModeU:"clamp-to-edge",addressModeV:"clamp-to-edge"},MC={};const PC={boolean:{validate:(e,t)=>!0,equal:(e,t,i)=>Boolean(e)===Boolean(t)},number:{validate:(e,t)=>Number.isFinite(e)&&(!("max"in t)||e<=t.max)&&(!("min"in t)||e>=t.min)},color:{validate:(e,t)=>t.optional&&!e||FC(e)&&(3===e.length||4===e.length),equal:(e,t,i)=>Nx(e,t,1)},accessor:{validate(e,t){const i=kC(e);return"function"===i||i===kC(t.value)},equal:(e,t,i)=>"function"==typeof t||Nx(e,t,1)},array:{validate:(e,t)=>t.optional&&!e||FC(e),equal(e,t,i){const{compare:r}=i,n=Number.isInteger(r)?r:r?1:0;return r?Nx(e,t,n):e===t}},object:{equal(e,t,i){if(i.ignore)return!0;const{compare:r}=i,n=Number.isInteger(r)?r:r?1:0;return r?Nx(e,t,n):e===t}},function:{validate:(e,t)=>t.optional&&!e||"function"==typeof e,equal:(e,t,i)=>!i.compare&&!1!==i.ignore||e===t},data:{transform:(e,t,i)=>{if(!e)return e;const{dataTransform:r}=i.props;return r?r(e):"string"==typeof e.shape&&e.shape.endsWith("-table")&&Array.isArray(e.data)?e.data:e}},image:{transform:(e,t,i)=>{const r=i.context;return r&&r.device?function(e,t,i,r){if(i instanceof Af)return i;i.constructor&&"Object"!==i.constructor.name&&(i={data:i});let n=null;i.compressed&&(n={minFilter:"linear",mipmapFilter:i.data.length>1?"nearest":"linear"});const o=t.createTexture({...i,sampler:{...IC,...n,...r}});return MC[o.id]=e,o}(i.id,r.device,e,{...t.parameters,...i.props.textureParameters}):null},release:(e,t,i)=>{var r,n;r=i.id,(n=e)&&n instanceof Af&&MC[n.id]===r&&(n.delete(),delete MC[n.id])}}};function RC(e,t){switch(kC(t)){case"object":return LC(e,t);case"array":return LC(e,{type:"array",value:t,compare:!1});case"boolean":return LC(e,{type:"boolean",value:t});case"number":return LC(e,{type:"number",value:t});case"function":return LC(e,{type:"function",value:t,compare:!0});default:return{name:e,type:"unknown",value:t}}}function LC(e,t){return"type"in t?{name:e,...PC[t.type],...t}:"value"in t?{name:e,type:kC(t.value),...t}:{name:e,type:"object",value:t}}function FC(e){return Array.isArray(e)||ArrayBuffer.isView(e)}function kC(e){return FC(e)?"array":null===e?"null":typeof e}const DC="_mergedDefaultProps";function OC(e,t){if(!(e instanceof GC.constructor))return{};let i=DC;if(t)for(const e of t){const t=e.constructor;t&&(i+=`:${t.extensionName||t.name}`)}const r=NC(e,i);return r||(e[i]=function(e,t){const i=e.prototype;if(!i)return null;const r=Object.getPrototypeOf(e),n=OC(r),o=NC(e,"defaultProps")||{},s=function(e){const t={},i={},r={};for(const[n,o]of Object.entries(e)){const e=o?.deprecatedFor;if(e)r[n]=Array.isArray(e)?e:[e];else{const e=RC(n,o);t[n]=e,i[n]=e.value}}return{propTypes:t,defaultProps:i,deprecatedProps:r}}(o),a=Object.assign(Object.create(null),n,s.defaultProps),l=Object.assign(Object.create(null),n?.[Ix],s.propTypes),c=Object.assign(Object.create(null),n?.[Mx],s.deprecatedProps);for(const e of t){const t=OC(e.constructor);t&&(Object.assign(a,t),Object.assign(l,t[Ix]),Object.assign(c,t[Mx]))}(function(e,t){const i=function(e){const t=e.componentName;t||rp.warn(`${e.name}.componentName not specified`)();return t||e.name}(t);Object.defineProperties(e,{id:{writable:!0,value:i}})})(a,e),function(e,t){const i={},r={};for(const e in t){const n=t[e],{name:o,value:s}=n;n.async&&(i[o]=s,r[o]=zC(o))}e[Px]=i,e[Rx]={},Object.defineProperties(e,r)}(a,l),function(e,t){for(const i in t)Object.defineProperty(e,i,{enumerable:!1,set(e){const r=`${this.id}: ${i}`;for(const r of t[i])UC(this,r)||(this[r]=e);rp.deprecated(r,t[i].join("/"))()}})}(a,c),a[Ix]=l,a[Mx]=c,0!==t.length||UC(e,"_propTypes")||(e._propTypes=l);return a}(e,t||[]))}function zC(e){return{enumerable:!0,set(t){"string"==typeof t||t instanceof Promise||WE(t)?this[Rx][e]=t:this[Lx][e]=t},get(){if(this[Lx]){if(e in this[Lx]){return this[Lx][e]||this[Px][e]}if(e in this[Rx]){const t=this[Sx]&&this[Sx].internalState;if(t&&t.hasAsyncProp(e))return t.getAsyncProp(e)||this[Px][e]}}return this[Px][e]}}}function UC(e,t){return Object.prototype.hasOwnProperty.call(e,t)}function NC(e,t){return UC(e,t)&&e[t]}let VC=0;class jC{constructor(...e){this.props=function(e,t){let i;for(let e=t.length-1;e>=0;e--){const r=t[e];"extensions"in r&&(i=r.extensions)}const r=OC(e.constructor,i),n=Object.create(r);n[Sx]=e,n[Rx]={},n[Lx]={};for(let e=0;e{},this.oldProps=null,this.oldAsyncProps=null}finalize(){for(const e in this.asyncProps){const t=this.asyncProps[e];t&&t.type&&t.type.release&&t.type.release(t.resolvedValue,t.type,this.component)}this.asyncProps={},this.component=null,this.resetOldProps()}getOldProps(){return this.oldAsyncProps||this.oldProps||HC}resetOldProps(){this.oldAsyncProps=null,this.oldProps=this.component?this.component.props:null}hasAsyncProp(e){return e in this.asyncProps}getAsyncProp(e){const t=this.asyncProps[e];return t&&t.resolvedValue}isAsyncPropLoading(e){if(e){const t=this.asyncProps[e];return Boolean(t&&t.pendingLoadCount>0&&t.pendingLoadCount!==t.resolvedLoadCount)}for(const e in this.asyncProps)if(this.isAsyncPropLoading(e))return!0;return!1}reloadAsyncProp(e,t){this._watchPromise(e,Promise.resolve(t))}setAsyncProps(e){this.component=e[Sx]||this.component;const t=e[Lx]||{},i=e[Rx]||e,r=e[Px]||{};for(const e in t){const i=t[e];this._createAsyncPropData(e,r[e]),this._updateAsyncProp(e,i),t[e]=this.getAsyncProp(e)}for(const e in i){const t=i[e];this._createAsyncPropData(e,r[e]),this._updateAsyncProp(e,t)}}_fetch(e,t){return null}_onResolve(e,t){}_onError(e,t){}_updateAsyncProp(e,t){this._didAsyncInputValueChange(e,t)&&("string"==typeof t&&(t=this._fetch(e,t)),t instanceof Promise?this._watchPromise(e,t):WE(t)?this._resolveAsyncIterable(e,t):this._setPropValue(e,t))}_freezeAsyncOldProps(){if(!this.oldAsyncProps&&this.oldProps){this.oldAsyncProps=Object.create(this.oldProps);for(const e in this.asyncProps)Object.defineProperty(this.oldAsyncProps,e,{enumerable:!0,value:this.oldProps[e]})}}_didAsyncInputValueChange(e,t){const i=this.asyncProps[e];return t!==i.resolvedValue&&t!==i.lastValue&&(i.lastValue=t,!0)}_setPropValue(e,t){this._freezeAsyncOldProps();const i=this.asyncProps[e];i&&(t=this._postProcessValue(i,t),i.resolvedValue=t,i.pendingLoadCount++,i.resolvedLoadCount=i.pendingLoadCount)}_setAsyncPropValue(e,t,i){const r=this.asyncProps[e];r&&i>=r.resolvedLoadCount&&void 0!==t&&(this._freezeAsyncOldProps(),r.resolvedValue=t,r.resolvedLoadCount=i,this.onAsyncPropUpdated(e,t))}_watchPromise(e,t){const i=this.asyncProps[e];if(i){i.pendingLoadCount++;const r=i.pendingLoadCount;t.then(t=>{this.component&&(t=this._postProcessValue(i,t),this._setAsyncPropValue(e,t,r),this._onResolve(e,t))}).catch(t=>{this._onError(e,t)})}}async _resolveAsyncIterable(e,t){if("data"!==e)return void this._setPropValue(e,t);const i=this.asyncProps[e];if(!i)return;i.pendingLoadCount++;const r=i.pendingLoadCount;let n=[],o=0;for await(const i of t){if(!this.component)return;const{dataTransform:t}=this.component.props;n=t?t(i,n):n.concat(i),Object.defineProperty(n,"__diff",{enumerable:!1,value:[{startRow:o,endRow:n.length}]}),o=n.length,this._setAsyncPropValue(e,n,r)}this._onResolve(e,n)}_postProcessValue(e,t){const i=e.type;return i&&this.component&&(i.release&&i.release(e.resolvedValue,i,this.component),i.transform)?i.transform(t,i,this.component):t}_createAsyncPropData(e,t){if(!this.asyncProps[e]){const i=this.component&&this.component.props[Ix];this.asyncProps[e]={type:i&&i[e],lastValue:null,resolvedValue:t,pendingLoadCount:0,resolvedLoadCount:0}}}}class $C extends QC{constructor({attributeManager:e,layer:t}){super(t),this.attributeManager=e,this.needsRedraw=!0,this.needsUpdate=!0,this.subLayers=null,this.usesPickingColorCache=!1}get layer(){return this.component}_fetch(e,t){const i=this.layer,r=i?.props.fetch;return r?r(t,{propName:e,layer:i}):super._fetch(e,t)}_onResolve(e,t){const i=this.layer;if(i){const r=i.props.onDataLoad;"data"===e&&r&&r(t,{propName:e,layer:i})}}_onError(e,t){const i=this.layer;i&&i.raiseError(t,`loading ${e} of ${this.layer}`)}}const ZC=2**24-1,WC=Object.freeze([]),qC=Ty(({oldViewport:e,viewport:t})=>e.equals(t));let KC=new Uint8ClampedArray(0);const XC={data:{type:"data",value:WC,async:!0},dataComparator:{type:"function",value:null,optional:!0},_dataDiff:{type:"function",value:e=>e&&e.__diff,optional:!0},dataTransform:{type:"function",value:null,optional:!0},onDataLoad:{type:"function",value:null,optional:!0},onError:{type:"function",value:null,optional:!0},fetch:{type:"function",value:(e,{propName:t,layer:i,loaders:r,loadOptions:n,signal:o})=>{const{resourceManager:s}=i.context;n=n||i.getLoadOptions(),r=r||i.props.loaders,o&&(n={...n,fetch:{...n?.fetch,signal:o}});let a=s.contains(e);return a||n||(s.add({resourceId:e,data:Ld(e,r),persistent:!1}),a=!0),a?s.subscribe({resourceId:e,onChange:e=>i.internalState?.reloadAsyncProp(t,e),consumerId:i.id,requestId:t}):Ld(e,r,n)}},updateTriggers:{},visible:!0,pickable:!1,opacity:{type:"number",min:0,max:1,value:1},operation:"draw",onHover:{type:"function",value:null,optional:!0},onClick:{type:"function",value:null,optional:!0},onDragStart:{type:"function",value:null,optional:!0},onDrag:{type:"function",value:null,optional:!0},onDragEnd:{type:"function",value:null,optional:!0},coordinateSystem:Ay.DEFAULT,coordinateOrigin:{type:"array",value:[0,0,0],compare:!0},modelMatrix:{type:"array",value:null,compare:!0,optional:!0},wrapLongitude:!1,positionFormat:"XYZ",colorFormat:"RGBA",parameters:{type:"object",value:{},optional:!0,compare:2},loadOptions:{type:"object",value:null,optional:!0,ignore:!0},transitions:null,extensions:[],loaders:{type:"array",value:[],optional:!0,ignore:!0},getPolygonOffset:{type:"function",value:({layerIndex:e})=>[0,100*-e]},highlightedObjectIndex:null,autoHighlight:!1,highlightColor:{type:"accessor",value:[0,0,128,128]}};class JC extends GC{constructor(){super(...arguments),this.internalState=null,this.lifecycle=bx,this.parent=null}static get componentName(){return Object.prototype.hasOwnProperty.call(this,"layerName")?this.layerName:""}get root(){let e=this;for(;e.parent;)e=e.parent;return e}toString(){return`${this.constructor.layerName||this.constructor.name}({id: '${this.props.id}'})`}project(e){Yx(this.internalState);const t=this.internalState.viewport||this.context.viewport,i=Kv(e,{viewport:t,modelMatrix:this.props.modelMatrix,coordinateOrigin:this.props.coordinateOrigin,coordinateSystem:this.props.coordinateSystem}),[r,n,o]=iv(i,t.pixelProjectionMatrix);return 2===e.length?[r,n]:[r,n,o]}unproject(e){Yx(this.internalState);return(this.internalState.viewport||this.context.viewport).unproject(e)}projectPosition(e,t){Yx(this.internalState);return Xv(e,{viewport:this.internalState.viewport||this.context.viewport,modelMatrix:this.props.modelMatrix,coordinateOrigin:this.props.coordinateOrigin,coordinateSystem:this.props.coordinateSystem,...t})}get isComposite(){return!1}setState(e){this.setChangeFlags({stateChanged:!0}),Object.assign(this.state,e),this.setNeedsRedraw()}setNeedsRedraw(){this.internalState&&(this.internalState.needsRedraw=!0)}setNeedsUpdate(){this.internalState&&(this.context.layerManager.setNeedsUpdate(String(this)),this.internalState.needsUpdate=!0)}get isLoaded(){return!!this.internalState&&!this.internalState.isAsyncPropLoading()}get wrapLongitude(){return this.props.wrapLongitude}isPickable(){return this.props.pickable&&this.props.visible}getModels(){const e=this.state;return e&&(e.models||e.model&&[e.model])||[]}setModuleParameters(e){for(const t of this.getModels())t.updateModuleSettings(e)}setShaderModuleProps(...e){for(const t of this.getModels())t.shaderInputs.setProps(...e)}getAttributeManager(){return this.internalState&&this.internalState.attributeManager}getCurrentLayer(){return this.internalState&&this.internalState.layer}getLoadOptions(){return this.props.loadOptions}use64bitPositions(){const{coordinateSystem:e}=this.props;return e===Ay.DEFAULT||e===Ay.LNGLAT||e===Ay.CARTESIAN}onHover(e,t){return this.props.onHover&&this.props.onHover(e,t)||!1}onClick(e,t){return this.props.onClick&&this.props.onClick(e,t)||!1}nullPickingColor(){return[0,0,0]}encodePickingColor(e,t=[]){return t[0]=e+1&255,t[1]=e+1>>8&255,t[2]=e+1>>8>>8&255,t}decodePickingColor(e){Yx(e instanceof Uint8Array);const[t,i,r]=e;return t+256*i+65536*r-1}getNumInstances(){return Number.isFinite(this.props.numInstances)?this.props.numInstances:this.state&&void 0!==this.state.numInstances?this.state.numInstances:BC(this.props.data)}getStartIndices(){return this.props.startIndices?this.props.startIndices:this.state&&this.state.startIndices?this.state.startIndices:null}getBounds(){return this.getAttributeManager()?.getBounds(["positions","instancePositions"])}getShaders(e){e=SC(e,{disableWarnings:!0,modules:this.context.defaultShaderModules});for(const t of this.props.extensions)e=SC(e,t.getShaders.call(this,t));return e}shouldUpdateState(e){return e.changeFlags.propsOrDataChanged}updateState(e){const t=this.getAttributeManager(),{dataChanged:i}=e.changeFlags;if(i&&t)if(Array.isArray(i))for(const e of i)t.invalidateAll(e);else t.invalidateAll();if(t){const{props:i}=e,r=this.internalState.hasPickingBuffer,n=Number.isInteger(i.highlightedObjectIndex)||i.pickable||i.extensions.some(e=>e.getNeedsPickingBuffer.call(this,e));if(r!==n){this.internalState.hasPickingBuffer=n;const{pickingColors:e,instancePickingColors:i}=t.attributes,r=e||i;r&&(n&&r.constant&&(r.constant=!1,t.invalidate(r.id)),r.value||n||(r.constant=!0,r.value=[0,0,0]))}}}finalizeState(e){for(const e of this.getModels())e.destroy();const t=this.getAttributeManager();t&&t.finalize(),this.context&&this.context.resourceManager.unsubscribe({consumerId:this.id}),this.internalState&&(this.internalState.uniformTransitions.clear(),this.internalState.finalize())}draw(e){for(const t of this.getModels())t.draw(e)}getPickingInfo({info:e,mode:t,sourceLayer:i}){const{index:r}=e;return r>=0&&Array.isArray(this.props.data)&&(e.object=this.props.data[r]),e}raiseError(e,t){t&&(e=new Error(`${t}: ${e.message}`,{cause:e})),this.props.onError?.(e)||this.context?.onError?.(e,this)}getNeedsRedraw(e={clearRedrawFlags:!1}){return this._getNeedsRedraw(e)}needsUpdate(){return!!this.internalState&&(this.internalState.needsUpdate||this.hasUniformTransition()||this.shouldUpdateState(this._getUpdateParams()))}hasUniformTransition(){return this.internalState?.uniformTransitions.active||!1}activateViewport(e){if(!this.internalState)return;const t=this.internalState.viewport;this.internalState.viewport=e,t&&qC({oldViewport:t,viewport:e})||(this.setChangeFlags({viewportChanged:!0}),this.isComposite?this.needsUpdate()&&this.setNeedsUpdate():this._update())}invalidateAttribute(e="all"){const t=this.getAttributeManager();t&&("all"===e?t.invalidateAll():t.invalidate(e))}updateAttributes(e){let t=!1;for(const i in e)e[i].layoutChanged()&&(t=!0);for(const i of this.getModels())this._setModelAttributes(i,e,t)}_updateAttributes(){const e=this.getAttributeManager();if(!e)return;const t=this.props,i=this.getNumInstances(),r=this.getStartIndices();e.update({data:t.data,numInstances:i,startIndices:r,props:t,transitions:t.transitions,buffers:t.data.attributes,context:this});const n=e.getChangedAttributes({clearChangedFlags:!0});this.updateAttributes(n)}_updateAttributeTransition(){const e=this.getAttributeManager();e&&e.updateTransition()}_updateUniformTransition(){const{uniformTransitions:e}=this.internalState;if(e.active){const t=e.update(),i=Object.create(this.props);for(const e in t)Object.defineProperty(i,e,{value:t[e]});return i}return this.props}calculateInstancePickingColors(e,{numInstances:t}){if(e.constant)return;const i=Math.floor(KC.length/4);if(this.internalState.usesPickingColorCache=!0,iZC&&rp.warn("Layer has too many data objects. Picking might not be able to distinguish all objects.")(),KC=Lv.allocate(KC,t,{size:4,copy:!0,maxCount:Math.max(t,ZC)});const e=Math.floor(KC.length/4),r=[];for(let t=i;t(rp.deprecated("layer.state.attributeManager","layer.getAttributeManager()")(),e)}),this.internalState.uniformTransitions=new vC(this.context.timeline),this.internalState.onAsyncPropUpdated=this._onAsyncPropUpdated.bind(this),this.internalState.setAsyncProps(this.props),this.initializeState(this.context);for(const e of this.props.extensions)e.initializeState.call(this,this.context,e);this.setChangeFlags({dataChanged:"init",propsChanged:"init",viewportChanged:!0,extensionsChanged:!0}),this._update()}_transferState(e){ap("layer.matched",this,this===e);const{state:t,internalState:i}=e;this!==e&&(this.internalState=i,this.state=t,this.internalState.setAsyncProps(this.props),this._diffProps(this.props,this.internalState.getOldProps()))}_update(){const e=this.needsUpdate();if(ap("layer.update",this,e),!e)return;const t=this.props,i=this.context,r=this.internalState,n=i.viewport,o=this._updateUniformTransition();r.propsInTransition=o,i.viewport=r.viewport||n,this.props=o;try{const e=this._getUpdateParams(),t=this.getModels();if(i.device)this.updateState(e);else try{this.updateState(e)}catch(e){}for(const t of this.props.extensions)t.updateState.call(this,e,t);const r=this.getModels()[0]!==t[0];this._postUpdate(e,r)}finally{i.viewport=n,this.props=t,this._clearChangeFlags(),r.needsUpdate=!1,r.resetOldProps()}}_finalize(){ap("layer.finalize",this),this.finalizeState(this.context);for(const e of this.props.extensions)e.finalizeState.call(this,this.context,e)}_drawLayer({renderPass:e,moduleParameters:t=null,uniforms:i={},parameters:r={}}){this._updateAttributeTransition();const n=this.props,o=this.context;this.props=this.internalState.propsInTransition||n;const s=this.props.opacity;i.opacity=Math.pow(s,1/2.2);try{if(t){const{isActive:e,isAttribute:i}=t.picking;this.setModuleParameters(t),this.setShaderModuleProps({picking:{isActive:e,isAttribute:i}})}const{getPolygonOffset:n}=this.props,s=n&&n(i)||[0,0];o.device.setParametersWebGL({polygonOffset:s});for(const e of this.getModels())e.setParameters(r);o.device.withParametersWebGL(r,()=>{const n={renderPass:e,moduleParameters:t,uniforms:i,parameters:r,context:o};for(const e of this.props.extensions)e.draw.call(this,n,e);this.draw(n)})}finally{this.props=n}}getChangeFlags(){return this.internalState?.changeFlags}setChangeFlags(e){if(!this.internalState)return;const{changeFlags:t}=this.internalState;for(const i in e)if(e[i]){let r=!1;if("dataChanged"===i){const n=e[i],o=t[i];n&&Array.isArray(o)&&(t.dataChanged=Array.isArray(n)?o.concat(n):n,r=!0)}t[i]||(t[i]=e[i],r=!0),r&&ap("layer.changeFlag",this,i,e)}const i=Boolean(t.dataChanged||t.updateTriggersChanged||t.propsChanged||t.extensionsChanged);t.propsOrDataChanged=i,t.somethingChanged=i||t.viewportChanged||t.stateChanged}_clearChangeFlags(){this.internalState.changeFlags={dataChanged:!1,propsChanged:!1,updateTriggersChanged:!1,viewportChanged:!1,stateChanged:!1,extensionsChanged:!1,propsOrDataChanged:!1,somethingChanged:!1}}_diffProps(e,t){const i=xC(e,t);if(i.updateTriggersChanged)for(const e in i.updateTriggersChanged)i.updateTriggersChanged[e]&&this.invalidateAttribute(e);if(i.transitionsChanged)for(const r in i.transitionsChanged)this.internalState.uniformTransitions.add(r,t[r],e[r],e.transitions?.[r]);return this.setChangeFlags(i)}validateProps(){!function(e){const t=e[Ix];for(const i in t){const r=t[i],{validate:n}=r;if(n&&!n(e[i],r))throw new Error(`Invalid prop ${i}: ${e[i]}`)}}(this.props)}updateAutoHighlight(e){this.props.autoHighlight&&!Number.isInteger(this.props.highlightedObjectIndex)&&this._updateAutoHighlight(e)}_updateAutoHighlight(e){const t={highlightedObjectColor:e.picked?e.color:null},{highlightColor:i}=this.props;e.picked&&"function"==typeof i&&(t.highlightColor=i(e)),this.setShaderModuleProps({picking:t}),this.setNeedsRedraw()}_getAttributeManager(){const e=this.context;return new mC(e.device,{id:this.props.id,stats:e.stats,timeline:e.timeline})}_postUpdate(e,t){const{props:i,oldProps:r}=e;this.setNeedsRedraw(),this._updateAttributes();const n=this.state.model;n?.isInstanced&&n.setInstanceCount(this.getNumInstances());const{autoHighlight:o,highlightedObjectIndex:s,highlightColor:a}=i;if(t||r.autoHighlight!==o||r.highlightedObjectIndex!==s||r.highlightColor!==a){const e={};Array.isArray(a)&&(e.highlightColor=a),(t||r.autoHighlight!==o||s!==r.highlightedObjectIndex)&&(e.highlightedObjectColor=Number.isFinite(s)&&s>=0?this.encodePickingColor(s):null),this.setShaderModuleProps({picking:e})}}_getUpdateParams(){return{props:this.props,oldProps:this.internalState.getOldProps(),context:this.context,changeFlags:this.internalState.changeFlags}}_getNeedsRedraw(e){if(!this.internalState)return!1;let t=!1;t=t||this.internalState.needsRedraw&&this.id;const i=this.getAttributeManager(),r=!!i&&i.getNeedsRedraw(e);if(t=t||r,t)for(const e of this.props.extensions)e.onNeedsRedraw.call(this,e);return this.internalState.needsRedraw=this.internalState.needsRedraw&&!e.clearRedrawFlags,t}_onAsyncPropUpdated(){this._diffProps(this.props,this.internalState.getOldProps()),this.setNeedsUpdate()}}JC.defaultProps=XC,JC.layerName="Layer";var YC=JC;class eB extends YC{get isComposite(){return!0}get isLoaded(){return super.isLoaded&&this.getSubLayers().every(e=>e.isLoaded)}getSubLayers(){return this.internalState&&this.internalState.subLayers||[]}initializeState(e){}setState(e){super.setState(e),this.setNeedsUpdate()}getPickingInfo({info:e}){const{object:t}=e;return t&&t.__source&&t.__source.parent&&t.__source.parent.id===this.id?(e.object=t.__source.object,e.index=t.__source.index,e):e}filterSubLayer(e){return!0}shouldRenderSubLayer(e,t){return t&&t.length}getSubLayerClass(e,t){const{_subLayerProps:i}=this.props;return i&&i[e]&&i[e].type||t}getSubLayerRow(e,t,i){return e.__source={parent:this,object:t,index:i},e}getSubLayerAccessor(e){if("function"==typeof e){const t={index:-1,data:this.props.data,target:[]};return(i,r)=>i&&i.__source?(t.index=i.__source.index,e(i.__source.object,t)):e(i,r)}return e}getSubLayerProps(e={}){const{opacity:t,pickable:i,visible:r,parameters:n,getPolygonOffset:o,highlightedObjectIndex:s,autoHighlight:a,highlightColor:l,coordinateSystem:c,coordinateOrigin:u,wrapLongitude:h,positionFormat:d,modelMatrix:p,extensions:f,fetch:m,operation:g,_subLayerProps:_}=this.props,A={id:"",updateTriggers:{},opacity:t,pickable:i,visible:r,parameters:n,getPolygonOffset:o,highlightedObjectIndex:s,autoHighlight:a,highlightColor:l,coordinateSystem:c,coordinateOrigin:u,wrapLongitude:h,positionFormat:d,modelMatrix:p,extensions:f,fetch:m,operation:g},y=_&&e.id&&_[e.id],v=y&&y.updateTriggers,x=e.id||"sublayer";if(y){const t=this.props[Ix],i=e.type?e.type._propTypes:{};for(const e in y){const r=i[e]||t[e];r&&"accessor"===r.type&&(y[e]=this.getSubLayerAccessor(y[e]))}}Object.assign(A,e,y),A.id=`${this.props.id}-${x}`,A.updateTriggers={all:this.props.updateTriggers?.all,...e.updateTriggers,...v};for(const e of f){const t=e.getSubLayerProps.call(this,e);t&&Object.assign(A,t,{updateTriggers:Object.assign(A.updateTriggers,t.updateTriggers)})}return A}_updateAutoHighlight(e){for(const t of this.getSubLayers())t.updateAutoHighlight(e)}_getAttributeManager(){return null}_postUpdate(e,t){let i=this.internalState.subLayers;const r=!i||this.needsUpdate();if(r){i=Fx(this.renderLayers(),Boolean),this.internalState.subLayers=i}ap("compositeLayer.renderLayers",this,r,i);for(const e of i)e.parent=this}}eB.layerName="CompositeLayer";var tB=eB;const iB=512,rB=Math.PI/180;function nB({map:e,gl:t,deck:i}){if(e.__deck)return e.__deck;const r=i?.props._customRender,n=i?.props.onLoad,o=aB({...i?.props,_customRender:()=>{e.triggerRepaint(),r?.("")}});let s;return i&&i.props.gl!==t||(Object.assign(o,{gl:t,width:null,height:null,touchAction:"unset",viewState:lB(e)}),i?.isInitialized?oB(i,e):o.onLoad=()=>{n?.(),oB(s,e)}),i?(s=i,i.setProps(o),i.userData.isExternal=!0):(s=new UE(o),e.on("remove",()=>{sB(e)})),s.userData.mapboxLayers=new Set,e.__deck=s,e.on("render",()=>{s.isInitialized&&function(e,t){const{mapboxLayers:i,isExternal:r}=e.userData;if(r){const r=Array.from(i,e=>e.id),n=Fx(e.props.layers,Boolean).some(e=>e&&!r.includes(e.id));let o=e.getViewports();const s=o.findIndex(e=>"mapbox"===e.id),a=o.length>1||s<0;(n||a)&&(s>=0&&(o=o.slice(),o[s]=cB(e,t,!1)),e._drawLayers("mapbox-repaint",{viewports:o,layerFilter:t=>(!e.props.layerFilter||e.props.layerFilter(t))&&("mapbox"!==t.viewport.id||!r.includes(t.layer.id)),clearCanvas:!1}))}e.userData.currentViewport=null}(s,e)}),s}function oB(e,t){const i=()=>{e.isInitialized?function(e,t){e.setProps({viewState:lB(t)}),e.needsRedraw({clearRedrawFlags:!0})}(e,t):t.off("move",i)};t.on("move",i)}function sB(e){e.__deck?.finalize(),e.__deck=null}function aB(e){return{...e,parameters:{depthMask:!0,depthTest:!0,blend:!0,blendFunc:[770,771,1,771],polygonOffsetFill:!0,depthFunc:515,blendEquation:32774,...e.parameters},views:e.views||[new Ab({id:"mapbox"})]}}function lB(e){const{lng:t,lat:i}=e.getCenter(),r={longitude:(t+540)%360-180,latitude:i,zoom:e.getZoom(),bearing:e.getBearing(),pitch:e.getPitch(),padding:e.getPadding(),repeat:e.getRenderWorldCopies()};return e.getTerrain?.()&&function(e,t){if(e.getFreeCameraOptions){const{position:i}=e.getFreeCameraOptions();if(!i||void 0===i.z)return;const r=e.transform.height,{longitude:n,latitude:o,pitch:s}=t,a=i.x*iB,l=(1-i.y)*iB,c=i.z*iB,u=Wy([n,o]),h=a-u[0],d=l-u[1],p=Math.sqrt(h*h+d*d),f=s*rB,m=1.5*r,g=f<.001?m*Math.cos(f)/c:m*Math.sin(f)/p;t.zoom=Math.log2(g);const _=c-m*Math.cos(f)/g;t.position=[0,0,_/Xy(o)]}else"number"==typeof e.transform.elevation&&(t.position=[0,0,e.transform.elevation])}(e,r),r}function cB(e,t,i=!0){return new Zv({id:"mapbox",x:0,y:0,width:e.width,height:e.height,...lB(t),nearZMultiplier:i?.02:.1,nearZ:t.transform._nearZ/t.transform.height,farZ:t.transform._farZ/t.transform.height})}function uB(e){if(e.userData.isExternal)return;const t=[];e.userData.mapboxLayers.forEach(e=>{const i=new(0,e.props.type)(e.props);t.push(i)}),e.setProps({layers:t})}class hB{constructor(e){if(!e.id)throw new Error("Layer must have an unique id");this.id=e.id,this.type="custom",this.renderingMode=e.renderingMode||"3d",this.map=null,this.deck=null,this.props=e}onAdd(e,t){var i,r;this.map=e,this.deck=nB({map:e,gl:t,deck:this.props.deck}),i=this.deck,r=this,i.userData.mapboxLayers.add(r),uB(i)}onRemove(){var e,t;this.deck&&(e=this.deck,t=this,e.userData.mapboxLayers.delete(t),uB(e))}setProps(e){Object.assign(this.props,e,{id:this.id}),this.deck&&uB(this.deck)}render(){!function(e,t,i){let{currentViewport:r}=e.userData,n=!1;r||(r=cB(e,t,!0),e.userData.currentViewport=r,n=!0),e.isInitialized&&e._drawLayers("mapbox-repaint",{viewports:[r],layerFilter:({layer:e})=>i.id===e.id||e.props.operation.includes("terrain"),clearStack:n,clearCanvas:!1})}(this.deck,this.map,this)}}const dB="__UNDEFINED__";function pB(e,t,i,r){if(!(e&&t&&e.style&&e.style._loaded))return;const n=Fx(r,Boolean);if(i!==r){const t=Fx(i,Boolean),r=new Set(t.map(e=>e.id));for(const e of n)r.delete(e.id);for(const t of r)e.getLayer(t)&&e.removeLayer(t)}for(const i of n){const r=e.getLayer(i.id);if(r){(r.implementation||r).setProps(i.props)}else e.addLayer(new hB({id:i.id,deck:t}),i.props.beforeId)}const o=e.style._order,s={};for(const e of n){let{beforeId:t}=e.props;t&&o.includes(t)||(t=dB),s[t]=s[t]||[],s[t].push(e.id)}for(const t in s){const i=s[t];let r=t===dB?o.length:o.indexOf(t),n=t===dB?void 0:t;for(let t=i.length-1;t>=0;t--){const s=i[t],a=o.indexOf(s);a!==r-1&&(e.moveLayer(s,n),a>r&&r++),r--,n=s}}}class fB{constructor(e){this._handleStyleChange=()=>{pB(this._map,this._deck,this._props.layers,this._props.layers)},this._updateContainerSize=()=>{if(this._map&&this._container){const{clientWidth:e,clientHeight:t}=this._map.getContainer();Object.assign(this._container.style,{width:`${e}px`,height:`${t}px`})}},this._updateViewState=()=>{const e=this._deck;e&&(e.setProps({viewState:lB(this._map)}),e.isInitialized&&e.redraw())},this._handleMouseEvent=e=>{const t=this._deck;if(!t||!t.isInitialized)return;const i={type:e.type,offsetCenter:e.point,srcEvent:e},r=this._lastMouseDownPoint;switch(!e.point&&r&&(i.deltaX=e.originalEvent.clientX-r.clientX,i.deltaY=e.originalEvent.clientY-r.clientY,i.offsetCenter={x:r.x+i.deltaX,y:r.y+i.deltaY}),i.type){case"mousedown":t._onPointerDown(i),this._lastMouseDownPoint={...e.point,clientX:e.originalEvent.clientX,clientY:e.originalEvent.clientY};break;case"dragstart":i.type="panstart",t._onEvent(i);break;case"drag":i.type="panmove",t._onEvent(i);break;case"dragend":i.type="panend",t._onEvent(i);break;case"click":i.tapCount=1,t._onEvent(i);break;case"dblclick":i.type="click",i.tapCount=2,t._onEvent(i);break;case"mousemove":i.type="pointermove",t._onPointerMove(i);break;case"mouseout":i.type="pointerleave",t._onPointerMove(i);break;default:return}};const{interleaved:t=!1,...i}=e;this._interleaved=t,this._props=i}setProps(e){this._interleaved&&e.layers&&pB(this._map,this._deck,this._props.layers,e.layers),Object.assign(this._props,e),this._deck&&this._deck.setProps(this._interleaved?aB(this._props):this._props)}onAdd(e){return this._map=e,this._interleaved?this._onAddInterleaved(e):this._onAddOverlaid(e)}_onAddOverlaid(e){const t=document.createElement("div");return Object.assign(t.style,{position:"absolute",left:0,top:0,textAlign:"initial",pointerEvents:"none"}),this._container=t,this._deck=new UE({...this._props,parent:t,viewState:lB(e)}),e.on("resize",this._updateContainerSize),e.on("render",this._updateViewState),e.on("mousedown",this._handleMouseEvent),e.on("dragstart",this._handleMouseEvent),e.on("drag",this._handleMouseEvent),e.on("dragend",this._handleMouseEvent),e.on("mousemove",this._handleMouseEvent),e.on("mouseout",this._handleMouseEvent),e.on("click",this._handleMouseEvent),e.on("dblclick",this._handleMouseEvent),this._updateContainerSize(),t}_onAddInterleaved(e){const t=e.painter.context.gl;return t instanceof WebGLRenderingContext&&rp.warn("Incompatible basemap library. See: https://deck.gl/docs/api-reference/mapbox/overview#compatibility")(),this._deck=nB({map:e,gl:t,deck:new UE({...this._props,gl:t})}),e.on("styledata",this._handleStyleChange),pB(e,this._deck,[],this._props.layers),document.createElement("div")}onRemove(){const e=this._map;e&&(this._interleaved?this._onRemoveInterleaved(e):this._onRemoveOverlaid(e)),this._deck=void 0,this._map=void 0,this._container=void 0}_onRemoveOverlaid(e){e.off("resize",this._updateContainerSize),e.off("render",this._updateViewState),e.off("mousedown",this._handleMouseEvent),e.off("dragstart",this._handleMouseEvent),e.off("drag",this._handleMouseEvent),e.off("dragend",this._handleMouseEvent),e.off("mousemove",this._handleMouseEvent),e.off("mouseout",this._handleMouseEvent),e.off("click",this._handleMouseEvent),e.off("dblclick",this._handleMouseEvent),this._deck?.finalize()}_onRemoveInterleaved(e){e.off("styledata",this._handleStyleChange),pB(e,this._deck,this._props.layers,[]),sB(e)}getDefaultPosition(){return"top-left"}pickObject(e){return Yx(this._deck),this._deck.pickObject(e)}pickMultipleObjects(e){return Yx(this._deck),this._deck.pickMultipleObjects(e)}pickObjects(e){return Yx(this._deck),this._deck.pickObjects(e)}finalize(){this._map&&this._map.removeControl(this)}getCanvas(){return this._map?this._interleaved?this._map.getCanvas():this._deck.getCanvas():null}}function mB(e,t){if(!e)throw new Error(t||"loader assertion failed.")}const gB=Boolean("object"!=typeof process||"[object process]"!==String(process)||process.browser),_B="undefined"!=typeof process&&process.version&&/v([0-9]*)/.exec(process.version);function AB(e,t){return yB(e||{},t)}function yB(e,t,i=0){if(i>3)return t;const r={...e};for(const[e,n]of Object.entries(t))n&&"object"==typeof n&&!Array.isArray(n)?r[e]=yB(r[e]||{},t[e],i+1):r[e]=t[e];return r}_B&&parseFloat(_B[1]);const vB=(globalThis._loadersgl_?.version||(globalThis._loadersgl_=globalThis._loadersgl_||{},globalThis._loadersgl_.version="4.2.4"),globalThis._loadersgl_.version);function xB(e,t){if(!e)throw new Error(t||"loaders.gl assertion failed.")}const bB="object"!=typeof process||"[object process]"!==String(process)||process.browser,wB="function"==typeof importScripts,TB="undefined"!=typeof window&&void 0!==window.orientation,EB="undefined"!=typeof process&&process.version&&/v([0-9]*)/.exec(process.version);EB&&parseFloat(EB[1]);class CB{name;workerThread;isRunning=!0;result;_resolve=()=>{};_reject=()=>{};constructor(e,t){this.name=e,this.workerThread=t,this.result=new Promise((e,t)=>{this._resolve=e,this._reject=t})}postMessage(e,t){this.workerThread.postMessage({source:"loaders.gl",type:e,payload:t})}done(e){xB(this.isRunning),this.isRunning=!1,this._resolve(e)}error(e){xB(this.isRunning),this.isRunning=!1,this._reject(e)}}class BB{terminate(){}}const SB=new Map;function IB(e){xB(e.source&&!e.url||!e.source&&e.url);let t=SB.get(e.source||e.url);return t||(e.url&&(t=function(e){if(!e.startsWith("http"))return e;return MB((t=e,`try {\n importScripts('${t}');\n} catch (error) {\n console.error(error);\n throw error;\n}`));var t}(e.url),SB.set(e.url,t)),e.source&&(t=MB(e.source),SB.set(e.source,t))),xB(t),t}function MB(e){const t=new Blob([e],{type:"application/javascript"});return URL.createObjectURL(t)}function PB(e,t=!0,i){const r=i||new Set;if(e){if(RB(e))r.add(e);else if(RB(e.buffer))r.add(e.buffer);else if(ArrayBuffer.isView(e));else if(t&&"object"==typeof e)for(const i in e)PB(e[i],t,r)}else;return void 0===i?Array.from(r):[]}function RB(e){return!!e&&(e instanceof ArrayBuffer||("undefined"!=typeof MessagePort&&e instanceof MessagePort||("undefined"!=typeof ImageBitmap&&e instanceof ImageBitmap||"undefined"!=typeof OffscreenCanvas&&e instanceof OffscreenCanvas)))}const LB=()=>{};class FB{name;source;url;terminated=!1;worker;onMessage;onError;_loadableURL="";static isSupported(){return"undefined"!=typeof Worker&&bB||void 0!==BB&&!bB}constructor(e){const{name:t,source:i,url:r}=e;xB(i||r),this.name=t,this.source=i,this.url=r,this.onMessage=LB,this.onError=e=>console.log(e),this.worker=bB?this._createBrowserWorker():this._createNodeWorker()}destroy(){this.onMessage=LB,this.onError=LB,this.worker.terminate(),this.terminated=!0}get isRunning(){return Boolean(this.onMessage)}postMessage(e,t){t=t||PB(e),this.worker.postMessage(e,t)}_getErrorFromErrorEvent(e){let t="Failed to load ";return t+=`worker ${this.name} from ${this.url}. `,e.message&&(t+=`${e.message} in `),e.lineno&&(t+=`:${e.lineno}:${e.colno}`),new Error(t)}_createBrowserWorker(){this._loadableURL=IB({source:this.source,url:this.url});const e=new Worker(this._loadableURL,{name:this.name});return e.onmessage=e=>{e.data?this.onMessage(e.data):this.onError(new Error("No data received"))},e.onerror=e=>{this.onError(this._getErrorFromErrorEvent(e)),this.terminated=!0},e.onmessageerror=e=>console.error(e),e}_createNodeWorker(){let e;if(this.url){const t=this.url.includes(":/")||this.url.startsWith("/")?this.url:`./${this.url}`;e=new BB(t,{eval:!1})}else{if(!this.source)throw new Error("no worker");e=new BB(this.source,{eval:!0})}return e.on("message",e=>{this.onMessage(e)}),e.on("error",e=>{this.onError(e)}),e.on("exit",e=>{}),e}}class kB{name="unnamed";source;url;maxConcurrency=1;maxMobileConcurrency=1;onDebug=()=>{};reuseWorkers=!0;props={};jobQueue=[];idleQueue=[];count=0;isDestroyed=!1;static isSupported(){return FB.isSupported()}constructor(e){this.source=e.source,this.url=e.url,this.setProps(e)}destroy(){this.idleQueue.forEach(e=>e.destroy()),this.isDestroyed=!0}setProps(e){this.props={...this.props,...e},void 0!==e.name&&(this.name=e.name),void 0!==e.maxConcurrency&&(this.maxConcurrency=e.maxConcurrency),void 0!==e.maxMobileConcurrency&&(this.maxMobileConcurrency=e.maxMobileConcurrency),void 0!==e.reuseWorkers&&(this.reuseWorkers=e.reuseWorkers),void 0!==e.onDebug&&(this.onDebug=e.onDebug)}async startJob(e,t=(e,t,i)=>e.done(i),i=(e,t)=>e.error(t)){const r=new Promise(r=>(this.jobQueue.push({name:e,onMessage:t,onError:i,onStart:r}),this));return this._startQueuedJob(),await r}async _startQueuedJob(){if(!this.jobQueue.length)return;const e=this._getAvailableWorker();if(!e)return;const t=this.jobQueue.shift();if(t){this.onDebug({message:"Starting job",name:t.name,workerThread:e,backlog:this.jobQueue.length});const i=new CB(t.name,e);e.onMessage=e=>t.onMessage(i,e.type,e.payload),e.onError=e=>t.onError(i,e),t.onStart(i);try{await i.result}catch(e){console.error(`Worker exception: ${e}`)}finally{this.returnWorkerToQueue(e)}}}returnWorkerToQueue(e){!bB||this.isDestroyed||!this.reuseWorkers||this.count>this._getMaxConcurrency()?(e.destroy(),this.count--):this.idleQueue.push(e),this.isDestroyed||this._startQueuedJob()}_getAvailableWorker(){if(this.idleQueue.length>0)return this.idleQueue.shift()||null;if(this.count{}};class OB{props;workerPools=new Map;static _workerFarm;static isSupported(){return FB.isSupported()}static getWorkerFarm(e={}){return OB._workerFarm=OB._workerFarm||new OB({}),OB._workerFarm.setProps(e),OB._workerFarm}constructor(e){this.props={...DB},this.setProps(e),this.workerPools=new Map}destroy(){for(const e of this.workerPools.values())e.destroy();this.workerPools=new Map}setProps(e){this.props={...this.props,...e};for(const e of this.workerPools.values())e.setProps(this._getWorkerPoolProps())}getWorkerPool(e){const{name:t,source:i,url:r}=e;let n=this.workerPools.get(t);return n||(n=new kB({name:t,source:i,url:r}),n.setProps(this._getWorkerPoolProps()),this.workerPools.set(t,n)),n}_getWorkerPoolProps(){return{maxConcurrency:this.props.maxConcurrency,maxMobileConcurrency:this.props.maxMobileConcurrency,reuseWorkers:this.props.reuseWorkers,onDebug:this.props.onDebug}}}const zB={};async function UB(e,t=null,i={},r=null){return t&&(e=function(e,t,i={},r=null){if(!i.useLocalLibraries&&e.startsWith("http"))return e;r=r||e;const n=i.modules||{};if(n[r])return n[r];if(!bB)return`modules/${t}/dist/libs/${r}`;if(i.CDN)return xB(i.CDN.startsWith("http")),`${i.CDN}/${t}@${vB}/dist/libs/${r}`;if(wB)return`../src/libs/${r}`;return`modules/${t}/src/libs/${r}`}(e,t,i,r)),zB[e]=zB[e]||async function(e){if(e.endsWith("wasm"))return await async function(e){const{readFileAsArrayBuffer:t}=globalThis.loaders||{};if(bB||!t||e.startsWith("http")){const t=await fetch(e);return await t.arrayBuffer()}return await t(e)}(e);if(!bB)try{const{requireFromFile:t}=globalThis.loaders||{};return await(t?.(e))}catch(e){return console.error(e),null}if(wB)return importScripts(e);const t=await async function(e){const{readFileAsText:t}=globalThis.loaders||{};if(bB||!t||e.startsWith("http")){const t=await fetch(e);return await t.text()}return await t(e)}(e);return function(e,t){if(!bB){const{requireFromString:i}=globalThis.loaders||{};return i?.(e,t)}if(wB)return eval.call(globalThis,e),null;const i=document.createElement("script");i.id=t;try{i.appendChild(document.createTextNode(e))}catch(t){i.text=e}return document.body.appendChild(i),null}(t,e)}(e),await zB[e]}async function NB(e,t,i,r,n){const o=e.id,s=function(e,t={}){const i=t[e.id]||{},r=bB?`${e.id}-worker.js`:`${e.id}-worker-node.js`;let n=i.workerUrl;if(n||"compression"!==e.id||(n=t.workerUrl),"test"===t._workerType&&(n=bB?`modules/${e.module}/dist/${r}`:`modules/${e.module}/src/workers/${e.id}-worker-node.ts`),!n){let t=e.version;"latest"===t&&(t="latest");const i=t?`@${t}`:"";n=`https://unpkg.com/@loaders.gl/${e.module}${i}/dist/${r}`}return xB(n),n}(e,i),a=OB.getWorkerFarm(i).getWorkerPool({name:o,url:s});i=JSON.parse(JSON.stringify(i)),r=JSON.parse(JSON.stringify(r||{}));const l=await a.startJob("process-on-worker",VB.bind(null,n));l.postMessage("process",{input:t,options:i,context:r});const c=await l.result;return await c.result}async function VB(e,t,i,r){switch(i){case"done":t.done(r);break;case"error":t.error(new Error(r.error));break;case"process":const{id:n,input:o,options:s}=r;try{const i=await e(o,s);t.postMessage("done",{id:n,result:i})}catch(e){const i=e instanceof Error?e.message:"unknown error";t.postMessage("error",{id:n,error:i})}break;default:console.warn(`parse-with-worker unknown message ${i}`)}}function jB(...e){return function(e){const t=e.map(e=>e instanceof ArrayBuffer?new Uint8Array(e):e),i=t.reduce((e,t)=>e+t.byteLength,0),r=new Uint8Array(i);let n=0;for(const e of t)r.set(e,n),n+=e.byteLength;return r.buffer}(e)}const GB={};function HB(e){if((t=e)&&"object"==typeof t&&t.isBuffer)return e;var t;if(e instanceof ArrayBuffer)return e;if(ArrayBuffer.isView(e))return 0===e.byteOffset&&e.byteLength===e.buffer.byteLength?e.buffer:e.buffer.slice(e.byteOffset,e.byteOffset+e.byteLength);if("string"==typeof e){const t=e;return(new TextEncoder).encode(t).buffer}if(e&&"object"==typeof e&&e._toArrayBuffer)return e._toArrayBuffer();throw new Error("toArrayBuffer")}function QB(e){const t=e?e.lastIndexOf("/"):-1;return t>=0?e.substr(t+1):""}const $B=e=>"function"==typeof e,ZB=e=>null!==e&&"object"==typeof e,WB=e=>ZB(e)&&e.constructor==={}.constructor,qB=e=>"undefined"!=typeof Response&&e instanceof Response||e&&e.arrayBuffer&&e.text&&e.json,KB=e=>"undefined"!=typeof Blob&&e instanceof Blob,XB=e=>(e=>"undefined"!=typeof ReadableStream&&e instanceof ReadableStream||ZB(e)&&$B(e.tee)&&$B(e.cancel)&&$B(e.getReader))(e)||(e=>ZB(e)&&$B(e.read)&&$B(e.pipe)&&(e=>"boolean"==typeof e)(e.readable))(e);class JB extends Error{constructor(e,t){super(e),this.reason=t.reason,this.url=t.url,this.response=t.response}reason;url;response}const YB=/^data:([-\w.]+\/[-\w.+]+)(;|,)/,eS=/^([-\w.]+\/[-\w.+]+)/;function tS(e,t){return e.toLowerCase()===t.toLowerCase()}function iS(e){const t=YB.exec(e);return t?t[1]:""}const rS=/\?.*/;function nS(e){return e.replace(rS,"")}function oS(e){if(qB(e)){return e.url}if(KB(e)){return e.name||""}return"string"==typeof e?e:""}function sS(e){if(qB(e)){const t=e,i=t.headers.get("content-type")||"",r=nS(t.url);return function(e){const t=eS.exec(e);return t?t[1]:e}(i)||iS(r)}if(KB(e)){return e.type||""}return"string"==typeof e?iS(e):""}async function aS(e){if(qB(e))return e;const t={},i=function(e){if(qB(e))return e.headers["content-length"]||-1;if(KB(e))return e.size;return"string"==typeof e?e.length:e instanceof ArrayBuffer||ArrayBuffer.isView(e)?e.byteLength:-1}(e);i>=0&&(t["content-length"]=String(i));const r=oS(e),n=sS(e);n&&(t["content-type"]=n);const o=await async function(e){const t=5;if("string"==typeof e)return`data:,${e.slice(0,t)}`;if(e instanceof Blob){const t=e.slice(0,5);return await new Promise(e=>{const i=new FileReader;i.onload=t=>e(t?.target?.result),i.readAsDataURL(t)})}if(e instanceof ArrayBuffer){const i=function(e){let t="";const i=new Uint8Array(e);for(let e=0;e100?`${i.slice(0,100)}...`:i;const r={reason:e.statusText,url:e.url,response:e};try{const t=e.headers.get("Content-Type");r.reason=t?.includes("application/json")?await e.json():e.text()}catch(e){}return new JB(i,r)}(e);throw t}}async function cS(e,t){if("string"==typeof e){const i=function(e){for(const t in GB)if(e.startsWith(t)){const i=GB[t];e=e.replace(t,i)}return e.startsWith("http://")||e.startsWith("https://")||(e=`${e}`),e}(e);return function(e){return!function(e){return e.startsWith("http:")||e.startsWith("https:")}(e)&&!function(e){return e.startsWith("data:")}(e)}(i)&&globalThis.loaders?.fetchNode?globalThis.loaders?.fetchNode(i,t):await fetch(i,t)}return await aS(e)}const uS=new Gu({id:"loaders.gl"});class hS{log(){return()=>{}}info(){return()=>{}}warn(){return()=>{}}error(){return()=>{}}}const dS={fetch:null,mimeType:void 0,nothrow:!1,log:new class{console;constructor(){this.console=console}log(...e){return this.console.log.bind(this.console,...e)}info(...e){return this.console.info.bind(this.console,...e)}warn(...e){return this.console.warn.bind(this.console,...e)}error(...e){return this.console.error.bind(this.console,...e)}},useLocalLibraries:!1,CDN:"https://unpkg.com/@loaders.gl",worker:!0,maxConcurrency:3,maxMobileConcurrency:1,reuseWorkers:gB,_nodeWorkers:!1,_workerType:"",limit:0,_limitMB:0,batchSize:"auto",batchDebounceMs:0,metadata:!1,transforms:[]},pS={throws:"nothrow",dataType:"(no longer used)",uri:"baseUri",method:"fetch.method",headers:"fetch.headers",body:"fetch.body",mode:"fetch.mode",credentials:"fetch.credentials",cache:"fetch.cache",redirect:"fetch.redirect",referrer:"fetch.referrer",referrerPolicy:"fetch.referrerPolicy",integrity:"fetch.integrity",keepalive:"fetch.keepalive",signal:"fetch.signal"};function fS(){globalThis.loaders=globalThis.loaders||{};const{loaders:e}=globalThis;return e._state||(e._state={}),e._state}function mS(){const e=fS();return e.globalOptions=e.globalOptions||{...dS},e.globalOptions}function gS(e,t,i,r){return i=i||[],function(e,t){_S(e,null,dS,pS,t);for(const i of t){const r=e&&e[i.id]||{},n=i.options&&i.options[i.id]||{},o=i.deprecatedOptions&&i.deprecatedOptions[i.id]||{};_S(r,i.id,n,o,t)}}(e,i=Array.isArray(i)?i:[i]),function(e,t,i){const r=e.options||{},n={...r};(function(e,t){t&&!("baseUri"in e)&&(e.baseUri=t)})(n,i),null===n.log&&(n.log=new hS);return yS(n,mS()),yS(n,t),n}(t,e,r)}function _S(e,t,i,r,n){const o=t||"Top level",s=t?`${t}.`:"";for(const a in e){const l=!t&&ZB(e[a]);if(!(a in i)&&!("baseUri"===a&&!t)&&!("workerUrl"===a&&t))if(a in r)uS.warn(`${o} loader option '${s}${a}' no longer supported, use '${r[a]}'`)();else if(!l){const e=AS(a,n);uS.warn(`${o} loader option '${s}${a}' not recognized. ${e}`)()}}}function AS(e,t){const i=e.toLowerCase();let r="";for(const n of t)for(const t in n.options){if(e===t)return`Did you mean '${n.id}.${t}'?`;const o=t.toLowerCase();(i.startsWith(o)||o.startsWith(i))&&(r=r||`Did you mean '${n.id}.${t}'?`)}return r}function yS(e,t){for(const i in t)if(i in t){const r=t[i];WB(r)&&WB(e[i])?e[i]={...e[i],...t[i]}:e[i]=t[i]}}function vS(e){if(!e)return!1;Array.isArray(e)&&(e=e[0]);return Array.isArray(e?.extensions)}function xS(e){let t;return mB(e,"null loader"),mB(vS(e),"invalid loader"),Array.isArray(e)&&(t=e[1],e=e[0],e={...e,options:{...e.options,...t}}),(e?.parseTextSync||e?.parseText)&&(e.text=!0),e.text||(e.binary=!0),e}function bS(){return(()=>{const e=fS();return e.loaderRegistry=e.loaderRegistry||[],e.loaderRegistry})()}const wS=new Gu({id:"loaders.gl"}),TS=/\.([^.]+)$/;function ES(e,t=[],i,r){if(!CS(e))return null;if(t&&!Array.isArray(t))return xS(t);let n=[];t&&(n=n.concat(t)),i?.ignoreRegisteredLoaders||n.push(...bS()),function(e){for(const t of e)xS(t)}(n);const o=function(e,t,i,r){const n=oS(e),o=sS(e),s=nS(n)||r?.url;let a=null,l="";i?.mimeType&&(a=SS(t,i?.mimeType),l=`match forced by supplied MIME type ${i?.mimeType}`);a=a||function(e,t){const i=t&&TS.exec(t),r=i&&i[1];return r?function(e,t){t=t.toLowerCase();for(const i of e)for(const e of i.extensions)if(e.toLowerCase()===t)return i;return null}(e,r):null}(t,s),l=l||(a?`matched url ${s}`:""),a=a||SS(t,o),l=l||(a?`matched MIME type ${o}`:""),a=a||function(e,t){if(!t)return null;for(const i of e)if("string"==typeof t){if(IS(t,i))return i}else if(ArrayBuffer.isView(t)){if(MS(t.buffer,t.byteOffset,i))return i}else if(t instanceof ArrayBuffer){if(MS(t,0,i))return i}return null}(t,e),l=l||(a?`matched initial data ${PS(e)}`:""),i?.fallbackMimeType&&(a=a||SS(t,i?.fallbackMimeType),l=l||(a?`matched fallback MIME type ${o}`:""));l&&wS.log(1,`selectLoader selected ${a?.name}: ${l}.`);return a}(e,n,i,r);if(!o&&!i?.nothrow)throw new Error(BS(e));return o}function CS(e){return!(e instanceof Response&&204===e.status)}function BS(e){const t=oS(e),i=sS(e);let r="No valid loader found (";r+=t?`${QB(t)}, `:"no url provided, ",r+=`MIME type: ${i?`"${i}"`:"not provided"}, `;const n=e?PS(e):"";return r+=n?` first bytes: "${n}"`:"first bytes: not available",r+=")",r}function SS(e,t){for(const i of e){if(i.mimeTypes?.some(e=>tS(t,e)))return i;if(tS(t,`application/x.${i.id}`))return i}return null}function IS(e,t){if(t.testText)return t.testText(e);return(Array.isArray(t.tests)?t.tests:[t.tests]).some(t=>e.startsWith(t))}function MS(e,t,i){return(Array.isArray(i.tests)?i.tests:[i.tests]).some(i=>function(e,t,i,r){if(r instanceof ArrayBuffer)return function(e,t,i){if(i=i||e.byteLength,e.byteLengthe&&"object"==typeof e&&e.isBuffer)(e)&&(e=e.buffer),e instanceof ArrayBuffer){const i=e;return t.text&&!t.binary?new TextDecoder("utf8").decode(i):i}if(ArrayBuffer.isView(e)){if(t.text&&!t.binary)return new TextDecoder("utf8").decode(e);let i=e.buffer;const r=e.byteLength||e.length;return 0===e.byteOffset&&r===i.byteLength||(i=i.slice(e.byteOffset,e.byteOffset+r)),i}throw new Error(DS)}(e,t);if(KB(e)&&(e=await aS(e)),qB(e)){const i=e;return await lS(i),t.binary?await i.arrayBuffer():await i.text()}if(XB(e)&&(e=kS(e,i)),(e=>Boolean(e)&&"function"==typeof e[Symbol.iterator])(e)||(e=>e&&"function"==typeof e[Symbol.asyncIterator])(e))return async function(e){const t=[];for await(const i of e)t.push(i);return jB(...t)}(e);throw new Error(DS)}function zS(e,t){const i=mS(),r=e||i;return"function"==typeof r.fetch?r.fetch:ZB(r.fetch)?e=>cS(e,r.fetch):t?.fetch?t?.fetch:cS}function US(e,t,i){if(i)return i;const r={fetch:zS(t,e),...e};if(r.url){const e=nS(r.url);r.baseUrl=e,r.queryString=function(e){const t=e.match(rS);return t&&t[0]}(r.url),r.filename=QB(e),r.baseUrl=function(e){const t=e?e.lastIndexOf("/"):-1;return t>=0?e.substr(0,t):""}(e)}return Array.isArray(r.loaders)||(r.loaders=null),r}async function NS(e,t,i,r){!t||Array.isArray(t)||vS(t)||(r=void 0,i=t,t=void 0),i=i||{};const n=oS(e=await e),o=function(e,t){if(e&&!Array.isArray(e))return e;let i;if(e&&(i=Array.isArray(e)?e:[e]),t&&t.loaders){const e=Array.isArray(t.loaders)?t.loaders:[t.loaders];i=i?[...i,...e]:e}return i&&i.length?i:void 0}(t,r),s=await async function(e,t=[],i,r){if(!CS(e))return null;let n=ES(e,t,{...i,nothrow:!0},r);if(n)return n;if(KB(e)&&(n=ES(e=await e.slice(0,10).arrayBuffer(),t,i,r)),!n&&!i?.nothrow)throw new Error(BS(e));return n}(e,o,i);return s?(r=US({url:n,_parse:NS,loaders:o},i=gS(i,s,o,n),r||null),await async function(e,t,i,r){if(function(e){xB(e,"no worker provided");const t=e.version}(e),i=AB(e.options,i),qB(t)){const e=t,{ok:i,redirected:n,status:o,statusText:s,type:a,url:l}=e,c=Object.fromEntries(e.headers.entries());r.response={headers:c,ok:i,redirected:n,status:o,statusText:s,type:a,url:l}}t=await OS(t,e,i);const n=e;if(n.parseTextSync&&"string"==typeof t)return n.parseTextSync(t,i,r);if(function(e,t){return!!OB.isSupported()&&!(!bB&&!t?._nodeWorkers)&&e.worker&&t?.worker}(e,i))return await NB(e,t,i,r,NS);if(n.parseText&&"string"==typeof t)return await n.parseText(t,i,r);if(n.parse)return await n.parse(t,i,r);throw xB(!n.parseSync),new Error(`${e.id} loader - no parser found and worker is disabled`)}(s,e,i,r)):null}async function VS(e,t,i,r){let n,o;Array.isArray(t)||vS(t)?(n=t,o=i):(n=[],o=t);const s=zS(o);let a=e;return"string"==typeof e&&(a=await s(e)),KB(e)&&(a=await s(e)),Array.isArray(n),await NS(a,n,o)}const jS=[0,0,0,255],GS=[0,0,1],HS={sizeUnits:"pixels",pointSize:{type:"number",min:0,value:10},getPosition:{type:"accessor",value:e=>e.position},getNormal:{type:"accessor",value:GS},getColor:{type:"accessor",value:jS},material:!0,radiusPixels:{deprecatedFor:"pointSize"}};class QS extends YC{getShaders(){return super.getShaders({vs:"#version 300 es\n#define SHADER_NAME point-cloud-layer-vertex-shader\nin vec3 positions;\nin vec3 instanceNormals;\nin vec4 instanceColors;\nin vec3 instancePositions;\nin vec3 instancePositions64Low;\nin vec3 instancePickingColors;\nuniform float opacity;\nuniform float radiusPixels;\nuniform int sizeUnits;\nout vec4 vColor;\nout vec2 unitPosition;\nvoid main(void) {\ngeometry.worldPosition = instancePositions;\ngeometry.normal = project_normal(instanceNormals);\nunitPosition = positions.xy;\ngeometry.uv = unitPosition;\ngeometry.pickingColor = instancePickingColors;\nvec3 offset = vec3(positions.xy * project_size_to_pixel(radiusPixels, sizeUnits), 0.0);\nDECKGL_FILTER_SIZE(offset, geometry);\ngl_Position = project_position_to_clipspace(instancePositions, instancePositions64Low, vec3(0.), geometry.position);\nDECKGL_FILTER_GL_POSITION(gl_Position, geometry);\ngl_Position.xy += project_pixel_size_to_clipspace(offset.xy);\nvec3 lightColor = lighting_getLightColor(instanceColors.rgb, project_uCameraPosition, geometry.position.xyz, geometry.normal);\nvColor = vec4(lightColor, instanceColors.a * opacity);\nDECKGL_FILTER_COLOR(vColor, geometry);\n}\n",fs:"#version 300 es\n#define SHADER_NAME point-cloud-layer-fragment-shader\nprecision highp float;\nin vec4 vColor;\nin vec2 unitPosition;\nout vec4 fragColor;\nvoid main(void) {\ngeometry.uv = unitPosition;\nfloat distToCenter = length(unitPosition);\nif (distToCenter > 1.0) {\ndiscard;\n}\nfragColor = vColor;\nDECKGL_FILTER_COLOR(fragColor, geometry);\n}\n",modules:[Fy,py,dv]})}initializeState(){this.getAttributeManager().addInstanced({instancePositions:{size:3,type:"float64",fp64:this.use64bitPositions(),transition:!0,accessor:"getPosition"},instanceNormals:{size:3,transition:!0,accessor:"getNormal",defaultValue:GS},instanceColors:{size:this.props.colorFormat.length,type:"unorm8",transition:!0,accessor:"getColor",defaultValue:jS}})}updateState(e){const{changeFlags:t,props:i}=e;super.updateState(e),t.extensionsChanged&&(this.state.model?.destroy(),this.state.model=this._getModel(),this.getAttributeManager().invalidateAll()),t.dataChanged&&function(e){const{header:t,attributes:i}=e;if(t&&i&&(e.length=t.vertexCount,i.POSITION&&(i.instancePositions=i.POSITION),i.NORMAL&&(i.instanceNormals=i.NORMAL),i.COLOR_0)){const{size:e,value:t}=i.COLOR_0;i.instanceColors={size:e,type:"unorm8",value:t}}}(i.data)}draw({uniforms:e}){const{pointSize:t,sizeUnits:i}=this.props,r=this.state.model;r.setUniforms(e),r.setUniforms({sizeUnits:vy[i],radiusPixels:t}),r.draw(this.context.renderPass)}_getModel(){const e=[];for(let t=0;t<3;t++){const i=t/3*Math.PI*2;e.push(2*Math.cos(i),2*Math.sin(i),0)}return new hx(this.context.device,{...this.getShaders(),id:this.props.id,bufferLayout:this.getAttributeManager().getBufferLayouts(),geometry:new mx({topology:"triangle-list",attributes:{positions:new Float32Array(e)}}),isInstanced:!0})}}QS.layerName="PointCloudLayer",QS.defaultProps=HS;var $S=QS;const ZS=-1,WS=0,qS=1;new mA,new mA;const KS=new mA,XS=new mA;class JS{constructor(e=[0,0,0],t=0){this.radius=-0,this.center=new mA,this.fromCenterRadius(e,t)}fromCenterRadius(e,t){return this.center.from(e),this.radius=t,this}fromCornerPoints(e,t){return t=KS.from(t),this.center=(new mA).from(e).add(t).scale(.5),this.radius=this.center.distance(t),this}equals(e){return this===e||Boolean(e)&&this.center.equals(e.center)&&this.radius===e.radius}clone(){return new JS(this.center,this.radius)}union(e){const t=this.center,i=this.radius,r=e.center,n=e.radius,o=KS.copy(r).subtract(t),s=o.magnitude();if(i>=s+n)return this.clone();if(n>=s+i)return e.clone();const a=.5*(i+s+n);return XS.copy(o).scale((-i+a)/s).add(t),this.center.copy(XS),this.radius=a,this}expand(e){const t=KS.from(e).subtract(this.center).magnitude();return t>this.radius&&(this.radius=t),this}transform(e){this.center.transform(e);const t=function(e,t){const i=t[0],r=t[1],n=t[2],o=t[4],s=t[5],a=t[6],l=t[8],c=t[9],u=t[10];return e[0]=Math.sqrt(i*i+r*r+n*n),e[1]=Math.sqrt(o*o+s*s+a*a),e[2]=Math.sqrt(l*l+c*c+u*u),e}(KS,e);return this.radius=Math.max(t[0],Math.max(t[1],t[2]))*this.radius,this}distanceSquaredTo(e){const t=this.distanceTo(e);return t*t}distanceTo(e){const t=KS.from(e).subtract(this.center);return Math.max(0,t.len()-this.radius)}intersectPlane(e){const t=this.center,i=this.radius,r=e.normal.dot(t)+e.distance;return r<-i?ZS:r=a?qS:WS}distanceTo(e){return Math.sqrt(this.distanceSquaredTo(e))}distanceSquaredTo(e){const t=eI.from(e).subtract(this.center),i=this.halfAxes,r=i.getColumn(0,tI),n=i.getColumn(1,iI),o=i.getColumn(2,rI),s=r.magnitude(),a=n.magnitude(),l=o.magnitude();r.normalize(),n.normalize(),o.normalize();let c,u=0;return c=Math.abs(t.dot(r))-s,c>0&&(u+=c*c),c=Math.abs(t.dot(n))-a,c>0&&(u+=c*c),c=Math.abs(t.dot(o))-l,c>0&&(u+=c*c),u}computePlaneDistances(e,t,i=[-0,-0]){let r=Number.POSITIVE_INFINITY,n=Number.NEGATIVE_INFINITY;const o=this.center,s=this.halfAxes,a=s.getColumn(0,tI),l=s.getColumn(1,iI),c=s.getColumn(2,rI),u=nI.copy(a).add(l).add(c).add(o),h=oI.copy(u).subtract(e);let d=t.dot(h);return r=Math.min(d,r),n=Math.max(d,n),u.copy(o).add(a).add(l).subtract(c),h.copy(u).subtract(e),d=t.dot(h),r=Math.min(d,r),n=Math.max(d,n),u.copy(o).add(a).subtract(l).add(c),h.copy(u).subtract(e),d=t.dot(h),r=Math.min(d,r),n=Math.max(d,n),u.copy(o).add(a).subtract(l).subtract(c),h.copy(u).subtract(e),d=t.dot(h),r=Math.min(d,r),n=Math.max(d,n),o.copy(u).subtract(a).add(l).add(c),h.copy(u).subtract(e),d=t.dot(h),r=Math.min(d,r),n=Math.max(d,n),o.copy(u).subtract(a).add(l).subtract(c),h.copy(u).subtract(e),d=t.dot(h),r=Math.min(d,r),n=Math.max(d,n),o.copy(u).subtract(a).subtract(l).add(c),h.copy(u).subtract(e),d=t.dot(h),r=Math.min(d,r),n=Math.max(d,n),o.copy(u).subtract(a).subtract(l).subtract(c),h.copy(u).subtract(e),d=t.dot(h),r=Math.min(d,r),n=Math.max(d,n),i[0]=r,i[1]=n,i}transform(e){this.center.transformAsPoint(e);const t=this.halfAxes.getColumn(0,tI);t.transformAsPoint(e);const i=this.halfAxes.getColumn(1,iI);i.transformAsPoint(e);const r=this.halfAxes.getColumn(2,rI);return r.transformAsPoint(e),this.halfAxes=new bA([...t,...i,...r]),this}getTransform(){throw new Error("not implemented")}}const gI=new mA,_I=new mA;class AI{constructor(e=[0,0,1],t=0){this.normal=new mA,this.distance=-0,this.fromNormalDistance(e,t)}fromNormalDistance(e,t){return H_(Number.isFinite(t)),this.normal.from(e).normalize(),this.distance=t,this}fromPointNormal(e,t){e=gI.from(e),this.normal.from(t).normalize();const i=-this.normal.dot(e);return this.distance=i,this}fromCoefficients(e,t,i,r){return this.normal.set(e,t,i),H_(U_(this.normal.len(),1)),this.distance=r,this}clone(){return new AI(this.normal,this.distance)}equals(e){return U_(this.distance,e.distance)&&U_(this.normal,e.normal)}getPointDistance(e){return this.normal.dot(e)+this.distance}transform(e){const t=_I.copy(this.normal).transformAsVector(e).normalize(),i=this.normal.scale(-this.distance).transform(e);return this.fromPointNormal(i,t)}projectPointOntoPlane(e,t=[0,0,0]){const i=gI.from(e),r=this.getPointDistance(i),n=_I.copy(this.normal).scale(r);return i.subtract(n).to(t)}}const yI=[new mA([1,0,0]),new mA([0,1,0]),new mA([0,0,1])],vI=new mA,xI=new mA;class bI{constructor(e=[]){this.planes=e}fromBoundingSphere(e){this.planes.length=2*yI.length;const t=e.center,i=e.radius;let r=0;for(const e of yI){let n=this.planes[r],o=this.planes[r+1];n||(n=this.planes[r]=new AI),o||(o=this.planes[r+1]=new AI);const s=vI.copy(e).scale(-i).add(t);n.fromPointNormal(s,e);const a=vI.copy(e).scale(i).add(t),l=xI.copy(e).negate();o.fromPointNormal(a,l),r+=2}return this}computeVisibility(e){let t=qS;for(const i of this.planes){switch(e.intersectPlane(i)){case ZS:return ZS;case WS:t=WS}}return t}computeVisibilityWithPlaneMask(e,t){if(H_(Number.isFinite(t),"parentPlaneMask is required."),t===bI.MASK_OUTSIDE||t===bI.MASK_INSIDE)return t;let i=bI.MASK_INSIDE;const r=this.planes;for(let n=0;ns;)RI(o,CI),BI.copy(CI).transpose(),o.multiplyRight(CI),o.multiplyLeft(BI),n.multiplyRight(CI),++i>2&&(++r,i=0);return t.unitary=n.toTarget(t.unitary),t.diagonal=o.toTarget(t.diagonal),t}const II=[1,0,0],MI=[2,2,1];function PI(e){let t=0;for(let i=0;i<3;++i){const r=e[wI.getElementIndex(MI[i],II[i])];t+=2*r*r}return Math.sqrt(t)}function RI(e,t){let i=0,r=1;for(let t=0;t<3;++t){const n=Math.abs(e[wI.getElementIndex(MI[t],II[t])]);n>i&&(r=t,i=n)}const n=II[r],o=MI[r];let s=1,a=0;if(Math.abs(e[wI.getElementIndex(o,n)])>1e-15){const t=(e[wI.getElementIndex(o,o)]-e[wI.getElementIndex(n,n)])/2/e[wI.getElementIndex(o,n)];let i;i=t<0?-1/(-t+Math.sqrt(1+t*t)):1/(t+Math.sqrt(1+t*t)),s=1/Math.sqrt(1+i*i),a=i*s}return bA.IDENTITY.to(t),t[wI.getElementIndex(n,n)]=t[wI.getElementIndex(o,o)]=s,t[wI.getElementIndex(o,n)]=a,t[wI.getElementIndex(n,o)]=-a,t}const LI=new mA,FI=new mA,kI=new mA,DI=new mA,OI=new mA,zI=new bA,UI={diagonal:new bA,unitary:new bA};function NI(e,t=new mI){if(!e||0===e.length)return t.halfAxes=new bA([0,0,0,0,0,0,0,0,0]),t.center=new mA,t;const i=e.length,r=new mA(0,0,0);for(const t of e)r.add(t);const n=1/i;r.multiplyByScalar(n);let o=0,s=0,a=0,l=0,c=0,u=0;for(const t of e){const e=LI.copy(t).subtract(r);o+=e.x*e.x,s+=e.x*e.y,a+=e.x*e.z,l+=e.y*e.y,c+=e.y*e.z,u+=e.z*e.z}o*=n,s*=n,a*=n,l*=n,c*=n,u*=n;const h=zI;h[0]=o,h[1]=s,h[2]=a,h[3]=s,h[4]=l,h[5]=c,h[6]=a,h[7]=c,h[8]=u;const{unitary:d}=SI(h,UI),p=t.halfAxes.copy(d);let f=p.getColumn(0,kI),m=p.getColumn(1,DI),g=p.getColumn(2,OI),_=-Number.MAX_VALUE,A=-Number.MAX_VALUE,y=-Number.MAX_VALUE,v=Number.MAX_VALUE,x=Number.MAX_VALUE,b=Number.MAX_VALUE;for(const t of e)LI.copy(t),_=Math.max(LI.dot(f),_),A=Math.max(LI.dot(m),A),y=Math.max(LI.dot(g),y),v=Math.min(LI.dot(f),v),x=Math.min(LI.dot(m),x),b=Math.min(LI.dot(g),b);f=f.multiplyByScalar(.5*(v+_)),m=m.multiplyByScalar(.5*(x+A)),g=g.multiplyByScalar(.5*(b+y)),t.center.copy(f).add(m).add(g);const w=FI.set(_-v,A-x,y-b).multiplyByScalar(.5),T=new bA([w[0],0,0,0,w[1],0,0,0,w[2]]);return t.halfAxes.multiplyRight(T),t}const VI=Math.PI/180,jI=new Float32Array(16),GI=new Float32Array(12);function HI(e,t,i){const r=t[0]*VI,n=t[1]*VI,o=t[2]*VI,s=Math.sin(o),a=Math.sin(r),l=Math.sin(n),c=Math.cos(o),u=Math.cos(r),h=Math.cos(n),d=i[0],p=i[1],f=i[2];e[0]=d*h*u,e[1]=d*l*u,e[2]=d*-a,e[3]=p*(-l*c+h*a*s),e[4]=p*(h*c+l*a*s),e[5]=p*u*s,e[6]=f*(l*s+h*a*c),e[7]=f*(-h*s+l*a*c),e[8]=f*u*c}function QI(e){return e[0]=e[0],e[1]=e[1],e[2]=e[2],e[3]=e[4],e[4]=e[5],e[5]=e[6],e[6]=e[8],e[7]=e[9],e[8]=e[10],e[9]=e[12],e[10]=e[13],e[11]=e[14],e.subarray(0,12)}const $I={size:12,accessor:["getOrientation","getScale","getTranslation","getTransformMatrix"],shaderAttributes:{instanceModelMatrixCol0:{size:3,elementOffset:0},instanceModelMatrixCol1:{size:3,elementOffset:3},instanceModelMatrixCol2:{size:3,elementOffset:6},instanceTranslation:{size:3,elementOffset:9}},update(e,{startRow:t,endRow:i}){const{data:r,getOrientation:n,getScale:o,getTranslation:s,getTransformMatrix:a}=this.props,l=Array.isArray(a),c=l&&16===a.length,u=Array.isArray(o),h=Array.isArray(n),d=Array.isArray(s),p=c||!l&&Boolean(a(r[0]));e.constant=p?c:h&&u&&d;const f=e.value;if(e.constant){let t;if(p)jI.set(a),t=QI(jI);else{t=GI;HI(t,n,o),t.set(s,9)}e.value=new Float32Array(t)}else{let l=t*e.size;const{iterable:m,objectInfo:g}=ZE(r,t,i);for(const e of m){let t;if(g.index++,p)jI.set(c?a:a(e,g)),t=QI(jI);else{t=GI;HI(t,h?n:n(e,g),u?o:o(e,g)),t.set(d?s:s(e,g),9)}f[l++]=t[0],f[l++]=t[1],f[l++]=t[2],f[l++]=t[3],f[l++]=t[4],f[l++]=t[5],f[l++]=t[6],f[l++]=t[7],f[l++]=t[8],f[l++]=t[9],f[l++]=t[10],f[l++]=t[11]}}}};function ZI(e,t){return t===Ay.CARTESIAN||t===Ay.METER_OFFSETS||t===Ay.DEFAULT&&!e.isGeospatial}function WI(e){const t=e.positions||e.POSITION;rp.assert(t,'no "postions" or "POSITION" attribute in mesh');const i=t.value.length/t.size;let r=e.COLOR_0||e.colors;r||(r={size:3,value:new Float32Array(3*i).fill(1)});let n=e.NORMAL||e.normals;n||(n={size:3,value:new Float32Array(3*i).fill(0)});let o=e.TEXCOORD_0||e.texCoords;return o||(o={size:2,value:new Float32Array(2*i).fill(0)}),{positions:t,colors:r,normals:n,texCoords:o}}function qI(e){return e instanceof mx?(e.attributes=WI(e.attributes),e):e.attributes?new mx({...e,topology:"triangle-list",attributes:WI(e.attributes)}):new mx({topology:"triangle-list",attributes:WI(e)})}const KI={mesh:{type:"object",value:null,async:!0},texture:{type:"image",value:null,async:!0},sizeScale:{type:"number",value:1,min:0},_instanced:!0,wireframe:!1,material:!0,getPosition:{type:"accessor",value:e=>e.position},getColor:{type:"accessor",value:[0,0,0,255]},getOrientation:{type:"accessor",value:[0,0,0]},getScale:{type:"accessor",value:[1,1,1]},getTranslation:{type:"accessor",value:[0,0,0]},getTransformMatrix:{type:"accessor",value:[]},textureParameters:{type:"object",ignore:!0,value:null}};class XI extends YC{getShaders(){return super.getShaders({vs:"#version 300 es\n#define SHADER_NAME simple-mesh-layer-vs\nuniform float sizeScale;\nuniform bool composeModelMatrix;\nin vec3 positions;\nin vec3 normals;\nin vec3 colors;\nin vec2 texCoords;\nin vec3 instancePositions;\nin vec3 instancePositions64Low;\nin vec4 instanceColors;\nin vec3 instancePickingColors;\nin vec3 instanceModelMatrixCol0;\nin vec3 instanceModelMatrixCol1;\nin vec3 instanceModelMatrixCol2;\nin vec3 instanceTranslation;\nout vec2 vTexCoord;\nout vec3 cameraPosition;\nout vec3 normals_commonspace;\nout vec4 position_commonspace;\nout vec4 vColor;\nvoid main(void) {\ngeometry.worldPosition = instancePositions;\ngeometry.uv = texCoords;\ngeometry.pickingColor = instancePickingColors;\nvTexCoord = texCoords;\ncameraPosition = project_uCameraPosition;\nvColor = vec4(colors * instanceColors.rgb, instanceColors.a);\nmat3 instanceModelMatrix = mat3(instanceModelMatrixCol0, instanceModelMatrixCol1, instanceModelMatrixCol2);\nvec3 pos = (instanceModelMatrix * positions) * sizeScale + instanceTranslation;\nif (composeModelMatrix) {\nDECKGL_FILTER_SIZE(pos, geometry);\nnormals_commonspace = project_normal(instanceModelMatrix * normals);\ngeometry.worldPosition += pos;\ngl_Position = project_position_to_clipspace(pos + instancePositions, instancePositions64Low, vec3(0.0), position_commonspace);\ngeometry.position = position_commonspace;\n}\nelse {\npos = project_size(pos);\nDECKGL_FILTER_SIZE(pos, geometry);\ngl_Position = project_position_to_clipspace(instancePositions, instancePositions64Low, pos, position_commonspace);\ngeometry.position = position_commonspace;\nnormals_commonspace = project_normal(instanceModelMatrix * normals);\n}\ngeometry.normal = normals_commonspace;\nDECKGL_FILTER_GL_POSITION(gl_Position, geometry);\nDECKGL_FILTER_COLOR(vColor, geometry);\n}\n",fs:"#version 300 es\n#define SHADER_NAME simple-mesh-layer-fs\nprecision highp float;\nuniform bool hasTexture;\nuniform sampler2D sampler;\nuniform bool flatShading;\nuniform float opacity;\nin vec2 vTexCoord;\nin vec3 cameraPosition;\nin vec3 normals_commonspace;\nin vec4 position_commonspace;\nin vec4 vColor;\nout vec4 fragColor;\nvoid main(void) {\ngeometry.uv = vTexCoord;\nvec3 normal;\nif (flatShading) {\nnormal = normalize(cross(dFdx(position_commonspace.xyz), dFdy(position_commonspace.xyz)));\n} else {\nnormal = normals_commonspace;\n}\nvec4 color = hasTexture ? texture(sampler, vTexCoord) : vColor;\nDECKGL_FILTER_COLOR(color, geometry);\nvec3 lightColor = lighting_getLightColor(color.rgb, cameraPosition, position_commonspace.xyz, normal);\nfragColor = vec4(lightColor, color.a * opacity);\n}\n",modules:[Fy,fy,dv]})}getBounds(){if(this.props._instanced)return super.getBounds();let e=this.state.positionBounds;if(e)return e;const{mesh:t}=this.props;if(!t)return null;if(e=t.header?.boundingBox,!e){const{attributes:i}=qI(t);i.POSITION=i.POSITION||i.positions,e=Pd(i)}return this.state.positionBounds=e,e}initializeState(){this.getAttributeManager().addInstanced({instancePositions:{transition:!0,type:"float64",fp64:this.use64bitPositions(),size:3,accessor:"getPosition"},instanceColors:{type:"unorm8",transition:!0,size:this.props.colorFormat.length,accessor:"getColor",defaultValue:[0,0,0,255]},instanceModelMatrix:$I}),this.setState({emptyTexture:this.context.device.createTexture({data:new Uint8Array(4),width:1,height:1})})}updateState(e){super.updateState(e);const{props:t,oldProps:i,changeFlags:r}=e;if(t.mesh!==i.mesh||r.extensionsChanged){if(this.state.positionBounds=null,this.state.model?.destroy(),t.mesh){this.state.model=this.getModel(t.mesh);const e=t.mesh.attributes||t.mesh;this.setState({hasNormals:Boolean(e.NORMAL||e.normals)})}this.getAttributeManager().invalidateAll()}t.texture!==i.texture&&t.texture instanceof Af&&this.setTexture(t.texture),this.state.model&&this.state.model.setTopology(this.props.wireframe?"line-strip":"triangle-list")}finalizeState(e){super.finalizeState(e),this.state.emptyTexture.delete()}draw({uniforms:e}){const{model:t}=this.state;if(!t)return;const{viewport:i,renderPass:r}=this.context,{sizeScale:n,coordinateSystem:o,_instanced:s}=this.props;t.setUniforms(e),t.setUniforms({sizeScale:n,composeModelMatrix:!s||ZI(i,o),flatShading:!this.state.hasNormals}),t.draw(r)}get isLoaded(){return Boolean(this.state?.model&&super.isLoaded)}getModel(e){const t=new hx(this.context.device,{...this.getShaders(),id:this.props.id,bufferLayout:this.getAttributeManager().getBufferLayouts(),geometry:qI(e),isInstanced:!0}),{texture:i}=this.props,{emptyTexture:r}=this.state;return t.setBindings({sampler:i||r}),t.setUniforms({hasTexture:Boolean(i)}),t}setTexture(e){const{emptyTexture:t,model:i}=this.state;i&&(i.setBindings({sampler:e||t}),i.setUniforms({hasTexture:Boolean(e)}))}}XI.defaultProps=KI,XI.layerName="SimpleMeshLayer";var JI,YI=XI;function eM(e,t,i,r){const n={defines:{MANUAL_SRGB:1,SRGB_FAST_APPROXIMATION:1},bindings:{},uniforms:{u_Camera:[0,0,0],u_MetallicRoughnessValues:[1,1]},parameters:{},glParameters:{},generatedTextures:[]};n.defines.USE_TEX_LOD=1;const{imageBasedLightingEnvironment:o}=r;return o&&(n.bindings.u_DiffuseEnvSampler=o.diffuseEnvSampler,n.bindings.u_SpecularEnvSampler=o.specularEnvSampler,n.bindings.u_brdfLUT=o.brdfLutTexture,n.uniforms.u_ScaleIBLAmbient=[1,1]),r?.pbrDebug&&(n.defines.PBR_DEBUG=1,n.uniforms.u_ScaleDiffBaseMR=[0,0,0,0],n.uniforms.u_ScaleFGDSpec=[0,0,0,0]),i.NORMAL&&(n.defines.HAS_NORMALS=1),i.TANGENT&&r?.useTangents&&(n.defines.HAS_TANGENTS=1),i.TEXCOORD_0&&(n.defines.HAS_UV=1),r?.imageBasedLightingEnvironment&&(n.defines.USE_IBL=1),r?.lights&&(n.defines.USE_LIGHTS=1),t&&function(e,t,i){i.uniforms.pbr_uUnlit=Boolean(t.unlit),t.pbrMetallicRoughness&&function(e,t,i){t.baseColorTexture&&tM(e,t.baseColorTexture,"u_BaseColorSampler","HAS_BASECOLORMAP",i);i.uniforms.u_BaseColorFactor=t.baseColorFactor||[1,1,1,1],t.metallicRoughnessTexture&&tM(e,t.metallicRoughnessTexture,"u_MetallicRoughnessSampler","HAS_METALROUGHNESSMAP",i);const{metallicFactor:r=1,roughnessFactor:n=1}=t;i.uniforms.u_MetallicRoughnessValues=[r,n]}(e,t.pbrMetallicRoughness,i);if(t.normalTexture){tM(e,t.normalTexture,"u_NormalSampler","HAS_NORMALMAP",i);const{scale:r=1}=t.normalTexture;i.uniforms.u_NormalScale=r}if(t.occlusionTexture){tM(e,t.occlusionTexture,"u_OcclusionSampler","HAS_OCCLUSIONMAP",i);const{strength:r=1}=t.occlusionTexture;i.uniforms.u_OcclusionStrength=r}t.emissiveTexture&&(tM(e,t.emissiveTexture,"u_EmissiveSampler","HAS_EMISSIVEMAP",i),i.uniforms.u_EmissiveFactor=t.emissiveFactor||[0,0,0]);switch(t.alphaMode){case"MASK":const{alphaCutoff:e=.5}=t;i.defines.ALPHA_CUTOFF=1,i.uniforms.u_AlphaCutoff=e;break;case"BLEND":jp.warn("glTF BLEND alphaMode might not work well because it requires mesh sorting")(),i.parameters.blendColorOperation="add",i.parameters.blendColorSrcFactor="src-alpha",i.parameters.blendColorDstFactor="one-minus-src-alpha",i.parameters.blendAlphaOperation="add",i.parameters.blendAlphaSrcFactor="one",i.parameters.blendAlphaDstFactor="one-minus-src-alpha",i.glParameters.blend=!0,i.glParameters.blendEquation=JI.FUNC_ADD,i.glParameters.blendFunc=[JI.SRC_ALPHA,JI.ONE_MINUS_SRC_ALPHA,JI.ONE,JI.ONE_MINUS_SRC_ALPHA]}}(e,t,n),n}function tM(e,t,i,r=null,n){const o=t?.texture?.sampler?.parameters||{},s=t.texture.source.image;let a,l={};s.compressed?(a=s,l={[JI.TEXTURE_MIN_FILTER]:s.data.length>1?JI.LINEAR_MIPMAP_NEAREST:JI.LINEAR}):a={data:s};const c=e.createTexture({id:t.uniformName||t.id,parameters:{...o,...l},pixelStore:{[JI.UNPACK_FLIP_Y_WEBGL]:!1},...a});n.bindings[i]=c,r&&(n.defines[r]=1),n.generatedTextures.push(c)}!function(e){e[e.FUNC_ADD=32774]="FUNC_ADD",e[e.ONE=1]="ONE",e[e.SRC_ALPHA=770]="SRC_ALPHA",e[e.ONE_MINUS_SRC_ALPHA=771]="ONE_MINUS_SRC_ALPHA",e[e.TEXTURE_MIN_FILTER=10241]="TEXTURE_MIN_FILTER",e[e.LINEAR=9729]="LINEAR",e[e.LINEAR_MIPMAP_NEAREST=9985]="LINEAR_MIPMAP_NEAREST",e[e.UNPACK_FLIP_Y_WEBGL=37440]="UNPACK_FLIP_Y_WEBGL"}(JI||(JI={}));const iM=(globalThis._loadersgl_?.version||(globalThis._loadersgl_=globalThis._loadersgl_||{},globalThis._loadersgl_.version="4.3.3"),globalThis._loadersgl_.version);const rM="object"!=typeof process||"[object process]"!==String(process)||process.browser,nM="function"==typeof importScripts,oM="undefined"!=typeof process&&process.version&&/v([0-9]*)/.exec(process.version);oM&&parseFloat(oM[1]);const sM={};async function aM(e,t=null,i={},r=null){return t&&(e=function(e,t,i={},r=null){if(!i.useLocalLibraries&&e.startsWith("http"))return e;r=r||e;const n=i.modules||{};if(n[r])return n[r];if(!rM)return`modules/${t}/dist/libs/${r}`;if(i.CDN)return function(e,t){if(!e)throw new Error(t||"loaders.gl assertion failed.")}(i.CDN.startsWith("http")),`${i.CDN}/${t}@${iM}/dist/libs/${r}`;if(nM)return`../src/libs/${r}`;return`modules/${t}/src/libs/${r}`}(e,t,i,r)),sM[e]=sM[e]||async function(e){if(e.endsWith("wasm"))return await async function(e){const{readFileAsArrayBuffer:t}=globalThis.loaders||{};if(rM||!t||e.startsWith("http")){const t=await fetch(e);return await t.arrayBuffer()}return await t(e)}(e);if(!rM)try{const{requireFromFile:t}=globalThis.loaders||{};return await(t?.(e))}catch(e){return console.error(e),null}if(nM)return importScripts(e);const t=await async function(e){const{readFileAsText:t}=globalThis.loaders||{};if(rM||!t||e.startsWith("http")){const t=await fetch(e);return await t.text()}return await t(e)}(e);return function(e,t){if(!rM){const{requireFromString:i}=globalThis.loaders||{};return i?.(e,t)}if(nM)return eval.call(globalThis,e),null;const i=document.createElement("script");i.id=t;try{i.appendChild(document.createTextNode(e))}catch(t){i.text=e}return document.body.appendChild(i),null}(t,e)}(e),await sM[e]}const lM="basis_transcoder.js",cM="basis_transcoder.wasm",uM="basis_encoder.js",hM="basis_encoder.wasm";let dM,pM;async function fM(e){var t;t=e.modules,globalThis.loaders||={},globalThis.loaders.modules||={},Object.assign(globalThis.loaders.modules,t);const i=function(e){const t=globalThis.loaders?.modules?.[e];return t||null}("basis");return i||(dM||=async function(e){let t=null,i=null;return[t,i]=await Promise.all([await aM(lM,"textures",e),await aM(cM,"textures",e)]),t=t||globalThis.BASIS,await function(e,t){const i={};t&&(i.wasmBinary=t);return new Promise(t=>{e(i).then(e=>{const{BasisFile:i,initializeBasis:r}=e;r(),t({BasisFile:i})})})}(t,i)}(e),await dM)}async function mM(e){const t=e.modules||{};return t.basisEncoder?t.basisEncoder:(pM=pM||async function(e){let t=null,i=null;return[t,i]=await Promise.all([await aM(uM,"textures",e),await aM(hM,"textures",e)]),t=t||globalThis.BASIS,await function(e,t){const i={};t&&(i.wasmBinary=t);return new Promise(t=>{e(i).then(e=>{const{BasisFile:i,KTX2File:r,initializeBasis:n,BasisEncoder:o}=e;n(),t({BasisFile:i,KTX2File:r,BasisEncoder:o})})})}(t,i)}(e),await pM)}const gM=["","WEBKIT_","MOZ_"],_M={WEBGL_compressed_texture_s3tc:"dxt",WEBGL_compressed_texture_s3tc_srgb:"dxt-srgb",WEBGL_compressed_texture_etc1:"etc1",WEBGL_compressed_texture_etc:"etc2",WEBGL_compressed_texture_pvrtc:"pvrtc",WEBGL_compressed_texture_atc:"atc",WEBGL_compressed_texture_astc:"astc",EXT_texture_compression_rgtc:"rgtc"};let AM=null;function yM(e){if(!AM){e=e||function(){try{return document.createElement("canvas").getContext("webgl")}catch(e){return null}}()||void 0,AM=new Set;for(const t of gM)for(const i in _M)if(e&&e.getExtension(`${t}${i}`)){const e=_M[i];AM.add(e)}}return AM}const vM=[171,75,84,88,32,50,48,187,13,10,26,10];const xM={etc1:{basisFormat:0,compressed:!0,format:36196},etc2:{basisFormat:1,compressed:!0},bc1:{basisFormat:2,compressed:!0,format:33776},bc3:{basisFormat:3,compressed:!0,format:33779},bc4:{basisFormat:4,compressed:!0},bc5:{basisFormat:5,compressed:!0},"bc7-m6-opaque-only":{basisFormat:6,compressed:!0},"bc7-m5":{basisFormat:7,compressed:!0},"pvrtc1-4-rgb":{basisFormat:8,compressed:!0,format:35840},"pvrtc1-4-rgba":{basisFormat:9,compressed:!0,format:35842},"astc-4x4":{basisFormat:10,compressed:!0,format:37808},"atc-rgb":{basisFormat:11,compressed:!0},"atc-rgba-interpolated-alpha":{basisFormat:12,compressed:!0},rgba32:{basisFormat:13,compressed:!1},rgb565:{basisFormat:14,compressed:!1},bgr565:{basisFormat:15,compressed:!1},rgba4444:{basisFormat:16,compressed:!1}};function bM(e,t,i){const r=new e(new Uint8Array(t));try{if(!r.startTranscoding())throw new Error("Failed to start basis transcoding");const e=r.getNumImages(),t=[];for(let n=0;n{!function(e,{input:t,interpolation:i,output:r},n,o){const s=t[t.length-1],a=e%s,l=t.findIndex(e=>e>=a),c=Math.max(0,l-1);if(!Array.isArray(n[o]))switch(o){case"translation":n[o]=[0,0,0];break;case"rotation":n[o]=[0,0,0,1];break;case"scale":n[o]=[1,1,1];break;default:jp.warn(`Bad animation path ${o}`)()}lf(n[o].length===r[c].length);const u=t[c],h=t[l];switch(i){case"STEP":!function(e,t,i){for(let r=0;ru){const e=(a-u)/(h-u);!function(e,t,i,r,n){if("rotation"===t){kM.slerp({start:i,target:r,ratio:n});for(let i=0;iu){const e=(a-u)/(h-u),t=h-u;!function(e,t,{p0:i,outTangent0:r,inTangent1:n,p1:o,tDiff:s,ratio:a}){for(let l=0;l{const r=t.name||`Animation-${i}`,n=t.samplers.map(({input:t,interpolation:i="LINEAR",output:r})=>({input:LM(e.accessors[t]),interpolation:i,output:LM(e.accessors[r])})),o=t.channels.map(({sampler:t,target:i})=>({sampler:n[t],target:e.nodes[i.node],path:i.path}));return new PM({name:r,channels:o})})}animate(e){this.setTime(e)}setTime(e){this.animations.forEach(t=>t.animate(e))}getAnimations(){return this.animations}}function LM(e){if(!e._animation){const t=MM[e.componentType],i=IM[e.type],r=i*e.count,{buffer:n,byteOffset:o}=e.bufferView.data,s=new t(n,o+(e.byteOffset||0),r);if(1===i)e._animation=Array.from(s);else{const t=[];for(let e=0;ethis.createScene(e))}createAnimator(){return Array.isArray(this.gltf.animations)?new RM(this.gltf):null}createScene(e){const t=(e.nodes||[]).map(e=>this.createNode(e));return new _x({id:e.name||e.id,children:t})}createNode(e){if(!e._node){const t=(e.children||[]).map(e=>this.createNode(e));e.mesh&&t.push(this.createMesh(e.mesh));const i=new _x({id:e.name||e.id,children:t});if(e.matrix)i.setMatrix(e.matrix);else{if(i.matrix.identity(),e.translation&&i.matrix.translate(e.translation),e.rotation){const t=(new VA).fromQuaternion(e.rotation);i.matrix.multiplyRight(t)}e.scale&&i.matrix.scale(e.scale)}e._node=i}return e._node}createMesh(e){if(!e._mesh){const t=(e.primitives||[]).map((t,i)=>this.createPrimitive(t,i,e)),i=new _x({id:e.name||e.id,children:t});e._mesh=i}return e._mesh}createPrimitive(e,t,i){const r=e.name||`${i.name||i.id}-primitive-${t}`,n=function(e){switch(e){case UM.POINTS:return"point-list";case UM.LINES:return"line-list";case UM.LINE_STRIP:return"line-strip";case UM.LINE_LOOP:return"line-loop-webgl";case UM.TRIANGLES:return"triangle-list";case UM.TRIANGLE_STRIP:return"triangle-strip";case UM.TRIANGLE_FAN:return"triangle-fan-webgl";default:throw new Error(e)}}(e.mode||4),o=e.indices?e.indices.count:this.getVertexCount(e.attributes),s=function(e,t){const{id:i,geometry:r,material:n,vertexCount:o,materialOptions:s,modelOptions:a}=t,l=eM(e,n,r.attributes,s);jp.info(4,"createGLTFModel defines: ",l.defines)();const c={id:i,geometry:r,topology:r.topology,vertexCount:o,modules:[my],vs:DM(0,"\n#pragma vscode_glsllint_stage: vert\n#if (__VERSION__ < 300)\n #define _attr attribute\n#else\n #define _attr in\n#endif\n\n // _attr vec4 POSITION;\n _attr vec4 positions;\n\n #ifdef HAS_NORMALS\n // _attr vec4 NORMAL;\n _attr vec4 normals;\n #endif\n\n #ifdef HAS_TANGENTS\n _attr vec4 TANGENT;\n #endif\n\n #ifdef HAS_UV\n // _attr vec2 TEXCOORD_0;\n _attr vec2 texCoords;\n #endif\n\n void main(void) {\n vec4 _NORMAL = vec4(0.);\n vec4 _TANGENT = vec4(0.);\n vec2 _TEXCOORD_0 = vec2(0.);\n\n #ifdef HAS_NORMALS\n _NORMAL = normals;\n #endif\n\n #ifdef HAS_TANGENTS\n _TANGENT = TANGENT;\n #endif\n\n #ifdef HAS_UV\n _TEXCOORD_0 = texCoords;\n #endif\n\n pbr_setPositionNormalTangentUV(positions, _NORMAL, _TANGENT, _TEXCOORD_0);\n gl_Position = u_MVPMatrix * positions;\n }\n"),fs:DM(0,"\n#pragma vscode_glsllint_stage: frag\n#if (__VERSION__ < 300)\n #define fragmentColor gl_FragColor\n#else\n out vec4 fragmentColor;\n#endif\n\n void main(void) {\n vec3 pos = pbr_vPosition;\n fragmentColor = pbr_filterColor(vec4(1.0));\n }\n"),...a,bindings:{...l.bindings,...a.bindings},defines:{...l.defines,...a.defines},parameters:{depthWriteEnabled:!0,depthCompare:"less",depthFormat:"depth24plus",cullMode:"back",...l.parameters,...a.parameters},uniforms:{...l.uniforms,...a.uniforms}},u=new hx(e,c);return new Ax({managedResources:[],model:u})}(this.device,{id:r,geometry:this.createGeometry(r,e,n),material:e.material,materialOptions:this.options,modelOptions:this.options.modelOptions,vertexCount:o});return s.bounds=[e.attributes.POSITION.min,e.attributes.POSITION.max],s}getVertexCount(e){throw new Error("getVertexCount not implemented")}createGeometry(e,t,i){const r={};for(const[e,i]of Object.entries(t.attributes)){const{components:t,size:n,value:o}=i;r[e]={size:n??t,value:o}}return new mx({id:e,topology:i,indices:t.indices.value,attributes:r})}createBuffer(e,t){e.bufferView||(e.bufferView={});const{bufferView:i}=e;return i.lumaBuffers||(i.lumaBuffers={}),i.lumaBuffers[t]||(i.lumaBuffers[t]=this.device.createBuffer({id:`from-${i.id}`,data:i.data||e.value})),i.lumaBuffers[t]}createSampler(e){return e}needsPOT(){return!1}}var UM;function NM(e,t){if(!e)throw new Error(t||"assert failed: gltf")}!function(e){e[e.POINTS=0]="POINTS",e[e.LINES=1]="LINES",e[e.LINE_LOOP=2]="LINE_LOOP",e[e.LINE_STRIP=3]="LINE_STRIP",e[e.TRIANGLES=4]="TRIANGLES",e[e.TRIANGLE_STRIP=5]="TRIANGLE_STRIP",e[e.TRIANGLE_FAN=6]="TRIANGLE_FAN"}(UM||(UM={}));const VM={SCALAR:1,VEC2:2,VEC3:3,VEC4:4,MAT2:4,MAT3:9,MAT4:16},jM={5120:1,5121:1,5122:2,5123:2,5125:4,5126:4},GM=["SCALAR","VEC2","VEC3","VEC4"],HM=[[Int8Array,5120],[Uint8Array,5121],[Int16Array,5122],[Uint16Array,5123],[Uint32Array,5125],[Float32Array,5126],[Float64Array,5130]],QM=new Map(HM),$M={SCALAR:1,VEC2:2,VEC3:3,VEC4:4,MAT2:4,MAT3:9,MAT4:16},ZM={5120:1,5121:1,5122:2,5123:2,5125:4,5126:4},WM={5120:Int8Array,5121:Uint8Array,5122:Int16Array,5123:Uint16Array,5125:Uint32Array,5126:Float32Array};function qM(e){return GM[e-1]||GM[0]}function KM(e){const t=QM.get(e.constructor);if(!t)throw new Error("Illegal typed array");return t}function XM(e,t){const i=WM[e.componentType],r=$M[e.type],n=ZM[e.componentType],o=e.count*r,s=e.count*r*n;NM(s>=0&&s<=t.byteLength);return{ArrayType:i,length:o,byteLength:s,componentByteSize:jM[e.componentType],numberOfComponentsInElement:VM[e.type]}}function JM(e){let{images:t,bufferViews:i}=e;t=t||[],i=i||[];const r=t.map(e=>e.bufferView);i=i.filter(e=>!r.includes(e));const n=i.reduce((e,t)=>e+t.byteLength,0),o=t.reduce((e,t)=>{const{width:i,height:r}=t.image;return e+i*r},0);return n+Math.ceil(4*o*1.33)}class YM{gltf;sourceBuffers;byteLength;constructor(e){this.gltf={json:e?.json||{asset:{version:"2.0",generator:"loaders.gl"},buffers:[],extensions:{},extensionsRequired:[],extensionsUsed:[]},buffers:e?.buffers||[],images:e?.images||[]},this.sourceBuffers=[],this.byteLength=0,this.gltf.buffers&&this.gltf.buffers[0]&&(this.byteLength=this.gltf.buffers[0].byteLength,this.sourceBuffers=[this.gltf.buffers[0]])}get json(){return this.gltf.json}getApplicationData(e){return this.json[e]}getExtraData(e){return(this.json.extras||{})[e]}hasExtension(e){const t=this.getUsedExtensions().find(t=>t===e),i=this.getRequiredExtensions().find(t=>t===e);return"string"==typeof t||"string"==typeof i}getExtension(e){const t=this.getUsedExtensions().find(t=>t===e),i=this.json.extensions||{};return t?i[e]:null}getRequiredExtension(e){return this.getRequiredExtensions().find(t=>t===e)?this.getExtension(e):null}getRequiredExtensions(){return this.json.extensionsRequired||[]}getUsedExtensions(){return this.json.extensionsUsed||[]}getRemovedExtensions(){return this.json.extensionsRemoved||[]}getObjectExtension(e,t){return(e.extensions||{})[t]}getScene(e){return this.getObject("scenes",e)}getNode(e){return this.getObject("nodes",e)}getSkin(e){return this.getObject("skins",e)}getMesh(e){return this.getObject("meshes",e)}getMaterial(e){return this.getObject("materials",e)}getAccessor(e){return this.getObject("accessors",e)}getTexture(e){return this.getObject("textures",e)}getSampler(e){return this.getObject("samplers",e)}getImage(e){return this.getObject("images",e)}getBufferView(e){return this.getObject("bufferViews",e)}getBuffer(e){return this.getObject("buffers",e)}getObject(e,t){if("object"==typeof t)return t;const i=this.json[e]&&this.json[e][t];if(!i)throw new Error(`glTF file error: Could not find ${e}[${t}]`);return i}getTypedArrayForBufferView(e){const t=(e=this.getBufferView(e)).buffer,i=this.gltf.buffers[t];NM(i);const r=(e.byteOffset||0)+i.byteOffset;return new Uint8Array(i.arrayBuffer,r,e.byteLength)}getTypedArrayForAccessor(e){const t=this.getAccessor(e);return function(e,t,i){const r="number"==typeof i?e.accessors?.[i]:i;if(!r)throw new Error(`No gltf accessor ${JSON.stringify(i)}`);const n=e.bufferViews?.[r.bufferView||0];if(!n)throw new Error(`No gltf buffer view for accessor ${n}`);const{arrayBuffer:o,byteOffset:s}=t[n.buffer],a=(s||0)+(r.byteOffset||0)+(n.byteOffset||0),{ArrayType:l,length:c,componentByteSize:u,numberOfComponentsInElement:h}=XM(r,n),d=u*h,p=n.byteStride||d;if(void 0===n.byteStride||n.byteStride===d)return new l(o,a,c);const f=new l(c);for(let e=0;et===e)||this.json.extensionsUsed.push(e)}registerRequiredExtension(e){this.registerUsedExtension(e),this.json.extensionsRequired=this.json.extensionsRequired||[],this.json.extensionsRequired.find(t=>t===e)||this.json.extensionsRequired.push(e)}removeExtension(e){if(this.json.extensions?.[e]){this.json.extensionsRemoved=this.json.extensionsRemoved||[];const t=this.json.extensionsRemoved;t.includes(e)||t.push(e)}this.json.extensions&&delete this.json.extensions[e],this.json.extensionsRequired&&this._removeStringFromArray(this.json.extensionsRequired,e),this.json.extensionsUsed&&this._removeStringFromArray(this.json.extensionsUsed,e)}setDefaultScene(e){this.json.scene=e}addScene(e){const{nodeIndices:t}=e;return this.json.scenes=this.json.scenes||[],this.json.scenes.push({nodes:t}),this.json.scenes.length-1}addNode(e){const{meshIndex:t,matrix:i}=e;this.json.nodes=this.json.nodes||[];const r={mesh:t};return i&&(r.matrix=i),this.json.nodes.push(r),this.json.nodes.length-1}addMesh(e){const{attributes:t,indices:i,material:r,mode:n=4}=e,o={primitives:[{attributes:this._addAttributes(t),mode:n}]};if(i){const e=this._addIndices(i);o.primitives[0].indices=e}return Number.isFinite(r)&&(o.primitives[0].material=r),this.json.meshes=this.json.meshes||[],this.json.meshes.push(o),this.json.meshes.length-1}addPointCloud(e){const t={primitives:[{attributes:this._addAttributes(e),mode:0}]};return this.json.meshes=this.json.meshes||[],this.json.meshes.push(t),this.json.meshes.length-1}addImage(e,t){const i=Jd(e),r=t||i?.mimeType,n={bufferView:this.addBufferView(e),mimeType:r};return this.json.images=this.json.images||[],this.json.images.push(n),this.json.images.length-1}addBufferView(e,t=0,i=this.byteLength){const r=e.byteLength;NM(Number.isFinite(r)),this.sourceBuffers=this.sourceBuffers||[],this.sourceBuffers.push(e);const n={buffer:t,byteOffset:i,byteLength:r};return this.byteLength+=xh(r,4),this.json.bufferViews=this.json.bufferViews||[],this.json.bufferViews.push(n),this.json.bufferViews.length-1}addAccessor(e,t){const i={bufferView:e,type:qM(t.size),componentType:t.componentType,count:t.count,max:t.max,min:t.min};return this.json.accessors=this.json.accessors||[],this.json.accessors.push(i),this.json.accessors.length-1}addBinaryBuffer(e,t={size:3}){const i=this.addBufferView(e);let r={min:t.min,max:t.max};r.min&&r.max||(r=this._getAccessorMinMax(e,t.size));const n={size:t.size,componentType:KM(e),count:Math.round(e.length/t.size),min:r.min,max:r.max};return this.addAccessor(i,Object.assign(n,t))}addTexture(e){const{imageIndex:t}=e,i={source:t};return this.json.textures=this.json.textures||[],this.json.textures.push(i),this.json.textures.length-1}addMaterial(e){return this.json.materials=this.json.materials||[],this.json.materials.push(e),this.json.materials.length-1}createBinaryChunk(){const e=this.byteLength,t=new ArrayBuffer(e),i=new Uint8Array(t);let r=0;for(const e of this.sourceBuffers||[])r=bh(e,i,r);this.json?.buffers?.[0]?this.json.buffers[0].byteLength=e:this.json.buffers=[{byteLength:e}],this.gltf.binary=t,this.sourceBuffers=[t],this.gltf.buffers=[{arrayBuffer:t,byteOffset:0,byteLength:t.byteLength}]}_removeStringFromArray(e,t){let i=!0;for(;i;){const r=e.indexOf(t);r>-1?e.splice(r,1):i=!1}}_addAttributes(e={}){const t={};for(const i in e){const r=e[i],n=this._getGltfAttributeName(i),o=this.addBinaryBuffer(r.value,r);t[n]=o}return t}_addIndices(e){return this.addBinaryBuffer(e,{size:1})}_getGltfAttributeName(e){switch(e.toLowerCase()){case"position":case"positions":case"vertices":return"POSITION";case"normal":case"normals":return"NORMAL";case"color":case"colors":return"COLOR_0";case"texcoord":case"texcoords":return"TEXCOORD_0";default:return e}}_getAccessorMinMax(e,t){const i={min:null,max:null};if(e.lengtht===e);-1===t&&(t=r.push(e)-1),o.push(t)}const s=new Uint32Array(o),a=e.gltf.buffers.push({arrayBuffer:s.buffer,byteOffset:s.byteOffset,byteLength:s.byteLength})-1,l=e.addBufferView(s,a,0),c=e.addAccessor(l,{size:1,componentType:KM(s),count:s.length});n.attributes[t]=c}function cP(e,t,i,r,n=[0]){const o={r:{offset:0,shift:0},g:{offset:1,shift:8},b:{offset:2,shift:16},a:{offset:3,shift:24}},s=i[r],a=i[r+1];let l=1;!t||-1===t.indexOf("image/jpeg")&&-1===t.indexOf("image/png")||(l=4);const c=function(e,t,i,r=1){const n=i.width,o=eP(e)*(n-1),s=Math.round(o),a=i.height,l=eP(t)*(a-1),c=Math.round(l),u=i.components?i.components:r,h=(c*n+s)*u;return h}(s,a,e,l);let u=0;for(const t of n){const i="number"==typeof t?Object.values(o)[t]:o[t],r=c+i.offset,n=Nd(e);if(n.data.length<=r)throw new Error(`${n.data.length} <= ${r}`);u|=n.data[r]<r)break;const l=t/n,c=a/n;o.push(e.slice(l,l+c))}return o}function hP(e,t,i){const r=[];for(let n=0;n{if(i.data){const{accessorKey:o,index:s}=function(e){const t="_FEATURE_ID_",i=Object.keys(e).filter(e=>0===e.indexOf(t));let r=-1;for(const e of i){const i=Number(e.substring(t.length));i>r&&(r=i)}r++;const n=`${t}${r}`;return{accessorKey:n,index:r}}(t.attributes),a=new Uint32Array(i.data);r[n]={featureCount:a.length,propertyTable:i.propertyTable,attribute:s},e.gltf.buffers.push({arrayBuffer:a.buffer,byteOffset:a.byteOffset,byteLength:a.byteLength});const l=e.addBufferView(a),c=e.addAccessor(l,{size:1,componentType:KM(a),count:a.length});t.attributes[o]=c}})}var _P=Object.freeze({__proto__:null,name:fP,decode:async function(e,t){!function(e,t){const i=e.gltf.json;if(!i.meshes)return;for(const r of i.meshes)for(const i of r.primitives)mP(e,i,t)}(new YM(e),t)},encode:function(e,t){const i=new YM(e);return function(e){const t=e.gltf.json.meshes;if(!t)return;for(const i of t)for(const t of i.primitives)gP(e,t)}(i),i.createBinaryChunk(),i.gltf},createExtMeshFeatures:function(e,t,i,r){t.extensions||(t.extensions={});let n=t.extensions[pP];n||(n={featureIds:[]},t.extensions[pP]=n);const{featureIds:o}=n,s={featureCount:i.length,propertyTable:r,data:i};o.push(s),e.addObjectExtension(t,pP,n)}});const AP="EXT_structural_metadata",yP=AP;function vP(e,t){for(const i of e)if(i.class===t)return i;return null}function xP(e,t,i,r){if(!t)return;const n=i.extensions?.[AP],o=n?.propertyTextures;if(o)for(const n of o){bP(e,t[n],i,r)}}function bP(e,t,i,r){if(!t.properties)return;r.dataAttributeNames||(r.dataAttributeNames=[]);const n=t.class;for(const o in t.properties){const s=`${n}_${o}`,a=t.properties?.[o];if(!a)continue;a.data||(a.data=[]);const l=a.data,c=aP(e,a,i);null!==c&&(lP(e,s,c,l,i),a.data=l,r.dataAttributeNames.push(s))}}function wP(e,t,i){const r=t.classes?.[i.class];if(!r)throw new Error(`Incorrect data in the EXT_structural_metadata extension: no schema class with name ${i.class}`);const n=i.count;for(const o in r.properties){const s=r.properties[o],a=i.properties?.[o];if(a){const i=TP(e,t,s,n,a);a.data=i}}}function TP(e,t,i,r,n){let o=[];const s=n.values,a=e.getTypedArrayForBufferView(s),l=function(e,t,i,r){if(t.array&&void 0===t.count&&void 0!==i.arrayOffsets)return oP(e,i.arrayOffsets,i.arrayOffsetType||"UINT32",r);return null}(e,i,n,r),c=function(e,t,i){if(void 0!==t.stringOffsets)return oP(e,t.stringOffsets,t.stringOffsetType||"UINT32",i);return null}(e,n,r);switch(i.type){case"SCALAR":case"VEC2":case"VEC3":case"VEC4":case"MAT2":case"MAT3":case"MAT4":o=function(e,t,i,r){const n=e.array,o=e.count,s=nP(e.type,e.componentType),a=i.byteLength/s;let l;l=e.componentType?sP(i,e.type,e.componentType,a):i;if(n)return r?uP(l,t,r,i.length,s):o?hP(l,t,o):[];return l}(i,r,a,l);break;case"BOOLEAN":throw new Error(`Not implemented - classProperty.type=${i.type}`);case"STRING":o=dP(r,a,l,c);break;case"ENUM":o=function(e,t,i,r,n){const o=t.enumType;if(!o)throw new Error("Incorrect data in the EXT_structural_metadata extension: classProperty.enumType is not set for type ENUM");const s=e.enums?.[o];if(!s)throw new Error(`Incorrect data in the EXT_structural_metadata extension: schema.enums does't contain ${o}`);const a=s.valueType||"UINT16",l=nP(t.type,a),c=r.byteLength/l;let u=sP(r,t.type,a,c);u||(u=r);if(t.array){if(n)return function(e){const{valuesData:t,numberOfElements:i,arrayOffsets:r,valuesDataBytesLength:n,elementSize:o,enumEntry:s}=e,a=[];for(let e=0;en)break;const c=EP(t,i/o,l/o,s);a.push(c)}return a}({valuesData:u,numberOfElements:i,arrayOffsets:n,valuesDataBytesLength:r.length,elementSize:l,enumEntry:s});const e=t.count;return e?function(e,t,i,r){const n=[];for(let o=0;o20);const r=t.getUint32(i+0,jP),n=t.getUint32(i+4,jP);return i+=8,Tu(0===n),ZP(e,t,i,r),i+=r,i+=WP(e,t,i,e.header.byteLength),i}(e,n,i);case 2:return function(e,t,i,r){return Tu(e.header.byteLength>20),function(e,t,i,r){for(;i+8<=e.header.byteLength;){const n=t.getUint32(i+0,jP),o=t.getUint32(i+4,jP);switch(i+=8,o){case HP:ZP(e,t,i,n);break;case QP:WP(e,t,i,n);break;case 0:r.strict||ZP(e,t,i,n);break;case 1:r.strict||WP(e,t,i,n)}i+=xh(n,4)}}(e,t,i,r),i+e.header.byteLength}(e,n,i,{});default:throw new Error(`Invalid GLB version ${e.version}. Only supports version 1 and 2.`)}}function ZP(e,t,i,r){const n=new Uint8Array(t.buffer,i,r),o=new TextDecoder("utf8").decode(n);return e.json=JSON.parse(o),xh(r,4)}function WP(e,t,i,r){return e.header.hasBinChunk=!0,e.binChunks.push({byteOffset:i,byteLength:r,arrayBuffer:t.buffer}),xh(r,4)}function qP(e,t){if(e.startsWith("data:")||e.startsWith("http:")||e.startsWith("https:"))return e;const i=t.baseUri||t.uri;if(!i)throw new Error(`'baseUri' must be provided to resolve relative url ${e}`);return i.substr(0,i.lastIndexOf("/")+1)+e}const KP="B9h9z9tFBBBF8fL9gBB9gLaaaaaFa9gEaaaB9gFaFa9gEaaaFaEMcBFFFGGGEIIILF9wFFFLEFBFKNFaFCx/IFMO/LFVK9tv9t9vq95GBt9f9f939h9z9t9f9j9h9s9s9f9jW9vq9zBBp9tv9z9o9v9wW9f9kv9j9v9kv9WvqWv94h919m9mvqBF8Z9tv9z9o9v9wW9f9kv9j9v9kv9J9u9kv94h919m9mvqBGy9tv9z9o9v9wW9f9kv9j9v9kv9J9u9kv949TvZ91v9u9jvBEn9tv9z9o9v9wW9f9kv9j9v9kv69p9sWvq9P9jWBIi9tv9z9o9v9wW9f9kv9j9v9kv69p9sWvq9R919hWBLn9tv9z9o9v9wW9f9kv9j9v9kv69p9sWvq9F949wBKI9z9iqlBOc+x8ycGBM/qQFTa8jUUUUBCU/EBlHL8kUUUUBC9+RKGXAGCFJAI9LQBCaRKAE2BBC+gF9HQBALAEAIJHOAGlAGTkUUUBRNCUoBAG9uC/wgBZHKCUGAKCUG9JyRVAECFJRICBRcGXEXAcAF9PQFAVAFAclAcAVJAF9JyRMGXGXAG9FQBAMCbJHKC9wZRSAKCIrCEJCGrRQANCUGJRfCBRbAIRTEXGXAOATlAQ9PQBCBRISEMATAQJRIGXAS9FQBCBRtCBREEXGXAOAIlCi9PQBCBRISLMANCU/CBJAEJRKGXGXGXGXGXATAECKrJ2BBAtCKZrCEZfIBFGEBMAKhB83EBAKCNJhB83EBSEMAKAI2BIAI2BBHmCKrHYAYCE6HYy86BBAKCFJAICIJAYJHY2BBAmCIrCEZHPAPCE6HPy86BBAKCGJAYAPJHY2BBAmCGrCEZHPAPCE6HPy86BBAKCEJAYAPJHY2BBAmCEZHmAmCE6Hmy86BBAKCIJAYAmJHY2BBAI2BFHmCKrHPAPCE6HPy86BBAKCLJAYAPJHY2BBAmCIrCEZHPAPCE6HPy86BBAKCKJAYAPJHY2BBAmCGrCEZHPAPCE6HPy86BBAKCOJAYAPJHY2BBAmCEZHmAmCE6Hmy86BBAKCNJAYAmJHY2BBAI2BGHmCKrHPAPCE6HPy86BBAKCVJAYAPJHY2BBAmCIrCEZHPAPCE6HPy86BBAKCcJAYAPJHY2BBAmCGrCEZHPAPCE6HPy86BBAKCMJAYAPJHY2BBAmCEZHmAmCE6Hmy86BBAKCSJAYAmJHm2BBAI2BEHICKrHYAYCE6HYy86BBAKCQJAmAYJHm2BBAICIrCEZHYAYCE6HYy86BBAKCfJAmAYJHm2BBAICGrCEZHYAYCE6HYy86BBAKCbJAmAYJHK2BBAICEZHIAICE6HIy86BBAKAIJRISGMAKAI2BNAI2BBHmCIrHYAYCb6HYy86BBAKCFJAICNJAYJHY2BBAmCbZHmAmCb6Hmy86BBAKCGJAYAmJHm2BBAI2BFHYCIrHPAPCb6HPy86BBAKCEJAmAPJHm2BBAYCbZHYAYCb6HYy86BBAKCIJAmAYJHm2BBAI2BGHYCIrHPAPCb6HPy86BBAKCLJAmAPJHm2BBAYCbZHYAYCb6HYy86BBAKCKJAmAYJHm2BBAI2BEHYCIrHPAPCb6HPy86BBAKCOJAmAPJHm2BBAYCbZHYAYCb6HYy86BBAKCNJAmAYJHm2BBAI2BIHYCIrHPAPCb6HPy86BBAKCVJAmAPJHm2BBAYCbZHYAYCb6HYy86BBAKCcJAmAYJHm2BBAI2BLHYCIrHPAPCb6HPy86BBAKCMJAmAPJHm2BBAYCbZHYAYCb6HYy86BBAKCSJAmAYJHm2BBAI2BKHYCIrHPAPCb6HPy86BBAKCQJAmAPJHm2BBAYCbZHYAYCb6HYy86BBAKCfJAmAYJHm2BBAI2BOHICIrHYAYCb6HYy86BBAKCbJAmAYJHK2BBAICbZHIAICb6HIy86BBAKAIJRISFMAKAI8pBB83BBAKCNJAICNJ8pBB83BBAICTJRIMAtCGJRtAECTJHEAS9JQBMMGXAIQBCBRISEMGXAM9FQBANAbJ2BBRtCBRKAfREEXAEANCU/CBJAKJ2BBHTCFrCBATCFZl9zAtJHt86BBAEAGJREAKCFJHKAM9HQBMMAfCFJRfAIRTAbCFJHbAG9HQBMMABAcAG9sJANCUGJAMAG9sTkUUUBpANANCUGJAMCaJAG9sJAGTkUUUBpMAMCBAIyAcJRcAIQBMC9+RKSFMCBC99AOAIlAGCAAGCA9Ly6yRKMALCU/EBJ8kUUUUBAKM+OmFTa8jUUUUBCoFlHL8kUUUUBC9+RKGXAFCE9uHOCtJAI9LQBCaRKAE2BBHNC/wFZC/gF9HQBANCbZHVCF9LQBALCoBJCgFCUFT+JUUUBpALC84Jha83EBALC8wJha83EBALC8oJha83EBALCAJha83EBALCiJha83EBALCTJha83EBALha83ENALha83EBAEAIJC9wJRcAECFJHNAOJRMGXAF9FQBCQCbAVCF6yRSABRECBRVCBRQCBRfCBRICBRKEXGXAMAcuQBC9+RKSEMGXGXAN2BBHOC/vF9LQBALCoBJAOCIrCa9zAKJCbZCEWJHb8oGIRTAb8oGBRtGXAOCbZHbAS9PQBALAOCa9zAIJCbZCGWJ8oGBAVAbyROAb9FRbGXGXAGCG9HQBABAt87FBABCIJAO87FBABCGJAT87FBSFMAEAtjGBAECNJAOjGBAECIJATjGBMAVAbJRVALCoBJAKCEWJHmAOjGBAmATjGIALAICGWJAOjGBALCoBJAKCFJCbZHKCEWJHTAtjGBATAOjGIAIAbJRIAKCFJRKSGMGXGXAbCb6QBAQAbJAbC989zJCFJRQSFMAM1BBHbCgFZROGXGXAbCa9MQBAMCFJRMSFMAM1BFHbCgBZCOWAOCgBZqROGXAbCa9MQBAMCGJRMSFMAM1BGHbCgBZCfWAOqROGXAbCa9MQBAMCEJRMSFMAM1BEHbCgBZCdWAOqROGXAbCa9MQBAMCIJRMSFMAM2BIC8cWAOqROAMCLJRMMAOCFrCBAOCFZl9zAQJRQMGXGXAGCG9HQBABAt87FBABCIJAQ87FBABCGJAT87FBSFMAEAtjGBAECNJAQjGBAECIJATjGBMALCoBJAKCEWJHOAQjGBAOATjGIALAICGWJAQjGBALCoBJAKCFJCbZHKCEWJHOAtjGBAOAQjGIAICFJRIAKCFJRKSFMGXAOCDF9LQBALAIAcAOCbZJ2BBHbCIrHTlCbZCGWJ8oGBAVCFJHtATyROALAIAblCbZCGWJ8oGBAtAT9FHmJHtAbCbZHTyRbAT9FRTGXGXAGCG9HQBABAV87FBABCIJAb87FBABCGJAO87FBSFMAEAVjGBAECNJAbjGBAECIJAOjGBMALAICGWJAVjGBALCoBJAKCEWJHYAOjGBAYAVjGIALAICFJHICbZCGWJAOjGBALCoBJAKCFJCbZCEWJHYAbjGBAYAOjGIALAIAmJCbZHICGWJAbjGBALCoBJAKCGJCbZHKCEWJHOAVjGBAOAbjGIAKCFJRKAIATJRIAtATJRVSFMAVCBAM2BBHYyHTAOC/+F6HPJROAYCbZRtGXGXAYCIrHmQBAOCFJRbSFMAORbALAIAmlCbZCGWJ8oGBROMGXGXAtQBAbCFJRVSFMAbRVALAIAYlCbZCGWJ8oGBRbMGXGXAP9FQBAMCFJRYSFMAM1BFHYCgFZRTGXGXAYCa9MQBAMCGJRYSFMAM1BGHYCgBZCOWATCgBZqRTGXAYCa9MQBAMCEJRYSFMAM1BEHYCgBZCfWATqRTGXAYCa9MQBAMCIJRYSFMAM1BIHYCgBZCdWATqRTGXAYCa9MQBAMCLJRYSFMAMCKJRYAM2BLC8cWATqRTMATCFrCBATCFZl9zAQJHQRTMGXGXAmCb6QBAYRPSFMAY1BBHMCgFZROGXGXAMCa9MQBAYCFJRPSFMAY1BFHMCgBZCOWAOCgBZqROGXAMCa9MQBAYCGJRPSFMAY1BGHMCgBZCfWAOqROGXAMCa9MQBAYCEJRPSFMAY1BEHMCgBZCdWAOqROGXAMCa9MQBAYCIJRPSFMAYCLJRPAY2BIC8cWAOqROMAOCFrCBAOCFZl9zAQJHQROMGXGXAtCb6QBAPRMSFMAP1BBHMCgFZRbGXGXAMCa9MQBAPCFJRMSFMAP1BFHMCgBZCOWAbCgBZqRbGXAMCa9MQBAPCGJRMSFMAP1BGHMCgBZCfWAbqRbGXAMCa9MQBAPCEJRMSFMAP1BEHMCgBZCdWAbqRbGXAMCa9MQBAPCIJRMSFMAPCLJRMAP2BIC8cWAbqRbMAbCFrCBAbCFZl9zAQJHQRbMGXGXAGCG9HQBABAT87FBABCIJAb87FBABCGJAO87FBSFMAEATjGBAECNJAbjGBAECIJAOjGBMALCoBJAKCEWJHYAOjGBAYATjGIALAICGWJATjGBALCoBJAKCFJCbZCEWJHYAbjGBAYAOjGIALAICFJHICbZCGWJAOjGBALCoBJAKCGJCbZCEWJHOATjGBAOAbjGIALAIAm9FAmCb6qJHICbZCGWJAbjGBAIAt9FAtCb6qJRIAKCEJRKMANCFJRNABCKJRBAECSJREAKCbZRKAICbZRIAfCEJHfAF9JQBMMCBC99AMAc6yRKMALCoFJ8kUUUUBAKM/tIFGa8jUUUUBCTlRLC9+RKGXAFCLJAI9LQBCaRKAE2BBC/+FZC/QF9HQBALhB83ENAECFJRKAEAIJC98JREGXAF9FQBGXAGCG6QBEXGXAKAE9JQBC9+bMAK1BBHGCgFZRIGXGXAGCa9MQBAKCFJRKSFMAK1BFHGCgBZCOWAICgBZqRIGXAGCa9MQBAKCGJRKSFMAK1BGHGCgBZCfWAIqRIGXAGCa9MQBAKCEJRKSFMAK1BEHGCgBZCdWAIqRIGXAGCa9MQBAKCIJRKSFMAK2BIC8cWAIqRIAKCLJRKMALCNJAICFZCGWqHGAICGrCBAICFrCFZl9zAG8oGBJHIjGBABAIjGBABCIJRBAFCaJHFQBSGMMEXGXAKAE9JQBC9+bMAK1BBHGCgFZRIGXGXAGCa9MQBAKCFJRKSFMAK1BFHGCgBZCOWAICgBZqRIGXAGCa9MQBAKCGJRKSFMAK1BGHGCgBZCfWAIqRIGXAGCa9MQBAKCEJRKSFMAK1BEHGCgBZCdWAIqRIGXAGCa9MQBAKCIJRKSFMAK2BIC8cWAIqRIAKCLJRKMABAICGrCBAICFrCFZl9zALCNJAICFZCGWqHI8oGBJHG87FBAIAGjGBABCGJRBAFCaJHFQBMMCBC99AKAE6yRKMAKM+lLKFaF99GaG99FaG99GXGXAGCI9HQBAF9FQFEXGXGX9DBBB8/9DBBB+/ABCGJHG1BB+yAB1BBHE+yHI+L+TABCFJHL1BBHK+yHO+L+THN9DBBBB9gHVyAN9DBB/+hANAN+U9DBBBBANAVyHcAc+MHMAECa3yAI+SHIAI+UAcAMAKCa3yAO+SHcAc+U+S+S+R+VHO+U+SHN+L9DBBB9P9d9FQBAN+oRESFMCUUUU94REMAGAE86BBGXGX9DBBB8/9DBBB+/Ac9DBBBB9gyAcAO+U+SHN+L9DBBB9P9d9FQBAN+oRGSFMCUUUU94RGMALAG86BBGXGX9DBBB8/9DBBB+/AI9DBBBB9gyAIAO+U+SHN+L9DBBB9P9d9FQBAN+oRGSFMCUUUU94RGMABAG86BBABCIJRBAFCaJHFQBSGMMAF9FQBEXGXGX9DBBB8/9DBBB+/ABCIJHG8uFB+yAB8uFBHE+yHI+L+TABCGJHL8uFBHK+yHO+L+THN9DBBBB9gHVyAN9DB/+g6ANAN+U9DBBBBANAVyHcAc+MHMAECa3yAI+SHIAI+UAcAMAKCa3yAO+SHcAc+U+S+S+R+VHO+U+SHN+L9DBBB9P9d9FQBAN+oRESFMCUUUU94REMAGAE87FBGXGX9DBBB8/9DBBB+/Ac9DBBBB9gyAcAO+U+SHN+L9DBBB9P9d9FQBAN+oRGSFMCUUUU94RGMALAG87FBGXGX9DBBB8/9DBBB+/AI9DBBBB9gyAIAO+U+SHN+L9DBBB9P9d9FQBAN+oRGSFMCUUUU94RGMABAG87FBABCNJRBAFCaJHFQBMMM/SEIEaE99EaF99GXAF9FQBCBREABRIEXGXGX9D/zI818/AICKJ8uFBHLCEq+y+VHKAI8uFB+y+UHO9DB/+g6+U9DBBB8/9DBBB+/AO9DBBBB9gy+SHN+L9DBBB9P9d9FQBAN+oRVSFMCUUUU94RVMAICIJ8uFBRcAICGJ8uFBRMABALCFJCEZAEqCFWJAV87FBGXGXAKAM+y+UHN9DB/+g6+U9DBBB8/9DBBB+/AN9DBBBB9gy+SHS+L9DBBB9P9d9FQBAS+oRMSFMCUUUU94RMMABALCGJCEZAEqCFWJAM87FBGXGXAKAc+y+UHK9DB/+g6+U9DBBB8/9DBBB+/AK9DBBBB9gy+SHS+L9DBBB9P9d9FQBAS+oRcSFMCUUUU94RcMABALCaJCEZAEqCFWJAc87FBGXGX9DBBU8/AOAO+U+TANAN+U+TAKAK+U+THO9DBBBBAO9DBBBB9gy+R9DB/+g6+U9DBBB8/+SHO+L9DBBB9P9d9FQBAO+oRcSFMCUUUU94RcMABALCEZAEqCFWJAc87FBAICNJRIAECIJREAFCaJHFQBMMM9JBGXAGCGrAF9sHF9FQBEXABAB8oGBHGCNWCN91+yAGCi91CnWCUUU/8EJ+++U84GBABCIJRBAFCaJHFQBMMM9TFEaCBCB8oGUkUUBHFABCEJC98ZJHBjGUkUUBGXGXAB8/BCTWHGuQBCaREABAGlCggEJCTrXBCa6QFMAFREMAEM/lFFFaGXGXAFABqCEZ9FQBABRESFMGXGXAGCT9PQBABRESFMABREEXAEAF8oGBjGBAECIJAFCIJ8oGBjGBAECNJAFCNJ8oGBjGBAECSJAFCSJ8oGBjGBAECTJREAFCTJRFAGC9wJHGCb9LQBMMAGCI9JQBEXAEAF8oGBjGBAFCIJRFAECIJREAGC98JHGCE9LQBMMGXAG9FQBEXAEAF2BB86BBAECFJREAFCFJRFAGCaJHGQBMMABMoFFGaGXGXABCEZ9FQBABRESFMAFCgFZC+BwsN9sRIGXGXAGCT9PQBABRESFMABREEXAEAIjGBAECSJAIjGBAECNJAIjGBAECIJAIjGBAECTJREAGC9wJHGCb9LQBMMAGCI9JQBEXAEAIjGBAECIJREAGC98JHGCE9LQBMMGXAG9FQBEXAEAF86BBAECFJREAGCaJHGQBMMABMMMFBCUNMIT9kBB",XP="B9h9z9tFBBBF8dL9gBB9gLaaaaaFa9gEaaaB9gGaaB9gFaFaEQSBBFBFFGEGEGIILF9wFFFLEFBFKNFaFCx/aFMO/LFVK9tv9t9vq95GBt9f9f939h9z9t9f9j9h9s9s9f9jW9vq9zBBp9tv9z9o9v9wW9f9kv9j9v9kv9WvqWv94h919m9mvqBG8Z9tv9z9o9v9wW9f9kv9j9v9kv9J9u9kv94h919m9mvqBIy9tv9z9o9v9wW9f9kv9j9v9kv9J9u9kv949TvZ91v9u9jvBLn9tv9z9o9v9wW9f9kv9j9v9kv69p9sWvq9P9jWBKi9tv9z9o9v9wW9f9kv9j9v9kv69p9sWvq9R919hWBNn9tv9z9o9v9wW9f9kv9j9v9kv69p9sWvq9F949wBcI9z9iqlBMc/j9JSIBTEM9+FLa8jUUUUBCTlRBCBRFEXCBRGCBREEXABCNJAGJAECUaAFAGrCFZHIy86BBAEAIJREAGCFJHGCN9HQBMAFCx+YUUBJAE86BBAFCEWCxkUUBJAB8pEN83EBAFCFJHFCUG9HQBMMkRIbaG97FaK978jUUUUBCU/KBlHL8kUUUUBC9+RKGXAGCFJAI9LQBCaRKAE2BBC+gF9HQBALAEAIJHOAGlAG/8cBBCUoBAG9uC/wgBZHKCUGAKCUG9JyRNAECFJRKCBRVGXEXAVAF9PQFANAFAVlAVANJAF9JyRcGXGXAG9FQBAcCbJHIC9wZHMCE9sRSAMCFWRQAICIrCEJCGrRfCBRbEXAKRTCBRtGXEXGXAOATlAf9PQBCBRKSLMALCU/CBJAtAM9sJRmATAfJRKCBREGXAMCoB9JQBAOAKlC/gB9JQBCBRIEXAmAIJREGXGXGXGXGXATAICKrJ2BBHYCEZfIBFGEBMAECBDtDMIBSEMAEAKDBBIAKDBBBHPCID+MFAPDQBTFtGmEYIPLdKeOnHPCGD+MFAPDQBTFtGmEYIPLdKeOnC0+G+MiDtD9OHdCEDbD8jHPD8dBhUg/8/4/w/goB9+h84k7HeCEWCxkUUBJDBEBAeCx+YUUBJDBBBHnAnDQBBBBBBBBBBBBBBBBAPD8dFhUg/8/4/w/goB9+h84k7HeCEWCxkUUBJDBEBD9uDQBFGEILKOTtmYPdenDfAdAPD9SDMIBAKCIJAnDeBJAeCx+YUUBJ2BBJRKSGMAEAKDBBNAKDBBBHPCID+MFAPDQBTFtGmEYIPLdKeOnC+P+e+8/4BDtD9OHdCbDbD8jHPD8dBhUg/8/4/w/goB9+h84k7HeCEWCxkUUBJDBEBAeCx+YUUBJDBBBHnAnDQBBBBBBBBBBBBBBBBAPD8dFhUg/8/4/w/goB9+h84k7HeCEWCxkUUBJDBEBD9uDQBFGEILKOTtmYPdenDfAdAPD9SDMIBAKCNJAnDeBJAeCx+YUUBJ2BBJRKSFMAEAKDBBBDMIBAKCTJRKMGXGXGXGXGXAYCGrCEZfIBFGEBMAECBDtDMITSEMAEAKDBBIAKDBBBHPCID+MFAPDQBTFtGmEYIPLdKeOnHPCGD+MFAPDQBTFtGmEYIPLdKeOnC0+G+MiDtD9OHdCEDbD8jHPD8dBhUg/8/4/w/goB9+h84k7HeCEWCxkUUBJDBEBAeCx+YUUBJDBBBHnAnDQBBBBBBBBBBBBBBBBAPD8dFhUg/8/4/w/goB9+h84k7HeCEWCxkUUBJDBEBD9uDQBFGEILKOTtmYPdenDfAdAPD9SDMITAKCIJAnDeBJAeCx+YUUBJ2BBJRKSGMAEAKDBBNAKDBBBHPCID+MFAPDQBTFtGmEYIPLdKeOnC+P+e+8/4BDtD9OHdCbDbD8jHPD8dBhUg/8/4/w/goB9+h84k7HeCEWCxkUUBJDBEBAeCx+YUUBJDBBBHnAnDQBBBBBBBBBBBBBBBBAPD8dFhUg/8/4/w/goB9+h84k7HeCEWCxkUUBJDBEBD9uDQBFGEILKOTtmYPdenDfAdAPD9SDMITAKCNJAnDeBJAeCx+YUUBJ2BBJRKSFMAEAKDBBBDMITAKCTJRKMGXGXGXGXGXAYCIrCEZfIBFGEBMAECBDtDMIASEMAEAKDBBIAKDBBBHPCID+MFAPDQBTFtGmEYIPLdKeOnHPCGD+MFAPDQBTFtGmEYIPLdKeOnC0+G+MiDtD9OHdCEDbD8jHPD8dBhUg/8/4/w/goB9+h84k7HeCEWCxkUUBJDBEBAeCx+YUUBJDBBBHnAnDQBBBBBBBBBBBBBBBBAPD8dFhUg/8/4/w/goB9+h84k7HeCEWCxkUUBJDBEBD9uDQBFGEILKOTtmYPdenDfAdAPD9SDMIAAKCIJAnDeBJAeCx+YUUBJ2BBJRKSGMAEAKDBBNAKDBBBHPCID+MFAPDQBTFtGmEYIPLdKeOnC+P+e+8/4BDtD9OHdCbDbD8jHPD8dBhUg/8/4/w/goB9+h84k7HeCEWCxkUUBJDBEBAeCx+YUUBJDBBBHnAnDQBBBBBBBBBBBBBBBBAPD8dFhUg/8/4/w/goB9+h84k7HeCEWCxkUUBJDBEBD9uDQBFGEILKOTtmYPdenDfAdAPD9SDMIAAKCNJAnDeBJAeCx+YUUBJ2BBJRKSFMAEAKDBBBDMIAAKCTJRKMGXGXGXGXGXAYCKrfIBFGEBMAECBDtDMI8wSEMAEAKDBBIAKDBBBHPCID+MFAPDQBTFtGmEYIPLdKeOnHPCGD+MFAPDQBTFtGmEYIPLdKeOnC0+G+MiDtD9OHdCEDbD8jHPD8dBhUg/8/4/w/goB9+h84k7HYCEWCxkUUBJDBEBAYCx+YUUBJDBBBHnAnDQBBBBBBBBBBBBBBBBAPD8dFhUg/8/4/w/goB9+h84k7HYCEWCxkUUBJDBEBD9uDQBFGEILKOTtmYPdenDfAdAPD9SDMI8wAKCIJAnDeBJAYCx+YUUBJ2BBJRKSGMAEAKDBBNAKDBBBHPCID+MFAPDQBTFtGmEYIPLdKeOnC+P+e+8/4BDtD9OHdCbDbD8jHPD8dBhUg/8/4/w/goB9+h84k7HYCEWCxkUUBJDBEBAYCx+YUUBJDBBBHnAnDQBBBBBBBBBBBBBBBBAPD8dFhUg/8/4/w/goB9+h84k7HYCEWCxkUUBJDBEBD9uDQBFGEILKOTtmYPdenDfAdAPD9SDMI8wAKCNJAnDeBJAYCx+YUUBJ2BBJRKSFMAEAKDBBBDMI8wAKCTJRKMAICoBJREAICUFJAM9LQFAERIAOAKlC/fB9LQBMMGXAEAM9PQBAECErRIEXGXAOAKlCi9PQBCBRKSOMAmAEJRYGXGXGXGXGXATAECKrJ2BBAICKZrCEZfIBFGEBMAYCBDtDMIBSEMAYAKDBBIAKDBBBHPCID+MFAPDQBTFtGmEYIPLdKeOnHPCGD+MFAPDQBTFtGmEYIPLdKeOnC0+G+MiDtD9OHdCEDbD8jHPD8dBhUg/8/4/w/goB9+h84k7HeCEWCxkUUBJDBEBAeCx+YUUBJDBBBHnAnDQBBBBBBBBBBBBBBBBAPD8dFhUg/8/4/w/goB9+h84k7HeCEWCxkUUBJDBEBD9uDQBFGEILKOTtmYPdenDfAdAPD9SDMIBAKCIJAnDeBJAeCx+YUUBJ2BBJRKSGMAYAKDBBNAKDBBBHPCID+MFAPDQBTFtGmEYIPLdKeOnC+P+e+8/4BDtD9OHdCbDbD8jHPD8dBhUg/8/4/w/goB9+h84k7HeCEWCxkUUBJDBEBAeCx+YUUBJDBBBHnAnDQBBBBBBBBBBBBBBBBAPD8dFhUg/8/4/w/goB9+h84k7HeCEWCxkUUBJDBEBD9uDQBFGEILKOTtmYPdenDfAdAPD9SDMIBAKCNJAnDeBJAeCx+YUUBJ2BBJRKSFMAYAKDBBBDMIBAKCTJRKMAICGJRIAECTJHEAM9JQBMMGXAK9FQBAKRTAtCFJHtCI6QGSFMMCBRKSEMGXAM9FQBALCUGJAbJREALAbJDBGBRnCBRYEXAEALCU/CBJAYJHIDBIBHdCFD9tAdCFDbHPD9OD9hD9RHdAIAMJDBIBHiCFD9tAiAPD9OD9hD9RHiDQBTFtGmEYIPLdKeOnH8ZAIAQJDBIBHpCFD9tApAPD9OD9hD9RHpAIASJDBIBHyCFD9tAyAPD9OD9hD9RHyDQBTFtGmEYIPLdKeOnH8cDQBFTtGEmYILPdKOenHPAPDQBFGEBFGEBFGEBFGEAnD9uHnDyBjGBAEAGJHIAnAPAPDQILKOILKOILKOILKOD9uHnDyBjGBAIAGJHIAnAPAPDQNVcMNVcMNVcMNVcMD9uHnDyBjGBAIAGJHIAnAPAPDQSQfbSQfbSQfbSQfbD9uHnDyBjGBAIAGJHIAnA8ZA8cDQNVi8ZcMpySQ8c8dfb8e8fHPAPDQBFGEBFGEBFGEBFGED9uHnDyBjGBAIAGJHIAnAPAPDQILKOILKOILKOILKOD9uHnDyBjGBAIAGJHIAnAPAPDQNVcMNVcMNVcMNVcMD9uHnDyBjGBAIAGJHIAnAPAPDQSQfbSQfbSQfbSQfbD9uHnDyBjGBAIAGJHIAnAdAiDQNiV8ZcpMyS8cQ8df8eb8fHdApAyDQNiV8ZcpMyS8cQ8df8eb8fHiDQBFTtGEmYILPdKOenHPAPDQBFGEBFGEBFGEBFGED9uHnDyBjGBAIAGJHIAnAPAPDQILKOILKOILKOILKOD9uHnDyBjGBAIAGJHIAnAPAPDQNVcMNVcMNVcMNVcMD9uHnDyBjGBAIAGJHIAnAPAPDQSQfbSQfbSQfbSQfbD9uHnDyBjGBAIAGJHIAnAdAiDQNVi8ZcMpySQ8c8dfb8e8fHPAPDQBFGEBFGEBFGEBFGED9uHnDyBjGBAIAGJHIAnAPAPDQILKOILKOILKOILKOD9uHnDyBjGBAIAGJHIAnAPAPDQNVcMNVcMNVcMNVcMD9uHnDyBjGBAIAGJHIAnAPAPDQSQfbSQfbSQfbSQfbD9uHnDyBjGBAIAGJREAYCTJHYAM9JQBMMAbCIJHbAG9JQBMMABAVAG9sJALCUGJAcAG9s/8cBBALALCUGJAcCaJAG9sJAG/8cBBMAcCBAKyAVJRVAKQBMC9+RKSFMCBC99AOAKlAGCAAGCA9Ly6yRKMALCU/KBJ8kUUUUBAKMNBT+BUUUBM+KmFTa8jUUUUBCoFlHL8kUUUUBC9+RKGXAFCE9uHOCtJAI9LQBCaRKAE2BBHNC/wFZC/gF9HQBANCbZHVCF9LQBALCoBJCgFCUF/8MBALC84Jha83EBALC8wJha83EBALC8oJha83EBALCAJha83EBALCiJha83EBALCTJha83EBALha83ENALha83EBAEAIJC9wJRcAECFJHNAOJRMGXAF9FQBCQCbAVCF6yRSABRECBRVCBRQCBRfCBRICBRKEXGXAMAcuQBC9+RKSEMGXGXAN2BBHOC/vF9LQBALCoBJAOCIrCa9zAKJCbZCEWJHb8oGIRTAb8oGBRtGXAOCbZHbAS9PQBALAOCa9zAIJCbZCGWJ8oGBAVAbyROAb9FRbGXGXAGCG9HQBABAt87FBABCIJAO87FBABCGJAT87FBSFMAEAtjGBAECNJAOjGBAECIJATjGBMAVAbJRVALCoBJAKCEWJHmAOjGBAmATjGIALAICGWJAOjGBALCoBJAKCFJCbZHKCEWJHTAtjGBATAOjGIAIAbJRIAKCFJRKSGMGXGXAbCb6QBAQAbJAbC989zJCFJRQSFMAM1BBHbCgFZROGXGXAbCa9MQBAMCFJRMSFMAM1BFHbCgBZCOWAOCgBZqROGXAbCa9MQBAMCGJRMSFMAM1BGHbCgBZCfWAOqROGXAbCa9MQBAMCEJRMSFMAM1BEHbCgBZCdWAOqROGXAbCa9MQBAMCIJRMSFMAM2BIC8cWAOqROAMCLJRMMAOCFrCBAOCFZl9zAQJRQMGXGXAGCG9HQBABAt87FBABCIJAQ87FBABCGJAT87FBSFMAEAtjGBAECNJAQjGBAECIJATjGBMALCoBJAKCEWJHOAQjGBAOATjGIALAICGWJAQjGBALCoBJAKCFJCbZHKCEWJHOAtjGBAOAQjGIAICFJRIAKCFJRKSFMGXAOCDF9LQBALAIAcAOCbZJ2BBHbCIrHTlCbZCGWJ8oGBAVCFJHtATyROALAIAblCbZCGWJ8oGBAtAT9FHmJHtAbCbZHTyRbAT9FRTGXGXAGCG9HQBABAV87FBABCIJAb87FBABCGJAO87FBSFMAEAVjGBAECNJAbjGBAECIJAOjGBMALAICGWJAVjGBALCoBJAKCEWJHYAOjGBAYAVjGIALAICFJHICbZCGWJAOjGBALCoBJAKCFJCbZCEWJHYAbjGBAYAOjGIALAIAmJCbZHICGWJAbjGBALCoBJAKCGJCbZHKCEWJHOAVjGBAOAbjGIAKCFJRKAIATJRIAtATJRVSFMAVCBAM2BBHYyHTAOC/+F6HPJROAYCbZRtGXGXAYCIrHmQBAOCFJRbSFMAORbALAIAmlCbZCGWJ8oGBROMGXGXAtQBAbCFJRVSFMAbRVALAIAYlCbZCGWJ8oGBRbMGXGXAP9FQBAMCFJRYSFMAM1BFHYCgFZRTGXGXAYCa9MQBAMCGJRYSFMAM1BGHYCgBZCOWATCgBZqRTGXAYCa9MQBAMCEJRYSFMAM1BEHYCgBZCfWATqRTGXAYCa9MQBAMCIJRYSFMAM1BIHYCgBZCdWATqRTGXAYCa9MQBAMCLJRYSFMAMCKJRYAM2BLC8cWATqRTMATCFrCBATCFZl9zAQJHQRTMGXGXAmCb6QBAYRPSFMAY1BBHMCgFZROGXGXAMCa9MQBAYCFJRPSFMAY1BFHMCgBZCOWAOCgBZqROGXAMCa9MQBAYCGJRPSFMAY1BGHMCgBZCfWAOqROGXAMCa9MQBAYCEJRPSFMAY1BEHMCgBZCdWAOqROGXAMCa9MQBAYCIJRPSFMAYCLJRPAY2BIC8cWAOqROMAOCFrCBAOCFZl9zAQJHQROMGXGXAtCb6QBAPRMSFMAP1BBHMCgFZRbGXGXAMCa9MQBAPCFJRMSFMAP1BFHMCgBZCOWAbCgBZqRbGXAMCa9MQBAPCGJRMSFMAP1BGHMCgBZCfWAbqRbGXAMCa9MQBAPCEJRMSFMAP1BEHMCgBZCdWAbqRbGXAMCa9MQBAPCIJRMSFMAPCLJRMAP2BIC8cWAbqRbMAbCFrCBAbCFZl9zAQJHQRbMGXGXAGCG9HQBABAT87FBABCIJAb87FBABCGJAO87FBSFMAEATjGBAECNJAbjGBAECIJAOjGBMALCoBJAKCEWJHYAOjGBAYATjGIALAICGWJATjGBALCoBJAKCFJCbZCEWJHYAbjGBAYAOjGIALAICFJHICbZCGWJAOjGBALCoBJAKCGJCbZCEWJHOATjGBAOAbjGIALAIAm9FAmCb6qJHICbZCGWJAbjGBAIAt9FAtCb6qJRIAKCEJRKMANCFJRNABCKJRBAECSJREAKCbZRKAICbZRIAfCEJHfAF9JQBMMCBC99AMAc6yRKMALCoFJ8kUUUUBAKM/tIFGa8jUUUUBCTlRLC9+RKGXAFCLJAI9LQBCaRKAE2BBC/+FZC/QF9HQBALhB83ENAECFJRKAEAIJC98JREGXAF9FQBGXAGCG6QBEXGXAKAE9JQBC9+bMAK1BBHGCgFZRIGXGXAGCa9MQBAKCFJRKSFMAK1BFHGCgBZCOWAICgBZqRIGXAGCa9MQBAKCGJRKSFMAK1BGHGCgBZCfWAIqRIGXAGCa9MQBAKCEJRKSFMAK1BEHGCgBZCdWAIqRIGXAGCa9MQBAKCIJRKSFMAK2BIC8cWAIqRIAKCLJRKMALCNJAICFZCGWqHGAICGrCBAICFrCFZl9zAG8oGBJHIjGBABAIjGBABCIJRBAFCaJHFQBSGMMEXGXAKAE9JQBC9+bMAK1BBHGCgFZRIGXGXAGCa9MQBAKCFJRKSFMAK1BFHGCgBZCOWAICgBZqRIGXAGCa9MQBAKCGJRKSFMAK1BGHGCgBZCfWAIqRIGXAGCa9MQBAKCEJRKSFMAK1BEHGCgBZCdWAIqRIGXAGCa9MQBAKCIJRKSFMAK2BIC8cWAIqRIAKCLJRKMABAICGrCBAICFrCFZl9zALCNJAICFZCGWqHI8oGBJHG87FBAIAGjGBABCGJRBAFCaJHFQBMMCBC99AKAE6yRKMAKM/xLGEaK978jUUUUBCAlHE8kUUUUBGXGXAGCI9HQBGXAFC98ZHI9FQBABRGCBRLEXAGAGDBBBHKCiD+rFCiD+sFD/6FHOAKCND+rFCiD+sFD/6FAOD/gFAKCTD+rFCiD+sFD/6FHND/gFD/kFD/lFHVCBDtD+2FHcAOCUUUU94DtHMD9OD9RD/kFHO9DBB/+hDYAOAOD/mFAVAVD/mFANAcANAMD9OD9RD/kFHOAOD/mFD/kFD/kFD/jFD/nFHND/mF9DBBX9LDYHcD/kFCgFDtD9OAKCUUU94DtD9OD9QAOAND/mFAcD/kFCND+rFCU/+EDtD9OD9QAVAND/mFAcD/kFCTD+rFCUU/8ODtD9OD9QDMBBAGCTJRGALCIJHLAI9JQBMMAIAF9PQFAEAFCEZHLCGWHGqCBCTAGl/8MBAEABAICGWJHIAG/8cBBGXAL9FQBAEAEDBIBHKCiD+rFCiD+sFD/6FHOAKCND+rFCiD+sFD/6FAOD/gFAKCTD+rFCiD+sFD/6FHND/gFD/kFD/lFHVCBDtD+2FHcAOCUUUU94DtHMD9OD9RD/kFHO9DBB/+hDYAOAOD/mFAVAVD/mFANAcANAMD9OD9RD/kFHOAOD/mFD/kFD/kFD/jFD/nFHND/mF9DBBX9LDYHcD/kFCgFDtD9OAKCUUU94DtD9OD9QAOAND/mFAcD/kFCND+rFCU/+EDtD9OD9QAVAND/mFAcD/kFCTD+rFCUU/8ODtD9OD9QDMIBMAIAEAG/8cBBSFMABAFC98ZHGT+HUUUBAGAF9PQBAEAFCEZHICEWHLJCBCAALl/8MBAEABAGCEWJHGAL/8cBBAEAIT+HUUUBAGAEAL/8cBBMAECAJ8kUUUUBM+yEGGaO97GXAF9FQBCBRGEXABCTJHEAEDBBBHICBDtHLCUU98D8cFCUU98D8cEHKD9OABDBBBHOAIDQILKOSQfbPden8c8d8e8fCggFDtD9OD/6FAOAIDQBFGENVcMTtmYi8ZpyHICTD+sFD/6FHND/gFAICTD+rFCTD+sFD/6FHVD/gFD/kFD/lFHI9DB/+g6DYAVAIALD+2FHLAVCUUUU94DtHcD9OD9RD/kFHVAVD/mFAIAID/mFANALANAcD9OD9RD/kFHIAID/mFD/kFD/kFD/jFD/nFHND/mF9DBBX9LDYHLD/kFCTD+rFAVAND/mFALD/kFCggEDtD9OD9QHVAIAND/mFALD/kFCaDbCBDnGCBDnECBDnKCBDnOCBDncCBDnMCBDnfCBDnbD9OHIDQNVi8ZcMpySQ8c8dfb8e8fD9QDMBBABAOAKD9OAVAIDQBFTtGEmYILPdKOenD9QDMBBABCAJRBAGCIJHGAF9JQBMMM94FEa8jUUUUBCAlHE8kUUUUBABAFC98ZHIT+JUUUBGXAIAF9PQBAEAFCEZHLCEWHFJCBCAAFl/8MBAEABAICEWJHBAF/8cBBAEALT+JUUUBABAEAF/8cBBMAECAJ8kUUUUBM/hEIGaF97FaL978jUUUUBCTlRGGXAF9FQBCBREEXAGABDBBBHIABCTJHLDBBBHKDQILKOSQfbPden8c8d8e8fHOCTD+sFHNCID+rFDMIBAB9DBBU8/DY9D/zI818/DYANCEDtD9QD/6FD/nFHNAIAKDQBFGENVcMTtmYi8ZpyHICTD+rFCTD+sFD/6FD/mFHKAKD/mFANAICTD+sFD/6FD/mFHVAVD/mFANAOCTD+rFCTD+sFD/6FD/mFHOAOD/mFD/kFD/kFD/lFCBDtD+4FD/jF9DB/+g6DYHND/mF9DBBX9LDYHID/kFCggEDtHcD9OAVAND/mFAID/kFCTD+rFD9QHVAOAND/mFAID/kFCTD+rFAKAND/mFAID/kFAcD9OD9QHNDQBFTtGEmYILPdKOenHID8dBAGDBIBDyB+t+J83EBABCNJAID8dFAGDBIBDyF+t+J83EBALAVANDQNVi8ZcMpySQ8c8dfb8e8fHND8dBAGDBIBDyG+t+J83EBABCiJAND8dFAGDBIBDyE+t+J83EBABCAJRBAECIJHEAF9JQBMMM/3FGEaF978jUUUUBCoBlREGXAGCGrAF9sHIC98ZHL9FQBCBRGABRFEXAFAFDBBBHKCND+rFCND+sFD/6FAKCiD+sFCnD+rFCUUU/8EDtD+uFD/mFDMBBAFCTJRFAGCIJHGAL9JQBMMGXALAI9PQBAEAICEZHGCGWHFqCBCoBAFl/8MBAEABALCGWJHLAF/8cBBGXAG9FQBAEAEDBIBHKCND+rFCND+sFD/6FAKCiD+sFCnD+rFCUUU/8EDtD+uFD/mFDMIBMALAEAF/8cBBMM9TFEaCBCB8oGUkUUBHFABCEJC98ZJHBjGUkUUBGXGXAB8/BCTWHGuQBCaREABAGlCggEJCTrXBCa6QFMAFREMAEMMMFBCUNMIT9tBB",JP=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]),YP=new Uint8Array([32,0,65,253,3,1,2,34,4,106,6,5,11,8,7,20,13,33,12,16,128,9,116,64,19,113,127,15,10,21,22,14,255,66,24,54,136,107,18,23,192,26,114,118,132,17,77,101,130,144,27,87,131,44,45,74,156,154,70,167]),eR={0:"",1:"meshopt_decodeFilterOct",2:"meshopt_decodeFilterQuat",3:"meshopt_decodeFilterExp",NONE:"",OCTAHEDRAL:"meshopt_decodeFilterOct",QUATERNION:"meshopt_decodeFilterQuat",EXPONENTIAL:"meshopt_decodeFilterExp"},tR={0:"meshopt_decodeVertexBuffer",1:"meshopt_decodeIndexBuffer",2:"meshopt_decodeIndexSequence",ATTRIBUTES:"meshopt_decodeVertexBuffer",TRIANGLES:"meshopt_decodeIndexBuffer",INDICES:"meshopt_decodeIndexSequence"};async function iR(e,t,i,r,n,o="NONE"){const s=await async function(){rR||(rR=async function(){let e=KP;WebAssembly.validate(JP)&&(e=XP,console.log("Warning: meshopt_decoder is using experimental SIMD support"));const t=await WebAssembly.instantiate(function(e){const t=new Uint8Array(e.length);for(let i=0;i96?r-71:r>64?r-65:r>47?r+4:r>46?63:62}let i=0;for(let r=0;rthis.decoder[e]).includes(r);if(n){const t=new this.draco.AttributeQuantizationTransform;try{if(t.InitFromAttribute(e))return{quantization_bits:t.quantization_bits(),range:t.range(),min_values:new Float32Array([1,2,3]).map(e=>t.min_value(e))}}finally{this.draco.destroy(t)}}return null}_getOctahedronTransform(e,t){const{octahedronAttributes:i=[]}=t,r=e.attribute_type(),n=i.map(e=>this.decoder[e]).includes(r);if(n){const t=new this.draco.AttributeQuantizationTransform;try{if(t.InitFromAttribute(e))return{quantization_bits:t.quantization_bits()}}finally{this.draco.destroy(t)}}return null}}const xR=(globalThis._loadersgl_?.version||(globalThis._loadersgl_=globalThis._loadersgl_||{},globalThis._loadersgl_.version="4.3.3"),globalThis._loadersgl_.version);const bR="object"!=typeof process||"[object process]"!==String(process)||process.browser,wR="function"==typeof importScripts,TR="undefined"!=typeof process&&process.version&&/v([0-9]*)/.exec(process.version);TR&&parseFloat(TR[1]);const ER={};async function CR(e,t=null,i={},r=null){return t&&(e=function(e,t,i={},r=null){if(!i.useLocalLibraries&&e.startsWith("http"))return e;r=r||e;const n=i.modules||{};if(n[r])return n[r];if(!bR)return`modules/${t}/dist/libs/${r}`;if(i.CDN)return function(e,t){if(!e)throw new Error(t||"loaders.gl assertion failed.")}(i.CDN.startsWith("http")),`${i.CDN}/${t}@${xR}/dist/libs/${r}`;if(wR)return`../src/libs/${r}`;return`modules/${t}/src/libs/${r}`}(e,t,i,r)),ER[e]=ER[e]||async function(e){if(e.endsWith("wasm"))return await async function(e){const{readFileAsArrayBuffer:t}=globalThis.loaders||{};if(bR||!t||e.startsWith("http")){const t=await fetch(e);return await t.arrayBuffer()}return await t(e)}(e);if(!bR)try{const{requireFromFile:t}=globalThis.loaders||{};return await(t?.(e))}catch(e){return console.error(e),null}if(wR)return importScripts(e);const t=await async function(e){const{readFileAsText:t}=globalThis.loaders||{};if(bR||!t||e.startsWith("http")){const t=await fetch(e);return await t.text()}return await t(e)}(e);return function(e,t){if(!bR){const{requireFromString:i}=globalThis.loaders||{};return i?.(e,t)}if(wR)return eval.call(globalThis,e),null;const i=document.createElement("script");i.id=t;try{i.appendChild(document.createTextNode(e))}catch(t){i.text=e}return document.body.appendChild(i),null}(t,e)}(e),await ER[e]}const BR="https://www.gstatic.com/draco/versioned/decoders/1.5.6",SR="draco_wasm_wrapper.js",IR="draco_decoder.wasm",MR="draco_decoder.js",PR="draco_encoder.js",RR={[SR]:`${BR}/${SR}`,[IR]:`${BR}/${IR}`,[MR]:`${BR}/${MR}`,[PR]:`https://raw.githubusercontent.com/google/draco/1.4.1/javascript/${PR}`};let LR;async function FR(e){const t=e.modules||{};return t.draco3d?LR||=t.draco3d.createDecoderModule({}).then(e=>({draco:e})):LR||=async function(e){let t,i;if("js"===(e.draco&&e.draco.decoderType))t=await CR(RR[MR],"draco",e,MR);else[t,i]=await Promise.all([await CR(RR[SR],"draco",e,SR),await CR(RR[IR],"draco",e,IR)]);return t=t||globalThis.DracoDecoderModule,await function(e,t){const i={};t&&(i.wasmBinary=t);return new Promise(t=>{e({...i,onModuleLoaded:e=>t({draco:e})})})}(t,i)}(e),await LR}const kR={...mR,parse:async function(e,t){const{draco:i}=await FR(t),r=new vR(i);try{return r.parseSync(e,t?.draco)}finally{r.destroy()}}};function DR(e){const{buffer:t,size:i,count:r}=function(e){let t=e,i=1,r=0;e&&e.value&&(t=e.value,i=e.size||1);t&&(ArrayBuffer.isView(t)||(t=function(e,t,i=!1){if(!e)return null;if(Array.isArray(e))return new t(e);if(i&&!(e instanceof t))return new t(e);return e}(t,Float32Array)),r=t.length/i);return{buffer:t,size:i,count:r}}(e);return{value:t,size:i,byteOffset:0,count:r,type:qM(i),componentType:KM(t)}}const OR="KHR_draco_mesh_compression",zR=OR;async function UR(e,t,i,r){const n=e.getObjectExtension(t,OR);if(!n)return;const o=e.getTypedArrayForBufferView(n.bufferView),s=vh(o.buffer,o.byteOffset),a={...i};delete a["3d-tiles"];const l=await wu(s,kR,a,r),c=function(e){const t={};for(const i in e){const r=e[i];if("indices"!==i){const e=DR(r);t[i]=e}}return t}(l.attributes);for(const[i,r]of Object.entries(c))if(i in t.attributes){const n=t.attributes[i],o=e.getAccessor(n);o?.min&&o?.max&&(r.min=o.min,r.max=o.max)}t.attributes=c,l.indices&&(t.indices=DR(l.indices)),e.removeObjectExtension(t,OR),function(e){if(!e.attributes&&Object.keys(e.attributes).length>0)throw new Error("glTF: Empty primitive detected: Draco decompression failure?")}(t)}function NR(e,t,i=4,r,n){if(!r.DracoWriter)throw new Error("options.gltf.DracoWriter not provided");const o=r.DracoWriter.encodeSync({attributes:e}),s=n?.parseSync?.({attributes:e}),a=r._addFauxAttributes(s.attributes),l=r.addBufferView(o);return{primitives:[{attributes:a,mode:i,extensions:{[OR]:{bufferView:l,attributes:a}}}]}}function*VR(e){for(const t of e.json.meshes||[])for(const e of t.primitives)yield e}var jR=Object.freeze({__proto__:null,name:zR,preprocess:function(e,t,i){const r=new YM(e);for(const e of VR(r))r.getObjectExtension(e,OR)},decode:async function(e,t,i){if(!t?.gltf?.decompressMeshes)return;const r=new YM(e),n=[];for(const e of VR(r))r.getObjectExtension(e,OR)&&n.push(UR(r,e,t,i));await Promise.all(n),r.removeExtension(OR)},encode:function(e,t={}){const i=new YM(e);for(const e of i.json.meshes||[])NR(e),i.addRequiredExtension(OR)}});const GR="KHR_texture_transform",HR=GR,QR=new mA,$R=new bA,ZR=new bA;function WR(e,t){const i=t.json.materials?.[e],r=[i?.pbrMetallicRoughness?.baseColorTexture,i?.emissiveTexture,i?.normalTexture,i?.occlusionTexture,i?.pbrMetallicRoughness?.metallicRoughnessTexture],n=[];for(const i of r)i&&i?.extensions?.[GR]&&qR(t,e,i,n)}function qR(e,t,i,r){const n=function(e,t){const i=e.extensions?.[GR],{texCoord:r=0}=e,{texCoord:n=r}=i,o=-1!==t.findIndex(([e,t])=>e===r&&t===n);if(!o){const o=function(e){const{offset:t=[0,0],rotation:i=0,scale:r=[1,1]}=e,n=(new bA).set(1,0,0,0,1,0,t[0],t[1],1),o=$R.set(Math.cos(i),Math.sin(i),0,-Math.sin(i),Math.cos(i),0,0,0,1),s=ZR.set(r[0],0,0,0,r[1],0,0,0,1);return n.multiplyRight(o).multiplyRight(s)}(i);return r!==n&&(e.texCoord=n),t.push([r,n]),{originalTexCoord:r,texCoord:n,matrix:o}}return null}(i,r);if(!n)return;const o=e.json.meshes||[];for(const i of o)for(const r of i.primitives){const i=r.material;Number.isFinite(i)&&t===i&&KR(e,r,n)}}function KR(e,t,i){const{originalTexCoord:r,texCoord:n,matrix:o}=i,s=t.attributes[`TEXCOORD_${r}`];if(Number.isFinite(s)){const i=e.json.accessors?.[s];if(i&&i.bufferView){const s=e.json.bufferViews?.[i.bufferView];if(s){const{arrayBuffer:a,byteOffset:l}=e.buffers[s.buffer],c=(l||0)+(i.byteOffset||0)+(s.byteOffset||0),{ArrayType:u,length:h}=XM(i,s),d=jM[i.componentType],p=VM[i.type],f=s.byteStride||d*p,m=new Float32Array(h);for(let e=0;e{e.uniforms[t].value&&!(t in i)&&(i[t]=e.uniforms[t].value)}),Object.keys(i).forEach(e=>{"object"==typeof i[e]&&void 0!==i[e].index&&(i[e].texture=t.getTexture(i[e].index))}),i}const sL=[PP,_P,aR,uR,pR,jR,eL,Object.freeze({__proto__:null,name:iL,decode:async function(e){const t=new YM(e),{json:i}=t;for(const e of i.materials||[]){e.extensions&&e.extensions.KHR_materials_unlit&&(e.unlit=!0),t.removeObjectExtension(e,tL)}t.removeExtension(tL)},encode:function(e){const t=new YM(e),{json:i}=t;if(t.materials)for(const e of i.materials||[])e.unlit&&(delete e.unlit,t.addObjectExtension(e,tL,{}),t.addExtension(tL))}}),Object.freeze({__proto__:null,name:nL,decode:async function(e){const t=new YM(e),{json:i}=t,r=t.getExtension(rL);if(r){const e=function(e,t){const{programs:i=[],shaders:r=[],techniques:n=[]}=e,o=new TextDecoder;return r.forEach(e=>{if(!Number.isFinite(e.bufferView))throw new Error("KHR_techniques_webgl: no shader code");e.code=o.decode(t.getTypedArrayForBufferView(e.bufferView))}),i.forEach(e=>{e.fragmentShader=r[e.fragmentShader],e.vertexShader=r[e.vertexShader]}),n.forEach(e=>{e.program=i[e.program]}),n}(r,t);for(const r of i.materials||[]){const i=t.getObjectExtension(r,rL);i&&(r.technique=Object.assign({},i,e[i.technique]),r.technique.values=oL(r.technique,t)),t.removeObjectExtension(r,rL)}t.removeExtension(rL)}},encode:async function(e,t){}}),XR,VP];function aL(e,t){const i=t?.gltf?.excludeExtensions||{};return!(e in i&&!i[e])}const lL="KHR_binary_glTF";const cL={accessors:"accessor",animations:"animation",buffers:"buffer",bufferViews:"bufferView",images:"image",materials:"material",meshes:"mesh",nodes:"node",samplers:"sampler",scenes:"scene",skins:"skin",textures:"texture"},uL={accessor:"accessors",animations:"animation",buffer:"buffers",bufferView:"bufferViews",image:"images",material:"materials",mesh:"meshes",node:"nodes",sampler:"samplers",scene:"scenes",skin:"skins",texture:"textures"};class hL{idToIndexMap={animations:{},accessors:{},buffers:{},bufferViews:{},images:{},materials:{},meshes:{},nodes:{},samplers:{},scenes:{},skins:{},textures:{}};json;normalize(e,t){this.json=e.json;const i=e.json;switch(i.asset&&i.asset.version){case"2.0":return;case void 0:case"1.0":break;default:return void console.warn(`glTF: Unknown version ${i.asset.version}`)}if(!t.normalize)throw new Error("glTF v1 is not supported.");console.warn("Converting glTF v1 to glTF v2 format. This is experimental and may fail."),this._addAsset(i),this._convertTopLevelObjectsToArrays(i),function(e){const t=new YM(e),{json:i}=t;for(const e of i.images||[]){const i=t.getObjectExtension(e,lL);i&&Object.assign(e,i),t.removeObjectExtension(e,lL)}i.buffers&&i.buffers[0]&&delete i.buffers[0].uri,t.removeExtension(lL)}(e),this._convertObjectIdsToArrayIndices(i),this._updateObjects(i),this._updateMaterial(i)}_addAsset(e){e.asset=e.asset||{},e.asset.version="2.0",e.asset.generator=e.asset.generator||"Normalized to glTF 2.0 by loaders.gl"}_convertTopLevelObjectsToArrays(e){for(const t in cL)this._convertTopLevelObjectToArray(e,t)}_convertTopLevelObjectToArray(e,t){const i=e[t];if(i&&!Array.isArray(i)){e[t]=[];for(const r in i){const n=i[r];n.id=n.id||r;const o=e[t].length;e[t].push(n),this.idToIndexMap[t][r]=o}}}_convertObjectIdsToArrayIndices(e){for(const t in cL)this._convertIdsToIndices(e,t);"scene"in e&&(e.scene=this._convertIdToIndex(e.scene,"scene"));for(const t of e.textures)this._convertTextureIds(t);for(const t of e.meshes)this._convertMeshIds(t);for(const t of e.nodes)this._convertNodeIds(t);for(const t of e.scenes)this._convertSceneIds(t)}_convertTextureIds(e){e.source&&(e.source=this._convertIdToIndex(e.source,"image"))}_convertMeshIds(e){for(const t of e.primitives){const{attributes:e,indices:i,material:r}=t;for(const t in e)e[t]=this._convertIdToIndex(e[t],"accessor");i&&(t.indices=this._convertIdToIndex(i,"accessor")),r&&(t.material=this._convertIdToIndex(r,"material"))}}_convertNodeIds(e){e.children&&(e.children=e.children.map(e=>this._convertIdToIndex(e,"node"))),e.meshes&&(e.meshes=e.meshes.map(e=>this._convertIdToIndex(e,"mesh")))}_convertSceneIds(e){e.nodes&&(e.nodes=e.nodes.map(e=>this._convertIdToIndex(e,"node")))}_convertIdsToIndices(e,t){e[t]||(console.warn(`gltf v1: json doesn't contain attribute ${t}`),e[t]=[]);for(const i of e[t])for(const e in i){const t=i[e],r=this._convertIdToIndex(t,e);i[e]=r}}_convertIdToIndex(e,t){const i=uL[t];if(i in this.idToIndexMap){const r=this.idToIndexMap[i][e];if(!Number.isFinite(r))throw new Error(`gltf v1: failed to resolve ${t} with id ${e}`);return r}return e}_updateObjects(e){for(const e of this.json.buffers)delete e.type}_updateMaterial(e){for(const t of e.materials){t.pbrMetallicRoughness={baseColorFactor:[1,1,1,1],metallicFactor:1,roughnessFactor:1};const i=t.values?.tex||t.values?.texture2d_0||t.values?.diffuseTex,r=e.textures.findIndex(e=>e.id===i);-1!==r&&(t.pbrMetallicRoughness.baseColorTexture={index:r})}}}async function dL(e,t,i=0,r,n){return function(e,t,i,r){r.uri&&(e.baseUri=r.uri);if(t instanceof ArrayBuffer&&!function(e,t=0,i={}){const r=new DataView(e),{magic:n=GP}=i,o=r.getUint32(t,!1);return o===n||o===GP}(t,i,r)){t=(new TextDecoder).decode(t)}if("string"==typeof t)e.json=Ah(t);else if(t instanceof ArrayBuffer){const n={};i=$P(n,t,i,r.glb),NM("glTF"===n.type,`Invalid GLB magic string ${n.type}`),e._glb=n,e.json=n.json}else NM(!1,"GLTF: must be ArrayBuffer or string");const n=e.json.buffers||[];if(e.buffers=new Array(n.length).fill(null),e._glb&&e._glb.header.hasBinChunk){const{binChunks:t}=e._glb;e.buffers[0]={arrayBuffer:t[0].arrayBuffer,byteOffset:t[0].byteOffset,byteLength:t[0].byteLength}}const o=e.json.images||[];e.images=new Array(o.length).fill({})}(e,t,i,r),function(e,t={}){(new hL).normalize(e,t)}(e,{normalize:r?.gltf?.normalize}),function(e,t={},i){const r=sL.filter(e=>aL(e.name,t));for(const n of r)n.preprocess?.(e,t,i)}(e,r,n),r?.gltf?.loadBuffers&&e.json.buffers&&await async function(e,t,i){const r=e.json.buffers||[];for(let n=0;naL(e.name,t));for(const n of r)await(n.decode?.(e,t,i))}(e,r,n),e}async function pL(e,t,i,r,n){let o;if(t.uri&&!t.hasOwnProperty("bufferView")){const e=qP(t.uri,r),{fetch:i}=n,s=await i(e);o=await s.arrayBuffer(),t.bufferView={data:o}}if(Number.isFinite(t.bufferView)){const i=function(e,t,i){const r=e.bufferViews[i];NM(r);const n=t[r.buffer];NM(n);const o=(r.byteOffset||0)+n.byteOffset;return new Uint8Array(n.arrayBuffer,o,r.byteLength)}(e.json,e.buffers,t.bufferView);o=vh(i.buffer,i.byteOffset,i.byteLength)}NM(o,"glTF image has no data");let s=await wu(o,[ep,SM],{...r,mimeType:t.mimeType,basis:r.basis||{format:BM()}},n);s&&s[0]&&(s={compressed:!0,mipmaps:!1,width:s[0].width,height:s[0].height,data:s[0]}),e.images=e.images||[],e.images[i]=s}const fL={dataType:null,batchType:null,name:"glTF",id:"gltf",module:"gltf",version:"4.3.3",extensions:["gltf","glb"],mimeTypes:["model/gltf+json","model/gltf-binary"],text:!0,binary:!0,tests:["glTF"],parse:async function(e,t={},i){(t={...fL.options,...t}).gltf={...fL.options.gltf,...t.gltf};const{byteOffset:r=0}=t;return await dL({},e,r,t,i)},options:{gltf:{normalize:!0,loadBuffers:!0,loadImages:!0,decompressMeshes:!0},log:console}};const mL={SCALAR:1,VEC2:2,VEC3:3,VEC4:4,MAT2:4,MAT3:9,MAT4:16},gL={5120:1,5121:1,5122:2,5123:2,5125:4,5126:4},_L=10240,AL=10241,yL=10242,vL=10243,xL=10497,bL=9729,wL=9986,TL={magFilter:_L,minFilter:AL,wrapS:yL,wrapT:vL},EL={[_L]:bL,[AL]:wL,[yL]:xL,[vL]:xL};class CL{baseUri="";jsonUnprocessed;json;buffers=[];images=[];postProcess(e,t={}){const{json:i,buffers:r=[],images:n=[]}=e,{baseUri:o=""}=e;return NM(i),this.baseUri=o,this.buffers=r,this.images=n,this.jsonUnprocessed=i,this.json=this._resolveTree(e.json,t),this.json}_resolveTree(e,t={}){const i={...e};return this.json=i,e.bufferViews&&(i.bufferViews=e.bufferViews.map((e,t)=>this._resolveBufferView(e,t))),e.images&&(i.images=e.images.map((e,t)=>this._resolveImage(e,t))),e.samplers&&(i.samplers=e.samplers.map((e,t)=>this._resolveSampler(e,t))),e.textures&&(i.textures=e.textures.map((e,t)=>this._resolveTexture(e,t))),e.accessors&&(i.accessors=e.accessors.map((e,t)=>this._resolveAccessor(e,t))),e.materials&&(i.materials=e.materials.map((e,t)=>this._resolveMaterial(e,t))),e.meshes&&(i.meshes=e.meshes.map((e,t)=>this._resolveMesh(e,t))),e.nodes&&(i.nodes=e.nodes.map((e,t)=>this._resolveNode(e,t)),i.nodes=i.nodes.map((e,t)=>this._resolveNodeChildren(e))),e.skins&&(i.skins=e.skins.map((e,t)=>this._resolveSkin(e,t))),e.scenes&&(i.scenes=e.scenes.map((e,t)=>this._resolveScene(e,t))),"number"==typeof this.json.scene&&i.scenes&&(i.scene=i.scenes[this.json.scene]),i}getScene(e){return this._get(this.json.scenes,e)}getNode(e){return this._get(this.json.nodes,e)}getSkin(e){return this._get(this.json.skins,e)}getMesh(e){return this._get(this.json.meshes,e)}getMaterial(e){return this._get(this.json.materials,e)}getAccessor(e){return this._get(this.json.accessors,e)}getCamera(e){return this._get(this.json.cameras,e)}getTexture(e){return this._get(this.json.textures,e)}getSampler(e){return this._get(this.json.samplers,e)}getImage(e){return this._get(this.json.images,e)}getBufferView(e){return this._get(this.json.bufferViews,e)}getBuffer(e){return this._get(this.json.buffers,e)}_get(e,t){if("object"==typeof t)return t;const i=e&&e[t];return i||console.warn(`glTF file error: Could not find ${e}[${t}]`),i}_resolveScene(e,t){return{...e,id:e.id||`scene-${t}`,nodes:(e.nodes||[]).map(e=>this.getNode(e))}}_resolveNode(e,t){const i={...e,id:e?.id||`node-${t}`};return void 0!==e.mesh&&(i.mesh=this.getMesh(e.mesh)),void 0!==e.camera&&(i.camera=this.getCamera(e.camera)),void 0!==e.skin&&(i.skin=this.getSkin(e.skin)),void 0!==e.meshes&&e.meshes.length&&(i.mesh=e.meshes.reduce((e,t)=>{const i=this.getMesh(t);return e.id=i.id,e.primitives=e.primitives.concat(i.primitives),e},{primitives:[]})),i}_resolveNodeChildren(e){return e.children&&(e.children=e.children.map(e=>this.getNode(e))),e}_resolveSkin(e,t){const i="number"==typeof e.inverseBindMatrices?this.getAccessor(e.inverseBindMatrices):void 0;return{...e,id:e.id||`skin-${t}`,inverseBindMatrices:i}}_resolveMesh(e,t){const i={...e,id:e.id||`mesh-${t}`,primitives:[]};return e.primitives&&(i.primitives=e.primitives.map(e=>{const t={...e,attributes:{},indices:void 0,material:void 0},i=e.attributes;for(const e in i)t.attributes[e]=this.getAccessor(i[e]);return void 0!==e.indices&&(t.indices=this.getAccessor(e.indices)),void 0!==e.material&&(t.material=this.getMaterial(e.material)),t})),i}_resolveMaterial(e,t){const i={...e,id:e.id||`material-${t}`};if(i.normalTexture&&(i.normalTexture={...i.normalTexture},i.normalTexture.texture=this.getTexture(i.normalTexture.index)),i.occlusionTexture&&(i.occlusionTexture={...i.occlusionTexture},i.occlusionTexture.texture=this.getTexture(i.occlusionTexture.index)),i.emissiveTexture&&(i.emissiveTexture={...i.emissiveTexture},i.emissiveTexture.texture=this.getTexture(i.emissiveTexture.index)),i.emissiveFactor||(i.emissiveFactor=i.emissiveTexture?[1,1,1]:[0,0,0]),i.pbrMetallicRoughness){i.pbrMetallicRoughness={...i.pbrMetallicRoughness};const e=i.pbrMetallicRoughness;e.baseColorTexture&&(e.baseColorTexture={...e.baseColorTexture},e.baseColorTexture.texture=this.getTexture(e.baseColorTexture.index)),e.metallicRoughnessTexture&&(e.metallicRoughnessTexture={...e.metallicRoughnessTexture},e.metallicRoughnessTexture.texture=this.getTexture(e.metallicRoughnessTexture.index))}return i}_resolveAccessor(e,t){const i=(r=e.componentType,gL[r]);var r;const n=function(e){return mL[e]}(e.type),o=i*n,s={...e,id:e.id||`accessor-${t}`,bytesPerComponent:i,components:n,bytesPerElement:o,value:void 0,bufferView:void 0,sparse:void 0};if(void 0!==e.bufferView&&(s.bufferView=this.getBufferView(e.bufferView)),s.bufferView){const e=s.bufferView.buffer,{ArrayType:t,byteLength:i}=XM(s,s.bufferView),r=(s.bufferView.byteOffset||0)+(s.byteOffset||0)+e.byteOffset;let n=e.arrayBuffer.slice(r,r+i);s.bufferView.byteStride&&(n=this._getValueFromInterleavedBuffer(e,r,s.bufferView.byteStride,s.bytesPerElement,s.count)),s.value=new t(n)}return s}_getValueFromInterleavedBuffer(e,t,i,r,n){const o=new Uint8Array(n*r);for(let s=0;s{e.traverse(e=>{Object.values(e.model.uniforms).forEach(e=>{!1===e.loaded&&t.push(e)})})}),await async function(e){for(;e();)await new Promise(e=>requestAnimationFrame(e))}(()=>t.some(e=>!e.loaded))}const IL=[255,255,255,255],ML={scenegraph:{type:"object",value:null,async:!0},getScene:e=>e&&e.scenes?"object"==typeof e.scene?e.scene:e.scenes[e.scene||0]:e,getAnimator:e=>e&&e.animator,_animations:null,sizeScale:{type:"number",value:1,min:0},sizeMinPixels:{type:"number",min:0,value:0},sizeMaxPixels:{type:"number",min:0,value:Number.MAX_SAFE_INTEGER},getPosition:{type:"accessor",value:e=>e.position},getColor:{type:"accessor",value:IL},_lighting:"flat",_imageBasedLightingEnvironment:void 0,getOrientation:{type:"accessor",value:[0,0,0]},getScale:{type:"accessor",value:[1,1,1]},getTranslation:{type:"accessor",value:[0,0,0]},getTransformMatrix:{type:"accessor",value:[]},loaders:[fL]};class PL extends YC{getShaders(){const e=[Fy,dv];return"pbr"===this.props._lighting&&e.push(my),super.getShaders({vs:"#version 300 es\n#define SHADER_NAME scenegraph-layer-vertex-shader\nin vec3 instancePositions;\nin vec3 instancePositions64Low;\nin vec4 instanceColors;\nin vec3 instancePickingColors;\nin vec3 instanceModelMatrixCol0;\nin vec3 instanceModelMatrixCol1;\nin vec3 instanceModelMatrixCol2;\nin vec3 instanceTranslation;\nuniform float sizeScale;\nuniform float sizeMinPixels;\nuniform float sizeMaxPixels;\nuniform mat4 sceneModelMatrix;\nuniform bool composeModelMatrix;\nin vec3 positions;\n#ifdef HAS_UV\nin vec2 texCoords;\n#endif\n#ifdef MODULE_PBR\n#ifdef HAS_NORMALS\nin vec3 normals;\n#endif\n#endif\nout vec4 vColor;\n#ifndef MODULE_PBR\n#ifdef HAS_UV\nout vec2 vTEXCOORD_0;\n#endif\n#endif\nvoid main(void) {\n#if defined(HAS_UV) && !defined(MODULE_PBR)\nvTEXCOORD_0 = texCoords;\ngeometry.uv = texCoords;\n#endif\ngeometry.worldPosition = instancePositions;\ngeometry.pickingColor = instancePickingColors;\nmat3 instanceModelMatrix = mat3(instanceModelMatrixCol0, instanceModelMatrixCol1, instanceModelMatrixCol2);\nvec3 normal = vec3(0.0, 0.0, 1.0);\n#ifdef MODULE_PBR\n#ifdef HAS_NORMALS\nnormal = instanceModelMatrix * (sceneModelMatrix * vec4(normals, 0.0)).xyz;\n#endif\n#endif\nfloat originalSize = project_size_to_pixel(sizeScale);\nfloat clampedSize = clamp(originalSize, sizeMinPixels, sizeMaxPixels);\nvec3 pos = (instanceModelMatrix * (sceneModelMatrix * vec4(positions, 1.0)).xyz) * sizeScale * (clampedSize / originalSize) + instanceTranslation;\nif(composeModelMatrix) {\nDECKGL_FILTER_SIZE(pos, geometry);\ngeometry.normal = project_normal(normal);\ngeometry.worldPosition += pos;\ngl_Position = project_position_to_clipspace(pos + instancePositions, instancePositions64Low, vec3(0.0), geometry.position);\n}\nelse {\npos = project_size(pos);\nDECKGL_FILTER_SIZE(pos, geometry);\ngl_Position = project_position_to_clipspace(instancePositions, instancePositions64Low, pos, geometry.position);\ngeometry.normal = project_normal(normal);\n}\nDECKGL_FILTER_GL_POSITION(gl_Position, geometry);\n#ifdef MODULE_PBR\npbr_vPosition = geometry.position.xyz;\n#ifdef HAS_NORMALS\npbr_vNormal = geometry.normal;\n#endif\n#ifdef HAS_UV\npbr_vUV = texCoords;\n#else\npbr_vUV = vec2(0., 0.);\n#endif\ngeometry.uv = pbr_vUV;\n#endif\nvColor = instanceColors;\nDECKGL_FILTER_COLOR(vColor, geometry);\n}\n",fs:"#version 300 es\n#define SHADER_NAME scenegraph-layer-fragment-shader\nuniform float opacity;\nin vec4 vColor;\nout vec4 fragColor;\n#ifndef MODULE_PBR\n#if defined(HAS_UV) && defined(HAS_BASECOLORMAP)\nin vec2 vTEXCOORD_0;\nuniform sampler2D u_BaseColorSampler;\n#endif\n#endif\nvoid main(void) {\n#ifdef MODULE_PBR\nfragColor = vColor * pbr_filterColor(vec4(0));\ngeometry.uv = pbr_vUV;\n#else\n#if defined(HAS_UV) && defined(HAS_BASECOLORMAP)\nfragColor = vColor * texture(u_BaseColorSampler, vTEXCOORD_0);\ngeometry.uv = vTEXCOORD_0;\n#else\nfragColor = vColor;\n#endif\n#endif\nfragColor.a *= opacity;\nDECKGL_FILTER_COLOR(fragColor, geometry);\n}\n",modules:e})}initializeState(){this.getAttributeManager().addInstanced({instancePositions:{size:3,type:"float64",fp64:this.use64bitPositions(),accessor:"getPosition",transition:!0},instanceColors:{type:"unorm8",size:this.props.colorFormat.length,accessor:"getColor",defaultValue:IL,transition:!0},instanceModelMatrix:$I})}updateState(e){super.updateState(e);const{props:t,oldProps:i}=e;t.scenegraph!==i.scenegraph?this._updateScenegraph():t._animations!==i._animations&&this._applyAnimationsProp(this.state.animator,t._animations)}finalizeState(e){super.finalizeState(e),this.state.scenegraph?.destroy()}get isLoaded(){return Boolean(this.state?.scenegraph&&super.isLoaded)}_updateScenegraph(){const e=this.props,{device:t}=this.context;let i=null;if(e.scenegraph instanceof gx)i={scenes:[e.scenegraph]};else if(e.scenegraph&&"object"==typeof e.scenegraph){const r=e.scenegraph,n=r.json?BL(r):r,o=function(e,t,i){const r=new zM(e,i);return{scenes:r.instantiate(t),animator:r.createAnimator()}}(t,n,this._getModelOptions());i={gltf:n,...o},SL(o).then(()=>{this.setNeedsRedraw()}).catch(e=>{this.raiseError(e,"loading glTF")})}const r={layer:this,device:this.context.device},n=e.getScene(i,r),o=e.getAnimator(i,r);if(n instanceof _x){this.state.scenegraph?.destroy(),this._applyAnimationsProp(o,e._animations);const t=[];n.traverse(e=>{e instanceof Ax&&t.push(e.model)}),this.setState({scenegraph:n,animator:o,models:t}),this.getAttributeManager().invalidateAll()}else null!==n&&rp.warn("invalid scenegraph:",n)()}_applyAnimationsProp(e,t){if(!e||!t)return;const i=e.getAnimations();Object.keys(t).sort().forEach(e=>{const r=t[e];if("*"===e)i.forEach(e=>{Object.assign(e,r)});else if(Number.isFinite(Number(e))){const t=Number(e);t>=0&&tt===e);t?Object.assign(t,r):rp.warn(`animation ${e} not found`)()}})}_getModelOptions(){const{_imageBasedLightingEnvironment:e}=this.props;let t;return e&&(t="function"==typeof e?e({gl:this.context.gl,layer:this}):e),{imageBasedLightingEnvironment:t,modelOptions:{id:this.props.id,isInstanced:!0,bufferLayout:this.getAttributeManager().getBufferLayouts(),...this.getShaders()},useTangents:!1}}draw({context:e}){if(!this.state.scenegraph)return;this.props._animations&&this.state.animator&&(this.state.animator.animate(e.timeline.getTime()),this.setNeedsRedraw());const{viewport:t,renderPass:i}=this.context,{sizeScale:r,sizeMinPixels:n,sizeMaxPixels:o,opacity:s,coordinateSystem:a}=this.props,l=this.getNumInstances();this.state.scenegraph.traverse((e,{worldMatrix:c})=>{if(e instanceof Ax){const{model:u}=e;u.setInstanceCount(l),u.setUniforms({sizeScale:r,opacity:s,sizeMinPixels:n,sizeMaxPixels:o,composeModelMatrix:ZI(t,a),sceneModelMatrix:c,u_Camera:u.uniforms.project_uCameraPosition}),u.draw(i)}})}}PL.defaultProps=ML,PL.layerName="ScenegraphLayer";var RL=PL;class LL extends YI{getShaders(){const e=super.getShaders();return e.modules.push(my),{...e,vs:"#version 300 es\n#define SHADER_NAME simple-mesh-layer-vs\nuniform float sizeScale;\nuniform bool composeModelMatrix;\nuniform bool pickFeatureIds;\nin vec3 positions;\nin vec3 normals;\nin vec3 colors;\nin vec2 texCoords;\nin vec4 uvRegions;\nin vec3 featureIdsPickingColors;\nin vec4 instanceColors;\nin vec3 instancePickingColors;\nin vec3 instanceModelMatrixCol0;\nin vec3 instanceModelMatrixCol1;\nin vec3 instanceModelMatrixCol2;\nout vec2 vTexCoord;\nout vec3 cameraPosition;\nout vec3 normals_commonspace;\nout vec4 position_commonspace;\nout vec4 vColor;\nvec2 applyUVRegion(vec2 uv) {\n#ifdef HAS_UV_REGIONS\nreturn fract(uv) * (uvRegions.zw - uvRegions.xy) + uvRegions.xy;\n#else\nreturn uv;\n#endif\n}\nvoid main(void) {\nvec2 uv = applyUVRegion(texCoords);\ngeometry.uv = uv;\nif (pickFeatureIds) {\ngeometry.pickingColor = featureIdsPickingColors;\n} else {\ngeometry.pickingColor = instancePickingColors;\n}\nmat3 instanceModelMatrix = mat3(instanceModelMatrixCol0, instanceModelMatrixCol1, instanceModelMatrixCol2);\nvTexCoord = uv;\ncameraPosition = project_uCameraPosition;\nvColor = vec4(colors * instanceColors.rgb, instanceColors.a);\nvec3 pos = (instanceModelMatrix * positions) * sizeScale;\nvec3 projectedPosition = project_position(positions);\nposition_commonspace = vec4(projectedPosition, 1.0);\ngl_Position = project_common_position_to_clipspace(position_commonspace);\ngeometry.position = position_commonspace;\nnormals_commonspace = project_normal(instanceModelMatrix * normals);\ngeometry.normal = normals_commonspace;\nDECKGL_FILTER_GL_POSITION(gl_Position, geometry);\n#ifdef MODULE_PBR\npbr_vPosition = geometry.position.xyz;\n#ifdef HAS_NORMALS\npbr_vNormal = geometry.normal;\n#endif\n#ifdef HAS_UV\npbr_vUV = uv;\n#else\npbr_vUV = vec2(0., 0.);\n#endif\ngeometry.uv = pbr_vUV;\n#endif\nDECKGL_FILTER_COLOR(vColor, geometry);\n}\n",fs:"#version 300 es\n#define SHADER_NAME simple-mesh-layer-fs\nprecision highp float;\nuniform bool hasTexture;\nuniform sampler2D sampler;\nuniform bool flatShading;\nuniform float opacity;\nin vec2 vTexCoord;\nin vec3 cameraPosition;\nin vec3 normals_commonspace;\nin vec4 position_commonspace;\nin vec4 vColor;\nout vec4 fragColor;\nvoid main(void) {\n#ifdef MODULE_PBR\nfragColor = vColor * pbr_filterColor(vec4(0));\ngeometry.uv = pbr_vUV;\nfragColor.a *= opacity;\n#else\ngeometry.uv = vTexCoord;\nvec3 normal;\nif (flatShading) {\nnormal = normalize(cross(dFdx(position_commonspace.xyz), dFdy(position_commonspace.xyz)));\n} else {\nnormal = normals_commonspace;\n}\nvec4 color = hasTexture ? texture(sampler, vTexCoord) : vColor;\nvec3 lightColor = lighting_getLightColor(color.rgb, cameraPosition, position_commonspace.xyz, normal);\nfragColor = vec4(lightColor, color.a * opacity);\n#endif\nDECKGL_FILTER_COLOR(fragColor, geometry);\n}\n"}}initializeState(){const{featureIds:e}=this.props;super.initializeState();const t=this.getAttributeManager();e&&t.add({featureIdsPickingColors:{type:"uint8",size:3,noAlloc:!0,update:this.calculateFeatureIdsPickingColors}})}updateState(e){super.updateState(e);const{props:t,oldProps:i}=e;t.pbrMaterial!==i.pbrMaterial&&this.updatePbrMaterialUniforms(t.pbrMaterial)}draw(e){const{featureIds:t}=this.props;this.state.model&&(this.state.model.setUniforms({u_Camera:this.state.model.uniforms.project_uCameraPosition,pickFeatureIds:Boolean(t)}),super.draw(e))}getModel(e){const{id:t,pbrMaterial:i}=this.props,r=this.parseMaterial(i,e);this.setState({parsedPBRMaterial:r});const n=this.getShaders();!function(e){const t=e.positions||e.POSITION,i=t.value.length/t.size;e.COLOR_0||e.colors||(e.colors={size:4,value:new Uint8Array(4*i).fill(255),normalized:!0})}(e.attributes);return new hx(this.context.device,{...this.getShaders(),id:t,geometry:e,bufferLayout:this.getAttributeManager().getBufferLayouts(),defines:{...n.defines,...r?.defines,HAS_UV_REGIONS:e.attributes.uvRegions?1:0},parameters:r?.parameters,isInstanced:!0})}updatePbrMaterialUniforms(e){const{model:t}=this.state;if(t){const{mesh:i}=this.props,r=this.parseMaterial(e,i);this.setState({parsedPBRMaterial:r}),t.setBindings(r.bindings),t.setUniforms(r.uniforms)}}parseMaterial(e,t){const i=Boolean(e.pbrMetallicRoughness&&e.pbrMetallicRoughness.baseColorTexture);return eM(this.context.device,{unlit:i,...e},{NORMAL:t.attributes.normals,TEXCOORD_0:t.attributes.texCoords},{pbrDebug:!1,lights:!0,useTangents:!1})}calculateFeatureIdsPickingColors(e){const t=this.props.featureIds,i=new Uint8ClampedArray(t.length*e.size),r=[];for(let e=0;ee.destroy()),this.setState({parsedPBRMaterial:null})}}LL.layerName="MeshLayer",LL.defaultProps={pbrMaterial:{type:"object",value:null},featureIds:{type:"array",value:null,optional:!0}};var FL=LL;function kL(e){return e}function DL(e,t=[]){return function(e,t=[],i=kL){return"longitude"in e?(t[0]=i(e.longitude),t[1]=i(e.latitude),t[2]=e.height):"x"in e?(t[0]=i(e.x),t[1]=i(e.y),t[2]=e.z):(t[0]=i(e[0]),t[1]=i(e[1]),t[2]=e[2]),t}(e,t,P_._cartographicRadians?kL:F_)}function OL(e,t){return function(e,t,i=kL){return"longitude"in t?(t.longitude=i(e[0]),t.latitude=i(e[1]),t.height=e[2]):"x"in t?(t.x=i(e[0]),t.y=i(e[1]),t.z=e[2]):(t[0]=i(e[0]),t[1]=i(e[1]),t[2]=e[2]),t}(e,t,P_._cartographicRadians?kL:k_)}new mA;const zL=new mA,UL={up:{south:"east",north:"west",west:"south",east:"north"},down:{south:"west",north:"east",west:"north",east:"south"},south:{up:"west",down:"east",west:"down",east:"up"},north:{up:"east",down:"west",west:"up",east:"down"},west:{up:"north",down:"south",north:"down",south:"up"},east:{up:"south",down:"north",north:"up",south:"down"}},NL={north:[-1,0,0],east:[0,1,0],up:[0,0,1],south:[1,0,0],west:[0,-1,0],down:[0,0,-1]},VL={east:new mA,north:new mA,up:new mA,west:new mA,south:new mA,down:new mA},jL=new mA,HL=new mA,QL=new mA;function $L(e,t,i,r,n,o){const s=UL[t]&&UL[t][i];let a,l,c;H_(s&&(!r||r===s));const u=zL.copy(n);if(U_(u.x,0,1e-14)&&U_(u.y,0,1e-14)){const e=Math.sign(u.z);a=jL.fromArray(NL[t]),"east"!==t&&"west"!==t&&a.scale(e),l=HL.fromArray(NL[i]),"east"!==i&&"west"!==i&&l.scale(e),c=QL.fromArray(NL[r]),"east"!==r&&"west"!==r&&c.scale(e)}else{const{up:n,east:o,north:s}=VL;o.set(-u.y,u.x,0).normalize(),e.geodeticSurfaceNormal(u,n),s.copy(n).cross(o);const{down:h,west:d,south:p}=VL;h.copy(n).scale(-1),d.copy(o).scale(-1),p.copy(s).scale(-1),a=VL[t],l=VL[i],c=VL[r]}return o[0]=a.x,o[1]=a.y,o[2]=a.z,o[3]=0,o[4]=l.x,o[5]=l.y,o[6]=l.z,o[7]=0,o[8]=c.x,o[9]=c.y,o[10]=c.z,o[11]=0,o[12]=u.x,o[13]=u.y,o[14]=u.z,o[15]=1,o}const ZL=new mA,WL=new mA,qL=new mA;const KL=new mA,XL=new mA,JL=new mA,YL=new mA,eF=new mA,tF=new mA;class iF{constructor(e=0,t=0,i=0){this.centerToleranceSquared=.1,H_(e>=0),H_(t>=0),H_(i>=0),this.radii=new mA(e,t,i),this.radiiSquared=new mA(e*e,t*t,i*i),this.radiiToTheFourth=new mA(e*e*e*e,t*t*t*t,i*i*i*i),this.oneOverRadii=new mA(0===e?0:1/e,0===t?0:1/t,0===i?0:1/i),this.oneOverRadiiSquared=new mA(0===e?0:1/(e*e),0===t?0:1/(t*t),0===i?0:1/(i*i)),this.minimumRadius=Math.min(e,t,i),this.maximumRadius=Math.max(e,t,i),0!==this.radiiSquared.z&&(this.squaredXOverSquaredZ=this.radiiSquared.x/this.radiiSquared.z),Object.freeze(this)}equals(e){return this===e||Boolean(e&&this.radii.equals(e.radii))}toString(){return this.radii.toString()}cartographicToCartesian(e,t=[0,0,0]){const i=XL,r=JL,[,,n]=e;this.geodeticSurfaceNormalCartographic(e,i),r.copy(this.radiiSquared).scale(i);const o=Math.sqrt(i.dot(r));return r.scale(1/o),i.scale(n),r.add(i),r.to(t)}cartesianToCartographic(e,t=[0,0,0]){tF.from(e);const i=this.scaleToGeodeticSurface(tF,YL);if(!i)return;const r=this.geodeticSurfaceNormal(i,XL),n=eF;n.copy(tF).subtract(i);return OL([Math.atan2(r.y,r.x),Math.asin(r.z),Math.sign(oA(n,tF))*rA(n)],t)}eastNorthUpToFixedFrame(e,t=new VA){return $L(this,"east","north","up",e,t)}localFrameToFixedFrame(e,t,i,r,n=new VA){return $L(this,e,t,i,r,n)}geocentricSurfaceNormal(e,t=[0,0,0]){return KL.from(e).normalize().to(t)}geodeticSurfaceNormalCartographic(e,t=[0,0,0]){const i=DL(e),r=i[0],n=i[1],o=Math.cos(n);return KL.set(o*Math.cos(r),o*Math.sin(r),Math.sin(n)).normalize(),KL.to(t)}geodeticSurfaceNormal(e,t=[0,0,0]){return KL.from(e).scale(this.oneOverRadiiSquared).normalize().to(t)}scaleToGeodeticSurface(e,t){return function(e,t,i=[]){const{oneOverRadii:r,oneOverRadiiSquared:n,centerToleranceSquared:o}=t;ZL.from(e);const s=ZL.x,a=ZL.y,l=ZL.z,c=r.x,u=r.y,h=r.z,d=s*s*c*c,p=a*a*u*u,f=l*l*h*h,m=d+p+f,g=Math.sqrt(1/m);if(!Number.isFinite(g))return;const _=WL;if(_.copy(e).scale(g),m1e-12);return ZL.scale([b,w,T]).to(i)}(e,this,t)}scaleToGeocentricSurface(e,t=[0,0,0]){YL.from(e);const i=YL.x,r=YL.y,n=YL.z,o=this.oneOverRadiiSquared,s=1/Math.sqrt(i*i*o.x+r*r*o.y+n*n*o.z);return YL.multiplyScalar(s).to(t)}transformPositionToScaledSpace(e,t=[0,0,0]){return YL.from(e).scale(this.oneOverRadii).to(t)}transformPositionFromScaledSpace(e,t=[0,0,0]){return YL.from(e).scale(this.radii).to(t)}getSurfaceNormalIntersectionWithZAxis(e,t=0,i=[0,0,0]){H_(U_(this.radii.x,this.radii.y,1e-15)),H_(this.radii.z>0),YL.from(e);const r=YL.z*(1-this.squaredXOverSquaredZ);if(!(Math.abs(r)>=this.radii.z-t))return YL.set(0,0,r).to(i)}}iF.WGS84=new iF(6378137,6378137,6356752.314245179);class rF{item;previous;next;constructor(e,t,i){this.item=e,this.previous=t,this.next=i}}class nF{head=null;tail=null;_length=0;get length(){return this._length}add(e){const t=new rF(e,this.tail,null);return this.tail?(this.tail.next=t,this.tail=t):(this.head=t,this.tail=t),++this._length,t}remove(e){e&&(e.previous&&e.next?(e.previous.next=e.next,e.next.previous=e.previous):e.previous?(e.previous.next=null,this.tail=e.previous):e.next?(e.next.previous=null,this.head=e.next):(this.head=null,this.tail=null),e.next=null,e.previous=null,--this._length)}splice(e,t){e!==t&&(this.remove(t),this._insert(e,t))}_insert(e,t){const i=e.next;e.next=t,this.tail===e?this.tail=t:i.previous=t,t.next=i,t.previous=e,++this._length}}class oF{_list;_sentinel;_trimTiles;constructor(){this._list=new nF,this._sentinel=this._list.add("sentinel"),this._trimTiles=!1}reset(){this._list.splice(this._list.tail,this._sentinel)}touch(e){const t=e._cacheNode;t&&this._list.splice(this._sentinel,t)}add(e,t,i){t._cacheNode||(t._cacheNode=this._list.add(t),i&&i(e,t))}unloadTile(e,t,i){const r=t._cacheNode;r&&(this._list.remove(r),t._cacheNode=null,i&&i(e,t))}unloadTiles(e,t){const i=this._trimTiles;this._trimTiles=!1;const r=this._list,n=1024*e.maximumMemoryUsage*1024,o=this._sentinel;let s=r.head;for(;s!==o&&(e.gpuMemoryUsageInBytes>n||i);){const i=s.item;s=s.next,this.unloadTile(e,i,t)}}trim(){this._trimTiles=!0}}const sF=new mA,aF=new mA,lF=new bI([new AI,new AI,new AI,new AI,new AI,new AI]);function cF(e,t){const{cameraDirection:i,cameraUp:r,height:n}=e,{metersPerUnit:o}=e.distanceScales,s=hF(e,e.center),a=iF.WGS84.eastNorthUpToFixedFrame(s),l=e.unprojectPosition(e.cameraPosition),c=iF.WGS84.cartographicToCartesian(l,new mA),u=new mA(a.transformAsVector(new mA(i).scale(o))).normalize(),h=new mA(a.transformAsVector(new mA(r).scale(o))).normalize();!function(e){const t=e.getFrustumPlanes(),i=uF(t.near,e.cameraPosition),r=hF(e,i),n=hF(e,e.cameraPosition,aF);let o=0;lF.planes[o++].fromPointNormal(r,sF.copy(r).subtract(n));for(const n in t){if("near"===n)continue;const s=hF(e,uF(t[n],i,aF),aF);lF.planes[o++].fromPointNormal(s,sF.copy(r).subtract(s))}}(e);const d=e.constructor,{longitude:p,latitude:f,width:m,bearing:g,zoom:_}=e;return{camera:{position:c,direction:u,up:h},viewport:e,topDownViewport:new d({longitude:p,latitude:f,height:n,width:m,bearing:g,zoom:_,pitch:0}),height:n,cullingVolume:lF,frameNumber:t,sseDenominator:1.15}}function uF(e,t,i=new mA){const r=e.normal.dot(t);return i.copy(e.normal).scale(e.distance-r).add(t),i}function hF(e,t,i=new mA){const r=e.unprojectPosition(t);return iF.WGS84.cartographicToCartesian(r,i)}const dF=6356752.314245179,pF=new mA;function fF(e,t){if(e instanceof mI){const{halfAxes:i}=e,r=function(e){e.getColumn(0,pF);const t=e.getColumn(1),i=e.getColumn(2),r=pF.add(t).add(i);return r.len()}(i);return Math.log2(dF/(r+t[2]))}if(e instanceof JS){const{radius:i}=e;return Math.log2(dF/(i+t[2]))}if(e.width&&e.height){const{width:t,height:i}=e;return(Math.log2(6378137/t)+Math.log2(6378137/i))/2}return 1}function mF(e,t,i){iF.WGS84.cartographicToCartesian([e.xmax,e.ymax,e.zmax],pF);const r=Math.sqrt(Math.pow(pF[0]-i[0],2)+Math.pow(pF[1]-i[1],2)+Math.pow(pF[2]-i[2],2));return Math.log2(dF/(r+t[2]))}const gF=0,_F=1,AF=3,yF=4,vF=5;var xF,bF,wF,TF;!function(e){e[e.ADD=1]="ADD",e[e.REPLACE=2]="REPLACE"}(xF||(xF={})),function(e){e.EMPTY="empty",e.SCENEGRAPH="scenegraph",e.POINTCLOUD="pointcloud",e.MESH="mesh"}(bF||(bF={})),function(e){e.I3S="I3S",e.TILES3D="TILES3D"}(wF||(wF={})),function(e){e.GEOMETRIC_ERROR="geometricError",e.MAX_SCREEN_THRESHOLD="maxScreenThreshold"}(TF||(TF={}));const EF=1;function CF(e){return null!=e}const BF=new mA,SF=new mA,IF=new mA,MF=new mA,PF=new mA,RF=new mA,LF=new mA,FF=new mA;function kF(e,t,i){if(Tu(e,"3D Tile: boundingVolume must be defined"),e.box)return OF(e.box,t,i);if(e.region)return function(e){const[t,i,r,n,o,s]=e,a=iF.WGS84.cartographicToCartesian([D_(t),D_(n),o],IF),l=iF.WGS84.cartographicToCartesian([D_(r),D_(i),s],MF),c=(new mA).addVectors(a,l).multiplyByScalar(.5);return iF.WGS84.cartesianToCartographic(c,PF),iF.WGS84.cartographicToCartesian([D_(r),PF[1],PF[2]],RF),iF.WGS84.cartographicToCartesian([PF[0],D_(n),PF[2]],LF),iF.WGS84.cartographicToCartesian([PF[0],PF[1],s],FF),OF([...c,...RF.subtract(c),...LF.subtract(c),...FF.subtract(c)],new VA)}(e.region);if(e.sphere)return function(e,t,i){const r=new mA(e[0],e[1],e[2]);t.transform(r,r);const n=t.getScale(SF),o=Math.max(Math.max(n[0],n[1]),n[2]),s=e[3]*o;if(CF(i))return i.center=r,i.radius=s,i;return new JS(r,s)}(e.sphere,t,i);throw new Error("3D Tile: boundingVolume must contain a sphere, region, or box")}function DF(e,t){if(e.box)return function(e){const t=zF(),{halfAxes:i}=e,r=new mA(i.getColumn(0)),n=new mA(i.getColumn(1)),o=new mA(i.getColumn(2));for(let i=0;i<2;i++){for(let i=0;i<2;i++){for(let i=0;i<2;i++)BF.copy(e.center),BF.add(r),BF.add(n),BF.add(o),UF(t,BF),o.negate();n.negate()}r.negate()}return t}(t);if(e.region){const[t,i,r,n,o,s]=e.region;return[[D_(t),D_(i),o],[D_(r),D_(n),s]]}if(e.sphere)return function(e){const t=zF(),{center:i,radius:r}=e,n=iF.WGS84.scaleToGeodeticSurface(i,BF);let o;o=n?iF.WGS84.geodeticSurfaceNormal(n):new mA(0,0,1);let s=new mA(o[2],-o[1],0);s.len()>0?s.normalize():s=new mA(0,1,0);const a=s.clone().cross(o);for(const e of[s,a,o]){SF.copy(e).scale(r);for(let e=0;e<2;e++)BF.copy(i),BF.add(SF),UF(t,BF),SF.negate()}return t}(t);throw new Error("Unkown boundingVolume type")}function OF(e,t,i){const r=new mA(e[0],e[1],e[2]);t.transform(r,r);let n=[];if(10===e.length){const t=e.slice(3,6),i=new oy;i.fromArray(e,6);const r=new mA([1,0,0]),o=new mA([0,1,0]),s=new mA([0,0,1]);r.transformByQuaternion(i),r.scale(t[0]),o.transformByQuaternion(i),o.scale(t[1]),s.transformByQuaternion(i),s.scale(t[2]),n=[...r.toArray(),...o.toArray(),...s.toArray()]}else n=[...e.slice(3,6),...e.slice(6,9),...e.slice(9,12)];const o=t.transformAsVector(n.slice(0,3)),s=t.transformAsVector(n.slice(3,6)),a=t.transformAsVector(n.slice(6,9)),l=new bA([o[0],o[1],o[2],s[0],s[1],s[2],a[0],a[1],a[2]]);return CF(i)?(i.center=r,i.halfAxes=l,i):new mI(r,l)}function zF(){return[[1/0,1/0,1/0],[-1/0,-1/0,-1/0]]}function UF(e,t){iF.WGS84.cartesianToCartographic(t,BF),e[0][0]=Math.min(e[0][0],BF[0]),e[0][1]=Math.min(e[0][1],BF[1]),e[0][2]=Math.min(e[0][2],BF[2]),e[1][0]=Math.max(e[1][0],BF[0]),e[1][1]=Math.max(e[1][1],BF[1]),e[1][2]=Math.max(e[1][2],BF[2])}function NF(e,t){if(e.dynamicScreenSpaceError&&e.dynamicScreenSpaceErrorComputedDensity){const i=e.dynamicScreenSpaceErrorComputedDensity,r=e.dynamicScreenSpaceErrorFactor,n=function(e,t){const i=e*t;return 1-Math.exp(-i*i)}(t,i)*r;return n}return 0}new mA,new mA,new VA,new mA,new mA,new mA;const VF=new mA,jF=new mA,GF=new mA,HF=new mA,QF=new mA,$F=new VA,ZF=new VA;function WF(e,t){const{topDownViewport:i}=t,r=e.header.mbs[1],n=e.header.mbs[0],o=e.header.mbs[2],s=e.header.mbs[3],a=[...e.boundingVolume.center],l=i.unprojectPosition(i.cameraPosition);iF.WGS84.cartographicToCartesian(l,VF),jF.copy(VF).subtract(a).normalize(),iF.WGS84.eastNorthUpToFixedFrame(a,$F),ZF.copy($F).invert(),GF.copy(VF).transform(ZF);const c=Math.sqrt(GF[0]*GF[0]+GF[1]*GF[1]),u=c*c/GF[2];HF.copy([GF[0],GF[1],u]);const h=HF.transform($F).subtract(a).normalize(),d=jF.cross(h).normalize().scale(s).add(a),p=iF.WGS84.cartesianToCartographic(d),f=i.project([n,r,o]),m=i.project(p);return QF.copy(f).subtract(m).magnitude()}class qF{_map=new Map;_array;_length;constructor(e=0){this._array=new Array(e),this._length=e}get length(){return this._length}set length(e){this._length=e,e>this._array.length&&(this._array.length=e)}get values(){return this._array}get(e){return Tu(e=0),e>=this.length&&(this.length=e+1),this._map.has(this._array[e])&&this._map.delete(this._array[e]),this._array[e]=t,this._map.set(t,e)}delete(e){const t=this._map.get(e);t>=0&&(this._array.splice(t,1),this._map.delete(e),this.length--)}peek(){return this._array[this._length-1]}push(e){if(!this._map.has(e)){const t=this.length++;this._array[t]=e,this._map.set(e,t)}}pop(){const e=this._array[--this.length];return this._map.delete(e),e}reserve(e){Tu(e>=0),e>this._array.length&&(this._array.length=e)}resize(e){Tu(e>=0),this.length=e}trim(e){null==e&&(e=this.length),this._array.length=e}reset(){this._array=[],this._map=new Map,this._length=0}find(e){return this._map.has(e)}}const KF={loadSiblings:!1,skipLevelOfDetail:!1,updateTransforms:!0,onTraversalEnd:()=>{},viewportTraversersMap:{},basePath:""};class XF{options;root=null;selectedTiles={};requestedTiles={};emptyTiles={};lastUpdate=(new Date).getTime();updateDebounceTime=1e3;_traversalStack=new qF;_emptyTraversalStack=new qF;_frameNumber=null;traversalFinished(e){return!0}constructor(e){this.options={...KF,...e}}traverse(e,t,i){this.root=e,this.options={...this.options,...i},this.reset(),this.updateTile(e,t),this._frameNumber=t.frameNumber,this.executeTraversal(e,t)}reset(){this.requestedTiles={},this.selectedTiles={},this.emptyTiles={},this._traversalStack.reset(),this._emptyTraversalStack.reset()}executeTraversal(e,t){const i=this._traversalStack;for(e._selectionDepth=1,i.push(e);i.length>0;){const e=i.pop();let r=!1;this.canTraverse(e,t)&&(this.updateChildTiles(e,t),r=this.updateAndPushChildren(e,t,i,e.hasRenderContent?e._selectionDepth+1:e._selectionDepth));const n=e.parent,o=Boolean(!n||n._shouldRefine),s=!r;e.hasRenderContent?e.refine===xF.ADD?(this.loadTile(e,t),this.selectTile(e,t)):e.refine===xF.REPLACE&&(this.loadTile(e,t),s&&this.selectTile(e,t)):(this.emptyTiles[e.id]=e,this.loadTile(e,t),s&&this.selectTile(e,t)),this.touchTile(e,t),e._shouldRefine=r&&o}const r=(new Date).getTime();(this.traversalFinished(t)||r-this.lastUpdate>this.updateDebounceTime)&&(this.lastUpdate=r,this.options.onTraversalEnd(t))}updateChildTiles(e,t){const i=e.children;for(const e of i)this.updateTile(e,t)}updateAndPushChildren(e,t,i,r){const{loadSiblings:n,skipLevelOfDetail:o}=this.options,s=e.children;s.sort(this.compareDistanceToCamera.bind(this));const a=e.refine===xF.REPLACE&&e.hasRenderContent&&!o;let l=!1,c=!0;for(const e of s)if(e._selectionDepth=r,e.isVisibleAndInRequestVolume?(i.find(e)&&i.delete(e),i.push(e),l=!0):(a||n)&&(this.loadTile(e,t),this.touchTile(e,t)),a){let i;if(i=!!e._inRequestVolume&&(e.hasRenderContent?e.contentAvailable:this.executeEmptyTraversal(e,t)),c=c&&i,!c)return!1}return l||(c=!1),c}updateTile(e,t){this.updateTileVisibility(e,t)}selectTile(e,t){this.shouldSelectTile(e)&&(e._selectedFrame=t.frameNumber,this.selectedTiles[e.id]=e)}loadTile(e,t){this.shouldLoadTile(e)&&(e._requestedFrame=t.frameNumber,e._priority=e._getPriority(),this.requestedTiles[e.id]=e)}touchTile(e,t){e.tileset._cache.touch(e),e._touchedFrame=t.frameNumber}canTraverse(e,t){return!!e.hasChildren&&(e.hasTilesetContent?!e.contentExpired:this.shouldRefine(e,t))}shouldLoadTile(e){return e.hasUnloadedContent||e.contentExpired}shouldSelectTile(e){return e.contentAvailable&&!this.options.skipLevelOfDetail}shouldRefine(e,t,i=!1){let r=e._screenSpaceError;return i&&(r=e.getScreenSpaceError(t,!0)),r>e.tileset.memoryAdjustedScreenSpaceError}updateTileVisibility(e,t){const i=[];if(this.options.viewportTraversersMap)for(const e in this.options.viewportTraversersMap){this.options.viewportTraversersMap[e]===t.viewport.id&&i.push(e)}else i.push(t.viewport.id);e.updateVisibility(t,i)}compareDistanceToCamera(e,t){return e._distanceToCamera-t._distanceToCamera}anyChildrenVisible(e,t){let i=!1;for(const r of e.children)r.updateVisibility(t),i=i||r.isVisibleAndInRequestVolume;return i}executeEmptyTraversal(e,t){let i=!0;const r=this._emptyTraversalStack;for(r.push(e);r.length>0;){const e=r.pop(),n=!e.hasRenderContent&&this.canTraverse(e,t),o=!e.hasRenderContent&&0===e.children.length;if(n||e.contentAvailable||o||(i=!1),this.updateTile(e,t),e.isVisibleAndInRequestVolume||(this.loadTile(e,t),this.touchTile(e,t)),n){const t=e.children;for(const e of t)r.push(e)}}return i}}const JF=new mA;class YF{tileset;header;id;url;parent;refine;type;contentUrl;lodMetricType="geometricError";lodMetricValue=0;boundingVolume=null;content=null;contentState=gF;gpuMemoryUsageInBytes=0;children=[];depth=0;viewportIds=[];transform=new VA;extensions=null;implicitTiling=null;userData={};computedTransform;hasEmptyContent=!1;hasTilesetContent=!1;traverser=new XF({});_cacheNode=null;_frameNumber=null;_expireDate=null;_expiredContent=null;_boundingBox=void 0;_distanceToCamera=0;_screenSpaceError=0;_visibilityPlaneMask;_visible=void 0;_contentBoundingVolume;_viewerRequestVolume;_initialTransform=new VA;_priority=0;_selectedFrame=0;_requestedFrame=0;_selectionDepth=0;_touchedFrame=0;_centerZDepth=0;_shouldRefine=!1;_stackLength=0;_visitedFrame=0;_inRequestVolume=!1;_lodJudge=null;constructor(e,t,i,r=""){this.header=t,this.tileset=e,this.id=r||t.id,this.url=t.url,this.parent=i,this.refine=this._getRefine(t.refine),this.type=t.type,this.contentUrl=t.contentUrl,this._initializeLodMetric(t),this._initializeTransforms(t),this._initializeBoundingVolumes(t),this._initializeContent(t),this._initializeRenderingState(t),Object.seal(this)}destroy(){this.header=null}isDestroyed(){return null===this.header}get selected(){return this._selectedFrame===this.tileset._frameNumber}get isVisible(){return this._visible}get isVisibleAndInRequestVolume(){return this._visible&&this._inRequestVolume}get hasRenderContent(){return!this.hasEmptyContent&&!this.hasTilesetContent}get hasChildren(){return this.children.length>0||this.header.children&&this.header.children.length>0}get contentReady(){return this.contentState===AF||this.hasEmptyContent}get contentAvailable(){return Boolean(this.contentReady&&this.hasRenderContent||this._expiredContent&&!this.contentFailed)}get hasUnloadedContent(){return this.hasRenderContent&&this.contentUnloaded}get contentUnloaded(){return this.contentState===gF}get contentExpired(){return this.contentState===yF}get contentFailed(){return this.contentState===vF}get distanceToCamera(){return this._distanceToCamera}get screenSpaceError(){return this._screenSpaceError}get boundingBox(){return this._boundingBox||(this._boundingBox=DF(this.header.boundingVolume,this.boundingVolume)),this._boundingBox}getScreenSpaceError(e,t){switch(this.tileset.type){case wF.I3S:return WF(this,e);case wF.TILES3D:return function(e,t,i){const r=e.tileset,n=e.parent&&e.parent.lodMetricValue||e.lodMetricValue,o=i?n:e.lodMetricValue;if(0===o)return 0;const s=Math.max(e._distanceToCamera,1e-7),{height:a,sseDenominator:l}=t,{viewDistanceScale:c}=r.options;let u=o*a*(c||1)/(s*l);return u-=NF(r,s),u}(this,e,t);default:throw new Error("Unsupported tileset type")}}unselect(){this._selectedFrame=0}_getGpuMemoryUsageInBytes(){return this.content.gpuMemoryUsageInBytes||this.content.byteLength||0}_getPriority(){const e=this.tileset._traverser,{skipLevelOfDetail:t}=e.options,i=this.refine===xF.ADD||t;if(i&&!this.isVisible&&void 0!==this._visible)return-1;if(this.tileset._frameNumber-this._touchedFrame>=1)return-1;if(this.contentState===gF)return-1;const r=this.parent,n=r&&(!i||0===this._screenSpaceError||r.hasTilesetContent)?r._screenSpaceError:this._screenSpaceError,o=e.root?e.root._screenSpaceError:0;return Math.max(o-n,0)}async loadContent(){if(this.hasEmptyContent)return!1;if(this.content)return!0;this.contentExpired&&(this._expireDate=null),this.contentState=_F;const e=await this.tileset._requestScheduler.scheduleRequest(this.id,this._getPriority.bind(this));if(!e)return this.contentState=gF,!1;try{const e=this.tileset.getTileUrl(this.contentUrl),t=this.tileset.loader,i={...this.tileset.loadOptions,[t.id]:{...this.tileset.loadOptions[t.id],isTileset:"json"===this.type,...this._getLoaderSpecificOptions(t.id)}};return this.content=await VS(e,t,i),this.tileset.options.contentLoader&&await this.tileset.options.contentLoader(this),this._isTileset()&&this.tileset._initializeTileHeaders(this.content,this),this.contentState=AF,this._onContentLoaded(),!0}catch(e){throw this.contentState=vF,e}finally{e.done()}}unloadContent(){return this.content&&this.content.destroy&&this.content.destroy(),this.content=null,this.header.content&&this.header.content.destroy&&this.header.content.destroy(),this.header.content=null,this.contentState=gF,!0}updateVisibility(e,t){if(this._frameNumber===e.frameNumber)return;const i=this.parent,r=i?i._visibilityPlaneMask:bI.MASK_INDETERMINATE;if(this.tileset._traverser.options.updateTransforms){const e=i?i.computedTransform:this.tileset.modelMatrix;this._updateTransform(e)}this._distanceToCamera=this.distanceToTile(e),this._screenSpaceError=this.getScreenSpaceError(e,!1),this._visibilityPlaneMask=this.visibility(e,r),this._visible=this._visibilityPlaneMask!==bI.MASK_OUTSIDE,this._inRequestVolume=this.insideViewerRequestVolume(e),this._frameNumber=e.frameNumber,this.viewportIds=t}visibility(e,t){const{cullingVolume:i}=e,{boundingVolume:r}=this;return i.computeVisibilityWithPlaneMask(r,t)}contentVisibility(){return!0}distanceToTile(e){const t=this.boundingVolume;return Math.sqrt(Math.max(t.distanceSquaredTo(e.camera.position),0))}cameraSpaceZDepth({camera:e}){const t=this.boundingVolume;return JF.subVectors(t.center,e.position),e.direction.dot(JF)}insideViewerRequestVolume(e){const t=this._viewerRequestVolume;return!t||t.distanceSquaredTo(e.camera.position)<=0}updateExpiration(){if(function(e){return null!=e}(this._expireDate)&&this.contentReady&&!this.hasEmptyContent){const e=Date.now();Date.lessThan(this._expireDate,e)&&(this.contentState=yF,this._expiredContent=this.content)}}get extras(){return this.header.extras}_initializeLodMetric(e){"lodMetricType"in e?this.lodMetricType=e.lodMetricType:(this.lodMetricType=this.parent&&this.parent.lodMetricType||this.tileset.lodMetricType,console.warn("3D Tile: Required prop lodMetricType is undefined. Using parent lodMetricType")),"lodMetricValue"in e?this.lodMetricValue=e.lodMetricValue:(this.lodMetricValue=this.parent&&this.parent.lodMetricValue||this.tileset.lodMetricValue,console.warn("3D Tile: Required prop lodMetricValue is undefined. Using parent lodMetricValue"))}_initializeTransforms(e){this.transform=e.transform?new VA(e.transform):new VA;const t=this.parent,i=this.tileset,r=t&&t.computedTransform?t.computedTransform.clone():i.modelMatrix.clone();this.computedTransform=new VA(r).multiplyRight(this.transform);const n=t&&t._initialTransform?t._initialTransform.clone():new VA;this._initialTransform=new VA(n).multiplyRight(this.transform)}_initializeBoundingVolumes(e){this._contentBoundingVolume=null,this._viewerRequestVolume=null,this._updateBoundingVolume(e)}_initializeContent(e){this.content={_tileset:this.tileset,_tile:this},this.hasEmptyContent=!0,this.contentState=gF,this.hasTilesetContent=!1,e.contentUrl&&(this.content=null,this.hasEmptyContent=!1)}_initializeRenderingState(e){this.depth=e.level||(this.parent?this.parent.depth+1:0),this._shouldRefine=!1,this._distanceToCamera=0,this._centerZDepth=0,this._screenSpaceError=0,this._visibilityPlaneMask=bI.MASK_INDETERMINATE,this._visible=void 0,this._inRequestVolume=!1,this._stackLength=0,this._selectionDepth=0,this._frameNumber=0,this._touchedFrame=0,this._visitedFrame=0,this._selectedFrame=0,this._requestedFrame=0,this._priority=0}_getRefine(e){return e||this.parent&&this.parent.refine||xF.REPLACE}_isTileset(){return-1!==this.contentUrl.indexOf(".json")}_onContentLoaded(){switch(this.content&&this.content.type){case"vctr":case"geom":this.tileset._traverser.disableSkipLevelOfDetail=!0}this._isTileset()?this.hasTilesetContent=!0:this.gpuMemoryUsageInBytes=this._getGpuMemoryUsageInBytes()}_updateBoundingVolume(e){this.boundingVolume=kF(e.boundingVolume,this.computedTransform,this.boundingVolume);const t=e.content;t&&(t.boundingVolume&&(this._contentBoundingVolume=kF(t.boundingVolume,this.computedTransform,this._contentBoundingVolume)),e.viewerRequestVolume&&(this._viewerRequestVolume=kF(e.viewerRequestVolume,this.computedTransform,this._viewerRequestVolume)))}_updateTransform(e=new VA){const t=e.clone().multiplyRight(this.transform);!t.equals(this.computedTransform)&&(this.computedTransform=t,this._updateBoundingVolume(this.header))}_getLoaderSpecificOptions(e){return"i3s"===e?{...this.tileset.options.i3s,_tileOptions:{attributeUrls:this.header.attributeUrls,textureUrl:this.header.textureUrl,textureFormat:this.header.textureFormat,textureLoaderOptions:this.header.textureLoaderOptions,materialDefinition:this.header.materialDefinition,isDracoGeometry:this.header.isDracoGeometry,mbs:this.header.mbs},_tilesetOptions:{store:this.tileset.tileset.store,attributeStorageInfo:this.tileset.tileset.attributeStorageInfo,fields:this.tileset.tileset.fields},isTileHeader:!1}:{assetGltfUpAxis:(t=this.tileset.tileset).asset&&t.asset.gltfUpAxis||"Y"};var t}}class ek extends XF{compareDistanceToCamera(e,t){return 0===t._distanceToCamera&&0===e._distanceToCamera?t._centerZDepth-e._centerZDepth:t._distanceToCamera-e._distanceToCamera}updateTileVisibility(e,t){if(super.updateTileVisibility(e,t),!e.isVisibleAndInRequestVolume)return;const i=e.children.length>0;if(e.hasTilesetContent&&i){const i=e.children[0];return this.updateTileVisibility(i,t),void(e._visible=i._visible)}if(this.meetsScreenSpaceErrorEarly(e,t))return void(e._visible=!1);const r=e.refine===xF.REPLACE,n=e._optimChildrenWithinParent===EF;r&&n&&i&&!this.anyChildrenVisible(e,t)&&(e._visible=!1)}meetsScreenSpaceErrorEarly(e,t){const{parent:i}=e;return!(!i||i.hasTilesetContent||i.refine!==xF.ADD)&&!this.shouldRefine(e,t,!0)}}class tk{frameNumberMap=new Map;register(e,t){const i=this.frameNumberMap.get(e)||new Map,r=i.get(t)||0;i.set(t,r+1),this.frameNumberMap.set(e,i)}deregister(e,t){const i=this.frameNumberMap.get(e);if(!i)return;const r=i.get(t)||1;i.set(t,r-1)}isZero(e,t){return 0===(this.frameNumberMap.get(e)?.get(t)||0)}}const ik="REQUESTED",rk="COMPLETED",nk="ERROR";class ok{_statusMap;pendingTilesRegister=new tk;constructor(){this._statusMap={}}add(e,t,i,r){if(!this._statusMap[t]){const{frameNumber:n,viewport:{id:o}}=r;this._statusMap[t]={request:e,callback:i,key:t,frameState:r,status:ik},this.pendingTilesRegister.register(o,n),e().then(e=>{this._statusMap[t].status=rk;const{frameNumber:i,viewport:{id:n}}=this._statusMap[t].frameState;this.pendingTilesRegister.deregister(n,i),this._statusMap[t].callback(e,r)}).catch(e=>{this._statusMap[t].status=nk;const{frameNumber:r,viewport:{id:n}}=this._statusMap[t].frameState;this.pendingTilesRegister.deregister(n,r),i(e)})}}update(e,t){if(this._statusMap[e]){const{frameNumber:i,viewport:{id:r}}=this._statusMap[e].frameState;this.pendingTilesRegister.deregister(r,i);const{frameNumber:n,viewport:{id:o}}=t;this.pendingTilesRegister.register(o,n),this._statusMap[e].frameState=t}}find(e){return this._statusMap[e]}hasPendingTiles(e,t){return!this.pendingTilesRegister.isZero(e,t)}}class sk extends XF{_tileManager;constructor(e){super(e),this._tileManager=new ok}traversalFinished(e){return!this._tileManager.hasPendingTiles(e.viewport.id,this._frameNumber||0)}shouldRefine(e,t){return e._lodJudge=function(e,t){if(0===e.lodMetricValue||isNaN(e.lodMetricValue))return"DIG";const i=2*WF(e,t);return i<2?"OUT":!e.header.children||i<=e.lodMetricValue?"DRAW":e.header.children?"DIG":"OUT"}(e,t),"DIG"===e._lodJudge}updateChildTiles(e,t){const i=e.header.children||[],r=e.children,n=e.tileset;for(const o of i){const i=`${o.id}-${t.viewport.id}`,s=r&&r.find(e=>e.id===i);if(s)s&&this.updateTile(s,t);else{let r=()=>this._loadTile(o.id,n);this._tileManager.find(i)?this._tileManager.update(i,t):(n.tileset.nodePages&&(r=()=>n.tileset.nodePagesTile.formTileFromNodePages(o.id)),this._tileManager.add(r,i,t=>this._onTileLoad(t,e,i),t))}}return!1}async _loadTile(e,t){const{loader:i}=t,r=t.getTileUrl(`${t.url}/nodes/${e}`),n={...t.loadOptions,i3s:{...t.loadOptions.i3s,isTileHeader:!0}};return await VS(r,i,n)}_onTileLoad(e,t,i){const r=new YF(t.tileset,e,t,i);t.children.push(r);const n=this._tileManager.find(r.id).frameState;this.updateTile(r,n),this._frameNumber===n.frameNumber&&(this.traversalFinished(n)||(new Date).getTime()-this.lastUpdate>this.updateDebounceTime)&&this.executeTraversal(r,n)}}const ak={description:"",ellipsoid:iF.WGS84,modelMatrix:new VA,throttleRequests:!0,maxRequests:64,maximumMemoryUsage:32,memoryCacheOverflow:1,maximumTilesSelected:0,debounceTime:0,onTileLoad:()=>{},onTileUnload:()=>{},onTileError:()=>{},onTraversalComplete:e=>e,contentLoader:void 0,viewDistanceScale:1,maximumScreenSpaceError:8,memoryAdjustedScreenSpaceError:!1,loadTiles:!0,updateTransforms:!0,viewportTraversersMap:null,loadOptions:{fetch:{}},attributions:[],basePath:"",i3s:{}},lk="Tiles In Tileset(s)",ck="Tiles In Memory",uk="Tiles In View",hk="Tiles To Render",dk="Tiles Loaded",pk="Tiles Loading",fk="Tiles Unloaded",mk="Failed Tile Loads",gk="Points/Vertices",_k="Tile Memory Use",Ak="Maximum Screen Space Error";class yk{options;loadOptions;type;tileset;loader;url;basePath;modelMatrix;ellipsoid;lodMetricType;lodMetricValue;refine;root=null;roots={};asset={};description="";properties;extras=null;attributions={};credits={};stats;contentFormats={draco:!1,meshopt:!1,dds:!1,ktx2:!1};cartographicCenter=null;cartesianCenter=null;zoom=1;boundingVolume=null;dynamicScreenSpaceErrorComputedDensity=0;maximumMemoryUsage=32;gpuMemoryUsageInBytes=0;memoryAdjustedScreenSpaceError=0;_cacheBytes=0;_cacheOverflowBytes=0;_frameNumber=0;_queryParams={};_extensionsUsed=[];_tiles={};_pendingCount=0;selectedTiles=[];traverseCounter=0;geometricError=0;lastUpdatedVieports=null;_requestedTiles=[];_emptyTiles=[];frameStateData={};_traverser;_cache=new oF;_requestScheduler;updatePromise=null;tilesetInitializationPromise;constructor(e,t){this.options={...ak,...t},this.tileset=e,this.loader=e.loader,this.type=e.type,this.url=e.url,this.basePath=e.basePath||Rh(this.url),this.modelMatrix=this.options.modelMatrix,this.ellipsoid=this.options.ellipsoid,this.lodMetricType=e.lodMetricType,this.lodMetricValue=e.lodMetricValue,this.refine=e.root.refine,this.loadOptions=this.options.loadOptions||{},this._traverser=this._initializeTraverser(),this._requestScheduler=new Bh({throttleRequests:this.options.throttleRequests,maxRequests:this.options.maxRequests}),this.memoryAdjustedScreenSpaceError=this.options.maximumScreenSpaceError,this._cacheBytes=1024*this.options.maximumMemoryUsage*1024,this._cacheOverflowBytes=1024*this.options.memoryCacheOverflow*1024,this.stats=new Eh({id:this.url}),this._initializeStats(),this.tilesetInitializationPromise=this._initializeTileSet(e)}destroy(){this._destroy()}isLoaded(){return 0===this._pendingCount&&0!==this._frameNumber&&0===this._requestedTiles.length}get tiles(){return Object.values(this._tiles)}get frameNumber(){return this._frameNumber}get queryParams(){return new URLSearchParams(this._queryParams).toString()}setProps(e){this.options={...this.options,...e}}getTileUrl(e){if(e.startsWith("data:"))return e;let t=e;return this.queryParams.length&&(t=`${e}${e.includes("?")?"&":"?"}${this.queryParams}`),t}hasExtension(e){return Boolean(this._extensionsUsed.indexOf(e)>-1)}update(e=null){this.tilesetInitializationPromise.then(()=>{!e&&this.lastUpdatedVieports?e=this.lastUpdatedVieports:this.lastUpdatedVieports=e,e&&this.doUpdate(e)})}async selectTiles(e=null){return await this.tilesetInitializationPromise,e&&(this.lastUpdatedVieports=e),this.updatePromise||(this.updatePromise=new Promise(e=>{setTimeout(()=>{this.lastUpdatedVieports&&this.doUpdate(this.lastUpdatedVieports),e(this._frameNumber),this.updatePromise=null},this.options.debounceTime)})),this.updatePromise}adjustScreenSpaceError(){this.gpuMemoryUsageInBytesthis._cacheBytes+this._cacheOverflowBytes&&(this.memoryAdjustedScreenSpaceError*=1.02)}doUpdate(e){if("loadTiles"in this.options&&!this.options.loadTiles)return;if(this.traverseCounter>0)return;const t=e instanceof Array?e:[e];this._cache.reset(),this._frameNumber++,this.traverseCounter=t.length;const i=[];for(const e of t){const t=e.id;this._needTraverse(t)?i.push(t):this.traverseCounter--}for(const e of t){const t=e.id;if(this.roots[t]||(this.roots[t]=this._initializeTileHeaders(this.tileset,null)),!i.includes(t))continue;const r=cF(e,this._frameNumber);this._traverser.traverse(this.roots[t],r,this.options)}}_needTraverse(e){let t=e;return this.options.viewportTraversersMap&&(t=this.options.viewportTraversersMap[e]),t===e}_onTraversalEnd(e){const t=e.viewport.id;this.frameStateData[t]||(this.frameStateData[t]={selectedTiles:[],_requestedTiles:[],_emptyTiles:[]});const i=this.frameStateData[t],r=Object.values(this._traverser.selectedTiles),[n,o]=function(e,t,i){if(0===i||e.length<=i)return[e,[]];const r=[],{longitude:n,latitude:o}=t.viewport;for(const[t,i]of e.entries()){const[e,s]=i.header.mbs,a=Math.abs(n-e),l=Math.abs(o-s),c=Math.sqrt(l*l+a*a);r.push([t,c])}const s=r.sort((e,t)=>e[1]-t[1]),a=[];for(let t=0;t0||this._updateTiles()}_updateTiles(){this.selectedTiles=[],this._requestedTiles=[],this._emptyTiles=[];for(const e in this.frameStateData){const t=this.frameStateData[e];this.selectedTiles=this.selectedTiles.concat(t.selectedTiles),this._requestedTiles=this._requestedTiles.concat(t._requestedTiles),this._emptyTiles=this._emptyTiles.concat(t._emptyTiles)}this.selectedTiles=this.options.onTraversalComplete(this.selectedTiles);for(const e of this.selectedTiles)this._tiles[e.id]=e;this._loadTiles(),this._unloadTiles(),this._updateStats()}_tilesChanged(e,t){if(e.length!==t.length)return!0;const i=new Set(e.map(e=>e.id)),r=new Set(t.map(e=>e.id));let n=e.filter(e=>!r.has(e.id)).length>0;return n=n||t.filter(e=>!i.has(e.id)).length>0,n}_loadTiles(){for(const e of this._requestedTiles)e.contentUnloaded&&this._loadTile(e)}_unloadTiles(){this._cache.unloadTiles(this,(e,t)=>e._unloadTile(t))}_updateStats(){let e=0,t=0;for(const i of this.selectedTiles)i.contentAvailable&&i.content&&(e++,i.content.pointCount?t+=i.content.pointCount:t+=i.content.vertexCount);this.stats.get(uk).count=this.selectedTiles.length,this.stats.get(hk).count=e,this.stats.get(gk).count=t,this.stats.get(Ak).count=this.memoryAdjustedScreenSpaceError}async _initializeTileSet(e){this.type===wF.I3S&&(this.calculateViewPropsI3S(),e.root=await e.root),this.root=this._initializeTileHeaders(e,null),this.type===wF.TILES3D&&(this._initializeTiles3DTileset(e),this.calculateViewPropsTiles3D()),this.type===wF.I3S&&this._initializeI3STileset()}calculateViewPropsI3S(){const e=this.tileset.fullExtent;if(e){const{xmin:t,xmax:i,ymin:r,ymax:n,zmin:o,zmax:s}=e;return this.cartographicCenter=new mA(t+(i-t)/2,r+(n-r)/2,o+(s-o)/2),this.cartesianCenter=new mA,iF.WGS84.cartographicToCartesian(this.cartographicCenter,this.cartesianCenter),void(this.zoom=mF(e,this.cartographicCenter,this.cartesianCenter))}const t=this.tileset.store?.extent;if(t){const[e,i,r,n]=t;return this.cartographicCenter=new mA(e+(r-e)/2,i+(n-i)/2,0),this.cartesianCenter=new mA,iF.WGS84.cartographicToCartesian(this.cartographicCenter,this.cartesianCenter),void(this.zoom=function(e,t,i){const[r,n,o,s]=e;return mF({xmin:r,xmax:o,ymin:n,ymax:s,zmin:0,zmax:0},t,i)}(t,this.cartographicCenter,this.cartesianCenter))}console.warn("Extent is not defined in the tileset header"),this.cartographicCenter=new mA,this.zoom=1}calculateViewPropsTiles3D(){const e=this.root,{center:t}=e.boundingVolume;if(!t)return console.warn("center was not pre-calculated for the root tile"),this.cartographicCenter=new mA,void(this.zoom=1);0!==t[0]||0!==t[1]||0!==t[2]?(this.cartographicCenter=new mA,iF.WGS84.cartesianToCartographic(t,this.cartographicCenter)):this.cartographicCenter=new mA(0,0,-iF.WGS84.radii[0]),this.cartesianCenter=t,this.zoom=fF(e.boundingVolume,this.cartographicCenter)}_initializeStats(){this.stats.get(lk),this.stats.get(pk),this.stats.get(ck),this.stats.get(uk),this.stats.get(hk),this.stats.get(dk),this.stats.get(fk),this.stats.get(mk),this.stats.get(gk),this.stats.get(_k,"memory"),this.stats.get(Ak)}_initializeTileHeaders(e,t){const i=new YF(this,e.root,t);if(t&&(t.children.push(i),i.depth=t.depth+1),this.type===wF.TILES3D){const e=[];for(e.push(i);e.length>0;){const t=e.pop();this.stats.get(lk).incrementCount();const i=t.header.children||[];for(const r of i){const i=new YF(this,r,t);if(i.contentUrl?.includes("?session=")){const e=new URL(i.contentUrl).searchParams.get("session");e&&(this._queryParams.session=e)}t.children.push(i),i.depth=t.depth+1,e.push(i)}}}return i}_initializeTraverser(){let e;switch(this.type){case wF.TILES3D:e=ek;break;case wF.I3S:e=sk;break;default:e=XF}return new e({basePath:this.basePath,onTraversalEnd:this._onTraversalEnd.bind(this)})}_destroyTileHeaders(e){this._destroySubtree(e)}async _loadTile(e){let t;try{this._onStartTileLoading(),t=await e.loadContent()}catch(t){this._onTileLoadError(e,t instanceof Error?t:new Error("load failed"))}finally{this._onEndTileLoading(),this._onTileLoad(e,t)}}_onTileLoadError(e,t){this.stats.get(mk).incrementCount();const i=t.message||t.toString(),r=e.url;console.error(`A 3D tile failed to load: ${e.url} ${i}`),this.options.onTileError(e,i,r)}_onTileLoad(e,t){if(t){if(this.type===wF.I3S){const e=this.tileset?.nodePagesTile?.nodesInNodePages||0;this.stats.get(lk).reset(),this.stats.get(lk).addCount(e)}e&&e.content&&function(e,t){Tu(e),Tu(t);const{rtcCenter:i,gltfUpAxis:r}=t,{computedTransform:n,boundingVolume:{center:o}}=e;let s=new VA(n);switch(i&&s.translate(i),r){case"Z":break;case"Y":const e=(new VA).rotateX(Math.PI/2);s=s.multiplyRight(e);break;case"X":const t=(new VA).rotateY(-Math.PI/2);s=s.multiplyRight(t)}t.isQuantized&&s.translate(t.quantizedVolumeOffset).scale(t.quantizedVolumeScale);const a=new mA(o);t.cartesianModelMatrix=s,t.cartesianOrigin=a;const l=iF.WGS84.cartesianToCartographic(a,new mA),c=iF.WGS84.eastNorthUpToFixedFrame(a).invert();t.cartographicModelMatrix=c.multiplyRight(s),t.cartographicOrigin=l,t.coordinateSystem||(t.modelMatrix=t.cartographicModelMatrix)}(e,e.content),this.updateContentTypes(e),this._addTileToCache(e),this.options.onTileLoad(e)}}updateContentTypes(e){if(this.type===wF.I3S)switch(e.header.isDracoGeometry&&(this.contentFormats.draco=!0),e.header.textureFormat){case"dds":this.contentFormats.dds=!0;break;case"ktx2":this.contentFormats.ktx2=!0}else if(this.type===wF.TILES3D){const{extensionsRemoved:t=[]}=e.content?.gltf||{};t.includes("KHR_draco_mesh_compression")&&(this.contentFormats.draco=!0),t.includes("EXT_meshopt_compression")&&(this.contentFormats.meshopt=!0),t.includes("KHR_texture_basisu")&&(this.contentFormats.ktx2=!0)}}_onStartTileLoading(){this._pendingCount++,this.stats.get(pk).incrementCount()}_onEndTileLoading(){this._pendingCount--,this.stats.get(pk).decrementCount()}_addTileToCache(e){this._cache.add(this,e,t=>t._updateCacheStats(e))}_updateCacheStats(e){this.stats.get(dk).incrementCount(),this.stats.get(ck).incrementCount(),this.gpuMemoryUsageInBytes+=e.gpuMemoryUsageInBytes||0,this.stats.get(_k).count=this.gpuMemoryUsageInBytes,this.options.memoryAdjustedScreenSpaceError&&this.adjustScreenSpaceError()}_unloadTile(e){this.gpuMemoryUsageInBytes-=e.gpuMemoryUsageInBytes||0,this.stats.get(ck).decrementCount(),this.stats.get(fk).incrementCount(),this.stats.get(_k).count=this.gpuMemoryUsageInBytes,this.options.onTileUnload(e),e.unloadContent()}_destroy(){const e=[];for(this.root&&e.push(this.root);e.length>0;){const t=e.pop();for(const i of t.children)e.push(i);this._destroyTile(t)}this.root=null}_destroySubtree(e){const t=e,i=[];for(i.push(t);i.length>0;){e=i.pop();for(const t of e.children)i.push(t);e!==t&&this._destroyTile(e)}t.children=[]}_destroyTile(e){this._cache.unloadTile(this,e),this._unloadTile(e),e.destroy()}_initializeTiles3DTileset(e){if(e.queryString){const t=new URLSearchParams(e.queryString),i=Object.fromEntries(t.entries());this._queryParams={...this._queryParams,...i}}if(this.asset=e.asset,!this.asset)throw new Error("Tileset must have an asset property.");if("0.0"!==this.asset.version&&"1.0"!==this.asset.version&&"1.1"!==this.asset.version)throw new Error("The tileset must be 3D Tiles version either 0.0 or 1.0 or 1.1.");"tilesetVersion"in this.asset&&(this._queryParams.v=this.asset.tilesetVersion),this.credits={attributions:this.options.attributions||[]},this.description=this.options.description||"",this.properties=e.properties,this.geometricError=e.geometricError,this._extensionsUsed=e.extensionsUsed||[],this.extras=e.extras}_initializeI3STileset(){this.loadOptions.i3s&&"token"in this.loadOptions.i3s&&(this._queryParams.token=this.loadOptions.i3s.token)}}const vk="4.3.3",xk="cmpt",bk="pnts",wk="b3dm",Tk="i3dm",Ek="glTF";function Ck(e,t,i){Tu(e instanceof ArrayBuffer);const r=new TextDecoder("utf8"),n=new Uint8Array(e,t,i);return r.decode(n)}const Bk="4.3.3",Sk={dataType:null,batchType:null,name:"Draco",id:"draco",module:"draco",version:Bk,worker:!0,extensions:["drc"],mimeTypes:["application/octet-stream"],binary:!0,tests:["DRACO"],options:{draco:{decoderType:"object"==typeof WebAssembly?"wasm":"js",libraryPath:"libs/",extraAttributes:{},attributeNameEntry:void 0}}};function Ik(e,t,i){return Rd(e,t,i?Mk(i.metadata):void 0)}function Mk(e){const t={};for(const i in e)t[`${i}.string`]=JSON.stringify(e[i]);return t}const Pk={POSITION:"POSITION",NORMAL:"NORMAL",COLOR:"COLOR_0",TEX_COORD:"TEXCOORD_0"},Rk={1:Int8Array,2:Uint8Array,3:Int16Array,4:Uint16Array,5:Int32Array,6:Uint32Array,9:Float32Array};class Lk{draco;decoder;metadataQuerier;constructor(e){this.draco=e,this.decoder=new this.draco.Decoder,this.metadataQuerier=new this.draco.MetadataQuerier}destroy(){this.draco.destroy(this.decoder),this.draco.destroy(this.metadataQuerier)}parseSync(e,t={}){const i=new this.draco.DecoderBuffer;i.Init(new Int8Array(e),e.byteLength),this._disableAttributeTransforms(t);const r=this.decoder.GetEncodedGeometryType(i),n=r===this.draco.TRIANGULAR_MESH?new this.draco.Mesh:new this.draco.PointCloud;try{let e;switch(r){case this.draco.TRIANGULAR_MESH:e=this.decoder.DecodeBufferToMesh(i,n);break;case this.draco.POINT_CLOUD:e=this.decoder.DecodeBufferToPointCloud(i,n);break;default:throw new Error("DRACO: Unknown geometry type.")}if(!e.ok()||!n.ptr){const t=`DRACO decompression failed: ${e.error_msg()}`;throw new Error(t)}const o=this._getDracoLoaderData(n,r,t),s=this._getMeshData(n,o,t),a=Pd(s.attributes),l=function(e,t,i){const r=Mk(t.metadata),n=[],o=function(e){const t={};for(const i in e){const r=e[i];t[r.name||"undefined"]=r}return t}(t.attributes);for(const t in e){const i=Ik(t,e[t],o[t]);n.push(i)}if(i){const e=Ik("indices",i);n.push(e)}return{fields:n,metadata:r}}(s.attributes,o,s.indices);return{loader:"draco",loaderData:o,header:{vertexCount:n.num_points(),boundingBox:a},...s,schema:l}}finally{this.draco.destroy(i),n&&this.draco.destroy(n)}}_getDracoLoaderData(e,t,i){const r=this._getTopLevelMetadata(e),n=this._getDracoAttributes(e,i);return{geometry_type:t,num_attributes:e.num_attributes(),num_points:e.num_points(),num_faces:e instanceof this.draco.Mesh?e.num_faces():0,metadata:r,attributes:n}}_getDracoAttributes(e,t){const i={};for(let r=0;rthis.decoder[e]).includes(r);if(n){const t=new this.draco.AttributeQuantizationTransform;try{if(t.InitFromAttribute(e))return{quantization_bits:t.quantization_bits(),range:t.range(),min_values:new Float32Array([1,2,3]).map(e=>t.min_value(e))}}finally{this.draco.destroy(t)}}return null}_getOctahedronTransform(e,t){const{octahedronAttributes:i=[]}=t,r=e.attribute_type(),n=i.map(e=>this.decoder[e]).includes(r);if(n){const t=new this.draco.AttributeQuantizationTransform;try{if(t.InitFromAttribute(e))return{quantization_bits:t.quantization_bits()}}finally{this.draco.destroy(t)}}return null}}const Fk=(globalThis._loadersgl_?.version||(globalThis._loadersgl_=globalThis._loadersgl_||{},globalThis._loadersgl_.version="4.3.3"),globalThis._loadersgl_.version);const kk="object"!=typeof process||"[object process]"!==String(process)||process.browser,Dk="function"==typeof importScripts,Ok="undefined"!=typeof process&&process.version&&/v([0-9]*)/.exec(process.version);Ok&&parseFloat(Ok[1]);const zk={};async function Uk(e,t=null,i={},r=null){return t&&(e=function(e,t,i={},r=null){if(!i.useLocalLibraries&&e.startsWith("http"))return e;r=r||e;const n=i.modules||{};if(n[r])return n[r];if(!kk)return`modules/${t}/dist/libs/${r}`;if(i.CDN)return function(e,t){if(!e)throw new Error(t||"loaders.gl assertion failed.")}(i.CDN.startsWith("http")),`${i.CDN}/${t}@${Fk}/dist/libs/${r}`;if(Dk)return`../src/libs/${r}`;return`modules/${t}/src/libs/${r}`}(e,t,i,r)),zk[e]=zk[e]||async function(e){if(e.endsWith("wasm"))return await async function(e){const{readFileAsArrayBuffer:t}=globalThis.loaders||{};if(kk||!t||e.startsWith("http")){const t=await fetch(e);return await t.arrayBuffer()}return await t(e)}(e);if(!kk)try{const{requireFromFile:t}=globalThis.loaders||{};return await(t?.(e))}catch(e){return console.error(e),null}if(Dk)return importScripts(e);const t=await async function(e){const{readFileAsText:t}=globalThis.loaders||{};if(kk||!t||e.startsWith("http")){const t=await fetch(e);return await t.text()}return await t(e)}(e);return function(e,t){if(!kk){const{requireFromString:i}=globalThis.loaders||{};return i?.(e,t)}if(Dk)return eval.call(globalThis,e),null;const i=document.createElement("script");i.id=t;try{i.appendChild(document.createTextNode(e))}catch(t){i.text=e}return document.body.appendChild(i),null}(t,e)}(e),await zk[e]}const Nk="https://www.gstatic.com/draco/versioned/decoders/1.5.6",Vk="draco_wasm_wrapper.js",jk="draco_decoder.wasm",Gk="draco_decoder.js",Hk="draco_encoder.js",Qk={[Vk]:`${Nk}/${Vk}`,[jk]:`${Nk}/${jk}`,[Gk]:`${Nk}/${Gk}`,[Hk]:`https://raw.githubusercontent.com/google/draco/1.4.1/javascript/${Hk}`};let $k;async function Zk(e){const t=e.modules||{};return t.draco3d?$k||=t.draco3d.createDecoderModule({}).then(e=>({draco:e})):$k||=async function(e){let t,i;if("js"===(e.draco&&e.draco.decoderType))t=await Uk(Qk[Gk],"draco",e,Gk);else[t,i]=await Promise.all([await Uk(Qk[Vk],"draco",e,Vk),await Uk(Qk[jk],"draco",e,jk)]);return t=t||globalThis.DracoDecoderModule,await function(e,t){const i={};t&&(i.wasmBinary=t);return new Promise(t=>{e({...i,onModuleLoaded:e=>t({draco:e})})})}(t,i)}(e),await $k}const Wk={...Sk,parse:async function(e,t){const{draco:i}=await Zk(t),r=new Lk(i);try{return r.parseSync(e,t?.draco)}finally{r.destroy()}}};const qk={BYTE:5120,UNSIGNED_BYTE:5121,SHORT:5122,UNSIGNED_SHORT:5123,INT:5124,UNSIGNED_INT:5125,FLOAT:5126,DOUBLE:5130},Kk={POINTS:0,LINES:1,LINE_LOOP:2,LINE_STRIP:3,TRIANGLES:4,TRIANGLE_STRIP:5,TRIANGLE_FAN:6,...qk},Xk={[qk.DOUBLE]:Float64Array,[qk.FLOAT]:Float32Array,[qk.UNSIGNED_SHORT]:Uint16Array,[qk.UNSIGNED_INT]:Uint32Array,[qk.UNSIGNED_BYTE]:Uint8Array,[qk.BYTE]:Int8Array,[qk.SHORT]:Int16Array,[qk.INT]:Int32Array},Jk={DOUBLE:qk.DOUBLE,FLOAT:qk.FLOAT,UNSIGNED_SHORT:qk.UNSIGNED_SHORT,UNSIGNED_INT:qk.UNSIGNED_INT,UNSIGNED_BYTE:qk.UNSIGNED_BYTE,BYTE:qk.BYTE,SHORT:qk.SHORT,INT:qk.INT},Yk="Failed to convert GL type";class eD{static fromTypedArray(e){e=ArrayBuffer.isView(e)?e.constructor:e;for(const t in Xk){if(Xk[t]===e)return t}throw new Error(Yk)}static fromName(e){const t=Jk[e];if(!t)throw new Error(Yk);return t}static getArrayType(e){switch(e){case qk.UNSIGNED_SHORT_5_6_5:case qk.UNSIGNED_SHORT_4_4_4_4:case qk.UNSIGNED_SHORT_5_5_5_1:return Uint16Array;default:const t=Xk[e];if(!t)throw new Error(Yk);return t}}static getByteSize(e){return eD.getArrayType(e).BYTES_PER_ELEMENT}static validate(e){return Boolean(eD.getArrayType(e))}static createTypedArray(e,t,i=0,r){void 0===r&&(r=(t.byteLength-i)/eD.getByteSize(e));return new(eD.getArrayType(e))(t,i,r)}}function tD(e,t=[0,0,0]){const i=e>>11&31,r=e>>5&63,n=31&e;return t[0]=i<<3,t[1]=r<<2,t[2]=n<<3,t}function iD(e,t=255){return O_(e,0,t)/t*2-1}function rD(e){return e<0?-1:1}function nD(e,t,i,r){if(function(e,t){if(!e)throw new Error(`math.gl assertion failed. ${t}`)}(r),e<0||e>i||t<0||t>i)throw new Error(`x and y must be unsigned normalized integers between 0 and ${i}`);if(r.x=iD(e,i),r.y=iD(t,i),r.z=1-(Math.abs(r.x)+Math.abs(r.y)),r.z<0){const e=r.x;r.x=(1-Math.abs(r.y))*rD(e),r.y=(1-Math.abs(e))*rD(r.y)}return r.normalize()}function oD(e,t,i){return nD(e,t,255,i)}new tA,new mA,new tA,new tA;class sD{json;buffer;featuresLength=0;_cachedTypedArrays={};constructor(e,t){this.json=e,this.buffer=t}getExtension(e){return this.json.extensions&&this.json.extensions[e]}hasProperty(e){return Boolean(this.json[e])}getGlobalProperty(e,t=Kk.UNSIGNED_INT,i=1){const r=this.json[e];return r&&Number.isFinite(r.byteOffset)?this._getTypedArrayFromBinary(e,t,i,1,r.byteOffset):r}getPropertyArray(e,t,i){const r=this.json[e];return r&&Number.isFinite(r.byteOffset)?("componentType"in r&&(t=eD.fromName(r.componentType)),this._getTypedArrayFromBinary(e,t,i,this.featuresLength,r.byteOffset)):this._getTypedArrayFromArray(e,t,r)}getProperty(e,t,i,r,n){const o=this.json[e];if(!o)return o;const s=this.getPropertyArray(e,t,i);if(1===i)return s[r];for(let e=0;ee[t],VEC2:(e,t)=>[e[2*t+0],e[2*t+1]],VEC3:(e,t)=>[e[3*t+0],e[3*t+1],e[3*t+2]],VEC4:(e,t)=>[e[4*t+0],e[4*t+1],e[4*t+2],e[4*t+3]],MAT2:(e,t)=>[e[4*t+0],e[4*t+1],e[4*t+2],e[4*t+3]],MAT3:(e,t)=>[e[9*t+0],e[9*t+1],e[9*t+2],e[9*t+3],e[9*t+4],e[9*t+5],e[9*t+6],e[9*t+7],e[9*t+8]],MAT4:(e,t)=>[e[16*t+0],e[16*t+1],e[16*t+2],e[16*t+3],e[16*t+4],e[16*t+5],e[16*t+6],e[16*t+7],e[16*t+8],e[16*t+9],e[16*t+10],e[16*t+11],e[16*t+12],e[16*t+13],e[16*t+14],e[16*t+15]]},cD={SCALAR:(e,t,i)=>{t[i]=e},VEC2:(e,t,i)=>{t[2*i+0]=e[0],t[2*i+1]=e[1]},VEC3:(e,t,i)=>{t[3*i+0]=e[0],t[3*i+1]=e[1],t[3*i+2]=e[2]},VEC4:(e,t,i)=>{t[4*i+0]=e[0],t[4*i+1]=e[1],t[4*i+2]=e[2],t[4*i+3]=e[3]},MAT2:(e,t,i)=>{t[4*i+0]=e[0],t[4*i+1]=e[1],t[4*i+2]=e[2],t[4*i+3]=e[3]},MAT3:(e,t,i)=>{t[9*i+0]=e[0],t[9*i+1]=e[1],t[9*i+2]=e[2],t[9*i+3]=e[3],t[9*i+4]=e[4],t[9*i+5]=e[5],t[9*i+6]=e[6],t[9*i+7]=e[7],t[9*i+8]=e[8],t[9*i+9]=e[9]},MAT4:(e,t,i)=>{t[16*i+0]=e[0],t[16*i+1]=e[1],t[16*i+2]=e[2],t[16*i+3]=e[3],t[16*i+4]=e[4],t[16*i+5]=e[5],t[16*i+6]=e[6],t[16*i+7]=e[7],t[16*i+8]=e[8],t[16*i+9]=e[9],t[16*i+10]=e[10],t[16*i+11]=e[11],t[16*i+12]=e[12],t[16*i+13]=e[13],t[16*i+14]=e[14],t[16*i+15]=e[15]}};const uD=e=>void 0!==e;function hD(e,t,i){if(!t)return null;let r=e.getExtension("3DTILES_batch_table_hierarchy");const n=t.HIERARCHY;return n&&(console.warn("3D Tile Parser: HIERARCHY is deprecated. Use 3DTILES_batch_table_hierarchy."),t.extensions=t.extensions||{},t.extensions["3DTILES_batch_table_hierarchy"]=n,r=n),r?function(e,t){let i,r,n;const o=e.instancesLength,s=e.classes;let a,l=e.classIds,c=e.parentCounts,u=e.parentIds,h=o;uD(l.byteOffset)&&(l.componentType=defaultValue(l.componentType,GL.UNSIGNED_SHORT),l.type=AttributeType.SCALAR,n=getBinaryAccessor(l),l=n.createArrayBufferView(t.buffer,t.byteOffset+l.byteOffset,o));if(uD(c))for(uD(c.byteOffset)&&(c.componentType=defaultValue(c.componentType,GL.UNSIGNED_SHORT),c.type=AttributeType.SCALAR,n=getBinaryAccessor(c),c=n.createArrayBufferView(t.buffer,t.byteOffset+c.byteOffset,o)),a=new Uint16Array(o),h=0,i=0;i0?function(e,t,i){const r=e.classIds,n=e.parentCounts,o=e.parentIds,s=e.parentIndexes,a=r.length,l=scratchVisited;l.length=Math.max(l.length,a);const c=++marker,u=scratchStack;u.length=0,u.push(t);for(;u.length>0;){if(l[t=u.pop()]===c)continue;l[t]=c;const r=i(e,t);if(uD(r))return r;const a=n[t],h=s[t];for(let e=0;ee,gD={HIERARCHY:!0,extensions:!0,extras:!0};class _D{json;binary;featureCount;_extensions;_properties;_binaryProperties;_hierarchy;constructor(e,t,i,r={}){Tu(i>=0),this.json=e||{},this.binary=t,this.featureCount=i,this._extensions=this.json?.extensions||{},this._properties={};for(const e in this.json)gD[e]||(this._properties[e]=this.json[e]);this._binaryProperties=this._initializeBinaryProperties(),r["3DTILES_batch_table_hierarchy"]&&(this._hierarchy=hD(this,this.json,this.binary))}getExtension(e){return this.json&&this.json.extensions&&this.json.extensions[e]}memorySizeInBytes(){return 0}isClass(e,t){if(this._checkBatchId(e),Tu("string"==typeof t,t),this._hierarchy){return fD(dD(this._hierarchy,e,(e,i)=>{const r=e.classIds[i];return e.classes[r].name===t}))}return!1}isExactClass(e,t){return Tu("string"==typeof t,t),this.getExactClassName(e)===t}getExactClassName(e){if(this._checkBatchId(e),this._hierarchy){const t=this._hierarchy.classIds[e];return this._hierarchy.classes[t].name}}hasProperty(e,t){return this._checkBatchId(e),Tu("string"==typeof t,t),fD(this._properties[t])||this._hasPropertyInHierarchy(e,t)}getPropertyNames(e,t){this._checkBatchId(e),(t=fD(t)?t:[]).length=0;const i=Object.keys(this._properties);return t.push(...i),this._hierarchy&&this._getPropertyNamesInHierarchy(e,t),t}getProperty(e,t){if(this._checkBatchId(e),Tu("string"==typeof t,t),this._binaryProperties){const i=this._binaryProperties[t];if(fD(i))return this._getBinaryProperty(i,e)}const i=this._properties[t];if(fD(i))return mD(i[e]);if(this._hierarchy){const i=this._getHierarchyProperty(e,t);if(fD(i))return i}}setProperty(e,t,i){const r=this.featureCount;if(this._checkBatchId(e),Tu("string"==typeof t,t),this._binaryProperties){const r=this._binaryProperties[t];if(r)return void this._setBinaryProperty(r,e,i)}if(this._hierarchy&&this._setHierarchyProperty(this,e,t,i))return;let n=this._properties[t];fD(n)||(this._properties[t]=new Array(r),n=this._properties[t]),n[e]=mD(i)}_checkBatchId(e){if(!(e>=0&&e{const r=e.classIds[i];return fD(e.classes[r].instances[t])});return fD(i)}_getPropertyNamesInHierarchy(e,t){dD(this._hierarchy,e,(e,i)=>{const r=e.classIds[i],n=e.classes[r].instances;for(const e in n)n.hasOwnProperty(e)&&-1===t.indexOf(e)&&t.push(e)})}_getHierarchyProperty(e,t){return dD(this._hierarchy,e,(e,i)=>{const r=e.classIds[i],n=e.classes[r],o=e.classIndexes[i],s=n.instances[t];return fD(s)?fD(s.typedArray)?this._getBinaryProperty(s,o):mD(s[o]):null})}_setHierarchyProperty(e,t,i,r){const n=dD(this._hierarchy,t,(e,n)=>{const o=e.classIds[n],s=e.classes[o],a=e.classIndexes[n],l=s.instances[i];return!!fD(l)&&(Tu(n===t,`Inherited property "${i}" is read-only.`),fD(l.typedArray)?this._setBinaryProperty(l,a,r):l[a]=mD(r),!0)});return fD(n)}}function AD(e,t,i=0){const r=new DataView(t);if(e.magic=r.getUint32(i,!0),i+=4,e.version=r.getUint32(i,!0),i+=4,e.byteLength=r.getUint32(i,!0),i+=4,1!==e.version)throw new Error(`3D Tile Version ${e.version} not supported`);return i}const yD="b3dm tile in legacy format.";function vD(e,t,i){const r=new DataView(t);let n;e.header=e.header||{};let o=r.getUint32(i,!0);i+=4;let s=r.getUint32(i,!0);i+=4;let a=r.getUint32(i,!0);i+=4;let l=r.getUint32(i,!0);return i+=4,a>=570425344?(i-=8,n=o,a=s,l=0,o=0,s=0,console.warn(yD)):l>=570425344&&(i-=4,n=a,a=o,l=s,o=0,s=0,console.warn(yD)),e.header.featureTableJsonByteLength=o,e.header.featureTableBinaryByteLength=s,e.header.batchTableJsonByteLength=a,e.header.batchTableBinaryByteLength=l,e.header.batchLength=n,i}function xD(e,t,i,r){return i=function(e,t,i){const{featureTableJsonByteLength:r,featureTableBinaryByteLength:n,batchLength:o}=e.header||{};if(e.featureTableJson={BATCH_LENGTH:o||0},r&&r>0){const n=Ck(t,i,r);e.featureTableJson=JSON.parse(n)}return i+=r||0,e.featureTableBinary=new Uint8Array(t,i,n),i+=n||0,i}(e,t,i),i=function(e,t,i){const{batchTableJsonByteLength:r,batchTableBinaryByteLength:n}=e.header||{};if(r&&r>0){const o=Ck(t,i,r);e.batchTableJson=JSON.parse(o),i+=r,n&&n>0&&(e.batchTableBinary=new Uint8Array(t,i,n),e.batchTableBinary=new Uint8Array(e.batchTableBinary),i+=n)}return i}(e,t,i),i}function bD(e,t,i){if(!(t||e&&e.batchIds&&i))return null;const{batchIds:r,isRGB565:n,pointCount:o=0}=e;if(r&&i){const e=new Uint8ClampedArray(3*o);for(let t=0;t255*e);e[3*t]=o[0],e[3*t+1]=o[1],e[3*t+2]=o[2]}return{type:Kk.UNSIGNED_BYTE,value:e,size:3,normalized:!0}}if(t&&n){const e=new Uint8ClampedArray(3*o);for(let i=0;i12;){const s={shape:"tile3d"};e.tiles.push(s),i=await o(t,i,r,n,s)}return i}(n,e,t,i,r,RD);case wk:return await MD(n,e,t,i,r);case Ek:return await async function(e,t,i,r){if(e.rotateYtoZ=!0,e.gltfUpAxis=i?.["3d-tiles"]?.assetGltfUpAxis?i["3d-tiles"].assetGltfUpAxis:"Y",i?.["3d-tiles"]?.loadGLTF){if(!r)return t.byteLength;const n=await wu(t,fL,i,r);e.gltf=BL(n),e.gpuMemoryUsageInBytes=JM(e.gltf)}else e.gltfArrayBuffer=t;return t.byteLength}(n,e,i,r);case Tk:return await PD(n,e,t,i,r);case bk:return await ED(n,e,t,i,r);default:throw new Error(`3DTileLoader: unknown type ${n.type}`)}}async function LD(e,t,i,r){const n=Number.isFinite(t.bitstream)?t.bitstream:t.bufferView;if("number"!=typeof n)return;const o=e.bufferViews[n],s=e.buffers[o.buffer];if(!r?.baseUrl)throw new Error("Url is not provided");if(!r.fetch)throw new Error("fetch is not provided");if(s.uri){const e=`${r?.baseUrl||""}/${s.uri}`,i=await r.fetch(e),n=await i.arrayBuffer();return void(t.explicitBitstream=new Uint8Array(n,o.byteOffset,o.byteLength))}const a=e.buffers.slice(0,o.buffer).reduce((e,t)=>e+t.byteLength,0);t.explicitBitstream=new Uint8Array(i.slice(a,a+s.byteLength),o.byteOffset,o.byteLength)}function FD(e){const t=new DataView(e);return t.getUint32(0,!0)+2**32*t.getUint32(4,!0)}const kD={dataType:null,batchType:null,id:"3d-tiles-subtree",name:"3D Tiles Subtree",module:"3d-tiles",version:vk,extensions:["subtree"],mimeTypes:["application/octet-stream"],tests:["subtree"],parse:async function(e,t,i){if(1952609651!==new Uint32Array(e.slice(0,4))[0])throw new Error("Wrong subtree file magic number");if(1!==new Uint32Array(e.slice(4,8))[0])throw new Error("Wrong subtree file verson, must be 1");const r=FD(e.slice(8,16)),n=new Uint8Array(e,24,r),o=new TextDecoder("utf8").decode(n),s=JSON.parse(o),a=FD(e.slice(16,24));let l=new ArrayBuffer(0);if(a&&(l=e.slice(24+r)),await LD(s,s.tileAvailability,l,i),Array.isArray(s.contentAvailability))for(const e of s.contentAvailability)await LD(s,e,l,i);else await LD(s,s.contentAvailability,l,i);return await LD(s,s.childSubtreeAvailability,l,i),s},options:{}}; + * Licensed under the MIT license */sE=aE,function(e,t,i,n){var r,o=["","webkit","Moz","MS","ms","o"],s=t.createElement("div"),a=Math.round,l=Math.abs,c=Date.now;function u(e,t,i){return setTimeout(_(e,i),t)}function h(e,t,i){return!!Array.isArray(e)&&(d(e,i[t],i),!0)}function d(e,t,i){var r;if(e)if(e.forEach)e.forEach(t,i);else if(e.length!==n)for(r=0;r\s*\(/gm,"{anonymous}()@"):"Unknown Stack Trace",o=e.console&&(e.console.warn||e.console.log);return o&&o.call(e.console,r,n),t.apply(this,arguments)}}r="function"!=typeof Object.assign?function(e){if(e===n||null===e)throw new TypeError("Cannot convert undefined or null to object");for(var t=Object(e),i=1;i-1}function T(e){return e.trim().split(/\s+/g)}function E(e,t,i){if(e.indexOf&&!i)return e.indexOf(t);for(var n=0;ni[t]}):n.sort()),n}function B(e,t){for(var i,r,s=t[0].toUpperCase()+t.slice(1),a=0;a1&&!i.firstMultiple?i.firstMultiple=V(t):1===o&&(i.firstMultiple=!1);var s=i.firstInput,a=i.firstMultiple,u=a?a.center:s.center,h=t.center=j(r);t.timeStamp=c(),t.deltaTime=t.timeStamp-s.timeStamp,t.angle=$(u,h),t.distance=Q(u,h),function(e,t){var i=t.center,n=e.offsetDelta||{},r=e.prevDelta||{},o=e.prevInput||{};1!==t.eventType&&4!==o.eventType||(r=e.prevDelta={x:o.deltaX||0,y:o.deltaY||0},n=e.offsetDelta={x:i.x,y:i.y}),t.deltaX=r.x+(i.x-n.x),t.deltaY=r.y+(i.y-n.y)}(i,t),t.offsetDirection=H(t.deltaX,t.deltaY);var d,p,f=G(t.deltaTime,t.deltaX,t.deltaY);t.overallVelocityX=f.x,t.overallVelocityY=f.y,t.overallVelocity=l(f.x)>l(f.y)?f.x:f.y,t.scale=a?(d=a.pointers,Q((p=r)[0],p[1],z)/Q(d[0],d[1],z)):1,t.rotation=a?function(e,t){return $(t[1],t[0],z)+$(e[1],e[0],z)}(a.pointers,r):0,t.maxPointers=i.prevInput?t.pointers.length>i.prevInput.maxPointers?t.pointers.length:i.prevInput.maxPointers:t.pointers.length,function(e,t){var i,r,o,s,a=e.lastInterval||t,c=t.timeStamp-a.timeStamp;if(8!=t.eventType&&(c>25||a.velocity===n)){var u=t.deltaX-a.deltaX,h=t.deltaY-a.deltaY,d=G(c,u,h);r=d.x,o=d.y,i=l(d.x)>l(d.y)?d.x:d.y,s=H(u,h),e.lastInterval=t}else i=a.velocity,r=a.velocityX,o=a.velocityY,s=a.direction;t.velocity=i,t.velocityX=r,t.velocityY=o,t.direction=s}(i,t);var m=e.element;b(t.srcEvent.target,m)&&(m=t.srcEvent.target),t.target=m}(e,i),e.emit("hammer.input",i),e.recognize(i),e.session.prevInput=i}function V(e){for(var t=[],i=0;i=l(t)?e<0?2:4:t<0?8:16}function Q(e,t,i){i||(i=O);var n=t[i[0]]-e[i[0]],r=t[i[1]]-e[i[1]];return Math.sqrt(n*n+r*r)}function $(e,t,i){i||(i=O);var n=t[i[0]]-e[i[0]],r=t[i[1]]-e[i[1]];return 180*Math.atan2(r,n)/Math.PI}U.prototype={handler:function(){},init:function(){this.evEl&&v(this.element,this.evEl,this.domHandler),this.evTarget&&v(this.target,this.evTarget,this.domHandler),this.evWin&&v(M(this.element),this.evWin,this.domHandler)},destroy:function(){this.evEl&&x(this.element,this.evEl,this.domHandler),this.evTarget&&x(this.target,this.evTarget,this.domHandler),this.evWin&&x(M(this.element),this.evWin,this.domHandler)}};var Z={mousedown:1,mousemove:2,mouseup:4},W="mousedown",q="mousemove mouseup";function K(){this.evEl=W,this.evWin=q,this.pressed=!1,U.apply(this,arguments)}g(K,U,{handler:function(e){var t=Z[e.type];1&t&&0===e.button&&(this.pressed=!0),2&t&&1!==e.which&&(t=4),this.pressed&&(4&t&&(this.pressed=!1),this.callback(this.manager,t,{pointers:[e],changedPointers:[e],pointerType:k,srcEvent:e}))}});var X={pointerdown:1,pointermove:2,pointerup:4,pointercancel:8,pointerout:8},J={2:F,3:"pen",4:k,5:"kinect"},Y="pointerdown",ee="pointermove pointerup pointercancel";function te(){this.evEl=Y,this.evWin=ee,U.apply(this,arguments),this.store=this.manager.session.pointerEvents=[]}e.MSPointerEvent&&!e.PointerEvent&&(Y="MSPointerDown",ee="MSPointerMove MSPointerUp MSPointerCancel"),g(te,U,{handler:function(e){var t=this.store,i=!1,n=e.type.toLowerCase().replace("ms",""),r=X[n],o=J[e.pointerType]||e.pointerType,s=o==F,a=E(t,e.pointerId,"pointerId");1&r&&(0===e.button||s)?a<0&&(t.push(e),a=t.length-1):12&r&&(i=!0),a<0||(t[a]=e,this.callback(this.manager,r,{pointers:t,changedPointers:[e],pointerType:o,srcEvent:e}),i&&t.splice(a,1))}});var ie={touchstart:1,touchmove:2,touchend:4,touchcancel:8};function ne(){this.evTarget="touchstart",this.evWin="touchstart touchmove touchend touchcancel",this.started=!1,U.apply(this,arguments)}function re(e,t){var i=C(e.touches),n=C(e.changedTouches);return 12&t&&(i=S(i.concat(n),"identifier",!0)),[i,n]}g(ne,U,{handler:function(e){var t=ie[e.type];if(1===t&&(this.started=!0),this.started){var i=re.call(this,e,t);12&t&&i[0].length-i[1].length===0&&(this.started=!1),this.callback(this.manager,t,{pointers:i[0],changedPointers:i[1],pointerType:F,srcEvent:e})}}});var oe={touchstart:1,touchmove:2,touchend:4,touchcancel:8},se="touchstart touchmove touchend touchcancel";function ae(){this.evTarget=se,this.targetIds={},U.apply(this,arguments)}function le(e,t){var i=C(e.touches),n=this.targetIds;if(3&t&&1===i.length)return n[i[0].identifier]=!0,[i,i];var r,o,s=C(e.changedTouches),a=[],l=this.target;if(o=i.filter(function(e){return b(e.target,l)}),1===t)for(r=0;r-1&&n.splice(e,1)},2500)}}function de(e){for(var t=e.srcEvent.clientX,i=e.srcEvent.clientY,n=0;n-1&&this.requireFail.splice(t,1),this},hasRequireFailures:function(){return this.requireFail.length>0},canRecognizeWith:function(e){return!!this.simultaneous[e.id]},emit:function(e){var t=this,i=this.state;function n(i){t.manager.emit(i,e)}i<8&&n(t.options.event+Ee(i)),n(t.options.event),e.additionalEvent&&n(e.additionalEvent),i>=8&&n(t.options.event+Ee(i))},tryEmit:function(e){if(this.canEmit())return this.emit(e);this.state=we},canEmit:function(){for(var e=0;et.threshold&&r&t.direction},attrTest:function(e){return Be.prototype.attrTest.call(this,e)&&(2&this.state||!(2&this.state)&&this.directionTest(e))},emit:function(e){this.pX=e.deltaX,this.pY=e.deltaY;var t=Ce(e.direction);t&&(e.additionalEvent=this.options.event+t),this._super.emit.call(this,e)}}),g(Me,Be,{defaults:{event:"pinch",threshold:0,pointers:2},getTouchAction:function(){return[Ae]},attrTest:function(e){return this._super.attrTest.call(this,e)&&(Math.abs(e.scale-1)>this.options.threshold||2&this.state)},emit:function(e){if(1!==e.scale){var t=e.scale<1?"in":"out";e.additionalEvent=this.options.event+t}this._super.emit.call(this,e)}}),g(Pe,Te,{defaults:{event:"press",pointers:1,time:251,threshold:9},getTouchAction:function(){return[ge]},process:function(e){var t=this.options,i=e.pointers.length===t.pointers,n=e.distancet.time;if(this._input=e,!n||!i||12&e.eventType&&!r)this.reset();else if(1&e.eventType)this.reset(),this._timer=u(function(){this.state=8,this.tryEmit()},t.time,this);else if(4&e.eventType)return 8;return we},reset:function(){clearTimeout(this._timer)},emit:function(e){8===this.state&&(e&&4&e.eventType?this.manager.emit(this.options.event+"up",e):(this._input.timeStamp=c(),this.manager.emit(this.options.event,this._input)))}}),g(Re,Be,{defaults:{event:"rotate",threshold:0,pointers:2},getTouchAction:function(){return[Ae]},attrTest:function(e){return this._super.attrTest.call(this,e)&&(Math.abs(e.rotation)>this.options.threshold||2&this.state)}}),g(Le,Be,{defaults:{event:"swipe",threshold:10,velocity:.3,direction:30,pointers:1},getTouchAction:function(){return Ie.prototype.getTouchAction.call(this)},attrTest:function(e){var t,i=this.options.direction;return 30&i?t=e.overallVelocity:6&i?t=e.overallVelocityX:i&D&&(t=e.overallVelocityY),this._super.attrTest.call(this,e)&&i&e.offsetDirection&&e.distance>this.options.threshold&&e.maxPointers==this.options.pointers&&l(t)>this.options.velocity&&4&e.eventType},emit:function(e){var t=Ce(e.offsetDirection);t&&this.manager.emit(this.options.event+t,e),this.manager.emit(this.options.event,e)}}),g(Fe,Te,{defaults:{event:"tap",pointers:1,taps:1,interval:300,time:250,threshold:9,posThreshold:10},getTouchAction:function(){return[_e]},process:function(e){var t=this.options,i=e.pointers.length===t.pointers,n=e.distance0&&"pointerdown"===e.type&&(function(e,t){for(let i=0;it.pointerId===e.pointerId)||i.push(e)),t.call(this,e)}}(aE.exports.PointerEventInput),aE.exports.MouseInput.prototype.handler=function(e){let t=cE[e.type];1&t&&e.button>=0&&(this.pressed=!0),2&t&&0===e.buttons&&(t=4),this.pressed&&(4&t&&(this.pressed=!1),this.callback(this.manager,t,{pointers:[e],changedPointers:[e],pointerType:"mouse",srcEvent:e}))};const uE=aE.exports.Manager;class hE{constructor(e,t,i){this.element=e,this.callback=t,this.options={enable:!0,...i}}}const dE=lE?[[lE.Pan,{event:"tripan",pointers:3,threshold:0,enable:!1}],[lE.Rotate,{enable:!1}],[lE.Pinch,{enable:!1}],[lE.Swipe,{enable:!1}],[lE.Pan,{threshold:0,enable:!1}],[lE.Press,{enable:!1}],[lE.Tap,{event:"doubletap",taps:2,enable:!1}],[lE.Tap,{event:"anytap",enable:!1}],[lE.Tap,{enable:!1}]]:null,pE={tripan:["rotate","pinch","pan"],rotate:["pinch"],pinch:["pan"],pan:["press","doubletap","anytap","tap"],doubletap:["anytap"],anytap:["tap"]},fE={doubletap:["tap"]},mE={pointerdown:"pointerdown",pointermove:"pointermove",pointerup:"pointerup",touchstart:"pointerdown",touchmove:"pointermove",touchend:"pointerup",mousedown:"pointerdown",mousemove:"pointermove",mouseup:"pointerup"},gE={KEY_EVENTS:["keydown","keyup"],MOUSE_EVENTS:["mousedown","mousemove","mouseup","mouseover","mouseout","mouseleave"],WHEEL_EVENTS:["wheel","mousewheel"]},_E={tap:"tap",anytap:"anytap",doubletap:"doubletap",press:"press",pinch:"pinch",pinchin:"pinch",pinchout:"pinch",pinchstart:"pinch",pinchmove:"pinch",pinchend:"pinch",pinchcancel:"pinch",rotate:"rotate",rotatestart:"rotate",rotatemove:"rotate",rotateend:"rotate",rotatecancel:"rotate",tripan:"tripan",tripanstart:"tripan",tripanmove:"tripan",tripanup:"tripan",tripandown:"tripan",tripanleft:"tripan",tripanright:"tripan",tripanend:"tripan",tripancancel:"tripan",pan:"pan",panstart:"pan",panmove:"pan",panup:"pan",pandown:"pan",panleft:"pan",panright:"pan",panend:"pan",pancancel:"pan",swipe:"swipe",swipeleft:"swipe",swiperight:"swipe",swipeup:"swipe",swipedown:"swipe"},AE={click:"tap",anyclick:"anytap",dblclick:"doubletap",mousedown:"pointerdown",mousemove:"pointermove",mouseup:"pointerup",mouseover:"pointerover",mouseout:"pointerout",mouseleave:"pointerleave"},yE="undefined"!=typeof navigator&&navigator.userAgent?navigator.userAgent.toLowerCase():"",vE="undefined"!=typeof window?window:global;let xE=!1;try{const e={get passive(){return xE=!0,!0}};vE.addEventListener("test",null,e),vE.removeEventListener("test",null)}catch(e){xE=!1}const bE=-1!==yE.indexOf("firefox"),{WHEEL_EVENTS:wE}=gE,TE="wheel",EE=4.000244140625;class CE extends hE{constructor(e,t,i){super(e,t,i),this.handleEvent=e=>{if(!this.options.enable)return;let t=e.deltaY;vE.WheelEvent&&(bE&&e.deltaMode===vE.WheelEvent.DOM_DELTA_PIXEL&&(t/=vE.devicePixelRatio),e.deltaMode===vE.WheelEvent.DOM_DELTA_LINE&&(t*=40)),0!==t&&t%EE===0&&(t=Math.floor(t/EE)),e.shiftKey&&t&&(t*=.25),this.callback({type:TE,center:{x:e.clientX,y:e.clientY},delta:-t,srcEvent:e,pointerType:"mouse",target:e.target})},this.events=(this.options.events||[]).concat(wE),this.events.forEach(t=>e.addEventListener(t,this.handleEvent,!!xE&&{passive:!1}))}destroy(){this.events.forEach(e=>this.element.removeEventListener(e,this.handleEvent))}enableEventType(e,t){e===TE&&(this.options.enable=t)}}const{MOUSE_EVENTS:SE}=gE,BE="pointermove",IE="pointerover",ME="pointerout",PE="pointerenter",RE="pointerleave";class LE extends hE{constructor(e,t,i){super(e,t,i),this.handleEvent=e=>{this.handleOverEvent(e),this.handleOutEvent(e),this.handleEnterEvent(e),this.handleLeaveEvent(e),this.handleMoveEvent(e)},this.pressed=!1;const{enable:n}=this.options;this.enableMoveEvent=n,this.enableLeaveEvent=n,this.enableEnterEvent=n,this.enableOutEvent=n,this.enableOverEvent=n,this.events=(this.options.events||[]).concat(SE),this.events.forEach(t=>e.addEventListener(t,this.handleEvent))}destroy(){this.events.forEach(e=>this.element.removeEventListener(e,this.handleEvent))}enableEventType(e,t){e===BE&&(this.enableMoveEvent=t),e===IE&&(this.enableOverEvent=t),e===ME&&(this.enableOutEvent=t),e===PE&&(this.enableEnterEvent=t),e===RE&&(this.enableLeaveEvent=t)}handleOverEvent(e){this.enableOverEvent&&"mouseover"===e.type&&this._emit(IE,e)}handleOutEvent(e){this.enableOutEvent&&"mouseout"===e.type&&this._emit(ME,e)}handleEnterEvent(e){this.enableEnterEvent&&"mouseenter"===e.type&&this._emit(PE,e)}handleLeaveEvent(e){this.enableLeaveEvent&&"mouseleave"===e.type&&this._emit(RE,e)}handleMoveEvent(e){if(this.enableMoveEvent)switch(e.type){case"mousedown":e.button>=0&&(this.pressed=!0);break;case"mousemove":0===e.buttons&&(this.pressed=!1),this.pressed||this._emit(BE,e);break;case"mouseup":this.pressed=!1}}_emit(e,t){this.callback({type:e,center:{x:t.clientX,y:t.clientY},srcEvent:t,pointerType:"mouse",target:t.target})}}const{KEY_EVENTS:FE}=gE,kE="keydown",DE="keyup";class OE extends hE{constructor(e,t,i){super(e,t,i),this.handleEvent=e=>{const t=e.target||e.srcElement;"INPUT"===t.tagName&&"text"===t.type||"TEXTAREA"===t.tagName||(this.enableDownEvent&&"keydown"===e.type&&this.callback({type:kE,srcEvent:e,key:e.key,target:e.target}),this.enableUpEvent&&"keyup"===e.type&&this.callback({type:DE,srcEvent:e,key:e.key,target:e.target}))},this.enableDownEvent=this.options.enable,this.enableUpEvent=this.options.enable,this.events=(this.options.events||[]).concat(FE),e.tabIndex=this.options.tabIndex||0,e.style.outline="none",this.events.forEach(t=>e.addEventListener(t,this.handleEvent))}destroy(){this.events.forEach(e=>this.element.removeEventListener(e,this.handleEvent))}enableEventType(e,t){e===kE&&(this.enableDownEvent=t),e===DE&&(this.enableUpEvent=t)}}const zE="contextmenu";class UE extends hE{constructor(e,t,i){super(e,t,i),this.handleEvent=e=>{this.options.enable&&this.callback({type:zE,center:{x:e.clientX,y:e.clientY},srcEvent:e,pointerType:"mouse",target:e.target})},e.addEventListener("contextmenu",this.handleEvent)}destroy(){this.element.removeEventListener("contextmenu",this.handleEvent)}enableEventType(e,t){e===zE&&(this.options.enable=t)}}const NE={pointerdown:1,pointermove:2,pointerup:4,mousedown:1,mousemove:2,mouseup:4};function VE(e){const t=NE[e.srcEvent.type];if(!t)return null;const{buttons:i,button:n}=e.srcEvent;let r=!1,o=!1,s=!1;return 2===t?(r=Boolean(1&i),o=Boolean(4&i),s=Boolean(2&i)):(r=0===n,o=1===n,s=2===n),{leftButton:r,middleButton:o,rightButton:s}}function jE(e,t){const i=e.center;if(!i)return null;const n=t.getBoundingClientRect(),r=n.width/t.offsetWidth||1,o=n.height/t.offsetHeight||1;return{center:i,offsetCenter:{x:(i.x-n.left-t.clientLeft)/r,y:(i.y-n.top-t.clientTop)/o}}}const GE={srcElement:"root",priority:0};class HE{constructor(e){this.handleEvent=e=>{if(this.isEmpty())return;const t=this._normalizeEvent(e);let i=e.srcEvent.target;for(;i&&i!==t.rootElement;){if(this._emit(t,i),t.handled)return;i=i.parentNode}this._emit(t,"root")},this.eventManager=e,this.handlers=[],this.handlersByElement=new Map,this._active=!1}isEmpty(){return!this._active}add(e,t,i,n=!1,r=!1){const{handlers:o,handlersByElement:s}=this;let a=GE;"string"==typeof i||i&&i.addEventListener?a={...GE,srcElement:i}:i&&(a={...GE,...i});let l=s.get(a.srcElement);l||(l=[],s.set(a.srcElement,l));const c={type:e,handler:t,srcElement:a.srcElement,priority:a.priority};n&&(c.once=!0),r&&(c.passive=!0),o.push(c),this._active=this._active||!c.passive;let u=l.length-1;for(;u>=0&&!(l[u].priority>=c.priority);)u--;l.splice(u+1,0,c)}remove(e,t){const{handlers:i,handlersByElement:n}=this;for(let r=i.length-1;r>=0;r--){const o=i[r];if(o.type===e&&o.handler===t){i.splice(r,1);const e=n.get(o.srcElement);e.splice(e.indexOf(o),1),0===e.length&&n.delete(o.srcElement)}}this._active=i.some(e=>!e.passive)}_emit(e,t){const i=this.handlersByElement.get(t);if(i){let t=!1;const n=()=>{e.handled=!0},r=()=>{e.handled=!0,t=!0},o=[];for(let s=0;s{e.srcEvent.preventDefault()},stopImmediatePropagation:null,stopPropagation:null,handled:!1,rootElement:t}}}const QE={events:null,recognizers:null,recognizerOptions:{},Manager:uE,touchAction:"none",tabIndex:0};class $E{constructor(e=null,t){this._onBasicInput=e=>{const{srcEvent:t}=e,i=mE[t.type];i&&this.manager.emit(i,e)},this._onOtherEvent=e=>{this.manager.emit(e.type,e)},this.options={...QE,...t},this.events=new Map,this.setElement(e);const{events:i}=this.options;i&&this.on(i)}getElement(){return this.element}setElement(e){if(this.element&&this.destroy(),this.element=e,!e)return;const{options:t}=this,i=t.Manager;this.manager=new i(e,{touchAction:t.touchAction,recognizers:t.recognizers||dE}).on("hammer.input",this._onBasicInput),t.recognizers||Object.keys(pE).forEach(e=>{const t=this.manager.get(e);t&&pE[e].forEach(e=>{t.recognizeWith(e)})});for(const e in t.recognizerOptions){const i=this.manager.get(e);if(i){const n=t.recognizerOptions[e];delete n.enable,i.set(n)}}this.wheelInput=new CE(e,this._onOtherEvent,{enable:!1}),this.moveInput=new LE(e,this._onOtherEvent,{enable:!1}),this.keyInput=new OE(e,this._onOtherEvent,{enable:!1,tabIndex:t.tabIndex}),this.contextmenuInput=new UE(e,this._onOtherEvent,{enable:!1});for(const[e,t]of this.events)t.isEmpty()||(this._toggleRecognizer(t.recognizerName,!0),this.manager.on(e,t.handleEvent))}destroy(){this.element&&(this.wheelInput.destroy(),this.moveInput.destroy(),this.keyInput.destroy(),this.contextmenuInput.destroy(),this.manager.destroy(),this.wheelInput=null,this.moveInput=null,this.keyInput=null,this.contextmenuInput=null,this.manager=null,this.element=null)}on(e,t,i){this._addEventHandler(e,t,i,!1)}once(e,t,i){this._addEventHandler(e,t,i,!0)}watch(e,t,i){this._addEventHandler(e,t,i,!1,!0)}off(e,t){this._removeEventHandler(e,t)}_toggleRecognizer(e,t){const{manager:i}=this;if(!i)return;const n=i.get(e);if(n&&n.options.enable!==t){n.set({enable:t});const r=fE[e];r&&!this.options.recognizers&&r.forEach(r=>{const o=i.get(r);t?(o.requireFailure(e),n.dropRequireFailure(r)):o.dropRequireFailure(e)})}this.wheelInput.enableEventType(e,t),this.moveInput.enableEventType(e,t),this.keyInput.enableEventType(e,t),this.contextmenuInput.enableEventType(e,t)}_addEventHandler(e,t,i,n,r){if("string"!=typeof e){i=t;for(const t in e)this._addEventHandler(t,e[t],i,n,r);return}const{manager:o,events:s}=this,a=AE[e]||e;let l=s.get(a);l||(l=new HE(this),s.set(a,l),l.recognizerName=_E[a]||a,o&&o.on(a,l.handleEvent)),l.add(e,t,i,n,r),l.isEmpty()||this._toggleRecognizer(l.recognizerName,!0)}_removeEventHandler(e,t){if("string"!=typeof e){for(const t in e)this._removeEventHandler(t,e[t]);return}const{events:i}=this,n=AE[e]||e,r=i.get(n);if(r&&(r.remove(e,t),r.isEmpty())){const{recognizerName:e}=r;let t=!1;for(const n of i.values())if(n.recognizerName===e&&!n.isEmpty()){t=!0;break}t||this._toggleRecognizer(e,!1)}}}function ZE(){}const WE={id:"",width:"100%",height:"100%",style:null,viewState:null,initialViewState:null,pickingRadius:0,layerFilter:null,parameters:{},parent:null,device:null,deviceProps:{type:"webgl"},gl:null,glOptions:{},canvas:null,layers:[],effects:[],views:null,controller:null,useDevicePixels:!0,touchAction:"none",eventRecognizerOptions:{},_framebuffer:null,_animate:!1,_pickable:!0,_typedArrayManagerProps:{},_customRender:null,widgets:[],onDeviceInitialized:ZE,onWebGLInitialized:ZE,onResize:ZE,onViewStateChange:ZE,onInteractionStateChange:ZE,onBeforeRender:ZE,onAfterRender:ZE,onLoad:ZE,onError:e=>rp.error(e.message,e.cause)(),onHover:null,onClick:null,onDragStart:null,onDrag:null,onDragEnd:null,_onMetrics:null,getCursor:({isDragging:e})=>e?"grabbing":"grab",getTooltip:null,debug:!1,drawPickingColors:!1};class qE{constructor(e){this.width=0,this.height=0,this.userData={},this.device=null,this.canvas=null,this.viewManager=null,this.layerManager=null,this.effectManager=null,this.deckRenderer=null,this.deckPicker=null,this.eventManager=null,this.widgetManager=null,this.tooltip=null,this.animationLoop=null,this.cursorState={isHovering:!1,isDragging:!1},this.stats=new Ch({id:"deck.gl"}),this.metrics={fps:0,setPropsTime:0,updateAttributesTime:0,framesRedrawn:0,pickTime:0,pickCount:0,gpuTime:0,gpuTimePerFrame:0,cpuTime:0,cpuTimePerFrame:0,bufferMemory:0,textureMemory:0,renderbufferMemory:0,gpuMemory:0},this._metricsCounter=0,this._needsRedraw="Initial render",this._pickRequest={mode:"hover",x:-1,y:-1,radius:0,event:null},this._lastPointerDownInfo=null,this._onPointerMove=e=>{const{_pickRequest:t}=this;if("pointerleave"===e.type)t.x=-1,t.y=-1,t.radius=0;else{if(e.leftButton||e.rightButton)return;{const i=e.offsetCenter;if(!i)return;t.x=i.x,t.y=i.y,t.radius=this.props.pickingRadius}}this.layerManager&&(this.layerManager.context.mousePosition={x:t.x,y:t.y}),t.event=e},this._onEvent=e=>{const t=Ty[e.type],i=e.offsetCenter;if(!t||!i||!this.layerManager)return;const n=this.layerManager.getLayers(),r=this.deckPicker.getLastPickedObject({x:i.x,y:i.y,layers:n,viewports:this.getViewports(i)},this._lastPointerDownInfo),{layer:o}=r,s=o&&(o[t.handler]||o.props[t.handler]),a=this.props[t.handler];let l=!1;s&&(l=s.call(o,r,e)),l||(a?.(r,e),this.widgetManager.onEvent(r,e))},this._onPointerDown=e=>{const t=e.offsetCenter,i=this._pick("pickObject","pickObject Time",{x:t.x,y:t.y,radius:this.props.pickingRadius});this._lastPointerDownInfo=i.result[0]||i.emptyInfo},this.props={...WE,...e},(e=this.props).viewState&&e.initialViewState&&rp.warn("View state tracking is disabled. Use either `initialViewState` for auto update or `viewState` for manual update.")(),this.viewState=this.props.initialViewState,e.device?this.device=e.device:e.gl&&(e.gl instanceof WebGLRenderingContext&&rp.error("WebGL1 context not supported.")(),this.device=oE.attach(e.gl));let t=this.device;t||(hf.registerDevices([oE]),t=hf.createDevice({...e.deviceProps,canvas:this._createCanvas(e)})),this.animationLoop=this._createAnimationLoop(t,e),this.setProps(e),e._typedArrayManagerProps&&Ov.setOptions(e._typedArrayManagerProps),this.animationLoop.start()}finalize(){this.animationLoop?.stop(),this.animationLoop?.destroy(),this.animationLoop=null,this._lastPointerDownInfo=null,this.layerManager?.finalize(),this.layerManager=null,this.viewManager?.finalize(),this.viewManager=null,this.effectManager?.finalize(),this.effectManager=null,this.deckRenderer?.finalize(),this.deckRenderer=null,this.deckPicker?.finalize(),this.deckPicker=null,this.eventManager?.destroy(),this.eventManager=null,this.widgetManager?.finalize(),this.widgetManager=null,this.props.canvas||this.props.device||this.props.gl||!this.canvas||(this.canvas.parentElement?.removeChild(this.canvas),this.canvas=null)}setProps(e){this.stats.get("setProps Time").timeStart(),"onLayerHover"in e&&rp.removed("onLayerHover","onHover")(),"onLayerClick"in e&&rp.removed("onLayerClick","onClick")(),e.initialViewState&&!Xx(this.props.initialViewState,e.initialViewState,3)&&(this.viewState=e.initialViewState),Object.assign(this.props,e),this._setCanvasSize(this.props);const t=Object.create(this.props);Object.assign(t,{views:this._getViews(),width:this.width,height:this.height,viewState:this._getViewState()}),this.animationLoop?.setProps(t),this.layerManager&&(this.viewManager.setProps(t),this.layerManager.activateViewport(this.getViewports()[0]),this.layerManager.setProps(t),this.effectManager.setProps(t),this.deckRenderer.setProps(t),this.deckPicker.setProps(t),this.widgetManager.setProps(t)),this.stats.get("setProps Time").timeEnd()}needsRedraw(e={clearRedrawFlags:!1}){if(!this.layerManager)return!1;if(this.props._animate)return"Deck._animate";let t=this._needsRedraw;e.clearRedrawFlags&&(this._needsRedraw=!1);const i=this.viewManager.needsRedraw(e),n=this.layerManager.needsRedraw(e),r=this.effectManager.needsRedraw(e),o=this.deckRenderer.needsRedraw(e);return t=t||i||n||r||o,t}redraw(e){if(!this.layerManager)return;let t=this.needsRedraw({clearRedrawFlags:!0});t=e||t,t&&(this.stats.get("Redraw Count").incrementCount(),this.props._customRender?this.props._customRender(t):this._drawLayers(t))}get isInitialized(){return null!==this.viewManager}getViews(){return ub(this.viewManager),this.viewManager.views}getViewports(e){return ub(this.viewManager),this.viewManager.getViewports(e)}getCanvas(){return this.canvas}pickObject(e){const t=this._pick("pickObject","pickObject Time",e).result;return t.length?t[0]:null}pickMultipleObjects(e){return e.depth=e.depth||10,this._pick("pickObject","pickMultipleObjects Time",e).result}pickObjects(e){return this._pick("pickObjects","pickObjects Time",e)}_addResources(e,t=!1){for(const i in e)this.layerManager.resourceManager.add({resourceId:i,data:e[i],forceUpdate:t})}_removeResources(e){for(const t of e)this.layerManager.resourceManager.remove(t)}_addDefaultEffect(e){this.effectManager.addDefaultEffect(e)}_addDefaultShaderModule(e){this.layerManager.addDefaultShaderModule(e)}_removeDefaultShaderModule(e){this.layerManager?.removeDefaultShaderModule(e)}_pick(e,t,i){ub(this.deckPicker);const{stats:n}=this;n.get("Pick Count").incrementCount(),n.get(t).timeStart();const r=this.deckPicker[e]({layers:this.layerManager.getLayers(i),views:this.viewManager.getViews(),viewports:this.getViewports(i),onViewportActive:this.layerManager.activateViewport,effects:this.effectManager.getEffects(),...i});return n.get(t).timeEnd(),r}_createCanvas(e){let t=e.canvas;if("string"==typeof t&&(t=document.getElementById(t),ub(t)),!t){t=document.createElement("canvas"),t.id=e.id||"deckgl-overlay";(e.parent||document.body).appendChild(t)}return Object.assign(t.style,e.style),t}_setCanvasSize(e){if(!this.canvas)return;const{width:t,height:i}=e;if(t||0===t){const e=Number.isFinite(t)?`${t}px`:t;this.canvas.style.width=e}if(i||0===i){const t=Number.isFinite(i)?`${i}px`:i;this.canvas.style.position=e.style?.position||"absolute",this.canvas.style.height=t}}_updateCanvasSize(){const{canvas:e}=this;if(!e)return;const t=e.clientWidth??e.width,i=e.clientHeight??e.height;t===this.width&&i===this.height||(this.width=t,this.height=i,this.viewManager?.setProps({width:t,height:i}),this.layerManager?.activateViewport(this.getViewports()[0]),this.props.onResize({width:t,height:i}))}_createAnimationLoop(e,t){const{gl:i,onError:n,useDevicePixels:r}=t;return new fx({device:e,useDevicePixels:r,autoResizeDrawingBuffer:!i,autoResizeViewport:!1,onInitialize:e=>this._setDevice(e.device),onRender:this._onRenderFrame.bind(this),onError:n})}_getViewState(){return this.props.viewState||this.viewState}_getViews(){const{views:e}=this.props,t=Array.isArray(e)?e:e?[e]:[new Ib({id:"default-view"})];return t.length&&this.props.controller&&(t[0].props.controller=this.props.controller),t}_onContextLost(){const{onError:e}=this.props;this.animationLoop&&e&&e(new Error("WebGL context is lost"))}_pickAndCallback(){const{_pickRequest:e}=this;if(e.event){const{result:t,emptyInfo:i}=this._pick("pickObject","pickObject Time",e);this.cursorState.isHovering=t.length>0;let n=i,r=!1;for(const i of t)n=i,r=i.layer?.onHover(i,e.event)||r;r||(this.props.onHover?.(n,e.event),this.widgetManager.onHover(n,e.event)),e.event=null}}_updateCursor(){const e=this.props.parent||this.canvas;e&&(e.style.cursor=this.props.getCursor(this.cursorState))}_setDevice(e){if(this.device=e,!this.animationLoop)return;this.canvas||(this.canvas=this.device.canvasContext?.canvas),this.device.setParametersWebGL({blend:!0,blendFunc:[770,771,1,771],polygonOffsetFill:!0,depthTest:!0,depthFunc:515}),this.props.onDeviceInitialized(this.device),this.device instanceof oE&&this.props.onWebGLInitialized(this.device.gl);const t=new hx;t.play(),this.animationLoop.attachTimeline(t),this.eventManager=new $E(this.props.parent||this.canvas,{touchAction:this.props.touchAction,recognizerOptions:this.props.eventRecognizerOptions,events:{pointerdown:this._onPointerDown,pointermove:this._onPointerMove,pointerleave:this._onPointerMove}});for(const e in Ty)this.eventManager.on(e,this._onEvent);this.viewManager=new Jx({timeline:t,eventManager:this.eventManager,onViewStateChange:this._onViewStateChange.bind(this),onInteractionStateChange:this._onInteractionStateChange.bind(this),views:this._getViews(),viewState:this._getViewState(),width:this.width,height:this.height});const i=this.viewManager.getViewports()[0];this.layerManager=new Kx(this.device,{deck:this,stats:this.stats,viewport:i,timeline:t}),this.effectManager=new Pb({deck:this,device:this.device}),this.deckRenderer=new Lb(this.device),this.deckPicker=new Ub(this.device),this.widgetManager=new Gb({deck:this,parentElement:this.canvas?.parentElement}),this.widgetManager.addDefault(new Qb),this.setProps(this.props),this._updateCanvasSize(),this.props.onLoad()}_drawLayers(e,t){const{device:i,gl:n}=this.layerManager.context;this.props.onBeforeRender({device:i,gl:n});const r={target:this.props._framebuffer,layers:this.layerManager.getLayers(),viewports:this.viewManager.getViewports(),onViewportActive:this.layerManager.activateViewport,views:this.viewManager.getViews(),pass:"screen",effects:this.effectManager.getEffects(),...t};this.deckRenderer?.renderLayers(r),"screen"===r.pass&&this.widgetManager.onRedraw({viewports:r.viewports,layers:r.layers}),this.props.onAfterRender({device:i,gl:n})}_onRenderFrame(){this._getFrameStats(),this._metricsCounter++%60==0&&(this._getMetrics(),this.stats.reset(),rp.table(4,this.metrics)(),this.props._onMetrics&&this.props._onMetrics(this.metrics)),this._updateCanvasSize(),this._updateCursor(),this.layerManager.updateLayers(),this._pickAndCallback(),this.redraw(),this.viewManager&&this.viewManager.updateViewStates()}_onViewStateChange(e){const t=this.props.onViewStateChange(e)||e.viewState;this.viewState&&(this.viewState={...this.viewState,[e.viewId]:t},this.props.viewState||this.viewManager&&this.viewManager.setProps({viewState:this.viewState}))}_onInteractionStateChange(e){this.cursorState.isDragging=e.isDragging||!1,this.props.onInteractionStateChange(e)}_getFrameStats(){const{stats:e}=this;e.get("frameRate").timeEnd(),e.get("frameRate").timeStart();const t=this.animationLoop.stats;e.get("GPU Time").addTime(t.get("GPU Time").lastTiming),e.get("CPU Time").addTime(t.get("CPU Time").lastTiming)}_getMetrics(){const{metrics:e,stats:t}=this;e.fps=t.get("frameRate").getHz(),e.setPropsTime=t.get("setProps Time").time,e.updateAttributesTime=t.get("Update Attributes").time,e.framesRedrawn=t.get("Redraw Count").count,e.pickTime=t.get("pickObject Time").time+t.get("pickMultipleObjects Time").time+t.get("pickObjects Time").time,e.pickCount=t.get("Pick Count").count,e.gpuTime=t.get("GPU Time").time,e.cpuTime=t.get("CPU Time").time,e.gpuTimePerFrame=t.get("GPU Time").getAverageTime(),e.cpuTimePerFrame=t.get("CPU Time").getAverageTime();const i=hf.stats.get("Memory Usage");e.bufferMemory=i.get("Buffer Memory").count,e.textureMemory=i.get("Texture Memory").count,e.renderbufferMemory=i.get("Renderbuffer Memory").count,e.gpuMemory=i.get("GPU Memory").count}}qE.defaultProps=WE,qE.VERSION=up;var KE=qE;const XE=Jf;function JE(e,t){return{attribute:e,format:t.size>1?`${t.type}x${t.size}`:t.type,byteOffset:t.offset||0}}function YE(e){return e.stride||e.size*e.bytesPerElement}function eC(e,t){t.offset&&rp.removed("shaderAttribute.offset","vertexOffset, elementOffset")();const i=YE(e),n=(void 0!==t.vertexOffset?t.vertexOffset:e.vertexOffset||0)*i+(t.elementOffset||0)*e.bytesPerElement+(e.offset||0);return{...t,offset:n,stride:i}}class tC{constructor(e,t,i){this._buffer=null,this.device=e,this.id=t.id||"",this.size=t.size||1;const n=t.logicalType||t.type,r="float64"===n;let o,{defaultValue:s}=t;s=Number.isFinite(s)?[s]:s||new Array(this.size).fill(0),o=r?"float32":!n&&t.isIndexed?"uint32":n||"float32";let a=function(e){switch(e){case"float64":return Float64Array;case"uint8":case"unorm8":return Uint8ClampedArray;default:return Yf(e)}}(n||o);this.doublePrecision=r,r&&!1===t.fp64&&(a=Float32Array),this.value=null,this.settings={...t,defaultType:a,defaultValue:s,logicalType:n,type:o,normalized:o.includes("norm"),size:this.size,bytesPerElement:a.BYTES_PER_ELEMENT},this.state={...i,externalBuffer:null,bufferAccessor:this.settings,allocatedValue:null,numInstances:0,bounds:null,constant:!1}}get isConstant(){return this.state.constant}get buffer(){return this._buffer}get byteOffset(){const e=this.getAccessor();return e.vertexOffset?e.vertexOffset*YE(e):0}get numInstances(){return this.state.numInstances}set numInstances(e){this.state.numInstances=e}delete(){this._buffer&&(this._buffer.delete(),this._buffer=null),Ov.release(this.state.allocatedValue)}getBuffer(){return this.state.constant?null:this.state.externalBuffer||this._buffer}getValue(e=this.id,t=null){const i={};if(this.state.constant){const n=this.value;if(t){const r=eC(this.getAccessor(),t),o=r.offset/n.BYTES_PER_ELEMENT,s=r.size||this.size;i[e]=n.subarray(o,o+s)}else i[e]=n}else i[e]=this.getBuffer();return this.doublePrecision&&(this.value instanceof Float64Array?i[`${e}64Low`]=i[e]:i[`${e}64Low`]=new Float32Array(this.size)),i}_getBufferLayout(e=this.id,t=null){const i=this.getAccessor(),n=[],r={name:this.id,byteStride:YE(i),attributes:n};if(this.doublePrecision){const r=function(e,t){const i=eC(e,t);return{high:i,low:{...i,offset:i.offset+4*e.size}}}(i,t||{});n.push(JE(e,{...i,...r.high}),JE(`${e}64Low`,{...i,...r.low}))}else if(t){const r=eC(i,t);n.push(JE(e,{...i,...r}))}else n.push(JE(e,i));return r}setAccessor(e){this.state.bufferAccessor=e}getAccessor(){return this.state.bufferAccessor}getBounds(){if(this.state.bounds)return this.state.bounds;let e=null;if(this.state.constant&&this.value){const t=Array.from(this.value);e=[t,t]}else{const{value:t,numInstances:i,size:n}=this,r=i*n;if(t&&r&&t.length>=r){const i=new Array(n).fill(1/0),o=new Array(n).fill(-1/0);for(let e=0;eo[r]&&(o[r]=n)}e=[i,o]}}return this.state.bounds=e,e}setData(e){const{state:t}=this;let i;i=ArrayBuffer.isView(e)?{value:e}:e instanceof Xp?{buffer:e}:e;const n={...this.settings,...i};if(ArrayBuffer.isView(i.value)){if(!i.type){if(this.doublePrecision&&i.value instanceof Float64Array)n.type="float32";else{const e=XE(i.value);n.type=n.normalized?e.replace("int","norm"):e}}n.bytesPerElement=i.value.BYTES_PER_ELEMENT,n.stride=YE(n)}if(t.bounds=null,i.constant){let e=i.value;e=this._normalizeValue(e,[],0),this.settings.normalized&&(e=this.normalizeConstant(e));if(!(!t.constant||!this._areValuesEqual(e,this.value)))return!1;t.externalBuffer=null,t.constant=!0,this.value=ArrayBuffer.isView(e)?e:new Float32Array(e)}else if(i.buffer){const e=i.buffer;t.externalBuffer=e,t.constant=!1,this.value=i.value||null}else if(i.value){this._checkExternalBuffer(i);let e=i.value;t.externalBuffer=null,t.constant=!1,this.value=e;let{buffer:r}=this;const o=YE(n),s=(n.vertexOffset||0)*o;if(this.doublePrecision&&e instanceof Float64Array&&(e=jv(e,n)),this.settings.isIndexed){const t=this.settings.defaultType;e.constructor!==t&&(e=new t(e))}const a=e.byteLength+s+2*o;(!r||r.byteLength(e+128)/255*2-1);case"snorm16":return new Float32Array(e).map(e=>(e+32768)/65535*2-1);case"unorm8":return new Float32Array(e).map(e=>e/255);case"unorm16":return new Float32Array(e).map(e=>e/65535);default:return e}}_normalizeValue(e,t,i){const{defaultValue:n,size:r}=this.settings;if(Number.isFinite(e))return t[i]=e,t;if(!e){let e=r;for(;--e>=0;)t[i+e]=n[e];return t}switch(r){case 4:t[i+3]=Number.isFinite(e[3])?e[3]:n[3];case 3:t[i+2]=Number.isFinite(e[2])?e[2]:n[2];case 2:t[i+1]=Number.isFinite(e[1])?e[1]:n[1];case 1:t[i+0]=Number.isFinite(e[0])?e[0]:n[0];break;default:let o=r;for(;--o>=0;)t[i+o]=Number.isFinite(e[o])?e[o]:n[o]}return t}_areValuesEqual(e,t){if(!e||!t)return!1;const{size:i}=this;for(let n=0;n0&&(nC.length=e.length,n=nC):n=iC,(t>0||Number.isFinite(i))&&(n=(Array.isArray(n)?n:Array.from(n)).slice(t,i),r.index=t-1),{iterable:n,objectInfo:r}}function oC(e){return e&&e[Symbol.asyncIterator]}function sC(e,t){const{size:i,stride:n,offset:r,startIndices:o,nested:s}=t,a=e.BYTES_PER_ELEMENT,l=n?n/a:i,c=r?r/a:0,u=Math.floor((e.length-c)/l);return(t,{index:n,target:r})=>{if(!o){const t=n*l+c;for(let n=0;ne},spring:{stiffness:.05,damping:.5}};function uC(e,t){if(!e)return null;Number.isFinite(e)&&(e={type:"interpolation",duration:e});const i=e.type||"interpolation";return{...cC[i],...t,...e,type:i}}class hC extends tC{constructor(e,t){super(e,t,{startIndices:null,lastExternalBuffer:null,binaryValue:null,binaryAccessor:null,needsUpdate:!0,needsRedraw:!1,layoutChanged:!1,updateRanges:lC}),this.constant=!1,this.settings.update=t.update||(t.accessor?this._autoUpdater:void 0),Object.seal(this.settings),Object.seal(this.state),this._validateAttributeUpdaters()}get startIndices(){return this.state.startIndices}set startIndices(e){this.state.startIndices=e}needsUpdate(){return this.state.needsUpdate}needsRedraw({clearChangedFlags:e=!1}={}){const t=this.state.needsRedraw;return this.state.needsRedraw=t&&!e,t}layoutChanged(){return this.state.layoutChanged}setAccessor(e){var t,i,n;(t=this.state).layoutChanged||(t.layoutChanged=(i=e,n=this.getAccessor(),!(i.type===n.type&&i.size===n.size&&YE(i)===YE(n)&&(i.offset||0)===(n.offset||0)))),super.setAccessor(e)}getUpdateTriggers(){const{accessor:e}=this.settings;return[this.id].concat("function"!=typeof e&&e||[])}supportsTransition(){return Boolean(this.settings.transition)}getTransitionSetting(e){if(!e||!this.supportsTransition())return null;const{accessor:t}=this.settings,i=this.settings.transition,n=Array.isArray(t)?e[t.find(t=>e[t])]:e[t];return uC(n,i)}setNeedsUpdate(e=this.id,t){if(this.state.needsUpdate=this.state.needsUpdate||e,this.setNeedsRedraw(e),t){const{startRow:e=0,endRow:i=1/0}=t;this.state.updateRanges=function(e,t){if(e===lC)return e;if(t[0]<0&&(t[0]=0),t[0]>=t[1])return e;const i=[],n=e.length;let r=0;for(let o=0;ot[1]?i.push(n):t=[Math.min(n[0],t[0]),Math.max(n[1],t[1])]}return i.splice(r,0,t),i}(this.state.updateRanges,[e,i])}else this.state.updateRanges=lC}clearNeedsUpdate(){this.state.needsUpdate=!1,this.state.updateRanges=aC}setNeedsRedraw(e=this.id){this.state.needsRedraw=this.state.needsRedraw||e}allocate(e){const{state:t,settings:i}=this;return!i.noAlloc&&(!!i.update&&(super.allocate(e,t.updateRanges!==lC),!0))}updateBuffer({numInstances:e,data:t,props:i,context:n}){if(!this.needsUpdate())return!1;const{state:{updateRanges:r},settings:{update:o,noAlloc:s}}=this;let a=!0;if(o){for(const[s,a]of r)o.call(n,this,{data:t,startRow:s,endRow:a,props:i,numInstances:e});if(this.value)if(this.constant||!this.buffer||this.buffer.byteLengthc?l.set(i,f):(e._normalizeValue(i,g.target,0),Zx({target:l,source:g.target,start:f,count:t}));f+=t*c}else e._normalizeValue(i,l,f),f+=c}}_validateAttributeUpdaters(){const{settings:e}=this;if(!(e.noAlloc||"function"==typeof e.update))throw new Error(`Attribute ${this.id} missing update or accessor`)}_checkAttributeArray(){const{value:e}=this,t=Math.min(4,this.size);if(e&&e.length>=t){let i=!0;switch(t){case 4:i=i&&Number.isFinite(e[3]);case 3:i=i&&Number.isFinite(e[2]);case 2:i=i&&Number.isFinite(e[1]);case 1:i=i&&Number.isFinite(e[0]);break;default:i=!1}if(!i)throw new Error(`Illegal attribute generated for ${this.id}`)}}}function dC(e){const{source:t,target:i,start:n=0,size:r,getData:o}=e,s=e.end||i.length,a=t.length,l=s-n;if(a>l)return void i.set(t.subarray(0,l),n);if(i.set(t,n),!o)return;let c=a;for(;ce}){const a=i.doublePrecision&&i.value instanceof Float64Array?2:1,l=i.size*a,c=i.byteOffset,u=i.settings.bytesPerElement<4?c/i.settings.bytesPerElement*4:c,h=i.startIndices,d=o&&h,p=i.isConstant;if(!d&&t&&n>=r)return t;const f=i.value instanceof Float64Array?Float32Array:i.value.constructor,m=p?i.value:new f(i.getBuffer().readSyncWebGL(c,r*f.BYTES_PER_ELEMENT).buffer);if(i.settings.normalized&&!p){const e=s;s=(t,n)=>i.normalizeConstant(e(t,n))}const g=p?(e,t)=>s(m,t):(e,t)=>s(m.subarray(e+c,e+c+l),t),_=t?new Float32Array(t.readSyncWebGL(u,4*n).buffer):new Float32Array(0),A=new Float32Array(r);return function({source:e,target:t,size:i,getData:n,sourceStartIndices:r,targetStartIndices:o}){if(!r||!o)return dC({source:e,target:t,size:i,getData:n}),t;let s=0,a=0;const l=n&&((e,t)=>n(e+a,t)),c=Math.min(r.length,o.length);for(let n=1;n0||n.end()}delete(){super.delete(),this.transform.destroy(),this.texture.destroy(),this.framebuffer.destroy()}}};class EC{constructor(e,{id:t,timeline:i}){if(!e)throw new Error("AttributeTransitionManager is constructed without device");this.id=t,this.device=e,this.timeline=i,this.transitions={},this.needsRedraw=!1,this.numInstances=1}finalize(){for(const e in this.transitions)this._removeTransition(e)}update({attributes:e,transitions:t,numInstances:i}){this.numInstances=i||1;for(const i in e){const n=e[i],r=n.getTransitionSetting(t);r&&this._updateAttribute(i,n,r)}for(const i in this.transitions){const n=e[i];n&&n.getTransitionSetting(t)||this._removeTransition(i)}}hasAttribute(e){const t=this.transitions[e];return t&&t.inProgress}getAttributes(){const e={};for(const t in this.transitions){const i=this.transitions[t];i.inProgress&&(e[t]=i.attributeInTransition)}return e}run(){if(0===this.numInstances)return!1;for(const e in this.transitions){this.transitions[e].update()&&(this.needsRedraw=!0)}const e=this.needsRedraw;return this.needsRedraw=!1,e}_removeTransition(e){this.transitions[e].delete(),delete this.transitions[e]}_updateAttribute(e,t,i){const n=this.transitions[e];let r=!n||n.type!==i.type;if(r){n&&this._removeTransition(e);const o=TC[i.type];o?this.transitions[e]=new o({attribute:t,timeline:this.timeline,device:this.device}):(rp.error(`unsupported transition type '${i.type}'`)(),r=!1)}(r||t.needsRedraw())&&(this.needsRedraw=!0,this.transitions[e].start(i,this.numInstances))}}const CC="attributeManager.invalidate";class SC{constructor(e,{id:t="attribute-manager",stats:i,timeline:n}={}){this.mergeBoundsMemoized=Sy(Gv),this.id=t,this.device=e,this.attributes={},this.updateTriggers={},this.needsRedraw=!0,this.userData={},this.stats=i,this.attributeTransitionManager=new EC(e,{id:`${t}-transitions`,timeline:n}),Object.seal(this)}finalize(){for(const e in this.attributes)this.attributes[e].delete();this.attributeTransitionManager.finalize()}getNeedsRedraw(e={clearRedrawFlags:!1}){const t=this.needsRedraw;return this.needsRedraw=this.needsRedraw&&!e.clearRedrawFlags,t&&this.id}setNeedsRedraw(){this.needsRedraw=!0}add(e){this._add(e)}addInstanced(e){this._add(e,{stepMode:"instance"})}remove(e){for(const t of e)void 0!==this.attributes[t]&&(this.attributes[t].delete(),delete this.attributes[t])}invalidate(e,t){const i=this._invalidateTrigger(e,t);lp(CC,this,e,i)}invalidateAll(e){for(const t in this.attributes)this.attributes[t].setNeedsUpdate(t,e);lp(CC,this,"all")}update({data:e,numInstances:t,startIndices:i=null,transitions:n,props:r={},buffers:o={},context:s={}}){let a=!1;lp("attributeManager.updateStart",this),this.stats&&this.stats.get("Update Attributes").timeStart();for(const n in this.attributes){const l=this.attributes[n],c=l.settings.accessor;l.startIndices=i,l.numInstances=t,r[n]&&rp.removed(`props.${n}`,`data.attributes.${n}`)(),l.setExternalBuffer(o[n])||l.setBinaryValue("string"==typeof c?o[c]:void 0,e.startIndices)||"string"==typeof c&&!o[c]&&l.setConstantValue(r[c])||l.needsUpdate()&&(a=!0,this._updateAttribute({attribute:l,numInstances:t,data:e,props:r,context:s})),this.needsRedraw=this.needsRedraw||l.needsRedraw()}a&&lp("attributeManager.updateEnd",this,t),this.stats&&this.stats.get("Update Attributes").timeEnd(),this.attributeTransitionManager.update({attributes:this.attributes,numInstances:t,transitions:n})}updateTransition(){const{attributeTransitionManager:e}=this,t=e.run();return this.needsRedraw=this.needsRedraw||t,t}getAttributes(){return{...this.attributes,...this.attributeTransitionManager.getAttributes()}}getBounds(e){const t=e.map(e=>this.attributes[e]?.getBounds());return this.mergeBoundsMemoized(t)}getChangedAttributes(e={clearChangedFlags:!1}){const{attributes:t,attributeTransitionManager:i}=this,n={...i.getAttributes()};for(const r in t){const o=t[r];o.needsRedraw(e)&&!i.hasAttribute(r)&&(n[r]=o)}return n}getBufferLayouts(e){return Object.values(this.getAttributes()).map(t=>t.getBufferLayout(e))}_add(e,t){for(const i in e){const n=e[i],r={...n,id:i,size:(n.isIndexed?1:n.size)||1,...t};this.attributes[i]=new hC(this.device,r)}this._mapUpdateTriggersToAttributes()}_mapUpdateTriggersToAttributes(){const e={};for(const t in this.attributes){this.attributes[t].getUpdateTriggers().forEach(i=>{e[i]||(e[i]=[]),e[i].push(t)})}this.updateTriggers=e}_invalidateTrigger(e,t){const{attributes:i,updateTriggers:n}=this,r=n[e];return r&&r.forEach(e=>{const n=i[e];n&&n.setNeedsUpdate(n.id,t)}),r}_updateAttribute(e){const{attribute:t,numInstances:i}=e;if(lp("attribute.updateStart",t),t.constant)return void t.setConstantValue(t.value);t.allocate(i)&&lp("attribute.allocate",t,i);t.updateBuffer(e)&&(this.needsRedraw=!0,lp("attribute.updateEnd",t,i))}}const BC=1e-5;function IC(e,t,i,n,r){const o=t-e;return(i-t)*r+-o*n+o+t}function MC(e,t){if(Array.isArray(e)){let i=0;for(let n=0;n0}add(e,t,i,n){const{transitions:r}=this;if(r.has(e)){const i=r.get(e),{value:n=i.settings.fromValue}=i;t=n,this.remove(e)}if(!(n=uC(n)))return;const o=PC[n.type];if(!o)return void rp.error(`unsupported transition type '${n.type}'`)();const s=new o(this.timeline);s.start({...n,fromValue:t,toValue:i}),r.set(e,s)}remove(e){const{transitions:t}=this;t.has(e)&&(t.get(e).cancel(),t.delete(e))}update(){const e={};for(const[t,i]of this.transitions)i.update(),e[t]=i.value,i.inProgress||this.remove(t);return e}clear(){for(const e of this.transitions.keys())this.remove(e)}}function LC(e,t){const i=kC({newProps:e,oldProps:t,propTypes:e[Nx],ignoreProps:{data:null,updateTriggers:null,extensions:null,transitions:null}}),n=function(e,t){if(null===t)return"oldProps is null, initial diff";let i=!1;const{dataComparator:n,_dataDiff:r}=e;n?n(e.data,t.data)||(i="Data comparator detected a change"):e.data!==t.data&&(i="A new data container was supplied");i&&r&&(i=r(e.data,t.data)||i);return i}(e,t);let r=!1;return n||(r=function(e,t){if(null===t)return{all:!0};if("all"in e.updateTriggers){if(zC(e,t,"all"))return{all:!0}}const i={};let n=!1;for(const r in e.updateTriggers)if("all"!==r){zC(e,t,r)&&(i[r]=!0,n=!0)}return!!n&&i}(e,t)),{dataChanged:n,propsChanged:i,updateTriggersChanged:r,extensionsChanged:OC(e,t),transitionsChanged:FC(e,t)}}function FC(e,t){if(!e.transitions)return!1;const i={},n=e[Nx];let r=!1;for(const o in e.transitions){const s=n[o],a=s&&s.type;("number"===a||"color"===a||"array"===a)&&DC(e[o],t[o],s)&&(i[o]=!0,r=!0)}return!!r&&i}function kC({newProps:e,oldProps:t,ignoreProps:i={},propTypes:n={},triggerName:r="props"}){if(t===e)return!1;if("object"!=typeof e||null===e)return`${r} changed shallowly`;if("object"!=typeof t||null===t)return`${r} changed shallowly`;for(const o of Object.keys(e))if(!(o in i)){if(!(o in t))return`${r}.${o} added`;const i=DC(e[o],t[o],n[o]);if(i)return`${r}.${o} ${i}`}for(const o of Object.keys(t))if(!(o in i)){if(!(o in e))return`${r}.${o} dropped`;if(!Object.hasOwnProperty.call(e,o)){const i=DC(e[o],t[o],n[o]);if(i)return`${r}.${o} ${i}`}}return!1}function DC(e,t,i){let n=i&&i.equal;return n&&!n(e,t,i)?"changed deeply":n||(n=e&&t&&e.equals,!n||n.call(e,t))?n||t===e?null:"changed shallowly":"changed deeply"}function OC(e,t){if(null===t)return!0;const i=t.extensions,{extensions:n}=e;if(n===i)return!1;if(!i||!n)return!0;if(n.length!==i.length)return!0;for(let e=0;e"project64"===e.name))){const e=i.modules.findIndex(e=>"project32"===e.name);e>=0&&i.modules.splice(e,1)}if("inject"in t)if(e.inject){const n={...e.inject};for(const e in t.inject)n[e]=(n[e]||"")+t.inject[e];i.inject=n}else i.inject=t.inject;return i}const VC={minFilter:"linear",mipmapFilter:"linear",magFilter:"linear",addressModeU:"clamp-to-edge",addressModeV:"clamp-to-edge"},jC={};const GC={boolean:{validate:(e,t)=>!0,equal:(e,t,i)=>Boolean(e)===Boolean(t)},number:{validate:(e,t)=>Number.isFinite(e)&&(!("max"in t)||e<=t.max)&&(!("min"in t)||e>=t.min)},color:{validate:(e,t)=>t.optional&&!e||$C(e)&&(3===e.length||4===e.length),equal:(e,t,i)=>Xx(e,t,1)},accessor:{validate(e,t){const i=ZC(e);return"function"===i||i===ZC(t.value)},equal:(e,t,i)=>"function"==typeof t||Xx(e,t,1)},array:{validate:(e,t)=>t.optional&&!e||$C(e),equal(e,t,i){const{compare:n}=i,r=Number.isInteger(n)?n:n?1:0;return n?Xx(e,t,r):e===t}},object:{equal(e,t,i){if(i.ignore)return!0;const{compare:n}=i,r=Number.isInteger(n)?n:n?1:0;return n?Xx(e,t,r):e===t}},function:{validate:(e,t)=>t.optional&&!e||"function"==typeof e,equal:(e,t,i)=>!i.compare&&!1!==i.ignore||e===t},data:{transform:(e,t,i)=>{if(!e)return e;const{dataTransform:n}=i.props;return n?n(e):"string"==typeof e.shape&&e.shape.endsWith("-table")&&Array.isArray(e.data)?e.data:e}},image:{transform:(e,t,i)=>{const n=i.context;return n&&n.device?function(e,t,i,n){if(i instanceof yf)return i;i.constructor&&"Object"!==i.constructor.name&&(i={data:i});let r=null;i.compressed&&(r={minFilter:"linear",mipmapFilter:i.data.length>1?"nearest":"linear"});const o=t.createTexture({...i,sampler:{...VC,...r,...n}});return jC[o.id]=e,o}(i.id,n.device,e,{...t.parameters,...i.props.textureParameters}):null},release:(e,t,i)=>{var n,r;n=i.id,(r=e)&&r instanceof yf&&jC[r.id]===n&&(r.delete(),delete jC[r.id])}}};function HC(e,t){switch(ZC(t)){case"object":return QC(e,t);case"array":return QC(e,{type:"array",value:t,compare:!1});case"boolean":return QC(e,{type:"boolean",value:t});case"number":return QC(e,{type:"number",value:t});case"function":return QC(e,{type:"function",value:t,compare:!0});default:return{name:e,type:"unknown",value:t}}}function QC(e,t){return"type"in t?{name:e,...GC[t.type],...t}:"value"in t?{name:e,type:ZC(t.value),...t}:{name:e,type:"object",value:t}}function $C(e){return Array.isArray(e)||ArrayBuffer.isView(e)}function ZC(e){return $C(e)?"array":null===e?"null":typeof e}const WC="_mergedDefaultProps";function qC(e,t){if(!(e instanceof tS.constructor))return{};let i=WC;if(t)for(const e of t){const t=e.constructor;t&&(i+=`:${t.extensionName||t.name}`)}const n=JC(e,i);return n||(e[i]=function(e,t){const i=e.prototype;if(!i)return null;const n=Object.getPrototypeOf(e),r=qC(n),o=JC(e,"defaultProps")||{},s=function(e){const t={},i={},n={};for(const[r,o]of Object.entries(e)){const e=o?.deprecatedFor;if(e)n[r]=Array.isArray(e)?e:[e];else{const e=HC(r,o);t[r]=e,i[r]=e.value}}return{propTypes:t,defaultProps:i,deprecatedProps:n}}(o),a=Object.assign(Object.create(null),r,s.defaultProps),l=Object.assign(Object.create(null),r?.[Nx],s.propTypes),c=Object.assign(Object.create(null),r?.[Vx],s.deprecatedProps);for(const e of t){const t=qC(e.constructor);t&&(Object.assign(a,t),Object.assign(l,t[Nx]),Object.assign(c,t[Vx]))}(function(e,t){const i=function(e){const t=e.componentName;t||rp.warn(`${e.name}.componentName not specified`)();return t||e.name}(t);Object.defineProperties(e,{id:{writable:!0,value:i}})})(a,e),function(e,t){const i={},n={};for(const e in t){const r=t[e],{name:o,value:s}=r;r.async&&(i[o]=s,n[o]=KC(o))}e[jx]=i,e[Gx]={},Object.defineProperties(e,n)}(a,l),function(e,t){for(const i in t)Object.defineProperty(e,i,{enumerable:!1,set(e){const n=`${this.id}: ${i}`;for(const n of t[i])XC(this,n)||(this[n]=e);rp.deprecated(n,t[i].join("/"))()}})}(a,c),a[Nx]=l,a[Vx]=c,0!==t.length||XC(e,"_propTypes")||(e._propTypes=l);return a}(e,t||[]))}function KC(e){return{enumerable:!0,set(t){"string"==typeof t||t instanceof Promise||oC(t)?this[Gx][e]=t:this[Hx][e]=t},get(){if(this[Hx]){if(e in this[Hx]){return this[Hx][e]||this[jx][e]}if(e in this[Gx]){const t=this[Ux]&&this[Ux].internalState;if(t&&t.hasAsyncProp(e))return t.getAsyncProp(e)||this[jx][e]}}return this[jx][e]}}}function XC(e,t){return Object.prototype.hasOwnProperty.call(e,t)}function JC(e,t){return XC(e,t)&&e[t]}let YC=0;class eS{constructor(...e){this.props=function(e,t){let i;for(let e=t.length-1;e>=0;e--){const n=t[e];"extensions"in n&&(i=n.extensions)}const n=qC(e.constructor,i),r=Object.create(n);r[Ux]=e,r[Gx]={},r[Hx]={};for(let e=0;e{},this.oldProps=null,this.oldAsyncProps=null}finalize(){for(const e in this.asyncProps){const t=this.asyncProps[e];t&&t.type&&t.type.release&&t.type.release(t.resolvedValue,t.type,this.component)}this.asyncProps={},this.component=null,this.resetOldProps()}getOldProps(){return this.oldAsyncProps||this.oldProps||iS}resetOldProps(){this.oldAsyncProps=null,this.oldProps=this.component?this.component.props:null}hasAsyncProp(e){return e in this.asyncProps}getAsyncProp(e){const t=this.asyncProps[e];return t&&t.resolvedValue}isAsyncPropLoading(e){if(e){const t=this.asyncProps[e];return Boolean(t&&t.pendingLoadCount>0&&t.pendingLoadCount!==t.resolvedLoadCount)}for(const e in this.asyncProps)if(this.isAsyncPropLoading(e))return!0;return!1}reloadAsyncProp(e,t){this._watchPromise(e,Promise.resolve(t))}setAsyncProps(e){this.component=e[Ux]||this.component;const t=e[Hx]||{},i=e[Gx]||e,n=e[jx]||{};for(const e in t){const i=t[e];this._createAsyncPropData(e,n[e]),this._updateAsyncProp(e,i),t[e]=this.getAsyncProp(e)}for(const e in i){const t=i[e];this._createAsyncPropData(e,n[e]),this._updateAsyncProp(e,t)}}_fetch(e,t){return null}_onResolve(e,t){}_onError(e,t){}_updateAsyncProp(e,t){this._didAsyncInputValueChange(e,t)&&("string"==typeof t&&(t=this._fetch(e,t)),t instanceof Promise?this._watchPromise(e,t):oC(t)?this._resolveAsyncIterable(e,t):this._setPropValue(e,t))}_freezeAsyncOldProps(){if(!this.oldAsyncProps&&this.oldProps){this.oldAsyncProps=Object.create(this.oldProps);for(const e in this.asyncProps)Object.defineProperty(this.oldAsyncProps,e,{enumerable:!0,value:this.oldProps[e]})}}_didAsyncInputValueChange(e,t){const i=this.asyncProps[e];return t!==i.resolvedValue&&t!==i.lastValue&&(i.lastValue=t,!0)}_setPropValue(e,t){this._freezeAsyncOldProps();const i=this.asyncProps[e];i&&(t=this._postProcessValue(i,t),i.resolvedValue=t,i.pendingLoadCount++,i.resolvedLoadCount=i.pendingLoadCount)}_setAsyncPropValue(e,t,i){const n=this.asyncProps[e];n&&i>=n.resolvedLoadCount&&void 0!==t&&(this._freezeAsyncOldProps(),n.resolvedValue=t,n.resolvedLoadCount=i,this.onAsyncPropUpdated(e,t))}_watchPromise(e,t){const i=this.asyncProps[e];if(i){i.pendingLoadCount++;const n=i.pendingLoadCount;t.then(t=>{this.component&&(t=this._postProcessValue(i,t),this._setAsyncPropValue(e,t,n),this._onResolve(e,t))}).catch(t=>{this._onError(e,t)})}}async _resolveAsyncIterable(e,t){if("data"!==e)return void this._setPropValue(e,t);const i=this.asyncProps[e];if(!i)return;i.pendingLoadCount++;const n=i.pendingLoadCount;let r=[],o=0;for await(const i of t){if(!this.component)return;const{dataTransform:t}=this.component.props;r=t?t(i,r):r.concat(i),Object.defineProperty(r,"__diff",{enumerable:!1,value:[{startRow:o,endRow:r.length}]}),o=r.length,this._setAsyncPropValue(e,r,n)}this._onResolve(e,r)}_postProcessValue(e,t){const i=e.type;return i&&this.component&&(i.release&&i.release(e.resolvedValue,i,this.component),i.transform)?i.transform(t,i,this.component):t}_createAsyncPropData(e,t){if(!this.asyncProps[e]){const i=this.component&&this.component.props[Nx];this.asyncProps[e]={type:i&&i[e],lastValue:null,resolvedValue:t,pendingLoadCount:0,resolvedLoadCount:0}}}}class rS extends nS{constructor({attributeManager:e,layer:t}){super(t),this.attributeManager=e,this.needsRedraw=!0,this.needsUpdate=!0,this.subLayers=null,this.usesPickingColorCache=!1}get layer(){return this.component}_fetch(e,t){const i=this.layer,n=i?.props.fetch;return n?n(t,{propName:e,layer:i}):super._fetch(e,t)}_onResolve(e,t){const i=this.layer;if(i){const n=i.props.onDataLoad;"data"===e&&n&&n(t,{propName:e,layer:i})}}_onError(e,t){const i=this.layer;i&&i.raiseError(t,`loading ${e} of ${this.layer}`)}}const oS=2**24-1,sS=Object.freeze([]),aS=Sy(({oldViewport:e,viewport:t})=>e.equals(t));let lS=new Uint8ClampedArray(0);const cS={data:{type:"data",value:sS,async:!0},dataComparator:{type:"function",value:null,optional:!0},_dataDiff:{type:"function",value:e=>e&&e.__diff,optional:!0},dataTransform:{type:"function",value:null,optional:!0},onDataLoad:{type:"function",value:null,optional:!0},onError:{type:"function",value:null,optional:!0},fetch:{type:"function",value:(e,{propName:t,layer:i,loaders:n,loadOptions:r,signal:o})=>{const{resourceManager:s}=i.context;r=r||i.getLoadOptions(),n=n||i.props.loaders,o&&(r={...r,fetch:{...r?.fetch,signal:o}});let a=s.contains(e);return a||r||(s.add({resourceId:e,data:Fd(e,n),persistent:!1}),a=!0),a?s.subscribe({resourceId:e,onChange:e=>i.internalState?.reloadAsyncProp(t,e),consumerId:i.id,requestId:t}):Fd(e,n,r)}},updateTriggers:{},visible:!0,pickable:!1,opacity:{type:"number",min:0,max:1,value:1},operation:"draw",onHover:{type:"function",value:null,optional:!0},onClick:{type:"function",value:null,optional:!0},onDragStart:{type:"function",value:null,optional:!0},onDrag:{type:"function",value:null,optional:!0},onDragEnd:{type:"function",value:null,optional:!0},coordinateSystem:xy.DEFAULT,coordinateOrigin:{type:"array",value:[0,0,0],compare:!0},modelMatrix:{type:"array",value:null,compare:!0,optional:!0},wrapLongitude:!1,positionFormat:"XYZ",colorFormat:"RGBA",parameters:{type:"object",value:{},optional:!0,compare:2},loadOptions:{type:"object",value:null,optional:!0,ignore:!0},transitions:null,extensions:[],loaders:{type:"array",value:[],optional:!0,ignore:!0},getPolygonOffset:{type:"function",value:({layerIndex:e})=>[0,100*-e]},highlightedObjectIndex:null,autoHighlight:!1,highlightColor:{type:"accessor",value:[0,0,128,128]}};class uS extends tS{constructor(){super(...arguments),this.internalState=null,this.lifecycle=Lx,this.parent=null}static get componentName(){return Object.prototype.hasOwnProperty.call(this,"layerName")?this.layerName:""}get root(){let e=this;for(;e.parent;)e=e.parent;return e}toString(){return`${this.constructor.layerName||this.constructor.name}({id: '${this.props.id}'})`}project(e){ub(this.internalState);const t=this.internalState.viewport||this.context.viewport,i=ex(e,{viewport:t,modelMatrix:this.props.modelMatrix,coordinateOrigin:this.props.coordinateOrigin,coordinateSystem:this.props.coordinateSystem}),[n,r,o]=sv(i,t.pixelProjectionMatrix);return 2===e.length?[n,r]:[n,r,o]}unproject(e){ub(this.internalState);return(this.internalState.viewport||this.context.viewport).unproject(e)}projectPosition(e,t){ub(this.internalState);return tx(e,{viewport:this.internalState.viewport||this.context.viewport,modelMatrix:this.props.modelMatrix,coordinateOrigin:this.props.coordinateOrigin,coordinateSystem:this.props.coordinateSystem,...t})}get isComposite(){return!1}setState(e){this.setChangeFlags({stateChanged:!0}),Object.assign(this.state,e),this.setNeedsRedraw()}setNeedsRedraw(){this.internalState&&(this.internalState.needsRedraw=!0)}setNeedsUpdate(){this.internalState&&(this.context.layerManager.setNeedsUpdate(String(this)),this.internalState.needsUpdate=!0)}get isLoaded(){return!!this.internalState&&!this.internalState.isAsyncPropLoading()}get wrapLongitude(){return this.props.wrapLongitude}isPickable(){return this.props.pickable&&this.props.visible}getModels(){const e=this.state;return e&&(e.models||e.model&&[e.model])||[]}setModuleParameters(e){for(const t of this.getModels())t.updateModuleSettings(e)}setShaderModuleProps(...e){for(const t of this.getModels())t.shaderInputs.setProps(...e)}getAttributeManager(){return this.internalState&&this.internalState.attributeManager}getCurrentLayer(){return this.internalState&&this.internalState.layer}getLoadOptions(){return this.props.loadOptions}use64bitPositions(){const{coordinateSystem:e}=this.props;return e===xy.DEFAULT||e===xy.LNGLAT||e===xy.CARTESIAN}onHover(e,t){return this.props.onHover&&this.props.onHover(e,t)||!1}onClick(e,t){return this.props.onClick&&this.props.onClick(e,t)||!1}nullPickingColor(){return[0,0,0]}encodePickingColor(e,t=[]){return t[0]=e+1&255,t[1]=e+1>>8&255,t[2]=e+1>>8>>8&255,t}decodePickingColor(e){ub(e instanceof Uint8Array);const[t,i,n]=e;return t+256*i+65536*n-1}getNumInstances(){return Number.isFinite(this.props.numInstances)?this.props.numInstances:this.state&&void 0!==this.state.numInstances?this.state.numInstances:UC(this.props.data)}getStartIndices(){return this.props.startIndices?this.props.startIndices:this.state&&this.state.startIndices?this.state.startIndices:null}getBounds(){return this.getAttributeManager()?.getBounds(["positions","instancePositions"])}getShaders(e){e=NC(e,{disableWarnings:!0,modules:this.context.defaultShaderModules});for(const t of this.props.extensions)e=NC(e,t.getShaders.call(this,t));return e}shouldUpdateState(e){return e.changeFlags.propsOrDataChanged}updateState(e){const t=this.getAttributeManager(),{dataChanged:i}=e.changeFlags;if(i&&t)if(Array.isArray(i))for(const e of i)t.invalidateAll(e);else t.invalidateAll();if(t){const{props:i}=e,n=this.internalState.hasPickingBuffer,r=Number.isInteger(i.highlightedObjectIndex)||i.pickable||i.extensions.some(e=>e.getNeedsPickingBuffer.call(this,e));if(n!==r){this.internalState.hasPickingBuffer=r;const{pickingColors:e,instancePickingColors:i}=t.attributes,n=e||i;n&&(r&&n.constant&&(n.constant=!1,t.invalidate(n.id)),n.value||r||(n.constant=!0,n.value=[0,0,0]))}}}finalizeState(e){for(const e of this.getModels())e.destroy();const t=this.getAttributeManager();t&&t.finalize(),this.context&&this.context.resourceManager.unsubscribe({consumerId:this.id}),this.internalState&&(this.internalState.uniformTransitions.clear(),this.internalState.finalize())}draw(e){for(const t of this.getModels())t.draw(e)}getPickingInfo({info:e,mode:t,sourceLayer:i}){const{index:n}=e;return n>=0&&Array.isArray(this.props.data)&&(e.object=this.props.data[n]),e}raiseError(e,t){t&&(e=new Error(`${t}: ${e.message}`,{cause:e})),this.props.onError?.(e)||this.context?.onError?.(e,this)}getNeedsRedraw(e={clearRedrawFlags:!1}){return this._getNeedsRedraw(e)}needsUpdate(){return!!this.internalState&&(this.internalState.needsUpdate||this.hasUniformTransition()||this.shouldUpdateState(this._getUpdateParams()))}hasUniformTransition(){return this.internalState?.uniformTransitions.active||!1}activateViewport(e){if(!this.internalState)return;const t=this.internalState.viewport;this.internalState.viewport=e,t&&aS({oldViewport:t,viewport:e})||(this.setChangeFlags({viewportChanged:!0}),this.isComposite?this.needsUpdate()&&this.setNeedsUpdate():this._update())}invalidateAttribute(e="all"){const t=this.getAttributeManager();t&&("all"===e?t.invalidateAll():t.invalidate(e))}updateAttributes(e){let t=!1;for(const i in e)e[i].layoutChanged()&&(t=!0);for(const i of this.getModels())this._setModelAttributes(i,e,t)}_updateAttributes(){const e=this.getAttributeManager();if(!e)return;const t=this.props,i=this.getNumInstances(),n=this.getStartIndices();e.update({data:t.data,numInstances:i,startIndices:n,props:t,transitions:t.transitions,buffers:t.data.attributes,context:this});const r=e.getChangedAttributes({clearChangedFlags:!0});this.updateAttributes(r)}_updateAttributeTransition(){const e=this.getAttributeManager();e&&e.updateTransition()}_updateUniformTransition(){const{uniformTransitions:e}=this.internalState;if(e.active){const t=e.update(),i=Object.create(this.props);for(const e in t)Object.defineProperty(i,e,{value:t[e]});return i}return this.props}calculateInstancePickingColors(e,{numInstances:t}){if(e.constant)return;const i=Math.floor(lS.length/4);if(this.internalState.usesPickingColorCache=!0,ioS&&rp.warn("Layer has too many data objects. Picking might not be able to distinguish all objects.")(),lS=Ov.allocate(lS,t,{size:4,copy:!0,maxCount:Math.max(t,oS)});const e=Math.floor(lS.length/4),n=[];for(let t=i;t(rp.deprecated("layer.state.attributeManager","layer.getAttributeManager()")(),e)}),this.internalState.uniformTransitions=new RC(this.context.timeline),this.internalState.onAsyncPropUpdated=this._onAsyncPropUpdated.bind(this),this.internalState.setAsyncProps(this.props),this.initializeState(this.context);for(const e of this.props.extensions)e.initializeState.call(this,this.context,e);this.setChangeFlags({dataChanged:"init",propsChanged:"init",viewportChanged:!0,extensionsChanged:!0}),this._update()}_transferState(e){lp("layer.matched",this,this===e);const{state:t,internalState:i}=e;this!==e&&(this.internalState=i,this.state=t,this.internalState.setAsyncProps(this.props),this._diffProps(this.props,this.internalState.getOldProps()))}_update(){const e=this.needsUpdate();if(lp("layer.update",this,e),!e)return;const t=this.props,i=this.context,n=this.internalState,r=i.viewport,o=this._updateUniformTransition();n.propsInTransition=o,i.viewport=n.viewport||r,this.props=o;try{const e=this._getUpdateParams(),t=this.getModels();if(i.device)this.updateState(e);else try{this.updateState(e)}catch(e){}for(const t of this.props.extensions)t.updateState.call(this,e,t);const n=this.getModels()[0]!==t[0];this._postUpdate(e,n)}finally{i.viewport=r,this.props=t,this._clearChangeFlags(),n.needsUpdate=!1,n.resetOldProps()}}_finalize(){lp("layer.finalize",this),this.finalizeState(this.context);for(const e of this.props.extensions)e.finalizeState.call(this,this.context,e)}_drawLayer({renderPass:e,moduleParameters:t=null,uniforms:i={},parameters:n={}}){this._updateAttributeTransition();const r=this.props,o=this.context;this.props=this.internalState.propsInTransition||r;const s=this.props.opacity;i.opacity=Math.pow(s,1/2.2);try{if(t){const{isActive:e,isAttribute:i}=t.picking;this.setModuleParameters(t),this.setShaderModuleProps({picking:{isActive:e,isAttribute:i}})}const{getPolygonOffset:r}=this.props,s=r&&r(i)||[0,0];o.device.setParametersWebGL({polygonOffset:s});for(const e of this.getModels())e.setParameters(n);o.device.withParametersWebGL(n,()=>{const r={renderPass:e,moduleParameters:t,uniforms:i,parameters:n,context:o};for(const e of this.props.extensions)e.draw.call(this,r,e);this.draw(r)})}finally{this.props=r}}getChangeFlags(){return this.internalState?.changeFlags}setChangeFlags(e){if(!this.internalState)return;const{changeFlags:t}=this.internalState;for(const i in e)if(e[i]){let n=!1;if("dataChanged"===i){const r=e[i],o=t[i];r&&Array.isArray(o)&&(t.dataChanged=Array.isArray(r)?o.concat(r):r,n=!0)}t[i]||(t[i]=e[i],n=!0),n&&lp("layer.changeFlag",this,i,e)}const i=Boolean(t.dataChanged||t.updateTriggersChanged||t.propsChanged||t.extensionsChanged);t.propsOrDataChanged=i,t.somethingChanged=i||t.viewportChanged||t.stateChanged}_clearChangeFlags(){this.internalState.changeFlags={dataChanged:!1,propsChanged:!1,updateTriggersChanged:!1,viewportChanged:!1,stateChanged:!1,extensionsChanged:!1,propsOrDataChanged:!1,somethingChanged:!1}}_diffProps(e,t){const i=LC(e,t);if(i.updateTriggersChanged)for(const e in i.updateTriggersChanged)i.updateTriggersChanged[e]&&this.invalidateAttribute(e);if(i.transitionsChanged)for(const n in i.transitionsChanged)this.internalState.uniformTransitions.add(n,t[n],e[n],e.transitions?.[n]);return this.setChangeFlags(i)}validateProps(){!function(e){const t=e[Nx];for(const i in t){const n=t[i],{validate:r}=n;if(r&&!r(e[i],n))throw new Error(`Invalid prop ${i}: ${e[i]}`)}}(this.props)}updateAutoHighlight(e){this.props.autoHighlight&&!Number.isInteger(this.props.highlightedObjectIndex)&&this._updateAutoHighlight(e)}_updateAutoHighlight(e){const t={highlightedObjectColor:e.picked?e.color:null},{highlightColor:i}=this.props;e.picked&&"function"==typeof i&&(t.highlightColor=i(e)),this.setShaderModuleProps({picking:t}),this.setNeedsRedraw()}_getAttributeManager(){const e=this.context;return new SC(e.device,{id:this.props.id,stats:e.stats,timeline:e.timeline})}_postUpdate(e,t){const{props:i,oldProps:n}=e;this.setNeedsRedraw(),this._updateAttributes();const r=this.state.model;r?.isInstanced&&r.setInstanceCount(this.getNumInstances());const{autoHighlight:o,highlightedObjectIndex:s,highlightColor:a}=i;if(t||n.autoHighlight!==o||n.highlightedObjectIndex!==s||n.highlightColor!==a){const e={};Array.isArray(a)&&(e.highlightColor=a),(t||n.autoHighlight!==o||s!==n.highlightedObjectIndex)&&(e.highlightedObjectColor=Number.isFinite(s)&&s>=0?this.encodePickingColor(s):null),this.setShaderModuleProps({picking:e})}}_getUpdateParams(){return{props:this.props,oldProps:this.internalState.getOldProps(),context:this.context,changeFlags:this.internalState.changeFlags}}_getNeedsRedraw(e){if(!this.internalState)return!1;let t=!1;t=t||this.internalState.needsRedraw&&this.id;const i=this.getAttributeManager(),n=!!i&&i.getNeedsRedraw(e);if(t=t||n,t)for(const e of this.props.extensions)e.onNeedsRedraw.call(this,e);return this.internalState.needsRedraw=this.internalState.needsRedraw&&!e.clearRedrawFlags,t}_onAsyncPropUpdated(){this._diffProps(this.props,this.internalState.getOldProps()),this.setNeedsUpdate()}}uS.defaultProps=cS,uS.layerName="Layer";var hS=uS;class dS extends hS{get isComposite(){return!0}get isLoaded(){return super.isLoaded&&this.getSubLayers().every(e=>e.isLoaded)}getSubLayers(){return this.internalState&&this.internalState.subLayers||[]}initializeState(e){}setState(e){super.setState(e),this.setNeedsUpdate()}getPickingInfo({info:e}){const{object:t}=e;return t&&t.__source&&t.__source.parent&&t.__source.parent.id===this.id?(e.object=t.__source.object,e.index=t.__source.index,e):e}filterSubLayer(e){return!0}shouldRenderSubLayer(e,t){return t&&t.length}getSubLayerClass(e,t){const{_subLayerProps:i}=this.props;return i&&i[e]&&i[e].type||t}getSubLayerRow(e,t,i){return e.__source={parent:this,object:t,index:i},e}getSubLayerAccessor(e){if("function"==typeof e){const t={index:-1,data:this.props.data,target:[]};return(i,n)=>i&&i.__source?(t.index=i.__source.index,e(i.__source.object,t)):e(i,n)}return e}getSubLayerProps(e={}){const{opacity:t,pickable:i,visible:n,parameters:r,getPolygonOffset:o,highlightedObjectIndex:s,autoHighlight:a,highlightColor:l,coordinateSystem:c,coordinateOrigin:u,wrapLongitude:h,positionFormat:d,modelMatrix:p,extensions:f,fetch:m,operation:g,_subLayerProps:_}=this.props,A={id:"",updateTriggers:{},opacity:t,pickable:i,visible:n,parameters:r,getPolygonOffset:o,highlightedObjectIndex:s,autoHighlight:a,highlightColor:l,coordinateSystem:c,coordinateOrigin:u,wrapLongitude:h,positionFormat:d,modelMatrix:p,extensions:f,fetch:m,operation:g},y=_&&e.id&&_[e.id],v=y&&y.updateTriggers,x=e.id||"sublayer";if(y){const t=this.props[Nx],i=e.type?e.type._propTypes:{};for(const e in y){const n=i[e]||t[e];n&&"accessor"===n.type&&(y[e]=this.getSubLayerAccessor(y[e]))}}Object.assign(A,e,y),A.id=`${this.props.id}-${x}`,A.updateTriggers={all:this.props.updateTriggers?.all,...e.updateTriggers,...v};for(const e of f){const t=e.getSubLayerProps.call(this,e);t&&Object.assign(A,t,{updateTriggers:Object.assign(A.updateTriggers,t.updateTriggers)})}return A}_updateAutoHighlight(e){for(const t of this.getSubLayers())t.updateAutoHighlight(e)}_getAttributeManager(){return null}_postUpdate(e,t){let i=this.internalState.subLayers;const n=!i||this.needsUpdate();if(n){i=Qx(this.renderLayers(),Boolean),this.internalState.subLayers=i}lp("compositeLayer.renderLayers",this,n,i);for(const e of i)e.parent=this}}dS.layerName="CompositeLayer";var pS=dS;const fS=Math.PI/180,mS=180/Math.PI,gS=6370972,_S=256;function AS(){const e=4018225162502676e-20,t=Math.PI/180*_S;return{unitsPerMeter:[e,e,e],unitsPerMeter2:[0,0,0],metersPerUnit:[24886.609375,24886.609375,24886.609375],unitsPerDegree:[t,t,e],unitsPerDegree2:[0,0,0],degreesPerUnit:[1/t,1/t,24886.609375]}}class yS extends qv{constructor(e={}){const{latitude:t=0,longitude:i=0,zoom:n=0,nearZMultiplier:r=.1,farZMultiplier:o=2,resolution:s=10}=e;let{height:a,altitude:l=1.5}=e;a=a||1,l=Math.max(.75,l);const c=(new HA).lookAt({eye:[0,-l,0],up:[0,0,1]}),u=Math.pow(2,n);c.rotateX(t*fS),c.rotateZ(-i*fS),c.scale(u/a);const h=Math.atan(.5/l),d=512*u/a;super({...e,height:a,viewMatrix:c,longitude:i,latitude:t,zoom:n,distanceScales:AS(),fovyRadians:2*h,focalDistance:l,near:r,far:Math.min(2,1/d+1)*l*o}),this.latitude=t,this.longitude=i,this.resolution=s}get projectionMode(){return by.GLOBE}getDistanceScales(){return this.distanceScales}getBounds(e={}){const t={targetZ:e.z||0},i=this.unproject([0,this.height/2],t),n=this.unproject([this.width/2,0],t),r=this.unproject([this.width,this.height/2],t),o=this.unproject([this.width/2,this.height],t);return r[0]this.longitude&&(i[0]-=360),[Math.min(i[0],r[0],n[0],o[0]),Math.min(i[1],r[1],n[1],o[1]),Math.max(i[0],r[0],n[0],o[0]),Math.max(i[1],r[1],n[1],o[1])]}unproject(e,{topLeft:t=!0,targetZ:i}={}){const[n,r,o]=e,s=t?r:this.height-r,{pixelUnprojectionMatrix:a}=this;let l;if(Number.isFinite(o))l=vS(a,[n,s,o,1]);else{const e=vS(a,[n,s,-1,1]),t=vS(a,[n,s,1,1]),r=((i||0)/gS+1)*_S,o=fA(dA([],e,t)),c=fA(e),u=fA(t),h=4*((4*c*u-(o-c-u)**2)/16)/o;l=function(e,t,i,n){const r=t[0],o=t[1],s=t[2];return e[0]=r+n*(i[0]-r),e[1]=o+n*(i[1]-o),e[2]=s+n*(i[2]-s),e}([],e,t,(Math.sqrt(c-h)-Math.sqrt(Math.max(0,r*r-h)))/Math.sqrt(o))}const[c,u,h]=this.unprojectPosition(l);return Number.isFinite(o)?[c,u,h]:Number.isFinite(i)?[c,u,i]:[c,u]}projectPosition(e){const[t,i,n=0]=e,r=t*fS,o=i*fS,s=Math.cos(o),a=(n/gS+1)*_S;return[Math.sin(r)*s*a,-Math.cos(r)*s*a,Math.sin(o)*a]}unprojectPosition(e){const[t,i,n]=e,r=pA(e),o=Math.asin(n/r);return[Math.atan2(t,-i)*mS,o*mS,(r/_S-1)*gS]}projectFlat(e){return e}unprojectFlat(e){return e}panByPosition(e,t){const i=this.unproject(t);return{longitude:e[0]-i[0]+this.longitude,latitude:e[1]-i[1]+this.latitude}}}function vS(e,t){const i=OA([],t,e);return DA(i,i,1/i[3]),i}const xS=(new HA).lookAt({eye:[0,0,1]});function bS({width:e,height:t,near:i,far:n,padding:r}){let o=-e/2,s=e/2,a=-t/2,l=t/2;if(r){const{left:i=0,right:n=0,top:c=0,bottom:u=0}=r,h=z_((i+e-n)/2,0,e)-e/2,d=z_((c+t-u)/2,0,t)-t/2;o-=h,s-=h,a+=d,l+=d}return(new HA).ortho({left:o,right:s,bottom:a,top:l,near:i,far:n})}class wS extends qv{constructor(e){const{width:t,height:i,near:n=.1,far:r=1e3,zoom:o=0,target:s=[0,0,0],padding:a=null,flipY:l=!0}=e,c=Array.isArray(o)?o[0]:o,u=Array.isArray(o)?o[1]:o,h=Math.min(c,u),d=Math.pow(2,h);let p;if(c!==u){const e=Math.pow(2,c),t=Math.pow(2,u);p={unitsPerMeter:[e/d,t/d,1],metersPerUnit:[d/e,d/t,1]}}super({...e,longitude:void 0,position:s,viewMatrix:xS.clone().scale([d,d*(l?-1:1),d]),projectionMatrix:bS({width:t||1,height:i||1,padding:a,near:n,far:r}),zoom:h,distanceScales:p})}projectFlat([e,t]){const{unitsPerMeter:i}=this.distanceScales;return[e*i[0],t*i[1]]}unprojectFlat([e,t]){const{metersPerUnit:i}=this.distanceScales;return[e*i[0],t*i[1]]}panByPosition(e,t){const i=av(t,this.pixelUnprojectionMatrix),n=q_([],this.projectFlat(e),K_([],i)),r=q_([],this.center,n);return{target:this.unprojectFlat(r)}}}class TS{static get componentName(){return Object.prototype.hasOwnProperty.call(this,"extensionName")?this.extensionName:""}constructor(e){e&&(this.opts=e)}equals(e){return this===e||this.constructor===e.constructor&&Xx(this.opts,e.opts,1)}getShaders(e){return null}getSubLayerProps(e){const{defaultProps:t}=e.constructor,i={updateTriggers:{}};for(const e in t)if(e in this.props){const n=t[e],r=this.props[e];i[e]=r,n&&"accessor"===n.type&&(i.updateTriggers[e]=this.props.updateTriggers[e],"function"==typeof r&&(i[e]=this.getSubLayerAccessor(r)))}return i}initializeState(e,t){}updateState(e,t){}onNeedsRedraw(e){}getNeedsPickingBuffer(e){return!1}draw(e,t){}finalizeState(e,t){}}TS.defaultProps={},TS.extensionName="LayerExtension";var ES=TS;class CS{constructor(e){this.indexStarts=[0],this.vertexStarts=[0],this.vertexCount=0,this.instanceCount=0;const{attributes:t={}}=e;this.typedArrayManager=Ov,this.attributes={},this._attributeDefs=t,this.opts=e,this.updateGeometry(e)}updateGeometry(e){Object.assign(this.opts,e);const{data:t,buffers:i={},getGeometry:n,geometryBuffer:r,positionFormat:o,dataChanged:s,normalize:a=!0}=this.opts;if(this.data=t,this.getGeometry=n,this.positionSize=r&&r.size||("XY"===o?2:3),this.buffers=i,this.normalize=a,r&&(ub(t.startIndices),this.getGeometry=this.getGeometryFromBuffer(r),a||(i.vertexPositions=r)),this.geometryBuffer=i.vertexPositions,Array.isArray(s))for(const e of s)this._rebuildGeometry(e);else this._rebuildGeometry()}updatePartialGeometry({startRow:e,endRow:t}){this._rebuildGeometry({startRow:e,endRow:t})}getGeometryFromBuffer(e){const t=e.value||e;return ArrayBuffer.isView(t)?sC(t,{size:this.positionSize,offset:e.offset,stride:e.stride,startIndices:this.data.startIndices}):null}_allocate(e,t){const{attributes:i,buffers:n,_attributeDefs:r,typedArrayManager:o}=this;for(const s in r)if(s in n)o.release(i[s]),i[s]=null;else{const n=r[s];n.copy=t,i[s]=o.allocate(i[s],e,n)}}_forEachGeometry(e,t,i){const{data:n,getGeometry:r}=this,{iterable:o,objectInfo:s}=rC(n,t,i);for(const t of o){s.index++;e(r?r(t,s):null,s.index)}}_rebuildGeometry(e){if(!this.data)return;let{indexStarts:t,vertexStarts:i,instanceCount:n}=this;const{data:r,geometryBuffer:o}=this,{startRow:s=0,endRow:a=1/0}=e||{},l={};if(e||(t=[0],i=[0]),this.normalize||!o)this._forEachGeometry((e,t)=>{const n=e&&this.normalizeGeometry(e);l[t]=n,i[t+1]=i[t]+(n?this.getGeometrySize(n):0)},s,a),n=i[i.length-1];else if(i=r.startIndices,n=i[r.length]||0,ArrayBuffer.isView(o))n=n||o.length/this.positionSize;else if(o instanceof Xp){const e=4*this.positionSize;n=n||o.byteLength/e}else if(o.buffer){const e=o.stride||4*this.positionSize;n=n||o.buffer.byteLength/e}else if(o.value){const e=o.value,t=o.stride/e.BYTES_PER_ELEMENT||this.positionSize;n=n||e.length/t}this._allocate(n,Boolean(e)),this.indexStarts=t,this.vertexStarts=i,this.instanceCount=n;const c={};this._forEachGeometry((e,r)=>{const o=l[r]||e;c.vertexStart=i[r],c.indexStart=t[r];const s=r{e.triggerRepaint(),n?.("")}});let s;return i&&i.props.gl!==t||(Object.assign(o,{gl:t,width:null,height:null,touchAction:"unset",viewState:LS(e)}),i?.isInitialized?MS(i,e):o.onLoad=()=>{r?.(),MS(s,e)}),i?(s=i,i.setProps(o),i.userData.isExternal=!0):(s=new KE(o),e.on("remove",()=>{PS(e)})),s.userData.mapboxLayers=new Set,e.__deck=s,e.on("render",()=>{s.isInitialized&&function(e,t){const{mapboxLayers:i,isExternal:n}=e.userData;if(n){const n=Array.from(i,e=>e.id),r=Qx(e.props.layers,Boolean).some(e=>e&&!n.includes(e.id));let o=e.getViewports();const s=o.findIndex(e=>"mapbox"===e.id),a=o.length>1||s<0;(r||a)&&(s>=0&&(o=o.slice(),o[s]=FS(e,t,!1)),e._drawLayers("mapbox-repaint",{viewports:o,layerFilter:t=>(!e.props.layerFilter||e.props.layerFilter(t))&&("mapbox"!==t.viewport.id||!n.includes(t.layer.id)),clearCanvas:!1}))}e.userData.currentViewport=null}(s,e)}),s}function MS(e,t){const i=()=>{e.isInitialized?function(e,t){e.setProps({viewState:LS(t)}),e.needsRedraw({clearRedrawFlags:!0})}(e,t):t.off("move",i)};t.on("move",i)}function PS(e){e.__deck?.finalize(),e.__deck=null}function RS(e){return{...e,parameters:{depthMask:!0,depthTest:!0,blend:!0,blendFunc:[770,771,1,771],polygonOffsetFill:!0,depthFunc:515,blendEquation:32774,...e.parameters},views:e.views||[new Ib({id:"mapbox"})]}}function LS(e){const{lng:t,lat:i}=e.getCenter(),n={longitude:(t+540)%360-180,latitude:i,zoom:e.getZoom(),bearing:e.getBearing(),pitch:e.getPitch(),padding:e.getPadding(),repeat:e.getRenderWorldCopies()};return e.getTerrain?.()&&function(e,t){if(e.getFreeCameraOptions){const{position:i}=e.getFreeCameraOptions();if(!i||void 0===i.z)return;const n=e.transform.height,{longitude:r,latitude:o,pitch:s}=t,a=i.x*SS,l=(1-i.y)*SS,c=i.z*SS,u=Jy([r,o]),h=a-u[0],d=l-u[1],p=Math.sqrt(h*h+d*d),f=s*BS,m=1.5*n,g=f<.001?m*Math.cos(f)/c:m*Math.sin(f)/p;t.zoom=Math.log2(g);const _=c-m*Math.cos(f)/g;t.position=[0,0,_/tv(o)]}else"number"==typeof e.transform.elevation&&(t.position=[0,0,e.transform.elevation])}(e,n),n}function FS(e,t,i=!0){return new Xv({id:"mapbox",x:0,y:0,width:e.width,height:e.height,...LS(t),nearZMultiplier:i?.02:.1,nearZ:t.transform._nearZ/t.transform.height,farZ:t.transform._farZ/t.transform.height})}function kS(e){if(e.userData.isExternal)return;const t=[];e.userData.mapboxLayers.forEach(e=>{const i=new(0,e.props.type)(e.props);t.push(i)}),e.setProps({layers:t})}class DS{constructor(e){if(!e.id)throw new Error("Layer must have an unique id");this.id=e.id,this.type="custom",this.renderingMode=e.renderingMode||"3d",this.map=null,this.deck=null,this.props=e}onAdd(e,t){var i,n;this.map=e,this.deck=IS({map:e,gl:t,deck:this.props.deck}),i=this.deck,n=this,i.userData.mapboxLayers.add(n),kS(i)}onRemove(){var e,t;this.deck&&(e=this.deck,t=this,e.userData.mapboxLayers.delete(t),kS(e))}setProps(e){Object.assign(this.props,e,{id:this.id}),this.deck&&kS(this.deck)}render(){!function(e,t,i){let{currentViewport:n}=e.userData,r=!1;n||(n=FS(e,t,!0),e.userData.currentViewport=n,r=!0),e.isInitialized&&e._drawLayers("mapbox-repaint",{viewports:[n],layerFilter:({layer:e})=>i.id===e.id||e.props.operation.includes("terrain"),clearStack:r,clearCanvas:!1})}(this.deck,this.map,this)}}const OS="__UNDEFINED__";function zS(e,t,i,n){if(!(e&&t&&e.style&&e.style._loaded))return;const r=Qx(n,Boolean);if(i!==n){const t=Qx(i,Boolean),n=new Set(t.map(e=>e.id));for(const e of r)n.delete(e.id);for(const t of n)e.getLayer(t)&&e.removeLayer(t)}for(const i of r){const n=e.getLayer(i.id);if(n){(n.implementation||n).setProps(i.props)}else e.addLayer(new DS({id:i.id,deck:t}),i.props.beforeId)}const o=e.style._order,s={};for(const e of r){let{beforeId:t}=e.props;t&&o.includes(t)||(t=OS),s[t]=s[t]||[],s[t].push(e.id)}for(const t in s){const i=s[t];let n=t===OS?o.length:o.indexOf(t),r=t===OS?void 0:t;for(let t=i.length-1;t>=0;t--){const s=i[t],a=o.indexOf(s);a!==n-1&&(e.moveLayer(s,r),a>n&&n++),n--,r=s}}}class US{constructor(e){this._handleStyleChange=()=>{zS(this._map,this._deck,this._props.layers,this._props.layers)},this._updateContainerSize=()=>{if(this._map&&this._container){const{clientWidth:e,clientHeight:t}=this._map.getContainer();Object.assign(this._container.style,{width:`${e}px`,height:`${t}px`})}},this._updateViewState=()=>{const e=this._deck;e&&(e.setProps({viewState:LS(this._map)}),e.isInitialized&&e.redraw())},this._handleMouseEvent=e=>{const t=this._deck;if(!t||!t.isInitialized)return;const i={type:e.type,offsetCenter:e.point,srcEvent:e},n=this._lastMouseDownPoint;switch(!e.point&&n&&(i.deltaX=e.originalEvent.clientX-n.clientX,i.deltaY=e.originalEvent.clientY-n.clientY,i.offsetCenter={x:n.x+i.deltaX,y:n.y+i.deltaY}),i.type){case"mousedown":t._onPointerDown(i),this._lastMouseDownPoint={...e.point,clientX:e.originalEvent.clientX,clientY:e.originalEvent.clientY};break;case"dragstart":i.type="panstart",t._onEvent(i);break;case"drag":i.type="panmove",t._onEvent(i);break;case"dragend":i.type="panend",t._onEvent(i);break;case"click":i.tapCount=1,t._onEvent(i);break;case"dblclick":i.type="click",i.tapCount=2,t._onEvent(i);break;case"mousemove":i.type="pointermove",t._onPointerMove(i);break;case"mouseout":i.type="pointerleave",t._onPointerMove(i);break;default:return}};const{interleaved:t=!1,...i}=e;this._interleaved=t,this._props=i}setProps(e){this._interleaved&&e.layers&&zS(this._map,this._deck,this._props.layers,e.layers),Object.assign(this._props,e),this._deck&&this._deck.setProps(this._interleaved?RS(this._props):this._props)}onAdd(e){return this._map=e,this._interleaved?this._onAddInterleaved(e):this._onAddOverlaid(e)}_onAddOverlaid(e){const t=document.createElement("div");return Object.assign(t.style,{position:"absolute",left:0,top:0,textAlign:"initial",pointerEvents:"none"}),this._container=t,this._deck=new KE({...this._props,parent:t,viewState:LS(e)}),e.on("resize",this._updateContainerSize),e.on("render",this._updateViewState),e.on("mousedown",this._handleMouseEvent),e.on("dragstart",this._handleMouseEvent),e.on("drag",this._handleMouseEvent),e.on("dragend",this._handleMouseEvent),e.on("mousemove",this._handleMouseEvent),e.on("mouseout",this._handleMouseEvent),e.on("click",this._handleMouseEvent),e.on("dblclick",this._handleMouseEvent),this._updateContainerSize(),t}_onAddInterleaved(e){const t=e.painter.context.gl;return t instanceof WebGLRenderingContext&&rp.warn("Incompatible basemap library. See: https://deck.gl/docs/api-reference/mapbox/overview#compatibility")(),this._deck=IS({map:e,gl:t,deck:new KE({...this._props,gl:t})}),e.on("styledata",this._handleStyleChange),zS(e,this._deck,[],this._props.layers),document.createElement("div")}onRemove(){const e=this._map;e&&(this._interleaved?this._onRemoveInterleaved(e):this._onRemoveOverlaid(e)),this._deck=void 0,this._map=void 0,this._container=void 0}_onRemoveOverlaid(e){e.off("resize",this._updateContainerSize),e.off("render",this._updateViewState),e.off("mousedown",this._handleMouseEvent),e.off("dragstart",this._handleMouseEvent),e.off("drag",this._handleMouseEvent),e.off("dragend",this._handleMouseEvent),e.off("mousemove",this._handleMouseEvent),e.off("mouseout",this._handleMouseEvent),e.off("click",this._handleMouseEvent),e.off("dblclick",this._handleMouseEvent),this._deck?.finalize()}_onRemoveInterleaved(e){e.off("styledata",this._handleStyleChange),zS(e,this._deck,this._props.layers,[]),PS(e)}getDefaultPosition(){return"top-left"}pickObject(e){return ub(this._deck),this._deck.pickObject(e)}pickMultipleObjects(e){return ub(this._deck),this._deck.pickMultipleObjects(e)}pickObjects(e){return ub(this._deck),this._deck.pickObjects(e)}finalize(){this._map&&this._map.removeControl(this)}getCanvas(){return this._map?this._interleaved?this._map.getCanvas():this._deck.getCanvas():null}}function NS(e,t){if(!e)throw new Error(t||"loader assertion failed.")}const VS=Boolean("object"!=typeof process||"[object process]"!==String(process)||process.browser),jS="undefined"!=typeof process&&process.version&&/v([0-9]*)/.exec(process.version);function GS(e,t){return HS(e||{},t)}function HS(e,t,i=0){if(i>3)return t;const n={...e};for(const[e,r]of Object.entries(t))r&&"object"==typeof r&&!Array.isArray(r)?n[e]=HS(n[e]||{},t[e],i+1):n[e]=t[e];return n}jS&&parseFloat(jS[1]);const QS=(globalThis._loadersgl_?.version||(globalThis._loadersgl_=globalThis._loadersgl_||{},globalThis._loadersgl_.version="4.2.4"),globalThis._loadersgl_.version);function $S(e,t){if(!e)throw new Error(t||"loaders.gl assertion failed.")}const ZS="object"!=typeof process||"[object process]"!==String(process)||process.browser,WS="function"==typeof importScripts,qS="undefined"!=typeof window&&void 0!==window.orientation,KS="undefined"!=typeof process&&process.version&&/v([0-9]*)/.exec(process.version);KS&&parseFloat(KS[1]);class XS{name;workerThread;isRunning=!0;result;_resolve=()=>{};_reject=()=>{};constructor(e,t){this.name=e,this.workerThread=t,this.result=new Promise((e,t)=>{this._resolve=e,this._reject=t})}postMessage(e,t){this.workerThread.postMessage({source:"loaders.gl",type:e,payload:t})}done(e){$S(this.isRunning),this.isRunning=!1,this._resolve(e)}error(e){$S(this.isRunning),this.isRunning=!1,this._reject(e)}}class JS{terminate(){}}const YS=new Map;function eB(e){$S(e.source&&!e.url||!e.source&&e.url);let t=YS.get(e.source||e.url);return t||(e.url&&(t=function(e){if(!e.startsWith("http"))return e;return tB((t=e,`try {\n importScripts('${t}');\n} catch (error) {\n console.error(error);\n throw error;\n}`));var t}(e.url),YS.set(e.url,t)),e.source&&(t=tB(e.source),YS.set(e.source,t))),$S(t),t}function tB(e){const t=new Blob([e],{type:"application/javascript"});return URL.createObjectURL(t)}function iB(e,t=!0,i){const n=i||new Set;if(e){if(nB(e))n.add(e);else if(nB(e.buffer))n.add(e.buffer);else if(ArrayBuffer.isView(e));else if(t&&"object"==typeof e)for(const i in e)iB(e[i],t,n)}else;return void 0===i?Array.from(n):[]}function nB(e){return!!e&&(e instanceof ArrayBuffer||("undefined"!=typeof MessagePort&&e instanceof MessagePort||("undefined"!=typeof ImageBitmap&&e instanceof ImageBitmap||"undefined"!=typeof OffscreenCanvas&&e instanceof OffscreenCanvas)))}const rB=()=>{};class oB{name;source;url;terminated=!1;worker;onMessage;onError;_loadableURL="";static isSupported(){return"undefined"!=typeof Worker&&ZS||void 0!==JS&&!ZS}constructor(e){const{name:t,source:i,url:n}=e;$S(i||n),this.name=t,this.source=i,this.url=n,this.onMessage=rB,this.onError=e=>console.log(e),this.worker=ZS?this._createBrowserWorker():this._createNodeWorker()}destroy(){this.onMessage=rB,this.onError=rB,this.worker.terminate(),this.terminated=!0}get isRunning(){return Boolean(this.onMessage)}postMessage(e,t){t=t||iB(e),this.worker.postMessage(e,t)}_getErrorFromErrorEvent(e){let t="Failed to load ";return t+=`worker ${this.name} from ${this.url}. `,e.message&&(t+=`${e.message} in `),e.lineno&&(t+=`:${e.lineno}:${e.colno}`),new Error(t)}_createBrowserWorker(){this._loadableURL=eB({source:this.source,url:this.url});const e=new Worker(this._loadableURL,{name:this.name});return e.onmessage=e=>{e.data?this.onMessage(e.data):this.onError(new Error("No data received"))},e.onerror=e=>{this.onError(this._getErrorFromErrorEvent(e)),this.terminated=!0},e.onmessageerror=e=>console.error(e),e}_createNodeWorker(){let e;if(this.url){const t=this.url.includes(":/")||this.url.startsWith("/")?this.url:`./${this.url}`;e=new JS(t,{eval:!1})}else{if(!this.source)throw new Error("no worker");e=new JS(this.source,{eval:!0})}return e.on("message",e=>{this.onMessage(e)}),e.on("error",e=>{this.onError(e)}),e.on("exit",e=>{}),e}}class sB{name="unnamed";source;url;maxConcurrency=1;maxMobileConcurrency=1;onDebug=()=>{};reuseWorkers=!0;props={};jobQueue=[];idleQueue=[];count=0;isDestroyed=!1;static isSupported(){return oB.isSupported()}constructor(e){this.source=e.source,this.url=e.url,this.setProps(e)}destroy(){this.idleQueue.forEach(e=>e.destroy()),this.isDestroyed=!0}setProps(e){this.props={...this.props,...e},void 0!==e.name&&(this.name=e.name),void 0!==e.maxConcurrency&&(this.maxConcurrency=e.maxConcurrency),void 0!==e.maxMobileConcurrency&&(this.maxMobileConcurrency=e.maxMobileConcurrency),void 0!==e.reuseWorkers&&(this.reuseWorkers=e.reuseWorkers),void 0!==e.onDebug&&(this.onDebug=e.onDebug)}async startJob(e,t=(e,t,i)=>e.done(i),i=(e,t)=>e.error(t)){const n=new Promise(n=>(this.jobQueue.push({name:e,onMessage:t,onError:i,onStart:n}),this));return this._startQueuedJob(),await n}async _startQueuedJob(){if(!this.jobQueue.length)return;const e=this._getAvailableWorker();if(!e)return;const t=this.jobQueue.shift();if(t){this.onDebug({message:"Starting job",name:t.name,workerThread:e,backlog:this.jobQueue.length});const i=new XS(t.name,e);e.onMessage=e=>t.onMessage(i,e.type,e.payload),e.onError=e=>t.onError(i,e),t.onStart(i);try{await i.result}catch(e){console.error(`Worker exception: ${e}`)}finally{this.returnWorkerToQueue(e)}}}returnWorkerToQueue(e){!ZS||this.isDestroyed||!this.reuseWorkers||this.count>this._getMaxConcurrency()?(e.destroy(),this.count--):this.idleQueue.push(e),this.isDestroyed||this._startQueuedJob()}_getAvailableWorker(){if(this.idleQueue.length>0)return this.idleQueue.shift()||null;if(this.count{}};class lB{props;workerPools=new Map;static _workerFarm;static isSupported(){return oB.isSupported()}static getWorkerFarm(e={}){return lB._workerFarm=lB._workerFarm||new lB({}),lB._workerFarm.setProps(e),lB._workerFarm}constructor(e){this.props={...aB},this.setProps(e),this.workerPools=new Map}destroy(){for(const e of this.workerPools.values())e.destroy();this.workerPools=new Map}setProps(e){this.props={...this.props,...e};for(const e of this.workerPools.values())e.setProps(this._getWorkerPoolProps())}getWorkerPool(e){const{name:t,source:i,url:n}=e;let r=this.workerPools.get(t);return r||(r=new sB({name:t,source:i,url:n}),r.setProps(this._getWorkerPoolProps()),this.workerPools.set(t,r)),r}_getWorkerPoolProps(){return{maxConcurrency:this.props.maxConcurrency,maxMobileConcurrency:this.props.maxMobileConcurrency,reuseWorkers:this.props.reuseWorkers,onDebug:this.props.onDebug}}}const cB={};async function uB(e,t=null,i={},n=null){return t&&(e=function(e,t,i={},n=null){if(!i.useLocalLibraries&&e.startsWith("http"))return e;n=n||e;const r=i.modules||{};if(r[n])return r[n];if(!ZS)return`modules/${t}/dist/libs/${n}`;if(i.CDN)return $S(i.CDN.startsWith("http")),`${i.CDN}/${t}@${QS}/dist/libs/${n}`;if(WS)return`../src/libs/${n}`;return`modules/${t}/src/libs/${n}`}(e,t,i,n)),cB[e]=cB[e]||async function(e){if(e.endsWith("wasm"))return await async function(e){const{readFileAsArrayBuffer:t}=globalThis.loaders||{};if(ZS||!t||e.startsWith("http")){const t=await fetch(e);return await t.arrayBuffer()}return await t(e)}(e);if(!ZS)try{const{requireFromFile:t}=globalThis.loaders||{};return await(t?.(e))}catch(e){return console.error(e),null}if(WS)return importScripts(e);const t=await async function(e){const{readFileAsText:t}=globalThis.loaders||{};if(ZS||!t||e.startsWith("http")){const t=await fetch(e);return await t.text()}return await t(e)}(e);return function(e,t){if(!ZS){const{requireFromString:i}=globalThis.loaders||{};return i?.(e,t)}if(WS)return eval.call(globalThis,e),null;const i=document.createElement("script");i.id=t;try{i.appendChild(document.createTextNode(e))}catch(t){i.text=e}return document.body.appendChild(i),null}(t,e)}(e),await cB[e]}async function hB(e,t,i,n,r){const o=e.id,s=function(e,t={}){const i=t[e.id]||{},n=ZS?`${e.id}-worker.js`:`${e.id}-worker-node.js`;let r=i.workerUrl;if(r||"compression"!==e.id||(r=t.workerUrl),"test"===t._workerType&&(r=ZS?`modules/${e.module}/dist/${n}`:`modules/${e.module}/src/workers/${e.id}-worker-node.ts`),!r){let t=e.version;"latest"===t&&(t="latest");const i=t?`@${t}`:"";r=`https://unpkg.com/@loaders.gl/${e.module}${i}/dist/${n}`}return $S(r),r}(e,i),a=lB.getWorkerFarm(i).getWorkerPool({name:o,url:s});i=JSON.parse(JSON.stringify(i)),n=JSON.parse(JSON.stringify(n||{}));const l=await a.startJob("process-on-worker",dB.bind(null,r));l.postMessage("process",{input:t,options:i,context:n});const c=await l.result;return await c.result}async function dB(e,t,i,n){switch(i){case"done":t.done(n);break;case"error":t.error(new Error(n.error));break;case"process":const{id:r,input:o,options:s}=n;try{const i=await e(o,s);t.postMessage("done",{id:r,result:i})}catch(e){const i=e instanceof Error?e.message:"unknown error";t.postMessage("error",{id:r,error:i})}break;default:console.warn(`parse-with-worker unknown message ${i}`)}}function pB(...e){return function(e){const t=e.map(e=>e instanceof ArrayBuffer?new Uint8Array(e):e),i=t.reduce((e,t)=>e+t.byteLength,0),n=new Uint8Array(i);let r=0;for(const e of t)n.set(e,r),r+=e.byteLength;return n.buffer}(e)}const fB={};function mB(e){if((t=e)&&"object"==typeof t&&t.isBuffer)return e;var t;if(e instanceof ArrayBuffer)return e;if(ArrayBuffer.isView(e))return 0===e.byteOffset&&e.byteLength===e.buffer.byteLength?e.buffer:e.buffer.slice(e.byteOffset,e.byteOffset+e.byteLength);if("string"==typeof e){const t=e;return(new TextEncoder).encode(t).buffer}if(e&&"object"==typeof e&&e._toArrayBuffer)return e._toArrayBuffer();throw new Error("toArrayBuffer")}function gB(e){const t=e?e.lastIndexOf("/"):-1;return t>=0?e.substr(t+1):""}const _B=e=>"function"==typeof e,AB=e=>null!==e&&"object"==typeof e,yB=e=>AB(e)&&e.constructor==={}.constructor,vB=e=>"undefined"!=typeof Response&&e instanceof Response||e&&e.arrayBuffer&&e.text&&e.json,xB=e=>"undefined"!=typeof Blob&&e instanceof Blob,bB=e=>(e=>"undefined"!=typeof ReadableStream&&e instanceof ReadableStream||AB(e)&&_B(e.tee)&&_B(e.cancel)&&_B(e.getReader))(e)||(e=>AB(e)&&_B(e.read)&&_B(e.pipe)&&(e=>"boolean"==typeof e)(e.readable))(e);class wB extends Error{constructor(e,t){super(e),this.reason=t.reason,this.url=t.url,this.response=t.response}reason;url;response}const TB=/^data:([-\w.]+\/[-\w.+]+)(;|,)/,EB=/^([-\w.]+\/[-\w.+]+)/;function CB(e,t){return e.toLowerCase()===t.toLowerCase()}function SB(e){const t=TB.exec(e);return t?t[1]:""}const BB=/\?.*/;function IB(e){return e.replace(BB,"")}function MB(e){if(vB(e)){return e.url}if(xB(e)){return e.name||""}return"string"==typeof e?e:""}function PB(e){if(vB(e)){const t=e,i=t.headers.get("content-type")||"",n=IB(t.url);return function(e){const t=EB.exec(e);return t?t[1]:e}(i)||SB(n)}if(xB(e)){return e.type||""}return"string"==typeof e?SB(e):""}async function RB(e){if(vB(e))return e;const t={},i=function(e){if(vB(e))return e.headers["content-length"]||-1;if(xB(e))return e.size;return"string"==typeof e?e.length:e instanceof ArrayBuffer||ArrayBuffer.isView(e)?e.byteLength:-1}(e);i>=0&&(t["content-length"]=String(i));const n=MB(e),r=PB(e);r&&(t["content-type"]=r);const o=await async function(e){const t=5;if("string"==typeof e)return`data:,${e.slice(0,t)}`;if(e instanceof Blob){const t=e.slice(0,5);return await new Promise(e=>{const i=new FileReader;i.onload=t=>e(t?.target?.result),i.readAsDataURL(t)})}if(e instanceof ArrayBuffer){const i=function(e){let t="";const i=new Uint8Array(e);for(let e=0;e100?`${i.slice(0,100)}...`:i;const n={reason:e.statusText,url:e.url,response:e};try{const t=e.headers.get("Content-Type");n.reason=t?.includes("application/json")?await e.json():e.text()}catch(e){}return new wB(i,n)}(e);throw t}}async function FB(e,t){if("string"==typeof e){const i=function(e){for(const t in fB)if(e.startsWith(t)){const i=fB[t];e=e.replace(t,i)}return e.startsWith("http://")||e.startsWith("https://")||(e=`${e}`),e}(e);return function(e){return!function(e){return e.startsWith("http:")||e.startsWith("https:")}(e)&&!function(e){return e.startsWith("data:")}(e)}(i)&&globalThis.loaders?.fetchNode?globalThis.loaders?.fetchNode(i,t):await fetch(i,t)}return await RB(e)}const kB=new Gu({id:"loaders.gl"});class DB{log(){return()=>{}}info(){return()=>{}}warn(){return()=>{}}error(){return()=>{}}}const OB={fetch:null,mimeType:void 0,nothrow:!1,log:new class{console;constructor(){this.console=console}log(...e){return this.console.log.bind(this.console,...e)}info(...e){return this.console.info.bind(this.console,...e)}warn(...e){return this.console.warn.bind(this.console,...e)}error(...e){return this.console.error.bind(this.console,...e)}},useLocalLibraries:!1,CDN:"https://unpkg.com/@loaders.gl",worker:!0,maxConcurrency:3,maxMobileConcurrency:1,reuseWorkers:VS,_nodeWorkers:!1,_workerType:"",limit:0,_limitMB:0,batchSize:"auto",batchDebounceMs:0,metadata:!1,transforms:[]},zB={throws:"nothrow",dataType:"(no longer used)",uri:"baseUri",method:"fetch.method",headers:"fetch.headers",body:"fetch.body",mode:"fetch.mode",credentials:"fetch.credentials",cache:"fetch.cache",redirect:"fetch.redirect",referrer:"fetch.referrer",referrerPolicy:"fetch.referrerPolicy",integrity:"fetch.integrity",keepalive:"fetch.keepalive",signal:"fetch.signal"};function UB(){globalThis.loaders=globalThis.loaders||{};const{loaders:e}=globalThis;return e._state||(e._state={}),e._state}function NB(){const e=UB();return e.globalOptions=e.globalOptions||{...OB},e.globalOptions}function VB(e,t,i,n){return i=i||[],function(e,t){jB(e,null,OB,zB,t);for(const i of t){const n=e&&e[i.id]||{},r=i.options&&i.options[i.id]||{},o=i.deprecatedOptions&&i.deprecatedOptions[i.id]||{};jB(n,i.id,r,o,t)}}(e,i=Array.isArray(i)?i:[i]),function(e,t,i){const n=e.options||{},r={...n};(function(e,t){t&&!("baseUri"in e)&&(e.baseUri=t)})(r,i),null===r.log&&(r.log=new DB);return HB(r,NB()),HB(r,t),r}(t,e,n)}function jB(e,t,i,n,r){const o=t||"Top level",s=t?`${t}.`:"";for(const a in e){const l=!t&&AB(e[a]);if(!(a in i)&&!("baseUri"===a&&!t)&&!("workerUrl"===a&&t))if(a in n)kB.warn(`${o} loader option '${s}${a}' no longer supported, use '${n[a]}'`)();else if(!l){const e=GB(a,r);kB.warn(`${o} loader option '${s}${a}' not recognized. ${e}`)()}}}function GB(e,t){const i=e.toLowerCase();let n="";for(const r of t)for(const t in r.options){if(e===t)return`Did you mean '${r.id}.${t}'?`;const o=t.toLowerCase();(i.startsWith(o)||o.startsWith(i))&&(n=n||`Did you mean '${r.id}.${t}'?`)}return n}function HB(e,t){for(const i in t)if(i in t){const n=t[i];yB(n)&&yB(e[i])?e[i]={...e[i],...t[i]}:e[i]=t[i]}}function QB(e){if(!e)return!1;Array.isArray(e)&&(e=e[0]);return Array.isArray(e?.extensions)}function $B(e){let t;return NS(e,"null loader"),NS(QB(e),"invalid loader"),Array.isArray(e)&&(t=e[1],e=e[0],e={...e,options:{...e.options,...t}}),(e?.parseTextSync||e?.parseText)&&(e.text=!0),e.text||(e.binary=!0),e}function ZB(){return(()=>{const e=UB();return e.loaderRegistry=e.loaderRegistry||[],e.loaderRegistry})()}const WB=new Gu({id:"loaders.gl"}),qB=/\.([^.]+)$/;function KB(e,t=[],i,n){if(!XB(e))return null;if(t&&!Array.isArray(t))return $B(t);let r=[];t&&(r=r.concat(t)),i?.ignoreRegisteredLoaders||r.push(...ZB()),function(e){for(const t of e)$B(t)}(r);const o=function(e,t,i,n){const r=MB(e),o=PB(e),s=IB(r)||n?.url;let a=null,l="";i?.mimeType&&(a=YB(t,i?.mimeType),l=`match forced by supplied MIME type ${i?.mimeType}`);a=a||function(e,t){const i=t&&qB.exec(t),n=i&&i[1];return n?function(e,t){t=t.toLowerCase();for(const i of e)for(const e of i.extensions)if(e.toLowerCase()===t)return i;return null}(e,n):null}(t,s),l=l||(a?`matched url ${s}`:""),a=a||YB(t,o),l=l||(a?`matched MIME type ${o}`:""),a=a||function(e,t){if(!t)return null;for(const i of e)if("string"==typeof t){if(eI(t,i))return i}else if(ArrayBuffer.isView(t)){if(tI(t.buffer,t.byteOffset,i))return i}else if(t instanceof ArrayBuffer){if(tI(t,0,i))return i}return null}(t,e),l=l||(a?`matched initial data ${iI(e)}`:""),i?.fallbackMimeType&&(a=a||YB(t,i?.fallbackMimeType),l=l||(a?`matched fallback MIME type ${o}`:""));l&&WB.log(1,`selectLoader selected ${a?.name}: ${l}.`);return a}(e,r,i,n);if(!o&&!i?.nothrow)throw new Error(JB(e));return o}function XB(e){return!(e instanceof Response&&204===e.status)}function JB(e){const t=MB(e),i=PB(e);let n="No valid loader found (";n+=t?`${gB(t)}, `:"no url provided, ",n+=`MIME type: ${i?`"${i}"`:"not provided"}, `;const r=e?iI(e):"";return n+=r?` first bytes: "${r}"`:"first bytes: not available",n+=")",n}function YB(e,t){for(const i of e){if(i.mimeTypes?.some(e=>CB(t,e)))return i;if(CB(t,`application/x.${i.id}`))return i}return null}function eI(e,t){if(t.testText)return t.testText(e);return(Array.isArray(t.tests)?t.tests:[t.tests]).some(t=>e.startsWith(t))}function tI(e,t,i){return(Array.isArray(i.tests)?i.tests:[i.tests]).some(i=>function(e,t,i,n){if(n instanceof ArrayBuffer)return function(e,t,i){if(i=i||e.byteLength,e.byteLengthe&&"object"==typeof e&&e.isBuffer)(e)&&(e=e.buffer),e instanceof ArrayBuffer){const i=e;return t.text&&!t.binary?new TextDecoder("utf8").decode(i):i}if(ArrayBuffer.isView(e)){if(t.text&&!t.binary)return new TextDecoder("utf8").decode(e);let i=e.buffer;const n=e.byteLength||e.length;return 0===e.byteOffset&&n===i.byteLength||(i=i.slice(e.byteOffset,e.byteOffset+n)),i}throw new Error(aI)}(e,t);if(xB(e)&&(e=await RB(e)),vB(e)){const i=e;return await LB(i),t.binary?await i.arrayBuffer():await i.text()}if(bB(e)&&(e=sI(e,i)),(e=>Boolean(e)&&"function"==typeof e[Symbol.iterator])(e)||(e=>e&&"function"==typeof e[Symbol.asyncIterator])(e))return async function(e){const t=[];for await(const i of e)t.push(i);return pB(...t)}(e);throw new Error(aI)}function cI(e,t){const i=NB(),n=e||i;return"function"==typeof n.fetch?n.fetch:AB(n.fetch)?e=>FB(e,n.fetch):t?.fetch?t?.fetch:FB}function uI(e,t,i){if(i)return i;const n={fetch:cI(t,e),...e};if(n.url){const e=IB(n.url);n.baseUrl=e,n.queryString=function(e){const t=e.match(BB);return t&&t[0]}(n.url),n.filename=gB(e),n.baseUrl=function(e){const t=e?e.lastIndexOf("/"):-1;return t>=0?e.substr(0,t):""}(e)}return Array.isArray(n.loaders)||(n.loaders=null),n}async function hI(e,t,i,n){!t||Array.isArray(t)||QB(t)||(n=void 0,i=t,t=void 0),i=i||{};const r=MB(e=await e),o=function(e,t){if(e&&!Array.isArray(e))return e;let i;if(e&&(i=Array.isArray(e)?e:[e]),t&&t.loaders){const e=Array.isArray(t.loaders)?t.loaders:[t.loaders];i=i?[...i,...e]:e}return i&&i.length?i:void 0}(t,n),s=await async function(e,t=[],i,n){if(!XB(e))return null;let r=KB(e,t,{...i,nothrow:!0},n);if(r)return r;if(xB(e)&&(r=KB(e=await e.slice(0,10).arrayBuffer(),t,i,n)),!r&&!i?.nothrow)throw new Error(JB(e));return r}(e,o,i);return s?(n=uI({url:r,_parse:hI,loaders:o},i=VB(i,s,o,r),n||null),await async function(e,t,i,n){if(function(e){$S(e,"no worker provided");const t=e.version}(e),i=GS(e.options,i),vB(t)){const e=t,{ok:i,redirected:r,status:o,statusText:s,type:a,url:l}=e,c=Object.fromEntries(e.headers.entries());n.response={headers:c,ok:i,redirected:r,status:o,statusText:s,type:a,url:l}}t=await lI(t,e,i);const r=e;if(r.parseTextSync&&"string"==typeof t)return r.parseTextSync(t,i,n);if(function(e,t){return!!lB.isSupported()&&!(!ZS&&!t?._nodeWorkers)&&e.worker&&t?.worker}(e,i))return await hB(e,t,i,n,hI);if(r.parseText&&"string"==typeof t)return await r.parseText(t,i,n);if(r.parse)return await r.parse(t,i,n);throw $S(!r.parseSync),new Error(`${e.id} loader - no parser found and worker is disabled`)}(s,e,i,n)):null}async function dI(e,t,i,n){let r,o;Array.isArray(t)||QB(t)?(r=t,o=i):(r=[],o=t);const s=cI(o);let a=e;return"string"==typeof e&&(a=await s(e)),xB(e)&&(a=await s(e)),Array.isArray(r),await hI(a,r,o)}const pI=()=>{},fI={minFilter:"linear",mipmapFilter:"linear",magFilter:"linear",addressModeU:"clamp-to-edge",addressModeV:"clamp-to-edge"},mI={x:0,y:0,width:0,height:0};function gI(e,t,i,n){const r=Math.min(i/t.width,n/t.height),o=Math.floor(t.width*r),s=Math.floor(t.height*r);return 1===r?{data:t,width:o,height:s}:(e.canvas.height=s,e.canvas.width=o,e.clearRect(0,0,o,s),e.drawImage(t,0,0,t.width,t.height,0,0,o,s),{data:e.canvas,width:o,height:s})}function _I(e){return e&&(e.id||e.url)}function AI(e,t,i){for(let n=0;n0){const{mapping:e,xOffset:t,yOffset:n,rowHeight:r,canvasHeight:o}=function({icons:e,buffer:t,mapping:i={},xOffset:n=0,yOffset:r=0,rowHeight:o=0,canvasWidth:s}){let a=[];for(let l=0;ls&&(AI(i,a,r),n=0,r=o+r+t,o=0,a=[]),a.push({icon:c,xOffset:n}),n=n+l+t,o=Math.max(o,e)}}return a.length>0&&AI(i,a,r),{mapping:i,rowHeight:o,xOffset:n,yOffset:r,canvasWidth:s,canvasHeight:(l=o+r+t,Math.pow(2,Math.ceil(Math.log2(l))))};var l}({icons:i,buffer:this._buffer,canvasWidth:this._canvasWidth,mapping:this._mapping,rowHeight:this._rowHeight,xOffset:this._xOffset,yOffset:this._yOffset});this._rowHeight=r,this._mapping=e,this._xOffset=t,this._yOffset=n,this._canvasHeight=o,this._texture||(this._texture=this.device.createTexture({format:"rgba8unorm",width:this._canvasWidth,height:this._canvasHeight,sampler:this._textureParameters||fI})),this._texture.height!==this._canvasHeight&&(this._texture=function(e,t,i,n){const{width:r,height:o,device:s}=e,a=s.createTexture({format:"rgba8unorm",width:t,height:i,sampler:n}),l=s.createCommandEncoder();return l.copyTextureToTexture({source:e,destination:a,width:r,height:o}),l.finish(),e.destroy(),a}(this._texture,this._canvasWidth,this._canvasHeight,this._textureParameters||fI)),this.onUpdate(),this._canvas=this._canvas||document.createElement("canvas"),this._loadIcons(i)}}_loadIcons(e){const t=this._canvas.getContext("2d",{willReadFrequently:!0});for(const i of e)this._pendingCount++,dI(i.url,this._loadOptions).then(e=>{const n=_I(i),r=this._mapping[n],{x:o,y:s,width:a,height:l}=r,{data:c,width:u,height:h}=gI(t,e,a,l);this._texture.setSubImageData({data:c,x:o+(a-u)/2,y:s+(l-h)/2,width:u,height:h}),r.width=u,r.height=h,this._texture.generateMipmap(),this.onUpdate()}).catch(e=>{this.onError({url:i.url,source:i.source,sourceIndex:i.sourceIndex,loadOptions:this._loadOptions,error:e})}).finally(()=>{this._pendingCount--})}}const vI=[0,0,0,255],xI={iconAtlas:{type:"image",value:null,async:!0},iconMapping:{type:"object",value:{},async:!0},sizeScale:{type:"number",value:1,min:0},billboard:!0,sizeUnits:"pixels",sizeMinPixels:{type:"number",min:0,value:0},sizeMaxPixels:{type:"number",min:0,value:Number.MAX_SAFE_INTEGER},alphaCutoff:{type:"number",value:.05,min:0,max:1},getPosition:{type:"accessor",value:e=>e.position},getIcon:{type:"accessor",value:e=>e.icon},getColor:{type:"accessor",value:vI},getSize:{type:"accessor",value:1},getAngle:{type:"accessor",value:0},getPixelOffset:{type:"accessor",value:[0,0]},onIconError:{type:"function",value:null,optional:!0},textureParameters:{type:"object",ignore:!0,value:null}};class bI extends hS{getShaders(){return super.getShaders({vs:"#version 300 es\n#define SHADER_NAME icon-layer-vertex-shader\nin vec2 positions;\nin vec3 instancePositions;\nin vec3 instancePositions64Low;\nin float instanceSizes;\nin float instanceAngles;\nin vec4 instanceColors;\nin vec3 instancePickingColors;\nin vec4 instanceIconFrames;\nin float instanceColorModes;\nin vec2 instanceOffsets;\nin vec2 instancePixelOffset;\nuniform float sizeScale;\nuniform vec2 iconsTextureDim;\nuniform float sizeMinPixels;\nuniform float sizeMaxPixels;\nuniform bool billboard;\nuniform int sizeUnits;\nout float vColorMode;\nout vec4 vColor;\nout vec2 vTextureCoords;\nout vec2 uv;\nvec2 rotate_by_angle(vec2 vertex, float angle) {\nfloat angle_radian = angle * PI / 180.0;\nfloat cos_angle = cos(angle_radian);\nfloat sin_angle = sin(angle_radian);\nmat2 rotationMatrix = mat2(cos_angle, -sin_angle, sin_angle, cos_angle);\nreturn rotationMatrix * vertex;\n}\nvoid main(void) {\ngeometry.worldPosition = instancePositions;\ngeometry.uv = positions;\ngeometry.pickingColor = instancePickingColors;\nuv = positions;\nvec2 iconSize = instanceIconFrames.zw;\nfloat sizePixels = clamp(\nproject_size_to_pixel(instanceSizes * sizeScale, sizeUnits),\nsizeMinPixels, sizeMaxPixels\n);\nfloat instanceScale = iconSize.y == 0.0 ? 0.0 : sizePixels / iconSize.y;\nvec2 pixelOffset = positions / 2.0 * iconSize + instanceOffsets;\npixelOffset = rotate_by_angle(pixelOffset, instanceAngles) * instanceScale;\npixelOffset += instancePixelOffset;\npixelOffset.y *= -1.0;\nif (billboard) {\ngl_Position = project_position_to_clipspace(instancePositions, instancePositions64Low, vec3(0.0), geometry.position);\nDECKGL_FILTER_GL_POSITION(gl_Position, geometry);\nvec3 offset = vec3(pixelOffset, 0.0);\nDECKGL_FILTER_SIZE(offset, geometry);\ngl_Position.xy += project_pixel_size_to_clipspace(offset.xy);\n} else {\nvec3 offset_common = vec3(project_pixel_size(pixelOffset), 0.0);\nDECKGL_FILTER_SIZE(offset_common, geometry);\ngl_Position = project_position_to_clipspace(instancePositions, instancePositions64Low, offset_common, geometry.position);\nDECKGL_FILTER_GL_POSITION(gl_Position, geometry);\n}\nvTextureCoords = mix(\ninstanceIconFrames.xy,\ninstanceIconFrames.xy + iconSize,\n(positions.xy + 1.0) / 2.0\n) / iconsTextureDim;\nvColor = instanceColors;\nDECKGL_FILTER_COLOR(vColor, geometry);\nvColorMode = instanceColorModes;\n}\n",fs:"#version 300 es\n#define SHADER_NAME icon-layer-fragment-shader\nprecision highp float;\nuniform float opacity;\nuniform sampler2D iconsTexture;\nuniform float alphaCutoff;\nin float vColorMode;\nin vec4 vColor;\nin vec2 vTextureCoords;\nin vec2 uv;\nout vec4 fragColor;\nvoid main(void) {\ngeometry.uv = uv;\nvec4 texColor = texture(iconsTexture, vTextureCoords);\nvec3 color = mix(texColor.rgb, vColor.rgb, vColorMode);\nfloat a = texColor.a * opacity * vColor.a;\nif (a < alphaCutoff) {\ndiscard;\n}\nfragColor = vec4(color, a);\nDECKGL_FILTER_COLOR(fragColor, geometry);\n}\n",modules:[zy,gv]})}initializeState(){this.state={iconManager:new yI(this.context.device,{onUpdate:this._onUpdate.bind(this),onError:this._onError.bind(this)})};this.getAttributeManager().addInstanced({instancePositions:{size:3,type:"float64",fp64:this.use64bitPositions(),transition:!0,accessor:"getPosition"},instanceSizes:{size:1,transition:!0,accessor:"getSize",defaultValue:1},instanceOffsets:{size:2,accessor:"getIcon",transform:this.getInstanceOffset},instanceIconFrames:{size:4,accessor:"getIcon",transform:this.getInstanceIconFrame},instanceColorModes:{size:1,type:"uint8",accessor:"getIcon",transform:this.getInstanceColorMode},instanceColors:{size:this.props.colorFormat.length,type:"unorm8",transition:!0,accessor:"getColor",defaultValue:vI},instanceAngles:{size:1,transition:!0,accessor:"getAngle"},instancePixelOffset:{size:2,transition:!0,accessor:"getPixelOffset"}})}updateState(e){super.updateState(e);const{props:t,oldProps:i,changeFlags:n}=e,r=this.getAttributeManager(),{iconAtlas:o,iconMapping:s,data:a,getIcon:l,textureParameters:c}=t,{iconManager:u}=this.state;if("string"==typeof o)return;const h=o||this.internalState.isAsyncPropLoading("iconAtlas");u.setProps({loadOptions:t.loadOptions,autoPacking:!h,iconAtlas:o,iconMapping:h?s:null,textureParameters:c}),h?i.iconMapping!==t.iconMapping&&r.invalidate("getIcon"):(n.dataChanged||n.updateTriggersChanged&&(n.updateTriggersChanged.all||n.updateTriggersChanged.getIcon))&&u.packIcons(a,l),n.extensionsChanged&&(this.state.model?.destroy(),this.state.model=this._getModel(),r.invalidateAll())}get isLoaded(){return super.isLoaded&&this.state.iconManager.isLoaded}finalizeState(e){super.finalizeState(e),this.state.iconManager.finalize()}draw({uniforms:e}){const{sizeScale:t,sizeMinPixels:i,sizeMaxPixels:n,sizeUnits:r,billboard:o,alphaCutoff:s}=this.props,{iconManager:a}=this.state,l=a.getTexture();if(l){const a=this.state.model;a.setBindings({iconsTexture:l}),a.setUniforms(e),a.setUniforms({iconsTextureDim:[l.width,l.height],sizeUnits:wy[r],sizeScale:t,sizeMinPixels:i,sizeMaxPixels:n,billboard:o,alphaCutoff:s}),a.draw(this.context.renderPass)}}_getModel(){return new bx(this.context.device,{...this.getShaders(),id:this.props.id,bufferLayout:this.getAttributeManager().getBufferLayouts(),geometry:new Cx({topology:"triangle-strip",attributes:{positions:{size:2,value:new Float32Array([-1,-1,1,-1,-1,1,1,1])}}}),isInstanced:!0})}_onUpdate(){this.setNeedsRedraw()}_onError(e){const t=this.getCurrentLayer()?.props.onIconError;t?t(e):rp.error(e.error.message)()}getInstanceOffset(e){const{width:t,height:i,anchorX:n=t/2,anchorY:r=i/2}=this.state.iconManager.getIconMapping(e);return[t/2-n,i/2-r]}getInstanceColorMode(e){return this.state.iconManager.getIconMapping(e).mask?1:0}getInstanceIconFrame(e){const{x:t,y:i,width:n,height:r}=this.state.iconManager.getIconMapping(e);return[t,i,n,r]}}bI.defaultProps=xI,bI.layerName="IconLayer";var wI=bI;const TI=[0,0,0,255],EI=[0,0,1],CI={sizeUnits:"pixels",pointSize:{type:"number",min:0,value:10},getPosition:{type:"accessor",value:e=>e.position},getNormal:{type:"accessor",value:EI},getColor:{type:"accessor",value:TI},material:!0,radiusPixels:{deprecatedFor:"pointSize"}};class SI extends hS{getShaders(){return super.getShaders({vs:"#version 300 es\n#define SHADER_NAME point-cloud-layer-vertex-shader\nin vec3 positions;\nin vec3 instanceNormals;\nin vec4 instanceColors;\nin vec3 instancePositions;\nin vec3 instancePositions64Low;\nin vec3 instancePickingColors;\nuniform float opacity;\nuniform float radiusPixels;\nuniform int sizeUnits;\nout vec4 vColor;\nout vec2 unitPosition;\nvoid main(void) {\ngeometry.worldPosition = instancePositions;\ngeometry.normal = project_normal(instanceNormals);\nunitPosition = positions.xy;\ngeometry.uv = unitPosition;\ngeometry.pickingColor = instancePickingColors;\nvec3 offset = vec3(positions.xy * project_size_to_pixel(radiusPixels, sizeUnits), 0.0);\nDECKGL_FILTER_SIZE(offset, geometry);\ngl_Position = project_position_to_clipspace(instancePositions, instancePositions64Low, vec3(0.), geometry.position);\nDECKGL_FILTER_GL_POSITION(gl_Position, geometry);\ngl_Position.xy += project_pixel_size_to_clipspace(offset.xy);\nvec3 lightColor = lighting_getLightColor(instanceColors.rgb, project_uCameraPosition, geometry.position.xyz, geometry.normal);\nvColor = vec4(lightColor, instanceColors.a * opacity);\nDECKGL_FILTER_COLOR(vColor, geometry);\n}\n",fs:"#version 300 es\n#define SHADER_NAME point-cloud-layer-fragment-shader\nprecision highp float;\nin vec4 vColor;\nin vec2 unitPosition;\nout vec4 fragColor;\nvoid main(void) {\ngeometry.uv = unitPosition;\nfloat distToCenter = length(unitPosition);\nif (distToCenter > 1.0) {\ndiscard;\n}\nfragColor = vColor;\nDECKGL_FILTER_COLOR(fragColor, geometry);\n}\n",modules:[zy,gy,gv]})}initializeState(){this.getAttributeManager().addInstanced({instancePositions:{size:3,type:"float64",fp64:this.use64bitPositions(),transition:!0,accessor:"getPosition"},instanceNormals:{size:3,transition:!0,accessor:"getNormal",defaultValue:EI},instanceColors:{size:this.props.colorFormat.length,type:"unorm8",transition:!0,accessor:"getColor",defaultValue:TI}})}updateState(e){const{changeFlags:t,props:i}=e;super.updateState(e),t.extensionsChanged&&(this.state.model?.destroy(),this.state.model=this._getModel(),this.getAttributeManager().invalidateAll()),t.dataChanged&&function(e){const{header:t,attributes:i}=e;if(t&&i&&(e.length=t.vertexCount,i.POSITION&&(i.instancePositions=i.POSITION),i.NORMAL&&(i.instanceNormals=i.NORMAL),i.COLOR_0)){const{size:e,value:t}=i.COLOR_0;i.instanceColors={size:e,type:"unorm8",value:t}}}(i.data)}draw({uniforms:e}){const{pointSize:t,sizeUnits:i}=this.props,n=this.state.model;n.setUniforms(e),n.setUniforms({sizeUnits:wy[i],radiusPixels:t}),n.draw(this.context.renderPass)}_getModel(){const e=[];for(let t=0;t<3;t++){const i=t/3*Math.PI*2;e.push(2*Math.cos(i),2*Math.sin(i),0)}return new bx(this.context.device,{...this.getShaders(),id:this.props.id,bufferLayout:this.getAttributeManager().getBufferLayouts(),geometry:new Cx({topology:"triangle-list",attributes:{positions:new Float32Array(e)}}),isInstanced:!0})}}SI.layerName="PointCloudLayer",SI.defaultProps=CI;var BI=SI;const II=[0,0,0,255],MI={radiusUnits:"meters",radiusScale:{type:"number",min:0,value:1},radiusMinPixels:{type:"number",min:0,value:0},radiusMaxPixels:{type:"number",min:0,value:Number.MAX_SAFE_INTEGER},lineWidthUnits:"meters",lineWidthScale:{type:"number",min:0,value:1},lineWidthMinPixels:{type:"number",min:0,value:0},lineWidthMaxPixels:{type:"number",min:0,value:Number.MAX_SAFE_INTEGER},stroked:!1,filled:!0,billboard:!1,antialiasing:!0,getPosition:{type:"accessor",value:e=>e.position},getRadius:{type:"accessor",value:1},getFillColor:{type:"accessor",value:II},getLineColor:{type:"accessor",value:II},getLineWidth:{type:"accessor",value:1},strokeWidth:{deprecatedFor:"getLineWidth"},outline:{deprecatedFor:"stroked"},getColor:{deprecatedFor:["getFillColor","getLineColor"]}};class PI extends hS{getShaders(){return super.getShaders({vs:"#version 300 es\n#define SHADER_NAME scatterplot-layer-vertex-shader\nin vec3 positions;\nin vec3 instancePositions;\nin vec3 instancePositions64Low;\nin float instanceRadius;\nin float instanceLineWidths;\nin vec4 instanceFillColors;\nin vec4 instanceLineColors;\nin vec3 instancePickingColors;\nuniform float opacity;\nuniform float radiusScale;\nuniform float radiusMinPixels;\nuniform float radiusMaxPixels;\nuniform float lineWidthScale;\nuniform float lineWidthMinPixels;\nuniform float lineWidthMaxPixels;\nuniform float stroked;\nuniform bool filled;\nuniform bool antialiasing;\nuniform bool billboard;\nuniform int radiusUnits;\nuniform int lineWidthUnits;\nout vec4 vFillColor;\nout vec4 vLineColor;\nout vec2 unitPosition;\nout float innerUnitRadius;\nout float outerRadiusPixels;\nvoid main(void) {\ngeometry.worldPosition = instancePositions;\nouterRadiusPixels = clamp(\nproject_size_to_pixel(radiusScale * instanceRadius, radiusUnits),\nradiusMinPixels, radiusMaxPixels\n);\nfloat lineWidthPixels = clamp(\nproject_size_to_pixel(lineWidthScale * instanceLineWidths, lineWidthUnits),\nlineWidthMinPixels, lineWidthMaxPixels\n);\nouterRadiusPixels += stroked * lineWidthPixels / 2.0;\nfloat edgePadding = antialiasing ? (outerRadiusPixels + SMOOTH_EDGE_RADIUS) / outerRadiusPixels : 1.0;\nunitPosition = edgePadding * positions.xy;\ngeometry.uv = unitPosition;\ngeometry.pickingColor = instancePickingColors;\ninnerUnitRadius = 1.0 - stroked * lineWidthPixels / outerRadiusPixels;\nif (billboard) {\ngl_Position = project_position_to_clipspace(instancePositions, instancePositions64Low, vec3(0.0), geometry.position);\nDECKGL_FILTER_GL_POSITION(gl_Position, geometry);\nvec3 offset = edgePadding * positions * outerRadiusPixels;\nDECKGL_FILTER_SIZE(offset, geometry);\ngl_Position.xy += project_pixel_size_to_clipspace(offset.xy);\n} else {\nvec3 offset = edgePadding * positions * project_pixel_size(outerRadiusPixels);\nDECKGL_FILTER_SIZE(offset, geometry);\ngl_Position = project_position_to_clipspace(instancePositions, instancePositions64Low, offset, geometry.position);\nDECKGL_FILTER_GL_POSITION(gl_Position, geometry);\n}\nvFillColor = vec4(instanceFillColors.rgb, instanceFillColors.a * opacity);\nDECKGL_FILTER_COLOR(vFillColor, geometry);\nvLineColor = vec4(instanceLineColors.rgb, instanceLineColors.a * opacity);\nDECKGL_FILTER_COLOR(vLineColor, geometry);\n}\n",fs:"#version 300 es\n#define SHADER_NAME scatterplot-layer-fragment-shader\nprecision highp float;\nuniform bool filled;\nuniform float stroked;\nuniform bool antialiasing;\nin vec4 vFillColor;\nin vec4 vLineColor;\nin vec2 unitPosition;\nin float innerUnitRadius;\nin float outerRadiusPixels;\nout vec4 fragColor;\nvoid main(void) {\ngeometry.uv = unitPosition;\nfloat distToCenter = length(unitPosition) * outerRadiusPixels;\nfloat inCircle = antialiasing ?\nsmoothedge(distToCenter, outerRadiusPixels) :\nstep(distToCenter, outerRadiusPixels);\nif (inCircle == 0.0) {\ndiscard;\n}\nif (stroked > 0.5) {\nfloat isLine = antialiasing ?\nsmoothedge(innerUnitRadius * outerRadiusPixels, distToCenter) :\nstep(innerUnitRadius * outerRadiusPixels, distToCenter);\nif (filled) {\nfragColor = mix(vFillColor, vLineColor, isLine);\n} else {\nif (isLine == 0.0) {\ndiscard;\n}\nfragColor = vec4(vLineColor.rgb, vLineColor.a * isLine);\n}\n} else if (!filled) {\ndiscard;\n} else {\nfragColor = vFillColor;\n}\nfragColor.a *= inCircle;\nDECKGL_FILTER_COLOR(fragColor, geometry);\n}\n",modules:[zy,gv]})}initializeState(){this.getAttributeManager().addInstanced({instancePositions:{size:3,type:"float64",fp64:this.use64bitPositions(),transition:!0,accessor:"getPosition"},instanceRadius:{size:1,transition:!0,accessor:"getRadius",defaultValue:1},instanceFillColors:{size:this.props.colorFormat.length,transition:!0,type:"unorm8",accessor:"getFillColor",defaultValue:[0,0,0,255]},instanceLineColors:{size:this.props.colorFormat.length,transition:!0,type:"unorm8",accessor:"getLineColor",defaultValue:[0,0,0,255]},instanceLineWidths:{size:1,transition:!0,accessor:"getLineWidth",defaultValue:1}})}updateState(e){super.updateState(e),e.changeFlags.extensionsChanged&&(this.state.model?.destroy(),this.state.model=this._getModel(),this.getAttributeManager().invalidateAll())}draw({uniforms:e}){const{radiusUnits:t,radiusScale:i,radiusMinPixels:n,radiusMaxPixels:r,stroked:o,filled:s,billboard:a,antialiasing:l,lineWidthUnits:c,lineWidthScale:u,lineWidthMinPixels:h,lineWidthMaxPixels:d}=this.props,p=this.state.model;p.setUniforms(e),p.setUniforms({stroked:o?1:0,filled:s,billboard:a,antialiasing:l,radiusUnits:wy[t],radiusScale:i,radiusMinPixels:n,radiusMaxPixels:r,lineWidthUnits:wy[c],lineWidthScale:u,lineWidthMinPixels:h,lineWidthMaxPixels:d}),p.draw(this.context.renderPass)}_getModel(){return new bx(this.context.device,{...this.getShaders(),id:this.props.id,bufferLayout:this.getAttributeManager().getBufferLayouts(),geometry:new Cx({topology:"triangle-strip",attributes:{positions:{size:3,value:new Float32Array([-1,-1,0,1,-1,0,-1,1,0,1,1,0])}}}),isInstanced:!0})}}PI.defaultProps=MI,PI.layerName="ScatterplotLayer";var RI=PI;const LI=1,FI=-1;function kI(e,t,i={}){const n=function(e,t={}){return Math.sign(function(e,t={}){const{start:i=0,end:n=e.length,plane:r="xy"}=t,o=t.size||2;let s=0;const a=DI[r[0]],l=DI[r[1]];for(let t=i,r=n-o;t0){let r=!0;for(let o=0;ot[2]&&(i|=2),e[1]t[3]&&(i|=8),i}function jI(e,t){const{size:i=2,broken:n=!1,gridResolution:r=10,gridOffset:o=[0,0],startIndex:s=0,endIndex:a=e.length}=t||{},l=(a-s)/i;let c=[];const u=[c],h=UI(e,0,i,s);let d,p;const f=QI(h,r,o,[]),m=[];OI(c,h);for(let t=1;ti&&(c=[],u.push(c),OI(c,h)),p=VI(d,f)}OI(c,d),zI(h,d)}return n?u:u[0]}function GI(e,t=null,i){if(!e.length)return[];const{size:n=2,gridResolution:r=10,gridOffset:o=[0,0],edgeTypes:s=!1}=i||{},a=[],l=[{pos:e,types:s?new Array(e.length/n).fill(1):null,holes:t||[]}],c=[[],[]];let u=[];for(;l.length;){const{pos:e,types:t,holes:i}=l.shift();ZI(e,n,i[0]||e.length,c),u=QI(c[0],r,o,u);const h=VI(c[1],u);if(h){let r=HI(e,t,n,0,i[0]||e.length,u,h);const o={pos:r[0].pos,types:r[0].types,holes:[]},a={pos:r[1].pos,types:r[1].types,holes:[]};l.push(o,a);for(let l=0;l=0?(OI(c,p)&&h.push(m),v+=f):h.length&&(h[h.length-1]=0),zI(g,p),_=f,A=m;return[y?{pos:l,types:t&&u}:null,v?{pos:c,types:t&&h}:null]}function QI(e,t,i,n){const r=Math.floor((e[0]-i[0])/t)*t+i[0],o=Math.floor((e[1]-i[1])/t)*t+i[1];return n[0]=r,n[1]=o,n[2]=r+t,n[3]=o+t,n}function $I(e,t,i){8&i?(e[1]+=t,e[3]+=t):4&i?(e[1]-=t,e[3]-=t):2&i?(e[0]+=t,e[2]+=t):1&i&&(e[0]-=t,e[2]-=t)}function ZI(e,t,i,n){let r=1/0,o=-1/0,s=1/0,a=-1/0;for(let n=0;no?t:o,s=ia?i:a}return n[0][0]=r,n[0][1]=s,n[1][0]=o,n[1][1]=a,n}function WI(e,t){for(let i=0;ir&&(r=t,o=s-1)}return o}function KI(e,t,i,n,r=85.051129){const o=e[i],s=e[n-t];if(Math.abs(o-s)>180){const n=UI(e,0,t,i);n[0]+=360*Math.round((s-o)/360),OI(e,n),n[1]=Math.sign(n[1])*r,OI(e,n),n[0]=o,OI(e,n)}}function XI(e,t,i,n){let r,o=e[0];for(let s=i;s180||t<-180)&&(r-=360*Math.round(t/360)),e[s]=o=r}}function JI(e,t){let i;const n=e.length/t;for(let r=0;r=e.length&&(t+=1-e.length/n);const r=t*n;return i[0]=e[r],i[1]=e[r+1],i[2]=3===n&&e[r+2]||0,i}isClosed(e){if(!this.normalize)return Boolean(this.opts.loop);const{positionSize:t}=this,i=e.length-t;return e[0]===e[i]&&e[1]===e[i+1]&&(2===t||e[2]===e[i+2])}}function tM(e){return Array.isArray(e[0])}const iM=[0,0,0,255],nM={widthUnits:"meters",widthScale:{type:"number",min:0,value:1},widthMinPixels:{type:"number",min:0,value:0},widthMaxPixels:{type:"number",min:0,value:Number.MAX_SAFE_INTEGER},jointRounded:!1,capRounded:!1,miterLimit:{type:"number",min:0,value:4},billboard:!1,_pathType:null,getPath:{type:"accessor",value:e=>e.path},getColor:{type:"accessor",value:iM},getWidth:{type:"accessor",value:1},rounded:{deprecatedFor:["jointRounded","capRounded"]}},rM={enter:(e,t)=>t.length?t.subarray(t.length-e.length):e};class oM extends hS{getShaders(){return super.getShaders({vs:"#version 300 es\n#define SHADER_NAME path-layer-vertex-shader\nin vec2 positions;\nin float instanceTypes;\nin vec3 instanceStartPositions;\nin vec3 instanceEndPositions;\nin vec3 instanceLeftPositions;\nin vec3 instanceRightPositions;\nin vec3 instanceLeftPositions64Low;\nin vec3 instanceStartPositions64Low;\nin vec3 instanceEndPositions64Low;\nin vec3 instanceRightPositions64Low;\nin float instanceStrokeWidths;\nin vec4 instanceColors;\nin vec3 instancePickingColors;\nuniform float widthScale;\nuniform float widthMinPixels;\nuniform float widthMaxPixels;\nuniform float jointType;\nuniform float capType;\nuniform float miterLimit;\nuniform bool billboard;\nuniform int widthUnits;\nuniform float opacity;\nout vec4 vColor;\nout vec2 vCornerOffset;\nout float vMiterLength;\nout vec2 vPathPosition;\nout float vPathLength;\nout float vJointType;\nconst float EPSILON = 0.001;\nconst vec3 ZERO_OFFSET = vec3(0.0);\nfloat flipIfTrue(bool flag) {\nreturn -(float(flag) * 2. - 1.);\n}\nvec3 getLineJoinOffset(\nvec3 prevPoint, vec3 currPoint, vec3 nextPoint,\nvec2 width\n) {\nbool isEnd = positions.x > 0.0;\nfloat sideOfPath = positions.y;\nfloat isJoint = float(sideOfPath == 0.0);\nvec3 deltaA3 = (currPoint - prevPoint);\nvec3 deltaB3 = (nextPoint - currPoint);\nmat3 rotationMatrix;\nbool needsRotation = !billboard && project_needs_rotation(currPoint, rotationMatrix);\nif (needsRotation) {\ndeltaA3 = deltaA3 * rotationMatrix;\ndeltaB3 = deltaB3 * rotationMatrix;\n}\nvec2 deltaA = deltaA3.xy / width;\nvec2 deltaB = deltaB3.xy / width;\nfloat lenA = length(deltaA);\nfloat lenB = length(deltaB);\nvec2 dirA = lenA > 0. ? normalize(deltaA) : vec2(0.0, 0.0);\nvec2 dirB = lenB > 0. ? normalize(deltaB) : vec2(0.0, 0.0);\nvec2 perpA = vec2(-dirA.y, dirA.x);\nvec2 perpB = vec2(-dirB.y, dirB.x);\nvec2 tangent = dirA + dirB;\ntangent = length(tangent) > 0. ? normalize(tangent) : perpA;\nvec2 miterVec = vec2(-tangent.y, tangent.x);\nvec2 dir = isEnd ? dirA : dirB;\nvec2 perp = isEnd ? perpA : perpB;\nfloat L = isEnd ? lenA : lenB;\nfloat sinHalfA = abs(dot(miterVec, perp));\nfloat cosHalfA = abs(dot(dirA, miterVec));\nfloat turnDirection = flipIfTrue(dirA.x * dirB.y >= dirA.y * dirB.x);\nfloat cornerPosition = sideOfPath * turnDirection;\nfloat miterSize = 1.0 / max(sinHalfA, EPSILON);\nmiterSize = mix(\nmin(miterSize, max(lenA, lenB) / max(cosHalfA, EPSILON)),\nmiterSize,\nstep(0.0, cornerPosition)\n);\nvec2 offsetVec = mix(miterVec * miterSize, perp, step(0.5, cornerPosition))\n* (sideOfPath + isJoint * turnDirection);\nbool isStartCap = lenA == 0.0 || (!isEnd && (instanceTypes == 1.0 || instanceTypes == 3.0));\nbool isEndCap = lenB == 0.0 || (isEnd && (instanceTypes == 2.0 || instanceTypes == 3.0));\nbool isCap = isStartCap || isEndCap;\nif (isCap) {\noffsetVec = mix(perp * sideOfPath, dir * capType * 4.0 * flipIfTrue(isStartCap), isJoint);\nvJointType = capType;\n} else {\nvJointType = jointType;\n}\nvPathLength = L;\nvCornerOffset = offsetVec;\nvMiterLength = dot(vCornerOffset, miterVec * turnDirection);\nvMiterLength = isCap ? isJoint : vMiterLength;\nvec2 offsetFromStartOfPath = vCornerOffset + deltaA * float(isEnd);\nvPathPosition = vec2(\ndot(offsetFromStartOfPath, perp),\ndot(offsetFromStartOfPath, dir)\n);\ngeometry.uv = vPathPosition;\nfloat isValid = step(instanceTypes, 3.5);\nvec3 offset = vec3(offsetVec * width * isValid, 0.0);\nif (needsRotation) {\noffset = rotationMatrix * offset;\n}\nreturn offset;\n}\nvoid clipLine(inout vec4 position, vec4 refPosition) {\nif (position.w < EPSILON) {\nfloat r = (EPSILON - refPosition.w) / (position.w - refPosition.w);\nposition = refPosition + (position - refPosition) * r;\n}\n}\nvoid main() {\ngeometry.pickingColor = instancePickingColors;\nvColor = vec4(instanceColors.rgb, instanceColors.a * opacity);\nfloat isEnd = positions.x;\nvec3 prevPosition = mix(instanceLeftPositions, instanceStartPositions, isEnd);\nvec3 prevPosition64Low = mix(instanceLeftPositions64Low, instanceStartPositions64Low, isEnd);\nvec3 currPosition = mix(instanceStartPositions, instanceEndPositions, isEnd);\nvec3 currPosition64Low = mix(instanceStartPositions64Low, instanceEndPositions64Low, isEnd);\nvec3 nextPosition = mix(instanceEndPositions, instanceRightPositions, isEnd);\nvec3 nextPosition64Low = mix(instanceEndPositions64Low, instanceRightPositions64Low, isEnd);\ngeometry.worldPosition = currPosition;\nvec2 widthPixels = vec2(clamp(\nproject_size_to_pixel(instanceStrokeWidths * widthScale, widthUnits),\nwidthMinPixels, widthMaxPixels) / 2.0);\nvec3 width;\nif (billboard) {\nvec4 prevPositionScreen = project_position_to_clipspace(prevPosition, prevPosition64Low, ZERO_OFFSET);\nvec4 currPositionScreen = project_position_to_clipspace(currPosition, currPosition64Low, ZERO_OFFSET, geometry.position);\nvec4 nextPositionScreen = project_position_to_clipspace(nextPosition, nextPosition64Low, ZERO_OFFSET);\nclipLine(prevPositionScreen, currPositionScreen);\nclipLine(nextPositionScreen, currPositionScreen);\nclipLine(currPositionScreen, mix(nextPositionScreen, prevPositionScreen, isEnd));\nwidth = vec3(widthPixels, 0.0);\nDECKGL_FILTER_SIZE(width, geometry);\nvec3 offset = getLineJoinOffset(\nprevPositionScreen.xyz / prevPositionScreen.w,\ncurrPositionScreen.xyz / currPositionScreen.w,\nnextPositionScreen.xyz / nextPositionScreen.w,\nproject_pixel_size_to_clipspace(width.xy)\n);\nDECKGL_FILTER_GL_POSITION(currPositionScreen, geometry);\ngl_Position = vec4(currPositionScreen.xyz + offset * currPositionScreen.w, currPositionScreen.w);\n} else {\nprevPosition = project_position(prevPosition, prevPosition64Low);\ncurrPosition = project_position(currPosition, currPosition64Low);\nnextPosition = project_position(nextPosition, nextPosition64Low);\nwidth = vec3(project_pixel_size(widthPixels), 0.0);\nDECKGL_FILTER_SIZE(width, geometry);\nvec3 offset = getLineJoinOffset(prevPosition, currPosition, nextPosition, width.xy);\ngeometry.position = vec4(currPosition + offset, 1.0);\ngl_Position = project_common_position_to_clipspace(geometry.position);\nDECKGL_FILTER_GL_POSITION(gl_Position, geometry);\n}\nDECKGL_FILTER_COLOR(vColor, geometry);\n}\n",fs:"#version 300 es\n#define SHADER_NAME path-layer-fragment-shader\nprecision highp float;\nuniform float miterLimit;\nin vec4 vColor;\nin vec2 vCornerOffset;\nin float vMiterLength;\nin vec2 vPathPosition;\nin float vPathLength;\nin float vJointType;\nout vec4 fragColor;\nvoid main(void) {\ngeometry.uv = vPathPosition;\nif (vPathPosition.y < 0.0 || vPathPosition.y > vPathLength) {\nif (vJointType > 0.5 && length(vCornerOffset) > 1.0) {\ndiscard;\n}\nif (vJointType < 0.5 && vMiterLength > miterLimit + 1.0) {\ndiscard;\n}\n}\nfragColor = vColor;\nDECKGL_FILTER_COLOR(fragColor, geometry);\n}\n",modules:[zy,gv]})}get wrapLongitude(){return!1}getBounds(){return this.getAttributeManager()?.getBounds(["vertexPositions"])}initializeState(){const e=!0;this.getAttributeManager().addInstanced({vertexPositions:{size:3,vertexOffset:1,type:"float64",fp64:this.use64bitPositions(),transition:rM,accessor:"getPath",update:this.calculatePositions,noAlloc:e,shaderAttributes:{instanceLeftPositions:{vertexOffset:0},instanceStartPositions:{vertexOffset:1},instanceEndPositions:{vertexOffset:2},instanceRightPositions:{vertexOffset:3}}},instanceTypes:{size:1,type:"uint8",update:this.calculateSegmentTypes,noAlloc:e},instanceStrokeWidths:{size:1,accessor:"getWidth",transition:rM,defaultValue:1},instanceColors:{size:this.props.colorFormat.length,type:"unorm8",accessor:"getColor",transition:rM,defaultValue:iM},instancePickingColors:{size:4,type:"uint8",accessor:(e,{index:t,target:i})=>this.encodePickingColor(e&&e.__source?e.__source.index:t,i)}}),this.setState({pathTesselator:new eM({fp64:this.use64bitPositions()})})}updateState(e){super.updateState(e);const{props:t,changeFlags:i}=e,n=this.getAttributeManager();if(i.dataChanged||i.updateTriggersChanged&&(i.updateTriggersChanged.all||i.updateTriggersChanged.getPath)){const{pathTesselator:e}=this.state,r=t.data.attributes||{};e.updateGeometry({data:t.data,geometryBuffer:r.getPath,buffers:r,normalize:!t._pathType,loop:"loop"===t._pathType,getGeometry:t.getPath,positionFormat:t.positionFormat,wrapLongitude:t.wrapLongitude,resolution:this.context.viewport.resolution,dataChanged:i.dataChanged}),this.setState({numInstances:e.instanceCount,startIndices:e.vertexStarts}),i.dataChanged||n.invalidateAll()}i.extensionsChanged&&(this.state.model?.destroy(),this.state.model=this._getModel(),n.invalidateAll())}getPickingInfo(e){const t=super.getPickingInfo(e),{index:i}=t,n=this.props.data;return n[0]&&n[0].__source&&(t.object=n.find(e=>e.__source.index===i)),t}disablePickingIndex(e){const t=this.props.data;if(t[0]&&t[0].__source)for(let i=0;i80*i){n=o=e[0],r=s=e[1];for(var f=i;fo&&(o=a),l>s&&(s=l);c=0!==(c=Math.max(o-n,s-r))?32767/c:0}return hM(d,p,i,n,r,c,0),p}function cM(e,t,i,n,r){var o,s;if(r===LM(e,t,i,n)>0)for(o=t;o=t;o-=n)s=MM(o,e[o],e[o+1],s);return s&&TM(s,s.next)&&(PM(s),s=s.next),s}function uM(e,t){if(!e)return e;t||(t=e);var i,n=e;do{if(i=!1,n.steiner||!TM(n,n.next)&&0!==wM(n.prev,n,n.next))n=n.next;else{if(PM(n),(n=t=n.prev)===n.next)break;i=!0}}while(i||n!==t);return t}function hM(e,t,i,n,r,o,s){if(e){!s&&o&&function(e,t,i,n){var r=e;do{0===r.z&&(r.z=yM(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){var t,i,n,r,o,s,a,l,c=1;do{for(i=e,e=null,o=null,s=0;i;){for(s++,n=i,a=0,t=0;t0||l>0&&n;)0!==a&&(0===l||!n||i.z<=n.z)?(r=i,i=i.nextZ,a--):(r=n,n=n.nextZ,l--),o?o.nextZ=r:e=r,r.prevZ=o,o=r;i=n}o.nextZ=null,c*=2}while(s>1)}(r)}(e,n,r,o);for(var a,l,c=e;e.prev!==e.next;)if(a=e.prev,l=e.next,o?pM(e,n,r,o):dM(e))t.push(a.i/i|0),t.push(e.i/i|0),t.push(l.i/i|0),PM(e),e=l.next,c=l.next;else if((e=l)===c){s?1===s?hM(e=fM(uM(e),t,i),t,i,n,r,o,2):2===s&&mM(e,t,i,n,r,o):hM(uM(e),t,i,n,r,o,1);break}}}function dM(e){var t=e.prev,i=e,n=e.next;if(wM(t,i,n)>=0)return!1;for(var r=t.x,o=i.x,s=n.x,a=t.y,l=i.y,c=n.y,u=ro?r>s?r:s:o>s?o:s,p=a>l?a>c?a:c:l>c?l:c,f=n.next;f!==t;){if(f.x>=u&&f.x<=d&&f.y>=h&&f.y<=p&&xM(r,a,o,l,s,c,f.x,f.y)&&wM(f.prev,f,f.next)>=0)return!1;f=f.next}return!0}function pM(e,t,i,n){var r=e.prev,o=e,s=e.next;if(wM(r,o,s)>=0)return!1;for(var a=r.x,l=o.x,c=s.x,u=r.y,h=o.y,d=s.y,p=al?a>c?a:c:l>c?l:c,g=u>h?u>d?u:d:h>d?h:d,_=yM(p,f,t,i,n),A=yM(m,g,t,i,n),y=e.prevZ,v=e.nextZ;y&&y.z>=_&&v&&v.z<=A;){if(y.x>=p&&y.x<=m&&y.y>=f&&y.y<=g&&y!==r&&y!==s&&xM(a,u,l,h,c,d,y.x,y.y)&&wM(y.prev,y,y.next)>=0)return!1;if(y=y.prevZ,v.x>=p&&v.x<=m&&v.y>=f&&v.y<=g&&v!==r&&v!==s&&xM(a,u,l,h,c,d,v.x,v.y)&&wM(v.prev,v,v.next)>=0)return!1;v=v.nextZ}for(;y&&y.z>=_;){if(y.x>=p&&y.x<=m&&y.y>=f&&y.y<=g&&y!==r&&y!==s&&xM(a,u,l,h,c,d,y.x,y.y)&&wM(y.prev,y,y.next)>=0)return!1;y=y.prevZ}for(;v&&v.z<=A;){if(v.x>=p&&v.x<=m&&v.y>=f&&v.y<=g&&v!==r&&v!==s&&xM(a,u,l,h,c,d,v.x,v.y)&&wM(v.prev,v,v.next)>=0)return!1;v=v.nextZ}return!0}function fM(e,t,i){var n=e;do{var r=n.prev,o=n.next.next;!TM(r,o)&&EM(r,n,n.next,o)&&BM(r,o)&&BM(o,r)&&(t.push(r.i/i|0),t.push(n.i/i|0),t.push(o.i/i|0),PM(n),PM(n.next),n=e=o),n=n.next}while(n!==e);return uM(n)}function mM(e,t,i,n,r,o){var s=e;do{for(var a=s.next.next;a!==s.prev;){if(s.i!==a.i&&bM(s,a)){var l=IM(s,a);return s=uM(s,s.next),l=uM(l,l.next),hM(s,t,i,n,r,o,0),void hM(l,t,i,n,r,o,0)}a=a.next}s=s.next}while(s!==e)}function gM(e,t){return e.x-t.x}function _M(e,t){var i=function(e,t){var i,n=t,r=e.x,o=e.y,s=-1/0;do{if(o<=n.y&&o>=n.next.y&&n.next.y!==n.y){var a=n.x+(o-n.y)*(n.next.x-n.x)/(n.next.y-n.y);if(a<=r&&a>s&&(s=a,i=n.x=n.x&&n.x>=u&&r!==n.x&&xM(oi.x||n.x===i.x&&AM(i,n)))&&(i=n,d=l)),n=n.next}while(n!==c);return i}(e,t);if(!i)return t;var n=IM(i,e);return uM(n,n.next),uM(i,i.next)}function AM(e,t){return wM(e.prev,e,t.prev)<0&&wM(t.next,e,e.next)<0}function yM(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 vM(e){var t=e,i=e;do{(t.x=(e-s)*(o-a)&&(e-s)*(n-a)>=(i-s)*(t-a)&&(i-s)*(o-a)>=(r-s)*(n-a)}function bM(e,t){return e.next.i!==t.i&&e.prev.i!==t.i&&!function(e,t){var i=e;do{if(i.i!==e.i&&i.next.i!==e.i&&i.i!==t.i&&i.next.i!==t.i&&EM(i,i.next,e,t))return!0;i=i.next}while(i!==e);return!1}(e,t)&&(BM(e,t)&&BM(t,e)&&function(e,t){var i=e,n=!1,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)&&(wM(e.prev,e,t.prev)||wM(e,t.prev,t))||TM(e,t)&&wM(e.prev,e,e.next)>0&&wM(t.prev,t,t.next)>0)}function wM(e,t,i){return(t.y-e.y)*(i.x-t.x)-(t.x-e.x)*(i.y-t.y)}function TM(e,t){return e.x===t.x&&e.y===t.y}function EM(e,t,i,n){var r=SM(wM(e,t,i)),o=SM(wM(e,t,n)),s=SM(wM(i,n,e)),a=SM(wM(i,n,t));return r!==o&&s!==a||(!(0!==r||!CM(e,i,t))||(!(0!==o||!CM(e,n,t))||(!(0!==s||!CM(i,e,n))||!(0!==a||!CM(i,t,n)))))}function CM(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 SM(e){return e>0?1:e<0?-1:0}function BM(e,t){return wM(e.prev,e,e.next)<0?wM(e,t,e.next)>=0&&wM(e,e.prev,t)>=0:wM(e,t,e.prev)<0||wM(e,e.next,t)<0}function IM(e,t){var i=new RM(e.i,e.x,e.y),n=new RM(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 MM(e,t,i,n){var r=new RM(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 PM(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 RM(e,t,i){this.i=e,this.x=t,this.y=i,this.prev=null,this.next=null,this.z=0,this.prevZ=null,this.nextZ=null,this.steiner=!1}function LM(e,t,i,n){for(var r=0,o=t,s=i-n;o0&&(n+=e[r-1].length,i.holes.push(n))}return i};var FM=aM.exports;const kM=LI,DM=FI,OM={isClosed:!0};function zM(e){return"positions"in e?e.positions:e}function UM(e){return"holeIndices"in e?e.holeIndices:null}function NM(e,t,i,n,r){let o=t;const s=i.length;for(let t=0;t=1&&e[0].length>=2&&Number.isFinite(e[0][0])}(e)){let r=0;for(const[o,s]of e.entries())r=NM(i,r,s,t,0===o?kM:DM),n.push(r);return n.pop(),{positions:i,holeIndices:n}}return NM(i,0,e,t,kM),i}function GM(e,t,i){const n=e.length/3;let r=0;for(let o=0;oe/t));let o=zM(e);const s=n&&3===t;if(i){const e=o.length;o=o.slice();const n=[];for(let r=0;rt&&e>n||(t>n?(i||(o=o.slice()),HM(o,0,2,1)):(i||(o=o.slice()),HM(o,2,0,1)))}return FM(o,r,t)}(e,this.positionSize,this.opts.preproject,this.opts.full3d);a=s.allocate(a,n+c.length,{copy:!0});for(let e=0;e2?o[s*r+2]:0;n[3*e]=t,n[3*e+1]=i,n[3*e+2]=a}}_updateVertexValid(e,{vertexStart:t,geometrySize:i}){const{positionSize:n}=this,r=this.attributes.vertexValid,o=e&&UM(e);if(e&&e.edgeTypes?r.set(e.edgeTypes,t):r.fill(1,t,t+i),o)for(let e=0;e0&&!Number.isFinite(e[0])}var ZM="uniform bool extruded;\nuniform bool isWireframe;\nuniform float elevationScale;\nuniform float opacity;\nin vec4 fillColors;\nin vec4 lineColors;\nin vec3 pickingColors;\nout vec4 vColor;\nstruct PolygonProps {\nvec3 positions;\nvec3 positions64Low;\nvec3 normal;\nfloat elevations;\n};\nvec3 project_offset_normal(vec3 vector) {\nif (project_uCoordinateSystem == COORDINATE_SYSTEM_LNGLAT ||\nproject_uCoordinateSystem == COORDINATE_SYSTEM_LNGLAT_OFFSETS) {\nreturn normalize(vector * project_uCommonUnitsPerWorldUnit);\n}\nreturn project_normal(vector);\n}\nvoid calculatePosition(PolygonProps props) {\nvec3 pos = props.positions;\nvec3 pos64Low = props.positions64Low;\nvec3 normal = props.normal;\nvec4 colors = isWireframe ? lineColors : fillColors;\ngeometry.worldPosition = props.positions;\ngeometry.pickingColor = pickingColors;\nif (extruded) {\npos.z += props.elevations * elevationScale;\n}\ngl_Position = project_position_to_clipspace(pos, pos64Low, vec3(0.), geometry.position);\nDECKGL_FILTER_GL_POSITION(gl_Position, geometry);\nif (extruded) {\n#ifdef IS_SIDE_VERTEX\nnormal = project_offset_normal(normal);\n#else\nnormal = project_normal(normal);\n#endif\ngeometry.normal = normal;\nvec3 lightColor = lighting_getLightColor(colors.rgb, project_uCameraPosition, geometry.position.xyz, geometry.normal);\nvColor = vec4(lightColor, colors.a * opacity);\n} else {\nvColor = vec4(colors.rgb, colors.a * opacity);\n}\nDECKGL_FILTER_COLOR(vColor, geometry);\n}\n",WM=`#version 300 es\n#define SHADER_NAME solid-polygon-layer-vertex-shader\nin vec3 vertexPositions;\nin vec3 vertexPositions64Low;\nin float elevations;\n${ZM}\nvoid main(void) {\nPolygonProps props;\nprops.positions = vertexPositions;\nprops.positions64Low = vertexPositions64Low;\nprops.elevations = elevations;\nprops.normal = vec3(0.0, 0.0, 1.0);\ncalculatePosition(props);\n}\n`,qM=`#version 300 es\n#define SHADER_NAME solid-polygon-layer-vertex-shader-side\n#define IS_SIDE_VERTEX\nin vec2 positions;\nin vec3 vertexPositions;\nin vec3 nextVertexPositions;\nin vec3 vertexPositions64Low;\nin vec3 nextVertexPositions64Low;\nin float elevations;\nin float instanceVertexValid;\n${ZM}\nvoid main(void) {\nif(instanceVertexValid < 0.5){\ngl_Position = vec4(0.);\nreturn;\n}\nPolygonProps props;\nvec3 pos;\nvec3 pos64Low;\nvec3 nextPos;\nvec3 nextPos64Low;\n#if RING_WINDING_ORDER_CW == 1\npos = vertexPositions;\npos64Low = vertexPositions64Low;\nnextPos = nextVertexPositions;\nnextPos64Low = nextVertexPositions64Low;\n#else\npos = nextVertexPositions;\npos64Low = nextVertexPositions64Low;\nnextPos = vertexPositions;\nnextPos64Low = vertexPositions64Low;\n#endif\nprops.positions = mix(pos, nextPos, positions.x);\nprops.positions64Low = mix(pos64Low, nextPos64Low, positions.x);\nprops.normal = vec3(\npos.y - nextPos.y + (pos64Low.y - nextPos64Low.y),\nnextPos.x - pos.x + (nextPos64Low.x - pos64Low.x),\n0.0);\nprops.elevations = elevations * positions.y;\ncalculatePosition(props);\n}\n`;const KM=[0,0,0,255],XM={filled:!0,extruded:!1,wireframe:!1,_normalize:!0,_windingOrder:"CW",_full3d:!1,elevationScale:{type:"number",min:0,value:1},getPolygon:{type:"accessor",value:e=>e.polygon},getElevation:{type:"accessor",value:1e3},getFillColor:{type:"accessor",value:KM},getLineColor:{type:"accessor",value:KM},material:!0},JM={enter:(e,t)=>t.length?t.subarray(t.length-e.length):e};class YM extends hS{getShaders(e){return super.getShaders({vs:"top"===e?WM:qM,fs:"#version 300 es\n#define SHADER_NAME solid-polygon-layer-fragment-shader\nprecision highp float;\nin vec4 vColor;\nout vec4 fragColor;\nvoid main(void) {\nfragColor = vColor;\ngeometry.uv = vec2(0.);\nDECKGL_FILTER_COLOR(fragColor, geometry);\n}\n",defines:{RING_WINDING_ORDER_CW:this.props._normalize||"CCW"!==this.props._windingOrder?1:0},modules:[zy,gy,gv]})}get wrapLongitude(){return!1}getBounds(){return this.getAttributeManager()?.getBounds(["vertexPositions"])}initializeState(){const{viewport:e}=this.context;let{coordinateSystem:t}=this.props;const{_full3d:i}=this.props;let n;e.isGeospatial&&t===xy.DEFAULT&&(t=xy.LNGLAT),t===xy.LNGLAT&&(n=i?e.projectPosition.bind(e):e.projectFlat.bind(e)),this.setState({numInstances:0,polygonTesselator:new QM({preproject:n,fp64:this.use64bitPositions(),IndexType:Uint32Array})});const r=this.getAttributeManager(),o=!0;r.remove(["instancePickingColors"]),r.add({indices:{size:1,isIndexed:!0,update:this.calculateIndices,noAlloc:o},vertexPositions:{size:3,type:"float64",stepMode:"dynamic",fp64:this.use64bitPositions(),transition:JM,accessor:"getPolygon",update:this.calculatePositions,noAlloc:o,shaderAttributes:{nextVertexPositions:{vertexOffset:1}}},instanceVertexValid:{size:1,type:"uint16",stepMode:"instance",update:this.calculateVertexValid,noAlloc:o},elevations:{size:1,stepMode:"dynamic",transition:JM,accessor:"getElevation"},fillColors:{size:this.props.colorFormat.length,type:"unorm8",stepMode:"dynamic",transition:JM,accessor:"getFillColor",defaultValue:KM},lineColors:{size:this.props.colorFormat.length,type:"unorm8",stepMode:"dynamic",transition:JM,accessor:"getLineColor",defaultValue:KM},pickingColors:{size:4,type:"uint8",stepMode:"dynamic",accessor:(e,{index:t,target:i})=>this.encodePickingColor(e&&e.__source?e.__source.index:t,i)}})}getPickingInfo(e){const t=super.getPickingInfo(e),{index:i}=t,n=this.props.data;return n[0]&&n[0].__source&&(t.object=n.find(e=>e.__source.index===i)),t}disablePickingIndex(e){const t=this.props.data;if(t[0]&&t[0].__source)for(let i=0;ie.destroy()),this.setState(this._getModels()),r.invalidateAll())}updateGeometry({props:e,oldProps:t,changeFlags:i}){if(i.dataChanged||i.updateTriggersChanged&&(i.updateTriggersChanged.all||i.updateTriggersChanged.getPolygon)){const{polygonTesselator:t}=this.state,n=e.data.attributes||{};t.updateGeometry({data:e.data,normalize:e._normalize,geometryBuffer:n.getPolygon,buffers:n,getGeometry:e.getPolygon,positionFormat:e.positionFormat,wrapLongitude:e.wrapLongitude,resolution:this.context.viewport.resolution,fp64:this.use64bitPositions(),dataChanged:i.dataChanged,full3d:e._full3d}),this.setState({numInstances:t.instanceCount,startIndices:t.vertexStarts}),i.dataChanged||this.getAttributeManager().invalidateAll()}}_getModels(){const{id:e,filled:t,extruded:i}=this.props;let n,r,o;if(t){const t=this.getShaders("top");t.defines.NON_INSTANCED_MODEL=1;const i=this.getAttributeManager().getBufferLayouts({isInstanced:!1});n=new bx(this.context.device,{...t,id:`${e}-top`,topology:"triangle-list",uniforms:{isWireframe:!1},bufferLayout:i,isIndexed:!0,userData:{excludeAttributes:{instanceVertexValid:!0}}})}if(i){const t=this.getAttributeManager().getBufferLayouts({isInstanced:!0});r=new bx(this.context.device,{...this.getShaders("side"),id:`${e}-side`,bufferLayout:t,uniforms:{isWireframe:!1},geometry:new Cx({topology:"triangle-strip",attributes:{positions:{size:2,value:new Float32Array([1,0,0,0,1,1,0,1])}}}),isInstanced:!0,userData:{excludeAttributes:{indices:!0}}}),o=new bx(this.context.device,{...this.getShaders("side"),id:`${e}-wireframe`,bufferLayout:t,uniforms:{isWireframe:!0},geometry:new Cx({topology:"line-strip",attributes:{positions:{size:2,value:new Float32Array([1,0,0,0,0,1,1,1])}}}),isInstanced:!0,userData:{excludeAttributes:{indices:!0}}})}return{models:[r,o,n].filter(Boolean),topModel:n,sideModel:r,wireframeModel:o}}calculateIndices(e){const{polygonTesselator:t}=this.state;e.startIndices=t.indexStarts,e.value=t.get("indices")}calculatePositions(e){const{polygonTesselator:t}=this.state;e.startIndices=t.vertexStarts,e.value=t.get("positions")}calculateVertexValid(e){e.value=this.state.polygonTesselator.get("vertexValid")}}YM.defaultProps=XM,YM.layerName="SolidPolygonLayer";var eP=YM;function tP({data:e,getIndex:t,dataRange:i,replace:n}){const{startRow:r=0,endRow:o=1/0}=i,s=e.length;let a=s,l=s;for(let i=0;ii&&n>=r&&(a=i),n>=o){l=i;break}}let c=a;const u=l-a!==n.length?e.slice(l):void 0;for(let t=0;t 0.0) {\nfloat inFill = alpha;\nfloat inBorder = smoothstep(outlineBuffer - gamma, outlineBuffer + gamma, distance);\ncolor = mix(outlineColor, vColor, inFill);\nalpha = inBorder;\n}\n}\nfloat a = alpha * color.a;\nif (a < alphaCutoff) {\ndiscard;\n}\nfragColor = vec4(color.rgb, a * opacity);\n}\nDECKGL_FILTER_COLOR(fragColor, geometry);\n}\n"}}initializeState(){super.initializeState();this.getAttributeManager().addInstanced({instanceOffsets:{size:2,accessor:"getIconOffsets"},instancePickingColors:{type:"uint8",size:3,accessor:(e,{index:t,target:i})=>this.encodePickingColor(t,i)}})}updateState(e){super.updateState(e);const{props:t,oldProps:i}=e;let{outlineColor:n}=t;n!==i.outlineColor&&(n=n.map(e=>e/255),n[3]=Number.isFinite(n[3])?n[3]:1,this.setState({outlineColor:n})),!t.sdf&&t.outlineWidth&&rp.warn(`${this.id}: fontSettings.sdf is required to render outline`)()}draw(e){const{sdf:t,smoothing:i,outlineWidth:n}=this.props,{outlineColor:r}=this.state,o=n?Math.max(i,iP*(1-n)):-1;if(e.uniforms={...e.uniforms,sdfBuffer:iP,outlineBuffer:o,gamma:i,sdf:Boolean(t),outlineColor:r},super.draw(e),t&&n){const{iconManager:e}=this.state,t=e.getTexture(),i=this.state.model;t&&(i.setUniforms({outlineBuffer:iP}),i.draw(this.context.renderPass))}}getInstanceOffset(e){return e?Array.from(e).flatMap(e=>super.getInstanceOffset(e)):nP}getInstanceColorMode(e){return 1}getInstanceIconFrame(e){return e?Array.from(e).flatMap(e=>super.getInstanceIconFrame(e)):nP}}rP.defaultProps={getIconOffsets:{type:"accessor",value:e=>e.offsets},alphaCutoff:.001,smoothing:.1,outlineWidth:0,outlineColor:{type:"color",value:[0,0,0,255]}},rP.layerName="MultiIconLayer";var oP=rP;const sP=1e20;class aP{constructor({fontSize:e=24,buffer:t=3,radius:i=8,cutoff:n=.25,fontFamily:r="sans-serif",fontWeight:o="normal",fontStyle:s="normal",lang:a=null}={}){this.buffer=t,this.cutoff=n,this.radius=i,this.lang=a;const l=this.size=e+4*t,c=this._createCanvas(l),u=this.ctx=c.getContext("2d",{willReadFrequently:!0});u.font=`${s} ${o} ${e}px ${r}`,u.textBaseline="alphabetic",u.textAlign="left",u.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){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),s=Math.ceil(i),a=Math.max(0,Math.min(this.size-this.buffer,Math.ceil(o-r))),l=Math.min(this.size-this.buffer,s+Math.ceil(n)),c=a+2*this.buffer,u=l+2*this.buffer,h=Math.max(c*u,0),d=new Uint8ClampedArray(h),p={data:d,width:c,height:u,glyphWidth:a,glyphHeight:l,glyphTop:s,glyphLeft:0,glyphAdvance:t};if(0===a||0===l)return p;const{ctx:f,buffer:m,gridInner:g,gridOuter:_}=this;this.lang&&(f.lang=this.lang),f.clearRect(m,m,a,l),f.fillText(e,m,m+s);const A=f.getImageData(m,m,a,l);_.fill(sP,0,h),g.fill(0,0,h);for(let e=0;e0?e*e:0,g[n]=e<0?e*e:0}}lP(_,0,0,c,u,c,this.f,this.v,this.z),lP(g,m,m,a,l,c,this.f,this.v,this.z);for(let e=0;e-1);l++,o[l]=a,s[l]=c,s[l+1]=sP}for(let a=0,l=0;an&&(sa){let t=hP(e,a,l,r);c+t>n&&(sn&&(t=dP(e,a,l,n,r,o),s=o[o.length-1])),a=l,c+=t}}(e,r,o,i,n,s),s}function fP(e,t,i,n,r,o){let s=0,a=0;for(let o=t;o=0&&this._order.splice(t,1)}_appendOrder(e){this._order.push(e)}}const gP={fontFamily:"Monaco, monospace",fontWeight:"normal",characterSet:function(){const e=[];for(let t=32;t<128;t++)e.push(String.fromCharCode(t));return e}(),fontSize:64,buffer:4,sdf:!1,cutoff:.25,radius:12,smoothing:.1};let _P=new mP(3);function AP(e,t){for(let i=0;ir&&(c=0,l++),o[s]={x:c+n,y:a+l*u+n,width:e,height:u,layoutWidth:e,layoutHeight:i},c+=e+2*n}return{mapping:o,xOffset:c,yOffset:a+l*u,canvasHeight:(h=a+(l+1)*u,Math.pow(2,Math.ceil(Math.log2(h))))};var h}({getFontWidth:e=>u.measureText(e).width,fontHeight:1.2*r,buffer:o,characterSet:e,maxCanvasWidth:1024,...t&&{mapping:t.mapping,xOffset:t.xOffset,yOffset:t.yOffset}});if(c.height!==d){const e=u.getImageData(0,0,c.width,c.height);c.height=d,u.putImageData(e,0,0)}if(yP(u,i,r,n),s){const t=new aP({fontSize:r,buffer:o,radius:a,cutoff:l,fontFamily:i,fontWeight:`${n}`});for(const i of e){const{data:e,width:n,height:o,glyphTop:s}=t.draw(i);h[i].width=n,h[i].layoutOffsetY=.9*r-s;const a=u.createImageData(n,o);AP(e,a),u.putImageData(a,h[i].x,h[i].y)}}else for(const t of e)u.fillText(t,h[t].x,h[t].y+o+.9*r);return{xOffset:p,yOffset:f,mapping:h,data:c,width:c.width,height:c.height}}_getKey(){const{fontFamily:e,fontWeight:t,fontSize:i,buffer:n,sdf:r,radius:o,cutoff:s}=this.props;return r?`${e} ${t} ${i} ${n} ${o} ${s}`:`${e} ${t} ${i} ${n}`}}const xP={billboard:!0,sizeScale:1,sizeUnits:"pixels",sizeMinPixels:0,sizeMaxPixels:Number.MAX_SAFE_INTEGER,padding:{type:"array",value:[0,0,0,0]},getPosition:{type:"accessor",value:e=>e.position},getSize:{type:"accessor",value:1},getAngle:{type:"accessor",value:0},getPixelOffset:{type:"accessor",value:[0,0]},getBoundingRect:{type:"accessor",value:[0,0,0,0]},getFillColor:{type:"accessor",value:[0,0,0,255]},getLineColor:{type:"accessor",value:[0,0,0,255]},getLineWidth:{type:"accessor",value:1}};class bP extends hS{getShaders(){return super.getShaders({vs:"#version 300 es\n#define SHADER_NAME text-background-layer-vertex-shader\nin vec2 positions;\nin vec3 instancePositions;\nin vec3 instancePositions64Low;\nin vec4 instanceRects;\nin float instanceSizes;\nin float instanceAngles;\nin vec2 instancePixelOffsets;\nin float instanceLineWidths;\nin vec4 instanceFillColors;\nin vec4 instanceLineColors;\nin vec3 instancePickingColors;\nuniform bool billboard;\nuniform float opacity;\nuniform float sizeScale;\nuniform float sizeMinPixels;\nuniform float sizeMaxPixels;\nuniform vec4 padding;\nuniform int sizeUnits;\nout vec4 vFillColor;\nout vec4 vLineColor;\nout float vLineWidth;\nout vec2 uv;\nout vec2 dimensions;\nvec2 rotate_by_angle(vec2 vertex, float angle) {\nfloat angle_radian = radians(angle);\nfloat cos_angle = cos(angle_radian);\nfloat sin_angle = sin(angle_radian);\nmat2 rotationMatrix = mat2(cos_angle, -sin_angle, sin_angle, cos_angle);\nreturn rotationMatrix * vertex;\n}\nvoid main(void) {\ngeometry.worldPosition = instancePositions;\ngeometry.uv = positions;\ngeometry.pickingColor = instancePickingColors;\nuv = positions;\nvLineWidth = instanceLineWidths;\nfloat sizePixels = clamp(\nproject_size_to_pixel(instanceSizes * sizeScale, sizeUnits),\nsizeMinPixels, sizeMaxPixels\n);\ndimensions = instanceRects.zw * sizePixels + padding.xy + padding.zw;\nvec2 pixelOffset = (positions * instanceRects.zw + instanceRects.xy) * sizePixels + mix(-padding.xy, padding.zw, positions);\npixelOffset = rotate_by_angle(pixelOffset, instanceAngles);\npixelOffset += instancePixelOffsets;\npixelOffset.y *= -1.0;\nif (billboard) {\ngl_Position = project_position_to_clipspace(instancePositions, instancePositions64Low, vec3(0.0), geometry.position);\nDECKGL_FILTER_GL_POSITION(gl_Position, geometry);\nvec3 offset = vec3(pixelOffset, 0.0);\nDECKGL_FILTER_SIZE(offset, geometry);\ngl_Position.xy += project_pixel_size_to_clipspace(offset.xy);\n} else {\nvec3 offset_common = vec3(project_pixel_size(pixelOffset), 0.0);\nDECKGL_FILTER_SIZE(offset_common, geometry);\ngl_Position = project_position_to_clipspace(instancePositions, instancePositions64Low, offset_common, geometry.position);\nDECKGL_FILTER_GL_POSITION(gl_Position, geometry);\n}\nvFillColor = vec4(instanceFillColors.rgb, instanceFillColors.a * opacity);\nDECKGL_FILTER_COLOR(vFillColor, geometry);\nvLineColor = vec4(instanceLineColors.rgb, instanceLineColors.a * opacity);\nDECKGL_FILTER_COLOR(vLineColor, geometry);\n}\n",fs:"#version 300 es\n#define SHADER_NAME text-background-layer-fragment-shader\nprecision highp float;\nuniform bool stroked;\nin vec4 vFillColor;\nin vec4 vLineColor;\nin float vLineWidth;\nin vec2 uv;\nin vec2 dimensions;\nout vec4 fragColor;\nvoid main(void) {\ngeometry.uv = uv;\nvec2 pixelPosition = uv * dimensions;\nif (stroked) {\nfloat distToEdge = min(\nmin(pixelPosition.x, dimensions.x - pixelPosition.x),\nmin(pixelPosition.y, dimensions.y - pixelPosition.y)\n);\nfloat isBorder = smoothedge(distToEdge, vLineWidth);\nfragColor = mix(vFillColor, vLineColor, isBorder);\n} else {\nfragColor = vFillColor;\n}\nDECKGL_FILTER_COLOR(fragColor, geometry);\n}\n",modules:[zy,gv]})}initializeState(){this.getAttributeManager().addInstanced({instancePositions:{size:3,type:"float64",fp64:this.use64bitPositions(),transition:!0,accessor:"getPosition"},instanceSizes:{size:1,transition:!0,accessor:"getSize",defaultValue:1},instanceAngles:{size:1,transition:!0,accessor:"getAngle"},instanceRects:{size:4,accessor:"getBoundingRect"},instancePixelOffsets:{size:2,transition:!0,accessor:"getPixelOffset"},instanceFillColors:{size:4,transition:!0,type:"unorm8",accessor:"getFillColor",defaultValue:[0,0,0,255]},instanceLineColors:{size:4,transition:!0,type:"unorm8",accessor:"getLineColor",defaultValue:[0,0,0,255]},instanceLineWidths:{size:1,transition:!0,accessor:"getLineWidth",defaultValue:1}})}updateState(e){super.updateState(e);const{changeFlags:t}=e;t.extensionsChanged&&(this.state.model?.destroy(),this.state.model=this._getModel(),this.getAttributeManager().invalidateAll())}draw({uniforms:e}){const{billboard:t,sizeScale:i,sizeUnits:n,sizeMinPixels:r,sizeMaxPixels:o,getLineWidth:s}=this.props;let{padding:a}=this.props;a.length<4&&(a=[a[0],a[1],a[0],a[1]]);const l=this.state.model;l.setUniforms(e),l.setUniforms({billboard:t,stroked:Boolean(s),padding:a,sizeUnits:wy[n],sizeScale:i,sizeMinPixels:r,sizeMaxPixels:o}),l.draw(this.context.renderPass)}_getModel(){return new bx(this.context.device,{...this.getShaders(),id:this.props.id,bufferLayout:this.getAttributeManager().getBufferLayouts(),geometry:new Cx({topology:"triangle-fan-webgl",vertexCount:4,attributes:{positions:{size:2,value:new Float32Array([0,0,1,0,1,1,0,1])}}}),isInstanced:!0})}}bP.defaultProps=xP,bP.layerName="TextBackgroundLayer";var wP=bP;const TP={start:1,middle:0,end:-1},EP={top:1,center:0,bottom:-1},CP=[0,0,0,255],SP={billboard:!0,sizeScale:1,sizeUnits:"pixels",sizeMinPixels:0,sizeMaxPixels:Number.MAX_SAFE_INTEGER,background:!1,getBackgroundColor:{type:"accessor",value:[255,255,255,255]},getBorderColor:{type:"accessor",value:CP},getBorderWidth:{type:"accessor",value:0},backgroundPadding:{type:"array",value:[0,0,0,0]},characterSet:{type:"object",value:gP.characterSet},fontFamily:gP.fontFamily,fontWeight:gP.fontWeight,lineHeight:1,outlineWidth:{type:"number",value:0,min:0},outlineColor:{type:"color",value:CP},fontSettings:{type:"object",value:{},compare:1},wordBreak:"break-word",maxWidth:{type:"number",value:-1},getText:{type:"accessor",value:e=>e.text},getPosition:{type:"accessor",value:e=>e.position},getColor:{type:"accessor",value:CP},getSize:{type:"accessor",value:32},getAngle:{type:"accessor",value:0},getTextAnchor:{type:"accessor",value:"middle"},getAlignmentBaseline:{type:"accessor",value:"center"},getPixelOffset:{type:"accessor",value:[0,0]},backgroundColor:{deprecatedFor:["background","getBackgroundColor"]}};class BP extends pS{constructor(){super(...arguments),this.getBoundingRect=(e,t)=>{let{size:[i,n]}=this.transformParagraph(e,t);const{fontSize:r}=this.state.fontAtlasManager.props;i/=r,n/=r;const{getTextAnchor:o,getAlignmentBaseline:s}=this.props;return[(TP["function"==typeof o?o(e,t):o]-1)*i/2,(EP["function"==typeof s?s(e,t):s]-1)*n/2,i,n]},this.getIconOffsets=(e,t)=>{const{getTextAnchor:i,getAlignmentBaseline:n}=this.props,{x:r,y:o,rowWidth:s,size:[a,l]}=this.transformParagraph(e,t),c=TP["function"==typeof i?i(e,t):i],u=EP["function"==typeof n?n(e,t):n],h=r.length,d=new Array(2*h);let p=0;for(let e=0;e0&&rp.warn("v8.9 breaking change: TextLayer maxWidth is now relative to text size")()}updateState(e){const{props:t,oldProps:i,changeFlags:n}=e;(n.dataChanged||n.updateTriggersChanged&&(n.updateTriggersChanged.all||n.updateTriggersChanged.getText))&&this._updateText();(this._updateFontAtlas()||t.lineHeight!==i.lineHeight||t.wordBreak!==i.wordBreak||t.maxWidth!==i.maxWidth)&&this.setState({styleVersion:this.state.styleVersion+1})}getPickingInfo({info:e}){return e.object=e.index>=0?this.props.data[e.index]:null,e}_updateFontAtlas(){const{fontSettings:e,fontFamily:t,fontWeight:i}=this.props,{fontAtlasManager:n,characterSet:r}=this.state,o={...e,characterSet:r,fontFamily:t,fontWeight:i};if(!n.mapping)return n.setProps(o),!0;for(const e in o)if(o[e]!==n.props[e])return n.setProps(o),!0;return!1}_updateText(){const{data:e,characterSet:t}=this.props,i=e.attributes?.getText;let n,{getText:r}=this.props,o=e.startIndices;const s="auto"===t&&new Set;if(i&&o){const{texts:t,characterCount:a}=function({value:e,length:t,stride:i,offset:n,startIndices:r,characterSet:o}){const s=e.BYTES_PER_ELEMENT,a=i?i/s:1,l=n?n/s:0,c=r[t]||Math.ceil((e.length-l)/a),u=o&&new Set,h=new Array(t);let d=e;if(a>1||l>0){d=new(0,e.constructor)(c);for(let t=0;tt[i]}else{const{iterable:t,objectInfo:i}=rC(e);o=[0],n=0;for(const e of t){i.index++;const t=Array.from(r(e,i)||"");s&&t.forEach(s.add,s),n+=t.length,o.push(n)}}this.setState({getText:r,startIndices:o,numInstances:n,characterSet:s||t})}transformParagraph(e,t){const{fontAtlasManager:i}=this.state,n=i.mapping,r=this.state.getText,{wordBreak:o,lineHeight:s,maxWidth:a}=this.props;return function(e,t,i,n,r){const o=Array.from(e),s=o.length,a=new Array(s),l=new Array(s),c=new Array(s),u=("break-word"===i||"break-all"===i)&&isFinite(n)&&n>0,h=[0,0],d=[0,0];let p=0,f=0,m=0;for(let e=0;e<=s;e++){const g=o[e];if("\n"!==g&&e!==s||(m=e),m>f){const e=u?pP(o,i,n,r,f,m):uP;for(let i=0;i<=e.length;i++){const n=0===i?f:e[i-1],s=i=3,"Invalid cache limit"),_P=new mP(e)}(e)}}BP.defaultProps=SP,BP.layerName="TextLayer";const IP={circle:{type:RI,props:{filled:"filled",stroked:"stroked",lineWidthMaxPixels:"lineWidthMaxPixels",lineWidthMinPixels:"lineWidthMinPixels",lineWidthScale:"lineWidthScale",lineWidthUnits:"lineWidthUnits",pointRadiusMaxPixels:"radiusMaxPixels",pointRadiusMinPixels:"radiusMinPixels",pointRadiusScale:"radiusScale",pointRadiusUnits:"radiusUnits",pointAntialiasing:"antialiasing",pointBillboard:"billboard",getFillColor:"getFillColor",getLineColor:"getLineColor",getLineWidth:"getLineWidth",getPointRadius:"getRadius"}},icon:{type:wI,props:{iconAtlas:"iconAtlas",iconMapping:"iconMapping",iconSizeMaxPixels:"sizeMaxPixels",iconSizeMinPixels:"sizeMinPixels",iconSizeScale:"sizeScale",iconSizeUnits:"sizeUnits",iconAlphaCutoff:"alphaCutoff",iconBillboard:"billboard",getIcon:"getIcon",getIconAngle:"getAngle",getIconColor:"getColor",getIconPixelOffset:"getPixelOffset",getIconSize:"getSize"}},text:{type:BP,props:{textSizeMaxPixels:"sizeMaxPixels",textSizeMinPixels:"sizeMinPixels",textSizeScale:"sizeScale",textSizeUnits:"sizeUnits",textBackground:"background",textBackgroundPadding:"backgroundPadding",textFontFamily:"fontFamily",textFontWeight:"fontWeight",textLineHeight:"lineHeight",textMaxWidth:"maxWidth",textOutlineColor:"outlineColor",textOutlineWidth:"outlineWidth",textWordBreak:"wordBreak",textCharacterSet:"characterSet",textBillboard:"billboard",textFontSettings:"fontSettings",getText:"getText",getTextAngle:"getAngle",getTextColor:"getColor",getTextPixelOffset:"getPixelOffset",getTextSize:"getSize",getTextAnchor:"getTextAnchor",getTextAlignmentBaseline:"getAlignmentBaseline",getTextBackgroundColor:"getBackgroundColor",getTextBorderColor:"getBorderColor",getTextBorderWidth:"getBorderWidth"}}},MP={type:sM,props:{lineWidthUnits:"widthUnits",lineWidthScale:"widthScale",lineWidthMinPixels:"widthMinPixels",lineWidthMaxPixels:"widthMaxPixels",lineJointRounded:"jointRounded",lineCapRounded:"capRounded",lineMiterLimit:"miterLimit",lineBillboard:"billboard",getLineColor:"getColor",getLineWidth:"getWidth"}},PP={type:eP,props:{extruded:"extruded",filled:"filled",wireframe:"wireframe",elevationScale:"elevationScale",material:"material",_full3d:"_full3d",getElevation:"getElevation",getFillColor:"getFillColor",getLineColor:"getLineColor"}};function RP({type:e,props:t}){const i={};for(const n in t)i[n]=e.defaultProps[t[n]];return i}function LP(e,t){const{transitions:i,updateTriggers:n}=e.props,r={updateTriggers:{},transitions:i&&{getPosition:i.geometry}};for(const o in t){const s=t[o];let a=e.props[o];o.startsWith("get")&&(a=e.getSubLayerAccessor(a),r.updateTriggers[s]=n[o],i&&(r.transitions[s]=i[o])),r[s]=a}return r}function FP(e,t,i={}){const n={pointFeatures:[],lineFeatures:[],polygonFeatures:[],polygonOutlineFeatures:[]},{startRow:r=0,endRow:o=e.length}=i;for(let i=r;i0;)t=t[0];return t&&Number.isFinite(t[0])}(o,s))switch(o){case"Point":a.push(i({geometry:e},n,r));break;case"MultiPoint":s.forEach(e=>{a.push(i({geometry:{type:"Point",coordinates:e}},n,r))});break;case"LineString":l.push(i({geometry:e},n,r));break;case"MultiLineString":s.forEach(e=>{l.push(i({geometry:{type:"LineString",coordinates:e}},n,r))});break;case"Polygon":c.push(i({geometry:e},n,r)),s.forEach(e=>{u.push(i({geometry:{type:"LineString",coordinates:e}},n,r))});break;case"MultiPolygon":s.forEach(e=>{c.push(i({geometry:{type:"Polygon",coordinates:e}},n,r)),e.forEach(e=>{u.push(i({geometry:{type:"LineString",coordinates:e}},n,r))})})}else rp.warn(`${o} coordinates are malformed`)()}const DP={Point:1,MultiPoint:2,LineString:2,MultiLineString:3,Polygon:3,MultiPolygon:4};function OP(e){return e.geometry.coordinates}function zP(e,t){const i={points:{},lines:{},polygons:{},polygonsOutline:{}},{points:n,lines:r,polygons:o}=e,s=function(e,t){const i={points:null,lines:null,polygons:null};for(const n in i){const r=e[n].globalFeatureIds.value;i[n]=new Uint8ClampedArray(4*r.length);const o=[];for(let e=0;ee.properties.icon},getText:{type:"accessor",value:e=>e.properties.text},pointType:"circle",getRadius:{deprecatedFor:"getPointRadius"}};class VP extends pS{initializeState(){this.state={layerProps:{},features:{},featuresDiff:{}}}updateState({props:e,changeFlags:t}){if(!t.dataChanged)return;const{data:i}=this.props,n=i&&"points"in i&&"polygons"in i&&"lines"in i;this.setState({binary:n}),n?this._updateStateBinary({props:e,changeFlags:t}):this._updateStateJSON({props:e,changeFlags:t})}_updateStateBinary({props:e,changeFlags:t}){const i=zP(e.data,this.encodePickingColor);this.setState({layerProps:i})}_updateStateJSON({props:e,changeFlags:t}){const i=function(e){if(Array.isArray(e))return e;switch(rp.assert(e.type,"GeoJSON does not have type"),e.type){case"Feature":return[e];case"FeatureCollection":return rp.assert(Array.isArray(e.features),"GeoJSON does not have features array"),e.features;default:return[{geometry:e}]}}(e.data),n=this.getSubLayerRow.bind(this);let r={};const o={};if(Array.isArray(t.dataChanged)){const e=this.state.features;for(const t in e)r[t]=e[t].slice(),o[t]=[];for(const s of t.dataChanged){const t=FP(i,n,s);for(const i in e)o[i].push(tP({data:r[i],getIndex:e=>e.__source.index,dataRange:s,replace:t[i]}))}}else r=FP(i,n);const s=function(e,t){const i={points:{},lines:{},polygons:{},polygonsOutline:{}},{pointFeatures:n,lineFeatures:r,polygonFeatures:o,polygonOutlineFeatures:s}=e;return i.points.data=n,i.points._dataDiff=t.pointFeatures&&(()=>t.pointFeatures),i.points.getPosition=OP,i.lines.data=r,i.lines._dataDiff=t.lineFeatures&&(()=>t.lineFeatures),i.lines.getPath=OP,i.polygons.data=o,i.polygons._dataDiff=t.polygonFeatures&&(()=>t.polygonFeatures),i.polygons.getPolygon=OP,i.polygonsOutline.data=s,i.polygonsOutline._dataDiff=t.polygonOutlineFeatures&&(()=>t.polygonOutlineFeatures),i.polygonsOutline.getPath=OP,i}(r,o);this.setState({features:r,featuresDiff:o,layerProps:s})}getPickingInfo(e){const t=super.getPickingInfo(e),{index:i,sourceLayer:n}=t;return t.featureType=UP.find(e=>n.id.startsWith(`${this.id}-${e}-`)),i>=0&&n.id.startsWith(`${this.id}-points-text`)&&this.state.binary&&(t.index=this.props.data.points.globalFeatureIds.value[i]),t}_updateAutoHighlight(e){const t=`${this.id}-points-`,i="points"===e.featureType;for(const n of this.getSubLayers())n.id.startsWith(t)===i&&n.updateAutoHighlight(e)}_renderPolygonLayer(){const{extruded:e,wireframe:t}=this.props,{layerProps:i}=this.state,n="polygons-fill",r=this.shouldRenderSubLayer(n,i.polygons?.data)&&this.getSubLayerClass(n,PP.type);if(r){const o=LP(this,PP.props),s=e&&t;return s||delete o.getLineColor,o.updateTriggers.lineColors=s,new r(o,this.getSubLayerProps({id:n,updateTriggers:o.updateTriggers}),i.polygons)}return null}_renderLineLayers(){const{extruded:e,stroked:t}=this.props,{layerProps:i}=this.state,n="polygons-stroke",r="linestrings",o=!e&&t&&this.shouldRenderSubLayer(n,i.polygonsOutline?.data)&&this.getSubLayerClass(n,MP.type),s=this.shouldRenderSubLayer(r,i.lines?.data)&&this.getSubLayerClass(r,MP.type);if(o||s){const e=LP(this,MP.props);return[o&&new o(e,this.getSubLayerProps({id:n,updateTriggers:e.updateTriggers}),i.polygonsOutline),s&&new s(e,this.getSubLayerProps({id:r,updateTriggers:e.updateTriggers}),i.lines)]}return null}_renderPointLayers(){const{pointType:e}=this.props,{layerProps:t,binary:i}=this.state;let{highlightedObjectIndex:n}=this.props;!i&&Number.isFinite(n)&&(n=t.points.data.findIndex(e=>e.__source.index===n));const r=new Set(e.split("+")),o=[];for(const e of r){const r=`points-${e}`,s=IP[e],a=s&&this.shouldRenderSubLayer(r,t.points?.data)&&this.getSubLayerClass(r,s.type);if(a){const l=LP(this,s.props);let c=t.points;if("text"===e&&i){const{instancePickingColors:e,...t}=c.data.attributes;c={...c,data:{...c.data,attributes:t}}}o.push(new a(l,this.getSubLayerProps({id:r,updateTriggers:l.updateTriggers,highlightedObjectIndex:n}),c))}}return o}renderLayers(){const{extruded:e}=this.props,t=this._renderPolygonLayer();return[!e&&t,this._renderLineLayers(),this._renderPointLayers(),e&&t]}getSubLayerAccessor(e){const{binary:t}=this.state;return t&&"function"==typeof e?(t,i)=>{const{data:n,index:r}=i,o=function(e,t){if(!e)return null;const i="startIndices"in e?e.startIndices[t]:t,n=e.featureIds.value[i];return-1!==i?function(e,t,i){const n={properties:{...e.properties[t]}};for(const t in e.numericProps)n.properties[t]=e.numericProps[t].value[i];return n}(e,n,i):null}(n,r);return e(o,i)}:super.getSubLayerAccessor(e)}}VP.layerName="GeoJsonLayer",VP.defaultProps=NP;var jP=VP;class GP{constructor(e){this.index=e,this.isVisible=!1,this.isSelected=!1,this.parent=null,this.children=[],this.content=null,this._loader=void 0,this._abortController=null,this._loaderId=0,this._isLoaded=!1,this._isCancelled=!1,this._needsReload=!1}get bbox(){return this._bbox}set bbox(e){this._bbox||(this._bbox=e,this.boundingBox="west"in e?[[e.west,e.south],[e.east,e.north]]:[[e.left,e.top],[e.right,e.bottom]])}get data(){return this.isLoading&&this._loader?this._loader.then(()=>this.data):this.content}get isLoaded(){return this._isLoaded&&!this._needsReload}get isLoading(){return Boolean(this._loader)&&!this._isCancelled}get needsReload(){return this._needsReload||this._isCancelled}get byteLength(){const e=this.content?this.content.byteLength:0;return Number.isFinite(e)||console.error("byteLength not defined in tile data"),e}async _loadData({getData:e,requestScheduler:t,onLoad:i,onError:n}){const{index:r,id:o,bbox:s,userData:a,zoom:l}=this,c=this._loaderId;this._abortController=new AbortController;const{signal:u}=this._abortController,h=await t.scheduleRequest(this,e=>e.isSelected?1:-1);if(!h)return void(this._isCancelled=!0);if(this._isCancelled)return void h.done();let d,p=null;try{p=await e({index:r,id:o,bbox:s,userData:a,zoom:l,signal:u})}catch(e){d=e||!0}finally{h.done()}c===this._loaderId&&(this._loader=void 0,this.content=p,!this._isCancelled||p?(this._isLoaded=!0,this._isCancelled=!1,d?n(d,this):i(this)):this._isLoaded=!1)}loadData(e){return this._isLoaded=!1,this._isCancelled=!1,this._needsReload=!1,this._loaderId++,this._loader=this._loadData(e),this._loader}setNeedsReload(){this.isLoading&&(this.abort(),this._loader=void 0),this._needsReload=!0}abort(){this.isLoaded||(this._isCancelled=!0,this._abortController?.abort())}}const HP=-1,QP=0,$P=1,ZP=new AA,WP=new AA;class qP{constructor(e=[0,0,0],t=[0,0,0],i){i=i||ZP.copy(e).add(t).scale(.5),this.center=new AA(i),this.halfDiagonal=new AA(t).subtract(this.center),this.minimum=new AA(e),this.maximum=new AA(t)}clone(){return new qP(this.minimum,this.maximum,this.center)}equals(e){return this===e||Boolean(e)&&this.minimum.equals(e.minimum)&&this.maximum.equals(e.maximum)}transform(e){return this.center.transformAsPoint(e),this.halfDiagonal.transform(e),this.minimum.transform(e),this.maximum.transform(e),this}intersectPlane(e){const{halfDiagonal:t}=this,i=WP.from(e.normal),n=t.x*Math.abs(i.x)+t.y*Math.abs(i.y)+t.z*Math.abs(i.z),r=this.center.dot(i)+e.distance;return r-n>0?$P:r+n<0?HP:QP}distanceTo(e){return Math.sqrt(this.distanceSquaredTo(e))}distanceSquaredTo(e){const t=ZP.from(e).subtract(this.center),{halfDiagonal:i}=this;let n,r=0;return n=Math.abs(t.x)-i.x,n>0&&(r+=n*n),n=Math.abs(t.y)-i.y,n>0&&(r+=n*n),n=Math.abs(t.z)-i.z,n>0&&(r+=n*n),r}}const KP=new AA,XP=new AA;class JP{constructor(e=[0,0,0],t=0){this.radius=-0,this.center=new AA,this.fromCenterRadius(e,t)}fromCenterRadius(e,t){return this.center.from(e),this.radius=t,this}fromCornerPoints(e,t){return t=KP.from(t),this.center=(new AA).from(e).add(t).scale(.5),this.radius=this.center.distance(t),this}equals(e){return this===e||Boolean(e)&&this.center.equals(e.center)&&this.radius===e.radius}clone(){return new JP(this.center,this.radius)}union(e){const t=this.center,i=this.radius,n=e.center,r=e.radius,o=KP.copy(n).subtract(t),s=o.magnitude();if(i>=s+r)return this.clone();if(r>=s+i)return e.clone();const a=.5*(i+s+r);return XP.copy(o).scale((-i+a)/s).add(t),this.center.copy(XP),this.radius=a,this}expand(e){const t=KP.from(e).subtract(this.center).magnitude();return t>this.radius&&(this.radius=t),this}transform(e){this.center.transform(e);const t=function(e,t){const i=t[0],n=t[1],r=t[2],o=t[4],s=t[5],a=t[6],l=t[8],c=t[9],u=t[10];return e[0]=Math.sqrt(i*i+n*n+r*r),e[1]=Math.sqrt(o*o+s*s+a*a),e[2]=Math.sqrt(l*l+c*c+u*u),e}(KP,e);return this.radius=Math.max(t[0],Math.max(t[1],t[2]))*this.radius,this}distanceSquaredTo(e){const t=this.distanceTo(e);return t*t}distanceTo(e){const t=KP.from(e).subtract(this.center);return Math.max(0,t.len()-this.radius)}intersectPlane(e){const t=this.center,i=this.radius,n=e.normal.dot(t)+e.distance;return n<-i?HP:n=a?$P:QP}distanceTo(e){return Math.sqrt(this.distanceSquaredTo(e))}distanceSquaredTo(e){const t=eR.from(e).subtract(this.center),i=this.halfAxes,n=i.getColumn(0,tR),r=i.getColumn(1,iR),o=i.getColumn(2,nR),s=n.magnitude(),a=r.magnitude(),l=o.magnitude();n.normalize(),r.normalize(),o.normalize();let c,u=0;return c=Math.abs(t.dot(n))-s,c>0&&(u+=c*c),c=Math.abs(t.dot(r))-a,c>0&&(u+=c*c),c=Math.abs(t.dot(o))-l,c>0&&(u+=c*c),u}computePlaneDistances(e,t,i=[-0,-0]){let n=Number.POSITIVE_INFINITY,r=Number.NEGATIVE_INFINITY;const o=this.center,s=this.halfAxes,a=s.getColumn(0,tR),l=s.getColumn(1,iR),c=s.getColumn(2,nR),u=rR.copy(a).add(l).add(c).add(o),h=oR.copy(u).subtract(e);let d=t.dot(h);return n=Math.min(d,n),r=Math.max(d,r),u.copy(o).add(a).add(l).subtract(c),h.copy(u).subtract(e),d=t.dot(h),n=Math.min(d,n),r=Math.max(d,r),u.copy(o).add(a).subtract(l).add(c),h.copy(u).subtract(e),d=t.dot(h),n=Math.min(d,n),r=Math.max(d,r),u.copy(o).add(a).subtract(l).subtract(c),h.copy(u).subtract(e),d=t.dot(h),n=Math.min(d,n),r=Math.max(d,r),o.copy(u).subtract(a).add(l).add(c),h.copy(u).subtract(e),d=t.dot(h),n=Math.min(d,n),r=Math.max(d,r),o.copy(u).subtract(a).add(l).subtract(c),h.copy(u).subtract(e),d=t.dot(h),n=Math.min(d,n),r=Math.max(d,r),o.copy(u).subtract(a).subtract(l).add(c),h.copy(u).subtract(e),d=t.dot(h),n=Math.min(d,n),r=Math.max(d,r),o.copy(u).subtract(a).subtract(l).subtract(c),h.copy(u).subtract(e),d=t.dot(h),n=Math.min(d,n),r=Math.max(d,r),i[0]=n,i[1]=r,i}transform(e){this.center.transformAsPoint(e);const t=this.halfAxes.getColumn(0,tR);t.transformAsPoint(e);const i=this.halfAxes.getColumn(1,iR);i.transformAsPoint(e);const n=this.halfAxes.getColumn(2,nR);return n.transformAsPoint(e),this.halfAxes=new EA([...t,...i,...n]),this}getTransform(){throw new Error("not implemented")}}const gR=new AA,_R=new AA;class AR{constructor(e=[0,0,1],t=0){this.normal=new AA,this.distance=-0,this.fromNormalDistance(e,t)}fromNormalDistance(e,t){return Q_(Number.isFinite(t)),this.normal.from(e).normalize(),this.distance=t,this}fromPointNormal(e,t){e=gR.from(e),this.normal.from(t).normalize();const i=-this.normal.dot(e);return this.distance=i,this}fromCoefficients(e,t,i,n){return this.normal.set(e,t,i),Q_(N_(this.normal.len(),1)),this.distance=n,this}clone(){return new AR(this.normal,this.distance)}equals(e){return N_(this.distance,e.distance)&&N_(this.normal,e.normal)}getPointDistance(e){return this.normal.dot(e)+this.distance}transform(e){const t=_R.copy(this.normal).transformAsVector(e).normalize(),i=this.normal.scale(-this.distance).transform(e);return this.fromPointNormal(i,t)}projectPointOntoPlane(e,t=[0,0,0]){const i=gR.from(e),n=this.getPointDistance(i),r=_R.copy(this.normal).scale(n);return i.subtract(r).to(t)}}const yR=[new AA([1,0,0]),new AA([0,1,0]),new AA([0,0,1])],vR=new AA,xR=new AA;class bR{constructor(e=[]){this.planes=e}fromBoundingSphere(e){this.planes.length=2*yR.length;const t=e.center,i=e.radius;let n=0;for(const e of yR){let r=this.planes[n],o=this.planes[n+1];r||(r=this.planes[n]=new AR),o||(o=this.planes[n+1]=new AR);const s=vR.copy(e).scale(-i).add(t);r.fromPointNormal(s,e);const a=vR.copy(e).scale(i).add(t),l=xR.copy(e).negate();o.fromPointNormal(a,l),n+=2}return this}computeVisibility(e){let t=$P;for(const i of this.planes){switch(e.intersectPlane(i)){case HP:return HP;case QP:t=QP}}return t}computeVisibilityWithPlaneMask(e,t){if(Q_(Number.isFinite(t),"parentPlaneMask is required."),t===bR.MASK_OUTSIDE||t===bR.MASK_INSIDE)return t;let i=bR.MASK_INSIDE;const n=this.planes;for(let r=0;rs;)RR(o,CR),SR.copy(CR).transpose(),o.multiplyRight(CR),o.multiplyLeft(SR),r.multiplyRight(CR),++i>2&&(++n,i=0);return t.unitary=r.toTarget(t.unitary),t.diagonal=o.toTarget(t.diagonal),t}const IR=[1,0,0],MR=[2,2,1];function PR(e){let t=0;for(let i=0;i<3;++i){const n=e[wR.getElementIndex(MR[i],IR[i])];t+=2*n*n}return Math.sqrt(t)}function RR(e,t){let i=0,n=1;for(let t=0;t<3;++t){const r=Math.abs(e[wR.getElementIndex(MR[t],IR[t])]);r>i&&(n=t,i=r)}const r=IR[n],o=MR[n];let s=1,a=0;if(Math.abs(e[wR.getElementIndex(o,r)])>1e-15){const t=(e[wR.getElementIndex(o,o)]-e[wR.getElementIndex(r,r)])/2/e[wR.getElementIndex(o,r)];let i;i=t<0?-1/(-t+Math.sqrt(1+t*t)):1/(t+Math.sqrt(1+t*t)),s=1/Math.sqrt(1+i*i),a=i*s}return EA.IDENTITY.to(t),t[wR.getElementIndex(r,r)]=t[wR.getElementIndex(o,o)]=s,t[wR.getElementIndex(o,r)]=a,t[wR.getElementIndex(r,o)]=-a,t}const LR=new AA,FR=new AA,kR=new AA,DR=new AA,OR=new AA,zR=new EA,UR={diagonal:new EA,unitary:new EA};function NR(e,t=new mR){if(!e||0===e.length)return t.halfAxes=new EA([0,0,0,0,0,0,0,0,0]),t.center=new AA,t;const i=e.length,n=new AA(0,0,0);for(const t of e)n.add(t);const r=1/i;n.multiplyByScalar(r);let o=0,s=0,a=0,l=0,c=0,u=0;for(const t of e){const e=LR.copy(t).subtract(n);o+=e.x*e.x,s+=e.x*e.y,a+=e.x*e.z,l+=e.y*e.y,c+=e.y*e.z,u+=e.z*e.z}o*=r,s*=r,a*=r,l*=r,c*=r,u*=r;const h=zR;h[0]=o,h[1]=s,h[2]=a,h[3]=s,h[4]=l,h[5]=c,h[6]=a,h[7]=c,h[8]=u;const{unitary:d}=BR(h,UR),p=t.halfAxes.copy(d);let f=p.getColumn(0,kR),m=p.getColumn(1,DR),g=p.getColumn(2,OR),_=-Number.MAX_VALUE,A=-Number.MAX_VALUE,y=-Number.MAX_VALUE,v=Number.MAX_VALUE,x=Number.MAX_VALUE,b=Number.MAX_VALUE;for(const t of e)LR.copy(t),_=Math.max(LR.dot(f),_),A=Math.max(LR.dot(m),A),y=Math.max(LR.dot(g),y),v=Math.min(LR.dot(f),v),x=Math.min(LR.dot(m),x),b=Math.min(LR.dot(g),b);f=f.multiplyByScalar(.5*(v+_)),m=m.multiplyByScalar(.5*(x+A)),g=g.multiplyByScalar(.5*(b+y)),t.center.copy(f).add(m).add(g);const w=FR.set(_-v,A-x,y-b).multiplyByScalar(.5),T=new EA([w[0],0,0,0,w[1],0,0,0,w[2]]);return t.halfAxes.multiplyRight(T),t}const VR=512,jR=[[.5,.5],[0,0],[0,1],[1,0],[1,1]],GR=jR.concat([[0,.5],[.5,0],[1,.5],[.5,1]]),HR=GR.concat([[.25,.5],[.75,.5]]);class QR{constructor(e,t,i){this.x=e,this.y=t,this.z=i}get children(){if(!this._children){const e=2*this.x,t=2*this.y,i=this.z+1;this._children=[new QR(e,t,i),new QR(e,t+1,i),new QR(e+1,t,i),new QR(e+1,t+1,i)]}return this._children}update(e){const{viewport:t,cullingVolume:i,elevationBounds:n,minZ:r,maxZ:o,bounds:s,offset:a,project:l}=e,c=this.getBoundingVolume(n,a,l);if(s&&!this.insideBounds(s))return!1;if(i.computeVisibility(c)<0)return!1;if(!this.childVisible){let{z:e}=this;if(e=r){const i=c.distanceTo(t.cameraPosition)*t.scale/t.height;e+=Math.floor(Math.log2(i))}if(e>=o)return this.selected=!0,!0}this.selected=!1,this.childVisible=!0;for(const t of this.children)t.update(e);return!0}getSelected(e=[]){if(this.selected&&e.push(this),this._children)for(const t of this._children)t.getSelected(e);return e}insideBounds([e,t,i,n]){const r=Math.pow(2,this.z),o=VR/r;return this.x*oe&&(this.y+1)*o>t}getBoundingVolume(e,t,i){if(i){const t=this.z<1?HR:this.z<2?GR:jR,n=[];for(const r of t){const t=eL(this.x+r[0],this.y+r[1],this.z);t[2]=e[0],n.push(i(t)),e[0]!==e[1]&&(t[2]=e[1],n.push(i(t)))}return NR(n)}const n=Math.pow(2,this.z),r=VR/n,o=this.x*r+t*VR,s=VR-(this.y+1)*r;return new qP([o,s,e[0]],[o+r,s+r,e[1]])}}const $R=512,ZR=[-1/0,-1/0,1/0,1/0],WR={type:"object",value:null,validate:(e,t)=>t.optional&&null===e||"string"==typeof e||Array.isArray(e)&&e.every(e=>"string"==typeof e),equal:(e,t)=>{if(e===t)return!0;if(!Array.isArray(e)||!Array.isArray(t))return!1;const i=e.length;if(i!==t.length)return!1;for(let n=0;ne[0])),Math.min(...i.map(e=>e[1])),Math.max(...i.map(e=>e[0])),Math.max(...i.map(e=>e[1]))];return n}function KR(e,t){if(!e||!e.length)return null;const{index:i,id:n}=t;if(Array.isArray(e)){const t=function(e){return Math.abs(e.split("").reduce((e,t)=>(e<<5)-e+t.charCodeAt(0)|0,0))}(n)%e.length;e=e[t]}let r=e;for(const e of Object.keys(i)){const t=new RegExp(`{${e}}`,"g");r=r.replace(t,String(i[e]))}return Number.isInteger(i.y)&&Number.isInteger(i.z)&&(r=r.replace(/\{-y\}/g,String(Math.pow(2,i.z)-i.y-1))),r}function XR({viewport:e,z:t,cullRect:i}){return(e.subViewports||[e]).map(e=>JR(e,t||0,i))}function JR(e,t,i){if(!Array.isArray(t)){const n=i.x-e.x,r=i.y-e.y,{width:o,height:s}=i,a={targetZ:t},l=e.unproject([n,r],a),c=e.unproject([n+o,r],a),u=e.unproject([n,r+s],a),h=e.unproject([n+o,r+s],a);return[Math.min(l[0],c[0],u[0],h[0]),Math.min(l[1],c[1],u[1],h[1]),Math.max(l[0],c[0],u[0],h[0]),Math.max(l[1],c[1],u[1],h[1])]}const n=JR(e,t[0],i),r=JR(e,t[1],i);return[Math.min(n[0],r[0]),Math.min(n[1],r[1]),Math.max(n[2],r[2]),Math.max(n[3],r[3])]}function YR(e,t){return Math.pow(2,e)*$R/t}function eL(e,t,i){const n=YR(i,$R),r=e/n*360-180,o=Math.PI-2*Math.PI*t/n;return[r,180/Math.PI*Math.atan(.5*(Math.exp(o)-Math.exp(-o)))]}function tL(e,t,i,n){const r=YR(i,n);return[e/r*$R,t/r*$R]}function iL(e,t,i,n,r=$R){if(e.isGeospatial){const[e,r]=eL(t,i,n),[o,s]=eL(t+1,i+1,n);return{west:e,north:r,east:o,south:s}}const[o,s]=tL(t,i,n,r),[a,l]=tL(t+1,i+1,n,r);return{left:o,top:s,right:a,bottom:l}}function nL(e,t,i,n,r){const o=function(e,t,i){let n;if(t&&2===t.length){const[i,r]=t,o=e.getBounds({z:i}),s=e.getBounds({z:r});n=[Math.min(o[0],s[0]),Math.min(o[1],s[1]),Math.max(o[2],s[2]),Math.max(o[3],s[3])]}else n=e.getBounds();return e.isGeospatial?[Math.max(n[0],i[0]),Math.max(n[1],i[1]),Math.min(n[2],i[2]),Math.min(n[3],i[3])]:[Math.max(Math.min(n[0],i[2]),i[0]),Math.max(Math.min(n[1],i[3]),i[1]),Math.min(Math.max(n[2],i[0]),i[2]),Math.min(Math.max(n[3],i[1]),i[3])]}(e,null,n),s=YR(t,i),[a,l,c,u]=function(e,t,i){if(i){const n=qR(e,i).map(e=>e*t/$R);return n}return e.map(e=>e*t/$R)}(o,s,r),h=[];for(let e=Math.floor(a);et&&(c=t);let u=r;return s&&a&&r&&!e.isGeospatial&&(u=qR(r,s)),e.isGeospatial?function(e,t,i,n){const r=e instanceof yS&&e.resolution?e.projectPosition:null,o=Object.values(e.getFrustumPlanes()).map(({normal:e,distance:t})=>new AR(e.clone().negate(),t)),s=new bR(o),a=e.distanceScales.unitsPerMeter[2],l=i&&i[0]*a||0,c=i&&i[1]*a||0,u=e instanceof Xv&&e.pitch<=60?t:0;if(n){const[e,t,i,r]=n,o=Jy([e,r]),s=Jy([i,t]);n=[o[0],VR-o[1],s[0],VR-s[1]]}const h=new QR(0,0,0),d={viewport:e,project:r,cullingVolume:s,elevationBounds:[l,c],minZ:u,maxZ:t,bounds:n,offset:0};if(h.update(d),e instanceof Xv&&e.subViewports&&e.subViewports.length>1){for(d.offset=-1;h.update(d)&&!(--d.offset<-3););for(d.offset=1;h.update(d)&&!(++d.offset>3););}return h.getSelected()}(e,c,n,r):nL(e,c,o,u||ZR,a)}function oL(e,t){if(e===t)return!0;if(Array.isArray(e)){const i=e.length;if(!t||t.length!==i)return!1;for(let n=0;ne.zoom-t.zoom);for(const e of t)if(e.isVisible=Boolean(2&e.state),e.children&&(e.isVisible||1&e.state))for(const t of e.children)t.state=1;else e.isSelected&&dL(e)},[sL]:()=>{}},uL={extent:null,tileSize:512,maxZoom:null,minZoom:null,maxCacheSize:null,maxCacheByteSize:null,refinementStrategy:"best-available",zRange:null,maxRequests:6,debounceTime:0,zoomOffset:0,onTileLoad:()=>{},onTileUnload:()=>{},onTileError:()=>{}};function hL(e){let t=e;for(;t;){if(t.isLoaded||t.content)return t.state|=2,!0;t=t.parent}return!1}function dL(e){for(const t of e.children)t.isLoaded||t.content?t.state|=2:dL(t)}const pL={TilesetClass:class{constructor(e){this._getCullBounds=function(e){let t,i={};return n=>{for(const r in n)if(!oL(n[r],i[r])){t=e(n),i=n;break}return t}}(XR),this.opts={...uL,...e},this.setOptions(this.opts),this.onTileLoad=e=>{this.opts.onTileLoad?.(e),null!=this.opts.maxCacheByteSize&&(this._cacheByteSize+=e.byteLength,this._resizeCache())},this._requestScheduler=new Bh({throttleRequests:this.opts.maxRequests>0||this.opts.debounceTime>0,maxRequests:this.opts.maxRequests,debounceTime:this.opts.debounceTime}),this._cache=new Map,this._tiles=[],this._dirty=!1,this._cacheByteSize=0,this._viewport=null,this._zRange=null,this._selectedTiles=null,this._frameNumber=0,this._modelMatrix=new HA,this._modelMatrixInverse=new HA}get tiles(){return this._tiles}get selectedTiles(){return this._selectedTiles}get isLoaded(){return null!==this._selectedTiles&&this._selectedTiles.every(e=>e.isLoaded)}get needsReload(){return null!==this._selectedTiles&&this._selectedTiles.some(e=>e.needsReload)}setOptions(e){Object.assign(this.opts,e),Number.isFinite(e.maxZoom)&&(this._maxZoom=Math.floor(e.maxZoom)),Number.isFinite(e.minZoom)&&(this._minZoom=Math.ceil(e.minZoom))}finalize(){for(const e of this._cache.values())e.isLoading&&e.abort();this._cache.clear(),this._tiles=[],this._selectedTiles=null}reloadAll(){for(const e of this._cache.keys()){const t=this._cache.get(e);this._selectedTiles&&this._selectedTiles.includes(t)?t.setNeedsReload():this._cache.delete(e)}}update(e,{zRange:t,modelMatrix:i}={zRange:null,modelMatrix:null}){const n=i?new HA(i):new HA,r=!n.equals(this._modelMatrix);if(this._viewport&&e.equals(this._viewport)&&N_(this._zRange,t)&&!r)this.needsReload&&(this._selectedTiles=this._selectedTiles.map(e=>this._getTile(e.index,!0)));else{r&&(this._modelMatrixInverse=n.clone().invert(),this._modelMatrix=n),this._viewport=e,this._zRange=t;const i=this.getTileIndices({viewport:e,maxZoom:this._maxZoom,minZoom:this._minZoom,zRange:t,modelMatrix:this._modelMatrix,modelMatrixInverse:this._modelMatrixInverse});this._selectedTiles=i.map(e=>this._getTile(e,!0)),this._dirty&&this._rebuildTree()}const o=this.updateTileStates();return this._pruneRequests(),this._dirty&&this._resizeCache(),o&&this._frameNumber++,this._frameNumber}isTileVisible(e,t){if(!e.isVisible)return!1;if(t&&this._viewport){const i=this._getCullBounds({viewport:this._viewport,z:this._zRange,cullRect:t}),{bbox:n}=e;for(const[e,t,r,o]of i){let i;if("west"in n)i=n.weste&&n.southt;else{const s=Math.min(n.top,n.bottom),a=Math.max(n.top,n.bottom);i=n.lefte&&st}if(i)return!0}return!1}return!0}getTileIndices({viewport:e,maxZoom:t,minZoom:i,zRange:n,modelMatrix:r,modelMatrixInverse:o}){const{tileSize:s,extent:a,zoomOffset:l}=this.opts;return rL({viewport:e,maxZoom:t,minZoom:i,zRange:n,tileSize:s,extent:a,modelMatrix:r,modelMatrixInverse:o,zoomOffset:l})}getTileId(e){return`${e.x}-${e.y}-${e.z}`}getTileZoom(e){return e.z}getTileMetadata(e){const{tileSize:t}=this.opts;return{bbox:iL(this._viewport,e.x,e.y,e.z,t)}}getParentIndex(e){return{x:Math.floor(e.x/2),y:Math.floor(e.y/2),z:e.z-1}}updateTileStates(){const e=this.opts.refinementStrategy||lL,t=new Array(this._cache.size);let i=0;for(const e of this._cache.values())t[i++]=e.isVisible,e.isSelected=!1,e.isVisible=!1;for(const e of this._selectedTiles)e.isSelected=!0,e.isVisible=!0;("function"==typeof e?e:cL[e])(Array.from(this._cache.values())),i=0;for(const e of this._cache.values())if(t[i++]!==e.isVisible)return!0;return!1}_pruneRequests(){const{maxRequests:e=0}=this.opts,t=[];let i=0;for(const e of this._cache.values())e.isLoading&&(i++,e.isSelected||e.isVisible||t.push(e));for(;e>0&&i>e&&t.length>0;){t.shift().abort(),i--}}_rebuildTree(){const{_cache:e}=this;for(const t of e.values())t.parent=null,t.children&&(t.children.length=0);for(const t of e.values()){const e=this._getNearestAncestor(t);t.parent=e,e?.children&&e.children.push(t)}}_resizeCache(){const{_cache:e,opts:t}=this,i=t.maxCacheSize??(null!=t.maxCacheByteSize?1/0:5*this.selectedTiles.length),n=t.maxCacheByteSize??1/0;if(e.size>i||this._cacheByteSize>n){for(const[r,o]of e)if(o.isVisible||o.isSelected||(this._cacheByteSize-=null!=t.maxCacheByteSize?o.byteLength:0,e.delete(r),this.opts.onTileUnload?.(o)),e.size<=i&&this._cacheByteSize<=n)break;this._rebuildTree(),this._dirty=!0}this._dirty&&(this._tiles=Array.from(this._cache.values()).sort((e,t)=>e.zoom-t.zoom),this._dirty=!1)}_getTile(e,t){const i=this.getTileId(e);let n=this._cache.get(i),r=!1;return!n&&t?(n=new GP(e),Object.assign(n,this.getTileMetadata(n.index)),Object.assign(n,{id:i,zoom:this.getTileZoom(n.index)}),r=!0,this._cache.set(i,n),this._dirty=!0):n&&n.needsReload&&(r=!0),n&&r&&n.loadData({getData:this.opts.getTileData,requestScheduler:this._requestScheduler,onLoad:this.onTileLoad,onError:this.opts.onTileError}),n}_getNearestAncestor(e){const{_minZoom:t=0}=this;let i=e.index;for(;this.getTileZoom(i)>t;){i=this.getParentIndex(i);const e=this._getTile(i);if(e)return e}return null}},data:{type:"data",value:[]},dataComparator:WR.equal,renderSubLayers:{type:"function",value:e=>new jP(e)},getTileData:{type:"function",optional:!0,value:null},onViewportLoad:{type:"function",optional:!0,value:null},onTileLoad:{type:"function",value:e=>{}},onTileUnload:{type:"function",value:e=>{}},onTileError:{type:"function",value:e=>console.error(e)},extent:{type:"array",optional:!0,value:null,compare:!0},tileSize:512,maxZoom:null,minZoom:0,maxCacheSize:null,maxCacheByteSize:null,refinementStrategy:lL,zRange:null,maxRequests:6,debounceTime:0,zoomOffset:0};class fL extends pS{initializeState(){this.state={tileset:null,isLoaded:!1}}finalizeState(){this.state?.tileset?.finalize()}get isLoaded(){return Boolean(this.state?.tileset?.selectedTiles?.every(e=>e.isLoaded&&e.layers&&e.layers.every(e=>e.isLoaded)))}shouldUpdateState({changeFlags:e}){return e.somethingChanged}updateState({changeFlags:e}){let{tileset:t}=this.state;const i=e.propsOrDataChanged||e.updateTriggersChanged,n=e.dataChanged||e.updateTriggersChanged&&(e.updateTriggersChanged.all||e.updateTriggersChanged.getTileData);t?i&&(t.setOptions(this._getTilesetOptions()),n?t.reloadAll():t.tiles.forEach(e=>{e.layers=null})):(t=new this.props.TilesetClass(this._getTilesetOptions()),this.setState({tileset:t})),this._updateTileset()}_getTilesetOptions(){const{tileSize:e,maxCacheSize:t,maxCacheByteSize:i,refinementStrategy:n,extent:r,maxZoom:o,minZoom:s,maxRequests:a,debounceTime:l,zoomOffset:c}=this.props;return{maxCacheSize:t,maxCacheByteSize:i,maxZoom:o,minZoom:s,tileSize:e,refinementStrategy:n,extent:r,maxRequests:a,debounceTime:l,zoomOffset:c,getTileData:this.getTileData.bind(this),onTileLoad:this._onTileLoad.bind(this),onTileError:this._onTileError.bind(this),onTileUnload:this._onTileUnload.bind(this)}}_updateTileset(){const e=this.state.tileset,{zRange:t,modelMatrix:i}=this.props,n=e.update(this.context.viewport,{zRange:t,modelMatrix:i}),{isLoaded:r}=e,o=this.state.isLoaded!==r,s=this.state.frameNumber!==n;r&&(o||s)&&this._onViewportLoad(),s&&this.setState({frameNumber:n}),this.state.isLoaded=r}_onViewportLoad(){const{tileset:e}=this.state,{onViewportLoad:t}=this.props;t&&t(e.selectedTiles)}_onTileLoad(e){this.props.onTileLoad(e),e.layers=null,this.setNeedsUpdate()}_onTileError(e,t){this.props.onTileError(e),t.layers=null,this.setNeedsUpdate()}_onTileUnload(e){this.props.onTileUnload(e)}getTileData(e){const{data:t,getTileData:i,fetch:n}=this.props,{signal:r}=e;return e.url="string"==typeof t||Array.isArray(t)?KR(t,e):null,i?i(e):n&&e.url?n(e.url,{propName:"data",layer:this,signal:r}):null}renderSubLayers(e){return this.props.renderSubLayers(e)}getSubLayerPropsByTile(e){return null}getPickingInfo(e){const t=e.sourceLayer,i=t.props.tile,n=e.info;return n.picked&&(n.tile=i),n.sourceTile=i,n.sourceTileSubLayer=t,n}_updateAutoHighlight(e){e.sourceTileSubLayer.updateAutoHighlight(e)}renderLayers(){return this.state.tileset.tiles.map(e=>{const t=this.getSubLayerPropsByTile(e);if(e.isLoaded||e.content)if(e.layers)t&&e.layers[0]&&Object.keys(t).some(i=>e.layers[0].props[i]!==t[i])&&(e.layers=e.layers.map(e=>e.clone(t)));else{const i=this.renderSubLayers({...this.props,...this.getSubLayerProps({id:e.id,updateTriggers:this.props.updateTriggers}),data:e.content,_offset:0,tile:e});e.layers=Qx(i,Boolean).map(i=>i.clone({tile:e,...t}))}else;return e.layers})}filterSubLayer({layer:e,cullRect:t}){const{tile:i}=e.props;return this.state.tileset.isTileVisible(i,t)}}fL.defaultProps=pL,fL.layerName="TileLayer";var mL=fL;const gL=Math.PI/180,_L=new Float32Array(16),AL=new Float32Array(12);function yL(e,t,i){const n=t[0]*gL,r=t[1]*gL,o=t[2]*gL,s=Math.sin(o),a=Math.sin(n),l=Math.sin(r),c=Math.cos(o),u=Math.cos(n),h=Math.cos(r),d=i[0],p=i[1],f=i[2];e[0]=d*h*u,e[1]=d*l*u,e[2]=d*-a,e[3]=p*(-l*c+h*a*s),e[4]=p*(h*c+l*a*s),e[5]=p*u*s,e[6]=f*(l*s+h*a*c),e[7]=f*(-h*s+l*a*c),e[8]=f*u*c}function vL(e){return e[0]=e[0],e[1]=e[1],e[2]=e[2],e[3]=e[4],e[4]=e[5],e[5]=e[6],e[6]=e[8],e[7]=e[9],e[8]=e[10],e[9]=e[12],e[10]=e[13],e[11]=e[14],e.subarray(0,12)}const xL={size:12,accessor:["getOrientation","getScale","getTranslation","getTransformMatrix"],shaderAttributes:{instanceModelMatrixCol0:{size:3,elementOffset:0},instanceModelMatrixCol1:{size:3,elementOffset:3},instanceModelMatrixCol2:{size:3,elementOffset:6},instanceTranslation:{size:3,elementOffset:9}},update(e,{startRow:t,endRow:i}){const{data:n,getOrientation:r,getScale:o,getTranslation:s,getTransformMatrix:a}=this.props,l=Array.isArray(a),c=l&&16===a.length,u=Array.isArray(o),h=Array.isArray(r),d=Array.isArray(s),p=c||!l&&Boolean(a(n[0]));e.constant=p?c:h&&u&&d;const f=e.value;if(e.constant){let t;if(p)_L.set(a),t=vL(_L);else{t=AL;yL(t,r,o),t.set(s,9)}e.value=new Float32Array(t)}else{let l=t*e.size;const{iterable:m,objectInfo:g}=rC(n,t,i);for(const e of m){let t;if(g.index++,p)_L.set(c?a:a(e,g)),t=vL(_L);else{t=AL;yL(t,h?r:r(e,g),u?o:o(e,g)),t.set(d?s:s(e,g),9)}f[l++]=t[0],f[l++]=t[1],f[l++]=t[2],f[l++]=t[3],f[l++]=t[4],f[l++]=t[5],f[l++]=t[6],f[l++]=t[7],f[l++]=t[8],f[l++]=t[9],f[l++]=t[10],f[l++]=t[11]}}}};function bL(e,t){return t===xy.CARTESIAN||t===xy.METER_OFFSETS||t===xy.DEFAULT&&!e.isGeospatial}function wL(e){const t=e.positions||e.POSITION;rp.assert(t,'no "postions" or "POSITION" attribute in mesh');const i=t.value.length/t.size;let n=e.COLOR_0||e.colors;n||(n={size:3,value:new Float32Array(3*i).fill(1)});let r=e.NORMAL||e.normals;r||(r={size:3,value:new Float32Array(3*i).fill(0)});let o=e.TEXCOORD_0||e.texCoords;return o||(o={size:2,value:new Float32Array(2*i).fill(0)}),{positions:t,colors:n,normals:r,texCoords:o}}function TL(e){return e instanceof Cx?(e.attributes=wL(e.attributes),e):e.attributes?new Cx({...e,topology:"triangle-list",attributes:wL(e.attributes)}):new Cx({topology:"triangle-list",attributes:wL(e)})}const EL={mesh:{type:"object",value:null,async:!0},texture:{type:"image",value:null,async:!0},sizeScale:{type:"number",value:1,min:0},_instanced:!0,wireframe:!1,material:!0,getPosition:{type:"accessor",value:e=>e.position},getColor:{type:"accessor",value:[0,0,0,255]},getOrientation:{type:"accessor",value:[0,0,0]},getScale:{type:"accessor",value:[1,1,1]},getTranslation:{type:"accessor",value:[0,0,0]},getTransformMatrix:{type:"accessor",value:[]},textureParameters:{type:"object",ignore:!0,value:null}};class CL extends hS{getShaders(){return super.getShaders({vs:"#version 300 es\n#define SHADER_NAME simple-mesh-layer-vs\nuniform float sizeScale;\nuniform bool composeModelMatrix;\nin vec3 positions;\nin vec3 normals;\nin vec3 colors;\nin vec2 texCoords;\nin vec3 instancePositions;\nin vec3 instancePositions64Low;\nin vec4 instanceColors;\nin vec3 instancePickingColors;\nin vec3 instanceModelMatrixCol0;\nin vec3 instanceModelMatrixCol1;\nin vec3 instanceModelMatrixCol2;\nin vec3 instanceTranslation;\nout vec2 vTexCoord;\nout vec3 cameraPosition;\nout vec3 normals_commonspace;\nout vec4 position_commonspace;\nout vec4 vColor;\nvoid main(void) {\ngeometry.worldPosition = instancePositions;\ngeometry.uv = texCoords;\ngeometry.pickingColor = instancePickingColors;\nvTexCoord = texCoords;\ncameraPosition = project_uCameraPosition;\nvColor = vec4(colors * instanceColors.rgb, instanceColors.a);\nmat3 instanceModelMatrix = mat3(instanceModelMatrixCol0, instanceModelMatrixCol1, instanceModelMatrixCol2);\nvec3 pos = (instanceModelMatrix * positions) * sizeScale + instanceTranslation;\nif (composeModelMatrix) {\nDECKGL_FILTER_SIZE(pos, geometry);\nnormals_commonspace = project_normal(instanceModelMatrix * normals);\ngeometry.worldPosition += pos;\ngl_Position = project_position_to_clipspace(pos + instancePositions, instancePositions64Low, vec3(0.0), position_commonspace);\ngeometry.position = position_commonspace;\n}\nelse {\npos = project_size(pos);\nDECKGL_FILTER_SIZE(pos, geometry);\ngl_Position = project_position_to_clipspace(instancePositions, instancePositions64Low, pos, position_commonspace);\ngeometry.position = position_commonspace;\nnormals_commonspace = project_normal(instanceModelMatrix * normals);\n}\ngeometry.normal = normals_commonspace;\nDECKGL_FILTER_GL_POSITION(gl_Position, geometry);\nDECKGL_FILTER_COLOR(vColor, geometry);\n}\n",fs:"#version 300 es\n#define SHADER_NAME simple-mesh-layer-fs\nprecision highp float;\nuniform bool hasTexture;\nuniform sampler2D sampler;\nuniform bool flatShading;\nuniform float opacity;\nin vec2 vTexCoord;\nin vec3 cameraPosition;\nin vec3 normals_commonspace;\nin vec4 position_commonspace;\nin vec4 vColor;\nout vec4 fragColor;\nvoid main(void) {\ngeometry.uv = vTexCoord;\nvec3 normal;\nif (flatShading) {\nnormal = normalize(cross(dFdx(position_commonspace.xyz), dFdy(position_commonspace.xyz)));\n} else {\nnormal = normals_commonspace;\n}\nvec4 color = hasTexture ? texture(sampler, vTexCoord) : vColor;\nDECKGL_FILTER_COLOR(color, geometry);\nvec3 lightColor = lighting_getLightColor(color.rgb, cameraPosition, position_commonspace.xyz, normal);\nfragColor = vec4(lightColor, color.a * opacity);\n}\n",modules:[zy,_y,gv]})}getBounds(){if(this.props._instanced)return super.getBounds();let e=this.state.positionBounds;if(e)return e;const{mesh:t}=this.props;if(!t)return null;if(e=t.header?.boundingBox,!e){const{attributes:i}=TL(t);i.POSITION=i.POSITION||i.positions,e=Rd(i)}return this.state.positionBounds=e,e}initializeState(){this.getAttributeManager().addInstanced({instancePositions:{transition:!0,type:"float64",fp64:this.use64bitPositions(),size:3,accessor:"getPosition"},instanceColors:{type:"unorm8",transition:!0,size:this.props.colorFormat.length,accessor:"getColor",defaultValue:[0,0,0,255]},instanceModelMatrix:xL}),this.setState({emptyTexture:this.context.device.createTexture({data:new Uint8Array(4),width:1,height:1})})}updateState(e){super.updateState(e);const{props:t,oldProps:i,changeFlags:n}=e;if(t.mesh!==i.mesh||n.extensionsChanged){if(this.state.positionBounds=null,this.state.model?.destroy(),t.mesh){this.state.model=this.getModel(t.mesh);const e=t.mesh.attributes||t.mesh;this.setState({hasNormals:Boolean(e.NORMAL||e.normals)})}this.getAttributeManager().invalidateAll()}t.texture!==i.texture&&t.texture instanceof yf&&this.setTexture(t.texture),this.state.model&&this.state.model.setTopology(this.props.wireframe?"line-strip":"triangle-list")}finalizeState(e){super.finalizeState(e),this.state.emptyTexture.delete()}draw({uniforms:e}){const{model:t}=this.state;if(!t)return;const{viewport:i,renderPass:n}=this.context,{sizeScale:r,coordinateSystem:o,_instanced:s}=this.props;t.setUniforms(e),t.setUniforms({sizeScale:r,composeModelMatrix:!s||bL(i,o),flatShading:!this.state.hasNormals}),t.draw(n)}get isLoaded(){return Boolean(this.state?.model&&super.isLoaded)}getModel(e){const t=new bx(this.context.device,{...this.getShaders(),id:this.props.id,bufferLayout:this.getAttributeManager().getBufferLayouts(),geometry:TL(e),isInstanced:!0}),{texture:i}=this.props,{emptyTexture:n}=this.state;return t.setBindings({sampler:i||n}),t.setUniforms({hasTexture:Boolean(i)}),t}setTexture(e){const{emptyTexture:t,model:i}=this.state;i&&(i.setBindings({sampler:e||t}),i.setUniforms({hasTexture:Boolean(e)}))}}CL.defaultProps=EL,CL.layerName="SimpleMeshLayer";var SL,BL=CL;function IL(e,t,i,n){const r={defines:{MANUAL_SRGB:1,SRGB_FAST_APPROXIMATION:1},bindings:{},uniforms:{u_Camera:[0,0,0],u_MetallicRoughnessValues:[1,1]},parameters:{},glParameters:{},generatedTextures:[]};r.defines.USE_TEX_LOD=1;const{imageBasedLightingEnvironment:o}=n;return o&&(r.bindings.u_DiffuseEnvSampler=o.diffuseEnvSampler,r.bindings.u_SpecularEnvSampler=o.specularEnvSampler,r.bindings.u_brdfLUT=o.brdfLutTexture,r.uniforms.u_ScaleIBLAmbient=[1,1]),n?.pbrDebug&&(r.defines.PBR_DEBUG=1,r.uniforms.u_ScaleDiffBaseMR=[0,0,0,0],r.uniforms.u_ScaleFGDSpec=[0,0,0,0]),i.NORMAL&&(r.defines.HAS_NORMALS=1),i.TANGENT&&n?.useTangents&&(r.defines.HAS_TANGENTS=1),i.TEXCOORD_0&&(r.defines.HAS_UV=1),n?.imageBasedLightingEnvironment&&(r.defines.USE_IBL=1),n?.lights&&(r.defines.USE_LIGHTS=1),t&&function(e,t,i){i.uniforms.pbr_uUnlit=Boolean(t.unlit),t.pbrMetallicRoughness&&function(e,t,i){t.baseColorTexture&&ML(e,t.baseColorTexture,"u_BaseColorSampler","HAS_BASECOLORMAP",i);i.uniforms.u_BaseColorFactor=t.baseColorFactor||[1,1,1,1],t.metallicRoughnessTexture&&ML(e,t.metallicRoughnessTexture,"u_MetallicRoughnessSampler","HAS_METALROUGHNESSMAP",i);const{metallicFactor:n=1,roughnessFactor:r=1}=t;i.uniforms.u_MetallicRoughnessValues=[n,r]}(e,t.pbrMetallicRoughness,i);if(t.normalTexture){ML(e,t.normalTexture,"u_NormalSampler","HAS_NORMALMAP",i);const{scale:n=1}=t.normalTexture;i.uniforms.u_NormalScale=n}if(t.occlusionTexture){ML(e,t.occlusionTexture,"u_OcclusionSampler","HAS_OCCLUSIONMAP",i);const{strength:n=1}=t.occlusionTexture;i.uniforms.u_OcclusionStrength=n}t.emissiveTexture&&(ML(e,t.emissiveTexture,"u_EmissiveSampler","HAS_EMISSIVEMAP",i),i.uniforms.u_EmissiveFactor=t.emissiveFactor||[0,0,0]);switch(t.alphaMode){case"MASK":const{alphaCutoff:e=.5}=t;i.defines.ALPHA_CUTOFF=1,i.uniforms.u_AlphaCutoff=e;break;case"BLEND":Gp.warn("glTF BLEND alphaMode might not work well because it requires mesh sorting")(),i.parameters.blendColorOperation="add",i.parameters.blendColorSrcFactor="src-alpha",i.parameters.blendColorDstFactor="one-minus-src-alpha",i.parameters.blendAlphaOperation="add",i.parameters.blendAlphaSrcFactor="one",i.parameters.blendAlphaDstFactor="one-minus-src-alpha",i.glParameters.blend=!0,i.glParameters.blendEquation=SL.FUNC_ADD,i.glParameters.blendFunc=[SL.SRC_ALPHA,SL.ONE_MINUS_SRC_ALPHA,SL.ONE,SL.ONE_MINUS_SRC_ALPHA]}}(e,t,r),r}function ML(e,t,i,n=null,r){const o=t?.texture?.sampler?.parameters||{},s=t.texture.source.image;let a,l={};s.compressed?(a=s,l={[SL.TEXTURE_MIN_FILTER]:s.data.length>1?SL.LINEAR_MIPMAP_NEAREST:SL.LINEAR}):a={data:s};const c=e.createTexture({id:t.uniformName||t.id,parameters:{...o,...l},pixelStore:{[SL.UNPACK_FLIP_Y_WEBGL]:!1},...a});r.bindings[i]=c,n&&(r.defines[n]=1),r.generatedTextures.push(c)}!function(e){e[e.FUNC_ADD=32774]="FUNC_ADD",e[e.ONE=1]="ONE",e[e.SRC_ALPHA=770]="SRC_ALPHA",e[e.ONE_MINUS_SRC_ALPHA=771]="ONE_MINUS_SRC_ALPHA",e[e.TEXTURE_MIN_FILTER=10241]="TEXTURE_MIN_FILTER",e[e.LINEAR=9729]="LINEAR",e[e.LINEAR_MIPMAP_NEAREST=9985]="LINEAR_MIPMAP_NEAREST",e[e.UNPACK_FLIP_Y_WEBGL=37440]="UNPACK_FLIP_Y_WEBGL"}(SL||(SL={}));const PL=(globalThis._loadersgl_?.version||(globalThis._loadersgl_=globalThis._loadersgl_||{},globalThis._loadersgl_.version="4.3.3"),globalThis._loadersgl_.version);const RL="object"!=typeof process||"[object process]"!==String(process)||process.browser,LL="function"==typeof importScripts,FL="undefined"!=typeof process&&process.version&&/v([0-9]*)/.exec(process.version);FL&&parseFloat(FL[1]);const kL={};async function DL(e,t=null,i={},n=null){return t&&(e=function(e,t,i={},n=null){if(!i.useLocalLibraries&&e.startsWith("http"))return e;n=n||e;const r=i.modules||{};if(r[n])return r[n];if(!RL)return`modules/${t}/dist/libs/${n}`;if(i.CDN)return function(e,t){if(!e)throw new Error(t||"loaders.gl assertion failed.")}(i.CDN.startsWith("http")),`${i.CDN}/${t}@${PL}/dist/libs/${n}`;if(LL)return`../src/libs/${n}`;return`modules/${t}/src/libs/${n}`}(e,t,i,n)),kL[e]=kL[e]||async function(e){if(e.endsWith("wasm"))return await async function(e){const{readFileAsArrayBuffer:t}=globalThis.loaders||{};if(RL||!t||e.startsWith("http")){const t=await fetch(e);return await t.arrayBuffer()}return await t(e)}(e);if(!RL)try{const{requireFromFile:t}=globalThis.loaders||{};return await(t?.(e))}catch(e){return console.error(e),null}if(LL)return importScripts(e);const t=await async function(e){const{readFileAsText:t}=globalThis.loaders||{};if(RL||!t||e.startsWith("http")){const t=await fetch(e);return await t.text()}return await t(e)}(e);return function(e,t){if(!RL){const{requireFromString:i}=globalThis.loaders||{};return i?.(e,t)}if(LL)return eval.call(globalThis,e),null;const i=document.createElement("script");i.id=t;try{i.appendChild(document.createTextNode(e))}catch(t){i.text=e}return document.body.appendChild(i),null}(t,e)}(e),await kL[e]}const OL="basis_transcoder.js",zL="basis_transcoder.wasm",UL="basis_encoder.js",NL="basis_encoder.wasm";let VL,jL;async function HL(e){var t;t=e.modules,globalThis.loaders||={},globalThis.loaders.modules||={},Object.assign(globalThis.loaders.modules,t);const i=function(e){const t=globalThis.loaders?.modules?.[e];return t||null}("basis");return i||(VL||=async function(e){let t=null,i=null;return[t,i]=await Promise.all([await DL(OL,"textures",e),await DL(zL,"textures",e)]),t=t||globalThis.BASIS,await function(e,t){const i={};t&&(i.wasmBinary=t);return new Promise(t=>{e(i).then(e=>{const{BasisFile:i,initializeBasis:n}=e;n(),t({BasisFile:i})})})}(t,i)}(e),await VL)}async function QL(e){const t=e.modules||{};return t.basisEncoder?t.basisEncoder:(jL=jL||async function(e){let t=null,i=null;return[t,i]=await Promise.all([await DL(UL,"textures",e),await DL(NL,"textures",e)]),t=t||globalThis.BASIS,await function(e,t){const i={};t&&(i.wasmBinary=t);return new Promise(t=>{e(i).then(e=>{const{BasisFile:i,KTX2File:n,initializeBasis:r,BasisEncoder:o}=e;r(),t({BasisFile:i,KTX2File:n,BasisEncoder:o})})})}(t,i)}(e),await jL)}const $L=["","WEBKIT_","MOZ_"],ZL={WEBGL_compressed_texture_s3tc:"dxt",WEBGL_compressed_texture_s3tc_srgb:"dxt-srgb",WEBGL_compressed_texture_etc1:"etc1",WEBGL_compressed_texture_etc:"etc2",WEBGL_compressed_texture_pvrtc:"pvrtc",WEBGL_compressed_texture_atc:"atc",WEBGL_compressed_texture_astc:"astc",EXT_texture_compression_rgtc:"rgtc"};let WL=null;function qL(e){if(!WL){e=e||function(){try{return document.createElement("canvas").getContext("webgl")}catch(e){return null}}()||void 0,WL=new Set;for(const t of $L)for(const i in ZL)if(e&&e.getExtension(`${t}${i}`)){const e=ZL[i];WL.add(e)}}return WL}const KL=[171,75,84,88,32,50,48,187,13,10,26,10];const XL={etc1:{basisFormat:0,compressed:!0,format:36196},etc2:{basisFormat:1,compressed:!0},bc1:{basisFormat:2,compressed:!0,format:33776},bc3:{basisFormat:3,compressed:!0,format:33779},bc4:{basisFormat:4,compressed:!0},bc5:{basisFormat:5,compressed:!0},"bc7-m6-opaque-only":{basisFormat:6,compressed:!0},"bc7-m5":{basisFormat:7,compressed:!0},"pvrtc1-4-rgb":{basisFormat:8,compressed:!0,format:35840},"pvrtc1-4-rgba":{basisFormat:9,compressed:!0,format:35842},"astc-4x4":{basisFormat:10,compressed:!0,format:37808},"atc-rgb":{basisFormat:11,compressed:!0},"atc-rgba-interpolated-alpha":{basisFormat:12,compressed:!0},rgba32:{basisFormat:13,compressed:!1},rgb565:{basisFormat:14,compressed:!1},bgr565:{basisFormat:15,compressed:!1},rgba4444:{basisFormat:16,compressed:!1}};function JL(e,t,i){const n=new e(new Uint8Array(t));try{if(!n.startTranscoding())throw new Error("Failed to start basis transcoding");const e=n.getNumImages(),t=[];for(let r=0;r{!function(e,{input:t,interpolation:i,output:n},r,o){const s=t[t.length-1],a=e%s,l=t.findIndex(e=>e>=a),c=Math.max(0,l-1);if(!Array.isArray(r[o]))switch(o){case"translation":r[o]=[0,0,0];break;case"rotation":r[o]=[0,0,0,1];break;case"scale":r[o]=[1,1,1];break;default:Gp.warn(`Bad animation path ${o}`)()}cf(r[o].length===n[c].length);const u=t[c],h=t[l];switch(i){case"STEP":!function(e,t,i){for(let n=0;nu){const e=(a-u)/(h-u);!function(e,t,i,n,r){if("rotation"===t){hF.slerp({start:i,target:n,ratio:r});for(let i=0;iu){const e=(a-u)/(h-u),t=h-u;!function(e,t,{p0:i,outTangent0:n,inTangent1:r,p1:o,tDiff:s,ratio:a}){for(let l=0;l{const n=t.name||`Animation-${i}`,r=t.samplers.map(({input:t,interpolation:i="LINEAR",output:n})=>({input:cF(e.accessors[t]),interpolation:i,output:cF(e.accessors[n])})),o=t.channels.map(({sampler:t,target:i})=>({sampler:r[t],target:e.nodes[i.node],path:i.path}));return new aF({name:n,channels:o})})}animate(e){this.setTime(e)}setTime(e){this.animations.forEach(t=>t.animate(e))}getAnimations(){return this.animations}}function cF(e){if(!e._animation){const t=sF[e.componentType],i=oF[e.type],n=i*e.count,{buffer:r,byteOffset:o}=e.bufferView.data,s=new t(r,o+(e.byteOffset||0),n);if(1===i)e._animation=Array.from(s);else{const t=[];for(let e=0;ethis.createScene(e))}createAnimator(){return Array.isArray(this.gltf.animations)?new lF(this.gltf):null}createScene(e){const t=(e.nodes||[]).map(e=>this.createNode(e));return new Bx({id:e.name||e.id,children:t})}createNode(e){if(!e._node){const t=(e.children||[]).map(e=>this.createNode(e));e.mesh&&t.push(this.createMesh(e.mesh));const i=new Bx({id:e.name||e.id,children:t});if(e.matrix)i.setMatrix(e.matrix);else{if(i.matrix.identity(),e.translation&&i.matrix.translate(e.translation),e.rotation){const t=(new HA).fromQuaternion(e.rotation);i.matrix.multiplyRight(t)}e.scale&&i.matrix.scale(e.scale)}e._node=i}return e._node}createMesh(e){if(!e._mesh){const t=(e.primitives||[]).map((t,i)=>this.createPrimitive(t,i,e)),i=new Bx({id:e.name||e.id,children:t});e._mesh=i}return e._mesh}createPrimitive(e,t,i){const n=e.name||`${i.name||i.id}-primitive-${t}`,r=function(e){switch(e){case mF.POINTS:return"point-list";case mF.LINES:return"line-list";case mF.LINE_STRIP:return"line-strip";case mF.LINE_LOOP:return"line-loop-webgl";case mF.TRIANGLES:return"triangle-list";case mF.TRIANGLE_STRIP:return"triangle-strip";case mF.TRIANGLE_FAN:return"triangle-fan-webgl";default:throw new Error(e)}}(e.mode||4),o=e.indices?e.indices.count:this.getVertexCount(e.attributes),s=function(e,t){const{id:i,geometry:n,material:r,vertexCount:o,materialOptions:s,modelOptions:a}=t,l=IL(e,r,n.attributes,s);Gp.info(4,"createGLTFModel defines: ",l.defines)();const c={id:i,geometry:n,topology:n.topology,vertexCount:o,modules:[Ay],vs:dF(0,"\n#pragma vscode_glsllint_stage: vert\n#if (__VERSION__ < 300)\n #define _attr attribute\n#else\n #define _attr in\n#endif\n\n // _attr vec4 POSITION;\n _attr vec4 positions;\n\n #ifdef HAS_NORMALS\n // _attr vec4 NORMAL;\n _attr vec4 normals;\n #endif\n\n #ifdef HAS_TANGENTS\n _attr vec4 TANGENT;\n #endif\n\n #ifdef HAS_UV\n // _attr vec2 TEXCOORD_0;\n _attr vec2 texCoords;\n #endif\n\n void main(void) {\n vec4 _NORMAL = vec4(0.);\n vec4 _TANGENT = vec4(0.);\n vec2 _TEXCOORD_0 = vec2(0.);\n\n #ifdef HAS_NORMALS\n _NORMAL = normals;\n #endif\n\n #ifdef HAS_TANGENTS\n _TANGENT = TANGENT;\n #endif\n\n #ifdef HAS_UV\n _TEXCOORD_0 = texCoords;\n #endif\n\n pbr_setPositionNormalTangentUV(positions, _NORMAL, _TANGENT, _TEXCOORD_0);\n gl_Position = u_MVPMatrix * positions;\n }\n"),fs:dF(0,"\n#pragma vscode_glsllint_stage: frag\n#if (__VERSION__ < 300)\n #define fragmentColor gl_FragColor\n#else\n out vec4 fragmentColor;\n#endif\n\n void main(void) {\n vec3 pos = pbr_vPosition;\n fragmentColor = pbr_filterColor(vec4(1.0));\n }\n"),...a,bindings:{...l.bindings,...a.bindings},defines:{...l.defines,...a.defines},parameters:{depthWriteEnabled:!0,depthCompare:"less",depthFormat:"depth24plus",cullMode:"back",...l.parameters,...a.parameters},uniforms:{...l.uniforms,...a.uniforms}},u=new bx(e,c);return new Ix({managedResources:[],model:u})}(this.device,{id:n,geometry:this.createGeometry(n,e,r),material:e.material,materialOptions:this.options,modelOptions:this.options.modelOptions,vertexCount:o});return s.bounds=[e.attributes.POSITION.min,e.attributes.POSITION.max],s}getVertexCount(e){throw new Error("getVertexCount not implemented")}createGeometry(e,t,i){const n={};for(const[e,i]of Object.entries(t.attributes)){const{components:t,size:r,value:o}=i;n[e]={size:r??t,value:o}}return new Cx({id:e,topology:i,indices:t.indices.value,attributes:n})}createBuffer(e,t){e.bufferView||(e.bufferView={});const{bufferView:i}=e;return i.lumaBuffers||(i.lumaBuffers={}),i.lumaBuffers[t]||(i.lumaBuffers[t]=this.device.createBuffer({id:`from-${i.id}`,data:i.data||e.value})),i.lumaBuffers[t]}createSampler(e){return e}needsPOT(){return!1}}var mF;function gF(e,t){if(!e)throw new Error(t||"assert failed: gltf")}!function(e){e[e.POINTS=0]="POINTS",e[e.LINES=1]="LINES",e[e.LINE_LOOP=2]="LINE_LOOP",e[e.LINE_STRIP=3]="LINE_STRIP",e[e.TRIANGLES=4]="TRIANGLES",e[e.TRIANGLE_STRIP=5]="TRIANGLE_STRIP",e[e.TRIANGLE_FAN=6]="TRIANGLE_FAN"}(mF||(mF={}));const _F={SCALAR:1,VEC2:2,VEC3:3,VEC4:4,MAT2:4,MAT3:9,MAT4:16},AF={5120:1,5121:1,5122:2,5123:2,5125:4,5126:4},yF=["SCALAR","VEC2","VEC3","VEC4"],vF=[[Int8Array,5120],[Uint8Array,5121],[Int16Array,5122],[Uint16Array,5123],[Uint32Array,5125],[Float32Array,5126],[Float64Array,5130]],xF=new Map(vF),bF={SCALAR:1,VEC2:2,VEC3:3,VEC4:4,MAT2:4,MAT3:9,MAT4:16},wF={5120:1,5121:1,5122:2,5123:2,5125:4,5126:4},TF={5120:Int8Array,5121:Uint8Array,5122:Int16Array,5123:Uint16Array,5125:Uint32Array,5126:Float32Array};function EF(e){return yF[e-1]||yF[0]}function CF(e){const t=xF.get(e.constructor);if(!t)throw new Error("Illegal typed array");return t}function SF(e,t){const i=TF[e.componentType],n=bF[e.type],r=wF[e.componentType],o=e.count*n,s=e.count*n*r;gF(s>=0&&s<=t.byteLength);return{ArrayType:i,length:o,byteLength:s,componentByteSize:AF[e.componentType],numberOfComponentsInElement:_F[e.type]}}function BF(e){let{images:t,bufferViews:i}=e;t=t||[],i=i||[];const n=t.map(e=>e.bufferView);i=i.filter(e=>!n.includes(e));const r=i.reduce((e,t)=>e+t.byteLength,0),o=t.reduce((e,t)=>{const{width:i,height:n}=t.image;return e+i*n},0);return r+Math.ceil(4*o*1.33)}class IF{gltf;sourceBuffers;byteLength;constructor(e){this.gltf={json:e?.json||{asset:{version:"2.0",generator:"loaders.gl"},buffers:[],extensions:{},extensionsRequired:[],extensionsUsed:[]},buffers:e?.buffers||[],images:e?.images||[]},this.sourceBuffers=[],this.byteLength=0,this.gltf.buffers&&this.gltf.buffers[0]&&(this.byteLength=this.gltf.buffers[0].byteLength,this.sourceBuffers=[this.gltf.buffers[0]])}get json(){return this.gltf.json}getApplicationData(e){return this.json[e]}getExtraData(e){return(this.json.extras||{})[e]}hasExtension(e){const t=this.getUsedExtensions().find(t=>t===e),i=this.getRequiredExtensions().find(t=>t===e);return"string"==typeof t||"string"==typeof i}getExtension(e){const t=this.getUsedExtensions().find(t=>t===e),i=this.json.extensions||{};return t?i[e]:null}getRequiredExtension(e){return this.getRequiredExtensions().find(t=>t===e)?this.getExtension(e):null}getRequiredExtensions(){return this.json.extensionsRequired||[]}getUsedExtensions(){return this.json.extensionsUsed||[]}getRemovedExtensions(){return this.json.extensionsRemoved||[]}getObjectExtension(e,t){return(e.extensions||{})[t]}getScene(e){return this.getObject("scenes",e)}getNode(e){return this.getObject("nodes",e)}getSkin(e){return this.getObject("skins",e)}getMesh(e){return this.getObject("meshes",e)}getMaterial(e){return this.getObject("materials",e)}getAccessor(e){return this.getObject("accessors",e)}getTexture(e){return this.getObject("textures",e)}getSampler(e){return this.getObject("samplers",e)}getImage(e){return this.getObject("images",e)}getBufferView(e){return this.getObject("bufferViews",e)}getBuffer(e){return this.getObject("buffers",e)}getObject(e,t){if("object"==typeof t)return t;const i=this.json[e]&&this.json[e][t];if(!i)throw new Error(`glTF file error: Could not find ${e}[${t}]`);return i}getTypedArrayForBufferView(e){const t=(e=this.getBufferView(e)).buffer,i=this.gltf.buffers[t];gF(i);const n=(e.byteOffset||0)+i.byteOffset;return new Uint8Array(i.arrayBuffer,n,e.byteLength)}getTypedArrayForAccessor(e){const t=this.getAccessor(e);return function(e,t,i){const n="number"==typeof i?e.accessors?.[i]:i;if(!n)throw new Error(`No gltf accessor ${JSON.stringify(i)}`);const r=e.bufferViews?.[n.bufferView||0];if(!r)throw new Error(`No gltf buffer view for accessor ${r}`);const{arrayBuffer:o,byteOffset:s}=t[r.buffer],a=(s||0)+(n.byteOffset||0)+(r.byteOffset||0),{ArrayType:l,length:c,componentByteSize:u,numberOfComponentsInElement:h}=SF(n,r),d=u*h,p=r.byteStride||d;if(void 0===r.byteStride||r.byteStride===d)return new l(o,a,c);const f=new l(c);for(let e=0;et===e)||this.json.extensionsUsed.push(e)}registerRequiredExtension(e){this.registerUsedExtension(e),this.json.extensionsRequired=this.json.extensionsRequired||[],this.json.extensionsRequired.find(t=>t===e)||this.json.extensionsRequired.push(e)}removeExtension(e){if(this.json.extensions?.[e]){this.json.extensionsRemoved=this.json.extensionsRemoved||[];const t=this.json.extensionsRemoved;t.includes(e)||t.push(e)}this.json.extensions&&delete this.json.extensions[e],this.json.extensionsRequired&&this._removeStringFromArray(this.json.extensionsRequired,e),this.json.extensionsUsed&&this._removeStringFromArray(this.json.extensionsUsed,e)}setDefaultScene(e){this.json.scene=e}addScene(e){const{nodeIndices:t}=e;return this.json.scenes=this.json.scenes||[],this.json.scenes.push({nodes:t}),this.json.scenes.length-1}addNode(e){const{meshIndex:t,matrix:i}=e;this.json.nodes=this.json.nodes||[];const n={mesh:t};return i&&(n.matrix=i),this.json.nodes.push(n),this.json.nodes.length-1}addMesh(e){const{attributes:t,indices:i,material:n,mode:r=4}=e,o={primitives:[{attributes:this._addAttributes(t),mode:r}]};if(i){const e=this._addIndices(i);o.primitives[0].indices=e}return Number.isFinite(n)&&(o.primitives[0].material=n),this.json.meshes=this.json.meshes||[],this.json.meshes.push(o),this.json.meshes.length-1}addPointCloud(e){const t={primitives:[{attributes:this._addAttributes(e),mode:0}]};return this.json.meshes=this.json.meshes||[],this.json.meshes.push(t),this.json.meshes.length-1}addImage(e,t){const i=Yd(e),n=t||i?.mimeType,r={bufferView:this.addBufferView(e),mimeType:n};return this.json.images=this.json.images||[],this.json.images.push(r),this.json.images.length-1}addBufferView(e,t=0,i=this.byteLength){const n=e.byteLength;gF(Number.isFinite(n)),this.sourceBuffers=this.sourceBuffers||[],this.sourceBuffers.push(e);const r={buffer:t,byteOffset:i,byteLength:n};return this.byteLength+=bh(n,4),this.json.bufferViews=this.json.bufferViews||[],this.json.bufferViews.push(r),this.json.bufferViews.length-1}addAccessor(e,t){const i={bufferView:e,type:EF(t.size),componentType:t.componentType,count:t.count,max:t.max,min:t.min};return this.json.accessors=this.json.accessors||[],this.json.accessors.push(i),this.json.accessors.length-1}addBinaryBuffer(e,t={size:3}){const i=this.addBufferView(e);let n={min:t.min,max:t.max};n.min&&n.max||(n=this._getAccessorMinMax(e,t.size));const r={size:t.size,componentType:CF(e),count:Math.round(e.length/t.size),min:n.min,max:n.max};return this.addAccessor(i,Object.assign(r,t))}addTexture(e){const{imageIndex:t}=e,i={source:t};return this.json.textures=this.json.textures||[],this.json.textures.push(i),this.json.textures.length-1}addMaterial(e){return this.json.materials=this.json.materials||[],this.json.materials.push(e),this.json.materials.length-1}createBinaryChunk(){const e=this.byteLength,t=new ArrayBuffer(e),i=new Uint8Array(t);let n=0;for(const e of this.sourceBuffers||[])n=wh(e,i,n);this.json?.buffers?.[0]?this.json.buffers[0].byteLength=e:this.json.buffers=[{byteLength:e}],this.gltf.binary=t,this.sourceBuffers=[t],this.gltf.buffers=[{arrayBuffer:t,byteOffset:0,byteLength:t.byteLength}]}_removeStringFromArray(e,t){let i=!0;for(;i;){const n=e.indexOf(t);n>-1?e.splice(n,1):i=!1}}_addAttributes(e={}){const t={};for(const i in e){const n=e[i],r=this._getGltfAttributeName(i),o=this.addBinaryBuffer(n.value,n);t[r]=o}return t}_addIndices(e){return this.addBinaryBuffer(e,{size:1})}_getGltfAttributeName(e){switch(e.toLowerCase()){case"position":case"positions":case"vertices":return"POSITION";case"normal":case"normals":return"NORMAL";case"color":case"colors":return"COLOR_0";case"texcoord":case"texcoords":return"TEXCOORD_0";default:return e}}_getAccessorMinMax(e,t){const i={min:null,max:null};if(e.lengtht===e);-1===t&&(t=n.push(e)-1),o.push(t)}const s=new Uint32Array(o),a=e.gltf.buffers.push({arrayBuffer:s.buffer,byteOffset:s.byteOffset,byteLength:s.byteLength})-1,l=e.addBufferView(s,a,0),c=e.addAccessor(l,{size:1,componentType:CF(s),count:s.length});r.attributes[t]=c}function UF(e,t,i,n,r=[0]){const o={r:{offset:0,shift:0},g:{offset:1,shift:8},b:{offset:2,shift:16},a:{offset:3,shift:24}},s=i[n],a=i[n+1];let l=1;!t||-1===t.indexOf("image/jpeg")&&-1===t.indexOf("image/png")||(l=4);const c=function(e,t,i,n=1){const r=i.width,o=MF(e)*(r-1),s=Math.round(o),a=i.height,l=MF(t)*(a-1),c=Math.round(l),u=i.components?i.components:n,h=(c*r+s)*u;return h}(s,a,e,l);let u=0;for(const t of r){const i="number"==typeof t?Object.values(o)[t]:o[t],n=c+i.offset,r=Vd(e);if(r.data.length<=n)throw new Error(`${r.data.length} <= ${n}`);u|=r.data[n]<n)break;const l=t/r,c=a/r;o.push(e.slice(l,l+c))}return o}function VF(e,t,i){const n=[];for(let r=0;r{if(i.data){const{accessorKey:o,index:s}=function(e){const t="_FEATURE_ID_",i=Object.keys(e).filter(e=>0===e.indexOf(t));let n=-1;for(const e of i){const i=Number(e.substring(t.length));i>n&&(n=i)}n++;const r=`${t}${n}`;return{accessorKey:r,index:n}}(t.attributes),a=new Uint32Array(i.data);n[r]={featureCount:a.length,propertyTable:i.propertyTable,attribute:s},e.gltf.buffers.push({arrayBuffer:a.buffer,byteOffset:a.byteOffset,byteLength:a.byteLength});const l=e.addBufferView(a),c=e.addAccessor(l,{size:1,componentType:CF(a),count:a.length});t.attributes[o]=c}})}var ZF=Object.freeze({__proto__:null,name:HF,decode:async function(e,t){!function(e,t){const i=e.gltf.json;if(!i.meshes)return;for(const n of i.meshes)for(const i of n.primitives)QF(e,i,t)}(new IF(e),t)},encode:function(e,t){const i=new IF(e);return function(e){const t=e.gltf.json.meshes;if(!t)return;for(const i of t)for(const t of i.primitives)$F(e,t)}(i),i.createBinaryChunk(),i.gltf},createExtMeshFeatures:function(e,t,i,n){t.extensions||(t.extensions={});let r=t.extensions[GF];r||(r={featureIds:[]},t.extensions[GF]=r);const{featureIds:o}=r,s={featureCount:i.length,propertyTable:n,data:i};o.push(s),e.addObjectExtension(t,GF,r)}});const WF="EXT_structural_metadata",qF=WF;function KF(e,t){for(const i of e)if(i.class===t)return i;return null}function XF(e,t,i,n){if(!t)return;const r=i.extensions?.[WF],o=r?.propertyTextures;if(o)for(const r of o){JF(e,t[r],i,n)}}function JF(e,t,i,n){if(!t.properties)return;n.dataAttributeNames||(n.dataAttributeNames=[]);const r=t.class;for(const o in t.properties){const s=`${r}_${o}`,a=t.properties?.[o];if(!a)continue;a.data||(a.data=[]);const l=a.data,c=OF(e,a,i);null!==c&&(zF(e,s,c,l,i),a.data=l,n.dataAttributeNames.push(s))}}function YF(e,t,i){const n=t.classes?.[i.class];if(!n)throw new Error(`Incorrect data in the EXT_structural_metadata extension: no schema class with name ${i.class}`);const r=i.count;for(const o in n.properties){const s=n.properties[o],a=i.properties?.[o];if(a){const i=ek(e,t,s,r,a);a.data=i}}}function ek(e,t,i,n,r){let o=[];const s=r.values,a=e.getTypedArrayForBufferView(s),l=function(e,t,i,n){if(t.array&&void 0===t.count&&void 0!==i.arrayOffsets)return kF(e,i.arrayOffsets,i.arrayOffsetType||"UINT32",n);return null}(e,i,r,n),c=function(e,t,i){if(void 0!==t.stringOffsets)return kF(e,t.stringOffsets,t.stringOffsetType||"UINT32",i);return null}(e,r,n);switch(i.type){case"SCALAR":case"VEC2":case"VEC3":case"VEC4":case"MAT2":case"MAT3":case"MAT4":o=function(e,t,i,n){const r=e.array,o=e.count,s=FF(e.type,e.componentType),a=i.byteLength/s;let l;l=e.componentType?DF(i,e.type,e.componentType,a):i;if(r)return n?NF(l,t,n,i.length,s):o?VF(l,t,o):[];return l}(i,n,a,l);break;case"BOOLEAN":throw new Error(`Not implemented - classProperty.type=${i.type}`);case"STRING":o=jF(n,a,l,c);break;case"ENUM":o=function(e,t,i,n,r){const o=t.enumType;if(!o)throw new Error("Incorrect data in the EXT_structural_metadata extension: classProperty.enumType is not set for type ENUM");const s=e.enums?.[o];if(!s)throw new Error(`Incorrect data in the EXT_structural_metadata extension: schema.enums does't contain ${o}`);const a=s.valueType||"UINT16",l=FF(t.type,a),c=n.byteLength/l;let u=DF(n,t.type,a,c);u||(u=n);if(t.array){if(r)return function(e){const{valuesData:t,numberOfElements:i,arrayOffsets:n,valuesDataBytesLength:r,elementSize:o,enumEntry:s}=e,a=[];for(let e=0;er)break;const c=tk(t,i/o,l/o,s);a.push(c)}return a}({valuesData:u,numberOfElements:i,arrayOffsets:r,valuesDataBytesLength:n.length,elementSize:l,enumEntry:s});const e=t.count;return e?function(e,t,i,n){const r=[];for(let o=0;o20);const n=t.getUint32(i+0,Ak),r=t.getUint32(i+4,Ak);return i+=8,Tu(0===r),wk(e,t,i,n),i+=n,i+=Tk(e,t,i,e.header.byteLength),i}(e,r,i);case 2:return function(e,t,i,n){return Tu(e.header.byteLength>20),function(e,t,i,n){for(;i+8<=e.header.byteLength;){const r=t.getUint32(i+0,Ak),o=t.getUint32(i+4,Ak);switch(i+=8,o){case vk:wk(e,t,i,r);break;case xk:Tk(e,t,i,r);break;case 0:n.strict||wk(e,t,i,r);break;case 1:n.strict||Tk(e,t,i,r)}i+=bh(r,4)}}(e,t,i,n),i+e.header.byteLength}(e,r,i,{});default:throw new Error(`Invalid GLB version ${e.version}. Only supports version 1 and 2.`)}}function wk(e,t,i,n){const r=new Uint8Array(t.buffer,i,n),o=new TextDecoder("utf8").decode(r);return e.json=JSON.parse(o),bh(n,4)}function Tk(e,t,i,n){return e.header.hasBinChunk=!0,e.binChunks.push({byteOffset:i,byteLength:n,arrayBuffer:t.buffer}),bh(n,4)}function Ek(e,t){if(e.startsWith("data:")||e.startsWith("http:")||e.startsWith("https:"))return e;const i=t.baseUri||t.uri;if(!i)throw new Error(`'baseUri' must be provided to resolve relative url ${e}`);return i.substr(0,i.lastIndexOf("/")+1)+e}const Ck="B9h9z9tFBBBF8fL9gBB9gLaaaaaFa9gEaaaB9gFaFa9gEaaaFaEMcBFFFGGGEIIILF9wFFFLEFBFKNFaFCx/IFMO/LFVK9tv9t9vq95GBt9f9f939h9z9t9f9j9h9s9s9f9jW9vq9zBBp9tv9z9o9v9wW9f9kv9j9v9kv9WvqWv94h919m9mvqBF8Z9tv9z9o9v9wW9f9kv9j9v9kv9J9u9kv94h919m9mvqBGy9tv9z9o9v9wW9f9kv9j9v9kv9J9u9kv949TvZ91v9u9jvBEn9tv9z9o9v9wW9f9kv9j9v9kv69p9sWvq9P9jWBIi9tv9z9o9v9wW9f9kv9j9v9kv69p9sWvq9R919hWBLn9tv9z9o9v9wW9f9kv9j9v9kv69p9sWvq9F949wBKI9z9iqlBOc+x8ycGBM/qQFTa8jUUUUBCU/EBlHL8kUUUUBC9+RKGXAGCFJAI9LQBCaRKAE2BBC+gF9HQBALAEAIJHOAGlAGTkUUUBRNCUoBAG9uC/wgBZHKCUGAKCUG9JyRVAECFJRICBRcGXEXAcAF9PQFAVAFAclAcAVJAF9JyRMGXGXAG9FQBAMCbJHKC9wZRSAKCIrCEJCGrRQANCUGJRfCBRbAIRTEXGXAOATlAQ9PQBCBRISEMATAQJRIGXAS9FQBCBRtCBREEXGXAOAIlCi9PQBCBRISLMANCU/CBJAEJRKGXGXGXGXGXATAECKrJ2BBAtCKZrCEZfIBFGEBMAKhB83EBAKCNJhB83EBSEMAKAI2BIAI2BBHmCKrHYAYCE6HYy86BBAKCFJAICIJAYJHY2BBAmCIrCEZHPAPCE6HPy86BBAKCGJAYAPJHY2BBAmCGrCEZHPAPCE6HPy86BBAKCEJAYAPJHY2BBAmCEZHmAmCE6Hmy86BBAKCIJAYAmJHY2BBAI2BFHmCKrHPAPCE6HPy86BBAKCLJAYAPJHY2BBAmCIrCEZHPAPCE6HPy86BBAKCKJAYAPJHY2BBAmCGrCEZHPAPCE6HPy86BBAKCOJAYAPJHY2BBAmCEZHmAmCE6Hmy86BBAKCNJAYAmJHY2BBAI2BGHmCKrHPAPCE6HPy86BBAKCVJAYAPJHY2BBAmCIrCEZHPAPCE6HPy86BBAKCcJAYAPJHY2BBAmCGrCEZHPAPCE6HPy86BBAKCMJAYAPJHY2BBAmCEZHmAmCE6Hmy86BBAKCSJAYAmJHm2BBAI2BEHICKrHYAYCE6HYy86BBAKCQJAmAYJHm2BBAICIrCEZHYAYCE6HYy86BBAKCfJAmAYJHm2BBAICGrCEZHYAYCE6HYy86BBAKCbJAmAYJHK2BBAICEZHIAICE6HIy86BBAKAIJRISGMAKAI2BNAI2BBHmCIrHYAYCb6HYy86BBAKCFJAICNJAYJHY2BBAmCbZHmAmCb6Hmy86BBAKCGJAYAmJHm2BBAI2BFHYCIrHPAPCb6HPy86BBAKCEJAmAPJHm2BBAYCbZHYAYCb6HYy86BBAKCIJAmAYJHm2BBAI2BGHYCIrHPAPCb6HPy86BBAKCLJAmAPJHm2BBAYCbZHYAYCb6HYy86BBAKCKJAmAYJHm2BBAI2BEHYCIrHPAPCb6HPy86BBAKCOJAmAPJHm2BBAYCbZHYAYCb6HYy86BBAKCNJAmAYJHm2BBAI2BIHYCIrHPAPCb6HPy86BBAKCVJAmAPJHm2BBAYCbZHYAYCb6HYy86BBAKCcJAmAYJHm2BBAI2BLHYCIrHPAPCb6HPy86BBAKCMJAmAPJHm2BBAYCbZHYAYCb6HYy86BBAKCSJAmAYJHm2BBAI2BKHYCIrHPAPCb6HPy86BBAKCQJAmAPJHm2BBAYCbZHYAYCb6HYy86BBAKCfJAmAYJHm2BBAI2BOHICIrHYAYCb6HYy86BBAKCbJAmAYJHK2BBAICbZHIAICb6HIy86BBAKAIJRISFMAKAI8pBB83BBAKCNJAICNJ8pBB83BBAICTJRIMAtCGJRtAECTJHEAS9JQBMMGXAIQBCBRISEMGXAM9FQBANAbJ2BBRtCBRKAfREEXAEANCU/CBJAKJ2BBHTCFrCBATCFZl9zAtJHt86BBAEAGJREAKCFJHKAM9HQBMMAfCFJRfAIRTAbCFJHbAG9HQBMMABAcAG9sJANCUGJAMAG9sTkUUUBpANANCUGJAMCaJAG9sJAGTkUUUBpMAMCBAIyAcJRcAIQBMC9+RKSFMCBC99AOAIlAGCAAGCA9Ly6yRKMALCU/EBJ8kUUUUBAKM+OmFTa8jUUUUBCoFlHL8kUUUUBC9+RKGXAFCE9uHOCtJAI9LQBCaRKAE2BBHNC/wFZC/gF9HQBANCbZHVCF9LQBALCoBJCgFCUFT+JUUUBpALC84Jha83EBALC8wJha83EBALC8oJha83EBALCAJha83EBALCiJha83EBALCTJha83EBALha83ENALha83EBAEAIJC9wJRcAECFJHNAOJRMGXAF9FQBCQCbAVCF6yRSABRECBRVCBRQCBRfCBRICBRKEXGXAMAcuQBC9+RKSEMGXGXAN2BBHOC/vF9LQBALCoBJAOCIrCa9zAKJCbZCEWJHb8oGIRTAb8oGBRtGXAOCbZHbAS9PQBALAOCa9zAIJCbZCGWJ8oGBAVAbyROAb9FRbGXGXAGCG9HQBABAt87FBABCIJAO87FBABCGJAT87FBSFMAEAtjGBAECNJAOjGBAECIJATjGBMAVAbJRVALCoBJAKCEWJHmAOjGBAmATjGIALAICGWJAOjGBALCoBJAKCFJCbZHKCEWJHTAtjGBATAOjGIAIAbJRIAKCFJRKSGMGXGXAbCb6QBAQAbJAbC989zJCFJRQSFMAM1BBHbCgFZROGXGXAbCa9MQBAMCFJRMSFMAM1BFHbCgBZCOWAOCgBZqROGXAbCa9MQBAMCGJRMSFMAM1BGHbCgBZCfWAOqROGXAbCa9MQBAMCEJRMSFMAM1BEHbCgBZCdWAOqROGXAbCa9MQBAMCIJRMSFMAM2BIC8cWAOqROAMCLJRMMAOCFrCBAOCFZl9zAQJRQMGXGXAGCG9HQBABAt87FBABCIJAQ87FBABCGJAT87FBSFMAEAtjGBAECNJAQjGBAECIJATjGBMALCoBJAKCEWJHOAQjGBAOATjGIALAICGWJAQjGBALCoBJAKCFJCbZHKCEWJHOAtjGBAOAQjGIAICFJRIAKCFJRKSFMGXAOCDF9LQBALAIAcAOCbZJ2BBHbCIrHTlCbZCGWJ8oGBAVCFJHtATyROALAIAblCbZCGWJ8oGBAtAT9FHmJHtAbCbZHTyRbAT9FRTGXGXAGCG9HQBABAV87FBABCIJAb87FBABCGJAO87FBSFMAEAVjGBAECNJAbjGBAECIJAOjGBMALAICGWJAVjGBALCoBJAKCEWJHYAOjGBAYAVjGIALAICFJHICbZCGWJAOjGBALCoBJAKCFJCbZCEWJHYAbjGBAYAOjGIALAIAmJCbZHICGWJAbjGBALCoBJAKCGJCbZHKCEWJHOAVjGBAOAbjGIAKCFJRKAIATJRIAtATJRVSFMAVCBAM2BBHYyHTAOC/+F6HPJROAYCbZRtGXGXAYCIrHmQBAOCFJRbSFMAORbALAIAmlCbZCGWJ8oGBROMGXGXAtQBAbCFJRVSFMAbRVALAIAYlCbZCGWJ8oGBRbMGXGXAP9FQBAMCFJRYSFMAM1BFHYCgFZRTGXGXAYCa9MQBAMCGJRYSFMAM1BGHYCgBZCOWATCgBZqRTGXAYCa9MQBAMCEJRYSFMAM1BEHYCgBZCfWATqRTGXAYCa9MQBAMCIJRYSFMAM1BIHYCgBZCdWATqRTGXAYCa9MQBAMCLJRYSFMAMCKJRYAM2BLC8cWATqRTMATCFrCBATCFZl9zAQJHQRTMGXGXAmCb6QBAYRPSFMAY1BBHMCgFZROGXGXAMCa9MQBAYCFJRPSFMAY1BFHMCgBZCOWAOCgBZqROGXAMCa9MQBAYCGJRPSFMAY1BGHMCgBZCfWAOqROGXAMCa9MQBAYCEJRPSFMAY1BEHMCgBZCdWAOqROGXAMCa9MQBAYCIJRPSFMAYCLJRPAY2BIC8cWAOqROMAOCFrCBAOCFZl9zAQJHQROMGXGXAtCb6QBAPRMSFMAP1BBHMCgFZRbGXGXAMCa9MQBAPCFJRMSFMAP1BFHMCgBZCOWAbCgBZqRbGXAMCa9MQBAPCGJRMSFMAP1BGHMCgBZCfWAbqRbGXAMCa9MQBAPCEJRMSFMAP1BEHMCgBZCdWAbqRbGXAMCa9MQBAPCIJRMSFMAPCLJRMAP2BIC8cWAbqRbMAbCFrCBAbCFZl9zAQJHQRbMGXGXAGCG9HQBABAT87FBABCIJAb87FBABCGJAO87FBSFMAEATjGBAECNJAbjGBAECIJAOjGBMALCoBJAKCEWJHYAOjGBAYATjGIALAICGWJATjGBALCoBJAKCFJCbZCEWJHYAbjGBAYAOjGIALAICFJHICbZCGWJAOjGBALCoBJAKCGJCbZCEWJHOATjGBAOAbjGIALAIAm9FAmCb6qJHICbZCGWJAbjGBAIAt9FAtCb6qJRIAKCEJRKMANCFJRNABCKJRBAECSJREAKCbZRKAICbZRIAfCEJHfAF9JQBMMCBC99AMAc6yRKMALCoFJ8kUUUUBAKM/tIFGa8jUUUUBCTlRLC9+RKGXAFCLJAI9LQBCaRKAE2BBC/+FZC/QF9HQBALhB83ENAECFJRKAEAIJC98JREGXAF9FQBGXAGCG6QBEXGXAKAE9JQBC9+bMAK1BBHGCgFZRIGXGXAGCa9MQBAKCFJRKSFMAK1BFHGCgBZCOWAICgBZqRIGXAGCa9MQBAKCGJRKSFMAK1BGHGCgBZCfWAIqRIGXAGCa9MQBAKCEJRKSFMAK1BEHGCgBZCdWAIqRIGXAGCa9MQBAKCIJRKSFMAK2BIC8cWAIqRIAKCLJRKMALCNJAICFZCGWqHGAICGrCBAICFrCFZl9zAG8oGBJHIjGBABAIjGBABCIJRBAFCaJHFQBSGMMEXGXAKAE9JQBC9+bMAK1BBHGCgFZRIGXGXAGCa9MQBAKCFJRKSFMAK1BFHGCgBZCOWAICgBZqRIGXAGCa9MQBAKCGJRKSFMAK1BGHGCgBZCfWAIqRIGXAGCa9MQBAKCEJRKSFMAK1BEHGCgBZCdWAIqRIGXAGCa9MQBAKCIJRKSFMAK2BIC8cWAIqRIAKCLJRKMABAICGrCBAICFrCFZl9zALCNJAICFZCGWqHI8oGBJHG87FBAIAGjGBABCGJRBAFCaJHFQBMMCBC99AKAE6yRKMAKM+lLKFaF99GaG99FaG99GXGXAGCI9HQBAF9FQFEXGXGX9DBBB8/9DBBB+/ABCGJHG1BB+yAB1BBHE+yHI+L+TABCFJHL1BBHK+yHO+L+THN9DBBBB9gHVyAN9DBB/+hANAN+U9DBBBBANAVyHcAc+MHMAECa3yAI+SHIAI+UAcAMAKCa3yAO+SHcAc+U+S+S+R+VHO+U+SHN+L9DBBB9P9d9FQBAN+oRESFMCUUUU94REMAGAE86BBGXGX9DBBB8/9DBBB+/Ac9DBBBB9gyAcAO+U+SHN+L9DBBB9P9d9FQBAN+oRGSFMCUUUU94RGMALAG86BBGXGX9DBBB8/9DBBB+/AI9DBBBB9gyAIAO+U+SHN+L9DBBB9P9d9FQBAN+oRGSFMCUUUU94RGMABAG86BBABCIJRBAFCaJHFQBSGMMAF9FQBEXGXGX9DBBB8/9DBBB+/ABCIJHG8uFB+yAB8uFBHE+yHI+L+TABCGJHL8uFBHK+yHO+L+THN9DBBBB9gHVyAN9DB/+g6ANAN+U9DBBBBANAVyHcAc+MHMAECa3yAI+SHIAI+UAcAMAKCa3yAO+SHcAc+U+S+S+R+VHO+U+SHN+L9DBBB9P9d9FQBAN+oRESFMCUUUU94REMAGAE87FBGXGX9DBBB8/9DBBB+/Ac9DBBBB9gyAcAO+U+SHN+L9DBBB9P9d9FQBAN+oRGSFMCUUUU94RGMALAG87FBGXGX9DBBB8/9DBBB+/AI9DBBBB9gyAIAO+U+SHN+L9DBBB9P9d9FQBAN+oRGSFMCUUUU94RGMABAG87FBABCNJRBAFCaJHFQBMMM/SEIEaE99EaF99GXAF9FQBCBREABRIEXGXGX9D/zI818/AICKJ8uFBHLCEq+y+VHKAI8uFB+y+UHO9DB/+g6+U9DBBB8/9DBBB+/AO9DBBBB9gy+SHN+L9DBBB9P9d9FQBAN+oRVSFMCUUUU94RVMAICIJ8uFBRcAICGJ8uFBRMABALCFJCEZAEqCFWJAV87FBGXGXAKAM+y+UHN9DB/+g6+U9DBBB8/9DBBB+/AN9DBBBB9gy+SHS+L9DBBB9P9d9FQBAS+oRMSFMCUUUU94RMMABALCGJCEZAEqCFWJAM87FBGXGXAKAc+y+UHK9DB/+g6+U9DBBB8/9DBBB+/AK9DBBBB9gy+SHS+L9DBBB9P9d9FQBAS+oRcSFMCUUUU94RcMABALCaJCEZAEqCFWJAc87FBGXGX9DBBU8/AOAO+U+TANAN+U+TAKAK+U+THO9DBBBBAO9DBBBB9gy+R9DB/+g6+U9DBBB8/+SHO+L9DBBB9P9d9FQBAO+oRcSFMCUUUU94RcMABALCEZAEqCFWJAc87FBAICNJRIAECIJREAFCaJHFQBMMM9JBGXAGCGrAF9sHF9FQBEXABAB8oGBHGCNWCN91+yAGCi91CnWCUUU/8EJ+++U84GBABCIJRBAFCaJHFQBMMM9TFEaCBCB8oGUkUUBHFABCEJC98ZJHBjGUkUUBGXGXAB8/BCTWHGuQBCaREABAGlCggEJCTrXBCa6QFMAFREMAEM/lFFFaGXGXAFABqCEZ9FQBABRESFMGXGXAGCT9PQBABRESFMABREEXAEAF8oGBjGBAECIJAFCIJ8oGBjGBAECNJAFCNJ8oGBjGBAECSJAFCSJ8oGBjGBAECTJREAFCTJRFAGC9wJHGCb9LQBMMAGCI9JQBEXAEAF8oGBjGBAFCIJRFAECIJREAGC98JHGCE9LQBMMGXAG9FQBEXAEAF2BB86BBAECFJREAFCFJRFAGCaJHGQBMMABMoFFGaGXGXABCEZ9FQBABRESFMAFCgFZC+BwsN9sRIGXGXAGCT9PQBABRESFMABREEXAEAIjGBAECSJAIjGBAECNJAIjGBAECIJAIjGBAECTJREAGC9wJHGCb9LQBMMAGCI9JQBEXAEAIjGBAECIJREAGC98JHGCE9LQBMMGXAG9FQBEXAEAF86BBAECFJREAGCaJHGQBMMABMMMFBCUNMIT9kBB",Sk="B9h9z9tFBBBF8dL9gBB9gLaaaaaFa9gEaaaB9gGaaB9gFaFaEQSBBFBFFGEGEGIILF9wFFFLEFBFKNFaFCx/aFMO/LFVK9tv9t9vq95GBt9f9f939h9z9t9f9j9h9s9s9f9jW9vq9zBBp9tv9z9o9v9wW9f9kv9j9v9kv9WvqWv94h919m9mvqBG8Z9tv9z9o9v9wW9f9kv9j9v9kv9J9u9kv94h919m9mvqBIy9tv9z9o9v9wW9f9kv9j9v9kv9J9u9kv949TvZ91v9u9jvBLn9tv9z9o9v9wW9f9kv9j9v9kv69p9sWvq9P9jWBKi9tv9z9o9v9wW9f9kv9j9v9kv69p9sWvq9R919hWBNn9tv9z9o9v9wW9f9kv9j9v9kv69p9sWvq9F949wBcI9z9iqlBMc/j9JSIBTEM9+FLa8jUUUUBCTlRBCBRFEXCBRGCBREEXABCNJAGJAECUaAFAGrCFZHIy86BBAEAIJREAGCFJHGCN9HQBMAFCx+YUUBJAE86BBAFCEWCxkUUBJAB8pEN83EBAFCFJHFCUG9HQBMMkRIbaG97FaK978jUUUUBCU/KBlHL8kUUUUBC9+RKGXAGCFJAI9LQBCaRKAE2BBC+gF9HQBALAEAIJHOAGlAG/8cBBCUoBAG9uC/wgBZHKCUGAKCUG9JyRNAECFJRKCBRVGXEXAVAF9PQFANAFAVlAVANJAF9JyRcGXGXAG9FQBAcCbJHIC9wZHMCE9sRSAMCFWRQAICIrCEJCGrRfCBRbEXAKRTCBRtGXEXGXAOATlAf9PQBCBRKSLMALCU/CBJAtAM9sJRmATAfJRKCBREGXAMCoB9JQBAOAKlC/gB9JQBCBRIEXAmAIJREGXGXGXGXGXATAICKrJ2BBHYCEZfIBFGEBMAECBDtDMIBSEMAEAKDBBIAKDBBBHPCID+MFAPDQBTFtGmEYIPLdKeOnHPCGD+MFAPDQBTFtGmEYIPLdKeOnC0+G+MiDtD9OHdCEDbD8jHPD8dBhUg/8/4/w/goB9+h84k7HeCEWCxkUUBJDBEBAeCx+YUUBJDBBBHnAnDQBBBBBBBBBBBBBBBBAPD8dFhUg/8/4/w/goB9+h84k7HeCEWCxkUUBJDBEBD9uDQBFGEILKOTtmYPdenDfAdAPD9SDMIBAKCIJAnDeBJAeCx+YUUBJ2BBJRKSGMAEAKDBBNAKDBBBHPCID+MFAPDQBTFtGmEYIPLdKeOnC+P+e+8/4BDtD9OHdCbDbD8jHPD8dBhUg/8/4/w/goB9+h84k7HeCEWCxkUUBJDBEBAeCx+YUUBJDBBBHnAnDQBBBBBBBBBBBBBBBBAPD8dFhUg/8/4/w/goB9+h84k7HeCEWCxkUUBJDBEBD9uDQBFGEILKOTtmYPdenDfAdAPD9SDMIBAKCNJAnDeBJAeCx+YUUBJ2BBJRKSFMAEAKDBBBDMIBAKCTJRKMGXGXGXGXGXAYCGrCEZfIBFGEBMAECBDtDMITSEMAEAKDBBIAKDBBBHPCID+MFAPDQBTFtGmEYIPLdKeOnHPCGD+MFAPDQBTFtGmEYIPLdKeOnC0+G+MiDtD9OHdCEDbD8jHPD8dBhUg/8/4/w/goB9+h84k7HeCEWCxkUUBJDBEBAeCx+YUUBJDBBBHnAnDQBBBBBBBBBBBBBBBBAPD8dFhUg/8/4/w/goB9+h84k7HeCEWCxkUUBJDBEBD9uDQBFGEILKOTtmYPdenDfAdAPD9SDMITAKCIJAnDeBJAeCx+YUUBJ2BBJRKSGMAEAKDBBNAKDBBBHPCID+MFAPDQBTFtGmEYIPLdKeOnC+P+e+8/4BDtD9OHdCbDbD8jHPD8dBhUg/8/4/w/goB9+h84k7HeCEWCxkUUBJDBEBAeCx+YUUBJDBBBHnAnDQBBBBBBBBBBBBBBBBAPD8dFhUg/8/4/w/goB9+h84k7HeCEWCxkUUBJDBEBD9uDQBFGEILKOTtmYPdenDfAdAPD9SDMITAKCNJAnDeBJAeCx+YUUBJ2BBJRKSFMAEAKDBBBDMITAKCTJRKMGXGXGXGXGXAYCIrCEZfIBFGEBMAECBDtDMIASEMAEAKDBBIAKDBBBHPCID+MFAPDQBTFtGmEYIPLdKeOnHPCGD+MFAPDQBTFtGmEYIPLdKeOnC0+G+MiDtD9OHdCEDbD8jHPD8dBhUg/8/4/w/goB9+h84k7HeCEWCxkUUBJDBEBAeCx+YUUBJDBBBHnAnDQBBBBBBBBBBBBBBBBAPD8dFhUg/8/4/w/goB9+h84k7HeCEWCxkUUBJDBEBD9uDQBFGEILKOTtmYPdenDfAdAPD9SDMIAAKCIJAnDeBJAeCx+YUUBJ2BBJRKSGMAEAKDBBNAKDBBBHPCID+MFAPDQBTFtGmEYIPLdKeOnC+P+e+8/4BDtD9OHdCbDbD8jHPD8dBhUg/8/4/w/goB9+h84k7HeCEWCxkUUBJDBEBAeCx+YUUBJDBBBHnAnDQBBBBBBBBBBBBBBBBAPD8dFhUg/8/4/w/goB9+h84k7HeCEWCxkUUBJDBEBD9uDQBFGEILKOTtmYPdenDfAdAPD9SDMIAAKCNJAnDeBJAeCx+YUUBJ2BBJRKSFMAEAKDBBBDMIAAKCTJRKMGXGXGXGXGXAYCKrfIBFGEBMAECBDtDMI8wSEMAEAKDBBIAKDBBBHPCID+MFAPDQBTFtGmEYIPLdKeOnHPCGD+MFAPDQBTFtGmEYIPLdKeOnC0+G+MiDtD9OHdCEDbD8jHPD8dBhUg/8/4/w/goB9+h84k7HYCEWCxkUUBJDBEBAYCx+YUUBJDBBBHnAnDQBBBBBBBBBBBBBBBBAPD8dFhUg/8/4/w/goB9+h84k7HYCEWCxkUUBJDBEBD9uDQBFGEILKOTtmYPdenDfAdAPD9SDMI8wAKCIJAnDeBJAYCx+YUUBJ2BBJRKSGMAEAKDBBNAKDBBBHPCID+MFAPDQBTFtGmEYIPLdKeOnC+P+e+8/4BDtD9OHdCbDbD8jHPD8dBhUg/8/4/w/goB9+h84k7HYCEWCxkUUBJDBEBAYCx+YUUBJDBBBHnAnDQBBBBBBBBBBBBBBBBAPD8dFhUg/8/4/w/goB9+h84k7HYCEWCxkUUBJDBEBD9uDQBFGEILKOTtmYPdenDfAdAPD9SDMI8wAKCNJAnDeBJAYCx+YUUBJ2BBJRKSFMAEAKDBBBDMI8wAKCTJRKMAICoBJREAICUFJAM9LQFAERIAOAKlC/fB9LQBMMGXAEAM9PQBAECErRIEXGXAOAKlCi9PQBCBRKSOMAmAEJRYGXGXGXGXGXATAECKrJ2BBAICKZrCEZfIBFGEBMAYCBDtDMIBSEMAYAKDBBIAKDBBBHPCID+MFAPDQBTFtGmEYIPLdKeOnHPCGD+MFAPDQBTFtGmEYIPLdKeOnC0+G+MiDtD9OHdCEDbD8jHPD8dBhUg/8/4/w/goB9+h84k7HeCEWCxkUUBJDBEBAeCx+YUUBJDBBBHnAnDQBBBBBBBBBBBBBBBBAPD8dFhUg/8/4/w/goB9+h84k7HeCEWCxkUUBJDBEBD9uDQBFGEILKOTtmYPdenDfAdAPD9SDMIBAKCIJAnDeBJAeCx+YUUBJ2BBJRKSGMAYAKDBBNAKDBBBHPCID+MFAPDQBTFtGmEYIPLdKeOnC+P+e+8/4BDtD9OHdCbDbD8jHPD8dBhUg/8/4/w/goB9+h84k7HeCEWCxkUUBJDBEBAeCx+YUUBJDBBBHnAnDQBBBBBBBBBBBBBBBBAPD8dFhUg/8/4/w/goB9+h84k7HeCEWCxkUUBJDBEBD9uDQBFGEILKOTtmYPdenDfAdAPD9SDMIBAKCNJAnDeBJAeCx+YUUBJ2BBJRKSFMAYAKDBBBDMIBAKCTJRKMAICGJRIAECTJHEAM9JQBMMGXAK9FQBAKRTAtCFJHtCI6QGSFMMCBRKSEMGXAM9FQBALCUGJAbJREALAbJDBGBRnCBRYEXAEALCU/CBJAYJHIDBIBHdCFD9tAdCFDbHPD9OD9hD9RHdAIAMJDBIBHiCFD9tAiAPD9OD9hD9RHiDQBTFtGmEYIPLdKeOnH8ZAIAQJDBIBHpCFD9tApAPD9OD9hD9RHpAIASJDBIBHyCFD9tAyAPD9OD9hD9RHyDQBTFtGmEYIPLdKeOnH8cDQBFTtGEmYILPdKOenHPAPDQBFGEBFGEBFGEBFGEAnD9uHnDyBjGBAEAGJHIAnAPAPDQILKOILKOILKOILKOD9uHnDyBjGBAIAGJHIAnAPAPDQNVcMNVcMNVcMNVcMD9uHnDyBjGBAIAGJHIAnAPAPDQSQfbSQfbSQfbSQfbD9uHnDyBjGBAIAGJHIAnA8ZA8cDQNVi8ZcMpySQ8c8dfb8e8fHPAPDQBFGEBFGEBFGEBFGED9uHnDyBjGBAIAGJHIAnAPAPDQILKOILKOILKOILKOD9uHnDyBjGBAIAGJHIAnAPAPDQNVcMNVcMNVcMNVcMD9uHnDyBjGBAIAGJHIAnAPAPDQSQfbSQfbSQfbSQfbD9uHnDyBjGBAIAGJHIAnAdAiDQNiV8ZcpMyS8cQ8df8eb8fHdApAyDQNiV8ZcpMyS8cQ8df8eb8fHiDQBFTtGEmYILPdKOenHPAPDQBFGEBFGEBFGEBFGED9uHnDyBjGBAIAGJHIAnAPAPDQILKOILKOILKOILKOD9uHnDyBjGBAIAGJHIAnAPAPDQNVcMNVcMNVcMNVcMD9uHnDyBjGBAIAGJHIAnAPAPDQSQfbSQfbSQfbSQfbD9uHnDyBjGBAIAGJHIAnAdAiDQNVi8ZcMpySQ8c8dfb8e8fHPAPDQBFGEBFGEBFGEBFGED9uHnDyBjGBAIAGJHIAnAPAPDQILKOILKOILKOILKOD9uHnDyBjGBAIAGJHIAnAPAPDQNVcMNVcMNVcMNVcMD9uHnDyBjGBAIAGJHIAnAPAPDQSQfbSQfbSQfbSQfbD9uHnDyBjGBAIAGJREAYCTJHYAM9JQBMMAbCIJHbAG9JQBMMABAVAG9sJALCUGJAcAG9s/8cBBALALCUGJAcCaJAG9sJAG/8cBBMAcCBAKyAVJRVAKQBMC9+RKSFMCBC99AOAKlAGCAAGCA9Ly6yRKMALCU/KBJ8kUUUUBAKMNBT+BUUUBM+KmFTa8jUUUUBCoFlHL8kUUUUBC9+RKGXAFCE9uHOCtJAI9LQBCaRKAE2BBHNC/wFZC/gF9HQBANCbZHVCF9LQBALCoBJCgFCUF/8MBALC84Jha83EBALC8wJha83EBALC8oJha83EBALCAJha83EBALCiJha83EBALCTJha83EBALha83ENALha83EBAEAIJC9wJRcAECFJHNAOJRMGXAF9FQBCQCbAVCF6yRSABRECBRVCBRQCBRfCBRICBRKEXGXAMAcuQBC9+RKSEMGXGXAN2BBHOC/vF9LQBALCoBJAOCIrCa9zAKJCbZCEWJHb8oGIRTAb8oGBRtGXAOCbZHbAS9PQBALAOCa9zAIJCbZCGWJ8oGBAVAbyROAb9FRbGXGXAGCG9HQBABAt87FBABCIJAO87FBABCGJAT87FBSFMAEAtjGBAECNJAOjGBAECIJATjGBMAVAbJRVALCoBJAKCEWJHmAOjGBAmATjGIALAICGWJAOjGBALCoBJAKCFJCbZHKCEWJHTAtjGBATAOjGIAIAbJRIAKCFJRKSGMGXGXAbCb6QBAQAbJAbC989zJCFJRQSFMAM1BBHbCgFZROGXGXAbCa9MQBAMCFJRMSFMAM1BFHbCgBZCOWAOCgBZqROGXAbCa9MQBAMCGJRMSFMAM1BGHbCgBZCfWAOqROGXAbCa9MQBAMCEJRMSFMAM1BEHbCgBZCdWAOqROGXAbCa9MQBAMCIJRMSFMAM2BIC8cWAOqROAMCLJRMMAOCFrCBAOCFZl9zAQJRQMGXGXAGCG9HQBABAt87FBABCIJAQ87FBABCGJAT87FBSFMAEAtjGBAECNJAQjGBAECIJATjGBMALCoBJAKCEWJHOAQjGBAOATjGIALAICGWJAQjGBALCoBJAKCFJCbZHKCEWJHOAtjGBAOAQjGIAICFJRIAKCFJRKSFMGXAOCDF9LQBALAIAcAOCbZJ2BBHbCIrHTlCbZCGWJ8oGBAVCFJHtATyROALAIAblCbZCGWJ8oGBAtAT9FHmJHtAbCbZHTyRbAT9FRTGXGXAGCG9HQBABAV87FBABCIJAb87FBABCGJAO87FBSFMAEAVjGBAECNJAbjGBAECIJAOjGBMALAICGWJAVjGBALCoBJAKCEWJHYAOjGBAYAVjGIALAICFJHICbZCGWJAOjGBALCoBJAKCFJCbZCEWJHYAbjGBAYAOjGIALAIAmJCbZHICGWJAbjGBALCoBJAKCGJCbZHKCEWJHOAVjGBAOAbjGIAKCFJRKAIATJRIAtATJRVSFMAVCBAM2BBHYyHTAOC/+F6HPJROAYCbZRtGXGXAYCIrHmQBAOCFJRbSFMAORbALAIAmlCbZCGWJ8oGBROMGXGXAtQBAbCFJRVSFMAbRVALAIAYlCbZCGWJ8oGBRbMGXGXAP9FQBAMCFJRYSFMAM1BFHYCgFZRTGXGXAYCa9MQBAMCGJRYSFMAM1BGHYCgBZCOWATCgBZqRTGXAYCa9MQBAMCEJRYSFMAM1BEHYCgBZCfWATqRTGXAYCa9MQBAMCIJRYSFMAM1BIHYCgBZCdWATqRTGXAYCa9MQBAMCLJRYSFMAMCKJRYAM2BLC8cWATqRTMATCFrCBATCFZl9zAQJHQRTMGXGXAmCb6QBAYRPSFMAY1BBHMCgFZROGXGXAMCa9MQBAYCFJRPSFMAY1BFHMCgBZCOWAOCgBZqROGXAMCa9MQBAYCGJRPSFMAY1BGHMCgBZCfWAOqROGXAMCa9MQBAYCEJRPSFMAY1BEHMCgBZCdWAOqROGXAMCa9MQBAYCIJRPSFMAYCLJRPAY2BIC8cWAOqROMAOCFrCBAOCFZl9zAQJHQROMGXGXAtCb6QBAPRMSFMAP1BBHMCgFZRbGXGXAMCa9MQBAPCFJRMSFMAP1BFHMCgBZCOWAbCgBZqRbGXAMCa9MQBAPCGJRMSFMAP1BGHMCgBZCfWAbqRbGXAMCa9MQBAPCEJRMSFMAP1BEHMCgBZCdWAbqRbGXAMCa9MQBAPCIJRMSFMAPCLJRMAP2BIC8cWAbqRbMAbCFrCBAbCFZl9zAQJHQRbMGXGXAGCG9HQBABAT87FBABCIJAb87FBABCGJAO87FBSFMAEATjGBAECNJAbjGBAECIJAOjGBMALCoBJAKCEWJHYAOjGBAYATjGIALAICGWJATjGBALCoBJAKCFJCbZCEWJHYAbjGBAYAOjGIALAICFJHICbZCGWJAOjGBALCoBJAKCGJCbZCEWJHOATjGBAOAbjGIALAIAm9FAmCb6qJHICbZCGWJAbjGBAIAt9FAtCb6qJRIAKCEJRKMANCFJRNABCKJRBAECSJREAKCbZRKAICbZRIAfCEJHfAF9JQBMMCBC99AMAc6yRKMALCoFJ8kUUUUBAKM/tIFGa8jUUUUBCTlRLC9+RKGXAFCLJAI9LQBCaRKAE2BBC/+FZC/QF9HQBALhB83ENAECFJRKAEAIJC98JREGXAF9FQBGXAGCG6QBEXGXAKAE9JQBC9+bMAK1BBHGCgFZRIGXGXAGCa9MQBAKCFJRKSFMAK1BFHGCgBZCOWAICgBZqRIGXAGCa9MQBAKCGJRKSFMAK1BGHGCgBZCfWAIqRIGXAGCa9MQBAKCEJRKSFMAK1BEHGCgBZCdWAIqRIGXAGCa9MQBAKCIJRKSFMAK2BIC8cWAIqRIAKCLJRKMALCNJAICFZCGWqHGAICGrCBAICFrCFZl9zAG8oGBJHIjGBABAIjGBABCIJRBAFCaJHFQBSGMMEXGXAKAE9JQBC9+bMAK1BBHGCgFZRIGXGXAGCa9MQBAKCFJRKSFMAK1BFHGCgBZCOWAICgBZqRIGXAGCa9MQBAKCGJRKSFMAK1BGHGCgBZCfWAIqRIGXAGCa9MQBAKCEJRKSFMAK1BEHGCgBZCdWAIqRIGXAGCa9MQBAKCIJRKSFMAK2BIC8cWAIqRIAKCLJRKMABAICGrCBAICFrCFZl9zALCNJAICFZCGWqHI8oGBJHG87FBAIAGjGBABCGJRBAFCaJHFQBMMCBC99AKAE6yRKMAKM/xLGEaK978jUUUUBCAlHE8kUUUUBGXGXAGCI9HQBGXAFC98ZHI9FQBABRGCBRLEXAGAGDBBBHKCiD+rFCiD+sFD/6FHOAKCND+rFCiD+sFD/6FAOD/gFAKCTD+rFCiD+sFD/6FHND/gFD/kFD/lFHVCBDtD+2FHcAOCUUUU94DtHMD9OD9RD/kFHO9DBB/+hDYAOAOD/mFAVAVD/mFANAcANAMD9OD9RD/kFHOAOD/mFD/kFD/kFD/jFD/nFHND/mF9DBBX9LDYHcD/kFCgFDtD9OAKCUUU94DtD9OD9QAOAND/mFAcD/kFCND+rFCU/+EDtD9OD9QAVAND/mFAcD/kFCTD+rFCUU/8ODtD9OD9QDMBBAGCTJRGALCIJHLAI9JQBMMAIAF9PQFAEAFCEZHLCGWHGqCBCTAGl/8MBAEABAICGWJHIAG/8cBBGXAL9FQBAEAEDBIBHKCiD+rFCiD+sFD/6FHOAKCND+rFCiD+sFD/6FAOD/gFAKCTD+rFCiD+sFD/6FHND/gFD/kFD/lFHVCBDtD+2FHcAOCUUUU94DtHMD9OD9RD/kFHO9DBB/+hDYAOAOD/mFAVAVD/mFANAcANAMD9OD9RD/kFHOAOD/mFD/kFD/kFD/jFD/nFHND/mF9DBBX9LDYHcD/kFCgFDtD9OAKCUUU94DtD9OD9QAOAND/mFAcD/kFCND+rFCU/+EDtD9OD9QAVAND/mFAcD/kFCTD+rFCUU/8ODtD9OD9QDMIBMAIAEAG/8cBBSFMABAFC98ZHGT+HUUUBAGAF9PQBAEAFCEZHICEWHLJCBCAALl/8MBAEABAGCEWJHGAL/8cBBAEAIT+HUUUBAGAEAL/8cBBMAECAJ8kUUUUBM+yEGGaO97GXAF9FQBCBRGEXABCTJHEAEDBBBHICBDtHLCUU98D8cFCUU98D8cEHKD9OABDBBBHOAIDQILKOSQfbPden8c8d8e8fCggFDtD9OD/6FAOAIDQBFGENVcMTtmYi8ZpyHICTD+sFD/6FHND/gFAICTD+rFCTD+sFD/6FHVD/gFD/kFD/lFHI9DB/+g6DYAVAIALD+2FHLAVCUUUU94DtHcD9OD9RD/kFHVAVD/mFAIAID/mFANALANAcD9OD9RD/kFHIAID/mFD/kFD/kFD/jFD/nFHND/mF9DBBX9LDYHLD/kFCTD+rFAVAND/mFALD/kFCggEDtD9OD9QHVAIAND/mFALD/kFCaDbCBDnGCBDnECBDnKCBDnOCBDncCBDnMCBDnfCBDnbD9OHIDQNVi8ZcMpySQ8c8dfb8e8fD9QDMBBABAOAKD9OAVAIDQBFTtGEmYILPdKOenD9QDMBBABCAJRBAGCIJHGAF9JQBMMM94FEa8jUUUUBCAlHE8kUUUUBABAFC98ZHIT+JUUUBGXAIAF9PQBAEAFCEZHLCEWHFJCBCAAFl/8MBAEABAICEWJHBAF/8cBBAEALT+JUUUBABAEAF/8cBBMAECAJ8kUUUUBM/hEIGaF97FaL978jUUUUBCTlRGGXAF9FQBCBREEXAGABDBBBHIABCTJHLDBBBHKDQILKOSQfbPden8c8d8e8fHOCTD+sFHNCID+rFDMIBAB9DBBU8/DY9D/zI818/DYANCEDtD9QD/6FD/nFHNAIAKDQBFGENVcMTtmYi8ZpyHICTD+rFCTD+sFD/6FD/mFHKAKD/mFANAICTD+sFD/6FD/mFHVAVD/mFANAOCTD+rFCTD+sFD/6FD/mFHOAOD/mFD/kFD/kFD/lFCBDtD+4FD/jF9DB/+g6DYHND/mF9DBBX9LDYHID/kFCggEDtHcD9OAVAND/mFAID/kFCTD+rFD9QHVAOAND/mFAID/kFCTD+rFAKAND/mFAID/kFAcD9OD9QHNDQBFTtGEmYILPdKOenHID8dBAGDBIBDyB+t+J83EBABCNJAID8dFAGDBIBDyF+t+J83EBALAVANDQNVi8ZcMpySQ8c8dfb8e8fHND8dBAGDBIBDyG+t+J83EBABCiJAND8dFAGDBIBDyE+t+J83EBABCAJRBAECIJHEAF9JQBMMM/3FGEaF978jUUUUBCoBlREGXAGCGrAF9sHIC98ZHL9FQBCBRGABRFEXAFAFDBBBHKCND+rFCND+sFD/6FAKCiD+sFCnD+rFCUUU/8EDtD+uFD/mFDMBBAFCTJRFAGCIJHGAL9JQBMMGXALAI9PQBAEAICEZHGCGWHFqCBCoBAFl/8MBAEABALCGWJHLAF/8cBBGXAG9FQBAEAEDBIBHKCND+rFCND+sFD/6FAKCiD+sFCnD+rFCUUU/8EDtD+uFD/mFDMIBMALAEAF/8cBBMM9TFEaCBCB8oGUkUUBHFABCEJC98ZJHBjGUkUUBGXGXAB8/BCTWHGuQBCaREABAGlCggEJCTrXBCa6QFMAFREMAEMMMFBCUNMIT9tBB",Bk=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]),Ik=new Uint8Array([32,0,65,253,3,1,2,34,4,106,6,5,11,8,7,20,13,33,12,16,128,9,116,64,19,113,127,15,10,21,22,14,255,66,24,54,136,107,18,23,192,26,114,118,132,17,77,101,130,144,27,87,131,44,45,74,156,154,70,167]),Mk={0:"",1:"meshopt_decodeFilterOct",2:"meshopt_decodeFilterQuat",3:"meshopt_decodeFilterExp",NONE:"",OCTAHEDRAL:"meshopt_decodeFilterOct",QUATERNION:"meshopt_decodeFilterQuat",EXPONENTIAL:"meshopt_decodeFilterExp"},Pk={0:"meshopt_decodeVertexBuffer",1:"meshopt_decodeIndexBuffer",2:"meshopt_decodeIndexSequence",ATTRIBUTES:"meshopt_decodeVertexBuffer",TRIANGLES:"meshopt_decodeIndexBuffer",INDICES:"meshopt_decodeIndexSequence"};async function Rk(e,t,i,n,r,o="NONE"){const s=await async function(){Lk||(Lk=async function(){let e=Ck;WebAssembly.validate(Bk)&&(e=Sk,console.log("Warning: meshopt_decoder is using experimental SIMD support"));const t=await WebAssembly.instantiate(function(e){const t=new Uint8Array(e.length);for(let i=0;i96?n-71:n>64?n-65:n>47?n+4:n>46?63:62}let i=0;for(let n=0;nthis.decoder[e]).includes(n);if(r){const t=new this.draco.AttributeQuantizationTransform;try{if(t.InitFromAttribute(e))return{quantization_bits:t.quantization_bits(),range:t.range(),min_values:new Float32Array([1,2,3]).map(e=>t.min_value(e))}}finally{this.draco.destroy(t)}}return null}_getOctahedronTransform(e,t){const{octahedronAttributes:i=[]}=t,n=e.attribute_type(),r=i.map(e=>this.decoder[e]).includes(n);if(r){const t=new this.draco.AttributeQuantizationTransform;try{if(t.InitFromAttribute(e))return{quantization_bits:t.quantization_bits()}}finally{this.draco.destroy(t)}}return null}}const Xk=(globalThis._loadersgl_?.version||(globalThis._loadersgl_=globalThis._loadersgl_||{},globalThis._loadersgl_.version="4.3.3"),globalThis._loadersgl_.version);const Jk="object"!=typeof process||"[object process]"!==String(process)||process.browser,Yk="function"==typeof importScripts,eD="undefined"!=typeof process&&process.version&&/v([0-9]*)/.exec(process.version);eD&&parseFloat(eD[1]);const tD={};async function iD(e,t=null,i={},n=null){return t&&(e=function(e,t,i={},n=null){if(!i.useLocalLibraries&&e.startsWith("http"))return e;n=n||e;const r=i.modules||{};if(r[n])return r[n];if(!Jk)return`modules/${t}/dist/libs/${n}`;if(i.CDN)return function(e,t){if(!e)throw new Error(t||"loaders.gl assertion failed.")}(i.CDN.startsWith("http")),`${i.CDN}/${t}@${Xk}/dist/libs/${n}`;if(Yk)return`../src/libs/${n}`;return`modules/${t}/src/libs/${n}`}(e,t,i,n)),tD[e]=tD[e]||async function(e){if(e.endsWith("wasm"))return await async function(e){const{readFileAsArrayBuffer:t}=globalThis.loaders||{};if(Jk||!t||e.startsWith("http")){const t=await fetch(e);return await t.arrayBuffer()}return await t(e)}(e);if(!Jk)try{const{requireFromFile:t}=globalThis.loaders||{};return await(t?.(e))}catch(e){return console.error(e),null}if(Yk)return importScripts(e);const t=await async function(e){const{readFileAsText:t}=globalThis.loaders||{};if(Jk||!t||e.startsWith("http")){const t=await fetch(e);return await t.text()}return await t(e)}(e);return function(e,t){if(!Jk){const{requireFromString:i}=globalThis.loaders||{};return i?.(e,t)}if(Yk)return eval.call(globalThis,e),null;const i=document.createElement("script");i.id=t;try{i.appendChild(document.createTextNode(e))}catch(t){i.text=e}return document.body.appendChild(i),null}(t,e)}(e),await tD[e]}const nD="https://www.gstatic.com/draco/versioned/decoders/1.5.6",rD="draco_wasm_wrapper.js",oD="draco_decoder.wasm",sD="draco_decoder.js",aD="draco_encoder.js",lD={[rD]:`${nD}/${rD}`,[oD]:`${nD}/${oD}`,[sD]:`${nD}/${sD}`,[aD]:`https://raw.githubusercontent.com/google/draco/1.4.1/javascript/${aD}`};let cD;async function uD(e){const t=e.modules||{};return t.draco3d?cD||=t.draco3d.createDecoderModule({}).then(e=>({draco:e})):cD||=async function(e){let t,i;if("js"===(e.draco&&e.draco.decoderType))t=await iD(lD[sD],"draco",e,sD);else[t,i]=await Promise.all([await iD(lD[rD],"draco",e,rD),await iD(lD[oD],"draco",e,oD)]);return t=t||globalThis.DracoDecoderModule,await function(e,t){const i={};t&&(i.wasmBinary=t);return new Promise(t=>{e({...i,onModuleLoaded:e=>t({draco:e})})})}(t,i)}(e),await cD}const hD={...Qk,parse:async function(e,t){const{draco:i}=await uD(t),n=new Kk(i);try{return n.parseSync(e,t?.draco)}finally{n.destroy()}}};function dD(e){const{buffer:t,size:i,count:n}=function(e){let t=e,i=1,n=0;e&&e.value&&(t=e.value,i=e.size||1);t&&(ArrayBuffer.isView(t)||(t=function(e,t,i=!1){if(!e)return null;if(Array.isArray(e))return new t(e);if(i&&!(e instanceof t))return new t(e);return e}(t,Float32Array)),n=t.length/i);return{buffer:t,size:i,count:n}}(e);return{value:t,size:i,byteOffset:0,count:n,type:EF(i),componentType:CF(t)}}const pD="KHR_draco_mesh_compression",fD=pD;async function mD(e,t,i,n){const r=e.getObjectExtension(t,pD);if(!r)return;const o=e.getTypedArrayForBufferView(r.bufferView),s=xh(o.buffer,o.byteOffset),a={...i};delete a["3d-tiles"];const l=await wu(s,hD,a,n),c=function(e){const t={};for(const i in e){const n=e[i];if("indices"!==i){const e=dD(n);t[i]=e}}return t}(l.attributes);for(const[i,n]of Object.entries(c))if(i in t.attributes){const r=t.attributes[i],o=e.getAccessor(r);o?.min&&o?.max&&(n.min=o.min,n.max=o.max)}t.attributes=c,l.indices&&(t.indices=dD(l.indices)),e.removeObjectExtension(t,pD),function(e){if(!e.attributes&&Object.keys(e.attributes).length>0)throw new Error("glTF: Empty primitive detected: Draco decompression failure?")}(t)}function gD(e,t,i=4,n,r){if(!n.DracoWriter)throw new Error("options.gltf.DracoWriter not provided");const o=n.DracoWriter.encodeSync({attributes:e}),s=r?.parseSync?.({attributes:e}),a=n._addFauxAttributes(s.attributes),l=n.addBufferView(o);return{primitives:[{attributes:a,mode:i,extensions:{[pD]:{bufferView:l,attributes:a}}}]}}function*_D(e){for(const t of e.json.meshes||[])for(const e of t.primitives)yield e}var AD=Object.freeze({__proto__:null,name:fD,preprocess:function(e,t,i){const n=new IF(e);for(const e of _D(n))n.getObjectExtension(e,pD)},decode:async function(e,t,i){if(!t?.gltf?.decompressMeshes)return;const n=new IF(e),r=[];for(const e of _D(n))n.getObjectExtension(e,pD)&&r.push(mD(n,e,t,i));await Promise.all(r),n.removeExtension(pD)},encode:function(e,t={}){const i=new IF(e);for(const e of i.json.meshes||[])gD(e),i.addRequiredExtension(pD)}});const yD="KHR_texture_transform",vD=yD,xD=new AA,bD=new EA,wD=new EA;function TD(e,t){const i=t.json.materials?.[e],n=[i?.pbrMetallicRoughness?.baseColorTexture,i?.emissiveTexture,i?.normalTexture,i?.occlusionTexture,i?.pbrMetallicRoughness?.metallicRoughnessTexture],r=[];for(const i of n)i&&i?.extensions?.[yD]&&ED(t,e,i,r)}function ED(e,t,i,n){const r=function(e,t){const i=e.extensions?.[yD],{texCoord:n=0}=e,{texCoord:r=n}=i,o=-1!==t.findIndex(([e,t])=>e===n&&t===r);if(!o){const o=function(e){const{offset:t=[0,0],rotation:i=0,scale:n=[1,1]}=e,r=(new EA).set(1,0,0,0,1,0,t[0],t[1],1),o=bD.set(Math.cos(i),Math.sin(i),0,-Math.sin(i),Math.cos(i),0,0,0,1),s=wD.set(n[0],0,0,0,n[1],0,0,0,1);return r.multiplyRight(o).multiplyRight(s)}(i);return n!==r&&(e.texCoord=r),t.push([n,r]),{originalTexCoord:n,texCoord:r,matrix:o}}return null}(i,n);if(!r)return;const o=e.json.meshes||[];for(const i of o)for(const n of i.primitives){const i=n.material;Number.isFinite(i)&&t===i&&CD(e,n,r)}}function CD(e,t,i){const{originalTexCoord:n,texCoord:r,matrix:o}=i,s=t.attributes[`TEXCOORD_${n}`];if(Number.isFinite(s)){const i=e.json.accessors?.[s];if(i&&i.bufferView){const s=e.json.bufferViews?.[i.bufferView];if(s){const{arrayBuffer:a,byteOffset:l}=e.buffers[s.buffer],c=(l||0)+(i.byteOffset||0)+(s.byteOffset||0),{ArrayType:u,length:h}=SF(i,s),d=AF[i.componentType],p=_F[i.type],f=s.byteStride||d*p,m=new Float32Array(h);for(let e=0;e{e.uniforms[t].value&&!(t in i)&&(i[t]=e.uniforms[t].value)}),Object.keys(i).forEach(e=>{"object"==typeof i[e]&&void 0!==i[e].index&&(i[e].texture=t.getTexture(i[e].index))}),i}const DD=[ak,ZF,Ok,Nk,Gk,AD,MD,Object.freeze({__proto__:null,name:RD,decode:async function(e){const t=new IF(e),{json:i}=t;for(const e of i.materials||[]){e.extensions&&e.extensions.KHR_materials_unlit&&(e.unlit=!0),t.removeObjectExtension(e,PD)}t.removeExtension(PD)},encode:function(e){const t=new IF(e),{json:i}=t;if(t.materials)for(const e of i.materials||[])e.unlit&&(delete e.unlit,t.addObjectExtension(e,PD,{}),t.addExtension(PD))}}),Object.freeze({__proto__:null,name:FD,decode:async function(e){const t=new IF(e),{json:i}=t,n=t.getExtension(LD);if(n){const e=function(e,t){const{programs:i=[],shaders:n=[],techniques:r=[]}=e,o=new TextDecoder;return n.forEach(e=>{if(!Number.isFinite(e.bufferView))throw new Error("KHR_techniques_webgl: no shader code");e.code=o.decode(t.getTypedArrayForBufferView(e.bufferView))}),i.forEach(e=>{e.fragmentShader=n[e.fragmentShader],e.vertexShader=n[e.vertexShader]}),r.forEach(e=>{e.program=i[e.program]}),r}(n,t);for(const n of i.materials||[]){const i=t.getObjectExtension(n,LD);i&&(n.technique=Object.assign({},i,e[i.technique]),n.technique.values=kD(n.technique,t)),t.removeObjectExtension(n,LD)}t.removeExtension(LD)}},encode:async function(e,t){}}),SD,_k];function OD(e,t){const i=t?.gltf?.excludeExtensions||{};return!(e in i&&!i[e])}const zD="KHR_binary_glTF";const UD={accessors:"accessor",animations:"animation",buffers:"buffer",bufferViews:"bufferView",images:"image",materials:"material",meshes:"mesh",nodes:"node",samplers:"sampler",scenes:"scene",skins:"skin",textures:"texture"},ND={accessor:"accessors",animations:"animation",buffer:"buffers",bufferView:"bufferViews",image:"images",material:"materials",mesh:"meshes",node:"nodes",sampler:"samplers",scene:"scenes",skin:"skins",texture:"textures"};class VD{idToIndexMap={animations:{},accessors:{},buffers:{},bufferViews:{},images:{},materials:{},meshes:{},nodes:{},samplers:{},scenes:{},skins:{},textures:{}};json;normalize(e,t){this.json=e.json;const i=e.json;switch(i.asset&&i.asset.version){case"2.0":return;case void 0:case"1.0":break;default:return void console.warn(`glTF: Unknown version ${i.asset.version}`)}if(!t.normalize)throw new Error("glTF v1 is not supported.");console.warn("Converting glTF v1 to glTF v2 format. This is experimental and may fail."),this._addAsset(i),this._convertTopLevelObjectsToArrays(i),function(e){const t=new IF(e),{json:i}=t;for(const e of i.images||[]){const i=t.getObjectExtension(e,zD);i&&Object.assign(e,i),t.removeObjectExtension(e,zD)}i.buffers&&i.buffers[0]&&delete i.buffers[0].uri,t.removeExtension(zD)}(e),this._convertObjectIdsToArrayIndices(i),this._updateObjects(i),this._updateMaterial(i)}_addAsset(e){e.asset=e.asset||{},e.asset.version="2.0",e.asset.generator=e.asset.generator||"Normalized to glTF 2.0 by loaders.gl"}_convertTopLevelObjectsToArrays(e){for(const t in UD)this._convertTopLevelObjectToArray(e,t)}_convertTopLevelObjectToArray(e,t){const i=e[t];if(i&&!Array.isArray(i)){e[t]=[];for(const n in i){const r=i[n];r.id=r.id||n;const o=e[t].length;e[t].push(r),this.idToIndexMap[t][n]=o}}}_convertObjectIdsToArrayIndices(e){for(const t in UD)this._convertIdsToIndices(e,t);"scene"in e&&(e.scene=this._convertIdToIndex(e.scene,"scene"));for(const t of e.textures)this._convertTextureIds(t);for(const t of e.meshes)this._convertMeshIds(t);for(const t of e.nodes)this._convertNodeIds(t);for(const t of e.scenes)this._convertSceneIds(t)}_convertTextureIds(e){e.source&&(e.source=this._convertIdToIndex(e.source,"image"))}_convertMeshIds(e){for(const t of e.primitives){const{attributes:e,indices:i,material:n}=t;for(const t in e)e[t]=this._convertIdToIndex(e[t],"accessor");i&&(t.indices=this._convertIdToIndex(i,"accessor")),n&&(t.material=this._convertIdToIndex(n,"material"))}}_convertNodeIds(e){e.children&&(e.children=e.children.map(e=>this._convertIdToIndex(e,"node"))),e.meshes&&(e.meshes=e.meshes.map(e=>this._convertIdToIndex(e,"mesh")))}_convertSceneIds(e){e.nodes&&(e.nodes=e.nodes.map(e=>this._convertIdToIndex(e,"node")))}_convertIdsToIndices(e,t){e[t]||(console.warn(`gltf v1: json doesn't contain attribute ${t}`),e[t]=[]);for(const i of e[t])for(const e in i){const t=i[e],n=this._convertIdToIndex(t,e);i[e]=n}}_convertIdToIndex(e,t){const i=ND[t];if(i in this.idToIndexMap){const n=this.idToIndexMap[i][e];if(!Number.isFinite(n))throw new Error(`gltf v1: failed to resolve ${t} with id ${e}`);return n}return e}_updateObjects(e){for(const e of this.json.buffers)delete e.type}_updateMaterial(e){for(const t of e.materials){t.pbrMetallicRoughness={baseColorFactor:[1,1,1,1],metallicFactor:1,roughnessFactor:1};const i=t.values?.tex||t.values?.texture2d_0||t.values?.diffuseTex,n=e.textures.findIndex(e=>e.id===i);-1!==n&&(t.pbrMetallicRoughness.baseColorTexture={index:n})}}}async function jD(e,t,i=0,n,r){return function(e,t,i,n){n.uri&&(e.baseUri=n.uri);if(t instanceof ArrayBuffer&&!function(e,t=0,i={}){const n=new DataView(e),{magic:r=yk}=i,o=n.getUint32(t,!1);return o===r||o===yk}(t,i,n)){t=(new TextDecoder).decode(t)}if("string"==typeof t)e.json=Ah(t);else if(t instanceof ArrayBuffer){const r={};i=bk(r,t,i,n.glb),gF("glTF"===r.type,`Invalid GLB magic string ${r.type}`),e._glb=r,e.json=r.json}else gF(!1,"GLTF: must be ArrayBuffer or string");const r=e.json.buffers||[];if(e.buffers=new Array(r.length).fill(null),e._glb&&e._glb.header.hasBinChunk){const{binChunks:t}=e._glb;e.buffers[0]={arrayBuffer:t[0].arrayBuffer,byteOffset:t[0].byteOffset,byteLength:t[0].byteLength}}const o=e.json.images||[];e.images=new Array(o.length).fill({})}(e,t,i,n),function(e,t={}){(new VD).normalize(e,t)}(e,{normalize:n?.gltf?.normalize}),function(e,t={},i){const n=DD.filter(e=>OD(e.name,t));for(const r of n)r.preprocess?.(e,t,i)}(e,n,r),n?.gltf?.loadBuffers&&e.json.buffers&&await async function(e,t,i){const n=e.json.buffers||[];for(let r=0;rOD(e.name,t));for(const r of n)await(r.decode?.(e,t,i))}(e,n,r),e}async function GD(e,t,i,n,r){let o;if(t.uri&&!t.hasOwnProperty("bufferView")){const e=Ek(t.uri,n),{fetch:i}=r,s=await i(e);o=await s.arrayBuffer(),t.bufferView={data:o}}if(Number.isFinite(t.bufferView)){const i=function(e,t,i){const n=e.bufferViews[i];gF(n);const r=t[n.buffer];gF(r);const o=(n.byteOffset||0)+r.byteOffset;return new Uint8Array(r.arrayBuffer,o,n.byteLength)}(e.json,e.buffers,t.bufferView);o=xh(i.buffer,i.byteOffset,i.byteLength)}gF(o,"glTF image has no data");let s=await wu(o,[tp,rF],{...n,mimeType:t.mimeType,basis:n.basis||{format:nF()}},r);s&&s[0]&&(s={compressed:!0,mipmaps:!1,width:s[0].width,height:s[0].height,data:s[0]}),e.images=e.images||[],e.images[i]=s}const HD={dataType:null,batchType:null,name:"glTF",id:"gltf",module:"gltf",version:"4.3.3",extensions:["gltf","glb"],mimeTypes:["model/gltf+json","model/gltf-binary"],text:!0,binary:!0,tests:["glTF"],parse:async function(e,t={},i){(t={...HD.options,...t}).gltf={...HD.options.gltf,...t.gltf};const{byteOffset:n=0}=t;return await jD({},e,n,t,i)},options:{gltf:{normalize:!0,loadBuffers:!0,loadImages:!0,decompressMeshes:!0},log:console}};const QD={SCALAR:1,VEC2:2,VEC3:3,VEC4:4,MAT2:4,MAT3:9,MAT4:16},$D={5120:1,5121:1,5122:2,5123:2,5125:4,5126:4},ZD=10240,WD=10241,qD=10242,KD=10243,XD=10497,JD=9729,YD=9986,eO={magFilter:ZD,minFilter:WD,wrapS:qD,wrapT:KD},tO={[ZD]:JD,[WD]:YD,[qD]:XD,[KD]:XD};class iO{baseUri="";jsonUnprocessed;json;buffers=[];images=[];postProcess(e,t={}){const{json:i,buffers:n=[],images:r=[]}=e,{baseUri:o=""}=e;return gF(i),this.baseUri=o,this.buffers=n,this.images=r,this.jsonUnprocessed=i,this.json=this._resolveTree(e.json,t),this.json}_resolveTree(e,t={}){const i={...e};return this.json=i,e.bufferViews&&(i.bufferViews=e.bufferViews.map((e,t)=>this._resolveBufferView(e,t))),e.images&&(i.images=e.images.map((e,t)=>this._resolveImage(e,t))),e.samplers&&(i.samplers=e.samplers.map((e,t)=>this._resolveSampler(e,t))),e.textures&&(i.textures=e.textures.map((e,t)=>this._resolveTexture(e,t))),e.accessors&&(i.accessors=e.accessors.map((e,t)=>this._resolveAccessor(e,t))),e.materials&&(i.materials=e.materials.map((e,t)=>this._resolveMaterial(e,t))),e.meshes&&(i.meshes=e.meshes.map((e,t)=>this._resolveMesh(e,t))),e.nodes&&(i.nodes=e.nodes.map((e,t)=>this._resolveNode(e,t)),i.nodes=i.nodes.map((e,t)=>this._resolveNodeChildren(e))),e.skins&&(i.skins=e.skins.map((e,t)=>this._resolveSkin(e,t))),e.scenes&&(i.scenes=e.scenes.map((e,t)=>this._resolveScene(e,t))),"number"==typeof this.json.scene&&i.scenes&&(i.scene=i.scenes[this.json.scene]),i}getScene(e){return this._get(this.json.scenes,e)}getNode(e){return this._get(this.json.nodes,e)}getSkin(e){return this._get(this.json.skins,e)}getMesh(e){return this._get(this.json.meshes,e)}getMaterial(e){return this._get(this.json.materials,e)}getAccessor(e){return this._get(this.json.accessors,e)}getCamera(e){return this._get(this.json.cameras,e)}getTexture(e){return this._get(this.json.textures,e)}getSampler(e){return this._get(this.json.samplers,e)}getImage(e){return this._get(this.json.images,e)}getBufferView(e){return this._get(this.json.bufferViews,e)}getBuffer(e){return this._get(this.json.buffers,e)}_get(e,t){if("object"==typeof t)return t;const i=e&&e[t];return i||console.warn(`glTF file error: Could not find ${e}[${t}]`),i}_resolveScene(e,t){return{...e,id:e.id||`scene-${t}`,nodes:(e.nodes||[]).map(e=>this.getNode(e))}}_resolveNode(e,t){const i={...e,id:e?.id||`node-${t}`};return void 0!==e.mesh&&(i.mesh=this.getMesh(e.mesh)),void 0!==e.camera&&(i.camera=this.getCamera(e.camera)),void 0!==e.skin&&(i.skin=this.getSkin(e.skin)),void 0!==e.meshes&&e.meshes.length&&(i.mesh=e.meshes.reduce((e,t)=>{const i=this.getMesh(t);return e.id=i.id,e.primitives=e.primitives.concat(i.primitives),e},{primitives:[]})),i}_resolveNodeChildren(e){return e.children&&(e.children=e.children.map(e=>this.getNode(e))),e}_resolveSkin(e,t){const i="number"==typeof e.inverseBindMatrices?this.getAccessor(e.inverseBindMatrices):void 0;return{...e,id:e.id||`skin-${t}`,inverseBindMatrices:i}}_resolveMesh(e,t){const i={...e,id:e.id||`mesh-${t}`,primitives:[]};return e.primitives&&(i.primitives=e.primitives.map(e=>{const t={...e,attributes:{},indices:void 0,material:void 0},i=e.attributes;for(const e in i)t.attributes[e]=this.getAccessor(i[e]);return void 0!==e.indices&&(t.indices=this.getAccessor(e.indices)),void 0!==e.material&&(t.material=this.getMaterial(e.material)),t})),i}_resolveMaterial(e,t){const i={...e,id:e.id||`material-${t}`};if(i.normalTexture&&(i.normalTexture={...i.normalTexture},i.normalTexture.texture=this.getTexture(i.normalTexture.index)),i.occlusionTexture&&(i.occlusionTexture={...i.occlusionTexture},i.occlusionTexture.texture=this.getTexture(i.occlusionTexture.index)),i.emissiveTexture&&(i.emissiveTexture={...i.emissiveTexture},i.emissiveTexture.texture=this.getTexture(i.emissiveTexture.index)),i.emissiveFactor||(i.emissiveFactor=i.emissiveTexture?[1,1,1]:[0,0,0]),i.pbrMetallicRoughness){i.pbrMetallicRoughness={...i.pbrMetallicRoughness};const e=i.pbrMetallicRoughness;e.baseColorTexture&&(e.baseColorTexture={...e.baseColorTexture},e.baseColorTexture.texture=this.getTexture(e.baseColorTexture.index)),e.metallicRoughnessTexture&&(e.metallicRoughnessTexture={...e.metallicRoughnessTexture},e.metallicRoughnessTexture.texture=this.getTexture(e.metallicRoughnessTexture.index))}return i}_resolveAccessor(e,t){const i=(n=e.componentType,$D[n]);var n;const r=function(e){return QD[e]}(e.type),o=i*r,s={...e,id:e.id||`accessor-${t}`,bytesPerComponent:i,components:r,bytesPerElement:o,value:void 0,bufferView:void 0,sparse:void 0};if(void 0!==e.bufferView&&(s.bufferView=this.getBufferView(e.bufferView)),s.bufferView){const e=s.bufferView.buffer,{ArrayType:t,byteLength:i}=SF(s,s.bufferView),n=(s.bufferView.byteOffset||0)+(s.byteOffset||0)+e.byteOffset;let r=e.arrayBuffer.slice(n,n+i);s.bufferView.byteStride&&(r=this._getValueFromInterleavedBuffer(e,n,s.bufferView.byteStride,s.bytesPerElement,s.count)),s.value=new t(r)}return s}_getValueFromInterleavedBuffer(e,t,i,n,r){const o=new Uint8Array(r*n);for(let s=0;s{e.traverse(e=>{Object.values(e.model.uniforms).forEach(e=>{!1===e.loaded&&t.push(e)})})}),await async function(e){for(;e();)await new Promise(e=>requestAnimationFrame(e))}(()=>t.some(e=>!e.loaded))}const oO=[255,255,255,255],sO={scenegraph:{type:"object",value:null,async:!0},getScene:e=>e&&e.scenes?"object"==typeof e.scene?e.scene:e.scenes[e.scene||0]:e,getAnimator:e=>e&&e.animator,_animations:null,sizeScale:{type:"number",value:1,min:0},sizeMinPixels:{type:"number",min:0,value:0},sizeMaxPixels:{type:"number",min:0,value:Number.MAX_SAFE_INTEGER},getPosition:{type:"accessor",value:e=>e.position},getColor:{type:"accessor",value:oO},_lighting:"flat",_imageBasedLightingEnvironment:void 0,getOrientation:{type:"accessor",value:[0,0,0]},getScale:{type:"accessor",value:[1,1,1]},getTranslation:{type:"accessor",value:[0,0,0]},getTransformMatrix:{type:"accessor",value:[]},loaders:[HD]};class aO extends hS{getShaders(){const e=[zy,gv];return"pbr"===this.props._lighting&&e.push(Ay),super.getShaders({vs:"#version 300 es\n#define SHADER_NAME scenegraph-layer-vertex-shader\nin vec3 instancePositions;\nin vec3 instancePositions64Low;\nin vec4 instanceColors;\nin vec3 instancePickingColors;\nin vec3 instanceModelMatrixCol0;\nin vec3 instanceModelMatrixCol1;\nin vec3 instanceModelMatrixCol2;\nin vec3 instanceTranslation;\nuniform float sizeScale;\nuniform float sizeMinPixels;\nuniform float sizeMaxPixels;\nuniform mat4 sceneModelMatrix;\nuniform bool composeModelMatrix;\nin vec3 positions;\n#ifdef HAS_UV\nin vec2 texCoords;\n#endif\n#ifdef MODULE_PBR\n#ifdef HAS_NORMALS\nin vec3 normals;\n#endif\n#endif\nout vec4 vColor;\n#ifndef MODULE_PBR\n#ifdef HAS_UV\nout vec2 vTEXCOORD_0;\n#endif\n#endif\nvoid main(void) {\n#if defined(HAS_UV) && !defined(MODULE_PBR)\nvTEXCOORD_0 = texCoords;\ngeometry.uv = texCoords;\n#endif\ngeometry.worldPosition = instancePositions;\ngeometry.pickingColor = instancePickingColors;\nmat3 instanceModelMatrix = mat3(instanceModelMatrixCol0, instanceModelMatrixCol1, instanceModelMatrixCol2);\nvec3 normal = vec3(0.0, 0.0, 1.0);\n#ifdef MODULE_PBR\n#ifdef HAS_NORMALS\nnormal = instanceModelMatrix * (sceneModelMatrix * vec4(normals, 0.0)).xyz;\n#endif\n#endif\nfloat originalSize = project_size_to_pixel(sizeScale);\nfloat clampedSize = clamp(originalSize, sizeMinPixels, sizeMaxPixels);\nvec3 pos = (instanceModelMatrix * (sceneModelMatrix * vec4(positions, 1.0)).xyz) * sizeScale * (clampedSize / originalSize) + instanceTranslation;\nif(composeModelMatrix) {\nDECKGL_FILTER_SIZE(pos, geometry);\ngeometry.normal = project_normal(normal);\ngeometry.worldPosition += pos;\ngl_Position = project_position_to_clipspace(pos + instancePositions, instancePositions64Low, vec3(0.0), geometry.position);\n}\nelse {\npos = project_size(pos);\nDECKGL_FILTER_SIZE(pos, geometry);\ngl_Position = project_position_to_clipspace(instancePositions, instancePositions64Low, pos, geometry.position);\ngeometry.normal = project_normal(normal);\n}\nDECKGL_FILTER_GL_POSITION(gl_Position, geometry);\n#ifdef MODULE_PBR\npbr_vPosition = geometry.position.xyz;\n#ifdef HAS_NORMALS\npbr_vNormal = geometry.normal;\n#endif\n#ifdef HAS_UV\npbr_vUV = texCoords;\n#else\npbr_vUV = vec2(0., 0.);\n#endif\ngeometry.uv = pbr_vUV;\n#endif\nvColor = instanceColors;\nDECKGL_FILTER_COLOR(vColor, geometry);\n}\n",fs:"#version 300 es\n#define SHADER_NAME scenegraph-layer-fragment-shader\nuniform float opacity;\nin vec4 vColor;\nout vec4 fragColor;\n#ifndef MODULE_PBR\n#if defined(HAS_UV) && defined(HAS_BASECOLORMAP)\nin vec2 vTEXCOORD_0;\nuniform sampler2D u_BaseColorSampler;\n#endif\n#endif\nvoid main(void) {\n#ifdef MODULE_PBR\nfragColor = vColor * pbr_filterColor(vec4(0));\ngeometry.uv = pbr_vUV;\n#else\n#if defined(HAS_UV) && defined(HAS_BASECOLORMAP)\nfragColor = vColor * texture(u_BaseColorSampler, vTEXCOORD_0);\ngeometry.uv = vTEXCOORD_0;\n#else\nfragColor = vColor;\n#endif\n#endif\nfragColor.a *= opacity;\nDECKGL_FILTER_COLOR(fragColor, geometry);\n}\n",modules:e})}initializeState(){this.getAttributeManager().addInstanced({instancePositions:{size:3,type:"float64",fp64:this.use64bitPositions(),accessor:"getPosition",transition:!0},instanceColors:{type:"unorm8",size:this.props.colorFormat.length,accessor:"getColor",defaultValue:oO,transition:!0},instanceModelMatrix:xL})}updateState(e){super.updateState(e);const{props:t,oldProps:i}=e;t.scenegraph!==i.scenegraph?this._updateScenegraph():t._animations!==i._animations&&this._applyAnimationsProp(this.state.animator,t._animations)}finalizeState(e){super.finalizeState(e),this.state.scenegraph?.destroy()}get isLoaded(){return Boolean(this.state?.scenegraph&&super.isLoaded)}_updateScenegraph(){const e=this.props,{device:t}=this.context;let i=null;if(e.scenegraph instanceof Sx)i={scenes:[e.scenegraph]};else if(e.scenegraph&&"object"==typeof e.scenegraph){const n=e.scenegraph,r=n.json?nO(n):n,o=function(e,t,i){const n=new fF(e,i);return{scenes:n.instantiate(t),animator:n.createAnimator()}}(t,r,this._getModelOptions());i={gltf:r,...o},rO(o).then(()=>{this.setNeedsRedraw()}).catch(e=>{this.raiseError(e,"loading glTF")})}const n={layer:this,device:this.context.device},r=e.getScene(i,n),o=e.getAnimator(i,n);if(r instanceof Bx){this.state.scenegraph?.destroy(),this._applyAnimationsProp(o,e._animations);const t=[];r.traverse(e=>{e instanceof Ix&&t.push(e.model)}),this.setState({scenegraph:r,animator:o,models:t}),this.getAttributeManager().invalidateAll()}else null!==r&&rp.warn("invalid scenegraph:",r)()}_applyAnimationsProp(e,t){if(!e||!t)return;const i=e.getAnimations();Object.keys(t).sort().forEach(e=>{const n=t[e];if("*"===e)i.forEach(e=>{Object.assign(e,n)});else if(Number.isFinite(Number(e))){const t=Number(e);t>=0&&tt===e);t?Object.assign(t,n):rp.warn(`animation ${e} not found`)()}})}_getModelOptions(){const{_imageBasedLightingEnvironment:e}=this.props;let t;return e&&(t="function"==typeof e?e({gl:this.context.gl,layer:this}):e),{imageBasedLightingEnvironment:t,modelOptions:{id:this.props.id,isInstanced:!0,bufferLayout:this.getAttributeManager().getBufferLayouts(),...this.getShaders()},useTangents:!1}}draw({context:e}){if(!this.state.scenegraph)return;this.props._animations&&this.state.animator&&(this.state.animator.animate(e.timeline.getTime()),this.setNeedsRedraw());const{viewport:t,renderPass:i}=this.context,{sizeScale:n,sizeMinPixels:r,sizeMaxPixels:o,opacity:s,coordinateSystem:a}=this.props,l=this.getNumInstances();this.state.scenegraph.traverse((e,{worldMatrix:c})=>{if(e instanceof Ix){const{model:u}=e;u.setInstanceCount(l),u.setUniforms({sizeScale:n,opacity:s,sizeMinPixels:r,sizeMaxPixels:o,composeModelMatrix:bL(t,a),sceneModelMatrix:c,u_Camera:u.uniforms.project_uCameraPosition}),u.draw(i)}})}}aO.defaultProps=sO,aO.layerName="ScenegraphLayer";var lO=aO;class cO extends BL{getShaders(){const e=super.getShaders();return e.modules.push(Ay),{...e,vs:"#version 300 es\n#define SHADER_NAME simple-mesh-layer-vs\nuniform float sizeScale;\nuniform bool composeModelMatrix;\nuniform bool pickFeatureIds;\nin vec3 positions;\nin vec3 normals;\nin vec3 colors;\nin vec2 texCoords;\nin vec4 uvRegions;\nin vec3 featureIdsPickingColors;\nin vec4 instanceColors;\nin vec3 instancePickingColors;\nin vec3 instanceModelMatrixCol0;\nin vec3 instanceModelMatrixCol1;\nin vec3 instanceModelMatrixCol2;\nout vec2 vTexCoord;\nout vec3 cameraPosition;\nout vec3 normals_commonspace;\nout vec4 position_commonspace;\nout vec4 vColor;\nvec2 applyUVRegion(vec2 uv) {\n#ifdef HAS_UV_REGIONS\nreturn fract(uv) * (uvRegions.zw - uvRegions.xy) + uvRegions.xy;\n#else\nreturn uv;\n#endif\n}\nvoid main(void) {\nvec2 uv = applyUVRegion(texCoords);\ngeometry.uv = uv;\nif (pickFeatureIds) {\ngeometry.pickingColor = featureIdsPickingColors;\n} else {\ngeometry.pickingColor = instancePickingColors;\n}\nmat3 instanceModelMatrix = mat3(instanceModelMatrixCol0, instanceModelMatrixCol1, instanceModelMatrixCol2);\nvTexCoord = uv;\ncameraPosition = project_uCameraPosition;\nvColor = vec4(colors * instanceColors.rgb, instanceColors.a);\nvec3 pos = (instanceModelMatrix * positions) * sizeScale;\nvec3 projectedPosition = project_position(positions);\nposition_commonspace = vec4(projectedPosition, 1.0);\ngl_Position = project_common_position_to_clipspace(position_commonspace);\ngeometry.position = position_commonspace;\nnormals_commonspace = project_normal(instanceModelMatrix * normals);\ngeometry.normal = normals_commonspace;\nDECKGL_FILTER_GL_POSITION(gl_Position, geometry);\n#ifdef MODULE_PBR\npbr_vPosition = geometry.position.xyz;\n#ifdef HAS_NORMALS\npbr_vNormal = geometry.normal;\n#endif\n#ifdef HAS_UV\npbr_vUV = uv;\n#else\npbr_vUV = vec2(0., 0.);\n#endif\ngeometry.uv = pbr_vUV;\n#endif\nDECKGL_FILTER_COLOR(vColor, geometry);\n}\n",fs:"#version 300 es\n#define SHADER_NAME simple-mesh-layer-fs\nprecision highp float;\nuniform bool hasTexture;\nuniform sampler2D sampler;\nuniform bool flatShading;\nuniform float opacity;\nin vec2 vTexCoord;\nin vec3 cameraPosition;\nin vec3 normals_commonspace;\nin vec4 position_commonspace;\nin vec4 vColor;\nout vec4 fragColor;\nvoid main(void) {\n#ifdef MODULE_PBR\nfragColor = vColor * pbr_filterColor(vec4(0));\ngeometry.uv = pbr_vUV;\nfragColor.a *= opacity;\n#else\ngeometry.uv = vTexCoord;\nvec3 normal;\nif (flatShading) {\nnormal = normalize(cross(dFdx(position_commonspace.xyz), dFdy(position_commonspace.xyz)));\n} else {\nnormal = normals_commonspace;\n}\nvec4 color = hasTexture ? texture(sampler, vTexCoord) : vColor;\nvec3 lightColor = lighting_getLightColor(color.rgb, cameraPosition, position_commonspace.xyz, normal);\nfragColor = vec4(lightColor, color.a * opacity);\n#endif\nDECKGL_FILTER_COLOR(fragColor, geometry);\n}\n"}}initializeState(){const{featureIds:e}=this.props;super.initializeState();const t=this.getAttributeManager();e&&t.add({featureIdsPickingColors:{type:"uint8",size:3,noAlloc:!0,update:this.calculateFeatureIdsPickingColors}})}updateState(e){super.updateState(e);const{props:t,oldProps:i}=e;t.pbrMaterial!==i.pbrMaterial&&this.updatePbrMaterialUniforms(t.pbrMaterial)}draw(e){const{featureIds:t}=this.props;this.state.model&&(this.state.model.setUniforms({u_Camera:this.state.model.uniforms.project_uCameraPosition,pickFeatureIds:Boolean(t)}),super.draw(e))}getModel(e){const{id:t,pbrMaterial:i}=this.props,n=this.parseMaterial(i,e);this.setState({parsedPBRMaterial:n});const r=this.getShaders();!function(e){const t=e.positions||e.POSITION,i=t.value.length/t.size;e.COLOR_0||e.colors||(e.colors={size:4,value:new Uint8Array(4*i).fill(255),normalized:!0})}(e.attributes);return new bx(this.context.device,{...this.getShaders(),id:t,geometry:e,bufferLayout:this.getAttributeManager().getBufferLayouts(),defines:{...r.defines,...n?.defines,HAS_UV_REGIONS:e.attributes.uvRegions?1:0},parameters:n?.parameters,isInstanced:!0})}updatePbrMaterialUniforms(e){const{model:t}=this.state;if(t){const{mesh:i}=this.props,n=this.parseMaterial(e,i);this.setState({parsedPBRMaterial:n}),t.setBindings(n.bindings),t.setUniforms(n.uniforms)}}parseMaterial(e,t){const i=Boolean(e.pbrMetallicRoughness&&e.pbrMetallicRoughness.baseColorTexture);return IL(this.context.device,{unlit:i,...e},{NORMAL:t.attributes.normals,TEXCOORD_0:t.attributes.texCoords},{pbrDebug:!1,lights:!0,useTangents:!1})}calculateFeatureIdsPickingColors(e){const t=this.props.featureIds,i=new Uint8ClampedArray(t.length*e.size),n=[];for(let e=0;ee.destroy()),this.setState({parsedPBRMaterial:null})}}cO.layerName="MeshLayer",cO.defaultProps={pbrMaterial:{type:"object",value:null},featureIds:{type:"array",value:null,optional:!0}};var uO=cO;function hO(e){return e}function dO(e,t=[]){return function(e,t=[],i=hO){return"longitude"in e?(t[0]=i(e.longitude),t[1]=i(e.latitude),t[2]=e.height):"x"in e?(t[0]=i(e.x),t[1]=i(e.y),t[2]=e.z):(t[0]=i(e[0]),t[1]=i(e[1]),t[2]=e[2]),t}(e,t,R_._cartographicRadians?hO:k_)}function pO(e,t){return function(e,t,i=hO){return"longitude"in t?(t.longitude=i(e[0]),t.latitude=i(e[1]),t.height=e[2]):"x"in t?(t.x=i(e[0]),t.y=i(e[1]),t.z=e[2]):(t[0]=i(e[0]),t[1]=i(e[1]),t[2]=e[2]),t}(e,t,R_._cartographicRadians?hO:D_)}new AA;const fO=new AA,mO={up:{south:"east",north:"west",west:"south",east:"north"},down:{south:"west",north:"east",west:"north",east:"south"},south:{up:"west",down:"east",west:"down",east:"up"},north:{up:"east",down:"west",west:"up",east:"down"},west:{up:"north",down:"south",north:"down",south:"up"},east:{up:"south",down:"north",north:"up",south:"down"}},gO={north:[-1,0,0],east:[0,1,0],up:[0,0,1],south:[1,0,0],west:[0,-1,0],down:[0,0,-1]},_O={east:new AA,north:new AA,up:new AA,west:new AA,south:new AA,down:new AA},AO=new AA,yO=new AA,vO=new AA;function xO(e,t,i,n,r,o){const s=mO[t]&&mO[t][i];let a,l,c;Q_(s&&(!n||n===s));const u=fO.copy(r);if(N_(u.x,0,1e-14)&&N_(u.y,0,1e-14)){const e=Math.sign(u.z);a=AO.fromArray(gO[t]),"east"!==t&&"west"!==t&&a.scale(e),l=yO.fromArray(gO[i]),"east"!==i&&"west"!==i&&l.scale(e),c=vO.fromArray(gO[n]),"east"!==n&&"west"!==n&&c.scale(e)}else{const{up:r,east:o,north:s}=_O;o.set(-u.y,u.x,0).normalize(),e.geodeticSurfaceNormal(u,r),s.copy(r).cross(o);const{down:h,west:d,south:p}=_O;h.copy(r).scale(-1),d.copy(o).scale(-1),p.copy(s).scale(-1),a=_O[t],l=_O[i],c=_O[n]}return o[0]=a.x,o[1]=a.y,o[2]=a.z,o[3]=0,o[4]=l.x,o[5]=l.y,o[6]=l.z,o[7]=0,o[8]=c.x,o[9]=c.y,o[10]=c.z,o[11]=0,o[12]=u.x,o[13]=u.y,o[14]=u.z,o[15]=1,o}const bO=new AA,wO=new AA,TO=new AA;const EO=new AA,CO=new AA,SO=new AA,BO=new AA,IO=new AA,MO=new AA;class PO{constructor(e=0,t=0,i=0){this.centerToleranceSquared=.1,Q_(e>=0),Q_(t>=0),Q_(i>=0),this.radii=new AA(e,t,i),this.radiiSquared=new AA(e*e,t*t,i*i),this.radiiToTheFourth=new AA(e*e*e*e,t*t*t*t,i*i*i*i),this.oneOverRadii=new AA(0===e?0:1/e,0===t?0:1/t,0===i?0:1/i),this.oneOverRadiiSquared=new AA(0===e?0:1/(e*e),0===t?0:1/(t*t),0===i?0:1/(i*i)),this.minimumRadius=Math.min(e,t,i),this.maximumRadius=Math.max(e,t,i),0!==this.radiiSquared.z&&(this.squaredXOverSquaredZ=this.radiiSquared.x/this.radiiSquared.z),Object.freeze(this)}equals(e){return this===e||Boolean(e&&this.radii.equals(e.radii))}toString(){return this.radii.toString()}cartographicToCartesian(e,t=[0,0,0]){const i=CO,n=SO,[,,r]=e;this.geodeticSurfaceNormalCartographic(e,i),n.copy(this.radiiSquared).scale(i);const o=Math.sqrt(i.dot(n));return n.scale(1/o),i.scale(r),n.add(i),n.to(t)}cartesianToCartographic(e,t=[0,0,0]){MO.from(e);const i=this.scaleToGeodeticSurface(MO,BO);if(!i)return;const n=this.geodeticSurfaceNormal(i,CO),r=IO;r.copy(MO).subtract(i);return pO([Math.atan2(n.y,n.x),Math.asin(n.z),Math.sign(aA(r,MO))*oA(r)],t)}eastNorthUpToFixedFrame(e,t=new HA){return xO(this,"east","north","up",e,t)}localFrameToFixedFrame(e,t,i,n,r=new HA){return xO(this,e,t,i,n,r)}geocentricSurfaceNormal(e,t=[0,0,0]){return EO.from(e).normalize().to(t)}geodeticSurfaceNormalCartographic(e,t=[0,0,0]){const i=dO(e),n=i[0],r=i[1],o=Math.cos(r);return EO.set(o*Math.cos(n),o*Math.sin(n),Math.sin(r)).normalize(),EO.to(t)}geodeticSurfaceNormal(e,t=[0,0,0]){return EO.from(e).scale(this.oneOverRadiiSquared).normalize().to(t)}scaleToGeodeticSurface(e,t){return function(e,t,i=[]){const{oneOverRadii:n,oneOverRadiiSquared:r,centerToleranceSquared:o}=t;bO.from(e);const s=bO.x,a=bO.y,l=bO.z,c=n.x,u=n.y,h=n.z,d=s*s*c*c,p=a*a*u*u,f=l*l*h*h,m=d+p+f,g=Math.sqrt(1/m);if(!Number.isFinite(g))return;const _=wO;if(_.copy(e).scale(g),m1e-12);return bO.scale([b,w,T]).to(i)}(e,this,t)}scaleToGeocentricSurface(e,t=[0,0,0]){BO.from(e);const i=BO.x,n=BO.y,r=BO.z,o=this.oneOverRadiiSquared,s=1/Math.sqrt(i*i*o.x+n*n*o.y+r*r*o.z);return BO.multiplyScalar(s).to(t)}transformPositionToScaledSpace(e,t=[0,0,0]){return BO.from(e).scale(this.oneOverRadii).to(t)}transformPositionFromScaledSpace(e,t=[0,0,0]){return BO.from(e).scale(this.radii).to(t)}getSurfaceNormalIntersectionWithZAxis(e,t=0,i=[0,0,0]){Q_(N_(this.radii.x,this.radii.y,1e-15)),Q_(this.radii.z>0),BO.from(e);const n=BO.z*(1-this.squaredXOverSquaredZ);if(!(Math.abs(n)>=this.radii.z-t))return BO.set(0,0,n).to(i)}}PO.WGS84=new PO(6378137,6378137,6356752.314245179);class RO{item;previous;next;constructor(e,t,i){this.item=e,this.previous=t,this.next=i}}class LO{head=null;tail=null;_length=0;get length(){return this._length}add(e){const t=new RO(e,this.tail,null);return this.tail?(this.tail.next=t,this.tail=t):(this.head=t,this.tail=t),++this._length,t}remove(e){e&&(e.previous&&e.next?(e.previous.next=e.next,e.next.previous=e.previous):e.previous?(e.previous.next=null,this.tail=e.previous):e.next?(e.next.previous=null,this.head=e.next):(this.head=null,this.tail=null),e.next=null,e.previous=null,--this._length)}splice(e,t){e!==t&&(this.remove(t),this._insert(e,t))}_insert(e,t){const i=e.next;e.next=t,this.tail===e?this.tail=t:i.previous=t,t.next=i,t.previous=e,++this._length}}class FO{_list;_sentinel;_trimTiles;constructor(){this._list=new LO,this._sentinel=this._list.add("sentinel"),this._trimTiles=!1}reset(){this._list.splice(this._list.tail,this._sentinel)}touch(e){const t=e._cacheNode;t&&this._list.splice(this._sentinel,t)}add(e,t,i){t._cacheNode||(t._cacheNode=this._list.add(t),i&&i(e,t))}unloadTile(e,t,i){const n=t._cacheNode;n&&(this._list.remove(n),t._cacheNode=null,i&&i(e,t))}unloadTiles(e,t){const i=this._trimTiles;this._trimTiles=!1;const n=this._list,r=1024*e.maximumMemoryUsage*1024,o=this._sentinel;let s=n.head;for(;s!==o&&(e.gpuMemoryUsageInBytes>r||i);){const i=s.item;s=s.next,this.unloadTile(e,i,t)}}trim(){this._trimTiles=!0}}const kO=new AA,DO=new AA,OO=new bR([new AR,new AR,new AR,new AR,new AR,new AR]);function zO(e,t){const{cameraDirection:i,cameraUp:n,height:r}=e,{metersPerUnit:o}=e.distanceScales,s=NO(e,e.center),a=PO.WGS84.eastNorthUpToFixedFrame(s),l=e.unprojectPosition(e.cameraPosition),c=PO.WGS84.cartographicToCartesian(l,new AA),u=new AA(a.transformAsVector(new AA(i).scale(o))).normalize(),h=new AA(a.transformAsVector(new AA(n).scale(o))).normalize();!function(e){const t=e.getFrustumPlanes(),i=UO(t.near,e.cameraPosition),n=NO(e,i),r=NO(e,e.cameraPosition,DO);let o=0;OO.planes[o++].fromPointNormal(n,kO.copy(n).subtract(r));for(const r in t){if("near"===r)continue;const s=NO(e,UO(t[r],i,DO),DO);OO.planes[o++].fromPointNormal(s,kO.copy(n).subtract(s))}}(e);const d=e.constructor,{longitude:p,latitude:f,width:m,bearing:g,zoom:_}=e;return{camera:{position:c,direction:u,up:h},viewport:e,topDownViewport:new d({longitude:p,latitude:f,height:r,width:m,bearing:g,zoom:_,pitch:0}),height:r,cullingVolume:OO,frameNumber:t,sseDenominator:1.15}}function UO(e,t,i=new AA){const n=e.normal.dot(t);return i.copy(e.normal).scale(e.distance-n).add(t),i}function NO(e,t,i=new AA){const n=e.unprojectPosition(t);return PO.WGS84.cartographicToCartesian(n,i)}const VO=6356752.314245179,jO=new AA;function GO(e,t){if(e instanceof mR){const{halfAxes:i}=e,n=function(e){e.getColumn(0,jO);const t=e.getColumn(1),i=e.getColumn(2),n=jO.add(t).add(i);return n.len()}(i);return Math.log2(VO/(n+t[2]))}if(e instanceof JP){const{radius:i}=e;return Math.log2(VO/(i+t[2]))}if(e.width&&e.height){const{width:t,height:i}=e;return(Math.log2(6378137/t)+Math.log2(6378137/i))/2}return 1}function HO(e,t,i){PO.WGS84.cartographicToCartesian([e.xmax,e.ymax,e.zmax],jO);const n=Math.sqrt(Math.pow(jO[0]-i[0],2)+Math.pow(jO[1]-i[1],2)+Math.pow(jO[2]-i[2],2));return Math.log2(VO/(n+t[2]))}const QO=0,$O=1,ZO=3,WO=4,qO=5;var KO,XO,JO,YO;!function(e){e[e.ADD=1]="ADD",e[e.REPLACE=2]="REPLACE"}(KO||(KO={})),function(e){e.EMPTY="empty",e.SCENEGRAPH="scenegraph",e.POINTCLOUD="pointcloud",e.MESH="mesh"}(XO||(XO={})),function(e){e.I3S="I3S",e.TILES3D="TILES3D"}(JO||(JO={})),function(e){e.GEOMETRIC_ERROR="geometricError",e.MAX_SCREEN_THRESHOLD="maxScreenThreshold"}(YO||(YO={}));const ez=1;function tz(e){return null!=e}const iz=new AA,nz=new AA,rz=new AA,oz=new AA,sz=new AA,az=new AA,lz=new AA,cz=new AA;function uz(e,t,i){if(Tu(e,"3D Tile: boundingVolume must be defined"),e.box)return dz(e.box,t,i);if(e.region)return function(e){const[t,i,n,r,o,s]=e,a=PO.WGS84.cartographicToCartesian([O_(t),O_(r),o],rz),l=PO.WGS84.cartographicToCartesian([O_(n),O_(i),s],oz),c=(new AA).addVectors(a,l).multiplyByScalar(.5);return PO.WGS84.cartesianToCartographic(c,sz),PO.WGS84.cartographicToCartesian([O_(n),sz[1],sz[2]],az),PO.WGS84.cartographicToCartesian([sz[0],O_(r),sz[2]],lz),PO.WGS84.cartographicToCartesian([sz[0],sz[1],s],cz),dz([...c,...az.subtract(c),...lz.subtract(c),...cz.subtract(c)],new HA)}(e.region);if(e.sphere)return function(e,t,i){const n=new AA(e[0],e[1],e[2]);t.transform(n,n);const r=t.getScale(nz),o=Math.max(Math.max(r[0],r[1]),r[2]),s=e[3]*o;if(tz(i))return i.center=n,i.radius=s,i;return new JP(n,s)}(e.sphere,t,i);throw new Error("3D Tile: boundingVolume must contain a sphere, region, or box")}function hz(e,t){if(e.box)return function(e){const t=pz(),{halfAxes:i}=e,n=new AA(i.getColumn(0)),r=new AA(i.getColumn(1)),o=new AA(i.getColumn(2));for(let i=0;i<2;i++){for(let i=0;i<2;i++){for(let i=0;i<2;i++)iz.copy(e.center),iz.add(n),iz.add(r),iz.add(o),fz(t,iz),o.negate();r.negate()}n.negate()}return t}(t);if(e.region){const[t,i,n,r,o,s]=e.region;return[[O_(t),O_(i),o],[O_(n),O_(r),s]]}if(e.sphere)return function(e){const t=pz(),{center:i,radius:n}=e,r=PO.WGS84.scaleToGeodeticSurface(i,iz);let o;o=r?PO.WGS84.geodeticSurfaceNormal(r):new AA(0,0,1);let s=new AA(o[2],-o[1],0);s.len()>0?s.normalize():s=new AA(0,1,0);const a=s.clone().cross(o);for(const e of[s,a,o]){nz.copy(e).scale(n);for(let e=0;e<2;e++)iz.copy(i),iz.add(nz),fz(t,iz),nz.negate()}return t}(t);throw new Error("Unkown boundingVolume type")}function dz(e,t,i){const n=new AA(e[0],e[1],e[2]);t.transform(n,n);let r=[];if(10===e.length){const t=e.slice(3,6),i=new ly;i.fromArray(e,6);const n=new AA([1,0,0]),o=new AA([0,1,0]),s=new AA([0,0,1]);n.transformByQuaternion(i),n.scale(t[0]),o.transformByQuaternion(i),o.scale(t[1]),s.transformByQuaternion(i),s.scale(t[2]),r=[...n.toArray(),...o.toArray(),...s.toArray()]}else r=[...e.slice(3,6),...e.slice(6,9),...e.slice(9,12)];const o=t.transformAsVector(r.slice(0,3)),s=t.transformAsVector(r.slice(3,6)),a=t.transformAsVector(r.slice(6,9)),l=new EA([o[0],o[1],o[2],s[0],s[1],s[2],a[0],a[1],a[2]]);return tz(i)?(i.center=n,i.halfAxes=l,i):new mR(n,l)}function pz(){return[[1/0,1/0,1/0],[-1/0,-1/0,-1/0]]}function fz(e,t){PO.WGS84.cartesianToCartographic(t,iz),e[0][0]=Math.min(e[0][0],iz[0]),e[0][1]=Math.min(e[0][1],iz[1]),e[0][2]=Math.min(e[0][2],iz[2]),e[1][0]=Math.max(e[1][0],iz[0]),e[1][1]=Math.max(e[1][1],iz[1]),e[1][2]=Math.max(e[1][2],iz[2])}function mz(e,t){if(e.dynamicScreenSpaceError&&e.dynamicScreenSpaceErrorComputedDensity){const i=e.dynamicScreenSpaceErrorComputedDensity,n=e.dynamicScreenSpaceErrorFactor,r=function(e,t){const i=e*t;return 1-Math.exp(-i*i)}(t,i)*n;return r}return 0}new AA,new AA,new HA,new AA,new AA,new AA;const gz=new AA,_z=new AA,Az=new AA,yz=new AA,vz=new AA,xz=new HA,bz=new HA;function wz(e,t){const{topDownViewport:i}=t,n=e.header.mbs[1],r=e.header.mbs[0],o=e.header.mbs[2],s=e.header.mbs[3],a=[...e.boundingVolume.center],l=i.unprojectPosition(i.cameraPosition);PO.WGS84.cartographicToCartesian(l,gz),_z.copy(gz).subtract(a).normalize(),PO.WGS84.eastNorthUpToFixedFrame(a,xz),bz.copy(xz).invert(),Az.copy(gz).transform(bz);const c=Math.sqrt(Az[0]*Az[0]+Az[1]*Az[1]),u=c*c/Az[2];yz.copy([Az[0],Az[1],u]);const h=yz.transform(xz).subtract(a).normalize(),d=_z.cross(h).normalize().scale(s).add(a),p=PO.WGS84.cartesianToCartographic(d),f=i.project([r,n,o]),m=i.project(p);return vz.copy(f).subtract(m).magnitude()}class Tz{_map=new Map;_array;_length;constructor(e=0){this._array=new Array(e),this._length=e}get length(){return this._length}set length(e){this._length=e,e>this._array.length&&(this._array.length=e)}get values(){return this._array}get(e){return Tu(e=0),e>=this.length&&(this.length=e+1),this._map.has(this._array[e])&&this._map.delete(this._array[e]),this._array[e]=t,this._map.set(t,e)}delete(e){const t=this._map.get(e);t>=0&&(this._array.splice(t,1),this._map.delete(e),this.length--)}peek(){return this._array[this._length-1]}push(e){if(!this._map.has(e)){const t=this.length++;this._array[t]=e,this._map.set(e,t)}}pop(){const e=this._array[--this.length];return this._map.delete(e),e}reserve(e){Tu(e>=0),e>this._array.length&&(this._array.length=e)}resize(e){Tu(e>=0),this.length=e}trim(e){null==e&&(e=this.length),this._array.length=e}reset(){this._array=[],this._map=new Map,this._length=0}find(e){return this._map.has(e)}}const Ez={loadSiblings:!1,skipLevelOfDetail:!1,updateTransforms:!0,onTraversalEnd:()=>{},viewportTraversersMap:{},basePath:""};class Cz{options;root=null;selectedTiles={};requestedTiles={};emptyTiles={};lastUpdate=(new Date).getTime();updateDebounceTime=1e3;_traversalStack=new Tz;_emptyTraversalStack=new Tz;_frameNumber=null;traversalFinished(e){return!0}constructor(e){this.options={...Ez,...e}}traverse(e,t,i){this.root=e,this.options={...this.options,...i},this.reset(),this.updateTile(e,t),this._frameNumber=t.frameNumber,this.executeTraversal(e,t)}reset(){this.requestedTiles={},this.selectedTiles={},this.emptyTiles={},this._traversalStack.reset(),this._emptyTraversalStack.reset()}executeTraversal(e,t){const i=this._traversalStack;for(e._selectionDepth=1,i.push(e);i.length>0;){const e=i.pop();let n=!1;this.canTraverse(e,t)&&(this.updateChildTiles(e,t),n=this.updateAndPushChildren(e,t,i,e.hasRenderContent?e._selectionDepth+1:e._selectionDepth));const r=e.parent,o=Boolean(!r||r._shouldRefine),s=!n;e.hasRenderContent?e.refine===KO.ADD?(this.loadTile(e,t),this.selectTile(e,t)):e.refine===KO.REPLACE&&(this.loadTile(e,t),s&&this.selectTile(e,t)):(this.emptyTiles[e.id]=e,this.loadTile(e,t),s&&this.selectTile(e,t)),this.touchTile(e,t),e._shouldRefine=n&&o}const n=(new Date).getTime();(this.traversalFinished(t)||n-this.lastUpdate>this.updateDebounceTime)&&(this.lastUpdate=n,this.options.onTraversalEnd(t))}updateChildTiles(e,t){const i=e.children;for(const e of i)this.updateTile(e,t)}updateAndPushChildren(e,t,i,n){const{loadSiblings:r,skipLevelOfDetail:o}=this.options,s=e.children;s.sort(this.compareDistanceToCamera.bind(this));const a=e.refine===KO.REPLACE&&e.hasRenderContent&&!o;let l=!1,c=!0;for(const e of s)if(e._selectionDepth=n,e.isVisibleAndInRequestVolume?(i.find(e)&&i.delete(e),i.push(e),l=!0):(a||r)&&(this.loadTile(e,t),this.touchTile(e,t)),a){let i;if(i=!!e._inRequestVolume&&(e.hasRenderContent?e.contentAvailable:this.executeEmptyTraversal(e,t)),c=c&&i,!c)return!1}return l||(c=!1),c}updateTile(e,t){this.updateTileVisibility(e,t)}selectTile(e,t){this.shouldSelectTile(e)&&(e._selectedFrame=t.frameNumber,this.selectedTiles[e.id]=e)}loadTile(e,t){this.shouldLoadTile(e)&&(e._requestedFrame=t.frameNumber,e._priority=e._getPriority(),this.requestedTiles[e.id]=e)}touchTile(e,t){e.tileset._cache.touch(e),e._touchedFrame=t.frameNumber}canTraverse(e,t){return!!e.hasChildren&&(e.hasTilesetContent?!e.contentExpired:this.shouldRefine(e,t))}shouldLoadTile(e){return e.hasUnloadedContent||e.contentExpired}shouldSelectTile(e){return e.contentAvailable&&!this.options.skipLevelOfDetail}shouldRefine(e,t,i=!1){let n=e._screenSpaceError;return i&&(n=e.getScreenSpaceError(t,!0)),n>e.tileset.memoryAdjustedScreenSpaceError}updateTileVisibility(e,t){const i=[];if(this.options.viewportTraversersMap)for(const e in this.options.viewportTraversersMap){this.options.viewportTraversersMap[e]===t.viewport.id&&i.push(e)}else i.push(t.viewport.id);e.updateVisibility(t,i)}compareDistanceToCamera(e,t){return e._distanceToCamera-t._distanceToCamera}anyChildrenVisible(e,t){let i=!1;for(const n of e.children)n.updateVisibility(t),i=i||n.isVisibleAndInRequestVolume;return i}executeEmptyTraversal(e,t){let i=!0;const n=this._emptyTraversalStack;for(n.push(e);n.length>0;){const e=n.pop(),r=!e.hasRenderContent&&this.canTraverse(e,t),o=!e.hasRenderContent&&0===e.children.length;if(r||e.contentAvailable||o||(i=!1),this.updateTile(e,t),e.isVisibleAndInRequestVolume||(this.loadTile(e,t),this.touchTile(e,t)),r){const t=e.children;for(const e of t)n.push(e)}}return i}}const Sz=new AA;class Bz{tileset;header;id;url;parent;refine;type;contentUrl;lodMetricType="geometricError";lodMetricValue=0;boundingVolume=null;content=null;contentState=QO;gpuMemoryUsageInBytes=0;children=[];depth=0;viewportIds=[];transform=new HA;extensions=null;implicitTiling=null;userData={};computedTransform;hasEmptyContent=!1;hasTilesetContent=!1;traverser=new Cz({});_cacheNode=null;_frameNumber=null;_expireDate=null;_expiredContent=null;_boundingBox=void 0;_distanceToCamera=0;_screenSpaceError=0;_visibilityPlaneMask;_visible=void 0;_contentBoundingVolume;_viewerRequestVolume;_initialTransform=new HA;_priority=0;_selectedFrame=0;_requestedFrame=0;_selectionDepth=0;_touchedFrame=0;_centerZDepth=0;_shouldRefine=!1;_stackLength=0;_visitedFrame=0;_inRequestVolume=!1;_lodJudge=null;constructor(e,t,i,n=""){this.header=t,this.tileset=e,this.id=n||t.id,this.url=t.url,this.parent=i,this.refine=this._getRefine(t.refine),this.type=t.type,this.contentUrl=t.contentUrl,this._initializeLodMetric(t),this._initializeTransforms(t),this._initializeBoundingVolumes(t),this._initializeContent(t),this._initializeRenderingState(t),Object.seal(this)}destroy(){this.header=null}isDestroyed(){return null===this.header}get selected(){return this._selectedFrame===this.tileset._frameNumber}get isVisible(){return this._visible}get isVisibleAndInRequestVolume(){return this._visible&&this._inRequestVolume}get hasRenderContent(){return!this.hasEmptyContent&&!this.hasTilesetContent}get hasChildren(){return this.children.length>0||this.header.children&&this.header.children.length>0}get contentReady(){return this.contentState===ZO||this.hasEmptyContent}get contentAvailable(){return Boolean(this.contentReady&&this.hasRenderContent||this._expiredContent&&!this.contentFailed)}get hasUnloadedContent(){return this.hasRenderContent&&this.contentUnloaded}get contentUnloaded(){return this.contentState===QO}get contentExpired(){return this.contentState===WO}get contentFailed(){return this.contentState===qO}get distanceToCamera(){return this._distanceToCamera}get screenSpaceError(){return this._screenSpaceError}get boundingBox(){return this._boundingBox||(this._boundingBox=hz(this.header.boundingVolume,this.boundingVolume)),this._boundingBox}getScreenSpaceError(e,t){switch(this.tileset.type){case JO.I3S:return wz(this,e);case JO.TILES3D:return function(e,t,i){const n=e.tileset,r=e.parent&&e.parent.lodMetricValue||e.lodMetricValue,o=i?r:e.lodMetricValue;if(0===o)return 0;const s=Math.max(e._distanceToCamera,1e-7),{height:a,sseDenominator:l}=t,{viewDistanceScale:c}=n.options;let u=o*a*(c||1)/(s*l);return u-=mz(n,s),u}(this,e,t);default:throw new Error("Unsupported tileset type")}}unselect(){this._selectedFrame=0}_getGpuMemoryUsageInBytes(){return this.content.gpuMemoryUsageInBytes||this.content.byteLength||0}_getPriority(){const e=this.tileset._traverser,{skipLevelOfDetail:t}=e.options,i=this.refine===KO.ADD||t;if(i&&!this.isVisible&&void 0!==this._visible)return-1;if(this.tileset._frameNumber-this._touchedFrame>=1)return-1;if(this.contentState===QO)return-1;const n=this.parent,r=n&&(!i||0===this._screenSpaceError||n.hasTilesetContent)?n._screenSpaceError:this._screenSpaceError,o=e.root?e.root._screenSpaceError:0;return Math.max(o-r,0)}async loadContent(){if(this.hasEmptyContent)return!1;if(this.content)return!0;this.contentExpired&&(this._expireDate=null),this.contentState=$O;const e=await this.tileset._requestScheduler.scheduleRequest(this.id,this._getPriority.bind(this));if(!e)return this.contentState=QO,!1;try{const e=this.tileset.getTileUrl(this.contentUrl),t=this.tileset.loader,i={...this.tileset.loadOptions,[t.id]:{...this.tileset.loadOptions[t.id],isTileset:"json"===this.type,...this._getLoaderSpecificOptions(t.id)}};return this.content=await dI(e,t,i),this.tileset.options.contentLoader&&await this.tileset.options.contentLoader(this),this._isTileset()&&this.tileset._initializeTileHeaders(this.content,this),this.contentState=ZO,this._onContentLoaded(),!0}catch(e){throw this.contentState=qO,e}finally{e.done()}}unloadContent(){return this.content&&this.content.destroy&&this.content.destroy(),this.content=null,this.header.content&&this.header.content.destroy&&this.header.content.destroy(),this.header.content=null,this.contentState=QO,!0}updateVisibility(e,t){if(this._frameNumber===e.frameNumber)return;const i=this.parent,n=i?i._visibilityPlaneMask:bR.MASK_INDETERMINATE;if(this.tileset._traverser.options.updateTransforms){const e=i?i.computedTransform:this.tileset.modelMatrix;this._updateTransform(e)}this._distanceToCamera=this.distanceToTile(e),this._screenSpaceError=this.getScreenSpaceError(e,!1),this._visibilityPlaneMask=this.visibility(e,n),this._visible=this._visibilityPlaneMask!==bR.MASK_OUTSIDE,this._inRequestVolume=this.insideViewerRequestVolume(e),this._frameNumber=e.frameNumber,this.viewportIds=t}visibility(e,t){const{cullingVolume:i}=e,{boundingVolume:n}=this;return i.computeVisibilityWithPlaneMask(n,t)}contentVisibility(){return!0}distanceToTile(e){const t=this.boundingVolume;return Math.sqrt(Math.max(t.distanceSquaredTo(e.camera.position),0))}cameraSpaceZDepth({camera:e}){const t=this.boundingVolume;return Sz.subVectors(t.center,e.position),e.direction.dot(Sz)}insideViewerRequestVolume(e){const t=this._viewerRequestVolume;return!t||t.distanceSquaredTo(e.camera.position)<=0}updateExpiration(){if(function(e){return null!=e}(this._expireDate)&&this.contentReady&&!this.hasEmptyContent){const e=Date.now();Date.lessThan(this._expireDate,e)&&(this.contentState=WO,this._expiredContent=this.content)}}get extras(){return this.header.extras}_initializeLodMetric(e){"lodMetricType"in e?this.lodMetricType=e.lodMetricType:(this.lodMetricType=this.parent&&this.parent.lodMetricType||this.tileset.lodMetricType,console.warn("3D Tile: Required prop lodMetricType is undefined. Using parent lodMetricType")),"lodMetricValue"in e?this.lodMetricValue=e.lodMetricValue:(this.lodMetricValue=this.parent&&this.parent.lodMetricValue||this.tileset.lodMetricValue,console.warn("3D Tile: Required prop lodMetricValue is undefined. Using parent lodMetricValue"))}_initializeTransforms(e){this.transform=e.transform?new HA(e.transform):new HA;const t=this.parent,i=this.tileset,n=t&&t.computedTransform?t.computedTransform.clone():i.modelMatrix.clone();this.computedTransform=new HA(n).multiplyRight(this.transform);const r=t&&t._initialTransform?t._initialTransform.clone():new HA;this._initialTransform=new HA(r).multiplyRight(this.transform)}_initializeBoundingVolumes(e){this._contentBoundingVolume=null,this._viewerRequestVolume=null,this._updateBoundingVolume(e)}_initializeContent(e){this.content={_tileset:this.tileset,_tile:this},this.hasEmptyContent=!0,this.contentState=QO,this.hasTilesetContent=!1,e.contentUrl&&(this.content=null,this.hasEmptyContent=!1)}_initializeRenderingState(e){this.depth=e.level||(this.parent?this.parent.depth+1:0),this._shouldRefine=!1,this._distanceToCamera=0,this._centerZDepth=0,this._screenSpaceError=0,this._visibilityPlaneMask=bR.MASK_INDETERMINATE,this._visible=void 0,this._inRequestVolume=!1,this._stackLength=0,this._selectionDepth=0,this._frameNumber=0,this._touchedFrame=0,this._visitedFrame=0,this._selectedFrame=0,this._requestedFrame=0,this._priority=0}_getRefine(e){return e||this.parent&&this.parent.refine||KO.REPLACE}_isTileset(){return-1!==this.contentUrl.indexOf(".json")}_onContentLoaded(){switch(this.content&&this.content.type){case"vctr":case"geom":this.tileset._traverser.disableSkipLevelOfDetail=!0}this._isTileset()?this.hasTilesetContent=!0:this.gpuMemoryUsageInBytes=this._getGpuMemoryUsageInBytes()}_updateBoundingVolume(e){this.boundingVolume=uz(e.boundingVolume,this.computedTransform,this.boundingVolume);const t=e.content;t&&(t.boundingVolume&&(this._contentBoundingVolume=uz(t.boundingVolume,this.computedTransform,this._contentBoundingVolume)),e.viewerRequestVolume&&(this._viewerRequestVolume=uz(e.viewerRequestVolume,this.computedTransform,this._viewerRequestVolume)))}_updateTransform(e=new HA){const t=e.clone().multiplyRight(this.transform);!t.equals(this.computedTransform)&&(this.computedTransform=t,this._updateBoundingVolume(this.header))}_getLoaderSpecificOptions(e){return"i3s"===e?{...this.tileset.options.i3s,_tileOptions:{attributeUrls:this.header.attributeUrls,textureUrl:this.header.textureUrl,textureFormat:this.header.textureFormat,textureLoaderOptions:this.header.textureLoaderOptions,materialDefinition:this.header.materialDefinition,isDracoGeometry:this.header.isDracoGeometry,mbs:this.header.mbs},_tilesetOptions:{store:this.tileset.tileset.store,attributeStorageInfo:this.tileset.tileset.attributeStorageInfo,fields:this.tileset.tileset.fields},isTileHeader:!1}:{assetGltfUpAxis:(t=this.tileset.tileset).asset&&t.asset.gltfUpAxis||"Y"};var t}}class Iz extends Cz{compareDistanceToCamera(e,t){return 0===t._distanceToCamera&&0===e._distanceToCamera?t._centerZDepth-e._centerZDepth:t._distanceToCamera-e._distanceToCamera}updateTileVisibility(e,t){if(super.updateTileVisibility(e,t),!e.isVisibleAndInRequestVolume)return;const i=e.children.length>0;if(e.hasTilesetContent&&i){const i=e.children[0];return this.updateTileVisibility(i,t),void(e._visible=i._visible)}if(this.meetsScreenSpaceErrorEarly(e,t))return void(e._visible=!1);const n=e.refine===KO.REPLACE,r=e._optimChildrenWithinParent===ez;n&&r&&i&&!this.anyChildrenVisible(e,t)&&(e._visible=!1)}meetsScreenSpaceErrorEarly(e,t){const{parent:i}=e;return!(!i||i.hasTilesetContent||i.refine!==KO.ADD)&&!this.shouldRefine(e,t,!0)}}class Mz{frameNumberMap=new Map;register(e,t){const i=this.frameNumberMap.get(e)||new Map,n=i.get(t)||0;i.set(t,n+1),this.frameNumberMap.set(e,i)}deregister(e,t){const i=this.frameNumberMap.get(e);if(!i)return;const n=i.get(t)||1;i.set(t,n-1)}isZero(e,t){return 0===(this.frameNumberMap.get(e)?.get(t)||0)}}const Pz="REQUESTED",Rz="COMPLETED",Lz="ERROR";class Fz{_statusMap;pendingTilesRegister=new Mz;constructor(){this._statusMap={}}add(e,t,i,n){if(!this._statusMap[t]){const{frameNumber:r,viewport:{id:o}}=n;this._statusMap[t]={request:e,callback:i,key:t,frameState:n,status:Pz},this.pendingTilesRegister.register(o,r),e().then(e=>{this._statusMap[t].status=Rz;const{frameNumber:i,viewport:{id:r}}=this._statusMap[t].frameState;this.pendingTilesRegister.deregister(r,i),this._statusMap[t].callback(e,n)}).catch(e=>{this._statusMap[t].status=Lz;const{frameNumber:n,viewport:{id:r}}=this._statusMap[t].frameState;this.pendingTilesRegister.deregister(r,n),i(e)})}}update(e,t){if(this._statusMap[e]){const{frameNumber:i,viewport:{id:n}}=this._statusMap[e].frameState;this.pendingTilesRegister.deregister(n,i);const{frameNumber:r,viewport:{id:o}}=t;this.pendingTilesRegister.register(o,r),this._statusMap[e].frameState=t}}find(e){return this._statusMap[e]}hasPendingTiles(e,t){return!this.pendingTilesRegister.isZero(e,t)}}class kz extends Cz{_tileManager;constructor(e){super(e),this._tileManager=new Fz}traversalFinished(e){return!this._tileManager.hasPendingTiles(e.viewport.id,this._frameNumber||0)}shouldRefine(e,t){return e._lodJudge=function(e,t){if(0===e.lodMetricValue||isNaN(e.lodMetricValue))return"DIG";const i=2*wz(e,t);return i<2?"OUT":!e.header.children||i<=e.lodMetricValue?"DRAW":e.header.children?"DIG":"OUT"}(e,t),"DIG"===e._lodJudge}updateChildTiles(e,t){const i=e.header.children||[],n=e.children,r=e.tileset;for(const o of i){const i=`${o.id}-${t.viewport.id}`,s=n&&n.find(e=>e.id===i);if(s)s&&this.updateTile(s,t);else{let n=()=>this._loadTile(o.id,r);this._tileManager.find(i)?this._tileManager.update(i,t):(r.tileset.nodePages&&(n=()=>r.tileset.nodePagesTile.formTileFromNodePages(o.id)),this._tileManager.add(n,i,t=>this._onTileLoad(t,e,i),t))}}return!1}async _loadTile(e,t){const{loader:i}=t,n=t.getTileUrl(`${t.url}/nodes/${e}`),r={...t.loadOptions,i3s:{...t.loadOptions.i3s,isTileHeader:!0}};return await dI(n,i,r)}_onTileLoad(e,t,i){const n=new Bz(t.tileset,e,t,i);t.children.push(n);const r=this._tileManager.find(n.id).frameState;this.updateTile(n,r),this._frameNumber===r.frameNumber&&(this.traversalFinished(r)||(new Date).getTime()-this.lastUpdate>this.updateDebounceTime)&&this.executeTraversal(n,r)}}const Dz={description:"",ellipsoid:PO.WGS84,modelMatrix:new HA,throttleRequests:!0,maxRequests:64,maximumMemoryUsage:32,memoryCacheOverflow:1,maximumTilesSelected:0,debounceTime:0,onTileLoad:()=>{},onTileUnload:()=>{},onTileError:()=>{},onTraversalComplete:e=>e,contentLoader:void 0,viewDistanceScale:1,maximumScreenSpaceError:8,memoryAdjustedScreenSpaceError:!1,loadTiles:!0,updateTransforms:!0,viewportTraversersMap:null,loadOptions:{fetch:{}},attributions:[],basePath:"",i3s:{}},Oz="Tiles In Tileset(s)",zz="Tiles In Memory",Uz="Tiles In View",Nz="Tiles To Render",Vz="Tiles Loaded",jz="Tiles Loading",Gz="Tiles Unloaded",Hz="Failed Tile Loads",Qz="Points/Vertices",$z="Tile Memory Use",Zz="Maximum Screen Space Error";class Wz{options;loadOptions;type;tileset;loader;url;basePath;modelMatrix;ellipsoid;lodMetricType;lodMetricValue;refine;root=null;roots={};asset={};description="";properties;extras=null;attributions={};credits={};stats;contentFormats={draco:!1,meshopt:!1,dds:!1,ktx2:!1};cartographicCenter=null;cartesianCenter=null;zoom=1;boundingVolume=null;dynamicScreenSpaceErrorComputedDensity=0;maximumMemoryUsage=32;gpuMemoryUsageInBytes=0;memoryAdjustedScreenSpaceError=0;_cacheBytes=0;_cacheOverflowBytes=0;_frameNumber=0;_queryParams={};_extensionsUsed=[];_tiles={};_pendingCount=0;selectedTiles=[];traverseCounter=0;geometricError=0;lastUpdatedVieports=null;_requestedTiles=[];_emptyTiles=[];frameStateData={};_traverser;_cache=new FO;_requestScheduler;updatePromise=null;tilesetInitializationPromise;constructor(e,t){this.options={...Dz,...t},this.tileset=e,this.loader=e.loader,this.type=e.type,this.url=e.url,this.basePath=e.basePath||Lh(this.url),this.modelMatrix=this.options.modelMatrix,this.ellipsoid=this.options.ellipsoid,this.lodMetricType=e.lodMetricType,this.lodMetricValue=e.lodMetricValue,this.refine=e.root.refine,this.loadOptions=this.options.loadOptions||{},this._traverser=this._initializeTraverser(),this._requestScheduler=new Bh({throttleRequests:this.options.throttleRequests,maxRequests:this.options.maxRequests}),this.memoryAdjustedScreenSpaceError=this.options.maximumScreenSpaceError,this._cacheBytes=1024*this.options.maximumMemoryUsage*1024,this._cacheOverflowBytes=1024*this.options.memoryCacheOverflow*1024,this.stats=new Ch({id:this.url}),this._initializeStats(),this.tilesetInitializationPromise=this._initializeTileSet(e)}destroy(){this._destroy()}isLoaded(){return 0===this._pendingCount&&0!==this._frameNumber&&0===this._requestedTiles.length}get tiles(){return Object.values(this._tiles)}get frameNumber(){return this._frameNumber}get queryParams(){return new URLSearchParams(this._queryParams).toString()}setProps(e){this.options={...this.options,...e}}getTileUrl(e){if(e.startsWith("data:"))return e;let t=e;return this.queryParams.length&&(t=`${e}${e.includes("?")?"&":"?"}${this.queryParams}`),t}hasExtension(e){return Boolean(this._extensionsUsed.indexOf(e)>-1)}update(e=null){this.tilesetInitializationPromise.then(()=>{!e&&this.lastUpdatedVieports?e=this.lastUpdatedVieports:this.lastUpdatedVieports=e,e&&this.doUpdate(e)})}async selectTiles(e=null){return await this.tilesetInitializationPromise,e&&(this.lastUpdatedVieports=e),this.updatePromise||(this.updatePromise=new Promise(e=>{setTimeout(()=>{this.lastUpdatedVieports&&this.doUpdate(this.lastUpdatedVieports),e(this._frameNumber),this.updatePromise=null},this.options.debounceTime)})),this.updatePromise}adjustScreenSpaceError(){this.gpuMemoryUsageInBytesthis._cacheBytes+this._cacheOverflowBytes&&(this.memoryAdjustedScreenSpaceError*=1.02)}doUpdate(e){if("loadTiles"in this.options&&!this.options.loadTiles)return;if(this.traverseCounter>0)return;const t=e instanceof Array?e:[e];this._cache.reset(),this._frameNumber++,this.traverseCounter=t.length;const i=[];for(const e of t){const t=e.id;this._needTraverse(t)?i.push(t):this.traverseCounter--}for(const e of t){const t=e.id;if(this.roots[t]||(this.roots[t]=this._initializeTileHeaders(this.tileset,null)),!i.includes(t))continue;const n=zO(e,this._frameNumber);this._traverser.traverse(this.roots[t],n,this.options)}}_needTraverse(e){let t=e;return this.options.viewportTraversersMap&&(t=this.options.viewportTraversersMap[e]),t===e}_onTraversalEnd(e){const t=e.viewport.id;this.frameStateData[t]||(this.frameStateData[t]={selectedTiles:[],_requestedTiles:[],_emptyTiles:[]});const i=this.frameStateData[t],n=Object.values(this._traverser.selectedTiles),[r,o]=function(e,t,i){if(0===i||e.length<=i)return[e,[]];const n=[],{longitude:r,latitude:o}=t.viewport;for(const[t,i]of e.entries()){const[e,s]=i.header.mbs,a=Math.abs(r-e),l=Math.abs(o-s),c=Math.sqrt(l*l+a*a);n.push([t,c])}const s=n.sort((e,t)=>e[1]-t[1]),a=[];for(let t=0;t0||this._updateTiles()}_updateTiles(){this.selectedTiles=[],this._requestedTiles=[],this._emptyTiles=[];for(const e in this.frameStateData){const t=this.frameStateData[e];this.selectedTiles=this.selectedTiles.concat(t.selectedTiles),this._requestedTiles=this._requestedTiles.concat(t._requestedTiles),this._emptyTiles=this._emptyTiles.concat(t._emptyTiles)}this.selectedTiles=this.options.onTraversalComplete(this.selectedTiles);for(const e of this.selectedTiles)this._tiles[e.id]=e;this._loadTiles(),this._unloadTiles(),this._updateStats()}_tilesChanged(e,t){if(e.length!==t.length)return!0;const i=new Set(e.map(e=>e.id)),n=new Set(t.map(e=>e.id));let r=e.filter(e=>!n.has(e.id)).length>0;return r=r||t.filter(e=>!i.has(e.id)).length>0,r}_loadTiles(){for(const e of this._requestedTiles)e.contentUnloaded&&this._loadTile(e)}_unloadTiles(){this._cache.unloadTiles(this,(e,t)=>e._unloadTile(t))}_updateStats(){let e=0,t=0;for(const i of this.selectedTiles)i.contentAvailable&&i.content&&(e++,i.content.pointCount?t+=i.content.pointCount:t+=i.content.vertexCount);this.stats.get(Uz).count=this.selectedTiles.length,this.stats.get(Nz).count=e,this.stats.get(Qz).count=t,this.stats.get(Zz).count=this.memoryAdjustedScreenSpaceError}async _initializeTileSet(e){this.type===JO.I3S&&(this.calculateViewPropsI3S(),e.root=await e.root),this.root=this._initializeTileHeaders(e,null),this.type===JO.TILES3D&&(this._initializeTiles3DTileset(e),this.calculateViewPropsTiles3D()),this.type===JO.I3S&&this._initializeI3STileset()}calculateViewPropsI3S(){const e=this.tileset.fullExtent;if(e){const{xmin:t,xmax:i,ymin:n,ymax:r,zmin:o,zmax:s}=e;return this.cartographicCenter=new AA(t+(i-t)/2,n+(r-n)/2,o+(s-o)/2),this.cartesianCenter=new AA,PO.WGS84.cartographicToCartesian(this.cartographicCenter,this.cartesianCenter),void(this.zoom=HO(e,this.cartographicCenter,this.cartesianCenter))}const t=this.tileset.store?.extent;if(t){const[e,i,n,r]=t;return this.cartographicCenter=new AA(e+(n-e)/2,i+(r-i)/2,0),this.cartesianCenter=new AA,PO.WGS84.cartographicToCartesian(this.cartographicCenter,this.cartesianCenter),void(this.zoom=function(e,t,i){const[n,r,o,s]=e;return HO({xmin:n,xmax:o,ymin:r,ymax:s,zmin:0,zmax:0},t,i)}(t,this.cartographicCenter,this.cartesianCenter))}console.warn("Extent is not defined in the tileset header"),this.cartographicCenter=new AA,this.zoom=1}calculateViewPropsTiles3D(){const e=this.root,{center:t}=e.boundingVolume;if(!t)return console.warn("center was not pre-calculated for the root tile"),this.cartographicCenter=new AA,void(this.zoom=1);0!==t[0]||0!==t[1]||0!==t[2]?(this.cartographicCenter=new AA,PO.WGS84.cartesianToCartographic(t,this.cartographicCenter)):this.cartographicCenter=new AA(0,0,-PO.WGS84.radii[0]),this.cartesianCenter=t,this.zoom=GO(e.boundingVolume,this.cartographicCenter)}_initializeStats(){this.stats.get(Oz),this.stats.get(jz),this.stats.get(zz),this.stats.get(Uz),this.stats.get(Nz),this.stats.get(Vz),this.stats.get(Gz),this.stats.get(Hz),this.stats.get(Qz),this.stats.get($z,"memory"),this.stats.get(Zz)}_initializeTileHeaders(e,t){const i=new Bz(this,e.root,t);if(t&&(t.children.push(i),i.depth=t.depth+1),this.type===JO.TILES3D){const e=[];for(e.push(i);e.length>0;){const t=e.pop();this.stats.get(Oz).incrementCount();const i=t.header.children||[];for(const n of i){const i=new Bz(this,n,t);if(i.contentUrl?.includes("?session=")){const e=new URL(i.contentUrl).searchParams.get("session");e&&(this._queryParams.session=e)}t.children.push(i),i.depth=t.depth+1,e.push(i)}}}return i}_initializeTraverser(){let e;switch(this.type){case JO.TILES3D:e=Iz;break;case JO.I3S:e=kz;break;default:e=Cz}return new e({basePath:this.basePath,onTraversalEnd:this._onTraversalEnd.bind(this)})}_destroyTileHeaders(e){this._destroySubtree(e)}async _loadTile(e){let t;try{this._onStartTileLoading(),t=await e.loadContent()}catch(t){this._onTileLoadError(e,t instanceof Error?t:new Error("load failed"))}finally{this._onEndTileLoading(),this._onTileLoad(e,t)}}_onTileLoadError(e,t){this.stats.get(Hz).incrementCount();const i=t.message||t.toString(),n=e.url;console.error(`A 3D tile failed to load: ${e.url} ${i}`),this.options.onTileError(e,i,n)}_onTileLoad(e,t){if(t){if(this.type===JO.I3S){const e=this.tileset?.nodePagesTile?.nodesInNodePages||0;this.stats.get(Oz).reset(),this.stats.get(Oz).addCount(e)}e&&e.content&&function(e,t){Tu(e),Tu(t);const{rtcCenter:i,gltfUpAxis:n}=t,{computedTransform:r,boundingVolume:{center:o}}=e;let s=new HA(r);switch(i&&s.translate(i),n){case"Z":break;case"Y":const e=(new HA).rotateX(Math.PI/2);s=s.multiplyRight(e);break;case"X":const t=(new HA).rotateY(-Math.PI/2);s=s.multiplyRight(t)}t.isQuantized&&s.translate(t.quantizedVolumeOffset).scale(t.quantizedVolumeScale);const a=new AA(o);t.cartesianModelMatrix=s,t.cartesianOrigin=a;const l=PO.WGS84.cartesianToCartographic(a,new AA),c=PO.WGS84.eastNorthUpToFixedFrame(a).invert();t.cartographicModelMatrix=c.multiplyRight(s),t.cartographicOrigin=l,t.coordinateSystem||(t.modelMatrix=t.cartographicModelMatrix)}(e,e.content),this.updateContentTypes(e),this._addTileToCache(e),this.options.onTileLoad(e)}}updateContentTypes(e){if(this.type===JO.I3S)switch(e.header.isDracoGeometry&&(this.contentFormats.draco=!0),e.header.textureFormat){case"dds":this.contentFormats.dds=!0;break;case"ktx2":this.contentFormats.ktx2=!0}else if(this.type===JO.TILES3D){const{extensionsRemoved:t=[]}=e.content?.gltf||{};t.includes("KHR_draco_mesh_compression")&&(this.contentFormats.draco=!0),t.includes("EXT_meshopt_compression")&&(this.contentFormats.meshopt=!0),t.includes("KHR_texture_basisu")&&(this.contentFormats.ktx2=!0)}}_onStartTileLoading(){this._pendingCount++,this.stats.get(jz).incrementCount()}_onEndTileLoading(){this._pendingCount--,this.stats.get(jz).decrementCount()}_addTileToCache(e){this._cache.add(this,e,t=>t._updateCacheStats(e))}_updateCacheStats(e){this.stats.get(Vz).incrementCount(),this.stats.get(zz).incrementCount(),this.gpuMemoryUsageInBytes+=e.gpuMemoryUsageInBytes||0,this.stats.get($z).count=this.gpuMemoryUsageInBytes,this.options.memoryAdjustedScreenSpaceError&&this.adjustScreenSpaceError()}_unloadTile(e){this.gpuMemoryUsageInBytes-=e.gpuMemoryUsageInBytes||0,this.stats.get(zz).decrementCount(),this.stats.get(Gz).incrementCount(),this.stats.get($z).count=this.gpuMemoryUsageInBytes,this.options.onTileUnload(e),e.unloadContent()}_destroy(){const e=[];for(this.root&&e.push(this.root);e.length>0;){const t=e.pop();for(const i of t.children)e.push(i);this._destroyTile(t)}this.root=null}_destroySubtree(e){const t=e,i=[];for(i.push(t);i.length>0;){e=i.pop();for(const t of e.children)i.push(t);e!==t&&this._destroyTile(e)}t.children=[]}_destroyTile(e){this._cache.unloadTile(this,e),this._unloadTile(e),e.destroy()}_initializeTiles3DTileset(e){if(e.queryString){const t=new URLSearchParams(e.queryString),i=Object.fromEntries(t.entries());this._queryParams={...this._queryParams,...i}}if(this.asset=e.asset,!this.asset)throw new Error("Tileset must have an asset property.");if("0.0"!==this.asset.version&&"1.0"!==this.asset.version&&"1.1"!==this.asset.version)throw new Error("The tileset must be 3D Tiles version either 0.0 or 1.0 or 1.1.");"tilesetVersion"in this.asset&&(this._queryParams.v=this.asset.tilesetVersion),this.credits={attributions:this.options.attributions||[]},this.description=this.options.description||"",this.properties=e.properties,this.geometricError=e.geometricError,this._extensionsUsed=e.extensionsUsed||[],this.extras=e.extras}_initializeI3STileset(){this.loadOptions.i3s&&"token"in this.loadOptions.i3s&&(this._queryParams.token=this.loadOptions.i3s.token)}}const qz="4.3.3",Kz="cmpt",Xz="pnts",Jz="b3dm",Yz="i3dm",eU="glTF";function tU(e,t,i){Tu(e instanceof ArrayBuffer);const n=new TextDecoder("utf8"),r=new Uint8Array(e,t,i);return n.decode(r)}const iU="4.3.3",nU={dataType:null,batchType:null,name:"Draco",id:"draco",module:"draco",version:iU,worker:!0,extensions:["drc"],mimeTypes:["application/octet-stream"],binary:!0,tests:["DRACO"],options:{draco:{decoderType:"object"==typeof WebAssembly?"wasm":"js",libraryPath:"libs/",extraAttributes:{},attributeNameEntry:void 0}}};function rU(e,t,i){return Ld(e,t,i?oU(i.metadata):void 0)}function oU(e){const t={};for(const i in e)t[`${i}.string`]=JSON.stringify(e[i]);return t}const sU={POSITION:"POSITION",NORMAL:"NORMAL",COLOR:"COLOR_0",TEX_COORD:"TEXCOORD_0"},aU={1:Int8Array,2:Uint8Array,3:Int16Array,4:Uint16Array,5:Int32Array,6:Uint32Array,9:Float32Array};class lU{draco;decoder;metadataQuerier;constructor(e){this.draco=e,this.decoder=new this.draco.Decoder,this.metadataQuerier=new this.draco.MetadataQuerier}destroy(){this.draco.destroy(this.decoder),this.draco.destroy(this.metadataQuerier)}parseSync(e,t={}){const i=new this.draco.DecoderBuffer;i.Init(new Int8Array(e),e.byteLength),this._disableAttributeTransforms(t);const n=this.decoder.GetEncodedGeometryType(i),r=n===this.draco.TRIANGULAR_MESH?new this.draco.Mesh:new this.draco.PointCloud;try{let e;switch(n){case this.draco.TRIANGULAR_MESH:e=this.decoder.DecodeBufferToMesh(i,r);break;case this.draco.POINT_CLOUD:e=this.decoder.DecodeBufferToPointCloud(i,r);break;default:throw new Error("DRACO: Unknown geometry type.")}if(!e.ok()||!r.ptr){const t=`DRACO decompression failed: ${e.error_msg()}`;throw new Error(t)}const o=this._getDracoLoaderData(r,n,t),s=this._getMeshData(r,o,t),a=Rd(s.attributes),l=function(e,t,i){const n=oU(t.metadata),r=[],o=function(e){const t={};for(const i in e){const n=e[i];t[n.name||"undefined"]=n}return t}(t.attributes);for(const t in e){const i=rU(t,e[t],o[t]);r.push(i)}if(i){const e=rU("indices",i);r.push(e)}return{fields:r,metadata:n}}(s.attributes,o,s.indices);return{loader:"draco",loaderData:o,header:{vertexCount:r.num_points(),boundingBox:a},...s,schema:l}}finally{this.draco.destroy(i),r&&this.draco.destroy(r)}}_getDracoLoaderData(e,t,i){const n=this._getTopLevelMetadata(e),r=this._getDracoAttributes(e,i);return{geometry_type:t,num_attributes:e.num_attributes(),num_points:e.num_points(),num_faces:e instanceof this.draco.Mesh?e.num_faces():0,metadata:n,attributes:r}}_getDracoAttributes(e,t){const i={};for(let n=0;nthis.decoder[e]).includes(n);if(r){const t=new this.draco.AttributeQuantizationTransform;try{if(t.InitFromAttribute(e))return{quantization_bits:t.quantization_bits(),range:t.range(),min_values:new Float32Array([1,2,3]).map(e=>t.min_value(e))}}finally{this.draco.destroy(t)}}return null}_getOctahedronTransform(e,t){const{octahedronAttributes:i=[]}=t,n=e.attribute_type(),r=i.map(e=>this.decoder[e]).includes(n);if(r){const t=new this.draco.AttributeQuantizationTransform;try{if(t.InitFromAttribute(e))return{quantization_bits:t.quantization_bits()}}finally{this.draco.destroy(t)}}return null}}const cU=(globalThis._loadersgl_?.version||(globalThis._loadersgl_=globalThis._loadersgl_||{},globalThis._loadersgl_.version="4.3.3"),globalThis._loadersgl_.version);const uU="object"!=typeof process||"[object process]"!==String(process)||process.browser,hU="function"==typeof importScripts,dU="undefined"!=typeof process&&process.version&&/v([0-9]*)/.exec(process.version);dU&&parseFloat(dU[1]);const pU={};async function fU(e,t=null,i={},n=null){return t&&(e=function(e,t,i={},n=null){if(!i.useLocalLibraries&&e.startsWith("http"))return e;n=n||e;const r=i.modules||{};if(r[n])return r[n];if(!uU)return`modules/${t}/dist/libs/${n}`;if(i.CDN)return function(e,t){if(!e)throw new Error(t||"loaders.gl assertion failed.")}(i.CDN.startsWith("http")),`${i.CDN}/${t}@${cU}/dist/libs/${n}`;if(hU)return`../src/libs/${n}`;return`modules/${t}/src/libs/${n}`}(e,t,i,n)),pU[e]=pU[e]||async function(e){if(e.endsWith("wasm"))return await async function(e){const{readFileAsArrayBuffer:t}=globalThis.loaders||{};if(uU||!t||e.startsWith("http")){const t=await fetch(e);return await t.arrayBuffer()}return await t(e)}(e);if(!uU)try{const{requireFromFile:t}=globalThis.loaders||{};return await(t?.(e))}catch(e){return console.error(e),null}if(hU)return importScripts(e);const t=await async function(e){const{readFileAsText:t}=globalThis.loaders||{};if(uU||!t||e.startsWith("http")){const t=await fetch(e);return await t.text()}return await t(e)}(e);return function(e,t){if(!uU){const{requireFromString:i}=globalThis.loaders||{};return i?.(e,t)}if(hU)return eval.call(globalThis,e),null;const i=document.createElement("script");i.id=t;try{i.appendChild(document.createTextNode(e))}catch(t){i.text=e}return document.body.appendChild(i),null}(t,e)}(e),await pU[e]}const mU="https://www.gstatic.com/draco/versioned/decoders/1.5.6",gU="draco_wasm_wrapper.js",_U="draco_decoder.wasm",AU="draco_decoder.js",yU="draco_encoder.js",vU={[gU]:`${mU}/${gU}`,[_U]:`${mU}/${_U}`,[AU]:`${mU}/${AU}`,[yU]:`https://raw.githubusercontent.com/google/draco/1.4.1/javascript/${yU}`};let xU;async function bU(e){const t=e.modules||{};return t.draco3d?xU||=t.draco3d.createDecoderModule({}).then(e=>({draco:e})):xU||=async function(e){let t,i;if("js"===(e.draco&&e.draco.decoderType))t=await fU(vU[AU],"draco",e,AU);else[t,i]=await Promise.all([await fU(vU[gU],"draco",e,gU),await fU(vU[_U],"draco",e,_U)]);return t=t||globalThis.DracoDecoderModule,await function(e,t){const i={};t&&(i.wasmBinary=t);return new Promise(t=>{e({...i,onModuleLoaded:e=>t({draco:e})})})}(t,i)}(e),await xU}const wU={...nU,parse:async function(e,t){const{draco:i}=await bU(t),n=new lU(i);try{return n.parseSync(e,t?.draco)}finally{n.destroy()}}};const TU={BYTE:5120,UNSIGNED_BYTE:5121,SHORT:5122,UNSIGNED_SHORT:5123,INT:5124,UNSIGNED_INT:5125,FLOAT:5126,DOUBLE:5130},EU={POINTS:0,LINES:1,LINE_LOOP:2,LINE_STRIP:3,TRIANGLES:4,TRIANGLE_STRIP:5,TRIANGLE_FAN:6,...TU},CU={[TU.DOUBLE]:Float64Array,[TU.FLOAT]:Float32Array,[TU.UNSIGNED_SHORT]:Uint16Array,[TU.UNSIGNED_INT]:Uint32Array,[TU.UNSIGNED_BYTE]:Uint8Array,[TU.BYTE]:Int8Array,[TU.SHORT]:Int16Array,[TU.INT]:Int32Array},SU={DOUBLE:TU.DOUBLE,FLOAT:TU.FLOAT,UNSIGNED_SHORT:TU.UNSIGNED_SHORT,UNSIGNED_INT:TU.UNSIGNED_INT,UNSIGNED_BYTE:TU.UNSIGNED_BYTE,BYTE:TU.BYTE,SHORT:TU.SHORT,INT:TU.INT},BU="Failed to convert GL type";class IU{static fromTypedArray(e){e=ArrayBuffer.isView(e)?e.constructor:e;for(const t in CU){if(CU[t]===e)return t}throw new Error(BU)}static fromName(e){const t=SU[e];if(!t)throw new Error(BU);return t}static getArrayType(e){switch(e){case TU.UNSIGNED_SHORT_5_6_5:case TU.UNSIGNED_SHORT_4_4_4_4:case TU.UNSIGNED_SHORT_5_5_5_1:return Uint16Array;default:const t=CU[e];if(!t)throw new Error(BU);return t}}static getByteSize(e){return IU.getArrayType(e).BYTES_PER_ELEMENT}static validate(e){return Boolean(IU.getArrayType(e))}static createTypedArray(e,t,i=0,n){void 0===n&&(n=(t.byteLength-i)/IU.getByteSize(e));return new(IU.getArrayType(e))(t,i,n)}}function MU(e,t=[0,0,0]){const i=e>>11&31,n=e>>5&63,r=31&e;return t[0]=i<<3,t[1]=n<<2,t[2]=r<<3,t}function PU(e,t=255){return z_(e,0,t)/t*2-1}function RU(e){return e<0?-1:1}function LU(e,t,i,n){if(function(e,t){if(!e)throw new Error(`math.gl assertion failed. ${t}`)}(n),e<0||e>i||t<0||t>i)throw new Error(`x and y must be unsigned normalized integers between 0 and ${i}`);if(n.x=PU(e,i),n.y=PU(t,i),n.z=1-(Math.abs(n.x)+Math.abs(n.y)),n.z<0){const e=n.x;n.x=(1-Math.abs(n.y))*RU(e),n.y=(1-Math.abs(e))*RU(n.y)}return n.normalize()}function FU(e,t,i){return LU(e,t,255,i)}new nA,new AA,new nA,new nA;class kU{json;buffer;featuresLength=0;_cachedTypedArrays={};constructor(e,t){this.json=e,this.buffer=t}getExtension(e){return this.json.extensions&&this.json.extensions[e]}hasProperty(e){return Boolean(this.json[e])}getGlobalProperty(e,t=EU.UNSIGNED_INT,i=1){const n=this.json[e];return n&&Number.isFinite(n.byteOffset)?this._getTypedArrayFromBinary(e,t,i,1,n.byteOffset):n}getPropertyArray(e,t,i){const n=this.json[e];return n&&Number.isFinite(n.byteOffset)?("componentType"in n&&(t=IU.fromName(n.componentType)),this._getTypedArrayFromBinary(e,t,i,this.featuresLength,n.byteOffset)):this._getTypedArrayFromArray(e,t,n)}getProperty(e,t,i,n,r){const o=this.json[e];if(!o)return o;const s=this.getPropertyArray(e,t,i);if(1===i)return s[n];for(let e=0;ee[t],VEC2:(e,t)=>[e[2*t+0],e[2*t+1]],VEC3:(e,t)=>[e[3*t+0],e[3*t+1],e[3*t+2]],VEC4:(e,t)=>[e[4*t+0],e[4*t+1],e[4*t+2],e[4*t+3]],MAT2:(e,t)=>[e[4*t+0],e[4*t+1],e[4*t+2],e[4*t+3]],MAT3:(e,t)=>[e[9*t+0],e[9*t+1],e[9*t+2],e[9*t+3],e[9*t+4],e[9*t+5],e[9*t+6],e[9*t+7],e[9*t+8]],MAT4:(e,t)=>[e[16*t+0],e[16*t+1],e[16*t+2],e[16*t+3],e[16*t+4],e[16*t+5],e[16*t+6],e[16*t+7],e[16*t+8],e[16*t+9],e[16*t+10],e[16*t+11],e[16*t+12],e[16*t+13],e[16*t+14],e[16*t+15]]},zU={SCALAR:(e,t,i)=>{t[i]=e},VEC2:(e,t,i)=>{t[2*i+0]=e[0],t[2*i+1]=e[1]},VEC3:(e,t,i)=>{t[3*i+0]=e[0],t[3*i+1]=e[1],t[3*i+2]=e[2]},VEC4:(e,t,i)=>{t[4*i+0]=e[0],t[4*i+1]=e[1],t[4*i+2]=e[2],t[4*i+3]=e[3]},MAT2:(e,t,i)=>{t[4*i+0]=e[0],t[4*i+1]=e[1],t[4*i+2]=e[2],t[4*i+3]=e[3]},MAT3:(e,t,i)=>{t[9*i+0]=e[0],t[9*i+1]=e[1],t[9*i+2]=e[2],t[9*i+3]=e[3],t[9*i+4]=e[4],t[9*i+5]=e[5],t[9*i+6]=e[6],t[9*i+7]=e[7],t[9*i+8]=e[8],t[9*i+9]=e[9]},MAT4:(e,t,i)=>{t[16*i+0]=e[0],t[16*i+1]=e[1],t[16*i+2]=e[2],t[16*i+3]=e[3],t[16*i+4]=e[4],t[16*i+5]=e[5],t[16*i+6]=e[6],t[16*i+7]=e[7],t[16*i+8]=e[8],t[16*i+9]=e[9],t[16*i+10]=e[10],t[16*i+11]=e[11],t[16*i+12]=e[12],t[16*i+13]=e[13],t[16*i+14]=e[14],t[16*i+15]=e[15]}};const UU=e=>void 0!==e;function NU(e,t,i){if(!t)return null;let n=e.getExtension("3DTILES_batch_table_hierarchy");const r=t.HIERARCHY;return r&&(console.warn("3D Tile Parser: HIERARCHY is deprecated. Use 3DTILES_batch_table_hierarchy."),t.extensions=t.extensions||{},t.extensions["3DTILES_batch_table_hierarchy"]=r,n=r),n?function(e,t){let i,n,r;const o=e.instancesLength,s=e.classes;let a,l=e.classIds,c=e.parentCounts,u=e.parentIds,h=o;UU(l.byteOffset)&&(l.componentType=defaultValue(l.componentType,GL.UNSIGNED_SHORT),l.type=AttributeType.SCALAR,r=getBinaryAccessor(l),l=r.createArrayBufferView(t.buffer,t.byteOffset+l.byteOffset,o));if(UU(c))for(UU(c.byteOffset)&&(c.componentType=defaultValue(c.componentType,GL.UNSIGNED_SHORT),c.type=AttributeType.SCALAR,r=getBinaryAccessor(c),c=r.createArrayBufferView(t.buffer,t.byteOffset+c.byteOffset,o)),a=new Uint16Array(o),h=0,i=0;i0?function(e,t,i){const n=e.classIds,r=e.parentCounts,o=e.parentIds,s=e.parentIndexes,a=n.length,l=scratchVisited;l.length=Math.max(l.length,a);const c=++marker,u=scratchStack;u.length=0,u.push(t);for(;u.length>0;){if(l[t=u.pop()]===c)continue;l[t]=c;const n=i(e,t);if(UU(n))return n;const a=r[t],h=s[t];for(let e=0;ee,QU={HIERARCHY:!0,extensions:!0,extras:!0};class $U{json;binary;featureCount;_extensions;_properties;_binaryProperties;_hierarchy;constructor(e,t,i,n={}){Tu(i>=0),this.json=e||{},this.binary=t,this.featureCount=i,this._extensions=this.json?.extensions||{},this._properties={};for(const e in this.json)QU[e]||(this._properties[e]=this.json[e]);this._binaryProperties=this._initializeBinaryProperties(),n["3DTILES_batch_table_hierarchy"]&&(this._hierarchy=NU(this,this.json,this.binary))}getExtension(e){return this.json&&this.json.extensions&&this.json.extensions[e]}memorySizeInBytes(){return 0}isClass(e,t){if(this._checkBatchId(e),Tu("string"==typeof t,t),this._hierarchy){return GU(VU(this._hierarchy,e,(e,i)=>{const n=e.classIds[i];return e.classes[n].name===t}))}return!1}isExactClass(e,t){return Tu("string"==typeof t,t),this.getExactClassName(e)===t}getExactClassName(e){if(this._checkBatchId(e),this._hierarchy){const t=this._hierarchy.classIds[e];return this._hierarchy.classes[t].name}}hasProperty(e,t){return this._checkBatchId(e),Tu("string"==typeof t,t),GU(this._properties[t])||this._hasPropertyInHierarchy(e,t)}getPropertyNames(e,t){this._checkBatchId(e),(t=GU(t)?t:[]).length=0;const i=Object.keys(this._properties);return t.push(...i),this._hierarchy&&this._getPropertyNamesInHierarchy(e,t),t}getProperty(e,t){if(this._checkBatchId(e),Tu("string"==typeof t,t),this._binaryProperties){const i=this._binaryProperties[t];if(GU(i))return this._getBinaryProperty(i,e)}const i=this._properties[t];if(GU(i))return HU(i[e]);if(this._hierarchy){const i=this._getHierarchyProperty(e,t);if(GU(i))return i}}setProperty(e,t,i){const n=this.featureCount;if(this._checkBatchId(e),Tu("string"==typeof t,t),this._binaryProperties){const n=this._binaryProperties[t];if(n)return void this._setBinaryProperty(n,e,i)}if(this._hierarchy&&this._setHierarchyProperty(this,e,t,i))return;let r=this._properties[t];GU(r)||(this._properties[t]=new Array(n),r=this._properties[t]),r[e]=HU(i)}_checkBatchId(e){if(!(e>=0&&e{const n=e.classIds[i];return GU(e.classes[n].instances[t])});return GU(i)}_getPropertyNamesInHierarchy(e,t){VU(this._hierarchy,e,(e,i)=>{const n=e.classIds[i],r=e.classes[n].instances;for(const e in r)r.hasOwnProperty(e)&&-1===t.indexOf(e)&&t.push(e)})}_getHierarchyProperty(e,t){return VU(this._hierarchy,e,(e,i)=>{const n=e.classIds[i],r=e.classes[n],o=e.classIndexes[i],s=r.instances[t];return GU(s)?GU(s.typedArray)?this._getBinaryProperty(s,o):HU(s[o]):null})}_setHierarchyProperty(e,t,i,n){const r=VU(this._hierarchy,t,(e,r)=>{const o=e.classIds[r],s=e.classes[o],a=e.classIndexes[r],l=s.instances[i];return!!GU(l)&&(Tu(r===t,`Inherited property "${i}" is read-only.`),GU(l.typedArray)?this._setBinaryProperty(l,a,n):l[a]=HU(n),!0)});return GU(r)}}function ZU(e,t,i=0){const n=new DataView(t);if(e.magic=n.getUint32(i,!0),i+=4,e.version=n.getUint32(i,!0),i+=4,e.byteLength=n.getUint32(i,!0),i+=4,1!==e.version)throw new Error(`3D Tile Version ${e.version} not supported`);return i}const WU="b3dm tile in legacy format.";function qU(e,t,i){const n=new DataView(t);let r;e.header=e.header||{};let o=n.getUint32(i,!0);i+=4;let s=n.getUint32(i,!0);i+=4;let a=n.getUint32(i,!0);i+=4;let l=n.getUint32(i,!0);return i+=4,a>=570425344?(i-=8,r=o,a=s,l=0,o=0,s=0,console.warn(WU)):l>=570425344&&(i-=4,r=a,a=o,l=s,o=0,s=0,console.warn(WU)),e.header.featureTableJsonByteLength=o,e.header.featureTableBinaryByteLength=s,e.header.batchTableJsonByteLength=a,e.header.batchTableBinaryByteLength=l,e.header.batchLength=r,i}function KU(e,t,i,n){return i=function(e,t,i){const{featureTableJsonByteLength:n,featureTableBinaryByteLength:r,batchLength:o}=e.header||{};if(e.featureTableJson={BATCH_LENGTH:o||0},n&&n>0){const r=tU(t,i,n);e.featureTableJson=JSON.parse(r)}return i+=n||0,e.featureTableBinary=new Uint8Array(t,i,r),i+=r||0,i}(e,t,i),i=function(e,t,i){const{batchTableJsonByteLength:n,batchTableBinaryByteLength:r}=e.header||{};if(n&&n>0){const o=tU(t,i,n);e.batchTableJson=JSON.parse(o),i+=n,r&&r>0&&(e.batchTableBinary=new Uint8Array(t,i,r),e.batchTableBinary=new Uint8Array(e.batchTableBinary),i+=r)}return i}(e,t,i),i}function XU(e,t,i){if(!(t||e&&e.batchIds&&i))return null;const{batchIds:n,isRGB565:r,pointCount:o=0}=e;if(n&&i){const e=new Uint8ClampedArray(3*o);for(let t=0;t255*e);e[3*t]=o[0],e[3*t+1]=o[1],e[3*t+2]=o[2]}return{type:EU.UNSIGNED_BYTE,value:e,size:3,normalized:!0}}if(t&&r){const e=new Uint8ClampedArray(3*o);for(let i=0;i12;){const s={shape:"tile3d"};e.tiles.push(s),i=await o(t,i,n,r,s)}return i}(r,e,t,i,n,aN);case Jz:return await oN(r,e,t,i,n);case eU:return await async function(e,t,i,n){if(e.rotateYtoZ=!0,e.gltfUpAxis=i?.["3d-tiles"]?.assetGltfUpAxis?i["3d-tiles"].assetGltfUpAxis:"Y",i?.["3d-tiles"]?.loadGLTF){if(!n)return t.byteLength;const r=await wu(t,HD,i,n);e.gltf=nO(r),e.gpuMemoryUsageInBytes=BF(e.gltf)}else e.gltfArrayBuffer=t;return t.byteLength}(r,e,i,n);case Yz:return await sN(r,e,t,i,n);case Xz:return await eN(r,e,t,i,n);default:throw new Error(`3DTileLoader: unknown type ${r.type}`)}}async function lN(e,t,i,n){const r=Number.isFinite(t.bitstream)?t.bitstream:t.bufferView;if("number"!=typeof r)return;const o=e.bufferViews[r],s=e.buffers[o.buffer];if(!n?.baseUrl)throw new Error("Url is not provided");if(!n.fetch)throw new Error("fetch is not provided");if(s.uri){const e=`${n?.baseUrl||""}/${s.uri}`,i=await n.fetch(e),r=await i.arrayBuffer();return void(t.explicitBitstream=new Uint8Array(r,o.byteOffset,o.byteLength))}const a=e.buffers.slice(0,o.buffer).reduce((e,t)=>e+t.byteLength,0);t.explicitBitstream=new Uint8Array(i.slice(a,a+s.byteLength),o.byteOffset,o.byteLength)}function cN(e){const t=new DataView(e);return t.getUint32(0,!0)+2**32*t.getUint32(4,!0)}const uN={dataType:null,batchType:null,id:"3d-tiles-subtree",name:"3D Tiles Subtree",module:"3d-tiles",version:qz,extensions:["subtree"],mimeTypes:["application/octet-stream"],tests:["subtree"],parse:async function(e,t,i){if(1952609651!==new Uint32Array(e.slice(0,4))[0])throw new Error("Wrong subtree file magic number");if(1!==new Uint32Array(e.slice(4,8))[0])throw new Error("Wrong subtree file verson, must be 1");const n=cN(e.slice(8,16)),r=new Uint8Array(e,24,n),o=new TextDecoder("utf8").decode(r),s=JSON.parse(o),a=cN(e.slice(16,24));let l=new ArrayBuffer(0);if(a&&(l=e.slice(24+n)),await lN(s,s.tileAvailability,l,i),Array.isArray(s.contentAvailability))for(const e of s.contentAvailability)await lN(s,e,l,i);else await lN(s,s.contentAvailability,l,i);return await lN(s,s.childSubtreeAvailability,l,i),s},options:{}}; /** * @license * Copyright 2009 The Closure Library Authors @@ -30,7 +30,7 @@ function e(e,t){return t.forEach(function(t){t&&"string"!=typeof t&&!Array.isArr * limitations under the License. * * SPDX-License-Identifier: Apache-2.0 - */var DD=null;try{DD=new WebAssembly.Instance(new WebAssembly.Module(new Uint8Array([0,97,115,109,1,0,0,0,1,13,2,96,0,1,127,96,4,127,127,127,127,1,127,3,7,6,0,1,1,1,1,1,6,6,1,127,1,65,0,11,7,50,6,3,109,117,108,0,1,5,100,105,118,95,115,0,2,5,100,105,118,95,117,0,3,5,114,101,109,95,115,0,4,5,114,101,109,95,117,0,5,8,103,101,116,95,104,105,103,104,0,0,10,191,1,6,4,0,35,0,11,36,1,1,126,32,0,173,32,1,173,66,32,134,132,32,2,173,32,3,173,66,32,134,132,126,34,4,66,32,135,167,36,0,32,4,167,11,36,1,1,126,32,0,173,32,1,173,66,32,134,132,32,2,173,32,3,173,66,32,134,132,127,34,4,66,32,135,167,36,0,32,4,167,11,36,1,1,126,32,0,173,32,1,173,66,32,134,132,32,2,173,32,3,173,66,32,134,132,128,34,4,66,32,135,167,36,0,32,4,167,11,36,1,1,126,32,0,173,32,1,173,66,32,134,132,32,2,173,32,3,173,66,32,134,132,129,34,4,66,32,135,167,36,0,32,4,167,11,36,1,1,126,32,0,173,32,1,173,66,32,134,132,32,2,173,32,3,173,66,32,134,132,130,34,4,66,32,135,167,36,0,32,4,167,11])),{}).exports}catch{}function OD(e,t,i){this.low=0|e,this.high=0|t,this.unsigned=!!i}function zD(e){return!0===(e&&e.__isLong__)}function UD(e){var t=Math.clz32(e&-e);return e?31-t:t}OD.prototype.__isLong__,Object.defineProperty(OD.prototype,"__isLong__",{value:!0}),OD.isLong=zD;var ND={},VD={};function jD(e,t){var i,r,n;return t?(n=0<=(e>>>=0)&&e<256)&&(r=VD[e])?r:(i=HD(e,0,!0),n&&(VD[e]=i),i):(n=-128<=(e|=0)&&e<128)&&(r=ND[e])?r:(i=HD(e,e<0?-1:0,!1),n&&(ND[e]=i),i)}function GD(e,t){if(isNaN(e))return t?YD:JD;if(t){if(e<0)return YD;if(e>=qD)return nO}else{if(e<=-KD)return oO;if(e+1>=KD)return rO}return e<0?GD(-e,t).neg():HD(e%WD|0,e/WD|0,t)}function HD(e,t,i){return new OD(e,t,i)}OD.fromInt=jD,OD.fromNumber=GD,OD.fromBits=HD;var QD=Math.pow;function $D(e,t,i){if(0===e.length)throw Error("empty string");if("number"==typeof t?(i=t,t=!1):t=!!t,"NaN"===e||"Infinity"===e||"+Infinity"===e||"-Infinity"===e)return t?YD:JD;if((i=i||10)<2||360)throw Error("interior hyphen");if(0===r)return $D(e.substring(1),t,i).neg();for(var n=GD(QD(i,8)),o=JD,s=0;s>>0:this.low},sO.toNumber=function(){return this.unsigned?(this.high>>>0)*WD+(this.low>>>0):this.high*WD+(this.low>>>0)},sO.toString=function(e){if((e=e||10)<2||36>>0).toString(e);if((o=a).isZero())return l+s;for(;l.length<6;)l="0"+l;s=""+l+s}},sO.getHighBits=function(){return this.high},sO.getHighBitsUnsigned=function(){return this.high>>>0},sO.getLowBits=function(){return this.low},sO.getLowBitsUnsigned=function(){return this.low>>>0},sO.getNumBitsAbs=function(){if(this.isNegative())return this.eq(oO)?64:this.neg().getNumBitsAbs();for(var e=0!=this.high?this.high:this.low,t=31;t>0&&!(e&1<>21;return!e||!this.unsigned&&(-1===e&&!(0===this.low&&-2097152===this.high))},sO.isZero=function(){return 0===this.high&&0===this.low},sO.eqz=sO.isZero,sO.isNegative=function(){return!this.unsigned&&this.high<0},sO.isPositive=function(){return this.unsigned||this.high>=0},sO.isOdd=function(){return!(1&~this.low)},sO.isEven=function(){return!(1&this.low)},sO.equals=function(e){return zD(e)||(e=ZD(e)),(this.unsigned===e.unsigned||this.high>>>31!=1||e.high>>>31!=1)&&(this.high===e.high&&this.low===e.low)},sO.eq=sO.equals,sO.notEquals=function(e){return!this.eq(e)},sO.neq=sO.notEquals,sO.ne=sO.notEquals,sO.lessThan=function(e){return this.comp(e)<0},sO.lt=sO.lessThan,sO.lessThanOrEqual=function(e){return this.comp(e)<=0},sO.lte=sO.lessThanOrEqual,sO.le=sO.lessThanOrEqual,sO.greaterThan=function(e){return this.comp(e)>0},sO.gt=sO.greaterThan,sO.greaterThanOrEqual=function(e){return this.comp(e)>=0},sO.gte=sO.greaterThanOrEqual,sO.ge=sO.greaterThanOrEqual,sO.compare=function(e){if(zD(e)||(e=ZD(e)),this.eq(e))return 0;var t=this.isNegative(),i=e.isNegative();return t&&!i?-1:!t&&i?1:this.unsigned?e.high>>>0>this.high>>>0||e.high===this.high&&e.low>>>0>this.low>>>0?-1:1:this.sub(e).isNegative()?-1:1},sO.comp=sO.compare,sO.negate=function(){return!this.unsigned&&this.eq(oO)?oO:this.not().add(eO)},sO.neg=sO.negate,sO.add=function(e){zD(e)||(e=ZD(e));var t=this.high>>>16,i=65535&this.high,r=this.low>>>16,n=65535&this.low,o=e.high>>>16,s=65535&e.high,a=e.low>>>16,l=0,c=0,u=0,h=0;return u+=(h+=n+(65535&e.low))>>>16,c+=(u+=r+a)>>>16,l+=(c+=i+s)>>>16,l+=t+o,HD((u&=65535)<<16|(h&=65535),(l&=65535)<<16|(c&=65535),this.unsigned)},sO.subtract=function(e){return zD(e)||(e=ZD(e)),this.add(e.neg())},sO.sub=sO.subtract,sO.multiply=function(e){if(this.isZero())return this;if(zD(e)||(e=ZD(e)),DD)return HD(DD.mul(this.low,this.high,e.low,e.high),DD.get_high(),this.unsigned);if(e.isZero())return this.unsigned?YD:JD;if(this.eq(oO))return e.isOdd()?oO:JD;if(e.eq(oO))return this.isOdd()?oO:JD;if(this.isNegative())return e.isNegative()?this.neg().mul(e.neg()):this.neg().mul(e).neg();if(e.isNegative())return this.mul(e.neg()).neg();if(this.lt(XD)&&e.lt(XD))return GD(this.toNumber()*e.toNumber(),this.unsigned);var t=this.high>>>16,i=65535&this.high,r=this.low>>>16,n=65535&this.low,o=e.high>>>16,s=65535&e.high,a=e.low>>>16,l=65535&e.low,c=0,u=0,h=0,d=0;return h+=(d+=n*l)>>>16,u+=(h+=r*l)>>>16,h&=65535,u+=(h+=n*a)>>>16,c+=(u+=i*l)>>>16,u&=65535,c+=(u+=r*a)>>>16,u&=65535,c+=(u+=n*s)>>>16,c+=t*l+i*a+r*s+n*o,HD((h&=65535)<<16|(d&=65535),(c&=65535)<<16|(u&=65535),this.unsigned)},sO.mul=sO.multiply,sO.divide=function(e){if(zD(e)||(e=ZD(e)),e.isZero())throw Error("division by zero");var t,i,r;if(DD)return this.unsigned||-2147483648!==this.high||-1!==e.low||-1!==e.high?HD((this.unsigned?DD.div_u:DD.div_s)(this.low,this.high,e.low,e.high),DD.get_high(),this.unsigned):this;if(this.isZero())return this.unsigned?YD:JD;if(this.unsigned){if(e.unsigned||(e=e.toUnsigned()),e.gt(this))return YD;if(e.gt(this.shru(1)))return tO;r=YD}else{if(this.eq(oO))return e.eq(eO)||e.eq(iO)?oO:e.eq(oO)?eO:(t=this.shr(1).div(e).shl(1)).eq(JD)?e.isNegative()?eO:iO:(i=this.sub(e.mul(t)),r=t.add(i.div(e)));if(e.eq(oO))return this.unsigned?YD:JD;if(this.isNegative())return e.isNegative()?this.neg().div(e.neg()):this.neg().div(e).neg();if(e.isNegative())return this.div(e.neg()).neg();r=JD}for(i=this;i.gte(e);){t=Math.max(1,Math.floor(i.toNumber()/e.toNumber()));for(var n=Math.ceil(Math.log(t)/Math.LN2),o=n<=48?1:QD(2,n-48),s=GD(t),a=s.mul(e);a.isNegative()||a.gt(i);)a=(s=GD(t-=o,this.unsigned)).mul(e);s.isZero()&&(s=eO),r=r.add(s),i=i.sub(a)}return r},sO.div=sO.divide,sO.modulo=function(e){return zD(e)||(e=ZD(e)),DD?HD((this.unsigned?DD.rem_u:DD.rem_s)(this.low,this.high,e.low,e.high),DD.get_high(),this.unsigned):this.sub(this.div(e).mul(e))},sO.mod=sO.modulo,sO.rem=sO.modulo,sO.not=function(){return HD(~this.low,~this.high,this.unsigned)},sO.countLeadingZeros=function(){return this.high?Math.clz32(this.high):Math.clz32(this.low)+32},sO.clz=sO.countLeadingZeros,sO.countTrailingZeros=function(){return this.low?UD(this.low):UD(this.high)+32},sO.ctz=sO.countTrailingZeros,sO.and=function(e){return zD(e)||(e=ZD(e)),HD(this.low&e.low,this.high&e.high,this.unsigned)},sO.or=function(e){return zD(e)||(e=ZD(e)),HD(this.low|e.low,this.high|e.high,this.unsigned)},sO.xor=function(e){return zD(e)||(e=ZD(e)),HD(this.low^e.low,this.high^e.high,this.unsigned)},sO.shiftLeft=function(e){return zD(e)&&(e=e.toInt()),0==(e&=63)?this:e<32?HD(this.low<>>32-e,this.unsigned):HD(0,this.low<>>e|this.high<<32-e,this.high>>e,this.unsigned):HD(this.high>>e-32,this.high>=0?0:-1,this.unsigned)},sO.shr=sO.shiftRight,sO.shiftRightUnsigned=function(e){return zD(e)&&(e=e.toInt()),0==(e&=63)?this:e<32?HD(this.low>>>e|this.high<<32-e,this.high>>>e,this.unsigned):HD(32===e?this.high:this.high>>>e-32,0,this.unsigned)},sO.shru=sO.shiftRightUnsigned,sO.shr_u=sO.shiftRightUnsigned,sO.rotateLeft=function(e){var t;return zD(e)&&(e=e.toInt()),0==(e&=63)?this:32===e?HD(this.high,this.low,this.unsigned):e<32?(t=32-e,HD(this.low<>>t,this.high<>>t,this.unsigned)):(t=32-(e-=32),HD(this.high<>>t,this.low<>>t,this.unsigned))},sO.rotl=sO.rotateLeft,sO.rotateRight=function(e){var t;return zD(e)&&(e=e.toInt()),0==(e&=63)?this:32===e?HD(this.high,this.low,this.unsigned):e<32?(t=32-e,HD(this.high<>>e,this.low<>>e,this.unsigned)):(t=32-(e-=32),HD(this.low<>>e,this.high<>>e,this.unsigned))},sO.rotr=sO.rotateRight,sO.toSigned=function(){return this.unsigned?HD(this.low,this.high,!1):this},sO.toUnsigned=function(){return this.unsigned?this:HD(this.low,this.high,!0)},sO.toBytes=function(e){return e?this.toBytesLE():this.toBytesBE()},sO.toBytesLE=function(){var e=this.high,t=this.low;return[255&t,t>>>8&255,t>>>16&255,t>>>24,255&e,e>>>8&255,e>>>16&255,e>>>24]},sO.toBytesBE=function(){var e=this.high,t=this.low;return[e>>>24,e>>>16&255,e>>>8&255,255&e,t>>>24,t>>>16&255,t>>>8&255,255&t]},OD.fromBytes=function(e,t,i){return i?OD.fromBytesLE(e,t):OD.fromBytesBE(e,t)},OD.fromBytesLE=function(e,t){return new OD(e[0]|e[1]<<8|e[2]<<16|e[3]<<24,e[4]|e[5]<<8|e[6]<<16|e[7]<<24,t)},OD.fromBytesBE=function(e,t){return new OD(e[4]<<24|e[5]<<16|e[6]<<8|e[7],e[0]<<24|e[1]<<16|e[2]<<8|e[3],t)},"function"==typeof BigInt&&(OD.fromBigInt=function(e,t){return HD(Number(BigInt.asIntN(32,e)),Number(BigInt.asIntN(32,e>>BigInt(32))),t)},OD.fromValue=function(e,t){return"bigint"==typeof e?OD.fromBigInt(e,t):ZD(e,t)},sO.toBigInt=function(){var e=BigInt(this.low>>>0);return BigInt(this.unsigned?this.high>>>0:this.high)<=.5?1/3*(4*e*e-1):1/3*(1-4*(1-e)*(1-e))}function hO(e){return[uO(e[0]),uO(e[1])]}function dO(e,[t,i]){switch(e){case 0:return[1,t,i];case 1:return[-t,1,i];case 2:return[-t,-i,1];case 3:return[-1,-i,-t];case 4:return[i,-1,-t];case 5:return[i,t,-1];default:throw new Error("Invalid face")}}function pO([e,t,i]){const r=Math.atan2(i,Math.sqrt(e*e+t*t));return[Math.atan2(t,e)*lO,r*lO]}function fO(e,t,i,r){if(0===r){1===i&&(t[0]=e-1-t[0],t[1]=e-1-t[1]);const r=t[0];t[0]=t[1],t[1]=r}}function mO(e){const{face:t,ij:i,level:r}=e,n=[[0,0],[0,1],[1,1],[1,0],[0,0]],o=Math.max(1,Math.ceil(100*Math.pow(2,-r))),s=new Float64Array(4*o*2+2);let a=0,l=0;for(let e=0;e<4;e++){const c=n[e].slice(0),u=n[e+1],h=(u[0]-c[0])/o,d=(u[1]-c[1])/o;for(let e=0;e89.999&&(e[0]=l);const n=e[0]-l;e[0]+=n>180?-360:n<-180?360:0,s[a++]=e[0],s[a++]=e[1],l=e[0]}}return s[a++]=s[0],s[a++]=s[1],s}function gO(e){const t=function(e){if(e.indexOf("/")>0)return e;const t=aO(e);return function(e){if(e.isZero())return"";let t=e.toString(2);for(;t.length<64;)t="0"+t;const i=t.lastIndexOf("1"),r=t.substring(0,3),n=t.substring(3,i),o=n.length/2,s=OD.fromString(r,!0,2).toString(10);let a="";if(0!==o)for(a=OD.fromString(n,!0,2).toString(4);a.length=0;e--){o=n-e;const t=r[e];let i=0,a=0;"1"===t?a=1:"2"===t?(i=1,a=1):"3"===t&&(i=1);const l=Math.pow(2,o-1);fO(l,s,i,a),s[0]+=l*i,s[1]+=l*a}if(i%2==1){const e=s[0];s[0]=s[1],s[1]=e}return{face:i,ij:s,level:o}}(t);return i}function _O(e){return function(e){const t=hO(cO(e.ij,e.level,[.5,.5]));return pO(dO(e.face,t))}(gO(e))}function AO(e){if(e.length%2!=0)throw new Error("Invalid corners");const t=[],i=[];for(let r=0;re-t),i.sort((e,t)=>e-t),{west:t[0],east:t[t.length-1],north:i[i.length-1],south:i[0]}}function yO(e,t){const i=t?.minimumHeight||0,r=t?.maximumHeight||0,n=function(e){let t;if(2===e.face||5===e.face){let i=null,r=0;for(let t=0;t<4;t++){const n=mO(gO(`${e.face}/${t}`));null==i&&(i=new Float64Array(4*n.length)),i.set(n,r),r+=n.length}t=AO(i)}else t=AO(mO(e));return t}(gO(e)),o=n.west,s=n.south,a=n.east,l=n.north,c=[];return c.push(new mA(o,l,i)),c.push(new mA(a,l,i)),c.push(new mA(a,s,i)),c.push(new mA(o,s,i)),c.push(new mA(o,l,r)),c.push(new mA(a,l,r)),c.push(new mA(a,s,r)),c.push(new mA(o,s,r)),c}function vO(e){const t=e.token,i={minimumHeight:e.minimumHeight,maximumHeight:e.maximumHeight},r=yO(t,i),n=_O(t),o=n[0],s=n[1],a=iF.WGS84.cartographicToCartesian([o,s,i.maximumHeight]),l=new mA(a[0],a[1],a[2]);r.push(l);const c=NI(r);return[...c.center,...c.halfAxes]}const xO={QUADTREE:4,OCTREE:8};function bO(e,t,i){if(e?.box){const r=function(e,t){const i=function(e){return e.and(e.not().add(1))}(e).shiftRightUnsigned(2);return e.add(OD.fromNumber(2*t+1-4).multiply(i))}(aO(e.s2VolumeInfo.token),t),n=function(e){if(e.isZero())return"X";let t=e.countTrailingZeros();t=(t-t%4)/4;const i=t;t*=4;const r=e.shiftRightUnsigned(t).toString(16).replace(/0+$/,"");return Array(17-i-r.length).join("0")+r}(r),o={...e.s2VolumeInfo};if(o.token=n,"OCTREE"===i){const t=e.s2VolumeInfo,i=t.maximumHeight-t.minimumHeight,r=i/2,n=t.minimumHeight+i/2;t.minimumHeight=n-r,t.maximumHeight=n+r}return{box:vO(o),s2VolumeInfo:o}}}async function wO(e){const{subtree:t,subtreeData:i={level:0,x:0,y:0,z:0},parentData:r={mortonIndex:0,localLevel:-1,localX:0,localY:0,localZ:0},childIndex:n=0,implicitOptions:o,loaderOptions:s,s2VolumeBox:a}=e,{subdivisionScheme:l,subtreeLevels:c,maximumLevel:u,contentUrlTemplate:h,subtreesUriTemplate:d,basePath:p}=o,f={children:[],lodMetricValue:0,contentUrl:""};if(!u)return Zu.once(`Missing 'maximumLevel' or 'availableLevels' property. The subtree ${h} won't be loaded...`),f;const m=r.localLevel+1,g=i.level+m;if(g>u)return f;const _=xO[l],A=Math.log2(_),y=1&n,v=n>>1&1,x=n>>2&1,b=EO(r.localX,y,1),w=EO(r.localY,v,1),T=EO(r.localZ,x,1),E=EO(i.x,b,m),C=EO(i.y,w,m),B=EO(i.z,T,m),S=EO(r.mortonIndex,n,A);let I,M,P,R;if(m===c&&TO(t.childSubtreeAvailability,S)){const e=CO(`${p}/${d}`,g,E,C,B);I=await VS(e,kD,s),R=0,M={level:g,x:E,y:C,z:B},P={mortonIndex:0,localLevel:0,localX:0,localY:0,localZ:0}}else{I=t;R=(_**m-1)/(_-1)+S,M=i,P={mortonIndex:S,localLevel:m,localX:b,localY:w,localZ:T}}if(!TO(I.tileAvailability,R))return f;TO(I.contentAvailability,R)&&(f.contentUrl=CO(h,g,E,C,B));for(let e=0;e<_;e++){const t=bO(a,e,l),i=await wO({subtree:I,subtreeData:M,parentData:P,childIndex:e,implicitOptions:o,loaderOptions:s,s2VolumeBox:t});(i.contentUrl||i.children.length)&&f.children.push(i)}if(f.contentUrl||f.children.length){const e=function(e,t,i,r){const{basePath:n,refine:o,getRefine:s,lodMetricType:a,getTileType:l,rootLodMetricValue:c,rootBoundingVolume:u}=i,h=e.contentUrl&&e.contentUrl.replace(`${n}/`,""),d=c/2**t.level,p=r?.box?{box:r.box}:u,f=function(e,t,i){if(e.region){const{level:r,x:n,y:o,z:s}=t,[a,l,c,u,h,d]=e.region,p=2**r,f=(c-a)/p,[m,g]=[a+f*n,a+f*(n+1)],_=(u-l)/p,[A,y]=[l+_*o,l+_*(o+1)];let v,x;if("OCTREE"===i){const e=(d-h)/p;[v,x]=[h+e*s,h+e*(s+1)]}else[v,x]=[h,d];return{region:[m,A,g,y,v,x]}}if(e.box)return e;throw new Error(`Unsupported bounding volume type ${JSON.stringify(e)}`)}(p,t,i.subdivisionScheme);return{children:e.children,contentUrl:e.contentUrl,content:{uri:h},id:e.contentUrl,refine:s(o),type:l(e),lodMetricType:a,lodMetricValue:d,geometricError:d,transform:e.transform,boundingVolume:f}}(f,{level:g,x:E,y:C,z:B},o,a);return e}return f}function TO(e,t){let i;return Array.isArray(e)?(i=e[0],e.length>1&&Zu.once('Not supported extension "3DTILES_multiple_contents" has been detected')):i=e,"constant"in i?Boolean(i.constant):!!i.explicitBitstream&&function(e,t){const i=Math.floor(e/8),r=e%8;return 1==(t[i]>>r&1)}(t,i.explicitBitstream)}function EO(e,t,i){return(e<o[e])}function BO(e,t=""){if(!t)return bF.EMPTY;const i=t.split("?")[0].split(".").pop();switch(i){case"pnts":return bF.POINTCLOUD;case"i3dm":case"b3dm":case"glb":case"gltf":return bF.SCENEGRAPH;default:return i||bF.EMPTY}}function SO(e){switch(e){case"REPLACE":case"replace":return xF.REPLACE;case"ADD":case"add":return xF.ADD;default:return e}}function IO(e,t){if(/^[a-z][0-9a-z+.-]*:/i.test(t)){const i=new URL(e,`${t}/`);return decodeURI(i.toString())}return e.startsWith("/")?e:Lh(t,e)}function MO(e,t){if(!e)return null;let i;if(e.content){const r=e.content.uri||e.content?.url;void 0!==r&&(i=IO(r,t))}return{...e,id:i,contentUrl:i,lodMetricType:TF.GEOMETRIC_ERROR,lodMetricValue:e.geometricError,transformMatrix:e.transform,type:BO(0,i),refine:SO(e.refine)}}async function PO(e,t,i,r,n){const{subdivisionScheme:o,maximumLevel:s,availableLevels:a,subtreeLevels:l,subtrees:{uri:c}}=r,u=IO(CO(c,0,0,0,0),i),h=await VS(u,kD,n),d=e.content?.uri,p=d?IO(d,i):"",f=t?.root?.refine,m=e.geometricError,g=e.boundingVolume.extensions?.["3DTILES_bounding_volume_S2"];if(g){const t={box:vO(g),s2VolumeInfo:g};e.boundingVolume=t}const _=e.boundingVolume,A={contentUrlTemplate:p,subtreesUriTemplate:c,subdivisionScheme:o,subtreeLevels:l,maximumLevel:Number.isFinite(a)?a-1:s,refine:f,basePath:i,lodMetricType:TF.GEOMETRIC_ERROR,rootLodMetricValue:m,rootBoundingVolume:_,getTileType:BO,getRefine:SO};return await async function(e,t,i,r,n){if(!e)return null;const{children:o,contentUrl:s}=await wO({subtree:i,implicitOptions:r,loaderOptions:n});let a,l=null;s&&(a=s,l={uri:s.replace(`${t}/`,"")});const c={...e,id:a,contentUrl:a,lodMetricType:TF.GEOMETRIC_ERROR,lodMetricValue:e.geometricError,transformMatrix:e.transform,type:BO(0,a),refine:SO(e.refine),content:l||e.content,children:o};return c}(e,i,h,A,n)}function RO(e){return e?.extensions?.["3DTILES_implicit_tiling"]||e?.implicitTiling}const LO={dataType:null,batchType:null,id:"3d-tiles",name:"3D Tiles",module:"3d-tiles",version:vk,extensions:["cmpt","pnts","b3dm","i3dm"],mimeTypes:["application/octet-stream"],tests:["cmpt","pnts","b3dm","i3dm"],parse:async function(e,t={},i){const r=t["3d-tiles"]||{};let n;n="auto"===r.isTileset?i?.url&&-1!==i.url.indexOf(".json"):r.isTileset;return n?async function(e,t,i){const r=JSON.parse((new TextDecoder).decode(e)),n=i?.url||"",o=function(e){return Rh(e)}(n),s=await async function(e,t,i){let r=null;const n=RO(e.root);r=n&&e.root?await PO(e.root,e,t,n,i):MO(e.root,t);const o=[];for(o.push(r);o.length>0;){const r=o.pop()||{},n=r.children||[],s=[];for(const r of n){const n=RO(r);let a;a=n?await PO(r,e,t,n,i):MO(r,t),a&&(s.push(a),o.push(a))}r.children=s}return r}(r,o,t||{}),a={...r,shape:"tileset3d",loader:LO,url:n,queryString:i?.queryString||"",basePath:o,root:s||r.root,type:wF.TILES3D,lodMetricType:TF.GEOMETRIC_ERROR,lodMetricValue:r.root?.geometricError||0};return a}(e,t,i):async function(e,t,i){const r={content:{shape:"tile3d",featureIds:null}},n=0;return await RD(e,n,t,i,r.content),r.content}(e,t,i)},options:{"3d-tiles":{loadGLTF:!0,decodeQuantizedPositions:!1,isTileset:"auto",assetGltfUpAxis:null}}};const FO=[0],kO={getPointColor:{type:"accessor",value:[0,0,0,255]},pointSize:1,data:"",loader:LO,onTilesetLoad:{type:"function",value:e=>{}},onTileLoad:{type:"function",value:e=>{}},onTileUnload:{type:"function",value:e=>{}},onTileError:{type:"function",value:(e,t,i)=>{}},_getMeshColor:{type:"function",value:e=>[255,255,255]}};class DO extends tB{initializeState(){"onTileLoadFail"in this.props&&rp.removed("onTileLoadFail","onTileError")(),this.state={layerMap:{},tileset3d:null,activeViewports:{},lastUpdatedViewports:null}}get isLoaded(){return Boolean(this.state?.tileset3d?.isLoaded()&&super.isLoaded)}shouldUpdateState({changeFlags:e}){return e.somethingChanged}updateState({props:e,oldProps:t,changeFlags:i}){if(e.data&&e.data!==t.data&&this._loadTileset(e.data),i.viewportChanged){const{activeViewports:e}=this.state;Object.keys(e).length&&(this._updateTileset(e),this.state.lastUpdatedViewports=e,this.state.activeViewports={})}if(i.propsChanged){const{layerMap:e}=this.state;for(const t in e)e[t].needsUpdate=!0}}activateViewport(e){const{activeViewports:t,lastUpdatedViewports:i}=this.state;this.internalState.viewport=e,t[e.id]=e;const r=i?.[e.id];r&&e.equals(r)||(this.setChangeFlags({viewportChanged:!0}),this.setNeedsUpdate())}getPickingInfo({info:e,sourceLayer:t}){const i=t&&t.props.tile;return e.picked&&(e.object=i),e.sourceTile=i,e}filterSubLayer({layer:e,viewport:t}){const{tile:i}=e.props,{id:r}=t;return i.selected&&i.viewportIds.includes(r)}_updateAutoHighlight(e){const t=e.sourceTile,i=this.state.layerMap[t?.id];i&&i.layer&&i.layer.updateAutoHighlight(e)}async _loadTileset(e){const{loadOptions:t={}}=this.props,i=this.props.loader||this.props.loaders,r=Array.isArray(i)?i[0]:i,n={loadOptions:{...t}};let o=e;if(r.preload){const i=await r.preload(e,t);i.url&&(o=i.url),i.headers&&(n.loadOptions.fetch={...n.loadOptions.fetch,headers:i.headers}),Object.assign(n,i)}const s=await VS(o,r,n.loadOptions),a=new yk(s,{onTileLoad:this._onTileLoad.bind(this),onTileUnload:this._onTileUnload.bind(this),onTileError:this.props.onTileError,...n});this.setState({tileset3d:a,layerMap:{}}),this._updateTileset(this.state.activeViewports),this.props.onTilesetLoad(a)}_onTileLoad(e){const{lastUpdatedViewports:t}=this.state;this.props.onTileLoad(e),this._updateTileset(t),this.setNeedsUpdate()}_onTileUnload(e){delete this.state.layerMap[e.id],this.props.onTileUnload(e)}_updateTileset(e){if(!e)return;const{tileset3d:t}=this.state,{timeline:i}=this.context,r=Object.keys(e).length;i&&r&&t&&t.selectTiles(Object.values(e)).then(e=>{this.state.frameNumber!==e&&this.setState({frameNumber:e})})}_getSubLayer(e,t){if(!e.content)return null;switch(e.type){case bF.POINTCLOUD:return this._makePointCloudLayer(e,t);case bF.SCENEGRAPH:return this._make3DModelLayer(e);case bF.MESH:return this._makeSimpleMeshLayer(e,t);default:throw new Error(`Tile3DLayer: Failed to render layer of type ${e.content.type}`)}}_makePointCloudLayer(e,t){const{attributes:i,pointCount:r,constantRGBA:n,cartographicOrigin:o,modelMatrix:s}=e.content,{positions:a,normals:l,colors:c}=i;if(!a)return null;const u=t&&t.props.data||{header:{vertexCount:r},attributes:{POSITION:a,NORMAL:l,COLOR_0:c}},{pointSize:h,getPointColor:d}=this.props;return new(this.getSubLayerClass("pointcloud",$S))({pointSize:h},this.getSubLayerProps({id:"pointcloud"}),{id:`${this.id}-pointcloud-${e.id}`,tile:e,data:u,coordinateSystem:Ay.METER_OFFSETS,coordinateOrigin:o,modelMatrix:s,getColor:n||d,_offset:0})}_make3DModelLayer(e){const{gltf:t,instances:i,cartographicOrigin:r,modelMatrix:n}=e.content;return new(this.getSubLayerClass("scenegraph",RL))({_lighting:"pbr"},this.getSubLayerProps({id:"scenegraph"}),{id:`${this.id}-scenegraph-${e.id}`,tile:e,data:i||FO,scenegraph:t,coordinateSystem:Ay.METER_OFFSETS,coordinateOrigin:r,modelMatrix:n,getTransformMatrix:e=>e.modelMatrix,getPosition:[0,0,0],_offset:0})}_makeSimpleMeshLayer(e,t){const i=e.content,{attributes:r,indices:n,modelMatrix:o,cartographicOrigin:s,coordinateSystem:a=Ay.METER_OFFSETS,material:l,featureIds:c}=i,{_getMeshColor:u}=this.props,h=t&&t.props.mesh||new mx({topology:"triangle-list",attributes:zO(r),indices:n});return new(this.getSubLayerClass("mesh",FL))(this.getSubLayerProps({id:"mesh"}),{id:`${this.id}-mesh-${e.id}`,tile:e,mesh:h,data:FO,getColor:u(e),pbrMaterial:l,modelMatrix:o,coordinateOrigin:s,coordinateSystem:a,featureIds:c,_offset:0})}renderLayers(){const{tileset3d:e,layerMap:t}=this.state;return e?e.tiles.map(e=>{const i=t[e.id]=t[e.id]||{tile:e};let{layer:r}=i;return e.selected&&(r?i.needsUpdate&&(r=this._getSubLayer(e,r),i.needsUpdate=!1):r=this._getSubLayer(e)),i.layer=r,r}).filter(Boolean):null}}DO.defaultProps=kO,DO.layerName="Tile3DLayer";var OO=DO;function zO(e){const t={};return t.positions={...e.positions,value:new Float32Array(e.positions.value)},e.normals&&(t.normals=e.normals),e.texCoords&&(t.texCoords=e.texCoords),e.colors&&(t.colors=e.colors),e.uvRegions&&(t.uvRegions=e.uvRegions),t}async function UO(e,t,i,r){return r._parse(e,t,i,r)}function NO(e,t){if(!e)throw new Error(t||"loader assertion failed.")}const VO=Boolean("object"!=typeof process||"[object process]"!==String(process)||process.browser),jO="undefined"!=typeof process&&process.version&&/v([0-9]*)/.exec(process.version);function GO(e,t,i){if(e.byteLength<=t+i)return"";const r=new DataView(e);let n="";for(let e=0;e=0),NO(t>0),e+(t-1)&~(t-1)}function ZO(e,t,i){let r;if(e instanceof ArrayBuffer)r=new Uint8Array(e);else{const t=e.byteOffset,i=e.byteLength;r=new Uint8Array(e.buffer||e.arrayBuffer,t,i)}return t.set(r,i),i+$O(r.byteLength,4)}function WO(){if("undefined"!=typeof process&&void 0!==process.cwd)return process.cwd();const e=window.location?.pathname;return e?.slice(0,e.lastIndexOf("/")+1)||""}function qO(...e){const t=[];for(let i=0;i=-1&&!n;e--){let o;e>=0?o=t[e]:(void 0===i&&(i=WO()),o=i),0!==o.length&&(r=`${o}/${r}`,n=o.charCodeAt(0)===KO)}return r=function(e,t){let i,r="",n=-1,o=0,s=!1;for(let a=0;a<=e.length;++a){if(a2){const e=r.length-1;let t=e;for(;t>=0&&r.charCodeAt(t)!==KO;--t);if(t!==e){r=-1===t?"":r.slice(0,t),n=a,o=0,s=!1;continue}}else if(2===r.length||1===r.length){r="",n=a,o=0,s=!1;continue}t&&(r.length>0?r+="/..":r="..",s=!0)}else{const t=e.slice(n+1,a);r.length>0?r+=`/${t}`:r=t,s=!1}n=a,o=0}else i===XO&&-1!==o?++o:o=-1}return r}(r,!n),n?`/${r}`:r.length>0?r:"."}jO&&parseFloat(jO[1]);const KO=47,XO=46;var JO,YO,ez,tz;!function(e){e[e.ADD=1]="ADD",e[e.REPLACE=2]="REPLACE"}(JO||(JO={})),function(e){e.EMPTY="empty",e.SCENEGRAPH="scenegraph",e.POINTCLOUD="pointcloud",e.MESH="mesh"}(YO||(YO={})),function(e){e.I3S="I3S",e.TILES3D="TILES3D"}(ez||(ez={})),function(e){e.GEOMETRIC_ERROR="geometricError",e.MAX_SCREEN_THRESHOLD="maxScreenThreshold"}(tz||(tz={}));const iz="4.2.4",rz="cmpt",nz="pnts",oz="b3dm",sz="i3dm",az="glTF";function lz(e,t,i){NO(e instanceof ArrayBuffer);const r=new TextDecoder("utf8"),n=new Uint8Array(e,t,i);return r.decode(n)}const cz="4.2.4",uz={dataType:null,batchType:null,name:"Draco",id:"draco",module:"draco",version:cz,worker:!0,extensions:["drc"],mimeTypes:["application/octet-stream"],binary:!0,tests:["DRACO"],options:{draco:{decoderType:"object"==typeof WebAssembly?"wasm":"js",libraryPath:"libs/",extraAttributes:{},attributeNameEntry:void 0}}};function hz(e,t,i){const r=function(e){switch(e.constructor){case Int8Array:return"int8";case Uint8Array:case Uint8ClampedArray:return"uint8";case Int16Array:return"int16";case Uint16Array:return"uint16";case Int32Array:return"int32";case Uint32Array:return"uint32";case Float32Array:return"float32";case Float64Array:return"float64";default:return"null"}}(t.value),n=i||function(e){const t={};"byteOffset"in e&&(t.byteOffset=e.byteOffset.toString(10));"byteStride"in e&&(t.byteStride=e.byteStride.toString(10));"normalized"in e&&(t.normalized=e.normalized.toString());return t}(t);return{name:e,type:{type:"fixed-size-list",listSize:t.size,children:[{name:"value",type:r}]},nullable:!1,metadata:n}}function dz(e,t,i){return hz(e,t,i?pz(i.metadata):void 0)}function pz(e){const t={};for(const i in e)t[`${i}.string`]=JSON.stringify(e[i]);return t}const fz={POSITION:"POSITION",NORMAL:"NORMAL",COLOR:"COLOR_0",TEX_COORD:"TEXCOORD_0"},mz={1:Int8Array,2:Uint8Array,3:Int16Array,4:Uint16Array,5:Int32Array,6:Uint32Array,9:Float32Array};class gz{draco;decoder;metadataQuerier;constructor(e){this.draco=e,this.decoder=new this.draco.Decoder,this.metadataQuerier=new this.draco.MetadataQuerier}destroy(){this.draco.destroy(this.decoder),this.draco.destroy(this.metadataQuerier)}parseSync(e,t={}){const i=new this.draco.DecoderBuffer;i.Init(new Int8Array(e),e.byteLength),this._disableAttributeTransforms(t);const r=this.decoder.GetEncodedGeometryType(i),n=r===this.draco.TRIANGULAR_MESH?new this.draco.Mesh:new this.draco.PointCloud;try{let e;switch(r){case this.draco.TRIANGULAR_MESH:e=this.decoder.DecodeBufferToMesh(i,n);break;case this.draco.POINT_CLOUD:e=this.decoder.DecodeBufferToPointCloud(i,n);break;default:throw new Error("DRACO: Unknown geometry type.")}if(!e.ok()||!n.ptr){const t=`DRACO decompression failed: ${e.error_msg()}`;throw new Error(t)}const o=this._getDracoLoaderData(n,r,t),s=this._getMeshData(n,o,t),a=function(e){let t=1/0,i=1/0,r=1/0,n=-1/0,o=-1/0,s=-1/0;const a=e.POSITION?e.POSITION.value:[],l=a&&a.length;for(let e=0;en?l:n,o=c>o?c:o,s=u>s?u:s}return[[t,i,r],[n,o,s]]}(s.attributes),l=function(e,t,i){const r=pz(t.metadata),n=[],o=function(e){const t={};for(const i in e){const r=e[i];t[r.name||"undefined"]=r}return t}(t.attributes);for(const t in e){const i=dz(t,e[t],o[t]);n.push(i)}if(i){const e=dz("indices",i);n.push(e)}return{fields:n,metadata:r}}(s.attributes,o,s.indices);return{loader:"draco",loaderData:o,header:{vertexCount:n.num_points(),boundingBox:a},...s,schema:l}}finally{this.draco.destroy(i),n&&this.draco.destroy(n)}}_getDracoLoaderData(e,t,i){const r=this._getTopLevelMetadata(e),n=this._getDracoAttributes(e,i);return{geometry_type:t,num_attributes:e.num_attributes(),num_points:e.num_points(),num_faces:e instanceof this.draco.Mesh?e.num_faces():0,metadata:r,attributes:n}}_getDracoAttributes(e,t){const i={};for(let r=0;rthis.decoder[e]).includes(r);if(n){const t=new this.draco.AttributeQuantizationTransform;try{if(t.InitFromAttribute(e))return{quantization_bits:t.quantization_bits(),range:t.range(),min_values:new Float32Array([1,2,3]).map(e=>t.min_value(e))}}finally{this.draco.destroy(t)}}return null}_getOctahedronTransform(e,t){const{octahedronAttributes:i=[]}=t,r=e.attribute_type(),n=i.map(e=>this.decoder[e]).includes(r);if(n){const t=new this.draco.AttributeQuantizationTransform;try{if(t.InitFromAttribute(e))return{quantization_bits:t.quantization_bits()}}finally{this.draco.destroy(t)}}return null}}const _z="https://www.gstatic.com/draco/versioned/decoders/1.5.6",Az="draco_wasm_wrapper.js",yz="draco_decoder.wasm",vz="draco_decoder.js",xz="draco_encoder.js",bz={[Az]:`${_z}/${Az}`,[yz]:`${_z}/${yz}`,[vz]:`${_z}/${vz}`,[xz]:`https://raw.githubusercontent.com/google/draco/1.4.1/javascript/${xz}`};let wz;async function Tz(e){const t=e.modules||{};return t.draco3d?wz||=t.draco3d.createDecoderModule({}).then(e=>({draco:e})):wz||=async function(e){let t,i;if("js"===(e.draco&&e.draco.decoderType))t=await UB(bz[vz],"draco",e,vz);else[t,i]=await Promise.all([await UB(bz[Az],"draco",e,Az),await UB(bz[yz],"draco",e,yz)]);return t=t||globalThis.DracoDecoderModule,await function(e,t){const i={};t&&(i.wasmBinary=t);return new Promise(t=>{e({...i,onModuleLoaded:e=>t({draco:e})})})}(t,i)}(e),await wz}const Ez={...uz,parse:async function(e,t){const{draco:i}=await Tz(t),r=new gz(i);try{return r.parseSync(e,t?.draco)}finally{r.destroy()}}};const Cz={BYTE:5120,UNSIGNED_BYTE:5121,SHORT:5122,UNSIGNED_SHORT:5123,INT:5124,UNSIGNED_INT:5125,FLOAT:5126,DOUBLE:5130},Bz={POINTS:0,LINES:1,LINE_LOOP:2,LINE_STRIP:3,TRIANGLES:4,TRIANGLE_STRIP:5,TRIANGLE_FAN:6,...Cz},Sz={[Cz.DOUBLE]:Float64Array,[Cz.FLOAT]:Float32Array,[Cz.UNSIGNED_SHORT]:Uint16Array,[Cz.UNSIGNED_INT]:Uint32Array,[Cz.UNSIGNED_BYTE]:Uint8Array,[Cz.BYTE]:Int8Array,[Cz.SHORT]:Int16Array,[Cz.INT]:Int32Array},Iz={DOUBLE:Cz.DOUBLE,FLOAT:Cz.FLOAT,UNSIGNED_SHORT:Cz.UNSIGNED_SHORT,UNSIGNED_INT:Cz.UNSIGNED_INT,UNSIGNED_BYTE:Cz.UNSIGNED_BYTE,BYTE:Cz.BYTE,SHORT:Cz.SHORT,INT:Cz.INT},Mz="Failed to convert GL type";class Pz{static fromTypedArray(e){e=ArrayBuffer.isView(e)?e.constructor:e;for(const t in Sz){if(Sz[t]===e)return t}throw new Error(Mz)}static fromName(e){const t=Iz[e];if(!t)throw new Error(Mz);return t}static getArrayType(e){switch(e){case Cz.UNSIGNED_SHORT_5_6_5:case Cz.UNSIGNED_SHORT_4_4_4_4:case Cz.UNSIGNED_SHORT_5_5_5_1:return Uint16Array;default:const t=Sz[e];if(!t)throw new Error(Mz);return t}}static getByteSize(e){return Pz.getArrayType(e).BYTES_PER_ELEMENT}static validate(e){return Boolean(Pz.getArrayType(e))}static createTypedArray(e,t,i=0,r){void 0===r&&(r=(t.byteLength-i)/Pz.getByteSize(e));return new(Pz.getArrayType(e))(t,i,r)}}function Rz(e,t=[0,0,0]){const i=e>>11&31,r=e>>5&63,n=31&e;return t[0]=i<<3,t[1]=r<<2,t[2]=n<<3,t}function Lz(e,t=255){return O_(e,0,t)/t*2-1}function Fz(e){return e<0?-1:1}function kz(e,t,i,r){if(function(e,t){if(!e)throw new Error(`math.gl assertion failed. ${t}`)}(r),e<0||e>i||t<0||t>i)throw new Error(`x and y must be unsigned normalized integers between 0 and ${i}`);if(r.x=Lz(e,i),r.y=Lz(t,i),r.z=1-(Math.abs(r.x)+Math.abs(r.y)),r.z<0){const e=r.x;r.x=(1-Math.abs(r.y))*Fz(e),r.y=(1-Math.abs(e))*Fz(r.y)}return r.normalize()}function Dz(e,t,i){return kz(e,t,255,i)}new tA,new mA,new tA,new tA;class Oz{json;buffer;featuresLength=0;_cachedTypedArrays={};constructor(e,t){this.json=e,this.buffer=t}getExtension(e){return this.json.extensions&&this.json.extensions[e]}hasProperty(e){return Boolean(this.json[e])}getGlobalProperty(e,t=Bz.UNSIGNED_INT,i=1){const r=this.json[e];return r&&Number.isFinite(r.byteOffset)?this._getTypedArrayFromBinary(e,t,i,1,r.byteOffset):r}getPropertyArray(e,t,i){const r=this.json[e];return r&&Number.isFinite(r.byteOffset)?("componentType"in r&&(t=Pz.fromName(r.componentType)),this._getTypedArrayFromBinary(e,t,i,this.featuresLength,r.byteOffset)):this._getTypedArrayFromArray(e,t,r)}getProperty(e,t,i,r,n){const o=this.json[e];if(!o)return o;const s=this.getPropertyArray(e,t,i);if(1===i)return s[r];for(let e=0;ee[t],VEC2:(e,t)=>[e[2*t+0],e[2*t+1]],VEC3:(e,t)=>[e[3*t+0],e[3*t+1],e[3*t+2]],VEC4:(e,t)=>[e[4*t+0],e[4*t+1],e[4*t+2],e[4*t+3]],MAT2:(e,t)=>[e[4*t+0],e[4*t+1],e[4*t+2],e[4*t+3]],MAT3:(e,t)=>[e[9*t+0],e[9*t+1],e[9*t+2],e[9*t+3],e[9*t+4],e[9*t+5],e[9*t+6],e[9*t+7],e[9*t+8]],MAT4:(e,t)=>[e[16*t+0],e[16*t+1],e[16*t+2],e[16*t+3],e[16*t+4],e[16*t+5],e[16*t+6],e[16*t+7],e[16*t+8],e[16*t+9],e[16*t+10],e[16*t+11],e[16*t+12],e[16*t+13],e[16*t+14],e[16*t+15]]},Nz={SCALAR:(e,t,i)=>{t[i]=e},VEC2:(e,t,i)=>{t[2*i+0]=e[0],t[2*i+1]=e[1]},VEC3:(e,t,i)=>{t[3*i+0]=e[0],t[3*i+1]=e[1],t[3*i+2]=e[2]},VEC4:(e,t,i)=>{t[4*i+0]=e[0],t[4*i+1]=e[1],t[4*i+2]=e[2],t[4*i+3]=e[3]},MAT2:(e,t,i)=>{t[4*i+0]=e[0],t[4*i+1]=e[1],t[4*i+2]=e[2],t[4*i+3]=e[3]},MAT3:(e,t,i)=>{t[9*i+0]=e[0],t[9*i+1]=e[1],t[9*i+2]=e[2],t[9*i+3]=e[3],t[9*i+4]=e[4],t[9*i+5]=e[5],t[9*i+6]=e[6],t[9*i+7]=e[7],t[9*i+8]=e[8],t[9*i+9]=e[9]},MAT4:(e,t,i)=>{t[16*i+0]=e[0],t[16*i+1]=e[1],t[16*i+2]=e[2],t[16*i+3]=e[3],t[16*i+4]=e[4],t[16*i+5]=e[5],t[16*i+6]=e[6],t[16*i+7]=e[7],t[16*i+8]=e[8],t[16*i+9]=e[9],t[16*i+10]=e[10],t[16*i+11]=e[11],t[16*i+12]=e[12],t[16*i+13]=e[13],t[16*i+14]=e[14],t[16*i+15]=e[15]}};const Vz=e=>void 0!==e;function jz(e,t,i){if(!t)return null;let r=e.getExtension("3DTILES_batch_table_hierarchy");const n=t.HIERARCHY;return n&&(console.warn("3D Tile Parser: HIERARCHY is deprecated. Use 3DTILES_batch_table_hierarchy."),t.extensions=t.extensions||{},t.extensions["3DTILES_batch_table_hierarchy"]=n,r=n),r?function(e,t){let i,r,n;const o=e.instancesLength,s=e.classes;let a,l=e.classIds,c=e.parentCounts,u=e.parentIds,h=o;Vz(l.byteOffset)&&(l.componentType=defaultValue(l.componentType,GL.UNSIGNED_SHORT),l.type=AttributeType.SCALAR,n=getBinaryAccessor(l),l=n.createArrayBufferView(t.buffer,t.byteOffset+l.byteOffset,o));if(Vz(c))for(Vz(c.byteOffset)&&(c.componentType=defaultValue(c.componentType,GL.UNSIGNED_SHORT),c.type=AttributeType.SCALAR,n=getBinaryAccessor(c),c=n.createArrayBufferView(t.buffer,t.byteOffset+c.byteOffset,o)),a=new Uint16Array(o),h=0,i=0;i0?function(e,t,i){const r=e.classIds,n=e.parentCounts,o=e.parentIds,s=e.parentIndexes,a=r.length,l=scratchVisited;l.length=Math.max(l.length,a);const c=++marker,u=scratchStack;u.length=0,u.push(t);for(;u.length>0;){if(l[t=u.pop()]===c)continue;l[t]=c;const r=i(e,t);if(Vz(r))return r;const a=n[t],h=s[t];for(let e=0;ee,Zz={HIERARCHY:!0,extensions:!0,extras:!0};class Wz{json;binary;featureCount;_extensions;_properties;_binaryProperties;_hierarchy;constructor(e,t,i,r={}){NO(i>=0),this.json=e||{},this.binary=t,this.featureCount=i,this._extensions=this.json?.extensions||{},this._properties={};for(const e in this.json)Zz[e]||(this._properties[e]=this.json[e]);this._binaryProperties=this._initializeBinaryProperties(),r["3DTILES_batch_table_hierarchy"]&&(this._hierarchy=jz(this,this.json,this.binary))}getExtension(e){return this.json&&this.json.extensions&&this.json.extensions[e]}memorySizeInBytes(){return 0}isClass(e,t){if(this._checkBatchId(e),NO("string"==typeof t,t),this._hierarchy){return Qz(Gz(this._hierarchy,e,(e,i)=>{const r=e.classIds[i];return e.classes[r].name===t}))}return!1}isExactClass(e,t){return NO("string"==typeof t,t),this.getExactClassName(e)===t}getExactClassName(e){if(this._checkBatchId(e),this._hierarchy){const t=this._hierarchy.classIds[e];return this._hierarchy.classes[t].name}}hasProperty(e,t){return this._checkBatchId(e),NO("string"==typeof t,t),Qz(this._properties[t])||this._hasPropertyInHierarchy(e,t)}getPropertyNames(e,t){this._checkBatchId(e),(t=Qz(t)?t:[]).length=0;const i=Object.keys(this._properties);return t.push(...i),this._hierarchy&&this._getPropertyNamesInHierarchy(e,t),t}getProperty(e,t){if(this._checkBatchId(e),NO("string"==typeof t,t),this._binaryProperties){const i=this._binaryProperties[t];if(Qz(i))return this._getBinaryProperty(i,e)}const i=this._properties[t];if(Qz(i))return $z(i[e]);if(this._hierarchy){const i=this._getHierarchyProperty(e,t);if(Qz(i))return i}}setProperty(e,t,i){const r=this.featureCount;if(this._checkBatchId(e),NO("string"==typeof t,t),this._binaryProperties){const r=this._binaryProperties[t];if(r)return void this._setBinaryProperty(r,e,i)}if(this._hierarchy&&this._setHierarchyProperty(this,e,t,i))return;let n=this._properties[t];Qz(n)||(this._properties[t]=new Array(r),n=this._properties[t]),n[e]=$z(i)}_checkBatchId(e){if(!(e>=0&&e{const r=e.classIds[i];return Qz(e.classes[r].instances[t])});return Qz(i)}_getPropertyNamesInHierarchy(e,t){Gz(this._hierarchy,e,(e,i)=>{const r=e.classIds[i],n=e.classes[r].instances;for(const e in n)n.hasOwnProperty(e)&&-1===t.indexOf(e)&&t.push(e)})}_getHierarchyProperty(e,t){return Gz(this._hierarchy,e,(e,i)=>{const r=e.classIds[i],n=e.classes[r],o=e.classIndexes[i],s=n.instances[t];return Qz(s)?Qz(s.typedArray)?this._getBinaryProperty(s,o):$z(s[o]):null})}_setHierarchyProperty(e,t,i,r){const n=Gz(this._hierarchy,t,(e,n)=>{const o=e.classIds[n],s=e.classes[o],a=e.classIndexes[n],l=s.instances[i];return!!Qz(l)&&(NO(n===t,`Inherited property "${i}" is read-only.`),Qz(l.typedArray)?this._setBinaryProperty(l,a,r):l[a]=$z(r),!0)});return Qz(n)}}function qz(e,t,i=0){const r=new DataView(t);if(e.magic=r.getUint32(i,!0),i+=4,e.version=r.getUint32(i,!0),i+=4,e.byteLength=r.getUint32(i,!0),i+=4,1!==e.version)throw new Error(`3D Tile Version ${e.version} not supported`);return i}const Kz="b3dm tile in legacy format.";function Xz(e,t,i){const r=new DataView(t);let n;e.header=e.header||{};let o=r.getUint32(i,!0);i+=4;let s=r.getUint32(i,!0);i+=4;let a=r.getUint32(i,!0);i+=4;let l=r.getUint32(i,!0);return i+=4,a>=570425344?(i-=8,n=o,a=s,l=0,o=0,s=0,console.warn(Kz)):l>=570425344&&(i-=4,n=a,a=o,l=s,o=0,s=0,console.warn(Kz)),e.header.featureTableJsonByteLength=o,e.header.featureTableBinaryByteLength=s,e.header.batchTableJsonByteLength=a,e.header.batchTableBinaryByteLength=l,e.header.batchLength=n,i}function Jz(e,t,i,r){return i=function(e,t,i){const{featureTableJsonByteLength:r,featureTableBinaryByteLength:n,batchLength:o}=e.header||{};if(e.featureTableJson={BATCH_LENGTH:o||0},r&&r>0){const n=lz(t,i,r);e.featureTableJson=JSON.parse(n)}return i+=r||0,e.featureTableBinary=new Uint8Array(t,i,n),i+=n||0,i}(e,t,i),i=function(e,t,i){const{batchTableJsonByteLength:r,batchTableBinaryByteLength:n}=e.header||{};if(r&&r>0){const o=lz(t,i,r);e.batchTableJson=JSON.parse(o),i+=r,n&&n>0&&(e.batchTableBinary=new Uint8Array(t,i,n),e.batchTableBinary=new Uint8Array(e.batchTableBinary),i+=n)}return i}(e,t,i),i}function Yz(e,t,i){if(!(t||e&&e.batchIds&&i))return null;const{batchIds:r,isRGB565:n,pointCount:o=0}=e;if(r&&i){const e=new Uint8ClampedArray(3*o);for(let t=0;t255*e);e[3*t]=o[0],e[3*t+1]=o[1],e[3*t+2]=o[2]}return{type:Bz.UNSIGNED_BYTE,value:e,size:3,normalized:!0}}if(t&&n){const e=new Uint8ClampedArray(3*o);for(let i=0;i{try{i.onload=()=>e(i),i.onerror=e=>{const i=e instanceof Error?e.message:"error";t(new Error(i))}}catch(e){t(e)}})}(o||r,t)}finally{o&&n.revokeObjectURL(o)}}const mU={};let gU=!0;async function _U(e,t,i){let r;if(dU(i)){r=await fU(e,t,i)}else r=pU(e,i);const n=t&&t.imagebitmap;return await async function(e,t=null){!function(e){for(const t in e||mU)return!1;return!0}(t)&&gU||(t=null);if(t)try{return await createImageBitmap(e,t)}catch(e){console.warn(e),gU=!1}return await createImageBitmap(e)}(r,n)}function AU(e){return function(e,t,i=0){const r=(n=t,[...n].map(e=>e.charCodeAt(0)));var n;for(let t=0;t=24&&2303741511===t.getUint32(0,yU);if(!i)return null;return{mimeType:"image/png",width:t.getUint32(16,yU),height:t.getUint32(20,yU)}}(t)||function(e){const t=bU(e),i=t.byteLength>=3&&65496===t.getUint16(0,yU)&&255===t.getUint8(2);if(!i)return null;const{tableMarkers:r,sofMarkers:n}=function(){const e=new Set([65499,65476,65484,65501,65534]);for(let t=65504;t<65520;++t)e.add(t);const t=new Set([65472,65473,65474,65475,65477,65478,65479,65481,65482,65483,65485,65486,65487,65502]);return{tableMarkers:e,sofMarkers:t}}();let o=2;for(;o+9=10&&1195984440===t.getUint32(0,yU);if(!i)return null;return{mimeType:"image/gif",width:t.getUint16(6,vU),height:t.getUint16(8,vU)}}(t)||function(e){const t=bU(e),i=t.byteLength>=14&&16973===t.getUint16(0,yU)&&t.getUint32(2,vU)===t.byteLength;if(!i)return null;return{mimeType:"image/bmp",width:t.getUint32(18,vU),height:t.getUint32(22,vU)}}(t)||function(e){const t=new Uint8Array(e instanceof DataView?e.buffer:e),i=AU(t);if(!i)return null;return{mimeType:i.mimeType,width:0,height:0}}(t)}function bU(e){if(e instanceof DataView)return e;if(ArrayBuffer.isView(e))return new DataView(e.buffer);if(e instanceof ArrayBuffer)return new DataView(e);throw new Error("toDataView")}const wU={dataType:null,batchType:null,id:"image",module:"images",name:"Images",version:"4.2.4",mimeTypes:["image/png","image/jpeg","image/gif","image/webp","image/avif","image/bmp","image/vnd.microsoft.icon","image/svg+xml"],extensions:["png","jpg","jpeg","gif","webp","bmp","ico","svg","avif"],parse:async function(e,t,i){const r=((t=t||{}).image||{}).type||"auto",{url:n}=i||{},o=function(e){switch(e){case"auto":case"data":return function(){if(oU)return"imagebitmap";if(nU)return"image";if(aU)return"data";throw new Error("Install '@loaders.gl/polyfills' to parse images under Node.js")}();default:return function(e){switch(e){case"auto":return oU||nU||aU;case"imagebitmap":return oU;case"image":return nU;case"data":return aU;default:throw new Error(`@loaders.gl/images: image ${e} not supported in this environment`)}}(e),e}}(r);let s;switch(o){case"imagebitmap":s=await _U(e,t,n);break;case"image":s=await fU(e,t,n);break;case"data":s=await async function(e){const{mimeType:t}=xU(e)||{},i=globalThis.loaders?.parseImageNode;return NO(i),await i(e,t)}(e);break;default:NO(!1)}return"data"===r&&(s=cU(s)),s},tests:[e=>Boolean(xU(new DataView(e)))],options:{image:{type:"auto",decode:!0}}},TU={};function EU(e){if(void 0===TU[e]){const t=VO?function(e){switch(e){case"image/avif":case"image/webp":return function(e){try{const t=document.createElement("canvas");return 0===t.toDataURL(e).indexOf(`data:${e}`)}catch{return!1}}(e);default:return!0}}(e):function(e){const t=["image/png","image/jpeg","image/gif"],i=globalThis.loaders?.imageFormatsNode||t,r=globalThis.loaders?.parseImageNode;return Boolean(r)&&i.includes(e)}(e);TU[e]=t}return TU[e]}function CU(e,t){if(!e)throw new Error(t||"assert failed: gltf")}const BU={SCALAR:1,VEC2:2,VEC3:3,VEC4:4,MAT2:4,MAT3:9,MAT4:16},SU={5120:1,5121:1,5122:2,5123:2,5125:4,5126:4},IU=["SCALAR","VEC2","VEC3","VEC4"],MU=[[Int8Array,5120],[Uint8Array,5121],[Int16Array,5122],[Uint16Array,5123],[Uint32Array,5125],[Float32Array,5126],[Float64Array,5130]],PU=new Map(MU),RU={SCALAR:1,VEC2:2,VEC3:3,VEC4:4,MAT2:4,MAT3:9,MAT4:16},LU={5120:1,5121:1,5122:2,5123:2,5125:4,5126:4},FU={5120:Int8Array,5121:Uint8Array,5122:Int16Array,5123:Uint16Array,5125:Uint32Array,5126:Float32Array};function kU(e){return IU[e-1]||IU[0]}function DU(e){const t=PU.get(e.constructor);if(!t)throw new Error("Illegal typed array");return t}function OU(e,t){const i=FU[e.componentType],r=RU[e.type],n=LU[e.componentType],o=e.count*r,s=e.count*r*n;CU(s>=0&&s<=t.byteLength);return{ArrayType:i,length:o,byteLength:s,componentByteSize:SU[e.componentType],numberOfComponentsInElement:BU[e.type]}}function zU(e){let{images:t,bufferViews:i}=e;t=t||[],i=i||[];const r=t.map(e=>e.bufferView);i=i.filter(e=>!r.includes(e));const n=i.reduce((e,t)=>e+t.byteLength,0),o=t.reduce((e,t)=>{const{width:i,height:r}=t.image;return e+i*r},0);return n+Math.ceil(4*o*1.33)}class UU{gltf;sourceBuffers;byteLength;constructor(e){this.gltf={json:e?.json||{asset:{version:"2.0",generator:"loaders.gl"},buffers:[],extensions:{},extensionsRequired:[],extensionsUsed:[]},buffers:e?.buffers||[],images:e?.images||[]},this.sourceBuffers=[],this.byteLength=0,this.gltf.buffers&&this.gltf.buffers[0]&&(this.byteLength=this.gltf.buffers[0].byteLength,this.sourceBuffers=[this.gltf.buffers[0]])}get json(){return this.gltf.json}getApplicationData(e){return this.json[e]}getExtraData(e){return(this.json.extras||{})[e]}hasExtension(e){const t=this.getUsedExtensions().find(t=>t===e),i=this.getRequiredExtensions().find(t=>t===e);return"string"==typeof t||"string"==typeof i}getExtension(e){const t=this.getUsedExtensions().find(t=>t===e),i=this.json.extensions||{};return t?i[e]:null}getRequiredExtension(e){return this.getRequiredExtensions().find(t=>t===e)?this.getExtension(e):null}getRequiredExtensions(){return this.json.extensionsRequired||[]}getUsedExtensions(){return this.json.extensionsUsed||[]}getRemovedExtensions(){return this.json.extensionsRemoved||[]}getObjectExtension(e,t){return(e.extensions||{})[t]}getScene(e){return this.getObject("scenes",e)}getNode(e){return this.getObject("nodes",e)}getSkin(e){return this.getObject("skins",e)}getMesh(e){return this.getObject("meshes",e)}getMaterial(e){return this.getObject("materials",e)}getAccessor(e){return this.getObject("accessors",e)}getTexture(e){return this.getObject("textures",e)}getSampler(e){return this.getObject("samplers",e)}getImage(e){return this.getObject("images",e)}getBufferView(e){return this.getObject("bufferViews",e)}getBuffer(e){return this.getObject("buffers",e)}getObject(e,t){if("object"==typeof t)return t;const i=this.json[e]&&this.json[e][t];if(!i)throw new Error(`glTF file error: Could not find ${e}[${t}]`);return i}getTypedArrayForBufferView(e){const t=(e=this.getBufferView(e)).buffer,i=this.gltf.buffers[t];CU(i);const r=(e.byteOffset||0)+i.byteOffset;return new Uint8Array(i.arrayBuffer,r,e.byteLength)}getTypedArrayForAccessor(e){const t=this.getAccessor(e);return function(e,t,i){const r="number"==typeof i?e.accessors?.[i]:i;if(!r)throw new Error(`No gltf accessor ${JSON.stringify(i)}`);const n=e.bufferViews?.[r.bufferView||0];if(!n)throw new Error(`No gltf buffer view for accessor ${n}`);const{arrayBuffer:o,byteOffset:s}=t[n.buffer],a=(s||0)+(r.byteOffset||0)+(n.byteOffset||0),{ArrayType:l,length:c,componentByteSize:u,numberOfComponentsInElement:h}=OU(r,n),d=u*h,p=n.byteStride||d;if(void 0===n.byteStride||n.byteStride===d)return new l(o,a,c);const f=new l(c);for(let e=0;et===e)||this.json.extensionsUsed.push(e)}registerRequiredExtension(e){this.registerUsedExtension(e),this.json.extensionsRequired=this.json.extensionsRequired||[],this.json.extensionsRequired.find(t=>t===e)||this.json.extensionsRequired.push(e)}removeExtension(e){if(this.json.extensions?.[e]){this.json.extensionsRemoved=this.json.extensionsRemoved||[];const t=this.json.extensionsRemoved;t.includes(e)||t.push(e)}this.json.extensions&&delete this.json.extensions[e],this.json.extensionsRequired&&this._removeStringFromArray(this.json.extensionsRequired,e),this.json.extensionsUsed&&this._removeStringFromArray(this.json.extensionsUsed,e)}setDefaultScene(e){this.json.scene=e}addScene(e){const{nodeIndices:t}=e;return this.json.scenes=this.json.scenes||[],this.json.scenes.push({nodes:t}),this.json.scenes.length-1}addNode(e){const{meshIndex:t,matrix:i}=e;this.json.nodes=this.json.nodes||[];const r={mesh:t};return i&&(r.matrix=i),this.json.nodes.push(r),this.json.nodes.length-1}addMesh(e){const{attributes:t,indices:i,material:r,mode:n=4}=e,o={primitives:[{attributes:this._addAttributes(t),mode:n}]};if(i){const e=this._addIndices(i);o.primitives[0].indices=e}return Number.isFinite(r)&&(o.primitives[0].material=r),this.json.meshes=this.json.meshes||[],this.json.meshes.push(o),this.json.meshes.length-1}addPointCloud(e){const t={primitives:[{attributes:this._addAttributes(e),mode:0}]};return this.json.meshes=this.json.meshes||[],this.json.meshes.push(t),this.json.meshes.length-1}addImage(e,t){const i=xU(e),r=t||i?.mimeType,n={bufferView:this.addBufferView(e),mimeType:r};return this.json.images=this.json.images||[],this.json.images.push(n),this.json.images.length-1}addBufferView(e,t=0,i=this.byteLength){const r=e.byteLength;CU(Number.isFinite(r)),this.sourceBuffers=this.sourceBuffers||[],this.sourceBuffers.push(e);const n={buffer:t,byteOffset:i,byteLength:r};return this.byteLength+=$O(r,4),this.json.bufferViews=this.json.bufferViews||[],this.json.bufferViews.push(n),this.json.bufferViews.length-1}addAccessor(e,t){const i={bufferView:e,type:kU(t.size),componentType:t.componentType,count:t.count,max:t.max,min:t.min};return this.json.accessors=this.json.accessors||[],this.json.accessors.push(i),this.json.accessors.length-1}addBinaryBuffer(e,t={size:3}){const i=this.addBufferView(e);let r={min:t.min,max:t.max};r.min&&r.max||(r=this._getAccessorMinMax(e,t.size));const n={size:t.size,componentType:DU(e),count:Math.round(e.length/t.size),min:r.min,max:r.max};return this.addAccessor(i,Object.assign(n,t))}addTexture(e){const{imageIndex:t}=e,i={source:t};return this.json.textures=this.json.textures||[],this.json.textures.push(i),this.json.textures.length-1}addMaterial(e){return this.json.materials=this.json.materials||[],this.json.materials.push(e),this.json.materials.length-1}createBinaryChunk(){this.gltf.buffers=[];const e=this.byteLength,t=new ArrayBuffer(e),i=new Uint8Array(t);let r=0;for(const e of this.sourceBuffers||[])r=ZO(e,i,r);this.json?.buffers?.[0]?this.json.buffers[0].byteLength=e:this.json.buffers=[{byteLength:e}],this.gltf.binary=t,this.sourceBuffers=[t]}_removeStringFromArray(e,t){let i=!0;for(;i;){const r=e.indexOf(t);r>-1?e.splice(r,1):i=!1}}_addAttributes(e={}){const t={};for(const i in e){const r=e[i],n=this._getGltfAttributeName(i),o=this.addBinaryBuffer(r.value,r);t[n]=o}return t}_addIndices(e){return this.addBinaryBuffer(e,{size:1})}_getGltfAttributeName(e){switch(e.toLowerCase()){case"position":case"positions":case"vertices":return"POSITION";case"normal":case"normals":return"NORMAL";case"color":case"colors":return"COLOR_0";case"texcoord":case"texcoords":return"TEXCOORD_0";default:return e}}_getAccessorMinMax(e,t){const i={min:null,max:null};if(e.lengtht===e);-1===t&&(t=r.push(e)-1),o.push(t)}const s=new Uint32Array(o),a=e.gltf.buffers.push({arrayBuffer:s.buffer,byteOffset:s.byteOffset,byteLength:s.byteLength})-1,l=e.addBufferView(s,a,0),c=e.addAccessor(l,{size:1,componentType:DU(s),count:s.length});n.attributes[t]=c}function qU(e,t,i,r,n=[0]){const o={r:{offset:0,shift:0},g:{offset:1,shift:8},b:{offset:2,shift:16},a:{offset:3,shift:24}},s=i[r],a=i[r+1];let l=1;!t||-1===t.indexOf("image/jpeg")&&-1===t.indexOf("image/png")||(l=4);const c=function(e,t,i,r=1){const n=i.width,o=NU(e)*(n-1),s=Math.round(o),a=i.height,l=NU(t)*(a-1),c=Math.round(l),u=i.components?i.components:r,h=(c*n+s)*u;return h}(s,a,e,l);let u=0;for(const t of n){const i="number"==typeof t?Object.values(o)[t]:o[t],r=c+i.offset,n=cU(e);if(n.data.length<=r)throw new Error(`${n.data.length} <= ${r}`);u|=n.data[r]<r)break;const l=t/n,c=a/n;o.push(e.slice(l,l+c))}return o}function XU(e,t,i){const r=[];for(let n=0;nn)break;const c=uN(t,i/o,l/o,s);a.push(c)}return a}({valuesData:u,numberOfElements:i,arrayOffsets:n,valuesDataBytesLength:r.length,elementSize:l,enumEntry:s});const e=t.count;return e?function(e,t,i,r){const n=[];for(let o=0;o{e(i).then(e=>{const{BasisFile:i,initializeBasis:r}=e;r(),t({BasisFile:i})})})}(t,i)}(e),await BN)}async function MN(e){const t=e.modules||{};return t.basisEncoder?t.basisEncoder:(SN=SN||async function(e){let t=null,i=null;return[t,i]=await Promise.all([await UB(EN,"textures",e),await UB(CN,"textures",e)]),t=t||globalThis.BASIS,await function(e,t){const i={};t&&(i.wasmBinary=t);return new Promise(t=>{e(i).then(e=>{const{BasisFile:i,KTX2File:r,initializeBasis:n,BasisEncoder:o}=e;n(),t({BasisFile:i,KTX2File:r,BasisEncoder:o})})})}(t,i)}(e),await SN)}const PN=33776,RN=33779,LN=35840,FN=35842,kN=36196,DN=37808,ON=["","WEBKIT_","MOZ_"],zN={WEBGL_compressed_texture_s3tc:"dxt",WEBGL_compressed_texture_s3tc_srgb:"dxt-srgb",WEBGL_compressed_texture_etc1:"etc1",WEBGL_compressed_texture_etc:"etc2",WEBGL_compressed_texture_pvrtc:"pvrtc",WEBGL_compressed_texture_atc:"atc",WEBGL_compressed_texture_astc:"astc",EXT_texture_compression_rgtc:"rgtc"};let UN=null;function NN(e){if(!UN){e=e||function(){try{return document.createElement("canvas").getContext("webgl")}catch(e){return null}}()||void 0,UN=new Set;for(const t of ON)for(const i in zN)if(e&&e.getExtension(`${t}${i}`)){const e=zN[i];UN.add(e)}}return UN}var VN,jN,GN,HN,QN,$N,ZN,WN;!function(e){e[e.NONE=0]="NONE",e[e.BASISLZ=1]="BASISLZ",e[e.ZSTD=2]="ZSTD",e[e.ZLIB=3]="ZLIB"}(VN||(VN={})),function(e){e[e.BASICFORMAT=0]="BASICFORMAT"}(jN||(jN={})),function(e){e[e.UNSPECIFIED=0]="UNSPECIFIED",e[e.ETC1S=163]="ETC1S",e[e.UASTC=166]="UASTC"}(GN||(GN={})),function(e){e[e.UNSPECIFIED=0]="UNSPECIFIED",e[e.SRGB=1]="SRGB"}(HN||(HN={})),function(e){e[e.UNSPECIFIED=0]="UNSPECIFIED",e[e.LINEAR=1]="LINEAR",e[e.SRGB=2]="SRGB",e[e.ITU=3]="ITU",e[e.NTSC=4]="NTSC",e[e.SLOG=5]="SLOG",e[e.SLOG2=6]="SLOG2"}(QN||(QN={})),function(e){e[e.ALPHA_STRAIGHT=0]="ALPHA_STRAIGHT",e[e.ALPHA_PREMULTIPLIED=1]="ALPHA_PREMULTIPLIED"}($N||($N={})),function(e){e[e.RGB=0]="RGB",e[e.RRR=3]="RRR",e[e.GGG=4]="GGG",e[e.AAA=15]="AAA"}(ZN||(ZN={})),function(e){e[e.RGB=0]="RGB",e[e.RGBA=3]="RGBA",e[e.RRR=4]="RRR",e[e.RRRG=5]="RRRG"}(WN||(WN={}));const qN=[171,75,84,88,32,50,48,187,13,10,26,10];const KN={etc1:{basisFormat:0,compressed:!0,format:kN},etc2:{basisFormat:1,compressed:!0},bc1:{basisFormat:2,compressed:!0,format:PN},bc3:{basisFormat:3,compressed:!0,format:RN},bc4:{basisFormat:4,compressed:!0},bc5:{basisFormat:5,compressed:!0},"bc7-m6-opaque-only":{basisFormat:6,compressed:!0},"bc7-m5":{basisFormat:7,compressed:!0},"pvrtc1-4-rgb":{basisFormat:8,compressed:!0,format:LN},"pvrtc1-4-rgba":{basisFormat:9,compressed:!0,format:FN},"astc-4x4":{basisFormat:10,compressed:!0,format:DN},"atc-rgb":{basisFormat:11,compressed:!0},"atc-rgba-interpolated-alpha":{basisFormat:12,compressed:!0},rgba32:{basisFormat:13,compressed:!1},rgb565:{basisFormat:14,compressed:!1},bgr565:{basisFormat:15,compressed:!1},rgba4444:{basisFormat:16,compressed:!1}};function XN(e,t,i){const r=new e(new Uint8Array(t));try{if(!r.startTranscoding())throw new Error("Failed to start basis transcoding");const e=r.getNumImages(),t=[];for(let n=0;n20);const r=t.getUint32(i+0,nV),n=t.getUint32(i+4,nV);return i+=8,NO(0===n),cV(e,t,i,r),i+=r,i+=uV(e,t,i,e.header.byteLength),i}(e,n,i);case 2:return function(e,t,i,r){return NO(e.header.byteLength>20),function(e,t,i,r){for(;i+8<=e.header.byteLength;){const n=t.getUint32(i+0,nV),o=t.getUint32(i+4,nV);switch(i+=8,o){case sV:cV(e,t,i,n);break;case aV:uV(e,t,i,n);break;case 0:r.strict||cV(e,t,i,n);break;case 1:r.strict||uV(e,t,i,n)}i+=$O(n,4)}}(e,t,i,r),i+e.header.byteLength}(e,n,i,{});default:throw new Error(`Invalid GLB version ${e.version}. Only supports version 1 and 2.`)}}function cV(e,t,i,r){const n=new Uint8Array(t.buffer,i,r),o=new TextDecoder("utf8").decode(n);return e.json=JSON.parse(o),$O(r,4)}function uV(e,t,i,r){return e.header.hasBinChunk=!0,e.binChunks.push({byteOffset:i,byteLength:r,arrayBuffer:t.buffer}),$O(r,4)}function hV(e,t){if(e.startsWith("data:")||e.startsWith("http:")||e.startsWith("https:"))return e;const i=t.baseUri||t.uri;if(!i)throw new Error(`'baseUri' must be provided to resolve relative url ${e}`);return i.substr(0,i.lastIndexOf("/")+1)+e}const dV="B9h9z9tFBBBF8fL9gBB9gLaaaaaFa9gEaaaB9gFaFa9gEaaaFaEMcBFFFGGGEIIILF9wFFFLEFBFKNFaFCx/IFMO/LFVK9tv9t9vq95GBt9f9f939h9z9t9f9j9h9s9s9f9jW9vq9zBBp9tv9z9o9v9wW9f9kv9j9v9kv9WvqWv94h919m9mvqBF8Z9tv9z9o9v9wW9f9kv9j9v9kv9J9u9kv94h919m9mvqBGy9tv9z9o9v9wW9f9kv9j9v9kv9J9u9kv949TvZ91v9u9jvBEn9tv9z9o9v9wW9f9kv9j9v9kv69p9sWvq9P9jWBIi9tv9z9o9v9wW9f9kv9j9v9kv69p9sWvq9R919hWBLn9tv9z9o9v9wW9f9kv9j9v9kv69p9sWvq9F949wBKI9z9iqlBOc+x8ycGBM/qQFTa8jUUUUBCU/EBlHL8kUUUUBC9+RKGXAGCFJAI9LQBCaRKAE2BBC+gF9HQBALAEAIJHOAGlAGTkUUUBRNCUoBAG9uC/wgBZHKCUGAKCUG9JyRVAECFJRICBRcGXEXAcAF9PQFAVAFAclAcAVJAF9JyRMGXGXAG9FQBAMCbJHKC9wZRSAKCIrCEJCGrRQANCUGJRfCBRbAIRTEXGXAOATlAQ9PQBCBRISEMATAQJRIGXAS9FQBCBRtCBREEXGXAOAIlCi9PQBCBRISLMANCU/CBJAEJRKGXGXGXGXGXATAECKrJ2BBAtCKZrCEZfIBFGEBMAKhB83EBAKCNJhB83EBSEMAKAI2BIAI2BBHmCKrHYAYCE6HYy86BBAKCFJAICIJAYJHY2BBAmCIrCEZHPAPCE6HPy86BBAKCGJAYAPJHY2BBAmCGrCEZHPAPCE6HPy86BBAKCEJAYAPJHY2BBAmCEZHmAmCE6Hmy86BBAKCIJAYAmJHY2BBAI2BFHmCKrHPAPCE6HPy86BBAKCLJAYAPJHY2BBAmCIrCEZHPAPCE6HPy86BBAKCKJAYAPJHY2BBAmCGrCEZHPAPCE6HPy86BBAKCOJAYAPJHY2BBAmCEZHmAmCE6Hmy86BBAKCNJAYAmJHY2BBAI2BGHmCKrHPAPCE6HPy86BBAKCVJAYAPJHY2BBAmCIrCEZHPAPCE6HPy86BBAKCcJAYAPJHY2BBAmCGrCEZHPAPCE6HPy86BBAKCMJAYAPJHY2BBAmCEZHmAmCE6Hmy86BBAKCSJAYAmJHm2BBAI2BEHICKrHYAYCE6HYy86BBAKCQJAmAYJHm2BBAICIrCEZHYAYCE6HYy86BBAKCfJAmAYJHm2BBAICGrCEZHYAYCE6HYy86BBAKCbJAmAYJHK2BBAICEZHIAICE6HIy86BBAKAIJRISGMAKAI2BNAI2BBHmCIrHYAYCb6HYy86BBAKCFJAICNJAYJHY2BBAmCbZHmAmCb6Hmy86BBAKCGJAYAmJHm2BBAI2BFHYCIrHPAPCb6HPy86BBAKCEJAmAPJHm2BBAYCbZHYAYCb6HYy86BBAKCIJAmAYJHm2BBAI2BGHYCIrHPAPCb6HPy86BBAKCLJAmAPJHm2BBAYCbZHYAYCb6HYy86BBAKCKJAmAYJHm2BBAI2BEHYCIrHPAPCb6HPy86BBAKCOJAmAPJHm2BBAYCbZHYAYCb6HYy86BBAKCNJAmAYJHm2BBAI2BIHYCIrHPAPCb6HPy86BBAKCVJAmAPJHm2BBAYCbZHYAYCb6HYy86BBAKCcJAmAYJHm2BBAI2BLHYCIrHPAPCb6HPy86BBAKCMJAmAPJHm2BBAYCbZHYAYCb6HYy86BBAKCSJAmAYJHm2BBAI2BKHYCIrHPAPCb6HPy86BBAKCQJAmAPJHm2BBAYCbZHYAYCb6HYy86BBAKCfJAmAYJHm2BBAI2BOHICIrHYAYCb6HYy86BBAKCbJAmAYJHK2BBAICbZHIAICb6HIy86BBAKAIJRISFMAKAI8pBB83BBAKCNJAICNJ8pBB83BBAICTJRIMAtCGJRtAECTJHEAS9JQBMMGXAIQBCBRISEMGXAM9FQBANAbJ2BBRtCBRKAfREEXAEANCU/CBJAKJ2BBHTCFrCBATCFZl9zAtJHt86BBAEAGJREAKCFJHKAM9HQBMMAfCFJRfAIRTAbCFJHbAG9HQBMMABAcAG9sJANCUGJAMAG9sTkUUUBpANANCUGJAMCaJAG9sJAGTkUUUBpMAMCBAIyAcJRcAIQBMC9+RKSFMCBC99AOAIlAGCAAGCA9Ly6yRKMALCU/EBJ8kUUUUBAKM+OmFTa8jUUUUBCoFlHL8kUUUUBC9+RKGXAFCE9uHOCtJAI9LQBCaRKAE2BBHNC/wFZC/gF9HQBANCbZHVCF9LQBALCoBJCgFCUFT+JUUUBpALC84Jha83EBALC8wJha83EBALC8oJha83EBALCAJha83EBALCiJha83EBALCTJha83EBALha83ENALha83EBAEAIJC9wJRcAECFJHNAOJRMGXAF9FQBCQCbAVCF6yRSABRECBRVCBRQCBRfCBRICBRKEXGXAMAcuQBC9+RKSEMGXGXAN2BBHOC/vF9LQBALCoBJAOCIrCa9zAKJCbZCEWJHb8oGIRTAb8oGBRtGXAOCbZHbAS9PQBALAOCa9zAIJCbZCGWJ8oGBAVAbyROAb9FRbGXGXAGCG9HQBABAt87FBABCIJAO87FBABCGJAT87FBSFMAEAtjGBAECNJAOjGBAECIJATjGBMAVAbJRVALCoBJAKCEWJHmAOjGBAmATjGIALAICGWJAOjGBALCoBJAKCFJCbZHKCEWJHTAtjGBATAOjGIAIAbJRIAKCFJRKSGMGXGXAbCb6QBAQAbJAbC989zJCFJRQSFMAM1BBHbCgFZROGXGXAbCa9MQBAMCFJRMSFMAM1BFHbCgBZCOWAOCgBZqROGXAbCa9MQBAMCGJRMSFMAM1BGHbCgBZCfWAOqROGXAbCa9MQBAMCEJRMSFMAM1BEHbCgBZCdWAOqROGXAbCa9MQBAMCIJRMSFMAM2BIC8cWAOqROAMCLJRMMAOCFrCBAOCFZl9zAQJRQMGXGXAGCG9HQBABAt87FBABCIJAQ87FBABCGJAT87FBSFMAEAtjGBAECNJAQjGBAECIJATjGBMALCoBJAKCEWJHOAQjGBAOATjGIALAICGWJAQjGBALCoBJAKCFJCbZHKCEWJHOAtjGBAOAQjGIAICFJRIAKCFJRKSFMGXAOCDF9LQBALAIAcAOCbZJ2BBHbCIrHTlCbZCGWJ8oGBAVCFJHtATyROALAIAblCbZCGWJ8oGBAtAT9FHmJHtAbCbZHTyRbAT9FRTGXGXAGCG9HQBABAV87FBABCIJAb87FBABCGJAO87FBSFMAEAVjGBAECNJAbjGBAECIJAOjGBMALAICGWJAVjGBALCoBJAKCEWJHYAOjGBAYAVjGIALAICFJHICbZCGWJAOjGBALCoBJAKCFJCbZCEWJHYAbjGBAYAOjGIALAIAmJCbZHICGWJAbjGBALCoBJAKCGJCbZHKCEWJHOAVjGBAOAbjGIAKCFJRKAIATJRIAtATJRVSFMAVCBAM2BBHYyHTAOC/+F6HPJROAYCbZRtGXGXAYCIrHmQBAOCFJRbSFMAORbALAIAmlCbZCGWJ8oGBROMGXGXAtQBAbCFJRVSFMAbRVALAIAYlCbZCGWJ8oGBRbMGXGXAP9FQBAMCFJRYSFMAM1BFHYCgFZRTGXGXAYCa9MQBAMCGJRYSFMAM1BGHYCgBZCOWATCgBZqRTGXAYCa9MQBAMCEJRYSFMAM1BEHYCgBZCfWATqRTGXAYCa9MQBAMCIJRYSFMAM1BIHYCgBZCdWATqRTGXAYCa9MQBAMCLJRYSFMAMCKJRYAM2BLC8cWATqRTMATCFrCBATCFZl9zAQJHQRTMGXGXAmCb6QBAYRPSFMAY1BBHMCgFZROGXGXAMCa9MQBAYCFJRPSFMAY1BFHMCgBZCOWAOCgBZqROGXAMCa9MQBAYCGJRPSFMAY1BGHMCgBZCfWAOqROGXAMCa9MQBAYCEJRPSFMAY1BEHMCgBZCdWAOqROGXAMCa9MQBAYCIJRPSFMAYCLJRPAY2BIC8cWAOqROMAOCFrCBAOCFZl9zAQJHQROMGXGXAtCb6QBAPRMSFMAP1BBHMCgFZRbGXGXAMCa9MQBAPCFJRMSFMAP1BFHMCgBZCOWAbCgBZqRbGXAMCa9MQBAPCGJRMSFMAP1BGHMCgBZCfWAbqRbGXAMCa9MQBAPCEJRMSFMAP1BEHMCgBZCdWAbqRbGXAMCa9MQBAPCIJRMSFMAPCLJRMAP2BIC8cWAbqRbMAbCFrCBAbCFZl9zAQJHQRbMGXGXAGCG9HQBABAT87FBABCIJAb87FBABCGJAO87FBSFMAEATjGBAECNJAbjGBAECIJAOjGBMALCoBJAKCEWJHYAOjGBAYATjGIALAICGWJATjGBALCoBJAKCFJCbZCEWJHYAbjGBAYAOjGIALAICFJHICbZCGWJAOjGBALCoBJAKCGJCbZCEWJHOATjGBAOAbjGIALAIAm9FAmCb6qJHICbZCGWJAbjGBAIAt9FAtCb6qJRIAKCEJRKMANCFJRNABCKJRBAECSJREAKCbZRKAICbZRIAfCEJHfAF9JQBMMCBC99AMAc6yRKMALCoFJ8kUUUUBAKM/tIFGa8jUUUUBCTlRLC9+RKGXAFCLJAI9LQBCaRKAE2BBC/+FZC/QF9HQBALhB83ENAECFJRKAEAIJC98JREGXAF9FQBGXAGCG6QBEXGXAKAE9JQBC9+bMAK1BBHGCgFZRIGXGXAGCa9MQBAKCFJRKSFMAK1BFHGCgBZCOWAICgBZqRIGXAGCa9MQBAKCGJRKSFMAK1BGHGCgBZCfWAIqRIGXAGCa9MQBAKCEJRKSFMAK1BEHGCgBZCdWAIqRIGXAGCa9MQBAKCIJRKSFMAK2BIC8cWAIqRIAKCLJRKMALCNJAICFZCGWqHGAICGrCBAICFrCFZl9zAG8oGBJHIjGBABAIjGBABCIJRBAFCaJHFQBSGMMEXGXAKAE9JQBC9+bMAK1BBHGCgFZRIGXGXAGCa9MQBAKCFJRKSFMAK1BFHGCgBZCOWAICgBZqRIGXAGCa9MQBAKCGJRKSFMAK1BGHGCgBZCfWAIqRIGXAGCa9MQBAKCEJRKSFMAK1BEHGCgBZCdWAIqRIGXAGCa9MQBAKCIJRKSFMAK2BIC8cWAIqRIAKCLJRKMABAICGrCBAICFrCFZl9zALCNJAICFZCGWqHI8oGBJHG87FBAIAGjGBABCGJRBAFCaJHFQBMMCBC99AKAE6yRKMAKM+lLKFaF99GaG99FaG99GXGXAGCI9HQBAF9FQFEXGXGX9DBBB8/9DBBB+/ABCGJHG1BB+yAB1BBHE+yHI+L+TABCFJHL1BBHK+yHO+L+THN9DBBBB9gHVyAN9DBB/+hANAN+U9DBBBBANAVyHcAc+MHMAECa3yAI+SHIAI+UAcAMAKCa3yAO+SHcAc+U+S+S+R+VHO+U+SHN+L9DBBB9P9d9FQBAN+oRESFMCUUUU94REMAGAE86BBGXGX9DBBB8/9DBBB+/Ac9DBBBB9gyAcAO+U+SHN+L9DBBB9P9d9FQBAN+oRGSFMCUUUU94RGMALAG86BBGXGX9DBBB8/9DBBB+/AI9DBBBB9gyAIAO+U+SHN+L9DBBB9P9d9FQBAN+oRGSFMCUUUU94RGMABAG86BBABCIJRBAFCaJHFQBSGMMAF9FQBEXGXGX9DBBB8/9DBBB+/ABCIJHG8uFB+yAB8uFBHE+yHI+L+TABCGJHL8uFBHK+yHO+L+THN9DBBBB9gHVyAN9DB/+g6ANAN+U9DBBBBANAVyHcAc+MHMAECa3yAI+SHIAI+UAcAMAKCa3yAO+SHcAc+U+S+S+R+VHO+U+SHN+L9DBBB9P9d9FQBAN+oRESFMCUUUU94REMAGAE87FBGXGX9DBBB8/9DBBB+/Ac9DBBBB9gyAcAO+U+SHN+L9DBBB9P9d9FQBAN+oRGSFMCUUUU94RGMALAG87FBGXGX9DBBB8/9DBBB+/AI9DBBBB9gyAIAO+U+SHN+L9DBBB9P9d9FQBAN+oRGSFMCUUUU94RGMABAG87FBABCNJRBAFCaJHFQBMMM/SEIEaE99EaF99GXAF9FQBCBREABRIEXGXGX9D/zI818/AICKJ8uFBHLCEq+y+VHKAI8uFB+y+UHO9DB/+g6+U9DBBB8/9DBBB+/AO9DBBBB9gy+SHN+L9DBBB9P9d9FQBAN+oRVSFMCUUUU94RVMAICIJ8uFBRcAICGJ8uFBRMABALCFJCEZAEqCFWJAV87FBGXGXAKAM+y+UHN9DB/+g6+U9DBBB8/9DBBB+/AN9DBBBB9gy+SHS+L9DBBB9P9d9FQBAS+oRMSFMCUUUU94RMMABALCGJCEZAEqCFWJAM87FBGXGXAKAc+y+UHK9DB/+g6+U9DBBB8/9DBBB+/AK9DBBBB9gy+SHS+L9DBBB9P9d9FQBAS+oRcSFMCUUUU94RcMABALCaJCEZAEqCFWJAc87FBGXGX9DBBU8/AOAO+U+TANAN+U+TAKAK+U+THO9DBBBBAO9DBBBB9gy+R9DB/+g6+U9DBBB8/+SHO+L9DBBB9P9d9FQBAO+oRcSFMCUUUU94RcMABALCEZAEqCFWJAc87FBAICNJRIAECIJREAFCaJHFQBMMM9JBGXAGCGrAF9sHF9FQBEXABAB8oGBHGCNWCN91+yAGCi91CnWCUUU/8EJ+++U84GBABCIJRBAFCaJHFQBMMM9TFEaCBCB8oGUkUUBHFABCEJC98ZJHBjGUkUUBGXGXAB8/BCTWHGuQBCaREABAGlCggEJCTrXBCa6QFMAFREMAEM/lFFFaGXGXAFABqCEZ9FQBABRESFMGXGXAGCT9PQBABRESFMABREEXAEAF8oGBjGBAECIJAFCIJ8oGBjGBAECNJAFCNJ8oGBjGBAECSJAFCSJ8oGBjGBAECTJREAFCTJRFAGC9wJHGCb9LQBMMAGCI9JQBEXAEAF8oGBjGBAFCIJRFAECIJREAGC98JHGCE9LQBMMGXAG9FQBEXAEAF2BB86BBAECFJREAFCFJRFAGCaJHGQBMMABMoFFGaGXGXABCEZ9FQBABRESFMAFCgFZC+BwsN9sRIGXGXAGCT9PQBABRESFMABREEXAEAIjGBAECSJAIjGBAECNJAIjGBAECIJAIjGBAECTJREAGC9wJHGCb9LQBMMAGCI9JQBEXAEAIjGBAECIJREAGC98JHGCE9LQBMMGXAG9FQBEXAEAF86BBAECFJREAGCaJHGQBMMABMMMFBCUNMIT9kBB",pV="B9h9z9tFBBBF8dL9gBB9gLaaaaaFa9gEaaaB9gGaaB9gFaFaEQSBBFBFFGEGEGIILF9wFFFLEFBFKNFaFCx/aFMO/LFVK9tv9t9vq95GBt9f9f939h9z9t9f9j9h9s9s9f9jW9vq9zBBp9tv9z9o9v9wW9f9kv9j9v9kv9WvqWv94h919m9mvqBG8Z9tv9z9o9v9wW9f9kv9j9v9kv9J9u9kv94h919m9mvqBIy9tv9z9o9v9wW9f9kv9j9v9kv9J9u9kv949TvZ91v9u9jvBLn9tv9z9o9v9wW9f9kv9j9v9kv69p9sWvq9P9jWBKi9tv9z9o9v9wW9f9kv9j9v9kv69p9sWvq9R919hWBNn9tv9z9o9v9wW9f9kv9j9v9kv69p9sWvq9F949wBcI9z9iqlBMc/j9JSIBTEM9+FLa8jUUUUBCTlRBCBRFEXCBRGCBREEXABCNJAGJAECUaAFAGrCFZHIy86BBAEAIJREAGCFJHGCN9HQBMAFCx+YUUBJAE86BBAFCEWCxkUUBJAB8pEN83EBAFCFJHFCUG9HQBMMkRIbaG97FaK978jUUUUBCU/KBlHL8kUUUUBC9+RKGXAGCFJAI9LQBCaRKAE2BBC+gF9HQBALAEAIJHOAGlAG/8cBBCUoBAG9uC/wgBZHKCUGAKCUG9JyRNAECFJRKCBRVGXEXAVAF9PQFANAFAVlAVANJAF9JyRcGXGXAG9FQBAcCbJHIC9wZHMCE9sRSAMCFWRQAICIrCEJCGrRfCBRbEXAKRTCBRtGXEXGXAOATlAf9PQBCBRKSLMALCU/CBJAtAM9sJRmATAfJRKCBREGXAMCoB9JQBAOAKlC/gB9JQBCBRIEXAmAIJREGXGXGXGXGXATAICKrJ2BBHYCEZfIBFGEBMAECBDtDMIBSEMAEAKDBBIAKDBBBHPCID+MFAPDQBTFtGmEYIPLdKeOnHPCGD+MFAPDQBTFtGmEYIPLdKeOnC0+G+MiDtD9OHdCEDbD8jHPD8dBhUg/8/4/w/goB9+h84k7HeCEWCxkUUBJDBEBAeCx+YUUBJDBBBHnAnDQBBBBBBBBBBBBBBBBAPD8dFhUg/8/4/w/goB9+h84k7HeCEWCxkUUBJDBEBD9uDQBFGEILKOTtmYPdenDfAdAPD9SDMIBAKCIJAnDeBJAeCx+YUUBJ2BBJRKSGMAEAKDBBNAKDBBBHPCID+MFAPDQBTFtGmEYIPLdKeOnC+P+e+8/4BDtD9OHdCbDbD8jHPD8dBhUg/8/4/w/goB9+h84k7HeCEWCxkUUBJDBEBAeCx+YUUBJDBBBHnAnDQBBBBBBBBBBBBBBBBAPD8dFhUg/8/4/w/goB9+h84k7HeCEWCxkUUBJDBEBD9uDQBFGEILKOTtmYPdenDfAdAPD9SDMIBAKCNJAnDeBJAeCx+YUUBJ2BBJRKSFMAEAKDBBBDMIBAKCTJRKMGXGXGXGXGXAYCGrCEZfIBFGEBMAECBDtDMITSEMAEAKDBBIAKDBBBHPCID+MFAPDQBTFtGmEYIPLdKeOnHPCGD+MFAPDQBTFtGmEYIPLdKeOnC0+G+MiDtD9OHdCEDbD8jHPD8dBhUg/8/4/w/goB9+h84k7HeCEWCxkUUBJDBEBAeCx+YUUBJDBBBHnAnDQBBBBBBBBBBBBBBBBAPD8dFhUg/8/4/w/goB9+h84k7HeCEWCxkUUBJDBEBD9uDQBFGEILKOTtmYPdenDfAdAPD9SDMITAKCIJAnDeBJAeCx+YUUBJ2BBJRKSGMAEAKDBBNAKDBBBHPCID+MFAPDQBTFtGmEYIPLdKeOnC+P+e+8/4BDtD9OHdCbDbD8jHPD8dBhUg/8/4/w/goB9+h84k7HeCEWCxkUUBJDBEBAeCx+YUUBJDBBBHnAnDQBBBBBBBBBBBBBBBBAPD8dFhUg/8/4/w/goB9+h84k7HeCEWCxkUUBJDBEBD9uDQBFGEILKOTtmYPdenDfAdAPD9SDMITAKCNJAnDeBJAeCx+YUUBJ2BBJRKSFMAEAKDBBBDMITAKCTJRKMGXGXGXGXGXAYCIrCEZfIBFGEBMAECBDtDMIASEMAEAKDBBIAKDBBBHPCID+MFAPDQBTFtGmEYIPLdKeOnHPCGD+MFAPDQBTFtGmEYIPLdKeOnC0+G+MiDtD9OHdCEDbD8jHPD8dBhUg/8/4/w/goB9+h84k7HeCEWCxkUUBJDBEBAeCx+YUUBJDBBBHnAnDQBBBBBBBBBBBBBBBBAPD8dFhUg/8/4/w/goB9+h84k7HeCEWCxkUUBJDBEBD9uDQBFGEILKOTtmYPdenDfAdAPD9SDMIAAKCIJAnDeBJAeCx+YUUBJ2BBJRKSGMAEAKDBBNAKDBBBHPCID+MFAPDQBTFtGmEYIPLdKeOnC+P+e+8/4BDtD9OHdCbDbD8jHPD8dBhUg/8/4/w/goB9+h84k7HeCEWCxkUUBJDBEBAeCx+YUUBJDBBBHnAnDQBBBBBBBBBBBBBBBBAPD8dFhUg/8/4/w/goB9+h84k7HeCEWCxkUUBJDBEBD9uDQBFGEILKOTtmYPdenDfAdAPD9SDMIAAKCNJAnDeBJAeCx+YUUBJ2BBJRKSFMAEAKDBBBDMIAAKCTJRKMGXGXGXGXGXAYCKrfIBFGEBMAECBDtDMI8wSEMAEAKDBBIAKDBBBHPCID+MFAPDQBTFtGmEYIPLdKeOnHPCGD+MFAPDQBTFtGmEYIPLdKeOnC0+G+MiDtD9OHdCEDbD8jHPD8dBhUg/8/4/w/goB9+h84k7HYCEWCxkUUBJDBEBAYCx+YUUBJDBBBHnAnDQBBBBBBBBBBBBBBBBAPD8dFhUg/8/4/w/goB9+h84k7HYCEWCxkUUBJDBEBD9uDQBFGEILKOTtmYPdenDfAdAPD9SDMI8wAKCIJAnDeBJAYCx+YUUBJ2BBJRKSGMAEAKDBBNAKDBBBHPCID+MFAPDQBTFtGmEYIPLdKeOnC+P+e+8/4BDtD9OHdCbDbD8jHPD8dBhUg/8/4/w/goB9+h84k7HYCEWCxkUUBJDBEBAYCx+YUUBJDBBBHnAnDQBBBBBBBBBBBBBBBBAPD8dFhUg/8/4/w/goB9+h84k7HYCEWCxkUUBJDBEBD9uDQBFGEILKOTtmYPdenDfAdAPD9SDMI8wAKCNJAnDeBJAYCx+YUUBJ2BBJRKSFMAEAKDBBBDMI8wAKCTJRKMAICoBJREAICUFJAM9LQFAERIAOAKlC/fB9LQBMMGXAEAM9PQBAECErRIEXGXAOAKlCi9PQBCBRKSOMAmAEJRYGXGXGXGXGXATAECKrJ2BBAICKZrCEZfIBFGEBMAYCBDtDMIBSEMAYAKDBBIAKDBBBHPCID+MFAPDQBTFtGmEYIPLdKeOnHPCGD+MFAPDQBTFtGmEYIPLdKeOnC0+G+MiDtD9OHdCEDbD8jHPD8dBhUg/8/4/w/goB9+h84k7HeCEWCxkUUBJDBEBAeCx+YUUBJDBBBHnAnDQBBBBBBBBBBBBBBBBAPD8dFhUg/8/4/w/goB9+h84k7HeCEWCxkUUBJDBEBD9uDQBFGEILKOTtmYPdenDfAdAPD9SDMIBAKCIJAnDeBJAeCx+YUUBJ2BBJRKSGMAYAKDBBNAKDBBBHPCID+MFAPDQBTFtGmEYIPLdKeOnC+P+e+8/4BDtD9OHdCbDbD8jHPD8dBhUg/8/4/w/goB9+h84k7HeCEWCxkUUBJDBEBAeCx+YUUBJDBBBHnAnDQBBBBBBBBBBBBBBBBAPD8dFhUg/8/4/w/goB9+h84k7HeCEWCxkUUBJDBEBD9uDQBFGEILKOTtmYPdenDfAdAPD9SDMIBAKCNJAnDeBJAeCx+YUUBJ2BBJRKSFMAYAKDBBBDMIBAKCTJRKMAICGJRIAECTJHEAM9JQBMMGXAK9FQBAKRTAtCFJHtCI6QGSFMMCBRKSEMGXAM9FQBALCUGJAbJREALAbJDBGBRnCBRYEXAEALCU/CBJAYJHIDBIBHdCFD9tAdCFDbHPD9OD9hD9RHdAIAMJDBIBHiCFD9tAiAPD9OD9hD9RHiDQBTFtGmEYIPLdKeOnH8ZAIAQJDBIBHpCFD9tApAPD9OD9hD9RHpAIASJDBIBHyCFD9tAyAPD9OD9hD9RHyDQBTFtGmEYIPLdKeOnH8cDQBFTtGEmYILPdKOenHPAPDQBFGEBFGEBFGEBFGEAnD9uHnDyBjGBAEAGJHIAnAPAPDQILKOILKOILKOILKOD9uHnDyBjGBAIAGJHIAnAPAPDQNVcMNVcMNVcMNVcMD9uHnDyBjGBAIAGJHIAnAPAPDQSQfbSQfbSQfbSQfbD9uHnDyBjGBAIAGJHIAnA8ZA8cDQNVi8ZcMpySQ8c8dfb8e8fHPAPDQBFGEBFGEBFGEBFGED9uHnDyBjGBAIAGJHIAnAPAPDQILKOILKOILKOILKOD9uHnDyBjGBAIAGJHIAnAPAPDQNVcMNVcMNVcMNVcMD9uHnDyBjGBAIAGJHIAnAPAPDQSQfbSQfbSQfbSQfbD9uHnDyBjGBAIAGJHIAnAdAiDQNiV8ZcpMyS8cQ8df8eb8fHdApAyDQNiV8ZcpMyS8cQ8df8eb8fHiDQBFTtGEmYILPdKOenHPAPDQBFGEBFGEBFGEBFGED9uHnDyBjGBAIAGJHIAnAPAPDQILKOILKOILKOILKOD9uHnDyBjGBAIAGJHIAnAPAPDQNVcMNVcMNVcMNVcMD9uHnDyBjGBAIAGJHIAnAPAPDQSQfbSQfbSQfbSQfbD9uHnDyBjGBAIAGJHIAnAdAiDQNVi8ZcMpySQ8c8dfb8e8fHPAPDQBFGEBFGEBFGEBFGED9uHnDyBjGBAIAGJHIAnAPAPDQILKOILKOILKOILKOD9uHnDyBjGBAIAGJHIAnAPAPDQNVcMNVcMNVcMNVcMD9uHnDyBjGBAIAGJHIAnAPAPDQSQfbSQfbSQfbSQfbD9uHnDyBjGBAIAGJREAYCTJHYAM9JQBMMAbCIJHbAG9JQBMMABAVAG9sJALCUGJAcAG9s/8cBBALALCUGJAcCaJAG9sJAG/8cBBMAcCBAKyAVJRVAKQBMC9+RKSFMCBC99AOAKlAGCAAGCA9Ly6yRKMALCU/KBJ8kUUUUBAKMNBT+BUUUBM+KmFTa8jUUUUBCoFlHL8kUUUUBC9+RKGXAFCE9uHOCtJAI9LQBCaRKAE2BBHNC/wFZC/gF9HQBANCbZHVCF9LQBALCoBJCgFCUF/8MBALC84Jha83EBALC8wJha83EBALC8oJha83EBALCAJha83EBALCiJha83EBALCTJha83EBALha83ENALha83EBAEAIJC9wJRcAECFJHNAOJRMGXAF9FQBCQCbAVCF6yRSABRECBRVCBRQCBRfCBRICBRKEXGXAMAcuQBC9+RKSEMGXGXAN2BBHOC/vF9LQBALCoBJAOCIrCa9zAKJCbZCEWJHb8oGIRTAb8oGBRtGXAOCbZHbAS9PQBALAOCa9zAIJCbZCGWJ8oGBAVAbyROAb9FRbGXGXAGCG9HQBABAt87FBABCIJAO87FBABCGJAT87FBSFMAEAtjGBAECNJAOjGBAECIJATjGBMAVAbJRVALCoBJAKCEWJHmAOjGBAmATjGIALAICGWJAOjGBALCoBJAKCFJCbZHKCEWJHTAtjGBATAOjGIAIAbJRIAKCFJRKSGMGXGXAbCb6QBAQAbJAbC989zJCFJRQSFMAM1BBHbCgFZROGXGXAbCa9MQBAMCFJRMSFMAM1BFHbCgBZCOWAOCgBZqROGXAbCa9MQBAMCGJRMSFMAM1BGHbCgBZCfWAOqROGXAbCa9MQBAMCEJRMSFMAM1BEHbCgBZCdWAOqROGXAbCa9MQBAMCIJRMSFMAM2BIC8cWAOqROAMCLJRMMAOCFrCBAOCFZl9zAQJRQMGXGXAGCG9HQBABAt87FBABCIJAQ87FBABCGJAT87FBSFMAEAtjGBAECNJAQjGBAECIJATjGBMALCoBJAKCEWJHOAQjGBAOATjGIALAICGWJAQjGBALCoBJAKCFJCbZHKCEWJHOAtjGBAOAQjGIAICFJRIAKCFJRKSFMGXAOCDF9LQBALAIAcAOCbZJ2BBHbCIrHTlCbZCGWJ8oGBAVCFJHtATyROALAIAblCbZCGWJ8oGBAtAT9FHmJHtAbCbZHTyRbAT9FRTGXGXAGCG9HQBABAV87FBABCIJAb87FBABCGJAO87FBSFMAEAVjGBAECNJAbjGBAECIJAOjGBMALAICGWJAVjGBALCoBJAKCEWJHYAOjGBAYAVjGIALAICFJHICbZCGWJAOjGBALCoBJAKCFJCbZCEWJHYAbjGBAYAOjGIALAIAmJCbZHICGWJAbjGBALCoBJAKCGJCbZHKCEWJHOAVjGBAOAbjGIAKCFJRKAIATJRIAtATJRVSFMAVCBAM2BBHYyHTAOC/+F6HPJROAYCbZRtGXGXAYCIrHmQBAOCFJRbSFMAORbALAIAmlCbZCGWJ8oGBROMGXGXAtQBAbCFJRVSFMAbRVALAIAYlCbZCGWJ8oGBRbMGXGXAP9FQBAMCFJRYSFMAM1BFHYCgFZRTGXGXAYCa9MQBAMCGJRYSFMAM1BGHYCgBZCOWATCgBZqRTGXAYCa9MQBAMCEJRYSFMAM1BEHYCgBZCfWATqRTGXAYCa9MQBAMCIJRYSFMAM1BIHYCgBZCdWATqRTGXAYCa9MQBAMCLJRYSFMAMCKJRYAM2BLC8cWATqRTMATCFrCBATCFZl9zAQJHQRTMGXGXAmCb6QBAYRPSFMAY1BBHMCgFZROGXGXAMCa9MQBAYCFJRPSFMAY1BFHMCgBZCOWAOCgBZqROGXAMCa9MQBAYCGJRPSFMAY1BGHMCgBZCfWAOqROGXAMCa9MQBAYCEJRPSFMAY1BEHMCgBZCdWAOqROGXAMCa9MQBAYCIJRPSFMAYCLJRPAY2BIC8cWAOqROMAOCFrCBAOCFZl9zAQJHQROMGXGXAtCb6QBAPRMSFMAP1BBHMCgFZRbGXGXAMCa9MQBAPCFJRMSFMAP1BFHMCgBZCOWAbCgBZqRbGXAMCa9MQBAPCGJRMSFMAP1BGHMCgBZCfWAbqRbGXAMCa9MQBAPCEJRMSFMAP1BEHMCgBZCdWAbqRbGXAMCa9MQBAPCIJRMSFMAPCLJRMAP2BIC8cWAbqRbMAbCFrCBAbCFZl9zAQJHQRbMGXGXAGCG9HQBABAT87FBABCIJAb87FBABCGJAO87FBSFMAEATjGBAECNJAbjGBAECIJAOjGBMALCoBJAKCEWJHYAOjGBAYATjGIALAICGWJATjGBALCoBJAKCFJCbZCEWJHYAbjGBAYAOjGIALAICFJHICbZCGWJAOjGBALCoBJAKCGJCbZCEWJHOATjGBAOAbjGIALAIAm9FAmCb6qJHICbZCGWJAbjGBAIAt9FAtCb6qJRIAKCEJRKMANCFJRNABCKJRBAECSJREAKCbZRKAICbZRIAfCEJHfAF9JQBMMCBC99AMAc6yRKMALCoFJ8kUUUUBAKM/tIFGa8jUUUUBCTlRLC9+RKGXAFCLJAI9LQBCaRKAE2BBC/+FZC/QF9HQBALhB83ENAECFJRKAEAIJC98JREGXAF9FQBGXAGCG6QBEXGXAKAE9JQBC9+bMAK1BBHGCgFZRIGXGXAGCa9MQBAKCFJRKSFMAK1BFHGCgBZCOWAICgBZqRIGXAGCa9MQBAKCGJRKSFMAK1BGHGCgBZCfWAIqRIGXAGCa9MQBAKCEJRKSFMAK1BEHGCgBZCdWAIqRIGXAGCa9MQBAKCIJRKSFMAK2BIC8cWAIqRIAKCLJRKMALCNJAICFZCGWqHGAICGrCBAICFrCFZl9zAG8oGBJHIjGBABAIjGBABCIJRBAFCaJHFQBSGMMEXGXAKAE9JQBC9+bMAK1BBHGCgFZRIGXGXAGCa9MQBAKCFJRKSFMAK1BFHGCgBZCOWAICgBZqRIGXAGCa9MQBAKCGJRKSFMAK1BGHGCgBZCfWAIqRIGXAGCa9MQBAKCEJRKSFMAK1BEHGCgBZCdWAIqRIGXAGCa9MQBAKCIJRKSFMAK2BIC8cWAIqRIAKCLJRKMABAICGrCBAICFrCFZl9zALCNJAICFZCGWqHI8oGBJHG87FBAIAGjGBABCGJRBAFCaJHFQBMMCBC99AKAE6yRKMAKM/xLGEaK978jUUUUBCAlHE8kUUUUBGXGXAGCI9HQBGXAFC98ZHI9FQBABRGCBRLEXAGAGDBBBHKCiD+rFCiD+sFD/6FHOAKCND+rFCiD+sFD/6FAOD/gFAKCTD+rFCiD+sFD/6FHND/gFD/kFD/lFHVCBDtD+2FHcAOCUUUU94DtHMD9OD9RD/kFHO9DBB/+hDYAOAOD/mFAVAVD/mFANAcANAMD9OD9RD/kFHOAOD/mFD/kFD/kFD/jFD/nFHND/mF9DBBX9LDYHcD/kFCgFDtD9OAKCUUU94DtD9OD9QAOAND/mFAcD/kFCND+rFCU/+EDtD9OD9QAVAND/mFAcD/kFCTD+rFCUU/8ODtD9OD9QDMBBAGCTJRGALCIJHLAI9JQBMMAIAF9PQFAEAFCEZHLCGWHGqCBCTAGl/8MBAEABAICGWJHIAG/8cBBGXAL9FQBAEAEDBIBHKCiD+rFCiD+sFD/6FHOAKCND+rFCiD+sFD/6FAOD/gFAKCTD+rFCiD+sFD/6FHND/gFD/kFD/lFHVCBDtD+2FHcAOCUUUU94DtHMD9OD9RD/kFHO9DBB/+hDYAOAOD/mFAVAVD/mFANAcANAMD9OD9RD/kFHOAOD/mFD/kFD/kFD/jFD/nFHND/mF9DBBX9LDYHcD/kFCgFDtD9OAKCUUU94DtD9OD9QAOAND/mFAcD/kFCND+rFCU/+EDtD9OD9QAVAND/mFAcD/kFCTD+rFCUU/8ODtD9OD9QDMIBMAIAEAG/8cBBSFMABAFC98ZHGT+HUUUBAGAF9PQBAEAFCEZHICEWHLJCBCAALl/8MBAEABAGCEWJHGAL/8cBBAEAIT+HUUUBAGAEAL/8cBBMAECAJ8kUUUUBM+yEGGaO97GXAF9FQBCBRGEXABCTJHEAEDBBBHICBDtHLCUU98D8cFCUU98D8cEHKD9OABDBBBHOAIDQILKOSQfbPden8c8d8e8fCggFDtD9OD/6FAOAIDQBFGENVcMTtmYi8ZpyHICTD+sFD/6FHND/gFAICTD+rFCTD+sFD/6FHVD/gFD/kFD/lFHI9DB/+g6DYAVAIALD+2FHLAVCUUUU94DtHcD9OD9RD/kFHVAVD/mFAIAID/mFANALANAcD9OD9RD/kFHIAID/mFD/kFD/kFD/jFD/nFHND/mF9DBBX9LDYHLD/kFCTD+rFAVAND/mFALD/kFCggEDtD9OD9QHVAIAND/mFALD/kFCaDbCBDnGCBDnECBDnKCBDnOCBDncCBDnMCBDnfCBDnbD9OHIDQNVi8ZcMpySQ8c8dfb8e8fD9QDMBBABAOAKD9OAVAIDQBFTtGEmYILPdKOenD9QDMBBABCAJRBAGCIJHGAF9JQBMMM94FEa8jUUUUBCAlHE8kUUUUBABAFC98ZHIT+JUUUBGXAIAF9PQBAEAFCEZHLCEWHFJCBCAAFl/8MBAEABAICEWJHBAF/8cBBAEALT+JUUUBABAEAF/8cBBMAECAJ8kUUUUBM/hEIGaF97FaL978jUUUUBCTlRGGXAF9FQBCBREEXAGABDBBBHIABCTJHLDBBBHKDQILKOSQfbPden8c8d8e8fHOCTD+sFHNCID+rFDMIBAB9DBBU8/DY9D/zI818/DYANCEDtD9QD/6FD/nFHNAIAKDQBFGENVcMTtmYi8ZpyHICTD+rFCTD+sFD/6FD/mFHKAKD/mFANAICTD+sFD/6FD/mFHVAVD/mFANAOCTD+rFCTD+sFD/6FD/mFHOAOD/mFD/kFD/kFD/lFCBDtD+4FD/jF9DB/+g6DYHND/mF9DBBX9LDYHID/kFCggEDtHcD9OAVAND/mFAID/kFCTD+rFD9QHVAOAND/mFAID/kFCTD+rFAKAND/mFAID/kFAcD9OD9QHNDQBFTtGEmYILPdKOenHID8dBAGDBIBDyB+t+J83EBABCNJAID8dFAGDBIBDyF+t+J83EBALAVANDQNVi8ZcMpySQ8c8dfb8e8fHND8dBAGDBIBDyG+t+J83EBABCiJAND8dFAGDBIBDyE+t+J83EBABCAJRBAECIJHEAF9JQBMMM/3FGEaF978jUUUUBCoBlREGXAGCGrAF9sHIC98ZHL9FQBCBRGABRFEXAFAFDBBBHKCND+rFCND+sFD/6FAKCiD+sFCnD+rFCUUU/8EDtD+uFD/mFDMBBAFCTJRFAGCIJHGAL9JQBMMGXALAI9PQBAEAICEZHGCGWHFqCBCoBAFl/8MBAEABALCGWJHLAF/8cBBGXAG9FQBAEAEDBIBHKCND+rFCND+sFD/6FAKCiD+sFCnD+rFCUUU/8EDtD+uFD/mFDMIBMALAEAF/8cBBMM9TFEaCBCB8oGUkUUBHFABCEJC98ZJHBjGUkUUBGXGXAB8/BCTWHGuQBCaREABAGlCggEJCTrXBCa6QFMAFREMAEMMMFBCUNMIT9tBB",fV=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]),mV=new Uint8Array([32,0,65,253,3,1,2,34,4,106,6,5,11,8,7,20,13,33,12,16,128,9,116,64,19,113,127,15,10,21,22,14,255,66,24,54,136,107,18,23,192,26,114,118,132,17,77,101,130,144,27,87,131,44,45,74,156,154,70,167]),gV={0:"",1:"meshopt_decodeFilterOct",2:"meshopt_decodeFilterQuat",3:"meshopt_decodeFilterExp",NONE:"",OCTAHEDRAL:"meshopt_decodeFilterOct",QUATERNION:"meshopt_decodeFilterQuat",EXPONENTIAL:"meshopt_decodeFilterExp"},_V={0:"meshopt_decodeVertexBuffer",1:"meshopt_decodeIndexBuffer",2:"meshopt_decodeIndexSequence",ATTRIBUTES:"meshopt_decodeVertexBuffer",TRIANGLES:"meshopt_decodeIndexBuffer",INDICES:"meshopt_decodeIndexSequence"};async function AV(e,t,i,r,n,o="NONE"){const s=await async function(){yV||(yV=async function(){let e=dV;WebAssembly.validate(fV)&&(e=pV,console.log("Warning: meshopt_decoder is using experimental SIMD support"));const t=await WebAssembly.instantiate(function(e){const t=new Uint8Array(e.length);for(let i=0;i96?r-71:r>64?r-65:r>47?r+4:r>46?63:62}let i=0;for(let r=0;r0)throw new Error("glTF: Empty primitive detected: Draco decompression failure?")}(t)}function FV(e,t,i=4,r,n){if(!r.DracoWriter)throw new Error("options.gltf.DracoWriter not provided");const o=r.DracoWriter.encodeSync({attributes:e}),s=n?.parseSync?.({attributes:e}),a=r._addFauxAttributes(s.attributes),l=r.addBufferView(o);return{primitives:[{attributes:a,mode:i,extensions:{[PV]:{bufferView:l,attributes:a}}}]}}function*kV(e){for(const t of e.json.meshes||[])for(const e of t.primitives)yield e}var DV=Object.freeze({__proto__:null,name:RV,preprocess:function(e,t,i){const r=new UU(e);for(const e of kV(r))r.getObjectExtension(e,PV)},decode:async function(e,t,i){if(!t?.gltf?.decompressMeshes)return;const r=new UU(e),n=[];for(const e of kV(r))r.getObjectExtension(e,PV)&&n.push(LV(r,e,t,i));await Promise.all(n),r.removeExtension(PV)},encode:function(e,t={}){const i=new UU(e);for(const e of i.json.meshes||[])FV(e),i.addRequiredExtension(PV)}});const OV="KHR_texture_transform",zV=OV,UV=new mA,NV=new bA,VV=new bA;function jV(e,t){const i=t.json.materials?.[e],r=[i?.pbrMetallicRoughness?.baseColorTexture,i?.emissiveTexture,i?.normalTexture,i?.occlusionTexture,i?.pbrMetallicRoughness?.metallicRoughnessTexture],n=[];for(const i of r)i&&i?.extensions?.[OV]&&GV(t,e,i,n)}function GV(e,t,i,r){const n=function(e,t){const i=e.extensions?.[OV],{texCoord:r=0}=e,{texCoord:n=r}=i,o=-1!==t.findIndex(([e,t])=>e===r&&t===n);if(!o){const o=function(e){const{offset:t=[0,0],rotation:i=0,scale:r=[1,1]}=e,n=(new bA).set(1,0,0,0,1,0,t[0],t[1],1),o=NV.set(Math.cos(i),Math.sin(i),0,-Math.sin(i),Math.cos(i),0,0,0,1),s=VV.set(r[0],0,0,0,r[1],0,0,0,1);return n.multiplyRight(o).multiplyRight(s)}(i);return r!==n&&(e.texCoord=n),t.push([r,n]),{originalTexCoord:r,texCoord:n,matrix:o}}return null}(i,r);if(!n)return;const o=e.json.meshes||[];for(const i of o)for(const r of i.primitives){const i=r.material;Number.isFinite(i)&&t===i&&HV(e,r,n)}}function HV(e,t,i){const{originalTexCoord:r,texCoord:n,matrix:o}=i,s=t.attributes[`TEXCOORD_${r}`];if(Number.isFinite(s)){const i=e.json.accessors?.[s];if(i&&i.bufferView){const s=e.json.bufferViews?.[i.bufferView];if(s){const{arrayBuffer:a,byteOffset:l}=e.buffers[s.buffer],c=(l||0)+(i.byteOffset||0)+(s.byteOffset||0),{ArrayType:u,length:h}=OU(i,s),d=SU[i.componentType],p=BU[i.type],f=s.byteStride||d*p,m=new Float32Array(h);for(let e=0;e{e.uniforms[t].value&&!(t in i)&&(i[t]=e.uniforms[t].value)}),Object.keys(i).forEach(e=>{"object"==typeof i[e]&&void 0!==i[e].index&&(i[e].texture=t.getTexture(i[e].index))}),i}const ej=[dN,iN,wV,CV,IV,DV,WV,Object.freeze({__proto__:null,name:KV,decode:async function(e){const t=new UU(e),{json:i}=t;for(const e of i.materials||[]){e.extensions&&e.extensions.KHR_materials_unlit&&(e.unlit=!0),t.removeObjectExtension(e,qV)}t.removeExtension(qV)},encode:function(e){const t=new UU(e),{json:i}=t;if(t.materials)for(const e of i.materials||[])e.unlit&&(delete e.unlit,t.addObjectExtension(e,qV,{}),t.addExtension(qV))}}),Object.freeze({__proto__:null,name:JV,decode:async function(e){const t=new UU(e),{json:i}=t,r=t.getExtension(XV);if(r){const e=function(e,t){const{programs:i=[],shaders:r=[],techniques:n=[]}=e,o=new TextDecoder;return r.forEach(e=>{if(!Number.isFinite(e.bufferView))throw new Error("KHR_techniques_webgl: no shader code");e.code=o.decode(t.getTypedArrayForBufferView(e.bufferView))}),i.forEach(e=>{e.fragmentShader=r[e.fragmentShader],e.vertexShader=r[e.vertexShader]}),n.forEach(e=>{e.program=i[e.program]}),n}(r,t);for(const r of i.materials||[]){const i=t.getObjectExtension(r,XV);i&&(r.technique=Object.assign({},i,e[i.technique]),r.technique.values=YV(r.technique,t)),t.removeObjectExtension(r,XV)}t.removeExtension(XV)}},encode:async function(e,t){}}),QV,bN];function tj(e,t){const i=t?.gltf?.excludeExtensions||{};return!(e in i&&!i[e])}const ij="KHR_binary_glTF";const rj={accessors:"accessor",animations:"animation",buffers:"buffer",bufferViews:"bufferView",images:"image",materials:"material",meshes:"mesh",nodes:"node",samplers:"sampler",scenes:"scene",skins:"skin",textures:"texture"},nj={accessor:"accessors",animations:"animation",buffer:"buffers",bufferView:"bufferViews",image:"images",material:"materials",mesh:"meshes",node:"nodes",sampler:"samplers",scene:"scenes",skin:"skins",texture:"textures"};class oj{idToIndexMap={animations:{},accessors:{},buffers:{},bufferViews:{},images:{},materials:{},meshes:{},nodes:{},samplers:{},scenes:{},skins:{},textures:{}};json;normalize(e,t){this.json=e.json;const i=e.json;switch(i.asset&&i.asset.version){case"2.0":return;case void 0:case"1.0":break;default:return void console.warn(`glTF: Unknown version ${i.asset.version}`)}if(!t.normalize)throw new Error("glTF v1 is not supported.");console.warn("Converting glTF v1 to glTF v2 format. This is experimental and may fail."),this._addAsset(i),this._convertTopLevelObjectsToArrays(i),function(e){const t=new UU(e),{json:i}=t;for(const e of i.images||[]){const i=t.getObjectExtension(e,ij);i&&Object.assign(e,i),t.removeObjectExtension(e,ij)}i.buffers&&i.buffers[0]&&delete i.buffers[0].uri,t.removeExtension(ij)}(e),this._convertObjectIdsToArrayIndices(i),this._updateObjects(i),this._updateMaterial(i)}_addAsset(e){e.asset=e.asset||{},e.asset.version="2.0",e.asset.generator=e.asset.generator||"Normalized to glTF 2.0 by loaders.gl"}_convertTopLevelObjectsToArrays(e){for(const t in rj)this._convertTopLevelObjectToArray(e,t)}_convertTopLevelObjectToArray(e,t){const i=e[t];if(i&&!Array.isArray(i)){e[t]=[];for(const r in i){const n=i[r];n.id=n.id||r;const o=e[t].length;e[t].push(n),this.idToIndexMap[t][r]=o}}}_convertObjectIdsToArrayIndices(e){for(const t in rj)this._convertIdsToIndices(e,t);"scene"in e&&(e.scene=this._convertIdToIndex(e.scene,"scene"));for(const t of e.textures)this._convertTextureIds(t);for(const t of e.meshes)this._convertMeshIds(t);for(const t of e.nodes)this._convertNodeIds(t);for(const t of e.scenes)this._convertSceneIds(t)}_convertTextureIds(e){e.source&&(e.source=this._convertIdToIndex(e.source,"image"))}_convertMeshIds(e){for(const t of e.primitives){const{attributes:e,indices:i,material:r}=t;for(const t in e)e[t]=this._convertIdToIndex(e[t],"accessor");i&&(t.indices=this._convertIdToIndex(i,"accessor")),r&&(t.material=this._convertIdToIndex(r,"material"))}}_convertNodeIds(e){e.children&&(e.children=e.children.map(e=>this._convertIdToIndex(e,"node"))),e.meshes&&(e.meshes=e.meshes.map(e=>this._convertIdToIndex(e,"mesh")))}_convertSceneIds(e){e.nodes&&(e.nodes=e.nodes.map(e=>this._convertIdToIndex(e,"node")))}_convertIdsToIndices(e,t){e[t]||(console.warn(`gltf v1: json doesn't contain attribute ${t}`),e[t]=[]);for(const i of e[t])for(const e in i){const t=i[e],r=this._convertIdToIndex(t,e);i[e]=r}}_convertIdToIndex(e,t){const i=nj[t];if(i in this.idToIndexMap){const r=this.idToIndexMap[i][e];if(!Number.isFinite(r))throw new Error(`gltf v1: failed to resolve ${t} with id ${e}`);return r}return e}_updateObjects(e){for(const e of this.json.buffers)delete e.type}_updateMaterial(e){for(const t of e.materials){t.pbrMetallicRoughness={baseColorFactor:[1,1,1,1],metallicFactor:1,roughnessFactor:1};const i=t.values?.tex||t.values?.texture2d_0||t.values?.diffuseTex,r=e.textures.findIndex(e=>e.id===i);-1!==r&&(t.pbrMetallicRoughness.baseColorTexture={index:r})}}}async function sj(e,t,i=0,r,n){return function(e,t,i,r){r.uri&&(e.baseUri=r.uri);if(t instanceof ArrayBuffer&&!function(e,t=0,i={}){const r=new DataView(e),{magic:n=oV}=i,o=r.getUint32(t,!1);return o===n||o===oV}(t,i,r)){t=(new TextDecoder).decode(t)}if("string"==typeof t)e.json=HO(t);else if(t instanceof ArrayBuffer){const n={};i=lV(n,t,i,r.glb),CU("glTF"===n.type,`Invalid GLB magic string ${n.type}`),e._glb=n,e.json=n.json}else CU(!1,"GLTF: must be ArrayBuffer or string");const n=e.json.buffers||[];if(e.buffers=new Array(n.length).fill(null),e._glb&&e._glb.header.hasBinChunk){const{binChunks:t}=e._glb;e.buffers[0]={arrayBuffer:t[0].arrayBuffer,byteOffset:t[0].byteOffset,byteLength:t[0].byteLength}}const o=e.json.images||[];e.images=new Array(o.length).fill({})}(e,t,i,r),function(e,t={}){(new oj).normalize(e,t)}(e,{normalize:r?.gltf?.normalize}),function(e,t={},i){const r=ej.filter(e=>tj(e.name,t));for(const n of r)n.preprocess?.(e,t,i)}(e,r,n),r?.gltf?.loadBuffers&&e.json.buffers&&await async function(e,t,i){const r=e.json.buffers||[];for(let n=0;ntj(e.name,t));for(const n of r)await(n.decode?.(e,t,i))}(e,r,n),e}async function aj(e,t,i,r,n){let o;if(t.uri&&!t.hasOwnProperty("bufferView")){const e=hV(t.uri,r),{fetch:i}=n,s=await i(e);o=await s.arrayBuffer(),t.bufferView={data:o}}if(Number.isFinite(t.bufferView)){const i=function(e,t,i){const r=e.bufferViews[i];CU(r);const n=t[r.buffer];CU(n);const o=(r.byteOffset||0)+n.byteOffset;return new Uint8Array(n.arrayBuffer,o,r.byteLength)}(e.json,e.buffers,t.bufferView);o=QO(i.buffer,i.byteOffset,i.byteLength)}CU(o,"glTF image has no data");let s=await UO(o,[wU,rV],{...r,mimeType:t.mimeType,basis:r.basis||{format:iV()}},n);s&&s[0]&&(s={compressed:!0,mipmaps:!1,width:s[0].width,height:s[0].height,data:s[0]}),e.images=e.images||[],e.images[i]=s}const lj={dataType:null,batchType:null,name:"glTF",id:"gltf",module:"gltf",version:"4.2.4",extensions:["gltf","glb"],mimeTypes:["model/gltf+json","model/gltf-binary"],text:!0,binary:!0,tests:["glTF"],parse:async function(e,t={},i){(t={...lj.options,...t}).gltf={...lj.options.gltf,...t.gltf};const{byteOffset:r=0}=t;return await sj({},e,r,t,i)},options:{gltf:{normalize:!0,loadBuffers:!0,loadImages:!0,decompressMeshes:!0},log:console}};const cj={SCALAR:1,VEC2:2,VEC3:3,VEC4:4,MAT2:4,MAT3:9,MAT4:16},uj={5120:1,5121:1,5122:2,5123:2,5125:4,5126:4},hj=10240,dj=10241,pj=10242,fj=10243,mj=10497,gj=9729,_j=9986,Aj={magFilter:hj,minFilter:dj,wrapS:pj,wrapT:fj},yj={[hj]:gj,[dj]:_j,[pj]:mj,[fj]:mj};class vj{baseUri="";jsonUnprocessed;json;buffers=[];images=[];postProcess(e,t={}){const{json:i,buffers:r=[],images:n=[]}=e,{baseUri:o=""}=e;return CU(i),this.baseUri=o,this.buffers=r,this.images=n,this.jsonUnprocessed=i,this.json=this._resolveTree(e.json,t),this.json}_resolveTree(e,t={}){const i={...e};return this.json=i,e.bufferViews&&(i.bufferViews=e.bufferViews.map((e,t)=>this._resolveBufferView(e,t))),e.images&&(i.images=e.images.map((e,t)=>this._resolveImage(e,t))),e.samplers&&(i.samplers=e.samplers.map((e,t)=>this._resolveSampler(e,t))),e.textures&&(i.textures=e.textures.map((e,t)=>this._resolveTexture(e,t))),e.accessors&&(i.accessors=e.accessors.map((e,t)=>this._resolveAccessor(e,t))),e.materials&&(i.materials=e.materials.map((e,t)=>this._resolveMaterial(e,t))),e.meshes&&(i.meshes=e.meshes.map((e,t)=>this._resolveMesh(e,t))),e.nodes&&(i.nodes=e.nodes.map((e,t)=>this._resolveNode(e,t)),i.nodes=i.nodes.map((e,t)=>this._resolveNodeChildren(e))),e.skins&&(i.skins=e.skins.map((e,t)=>this._resolveSkin(e,t))),e.scenes&&(i.scenes=e.scenes.map((e,t)=>this._resolveScene(e,t))),"number"==typeof this.json.scene&&i.scenes&&(i.scene=i.scenes[this.json.scene]),i}getScene(e){return this._get(this.json.scenes,e)}getNode(e){return this._get(this.json.nodes,e)}getSkin(e){return this._get(this.json.skins,e)}getMesh(e){return this._get(this.json.meshes,e)}getMaterial(e){return this._get(this.json.materials,e)}getAccessor(e){return this._get(this.json.accessors,e)}getCamera(e){return this._get(this.json.cameras,e)}getTexture(e){return this._get(this.json.textures,e)}getSampler(e){return this._get(this.json.samplers,e)}getImage(e){return this._get(this.json.images,e)}getBufferView(e){return this._get(this.json.bufferViews,e)}getBuffer(e){return this._get(this.json.buffers,e)}_get(e,t){if("object"==typeof t)return t;const i=e&&e[t];return i||console.warn(`glTF file error: Could not find ${e}[${t}]`),i}_resolveScene(e,t){return{...e,id:e.id||`scene-${t}`,nodes:(e.nodes||[]).map(e=>this.getNode(e))}}_resolveNode(e,t){const i={...e,id:e?.id||`node-${t}`};return void 0!==e.mesh&&(i.mesh=this.getMesh(e.mesh)),void 0!==e.camera&&(i.camera=this.getCamera(e.camera)),void 0!==e.skin&&(i.skin=this.getSkin(e.skin)),void 0!==e.meshes&&e.meshes.length&&(i.mesh=e.meshes.reduce((e,t)=>{const i=this.getMesh(t);return e.id=i.id,e.primitives=e.primitives.concat(i.primitives),e},{primitives:[]})),i}_resolveNodeChildren(e){return e.children&&(e.children=e.children.map(e=>this.getNode(e))),e}_resolveSkin(e,t){const i="number"==typeof e.inverseBindMatrices?this.getAccessor(e.inverseBindMatrices):void 0;return{...e,id:e.id||`skin-${t}`,inverseBindMatrices:i}}_resolveMesh(e,t){const i={...e,id:e.id||`mesh-${t}`,primitives:[]};return e.primitives&&(i.primitives=e.primitives.map(e=>{const t={...e,attributes:{},indices:void 0,material:void 0},i=e.attributes;for(const e in i)t.attributes[e]=this.getAccessor(i[e]);return void 0!==e.indices&&(t.indices=this.getAccessor(e.indices)),void 0!==e.material&&(t.material=this.getMaterial(e.material)),t})),i}_resolveMaterial(e,t){const i={...e,id:e.id||`material-${t}`};if(i.normalTexture&&(i.normalTexture={...i.normalTexture},i.normalTexture.texture=this.getTexture(i.normalTexture.index)),i.occlusionTexture&&(i.occlusionTexture={...i.occlusionTexture},i.occlusionTexture.texture=this.getTexture(i.occlusionTexture.index)),i.emissiveTexture&&(i.emissiveTexture={...i.emissiveTexture},i.emissiveTexture.texture=this.getTexture(i.emissiveTexture.index)),i.emissiveFactor||(i.emissiveFactor=i.emissiveTexture?[1,1,1]:[0,0,0]),i.pbrMetallicRoughness){i.pbrMetallicRoughness={...i.pbrMetallicRoughness};const e=i.pbrMetallicRoughness;e.baseColorTexture&&(e.baseColorTexture={...e.baseColorTexture},e.baseColorTexture.texture=this.getTexture(e.baseColorTexture.index)),e.metallicRoughnessTexture&&(e.metallicRoughnessTexture={...e.metallicRoughnessTexture},e.metallicRoughnessTexture.texture=this.getTexture(e.metallicRoughnessTexture.index))}return i}_resolveAccessor(e,t){const i=(r=e.componentType,uj[r]);var r;const n=function(e){return cj[e]}(e.type),o=i*n,s={...e,id:e.id||`accessor-${t}`,bytesPerComponent:i,components:n,bytesPerElement:o,value:void 0,bufferView:void 0,sparse:void 0};if(void 0!==e.bufferView&&(s.bufferView=this.getBufferView(e.bufferView)),s.bufferView){const e=s.bufferView.buffer,{ArrayType:t,byteLength:i}=OU(s,s.bufferView),r=(s.bufferView.byteOffset||0)+(s.byteOffset||0)+e.byteOffset;let n=e.arrayBuffer.slice(r,r+i);s.bufferView.byteStride&&(n=this._getValueFromInterleavedBuffer(e,r,s.bufferView.byteStride,s.bytesPerElement,s.count)),s.value=new t(n)}return s}_getValueFromInterleavedBuffer(e,t,i,r,n){const o=new Uint8Array(n*r);for(let s=0;s12;){const s={shape:"tile3d"};e.tiles.push(s),i=await o(t,i,r,n,s)}return i}(n,e,t,i,r,Sj);case oz:return await Cj(n,e,t,i,r);case az:return await async function(e,t,i,r){if(e.rotateYtoZ=!0,e.gltfUpAxis=i?.["3d-tiles"]?.assetGltfUpAxis?i["3d-tiles"].assetGltfUpAxis:"Y",i?.["3d-tiles"]?.loadGLTF){if(!r)return t.byteLength;const n=await UO(t,lj,i,r);e.gltf=xj(n),e.gpuMemoryUsageInBytes=zU(e.gltf)}else e.gltfArrayBuffer=t;return t.byteLength}(n,e,i,r);case sz:return await Bj(n,e,t,i,r);case nz:return await iU(n,e,t,i,r);default:throw new Error(`3DTileLoader: unknown type ${n.type}`)}}async function Ij(e,t,i,r){const n=Number.isFinite(t.bitstream)?t.bitstream:t.bufferView;if("number"!=typeof n)return;const o=e.bufferViews[n],s=e.buffers[o.buffer];if(!r?.baseUrl)throw new Error("Url is not provided");if(!r.fetch)throw new Error("fetch is not provided");if(s.uri){const e=`${r?.baseUrl||""}/${s.uri}`,i=await r.fetch(e),n=await i.arrayBuffer();return void(t.explicitBitstream=new Uint8Array(n,o.byteOffset,o.byteLength))}const a=e.buffers.slice(0,o.buffer).reduce((e,t)=>e+t.byteLength,0);t.explicitBitstream=new Uint8Array(i.slice(a,a+s.byteLength),o.byteOffset,o.byteLength)}function Mj(e){const t=new DataView(e);return t.getUint32(0,!0)+2**32*t.getUint32(4,!0)}const Pj={dataType:null,batchType:null,id:"3d-tiles-subtree",name:"3D Tiles Subtree",module:"3d-tiles",version:iz,extensions:["subtree"],mimeTypes:["application/octet-stream"],tests:["subtree"],parse:async function(e,t,i){if(1952609651!==new Uint32Array(e.slice(0,4))[0])throw new Error("Wrong subtree file magic number");if(1!==new Uint32Array(e.slice(4,8))[0])throw new Error("Wrong subtree file verson, must be 1");const r=Mj(e.slice(8,16)),n=new Uint8Array(e,24,r),o=new TextDecoder("utf8").decode(n),s=JSON.parse(o),a=Mj(e.slice(16,24));let l=new ArrayBuffer(0);if(a&&(l=e.slice(24+r)),await Ij(s,s.tileAvailability,l,i),Array.isArray(s.contentAvailability))for(const e of s.contentAvailability)await Ij(s,e,l,i);else await Ij(s,s.contentAvailability,l,i);return await Ij(s,s.childSubtreeAvailability,l,i),s},options:{}}; + */var hN=null;try{hN=new WebAssembly.Instance(new WebAssembly.Module(new Uint8Array([0,97,115,109,1,0,0,0,1,13,2,96,0,1,127,96,4,127,127,127,127,1,127,3,7,6,0,1,1,1,1,1,6,6,1,127,1,65,0,11,7,50,6,3,109,117,108,0,1,5,100,105,118,95,115,0,2,5,100,105,118,95,117,0,3,5,114,101,109,95,115,0,4,5,114,101,109,95,117,0,5,8,103,101,116,95,104,105,103,104,0,0,10,191,1,6,4,0,35,0,11,36,1,1,126,32,0,173,32,1,173,66,32,134,132,32,2,173,32,3,173,66,32,134,132,126,34,4,66,32,135,167,36,0,32,4,167,11,36,1,1,126,32,0,173,32,1,173,66,32,134,132,32,2,173,32,3,173,66,32,134,132,127,34,4,66,32,135,167,36,0,32,4,167,11,36,1,1,126,32,0,173,32,1,173,66,32,134,132,32,2,173,32,3,173,66,32,134,132,128,34,4,66,32,135,167,36,0,32,4,167,11,36,1,1,126,32,0,173,32,1,173,66,32,134,132,32,2,173,32,3,173,66,32,134,132,129,34,4,66,32,135,167,36,0,32,4,167,11,36,1,1,126,32,0,173,32,1,173,66,32,134,132,32,2,173,32,3,173,66,32,134,132,130,34,4,66,32,135,167,36,0,32,4,167,11])),{}).exports}catch{}function dN(e,t,i){this.low=0|e,this.high=0|t,this.unsigned=!!i}function pN(e){return!0===(e&&e.__isLong__)}function fN(e){var t=Math.clz32(e&-e);return e?31-t:t}dN.prototype.__isLong__,Object.defineProperty(dN.prototype,"__isLong__",{value:!0}),dN.isLong=pN;var mN={},gN={};function _N(e,t){var i,n,r;return t?(r=0<=(e>>>=0)&&e<256)&&(n=gN[e])?n:(i=yN(e,0,!0),r&&(gN[e]=i),i):(r=-128<=(e|=0)&&e<128)&&(n=mN[e])?n:(i=yN(e,e<0?-1:0,!1),r&&(mN[e]=i),i)}function AN(e,t){if(isNaN(e))return t?BN:SN;if(t){if(e<0)return BN;if(e>=TN)return LN}else{if(e<=-EN)return FN;if(e+1>=EN)return RN}return e<0?AN(-e,t).neg():yN(e%wN|0,e/wN|0,t)}function yN(e,t,i){return new dN(e,t,i)}dN.fromInt=_N,dN.fromNumber=AN,dN.fromBits=yN;var vN=Math.pow;function xN(e,t,i){if(0===e.length)throw Error("empty string");if("number"==typeof t?(i=t,t=!1):t=!!t,"NaN"===e||"Infinity"===e||"+Infinity"===e||"-Infinity"===e)return t?BN:SN;if((i=i||10)<2||360)throw Error("interior hyphen");if(0===n)return xN(e.substring(1),t,i).neg();for(var r=AN(vN(i,8)),o=SN,s=0;s>>0:this.low},kN.toNumber=function(){return this.unsigned?(this.high>>>0)*wN+(this.low>>>0):this.high*wN+(this.low>>>0)},kN.toString=function(e){if((e=e||10)<2||36>>0).toString(e);if((o=a).isZero())return l+s;for(;l.length<6;)l="0"+l;s=""+l+s}},kN.getHighBits=function(){return this.high},kN.getHighBitsUnsigned=function(){return this.high>>>0},kN.getLowBits=function(){return this.low},kN.getLowBitsUnsigned=function(){return this.low>>>0},kN.getNumBitsAbs=function(){if(this.isNegative())return this.eq(FN)?64:this.neg().getNumBitsAbs();for(var e=0!=this.high?this.high:this.low,t=31;t>0&&!(e&1<>21;return!e||!this.unsigned&&(-1===e&&!(0===this.low&&-2097152===this.high))},kN.isZero=function(){return 0===this.high&&0===this.low},kN.eqz=kN.isZero,kN.isNegative=function(){return!this.unsigned&&this.high<0},kN.isPositive=function(){return this.unsigned||this.high>=0},kN.isOdd=function(){return!(1&~this.low)},kN.isEven=function(){return!(1&this.low)},kN.equals=function(e){return pN(e)||(e=bN(e)),(this.unsigned===e.unsigned||this.high>>>31!=1||e.high>>>31!=1)&&(this.high===e.high&&this.low===e.low)},kN.eq=kN.equals,kN.notEquals=function(e){return!this.eq(e)},kN.neq=kN.notEquals,kN.ne=kN.notEquals,kN.lessThan=function(e){return this.comp(e)<0},kN.lt=kN.lessThan,kN.lessThanOrEqual=function(e){return this.comp(e)<=0},kN.lte=kN.lessThanOrEqual,kN.le=kN.lessThanOrEqual,kN.greaterThan=function(e){return this.comp(e)>0},kN.gt=kN.greaterThan,kN.greaterThanOrEqual=function(e){return this.comp(e)>=0},kN.gte=kN.greaterThanOrEqual,kN.ge=kN.greaterThanOrEqual,kN.compare=function(e){if(pN(e)||(e=bN(e)),this.eq(e))return 0;var t=this.isNegative(),i=e.isNegative();return t&&!i?-1:!t&&i?1:this.unsigned?e.high>>>0>this.high>>>0||e.high===this.high&&e.low>>>0>this.low>>>0?-1:1:this.sub(e).isNegative()?-1:1},kN.comp=kN.compare,kN.negate=function(){return!this.unsigned&&this.eq(FN)?FN:this.not().add(IN)},kN.neg=kN.negate,kN.add=function(e){pN(e)||(e=bN(e));var t=this.high>>>16,i=65535&this.high,n=this.low>>>16,r=65535&this.low,o=e.high>>>16,s=65535&e.high,a=e.low>>>16,l=0,c=0,u=0,h=0;return u+=(h+=r+(65535&e.low))>>>16,c+=(u+=n+a)>>>16,l+=(c+=i+s)>>>16,l+=t+o,yN((u&=65535)<<16|(h&=65535),(l&=65535)<<16|(c&=65535),this.unsigned)},kN.subtract=function(e){return pN(e)||(e=bN(e)),this.add(e.neg())},kN.sub=kN.subtract,kN.multiply=function(e){if(this.isZero())return this;if(pN(e)||(e=bN(e)),hN)return yN(hN.mul(this.low,this.high,e.low,e.high),hN.get_high(),this.unsigned);if(e.isZero())return this.unsigned?BN:SN;if(this.eq(FN))return e.isOdd()?FN:SN;if(e.eq(FN))return this.isOdd()?FN:SN;if(this.isNegative())return e.isNegative()?this.neg().mul(e.neg()):this.neg().mul(e).neg();if(e.isNegative())return this.mul(e.neg()).neg();if(this.lt(CN)&&e.lt(CN))return AN(this.toNumber()*e.toNumber(),this.unsigned);var t=this.high>>>16,i=65535&this.high,n=this.low>>>16,r=65535&this.low,o=e.high>>>16,s=65535&e.high,a=e.low>>>16,l=65535&e.low,c=0,u=0,h=0,d=0;return h+=(d+=r*l)>>>16,u+=(h+=n*l)>>>16,h&=65535,u+=(h+=r*a)>>>16,c+=(u+=i*l)>>>16,u&=65535,c+=(u+=n*a)>>>16,u&=65535,c+=(u+=r*s)>>>16,c+=t*l+i*a+n*s+r*o,yN((h&=65535)<<16|(d&=65535),(c&=65535)<<16|(u&=65535),this.unsigned)},kN.mul=kN.multiply,kN.divide=function(e){if(pN(e)||(e=bN(e)),e.isZero())throw Error("division by zero");var t,i,n;if(hN)return this.unsigned||-2147483648!==this.high||-1!==e.low||-1!==e.high?yN((this.unsigned?hN.div_u:hN.div_s)(this.low,this.high,e.low,e.high),hN.get_high(),this.unsigned):this;if(this.isZero())return this.unsigned?BN:SN;if(this.unsigned){if(e.unsigned||(e=e.toUnsigned()),e.gt(this))return BN;if(e.gt(this.shru(1)))return MN;n=BN}else{if(this.eq(FN))return e.eq(IN)||e.eq(PN)?FN:e.eq(FN)?IN:(t=this.shr(1).div(e).shl(1)).eq(SN)?e.isNegative()?IN:PN:(i=this.sub(e.mul(t)),n=t.add(i.div(e)));if(e.eq(FN))return this.unsigned?BN:SN;if(this.isNegative())return e.isNegative()?this.neg().div(e.neg()):this.neg().div(e).neg();if(e.isNegative())return this.div(e.neg()).neg();n=SN}for(i=this;i.gte(e);){t=Math.max(1,Math.floor(i.toNumber()/e.toNumber()));for(var r=Math.ceil(Math.log(t)/Math.LN2),o=r<=48?1:vN(2,r-48),s=AN(t),a=s.mul(e);a.isNegative()||a.gt(i);)a=(s=AN(t-=o,this.unsigned)).mul(e);s.isZero()&&(s=IN),n=n.add(s),i=i.sub(a)}return n},kN.div=kN.divide,kN.modulo=function(e){return pN(e)||(e=bN(e)),hN?yN((this.unsigned?hN.rem_u:hN.rem_s)(this.low,this.high,e.low,e.high),hN.get_high(),this.unsigned):this.sub(this.div(e).mul(e))},kN.mod=kN.modulo,kN.rem=kN.modulo,kN.not=function(){return yN(~this.low,~this.high,this.unsigned)},kN.countLeadingZeros=function(){return this.high?Math.clz32(this.high):Math.clz32(this.low)+32},kN.clz=kN.countLeadingZeros,kN.countTrailingZeros=function(){return this.low?fN(this.low):fN(this.high)+32},kN.ctz=kN.countTrailingZeros,kN.and=function(e){return pN(e)||(e=bN(e)),yN(this.low&e.low,this.high&e.high,this.unsigned)},kN.or=function(e){return pN(e)||(e=bN(e)),yN(this.low|e.low,this.high|e.high,this.unsigned)},kN.xor=function(e){return pN(e)||(e=bN(e)),yN(this.low^e.low,this.high^e.high,this.unsigned)},kN.shiftLeft=function(e){return pN(e)&&(e=e.toInt()),0==(e&=63)?this:e<32?yN(this.low<>>32-e,this.unsigned):yN(0,this.low<>>e|this.high<<32-e,this.high>>e,this.unsigned):yN(this.high>>e-32,this.high>=0?0:-1,this.unsigned)},kN.shr=kN.shiftRight,kN.shiftRightUnsigned=function(e){return pN(e)&&(e=e.toInt()),0==(e&=63)?this:e<32?yN(this.low>>>e|this.high<<32-e,this.high>>>e,this.unsigned):yN(32===e?this.high:this.high>>>e-32,0,this.unsigned)},kN.shru=kN.shiftRightUnsigned,kN.shr_u=kN.shiftRightUnsigned,kN.rotateLeft=function(e){var t;return pN(e)&&(e=e.toInt()),0==(e&=63)?this:32===e?yN(this.high,this.low,this.unsigned):e<32?(t=32-e,yN(this.low<>>t,this.high<>>t,this.unsigned)):(t=32-(e-=32),yN(this.high<>>t,this.low<>>t,this.unsigned))},kN.rotl=kN.rotateLeft,kN.rotateRight=function(e){var t;return pN(e)&&(e=e.toInt()),0==(e&=63)?this:32===e?yN(this.high,this.low,this.unsigned):e<32?(t=32-e,yN(this.high<>>e,this.low<>>e,this.unsigned)):(t=32-(e-=32),yN(this.low<>>e,this.high<>>e,this.unsigned))},kN.rotr=kN.rotateRight,kN.toSigned=function(){return this.unsigned?yN(this.low,this.high,!1):this},kN.toUnsigned=function(){return this.unsigned?this:yN(this.low,this.high,!0)},kN.toBytes=function(e){return e?this.toBytesLE():this.toBytesBE()},kN.toBytesLE=function(){var e=this.high,t=this.low;return[255&t,t>>>8&255,t>>>16&255,t>>>24,255&e,e>>>8&255,e>>>16&255,e>>>24]},kN.toBytesBE=function(){var e=this.high,t=this.low;return[e>>>24,e>>>16&255,e>>>8&255,255&e,t>>>24,t>>>16&255,t>>>8&255,255&t]},dN.fromBytes=function(e,t,i){return i?dN.fromBytesLE(e,t):dN.fromBytesBE(e,t)},dN.fromBytesLE=function(e,t){return new dN(e[0]|e[1]<<8|e[2]<<16|e[3]<<24,e[4]|e[5]<<8|e[6]<<16|e[7]<<24,t)},dN.fromBytesBE=function(e,t){return new dN(e[4]<<24|e[5]<<16|e[6]<<8|e[7],e[0]<<24|e[1]<<16|e[2]<<8|e[3],t)},"function"==typeof BigInt&&(dN.fromBigInt=function(e,t){return yN(Number(BigInt.asIntN(32,e)),Number(BigInt.asIntN(32,e>>BigInt(32))),t)},dN.fromValue=function(e,t){return"bigint"==typeof e?dN.fromBigInt(e,t):bN(e,t)},kN.toBigInt=function(){var e=BigInt(this.low>>>0);return BigInt(this.unsigned?this.high>>>0:this.high)<=.5?1/3*(4*e*e-1):1/3*(1-4*(1-e)*(1-e))}function NN(e){return[UN(e[0]),UN(e[1])]}function VN(e,[t,i]){switch(e){case 0:return[1,t,i];case 1:return[-t,1,i];case 2:return[-t,-i,1];case 3:return[-1,-i,-t];case 4:return[i,-1,-t];case 5:return[i,t,-1];default:throw new Error("Invalid face")}}function jN([e,t,i]){const n=Math.atan2(i,Math.sqrt(e*e+t*t));return[Math.atan2(t,e)*ON,n*ON]}function GN(e,t,i,n){if(0===n){1===i&&(t[0]=e-1-t[0],t[1]=e-1-t[1]);const n=t[0];t[0]=t[1],t[1]=n}}function HN(e){const{face:t,ij:i,level:n}=e,r=[[0,0],[0,1],[1,1],[1,0],[0,0]],o=Math.max(1,Math.ceil(100*Math.pow(2,-n))),s=new Float64Array(4*o*2+2);let a=0,l=0;for(let e=0;e<4;e++){const c=r[e].slice(0),u=r[e+1],h=(u[0]-c[0])/o,d=(u[1]-c[1])/o;for(let e=0;e89.999&&(e[0]=l);const r=e[0]-l;e[0]+=r>180?-360:r<-180?360:0,s[a++]=e[0],s[a++]=e[1],l=e[0]}}return s[a++]=s[0],s[a++]=s[1],s}function QN(e){const t=function(e){if(e.indexOf("/")>0)return e;const t=DN(e);return function(e){if(e.isZero())return"";let t=e.toString(2);for(;t.length<64;)t="0"+t;const i=t.lastIndexOf("1"),n=t.substring(0,3),r=t.substring(3,i),o=r.length/2,s=dN.fromString(n,!0,2).toString(10);let a="";if(0!==o)for(a=dN.fromString(r,!0,2).toString(4);a.length=0;e--){o=r-e;const t=n[e];let i=0,a=0;"1"===t?a=1:"2"===t?(i=1,a=1):"3"===t&&(i=1);const l=Math.pow(2,o-1);GN(l,s,i,a),s[0]+=l*i,s[1]+=l*a}if(i%2==1){const e=s[0];s[0]=s[1],s[1]=e}return{face:i,ij:s,level:o}}(t);return i}function $N(e){return function(e){const t=NN(zN(e.ij,e.level,[.5,.5]));return jN(VN(e.face,t))}(QN(e))}function ZN(e){if(e.length%2!=0)throw new Error("Invalid corners");const t=[],i=[];for(let n=0;ne-t),i.sort((e,t)=>e-t),{west:t[0],east:t[t.length-1],north:i[i.length-1],south:i[0]}}function WN(e,t){const i=t?.minimumHeight||0,n=t?.maximumHeight||0,r=function(e){let t;if(2===e.face||5===e.face){let i=null,n=0;for(let t=0;t<4;t++){const r=HN(QN(`${e.face}/${t}`));null==i&&(i=new Float64Array(4*r.length)),i.set(r,n),n+=r.length}t=ZN(i)}else t=ZN(HN(e));return t}(QN(e)),o=r.west,s=r.south,a=r.east,l=r.north,c=[];return c.push(new AA(o,l,i)),c.push(new AA(a,l,i)),c.push(new AA(a,s,i)),c.push(new AA(o,s,i)),c.push(new AA(o,l,n)),c.push(new AA(a,l,n)),c.push(new AA(a,s,n)),c.push(new AA(o,s,n)),c}function qN(e){const t=e.token,i={minimumHeight:e.minimumHeight,maximumHeight:e.maximumHeight},n=WN(t,i),r=$N(t),o=r[0],s=r[1],a=PO.WGS84.cartographicToCartesian([o,s,i.maximumHeight]),l=new AA(a[0],a[1],a[2]);n.push(l);const c=NR(n);return[...c.center,...c.halfAxes]}const KN={QUADTREE:4,OCTREE:8};function XN(e,t,i){if(e?.box){const n=function(e,t){const i=function(e){return e.and(e.not().add(1))}(e).shiftRightUnsigned(2);return e.add(dN.fromNumber(2*t+1-4).multiply(i))}(DN(e.s2VolumeInfo.token),t),r=function(e){if(e.isZero())return"X";let t=e.countTrailingZeros();t=(t-t%4)/4;const i=t;t*=4;const n=e.shiftRightUnsigned(t).toString(16).replace(/0+$/,"");return Array(17-i-n.length).join("0")+n}(n),o={...e.s2VolumeInfo};if(o.token=r,"OCTREE"===i){const t=e.s2VolumeInfo,i=t.maximumHeight-t.minimumHeight,n=i/2,r=t.minimumHeight+i/2;t.minimumHeight=r-n,t.maximumHeight=r+n}return{box:qN(o),s2VolumeInfo:o}}}async function JN(e){const{subtree:t,subtreeData:i={level:0,x:0,y:0,z:0},parentData:n={mortonIndex:0,localLevel:-1,localX:0,localY:0,localZ:0},childIndex:r=0,implicitOptions:o,loaderOptions:s,s2VolumeBox:a}=e,{subdivisionScheme:l,subtreeLevels:c,maximumLevel:u,contentUrlTemplate:h,subtreesUriTemplate:d,basePath:p}=o,f={children:[],lodMetricValue:0,contentUrl:""};if(!u)return Zu.once(`Missing 'maximumLevel' or 'availableLevels' property. The subtree ${h} won't be loaded...`),f;const m=n.localLevel+1,g=i.level+m;if(g>u)return f;const _=KN[l],A=Math.log2(_),y=1&r,v=r>>1&1,x=r>>2&1,b=eV(n.localX,y,1),w=eV(n.localY,v,1),T=eV(n.localZ,x,1),E=eV(i.x,b,m),C=eV(i.y,w,m),S=eV(i.z,T,m),B=eV(n.mortonIndex,r,A);let I,M,P,R;if(m===c&&YN(t.childSubtreeAvailability,B)){const e=tV(`${p}/${d}`,g,E,C,S);I=await dI(e,uN,s),R=0,M={level:g,x:E,y:C,z:S},P={mortonIndex:0,localLevel:0,localX:0,localY:0,localZ:0}}else{I=t;R=(_**m-1)/(_-1)+B,M=i,P={mortonIndex:B,localLevel:m,localX:b,localY:w,localZ:T}}if(!YN(I.tileAvailability,R))return f;YN(I.contentAvailability,R)&&(f.contentUrl=tV(h,g,E,C,S));for(let e=0;e<_;e++){const t=XN(a,e,l),i=await JN({subtree:I,subtreeData:M,parentData:P,childIndex:e,implicitOptions:o,loaderOptions:s,s2VolumeBox:t});(i.contentUrl||i.children.length)&&f.children.push(i)}if(f.contentUrl||f.children.length){const e=function(e,t,i,n){const{basePath:r,refine:o,getRefine:s,lodMetricType:a,getTileType:l,rootLodMetricValue:c,rootBoundingVolume:u}=i,h=e.contentUrl&&e.contentUrl.replace(`${r}/`,""),d=c/2**t.level,p=n?.box?{box:n.box}:u,f=function(e,t,i){if(e.region){const{level:n,x:r,y:o,z:s}=t,[a,l,c,u,h,d]=e.region,p=2**n,f=(c-a)/p,[m,g]=[a+f*r,a+f*(r+1)],_=(u-l)/p,[A,y]=[l+_*o,l+_*(o+1)];let v,x;if("OCTREE"===i){const e=(d-h)/p;[v,x]=[h+e*s,h+e*(s+1)]}else[v,x]=[h,d];return{region:[m,A,g,y,v,x]}}if(e.box)return e;throw new Error(`Unsupported bounding volume type ${JSON.stringify(e)}`)}(p,t,i.subdivisionScheme);return{children:e.children,contentUrl:e.contentUrl,content:{uri:h},id:e.contentUrl,refine:s(o),type:l(e),lodMetricType:a,lodMetricValue:d,geometricError:d,transform:e.transform,boundingVolume:f}}(f,{level:g,x:E,y:C,z:S},o,a);return e}return f}function YN(e,t){let i;return Array.isArray(e)?(i=e[0],e.length>1&&Zu.once('Not supported extension "3DTILES_multiple_contents" has been detected')):i=e,"constant"in i?Boolean(i.constant):!!i.explicitBitstream&&function(e,t){const i=Math.floor(e/8),n=e%8;return 1==(t[i]>>n&1)}(t,i.explicitBitstream)}function eV(e,t,i){return(e<o[e])}function iV(e,t=""){if(!t)return XO.EMPTY;const i=t.split("?")[0].split(".").pop();switch(i){case"pnts":return XO.POINTCLOUD;case"i3dm":case"b3dm":case"glb":case"gltf":return XO.SCENEGRAPH;default:return i||XO.EMPTY}}function nV(e){switch(e){case"REPLACE":case"replace":return KO.REPLACE;case"ADD":case"add":return KO.ADD;default:return e}}function rV(e,t){if(/^[a-z][0-9a-z+.-]*:/i.test(t)){const i=new URL(e,`${t}/`);return decodeURI(i.toString())}return e.startsWith("/")?e:Fh(t,e)}function oV(e,t){if(!e)return null;let i;if(e.content){const n=e.content.uri||e.content?.url;void 0!==n&&(i=rV(n,t))}return{...e,id:i,contentUrl:i,lodMetricType:YO.GEOMETRIC_ERROR,lodMetricValue:e.geometricError,transformMatrix:e.transform,type:iV(0,i),refine:nV(e.refine)}}async function sV(e,t,i,n,r){const{subdivisionScheme:o,maximumLevel:s,availableLevels:a,subtreeLevels:l,subtrees:{uri:c}}=n,u=rV(tV(c,0,0,0,0),i),h=await dI(u,uN,r),d=e.content?.uri,p=d?rV(d,i):"",f=t?.root?.refine,m=e.geometricError,g=e.boundingVolume.extensions?.["3DTILES_bounding_volume_S2"];if(g){const t={box:qN(g),s2VolumeInfo:g};e.boundingVolume=t}const _=e.boundingVolume,A={contentUrlTemplate:p,subtreesUriTemplate:c,subdivisionScheme:o,subtreeLevels:l,maximumLevel:Number.isFinite(a)?a-1:s,refine:f,basePath:i,lodMetricType:YO.GEOMETRIC_ERROR,rootLodMetricValue:m,rootBoundingVolume:_,getTileType:iV,getRefine:nV};return await async function(e,t,i,n,r){if(!e)return null;const{children:o,contentUrl:s}=await JN({subtree:i,implicitOptions:n,loaderOptions:r});let a,l=null;s&&(a=s,l={uri:s.replace(`${t}/`,"")});const c={...e,id:a,contentUrl:a,lodMetricType:YO.GEOMETRIC_ERROR,lodMetricValue:e.geometricError,transformMatrix:e.transform,type:iV(0,a),refine:nV(e.refine),content:l||e.content,children:o};return c}(e,i,h,A,r)}function aV(e){return e?.extensions?.["3DTILES_implicit_tiling"]||e?.implicitTiling}const lV={dataType:null,batchType:null,id:"3d-tiles",name:"3D Tiles",module:"3d-tiles",version:qz,extensions:["cmpt","pnts","b3dm","i3dm"],mimeTypes:["application/octet-stream"],tests:["cmpt","pnts","b3dm","i3dm"],parse:async function(e,t={},i){const n=t["3d-tiles"]||{};let r;r="auto"===n.isTileset?i?.url&&-1!==i.url.indexOf(".json"):n.isTileset;return r?async function(e,t,i){const n=JSON.parse((new TextDecoder).decode(e)),r=i?.url||"",o=function(e){return Lh(e)}(r),s=await async function(e,t,i){let n=null;const r=aV(e.root);n=r&&e.root?await sV(e.root,e,t,r,i):oV(e.root,t);const o=[];for(o.push(n);o.length>0;){const n=o.pop()||{},r=n.children||[],s=[];for(const n of r){const r=aV(n);let a;a=r?await sV(n,e,t,r,i):oV(n,t),a&&(s.push(a),o.push(a))}n.children=s}return n}(n,o,t||{}),a={...n,shape:"tileset3d",loader:lV,url:r,queryString:i?.queryString||"",basePath:o,root:s||n.root,type:JO.TILES3D,lodMetricType:YO.GEOMETRIC_ERROR,lodMetricValue:n.root?.geometricError||0};return a}(e,t,i):async function(e,t,i){const n={content:{shape:"tile3d",featureIds:null}},r=0;return await aN(e,r,t,i,n.content),n.content}(e,t,i)},options:{"3d-tiles":{loadGLTF:!0,decodeQuantizedPositions:!1,isTileset:"auto",assetGltfUpAxis:null}}};const cV=[0],uV={getPointColor:{type:"accessor",value:[0,0,0,255]},pointSize:1,data:"",loader:lV,onTilesetLoad:{type:"function",value:e=>{}},onTileLoad:{type:"function",value:e=>{}},onTileUnload:{type:"function",value:e=>{}},onTileError:{type:"function",value:(e,t,i)=>{}},_getMeshColor:{type:"function",value:e=>[255,255,255]}};class hV extends pS{initializeState(){"onTileLoadFail"in this.props&&rp.removed("onTileLoadFail","onTileError")(),this.state={layerMap:{},tileset3d:null,activeViewports:{},lastUpdatedViewports:null}}get isLoaded(){return Boolean(this.state?.tileset3d?.isLoaded()&&super.isLoaded)}shouldUpdateState({changeFlags:e}){return e.somethingChanged}updateState({props:e,oldProps:t,changeFlags:i}){if(e.data&&e.data!==t.data&&this._loadTileset(e.data),i.viewportChanged){const{activeViewports:e}=this.state;Object.keys(e).length&&(this._updateTileset(e),this.state.lastUpdatedViewports=e,this.state.activeViewports={})}if(i.propsChanged){const{layerMap:e}=this.state;for(const t in e)e[t].needsUpdate=!0}}activateViewport(e){const{activeViewports:t,lastUpdatedViewports:i}=this.state;this.internalState.viewport=e,t[e.id]=e;const n=i?.[e.id];n&&e.equals(n)||(this.setChangeFlags({viewportChanged:!0}),this.setNeedsUpdate())}getPickingInfo({info:e,sourceLayer:t}){const i=t&&t.props.tile;return e.picked&&(e.object=i),e.sourceTile=i,e}filterSubLayer({layer:e,viewport:t}){const{tile:i}=e.props,{id:n}=t;return i.selected&&i.viewportIds.includes(n)}_updateAutoHighlight(e){const t=e.sourceTile,i=this.state.layerMap[t?.id];i&&i.layer&&i.layer.updateAutoHighlight(e)}async _loadTileset(e){const{loadOptions:t={}}=this.props,i=this.props.loader||this.props.loaders,n=Array.isArray(i)?i[0]:i,r={loadOptions:{...t}};let o=e;if(n.preload){const i=await n.preload(e,t);i.url&&(o=i.url),i.headers&&(r.loadOptions.fetch={...r.loadOptions.fetch,headers:i.headers}),Object.assign(r,i)}const s=await dI(o,n,r.loadOptions),a=new Wz(s,{onTileLoad:this._onTileLoad.bind(this),onTileUnload:this._onTileUnload.bind(this),onTileError:this.props.onTileError,...r});this.setState({tileset3d:a,layerMap:{}}),this._updateTileset(this.state.activeViewports),this.props.onTilesetLoad(a)}_onTileLoad(e){const{lastUpdatedViewports:t}=this.state;this.props.onTileLoad(e),this._updateTileset(t),this.setNeedsUpdate()}_onTileUnload(e){delete this.state.layerMap[e.id],this.props.onTileUnload(e)}_updateTileset(e){if(!e)return;const{tileset3d:t}=this.state,{timeline:i}=this.context,n=Object.keys(e).length;i&&n&&t&&t.selectTiles(Object.values(e)).then(e=>{this.state.frameNumber!==e&&this.setState({frameNumber:e})})}_getSubLayer(e,t){if(!e.content)return null;switch(e.type){case XO.POINTCLOUD:return this._makePointCloudLayer(e,t);case XO.SCENEGRAPH:return this._make3DModelLayer(e);case XO.MESH:return this._makeSimpleMeshLayer(e,t);default:throw new Error(`Tile3DLayer: Failed to render layer of type ${e.content.type}`)}}_makePointCloudLayer(e,t){const{attributes:i,pointCount:n,constantRGBA:r,cartographicOrigin:o,modelMatrix:s}=e.content,{positions:a,normals:l,colors:c}=i;if(!a)return null;const u=t&&t.props.data||{header:{vertexCount:n},attributes:{POSITION:a,NORMAL:l,COLOR_0:c}},{pointSize:h,getPointColor:d}=this.props;return new(this.getSubLayerClass("pointcloud",BI))({pointSize:h},this.getSubLayerProps({id:"pointcloud"}),{id:`${this.id}-pointcloud-${e.id}`,tile:e,data:u,coordinateSystem:xy.METER_OFFSETS,coordinateOrigin:o,modelMatrix:s,getColor:r||d,_offset:0})}_make3DModelLayer(e){const{gltf:t,instances:i,cartographicOrigin:n,modelMatrix:r}=e.content;return new(this.getSubLayerClass("scenegraph",lO))({_lighting:"pbr"},this.getSubLayerProps({id:"scenegraph"}),{id:`${this.id}-scenegraph-${e.id}`,tile:e,data:i||cV,scenegraph:t,coordinateSystem:xy.METER_OFFSETS,coordinateOrigin:n,modelMatrix:r,getTransformMatrix:e=>e.modelMatrix,getPosition:[0,0,0],_offset:0})}_makeSimpleMeshLayer(e,t){const i=e.content,{attributes:n,indices:r,modelMatrix:o,cartographicOrigin:s,coordinateSystem:a=xy.METER_OFFSETS,material:l,featureIds:c}=i,{_getMeshColor:u}=this.props,h=t&&t.props.mesh||new Cx({topology:"triangle-list",attributes:pV(n),indices:r});return new(this.getSubLayerClass("mesh",uO))(this.getSubLayerProps({id:"mesh"}),{id:`${this.id}-mesh-${e.id}`,tile:e,mesh:h,data:cV,getColor:u(e),pbrMaterial:l,modelMatrix:o,coordinateOrigin:s,coordinateSystem:a,featureIds:c,_offset:0})}renderLayers(){const{tileset3d:e,layerMap:t}=this.state;return e?e.tiles.map(e=>{const i=t[e.id]=t[e.id]||{tile:e};let{layer:n}=i;return e.selected&&(n?i.needsUpdate&&(n=this._getSubLayer(e,n),i.needsUpdate=!1):n=this._getSubLayer(e)),i.layer=n,n}).filter(Boolean):null}}hV.defaultProps=uV,hV.layerName="Tile3DLayer";var dV=hV;function pV(e){const t={};return t.positions={...e.positions,value:new Float32Array(e.positions.value)},e.normals&&(t.normals=e.normals),e.texCoords&&(t.texCoords=e.texCoords),e.colors&&(t.colors=e.colors),e.uvRegions&&(t.uvRegions=e.uvRegions),t}new Map([["centerX",Float64Array.BYTES_PER_ELEMENT],["centerY",Float64Array.BYTES_PER_ELEMENT],["centerZ",Float64Array.BYTES_PER_ELEMENT],["minHeight",Float32Array.BYTES_PER_ELEMENT],["maxHeight",Float32Array.BYTES_PER_ELEMENT],["boundingSphereCenterX",Float64Array.BYTES_PER_ELEMENT],["boundingSphereCenterY",Float64Array.BYTES_PER_ELEMENT],["boundingSphereCenterZ",Float64Array.BYTES_PER_ELEMENT],["boundingSphereRadius",Float64Array.BYTES_PER_ELEMENT],["horizonOcclusionPointX",Float64Array.BYTES_PER_ELEMENT],["horizonOcclusionPointY",Float64Array.BYTES_PER_ELEMENT],["horizonOcclusionPointZ",Float64Array.BYTES_PER_ELEMENT]]);function fV(e,t,i,n){const r=n?function(e,t){e.westIndices.sort((e,i)=>t[3*e+1]-t[3*i+1]),e.eastIndices.sort((e,i)=>t[3*i+1]-t[3*e+1]),e.southIndices.sort((e,i)=>t[3*i]-t[3*e]),e.northIndices.sort((e,i)=>t[3*e]-t[3*i]);const i=[];for(const t in e){const n=e[t];for(let e=0;eMath.min(...e)-Math.min(...t)||Math.max(...e)-Math.max(...t));const i=[];let n=0;for(;n>=1)>1;){const e=n+o>>1,t=r+s>>1;1&i?(o=n,s=r,n=a,r=l):(n=o,r=s,o=a,s=l),a=e,l=t}const c=4*e;this.coords[c+0]=n,this.coords[c+1]=r,this.coords[c+2]=o,this.coords[c+3]=s}}createTile(e){return new _V(e,this)}}class _V{constructor(e,t){const i=t.gridSize;if(e.length!==i*i)throw new Error(`Expected terrain data of length ${i*i} (${i} x ${i}), got ${e.length}.`);this.terrain=e,this.martini=t,this.errors=new Float32Array(e.length),this.update()}update(){const{numTriangles:e,numParentTriangles:t,coords:i,gridSize:n}=this.martini,{terrain:r,errors:o}=this;for(let s=e-1;s>=0;s--){const e=4*s,a=i[e+0],l=i[e+1],c=i[e+2],u=i[e+3],h=a+c>>1,d=l+u>>1,p=h+d-l,f=d+a-h,m=(r[l*n+a]+r[u*n+c])/2,g=d*n+h,_=Math.abs(m-r[g]);if(o[g]=Math.max(o[g],_),s>1)*n+(a+p>>1),t=(u+f>>1)*n+(c+p>>1);o[g]=Math.max(o[g],o[e],o[t])}}}getMesh(e=0){const{gridSize:t,indices:i}=this.martini,{errors:n}=this;let r=0,o=0;const s=t-1;function a(s,l,c,u,h,d){const p=s+c>>1,f=l+u>>1;Math.abs(s-h)+Math.abs(l-d)>1&&n[f*t+p]>e?(a(h,d,s,l,p,f),a(c,u,h,d,p,f)):(i[l*t+s]=i[l*t+s]||++r,i[u*t+c]=i[u*t+c]||++r,i[d*t+h]=i[d*t+h]||++r,o++)}i.fill(0),a(0,0,s,s,s,0),a(s,s,0,0,0,s);const l=new Uint16Array(2*r),c=new Uint32Array(3*o);let u=0;function h(r,o,s,a,d,p){const f=r+s>>1,m=o+a>>1;if(Math.abs(r-d)+Math.abs(o-p)>1&&n[m*t+f]>e)h(d,p,r,o,f,m),h(s,a,d,p,f,m);else{const e=i[o*t+r]-1,n=i[a*t+s]-1,h=i[p*t+d]-1;l[2*e]=r,l[2*e+1]=o,l[2*n]=s,l[2*n+1]=a,l[2*h]=d,l[2*h+1]=p,c[u++]=e,c[u++]=n,c[u++]=h}}return h(0,0,s,s,s,0),h(s,s,0,0,0,s),{vertices:l,triangles:c}}}class AV{constructor(e,t,i=t){this.data=e,this.width=t,this.height=i,this.coords=[],this.triangles=[],this._halfedges=[],this._candidates=[],this._queueIndices=[],this._queue=[],this._errors=[],this._rms=[],this._pending=[],this._pendingLen=0,this._rmsSum=0;const n=t-1,r=i-1,o=this._addPoint(0,0),s=this._addPoint(n,0),a=this._addPoint(0,r),l=this._addPoint(n,r),c=this._addTriangle(l,o,a,-1,-1,-1);this._addTriangle(o,l,s,c,-1,-1),this._flush()}run(e=1){for(;this.getMaxError()>e;)this.refine()}refine(){this._step(),this._flush()}getMaxError(){return this._errors[0]}getRMSD(){return this._rmsSum>0?Math.sqrt(this._rmsSum/(this.width*this.height)):0}heightAt(e,t){return this.data[this.width*t+e]}_flush(){const e=this.coords;for(let t=0;t=0&&n>=0&&r>=0){o=!0;const t=x*i+b*n+w*r,a=Math.abs(t-this.heightAt(s,e));S+=a*a,a>T&&(T=a,E=s,C=e)}else if(o)break;i+=g,n+=A,r+=f}h+=_,d+=y,p+=m}(E===e&&C===t||E===i&&C===n||E===r&&C===o)&&(T=0),this._candidates[2*s]=E,this._candidates[2*s+1]=C,this._rms[s]=S,this._queuePush(s,T,S)}_step(){const e=this._queuePop(),t=3*e+0,i=3*e+1,n=3*e+2,r=this.triangles[t],o=this.triangles[i],s=this.triangles[n],a=this.coords[2*r],l=this.coords[2*r+1],c=this.coords[2*o],u=this.coords[2*o+1],h=this.coords[2*s],d=this.coords[2*s+1],p=this._candidates[2*e],f=this._candidates[2*e+1],m=this._addPoint(p,f);if(0===yV(a,l,c,u,p,f))this._handleCollinear(m,t);else if(0===yV(c,u,h,d,p,f))this._handleCollinear(m,i);else if(0===yV(h,d,a,l,p,f))this._handleCollinear(m,n);else{const e=this._halfedges[t],a=this._halfedges[i],l=this._halfedges[n],c=this._addTriangle(r,o,m,e,-1,-1,t),u=this._addTriangle(o,s,m,a,-1,c+1),h=this._addTriangle(s,r,m,l,c+2,u+1);this._legalize(c),this._legalize(u),this._legalize(h)}}_addPoint(e,t){const i=this.coords.length>>1;return this.coords.push(e,t),i}_addTriangle(e,t,i,n,r,o,s=this.triangles.length){const a=s/3;return this.triangles[s+0]=e,this.triangles[s+1]=t,this.triangles[s+2]=i,this._halfedges[s+0]=n,this._halfedges[s+1]=r,this._halfedges[s+2]=o,n>=0&&(this._halfedges[n]=s+0),r>=0&&(this._halfedges[r]=s+1),o>=0&&(this._halfedges[o]=s+2),this._candidates[2*a+0]=0,this._candidates[2*a+1]=0,this._queueIndices[a]=-1,this._rms[a]=0,this._pending[this._pendingLen++]=a,s}_legalize(e){const t=this._halfedges[e];if(t<0)return;const i=e-e%3,n=t-t%3,r=i+(e+1)%3,o=i+(e+2)%3,s=n+(t+2)%3,a=n+(t+1)%3,l=this.triangles[o],c=this.triangles[e],u=this.triangles[r],h=this.triangles[s],d=this.coords;if(!function(e,t,i,n,r,o,s,a){const l=e-s,c=t-a,u=i-s,h=n-a,d=r-s,p=o-a,f=l*l+c*c,m=u*u+h*h,g=d*d+p*p;return l*(h*g-m*p)-c*(u*g-m*d)+f*(u*p-h*d)<0}(d[2*l],d[2*l+1],d[2*c],d[2*c+1],d[2*u],d[2*u+1],d[2*h],d[2*h+1]))return;const p=this._halfedges[r],f=this._halfedges[o],m=this._halfedges[s],g=this._halfedges[a];this._queueRemove(i/3),this._queueRemove(n/3);const _=this._addTriangle(l,h,u,-1,m,p,i),A=this._addTriangle(h,l,c,_,f,g,n);this._legalize(_+1),this._legalize(A+2)}_handleCollinear(e,t){const i=t-t%3,n=i+(t+1)%3,r=i+(t+2)%3,o=this.triangles[r],s=this.triangles[t],a=this.triangles[n],l=this._halfedges[n],c=this._halfedges[r],u=this._halfedges[t];if(u<0){const t=this._addTriangle(e,o,s,-1,c,-1,i),n=this._addTriangle(o,e,a,t,-1,l);return this._legalize(t+1),void this._legalize(n+2)}const h=u-u%3,d=h+(u+2)%3,p=h+(u+1)%3,f=this.triangles[d],m=this._halfedges[d],g=this._halfedges[p];this._queueRemove(h/3);const _=this._addTriangle(o,s,e,c,-1,-1,i),A=this._addTriangle(s,f,e,g,-1,_+1,h),y=this._addTriangle(f,a,e,m,-1,A+1),v=this._addTriangle(a,o,e,l,_+2,y+1);this._legalize(_),this._legalize(A),this._legalize(y),this._legalize(v)}_queuePush(e,t,i){const n=this._queue.length;this._queueIndices[e]=n,this._queue.push(e),this._errors.push(t),this._rmsSum+=i,this._queueUp(n)}_queuePop(){const e=this._queue.length-1;return this._queueSwap(0,e),this._queueDown(0,e),this._queuePopBack()}_queuePopBack(){const e=this._queue.pop();return this._errors.pop(),this._rmsSum-=this._rms[e],this._queueIndices[e]=-1,e}_queueRemove(e){const t=this._queueIndices[e];if(t<0){const t=this._pending.indexOf(e);if(-1===t)throw new Error("Broken triangulation (something went wrong).");return void(this._pending[t]=this._pending[--this._pendingLen])}const i=this._queue.length-1;i!==t&&(this._queueSwap(t,i),this._queueDown(t,i)||this._queueUp(t)),this._queuePopBack()}_queueLess(e,t){return this._errors[e]>this._errors[t]}_queueSwap(e,t){const i=this._queue[e],n=this._queue[t];this._queue[e]=n,this._queue[t]=i,this._queueIndices[i]=t,this._queueIndices[n]=e;const r=this._errors[e];this._errors[e]=this._errors[t],this._errors[t]=r}_queueUp(e){let t=e;for(;;){const e=t-1>>1;if(e===t||!this._queueLess(t,e))break;this._queueSwap(e,t),t=e}}_queueDown(e,t){let i=e;for(;;){const e=2*i+1;if(e>=t||e<0)break;const n=e+1;let r=e;if(ne}}function yV(e,t,i,n,r,o){return(i-r)*(t-o)-(n-o)*(e-r)}function vV(e,t){const{meshMaxError:i,bounds:n,elevationDecoder:r}=t,{data:o,width:s,height:a}=e;let l,c;switch(t.tesselator){case"martini":l=wV(o,s,a,r,t.tesselator),c=xV(i,s,l);break;case"delatin":l=wV(o,s,a,r,t.tesselator),c=bV(i,s,a,l);break;default:s!==a||a&s-1?(l=wV(o,s,a,r,"delatin"),c=bV(i,s,a,l)):(l=wV(o,s,a,r,"martini"),c=xV(i,s,l))}const{vertices:u}=c;let{triangles:h}=c,d=function(e,t,i,n,r){const o=i+1,s=e.length/2,a=new Float32Array(3*s),l=new Float32Array(2*s),[c,u,h,d]=r||[0,0,i,n],p=(h-c)/i,f=(d-u)/n;for(let r=0;rnull):Promise.resolve(null);return Promise.all([p,f])}renderSubLayers(e){const t=this.getSubLayerClass("mesh",BL),{color:i,wireframe:n,material:r}=this.props,{data:o}=e;if(!o)return null;const[s,a]=o;return new t(e,{data:SV,mesh:s,texture:a,_instanced:!1,coordinateSystem:xy.CARTESIAN,getPosition:e=>[0,0,0],getColor:i,wireframe:n,material:r})}onViewportLoad(e){if(!e)return;const{zRange:t}=this.state,i=e.map(e=>e.content).filter(Boolean).map(e=>e[0].header.boundingBox.map(e=>e[2]));if(0===i.length)return;const n=Math.min(...i.map(e=>e[0])),r=Math.max(...i.map(e=>e[1]));(!t||nt[1])&&this.setState({zRange:[n,r]})}renderLayers(){const{color:e,material:t,elevationData:i,texture:n,wireframe:r,meshMaxError:o,elevationDecoder:s,tileSize:a,maxZoom:l,minZoom:c,extent:u,maxRequests:h,onTileLoad:d,onTileUnload:p,onTileError:f,maxCacheSize:m,maxCacheByteSize:g,refinementStrategy:_}=this.props;if(this.state.isTiled)return new mL(this.getSubLayerProps({id:"tiles"}),{getTileData:this.getTiledTerrainData.bind(this),renderSubLayers:this.renderSubLayers.bind(this),updateTriggers:{getTileData:{elevationData:IV(i),texture:IV(n),meshMaxError:o,elevationDecoder:s}},onViewportLoad:this.onViewportLoad.bind(this),zRange:this.state.zRange||null,tileSize:a,maxZoom:l,minZoom:c,extent:u,maxRequests:h,onTileLoad:d,onTileUnload:p,onTileError:f,maxCacheSize:m,maxCacheByteSize:g,refinementStrategy:_});if(!i)return null;return new(this.getSubLayerClass("mesh",BL))(this.getSubLayerProps({id:"mesh"}),{data:SV,mesh:this.state.terrain,texture:n,_instanced:!1,getPosition:e=>[0,0,0],getColor:e,material:t,wireframe:r})}}MV.defaultProps=BV,MV.layerName="TerrainLayer";var PV=MV;function RV(e,t){const i=[1/0,1/0,-1/0,-1/0];for(const n of e){const e=n.getBounds();if(e){const r=n.projectPosition(e[0],{viewport:t,autoOffset:!1}),o=n.projectPosition(e[1],{viewport:t,autoOffset:!1});i[0]=Math.min(i[0],r[0]),i[1]=Math.min(i[1],r[1]),i[2]=Math.max(i[2],o[0]),i[3]=Math.max(i[3],o[1])}}return Number.isFinite(i[0])?i:null}function LV(e){const{bounds:t,viewport:i,border:n=0}=e,{isGeospatial:r}=i;if(t[2]<=t[0]||t[3]<=t[1])return null;const o=i.unprojectPosition([(t[0]+t[2])/2,(t[1]+t[3])/2,0]);let{width:s,height:a,zoom:l}=e;if(void 0===l){s-=2*n,a-=2*n;const e=Math.min(s/(t[2]-t[0]),a/(t[3]-t[1]));l=Math.min(Math.log2(e),20)}else if(!s||!a){const e=2**l;s=Math.round(Math.abs(t[2]-t[0])*e),a=Math.round(Math.abs(t[3]-t[1])*e);const i=2048-2*n;if(s>i||a>i){const e=i/Math.max(s,a);s=Math.round(s*e),a=Math.round(a*e),l+=Math.log2(e)}}return r?new Xv({id:i.id,x:n,y:n,width:s,height:a,longitude:o[0],latitude:o[1],zoom:l,orthographic:!0}):new wS({id:i.id,x:n,y:n,width:s,height:a,target:o,zoom:l,flipY:!1})}function FV(e,t,i){if(!e)return[0,0,1,1];const n=function(e,t){let i;if(t&&2===t.length){const[n,r]=t,o=e.getBounds({z:n}),s=e.getBounds({z:r});i=[Math.min(o[0],s[0]),Math.min(o[1],s[1]),Math.max(o[2],s[2]),Math.max(o[3],s[3])]}else i=e.getBounds();const n=e.projectPosition(i.slice(0,2)),r=e.projectPosition(i.slice(2,4));return[n[0],n[1],r[0],r[1]]}(t,i),r=function(e){const t=e[2]-e[0],i=e[3]-e[1],n=(e[0]+e[2])/2,r=(e[1]+e[3])/2;return[n-t,r-i,n+t,r+i]}(n);return e[2]-e[0]<=r[2]-r[0]&&e[3]-e[1]<=r[3]-r[1]?e:[Math.max(e[0],r[0]),Math.max(e[1],r[1]),Math.min(e[2],r[2]),Math.min(e[3],r[3])]}const kV={NONE:0,WRITE_HEIGHT_MAP:1,USE_HEIGHT_MAP:2,USE_COVER:3,USE_COVER_ONLY:4,SKIP:5},DV=Object.keys(kV).map(e=>`const float TERRAIN_MODE_${e} = ${kV[e]}.0;`).join("\n"),OV={name:"terrain",dependencies:[Oy],inject:{"vs:#decl":"\nuniform float terrain_mode;\nuniform sampler2D terrain_map;\nuniform vec4 terrain_bounds;\nout vec3 commonPos;\n"+DV,"vs:#main-start":"\nif (terrain_mode == TERRAIN_MODE_SKIP) {\ngl_Position = vec4(0.0);\nreturn;\n}\n","vs:DECKGL_FILTER_GL_POSITION":"\ncommonPos = geometry.position.xyz;\nif (terrain_mode == TERRAIN_MODE_WRITE_HEIGHT_MAP) {\nvec2 texCoords = (commonPos.xy - terrain_bounds.xy) / terrain_bounds.zw;\nposition = vec4(texCoords * 2.0 - 1.0, 0.0, 1.0);\ncommonPos.z += project_uCommonOrigin.z;\n}\nif (terrain_mode == TERRAIN_MODE_USE_HEIGHT_MAP) {\nvec3 anchor = geometry.worldPosition;\nanchor.z = 0.0;\nvec3 anchorCommon = project_position(anchor);\nvec2 texCoords = (anchorCommon.xy - terrain_bounds.xy) / terrain_bounds.zw;\nif (texCoords.x >= 0.0 && texCoords.y >= 0.0 && texCoords.x <= 1.0 && texCoords.y <= 1.0) {\nfloat terrainZ = texture(terrain_map, texCoords).r;\ngeometry.position.z += terrainZ;\nposition = project_common_position_to_clipspace(geometry.position);\n}\n}\n","fs:#decl":"\nuniform float terrain_mode;\nuniform sampler2D terrain_map;\nuniform vec4 terrain_bounds;\nin vec3 commonPos;\n"+DV,"fs:#main-start":"\nif (terrain_mode == TERRAIN_MODE_WRITE_HEIGHT_MAP) {\nfragColor = vec4(commonPos.z, 0.0, 0.0, 1.0);\nreturn;\n}\n","fs:DECKGL_FILTER_COLOR":"\nif ((terrain_mode == TERRAIN_MODE_USE_COVER) || (terrain_mode == TERRAIN_MODE_USE_COVER_ONLY)) {\nvec2 texCoords = (commonPos.xy - terrain_bounds.xy) / terrain_bounds.zw;\nvec4 pixel = texture(terrain_map, texCoords);\nif (terrain_mode == TERRAIN_MODE_USE_COVER_ONLY) {\ncolor = pixel;\n} else {\ncolor = pixel + color * (1.0 - pixel.a);\n}\nreturn;\n}\n"},getUniforms:(e={},t)=>{if("dummyHeightMap"in e){const{drawToTerrainHeightMap:i,heightMap:n,heightMapBounds:r,dummyHeightMap:o,terrainCover:s,useTerrainHeightMap:a,terrainSkipRender:l}=e,{project_uCommonOrigin:c}=t;let u=l?kV.SKIP:kV.NONE,h=o,d=null;if(i)u=kV.WRITE_HEIGHT_MAP,d=r;else if(a&&n)u=kV.USE_HEIGHT_MAP,h=n,d=r;else if(s){const t=e.picking?.isActive,i=t?s.getPickingFramebuffer():s.getRenderFramebuffer();h=i?.colorAttachments[0].texture,t&&(u=kV.SKIP),h?(u=u===kV.SKIP?kV.USE_COVER_ONLY:kV.USE_COVER,d=s.bounds):h=o}return{terrain_mode:u,terrain_map:h,terrain_bounds:d?[d[0]-c[0],d[1]-c[1],d[2]-d[0],d[3]-d[1]]:[0,0,0,0]}}return null}};function zV(e,t){return e.createFramebuffer({id:t.id,colorAttachments:[e.createTexture({id:t.id,...t.float&&{format:"rgba32float",type:5126},mipmaps:!1,sampler:!1===t.interpolate?{minFilter:"nearest",magFilter:"nearest"}:{minFilter:"linear",magFilter:"linear"}})]})}class UV{constructor(e){this.isDirty=!0,this.renderViewport=null,this.bounds=null,this.layers=[],this.targetBounds=null,this.targetBoundsCommon=null,this.targetLayer=e,this.tile=NV(e)}get id(){return this.targetLayer.id}get isActive(){return Boolean(this.targetLayer.getCurrentLayer())}shouldUpdate({targetLayer:e,viewport:t,layers:i,layerNeedsRedraw:n}){e&&(this.targetLayer=e);const r=!!t&&this._updateViewport(t);let o=!!i&&this._updateLayers(i);if(n)for(const e of this.layers)if(n[e]){o=!0;break}return o||r}_updateLayers(e){let t=!1;if((e=this.tile?function(e,t){return t.filter(t=>{const i=NV(t);return!i||function(e,t){if(e&&t)return e[0][0]e.id)),t}_updateViewport(e){const t=this.targetLayer;let i=!1;if(this.tile&&"boundingBox"in this.tile){if(!this.targetBounds){i=!0,this.targetBounds=this.tile.boundingBox;const t=e.projectPosition(this.targetBounds[0]),n=e.projectPosition(this.targetBounds[1]);this.targetBoundsCommon=[t[0],t[1],n[0],n[1]]}}else this.targetBounds!==t.getBounds()&&(i=!0,this.targetBounds=t.getBounds(),this.targetBoundsCommon=RV([t],e));if(!this.targetBoundsCommon)return!1;const n=Math.ceil(e.zoom+.5);if(this.tile)this.bounds=this.targetBoundsCommon;else{const t=this.renderViewport?.zoom;i=i||n!==t;const r=FV(this.targetBoundsCommon,e),o=this.bounds;i=i||!o||r.some((e,t)=>e!==o[t]),this.bounds=r}return i&&(this.renderViewport=LV({bounds:this.bounds,zoom:n,viewport:e})),i}getRenderFramebuffer(){return this.renderViewport&&0!==this.layers.length?(this.fbo||(this.fbo=zV(this.targetLayer.context.device,{id:this.id})),this.fbo):null}getPickingFramebuffer(){return!this.renderViewport||0===this.layers.length&&!this.targetLayer.props.pickable?null:(this.pickingFbo||(this.pickingFbo=zV(this.targetLayer.context.device,{id:`${this.id}-picking`,interpolate:!1})),this.pickingFbo)}filterLayers(e){return e.filter(({id:e})=>this.layers.includes(e))}delete(){const{fbo:e,pickingFbo:t}=this;e&&(e.colorAttachments[0].destroy(),e.destroy()),t&&(t.colorAttachments[0].destroy(),t.destroy())}}function NV(e){for(;e;){const{tile:t}=e.props;if(t)return t;e=e.parent}return null}const VV={blendColorOperation:"max",blendColorSrcFactor:"one",blendColorDstFactor:"one",blendAlphaOperation:"max",blendAlphaSrcFactor:"one",blendAlphaDstFactor:"one"};class jV extends Mv{getRenderableLayers(e,t){const{layers:i}=t,n=[],r=this._getDrawLayerParams(e,t,!0);for(let e=0;ee!==this.layers[t]||e.props.transitions||e.getBounds()!==this.layersBounds[t]);i&&(this.layers=e,this.layersBounds=e.map(e=>e.getBounds()),this.layersBoundsCommon=RV(e,t));const n=!this.lastViewport||!t.equals(this.lastViewport);if(this.layersBoundsCommon){if(i||n){const e=FV(this.layersBoundsCommon,t);if(e[2]<=e[0]||e[3]<=e[1])return this.renderViewport=null,!1;this.bounds=e,this.lastViewport=t;const i=t.scale,n=(e[2]-e[0])*i,r=(e[3]-e[1])*i;return this.renderViewport=n>0||r>0?LV({bounds:[t.center[0]-1,t.center[1]-1,t.center[0]+1,t.center[1]+1],zoom:t.zoom,width:Math.min(n,2048),height:Math.min(r,2048),viewport:t}):null,!0}}else this.renderViewport=null;return!1}delete(){this.fbo&&(this.fbo.colorAttachments[0].delete(),this.fbo.delete())}}class QV{constructor(){this.id="terrain-effect",this.props=null,this.useInPicking=!0,this.isPicking=!1,this.isDrapingEnabled=!1,this.terrainCovers=new Map}setup({device:e,deck:t}){this.dummyHeightMap=e.createTexture({width:1,height:1,data:new Uint8Array([0,0,0,0])}),this.terrainPass=new jV(e,{id:"terrain"}),this.terrainPickingPass=new GV(e,{id:"terrain-picking"}),HV.isSupported(e)?this.heightMap=new HV(e):rp.warn("Terrain offset mode is not supported by this browser")(),t._addDefaultShaderModule(OV)}preRender(e){if(e.pickZ)return void(this.isDrapingEnabled=!1);const{viewports:t}=e,i=e.pass.startsWith("picking");this.isPicking=i,this.isDrapingEnabled=!0;const n=t[0],r=(i?this.terrainPickingPass:this.terrainPass).getRenderableLayers(n,e),o=r.filter(e=>e.props.operation.includes("terrain"));if(0===o.length)return;if(!i){const t=r.filter(e=>"offset"===e.state.terrainDrawMode);t.length>0&&this._updateHeightMap(o,n,e)}const s=r.filter(e=>"drape"===e.state.terrainDrawMode);this._updateTerrainCovers(o,s,n,e)}getModuleParameters(e){const{terrainDrawMode:t}=e.state;return{heightMap:this.heightMap?.getRenderFramebuffer()?.colorAttachments[0].texture||null,heightMapBounds:this.heightMap?.bounds,dummyHeightMap:this.dummyHeightMap,terrainCover:this.isDrapingEnabled?this.terrainCovers.get(e.id):null,useTerrainHeightMap:"offset"===t,terrainSkipRender:"drape"===t||!e.props.operation.includes("draw")}}cleanup({deck:e}){this.dummyHeightMap&&(this.dummyHeightMap.delete(),this.dummyHeightMap=void 0),this.heightMap&&(this.heightMap.delete(),this.heightMap=void 0);for(const e of this.terrainCovers.values())e.delete();this.terrainCovers.clear(),e._removeDefaultShaderModule(OV)}_updateHeightMap(e,t,i){if(!this.heightMap)return;this.heightMap.shouldUpdate({layers:e,viewport:t})&&this.terrainPass.renderHeightMap(this.heightMap,{...i,layers:e,moduleParameters:{heightMapBounds:this.heightMap.bounds,dummyHeightMap:this.dummyHeightMap,devicePixelRatio:1,drawToTerrainHeightMap:!0}})}_updateTerrainCovers(e,t,i,n){const r={};for(const e of t)e.state.terrainCoverNeedsRedraw&&(r[e.id]=!0,e.state.terrainCoverNeedsRedraw=!1);for(const e of this.terrainCovers.values())e.isDirty=e.isDirty||e.shouldUpdate({layerNeedsRedraw:r});for(const r of e)this._updateTerrainCover(r,t,i,n);this.isPicking||this._pruneTerrainCovers()}_updateTerrainCover(e,t,i,n){const r=this.isPicking?this.terrainPickingPass:this.terrainPass;let o=this.terrainCovers.get(e.id);o||(o=new UV(e),this.terrainCovers.set(e.id,o));try{const s=o.shouldUpdate({targetLayer:e,viewport:i,layers:t});(this.isPicking||o.isDirty||s)&&(r.renderTerrainCover(o,{...n,layers:t,moduleParameters:{dummyHeightMap:this.dummyHeightMap,terrainSkipRender:!1,devicePixelRatio:1}}),this.isPicking||(o.isDirty=!1))}catch(t){e.raiseError(t,`Error rendering terrain cover ${o.id}`)}}_pruneTerrainCovers(){const e=[];for(const[t,i]of this.terrainCovers)i.isActive||e.push(t);for(const t of e)this.terrainCovers.delete(t)}}const $V={terrainDrawMode:void 0};class ZV extends ES{getShaders(){return{modules:[OV]}}initializeState(){this.context.deck?._addDefaultEffect(new QV)}updateState(e){const{props:t,oldProps:i}=e;if(this.state.terrainDrawMode&&t.terrainDrawMode===i.terrainDrawMode&&t.extruded===i.extruded)return;let{terrainDrawMode:n}=t;if(!n){const e=this.props.extruded,t=this.getAttributeManager()?.attributes;n=e||t&&"instancePositions"in t?"offset":"drape"}this.setState({terrainDrawMode:n})}onNeedsRedraw(){const e=this.state;"drape"===e.terrainDrawMode&&(e.terrainCoverNeedsRedraw=!0)}}ZV.defaultProps=$V,ZV.extensionName="TerrainExtension";var WV=ZV;async function qV(e,t,i,n){return n._parse(e,t,i,n)}function KV(e,t){if(!e)throw new Error(t||"loader assertion failed.")}const XV=Boolean("object"!=typeof process||"[object process]"!==String(process)||process.browser),JV="undefined"!=typeof process&&process.version&&/v([0-9]*)/.exec(process.version);function YV(e,t,i){if(e.byteLength<=t+i)return"";const n=new DataView(e);let r="";for(let e=0;e=0),KV(t>0),e+(t-1)&~(t-1)}function nj(e,t,i){let n;if(e instanceof ArrayBuffer)n=new Uint8Array(e);else{const t=e.byteOffset,i=e.byteLength;n=new Uint8Array(e.buffer||e.arrayBuffer,t,i)}return t.set(n,i),i+ij(n.byteLength,4)}function rj(){if("undefined"!=typeof process&&void 0!==process.cwd)return process.cwd();const e=window.location?.pathname;return e?.slice(0,e.lastIndexOf("/")+1)||""}function oj(...e){const t=[];for(let i=0;i=-1&&!r;e--){let o;e>=0?o=t[e]:(void 0===i&&(i=rj()),o=i),0!==o.length&&(n=`${o}/${n}`,r=o.charCodeAt(0)===sj)}return n=function(e,t){let i,n="",r=-1,o=0,s=!1;for(let a=0;a<=e.length;++a){if(a2){const e=n.length-1;let t=e;for(;t>=0&&n.charCodeAt(t)!==sj;--t);if(t!==e){n=-1===t?"":n.slice(0,t),r=a,o=0,s=!1;continue}}else if(2===n.length||1===n.length){n="",r=a,o=0,s=!1;continue}t&&(n.length>0?n+="/..":n="..",s=!0)}else{const t=e.slice(r+1,a);n.length>0?n+=`/${t}`:n=t,s=!1}r=a,o=0}else i===aj&&-1!==o?++o:o=-1}return n}(n,!r),r?`/${n}`:n.length>0?n:"."}JV&&parseFloat(JV[1]);const sj=47,aj=46;var lj,cj,uj,hj;!function(e){e[e.ADD=1]="ADD",e[e.REPLACE=2]="REPLACE"}(lj||(lj={})),function(e){e.EMPTY="empty",e.SCENEGRAPH="scenegraph",e.POINTCLOUD="pointcloud",e.MESH="mesh"}(cj||(cj={})),function(e){e.I3S="I3S",e.TILES3D="TILES3D"}(uj||(uj={})),function(e){e.GEOMETRIC_ERROR="geometricError",e.MAX_SCREEN_THRESHOLD="maxScreenThreshold"}(hj||(hj={}));const dj="4.2.4",pj="cmpt",fj="pnts",mj="b3dm",gj="i3dm",_j="glTF";function Aj(e,t,i){KV(e instanceof ArrayBuffer);const n=new TextDecoder("utf8"),r=new Uint8Array(e,t,i);return n.decode(r)}const yj="4.2.4",vj={dataType:null,batchType:null,name:"Draco",id:"draco",module:"draco",version:yj,worker:!0,extensions:["drc"],mimeTypes:["application/octet-stream"],binary:!0,tests:["DRACO"],options:{draco:{decoderType:"object"==typeof WebAssembly?"wasm":"js",libraryPath:"libs/",extraAttributes:{},attributeNameEntry:void 0}}};function xj(e,t,i){const n=function(e){switch(e.constructor){case Int8Array:return"int8";case Uint8Array:case Uint8ClampedArray:return"uint8";case Int16Array:return"int16";case Uint16Array:return"uint16";case Int32Array:return"int32";case Uint32Array:return"uint32";case Float32Array:return"float32";case Float64Array:return"float64";default:return"null"}}(t.value),r=i||function(e){const t={};"byteOffset"in e&&(t.byteOffset=e.byteOffset.toString(10));"byteStride"in e&&(t.byteStride=e.byteStride.toString(10));"normalized"in e&&(t.normalized=e.normalized.toString());return t}(t);return{name:e,type:{type:"fixed-size-list",listSize:t.size,children:[{name:"value",type:n}]},nullable:!1,metadata:r}}function bj(e,t,i){return xj(e,t,i?wj(i.metadata):void 0)}function wj(e){const t={};for(const i in e)t[`${i}.string`]=JSON.stringify(e[i]);return t}const Tj={POSITION:"POSITION",NORMAL:"NORMAL",COLOR:"COLOR_0",TEX_COORD:"TEXCOORD_0"},Ej={1:Int8Array,2:Uint8Array,3:Int16Array,4:Uint16Array,5:Int32Array,6:Uint32Array,9:Float32Array};class Cj{draco;decoder;metadataQuerier;constructor(e){this.draco=e,this.decoder=new this.draco.Decoder,this.metadataQuerier=new this.draco.MetadataQuerier}destroy(){this.draco.destroy(this.decoder),this.draco.destroy(this.metadataQuerier)}parseSync(e,t={}){const i=new this.draco.DecoderBuffer;i.Init(new Int8Array(e),e.byteLength),this._disableAttributeTransforms(t);const n=this.decoder.GetEncodedGeometryType(i),r=n===this.draco.TRIANGULAR_MESH?new this.draco.Mesh:new this.draco.PointCloud;try{let e;switch(n){case this.draco.TRIANGULAR_MESH:e=this.decoder.DecodeBufferToMesh(i,r);break;case this.draco.POINT_CLOUD:e=this.decoder.DecodeBufferToPointCloud(i,r);break;default:throw new Error("DRACO: Unknown geometry type.")}if(!e.ok()||!r.ptr){const t=`DRACO decompression failed: ${e.error_msg()}`;throw new Error(t)}const o=this._getDracoLoaderData(r,n,t),s=this._getMeshData(r,o,t),a=function(e){let t=1/0,i=1/0,n=1/0,r=-1/0,o=-1/0,s=-1/0;const a=e.POSITION?e.POSITION.value:[],l=a&&a.length;for(let e=0;er?l:r,o=c>o?c:o,s=u>s?u:s}return[[t,i,n],[r,o,s]]}(s.attributes),l=function(e,t,i){const n=wj(t.metadata),r=[],o=function(e){const t={};for(const i in e){const n=e[i];t[n.name||"undefined"]=n}return t}(t.attributes);for(const t in e){const i=bj(t,e[t],o[t]);r.push(i)}if(i){const e=bj("indices",i);r.push(e)}return{fields:r,metadata:n}}(s.attributes,o,s.indices);return{loader:"draco",loaderData:o,header:{vertexCount:r.num_points(),boundingBox:a},...s,schema:l}}finally{this.draco.destroy(i),r&&this.draco.destroy(r)}}_getDracoLoaderData(e,t,i){const n=this._getTopLevelMetadata(e),r=this._getDracoAttributes(e,i);return{geometry_type:t,num_attributes:e.num_attributes(),num_points:e.num_points(),num_faces:e instanceof this.draco.Mesh?e.num_faces():0,metadata:n,attributes:r}}_getDracoAttributes(e,t){const i={};for(let n=0;nthis.decoder[e]).includes(n);if(r){const t=new this.draco.AttributeQuantizationTransform;try{if(t.InitFromAttribute(e))return{quantization_bits:t.quantization_bits(),range:t.range(),min_values:new Float32Array([1,2,3]).map(e=>t.min_value(e))}}finally{this.draco.destroy(t)}}return null}_getOctahedronTransform(e,t){const{octahedronAttributes:i=[]}=t,n=e.attribute_type(),r=i.map(e=>this.decoder[e]).includes(n);if(r){const t=new this.draco.AttributeQuantizationTransform;try{if(t.InitFromAttribute(e))return{quantization_bits:t.quantization_bits()}}finally{this.draco.destroy(t)}}return null}}const Sj="https://www.gstatic.com/draco/versioned/decoders/1.5.6",Bj="draco_wasm_wrapper.js",Ij="draco_decoder.wasm",Mj="draco_decoder.js",Pj="draco_encoder.js",Rj={[Bj]:`${Sj}/${Bj}`,[Ij]:`${Sj}/${Ij}`,[Mj]:`${Sj}/${Mj}`,[Pj]:`https://raw.githubusercontent.com/google/draco/1.4.1/javascript/${Pj}`};let Lj;async function Fj(e){const t=e.modules||{};return t.draco3d?Lj||=t.draco3d.createDecoderModule({}).then(e=>({draco:e})):Lj||=async function(e){let t,i;if("js"===(e.draco&&e.draco.decoderType))t=await uB(Rj[Mj],"draco",e,Mj);else[t,i]=await Promise.all([await uB(Rj[Bj],"draco",e,Bj),await uB(Rj[Ij],"draco",e,Ij)]);return t=t||globalThis.DracoDecoderModule,await function(e,t){const i={};t&&(i.wasmBinary=t);return new Promise(t=>{e({...i,onModuleLoaded:e=>t({draco:e})})})}(t,i)}(e),await Lj}const kj={...vj,parse:async function(e,t){const{draco:i}=await Fj(t),n=new Cj(i);try{return n.parseSync(e,t?.draco)}finally{n.destroy()}}};const Dj={BYTE:5120,UNSIGNED_BYTE:5121,SHORT:5122,UNSIGNED_SHORT:5123,INT:5124,UNSIGNED_INT:5125,FLOAT:5126,DOUBLE:5130},Oj={POINTS:0,LINES:1,LINE_LOOP:2,LINE_STRIP:3,TRIANGLES:4,TRIANGLE_STRIP:5,TRIANGLE_FAN:6,...Dj},zj={[Dj.DOUBLE]:Float64Array,[Dj.FLOAT]:Float32Array,[Dj.UNSIGNED_SHORT]:Uint16Array,[Dj.UNSIGNED_INT]:Uint32Array,[Dj.UNSIGNED_BYTE]:Uint8Array,[Dj.BYTE]:Int8Array,[Dj.SHORT]:Int16Array,[Dj.INT]:Int32Array},Uj={DOUBLE:Dj.DOUBLE,FLOAT:Dj.FLOAT,UNSIGNED_SHORT:Dj.UNSIGNED_SHORT,UNSIGNED_INT:Dj.UNSIGNED_INT,UNSIGNED_BYTE:Dj.UNSIGNED_BYTE,BYTE:Dj.BYTE,SHORT:Dj.SHORT,INT:Dj.INT},Nj="Failed to convert GL type";class Vj{static fromTypedArray(e){e=ArrayBuffer.isView(e)?e.constructor:e;for(const t in zj){if(zj[t]===e)return t}throw new Error(Nj)}static fromName(e){const t=Uj[e];if(!t)throw new Error(Nj);return t}static getArrayType(e){switch(e){case Dj.UNSIGNED_SHORT_5_6_5:case Dj.UNSIGNED_SHORT_4_4_4_4:case Dj.UNSIGNED_SHORT_5_5_5_1:return Uint16Array;default:const t=zj[e];if(!t)throw new Error(Nj);return t}}static getByteSize(e){return Vj.getArrayType(e).BYTES_PER_ELEMENT}static validate(e){return Boolean(Vj.getArrayType(e))}static createTypedArray(e,t,i=0,n){void 0===n&&(n=(t.byteLength-i)/Vj.getByteSize(e));return new(Vj.getArrayType(e))(t,i,n)}}function jj(e,t=[0,0,0]){const i=e>>11&31,n=e>>5&63,r=31&e;return t[0]=i<<3,t[1]=n<<2,t[2]=r<<3,t}function Gj(e,t=255){return z_(e,0,t)/t*2-1}function Hj(e){return e<0?-1:1}function Qj(e,t,i,n){if(function(e,t){if(!e)throw new Error(`math.gl assertion failed. ${t}`)}(n),e<0||e>i||t<0||t>i)throw new Error(`x and y must be unsigned normalized integers between 0 and ${i}`);if(n.x=Gj(e,i),n.y=Gj(t,i),n.z=1-(Math.abs(n.x)+Math.abs(n.y)),n.z<0){const e=n.x;n.x=(1-Math.abs(n.y))*Hj(e),n.y=(1-Math.abs(e))*Hj(n.y)}return n.normalize()}function $j(e,t,i){return Qj(e,t,255,i)}new nA,new AA,new nA,new nA;class Zj{json;buffer;featuresLength=0;_cachedTypedArrays={};constructor(e,t){this.json=e,this.buffer=t}getExtension(e){return this.json.extensions&&this.json.extensions[e]}hasProperty(e){return Boolean(this.json[e])}getGlobalProperty(e,t=Oj.UNSIGNED_INT,i=1){const n=this.json[e];return n&&Number.isFinite(n.byteOffset)?this._getTypedArrayFromBinary(e,t,i,1,n.byteOffset):n}getPropertyArray(e,t,i){const n=this.json[e];return n&&Number.isFinite(n.byteOffset)?("componentType"in n&&(t=Vj.fromName(n.componentType)),this._getTypedArrayFromBinary(e,t,i,this.featuresLength,n.byteOffset)):this._getTypedArrayFromArray(e,t,n)}getProperty(e,t,i,n,r){const o=this.json[e];if(!o)return o;const s=this.getPropertyArray(e,t,i);if(1===i)return s[n];for(let e=0;ee[t],VEC2:(e,t)=>[e[2*t+0],e[2*t+1]],VEC3:(e,t)=>[e[3*t+0],e[3*t+1],e[3*t+2]],VEC4:(e,t)=>[e[4*t+0],e[4*t+1],e[4*t+2],e[4*t+3]],MAT2:(e,t)=>[e[4*t+0],e[4*t+1],e[4*t+2],e[4*t+3]],MAT3:(e,t)=>[e[9*t+0],e[9*t+1],e[9*t+2],e[9*t+3],e[9*t+4],e[9*t+5],e[9*t+6],e[9*t+7],e[9*t+8]],MAT4:(e,t)=>[e[16*t+0],e[16*t+1],e[16*t+2],e[16*t+3],e[16*t+4],e[16*t+5],e[16*t+6],e[16*t+7],e[16*t+8],e[16*t+9],e[16*t+10],e[16*t+11],e[16*t+12],e[16*t+13],e[16*t+14],e[16*t+15]]},Kj={SCALAR:(e,t,i)=>{t[i]=e},VEC2:(e,t,i)=>{t[2*i+0]=e[0],t[2*i+1]=e[1]},VEC3:(e,t,i)=>{t[3*i+0]=e[0],t[3*i+1]=e[1],t[3*i+2]=e[2]},VEC4:(e,t,i)=>{t[4*i+0]=e[0],t[4*i+1]=e[1],t[4*i+2]=e[2],t[4*i+3]=e[3]},MAT2:(e,t,i)=>{t[4*i+0]=e[0],t[4*i+1]=e[1],t[4*i+2]=e[2],t[4*i+3]=e[3]},MAT3:(e,t,i)=>{t[9*i+0]=e[0],t[9*i+1]=e[1],t[9*i+2]=e[2],t[9*i+3]=e[3],t[9*i+4]=e[4],t[9*i+5]=e[5],t[9*i+6]=e[6],t[9*i+7]=e[7],t[9*i+8]=e[8],t[9*i+9]=e[9]},MAT4:(e,t,i)=>{t[16*i+0]=e[0],t[16*i+1]=e[1],t[16*i+2]=e[2],t[16*i+3]=e[3],t[16*i+4]=e[4],t[16*i+5]=e[5],t[16*i+6]=e[6],t[16*i+7]=e[7],t[16*i+8]=e[8],t[16*i+9]=e[9],t[16*i+10]=e[10],t[16*i+11]=e[11],t[16*i+12]=e[12],t[16*i+13]=e[13],t[16*i+14]=e[14],t[16*i+15]=e[15]}};const Xj=e=>void 0!==e;function Jj(e,t,i){if(!t)return null;let n=e.getExtension("3DTILES_batch_table_hierarchy");const r=t.HIERARCHY;return r&&(console.warn("3D Tile Parser: HIERARCHY is deprecated. Use 3DTILES_batch_table_hierarchy."),t.extensions=t.extensions||{},t.extensions["3DTILES_batch_table_hierarchy"]=r,n=r),n?function(e,t){let i,n,r;const o=e.instancesLength,s=e.classes;let a,l=e.classIds,c=e.parentCounts,u=e.parentIds,h=o;Xj(l.byteOffset)&&(l.componentType=defaultValue(l.componentType,GL.UNSIGNED_SHORT),l.type=AttributeType.SCALAR,r=getBinaryAccessor(l),l=r.createArrayBufferView(t.buffer,t.byteOffset+l.byteOffset,o));if(Xj(c))for(Xj(c.byteOffset)&&(c.componentType=defaultValue(c.componentType,GL.UNSIGNED_SHORT),c.type=AttributeType.SCALAR,r=getBinaryAccessor(c),c=r.createArrayBufferView(t.buffer,t.byteOffset+c.byteOffset,o)),a=new Uint16Array(o),h=0,i=0;i0?function(e,t,i){const n=e.classIds,r=e.parentCounts,o=e.parentIds,s=e.parentIndexes,a=n.length,l=scratchVisited;l.length=Math.max(l.length,a);const c=++marker,u=scratchStack;u.length=0,u.push(t);for(;u.length>0;){if(l[t=u.pop()]===c)continue;l[t]=c;const n=i(e,t);if(Xj(n))return n;const a=r[t],h=s[t];for(let e=0;ee,nG={HIERARCHY:!0,extensions:!0,extras:!0};class rG{json;binary;featureCount;_extensions;_properties;_binaryProperties;_hierarchy;constructor(e,t,i,n={}){KV(i>=0),this.json=e||{},this.binary=t,this.featureCount=i,this._extensions=this.json?.extensions||{},this._properties={};for(const e in this.json)nG[e]||(this._properties[e]=this.json[e]);this._binaryProperties=this._initializeBinaryProperties(),n["3DTILES_batch_table_hierarchy"]&&(this._hierarchy=Jj(this,this.json,this.binary))}getExtension(e){return this.json&&this.json.extensions&&this.json.extensions[e]}memorySizeInBytes(){return 0}isClass(e,t){if(this._checkBatchId(e),KV("string"==typeof t,t),this._hierarchy){return tG(Yj(this._hierarchy,e,(e,i)=>{const n=e.classIds[i];return e.classes[n].name===t}))}return!1}isExactClass(e,t){return KV("string"==typeof t,t),this.getExactClassName(e)===t}getExactClassName(e){if(this._checkBatchId(e),this._hierarchy){const t=this._hierarchy.classIds[e];return this._hierarchy.classes[t].name}}hasProperty(e,t){return this._checkBatchId(e),KV("string"==typeof t,t),tG(this._properties[t])||this._hasPropertyInHierarchy(e,t)}getPropertyNames(e,t){this._checkBatchId(e),(t=tG(t)?t:[]).length=0;const i=Object.keys(this._properties);return t.push(...i),this._hierarchy&&this._getPropertyNamesInHierarchy(e,t),t}getProperty(e,t){if(this._checkBatchId(e),KV("string"==typeof t,t),this._binaryProperties){const i=this._binaryProperties[t];if(tG(i))return this._getBinaryProperty(i,e)}const i=this._properties[t];if(tG(i))return iG(i[e]);if(this._hierarchy){const i=this._getHierarchyProperty(e,t);if(tG(i))return i}}setProperty(e,t,i){const n=this.featureCount;if(this._checkBatchId(e),KV("string"==typeof t,t),this._binaryProperties){const n=this._binaryProperties[t];if(n)return void this._setBinaryProperty(n,e,i)}if(this._hierarchy&&this._setHierarchyProperty(this,e,t,i))return;let r=this._properties[t];tG(r)||(this._properties[t]=new Array(n),r=this._properties[t]),r[e]=iG(i)}_checkBatchId(e){if(!(e>=0&&e{const n=e.classIds[i];return tG(e.classes[n].instances[t])});return tG(i)}_getPropertyNamesInHierarchy(e,t){Yj(this._hierarchy,e,(e,i)=>{const n=e.classIds[i],r=e.classes[n].instances;for(const e in r)r.hasOwnProperty(e)&&-1===t.indexOf(e)&&t.push(e)})}_getHierarchyProperty(e,t){return Yj(this._hierarchy,e,(e,i)=>{const n=e.classIds[i],r=e.classes[n],o=e.classIndexes[i],s=r.instances[t];return tG(s)?tG(s.typedArray)?this._getBinaryProperty(s,o):iG(s[o]):null})}_setHierarchyProperty(e,t,i,n){const r=Yj(this._hierarchy,t,(e,r)=>{const o=e.classIds[r],s=e.classes[o],a=e.classIndexes[r],l=s.instances[i];return!!tG(l)&&(KV(r===t,`Inherited property "${i}" is read-only.`),tG(l.typedArray)?this._setBinaryProperty(l,a,n):l[a]=iG(n),!0)});return tG(r)}}function oG(e,t,i=0){const n=new DataView(t);if(e.magic=n.getUint32(i,!0),i+=4,e.version=n.getUint32(i,!0),i+=4,e.byteLength=n.getUint32(i,!0),i+=4,1!==e.version)throw new Error(`3D Tile Version ${e.version} not supported`);return i}const sG="b3dm tile in legacy format.";function aG(e,t,i){const n=new DataView(t);let r;e.header=e.header||{};let o=n.getUint32(i,!0);i+=4;let s=n.getUint32(i,!0);i+=4;let a=n.getUint32(i,!0);i+=4;let l=n.getUint32(i,!0);return i+=4,a>=570425344?(i-=8,r=o,a=s,l=0,o=0,s=0,console.warn(sG)):l>=570425344&&(i-=4,r=a,a=o,l=s,o=0,s=0,console.warn(sG)),e.header.featureTableJsonByteLength=o,e.header.featureTableBinaryByteLength=s,e.header.batchTableJsonByteLength=a,e.header.batchTableBinaryByteLength=l,e.header.batchLength=r,i}function lG(e,t,i,n){return i=function(e,t,i){const{featureTableJsonByteLength:n,featureTableBinaryByteLength:r,batchLength:o}=e.header||{};if(e.featureTableJson={BATCH_LENGTH:o||0},n&&n>0){const r=Aj(t,i,n);e.featureTableJson=JSON.parse(r)}return i+=n||0,e.featureTableBinary=new Uint8Array(t,i,r),i+=r||0,i}(e,t,i),i=function(e,t,i){const{batchTableJsonByteLength:n,batchTableBinaryByteLength:r}=e.header||{};if(n&&n>0){const o=Aj(t,i,n);e.batchTableJson=JSON.parse(o),i+=n,r&&r>0&&(e.batchTableBinary=new Uint8Array(t,i,r),e.batchTableBinary=new Uint8Array(e.batchTableBinary),i+=r)}return i}(e,t,i),i}function cG(e,t,i){if(!(t||e&&e.batchIds&&i))return null;const{batchIds:n,isRGB565:r,pointCount:o=0}=e;if(n&&i){const e=new Uint8ClampedArray(3*o);for(let t=0;t255*e);e[3*t]=o[0],e[3*t+1]=o[1],e[3*t+2]=o[2]}return{type:Oj.UNSIGNED_BYTE,value:e,size:3,normalized:!0}}if(t&&r){const e=new Uint8ClampedArray(3*o);for(let i=0;i{try{i.onload=()=>e(i),i.onerror=e=>{const i=e instanceof Error?e.message:"error";t(new Error(i))}}catch(e){t(e)}})}(o||n,t)}finally{o&&r.revokeObjectURL(o)}}const EG={};let CG=!0;async function SG(e,t,i){let n;if(bG(i)){n=await TG(e,t,i)}else n=wG(e,i);const r=t&&t.imagebitmap;return await async function(e,t=null){!function(e){for(const t in e||EG)return!1;return!0}(t)&&CG||(t=null);if(t)try{return await createImageBitmap(e,t)}catch(e){console.warn(e),CG=!1}return await createImageBitmap(e)}(n,r)}function BG(e){return function(e,t,i=0){const n=(r=t,[...r].map(e=>e.charCodeAt(0)));var r;for(let t=0;t=24&&2303741511===t.getUint32(0,IG);if(!i)return null;return{mimeType:"image/png",width:t.getUint32(16,IG),height:t.getUint32(20,IG)}}(t)||function(e){const t=RG(e),i=t.byteLength>=3&&65496===t.getUint16(0,IG)&&255===t.getUint8(2);if(!i)return null;const{tableMarkers:n,sofMarkers:r}=function(){const e=new Set([65499,65476,65484,65501,65534]);for(let t=65504;t<65520;++t)e.add(t);const t=new Set([65472,65473,65474,65475,65477,65478,65479,65481,65482,65483,65485,65486,65487,65502]);return{tableMarkers:e,sofMarkers:t}}();let o=2;for(;o+9=10&&1195984440===t.getUint32(0,IG);if(!i)return null;return{mimeType:"image/gif",width:t.getUint16(6,MG),height:t.getUint16(8,MG)}}(t)||function(e){const t=RG(e),i=t.byteLength>=14&&16973===t.getUint16(0,IG)&&t.getUint32(2,MG)===t.byteLength;if(!i)return null;return{mimeType:"image/bmp",width:t.getUint32(18,MG),height:t.getUint32(22,MG)}}(t)||function(e){const t=new Uint8Array(e instanceof DataView?e.buffer:e),i=BG(t);if(!i)return null;return{mimeType:i.mimeType,width:0,height:0}}(t)}function RG(e){if(e instanceof DataView)return e;if(ArrayBuffer.isView(e))return new DataView(e.buffer);if(e instanceof ArrayBuffer)return new DataView(e);throw new Error("toDataView")}const LG={dataType:null,batchType:null,id:"image",module:"images",name:"Images",version:"4.2.4",mimeTypes:["image/png","image/jpeg","image/gif","image/webp","image/avif","image/bmp","image/vnd.microsoft.icon","image/svg+xml"],extensions:["png","jpg","jpeg","gif","webp","bmp","ico","svg","avif"],parse:async function(e,t,i){const n=((t=t||{}).image||{}).type||"auto",{url:r}=i||{},o=function(e){switch(e){case"auto":case"data":return function(){if(mG)return"imagebitmap";if(fG)return"image";if(_G)return"data";throw new Error("Install '@loaders.gl/polyfills' to parse images under Node.js")}();default:return function(e){switch(e){case"auto":return mG||fG||_G;case"imagebitmap":return mG;case"image":return fG;case"data":return _G;default:throw new Error(`@loaders.gl/images: image ${e} not supported in this environment`)}}(e),e}}(n);let s;switch(o){case"imagebitmap":s=await SG(e,t,r);break;case"image":s=await TG(e,t,r);break;case"data":s=await async function(e){const{mimeType:t}=PG(e)||{},i=globalThis.loaders?.parseImageNode;return KV(i),await i(e,t)}(e);break;default:KV(!1)}return"data"===n&&(s=yG(s)),s},tests:[e=>Boolean(PG(new DataView(e)))],options:{image:{type:"auto",decode:!0}}},FG={};function kG(e){if(void 0===FG[e]){const t=XV?function(e){switch(e){case"image/avif":case"image/webp":return function(e){try{const t=document.createElement("canvas");return 0===t.toDataURL(e).indexOf(`data:${e}`)}catch{return!1}}(e);default:return!0}}(e):function(e){const t=["image/png","image/jpeg","image/gif"],i=globalThis.loaders?.imageFormatsNode||t,n=globalThis.loaders?.parseImageNode;return Boolean(n)&&i.includes(e)}(e);FG[e]=t}return FG[e]}function DG(e,t){if(!e)throw new Error(t||"assert failed: gltf")}const OG={SCALAR:1,VEC2:2,VEC3:3,VEC4:4,MAT2:4,MAT3:9,MAT4:16},zG={5120:1,5121:1,5122:2,5123:2,5125:4,5126:4},UG=["SCALAR","VEC2","VEC3","VEC4"],NG=[[Int8Array,5120],[Uint8Array,5121],[Int16Array,5122],[Uint16Array,5123],[Uint32Array,5125],[Float32Array,5126],[Float64Array,5130]],VG=new Map(NG),jG={SCALAR:1,VEC2:2,VEC3:3,VEC4:4,MAT2:4,MAT3:9,MAT4:16},GG={5120:1,5121:1,5122:2,5123:2,5125:4,5126:4},HG={5120:Int8Array,5121:Uint8Array,5122:Int16Array,5123:Uint16Array,5125:Uint32Array,5126:Float32Array};function QG(e){return UG[e-1]||UG[0]}function $G(e){const t=VG.get(e.constructor);if(!t)throw new Error("Illegal typed array");return t}function ZG(e,t){const i=HG[e.componentType],n=jG[e.type],r=GG[e.componentType],o=e.count*n,s=e.count*n*r;DG(s>=0&&s<=t.byteLength);return{ArrayType:i,length:o,byteLength:s,componentByteSize:zG[e.componentType],numberOfComponentsInElement:OG[e.type]}}function WG(e){let{images:t,bufferViews:i}=e;t=t||[],i=i||[];const n=t.map(e=>e.bufferView);i=i.filter(e=>!n.includes(e));const r=i.reduce((e,t)=>e+t.byteLength,0),o=t.reduce((e,t)=>{const{width:i,height:n}=t.image;return e+i*n},0);return r+Math.ceil(4*o*1.33)}class qG{gltf;sourceBuffers;byteLength;constructor(e){this.gltf={json:e?.json||{asset:{version:"2.0",generator:"loaders.gl"},buffers:[],extensions:{},extensionsRequired:[],extensionsUsed:[]},buffers:e?.buffers||[],images:e?.images||[]},this.sourceBuffers=[],this.byteLength=0,this.gltf.buffers&&this.gltf.buffers[0]&&(this.byteLength=this.gltf.buffers[0].byteLength,this.sourceBuffers=[this.gltf.buffers[0]])}get json(){return this.gltf.json}getApplicationData(e){return this.json[e]}getExtraData(e){return(this.json.extras||{})[e]}hasExtension(e){const t=this.getUsedExtensions().find(t=>t===e),i=this.getRequiredExtensions().find(t=>t===e);return"string"==typeof t||"string"==typeof i}getExtension(e){const t=this.getUsedExtensions().find(t=>t===e),i=this.json.extensions||{};return t?i[e]:null}getRequiredExtension(e){return this.getRequiredExtensions().find(t=>t===e)?this.getExtension(e):null}getRequiredExtensions(){return this.json.extensionsRequired||[]}getUsedExtensions(){return this.json.extensionsUsed||[]}getRemovedExtensions(){return this.json.extensionsRemoved||[]}getObjectExtension(e,t){return(e.extensions||{})[t]}getScene(e){return this.getObject("scenes",e)}getNode(e){return this.getObject("nodes",e)}getSkin(e){return this.getObject("skins",e)}getMesh(e){return this.getObject("meshes",e)}getMaterial(e){return this.getObject("materials",e)}getAccessor(e){return this.getObject("accessors",e)}getTexture(e){return this.getObject("textures",e)}getSampler(e){return this.getObject("samplers",e)}getImage(e){return this.getObject("images",e)}getBufferView(e){return this.getObject("bufferViews",e)}getBuffer(e){return this.getObject("buffers",e)}getObject(e,t){if("object"==typeof t)return t;const i=this.json[e]&&this.json[e][t];if(!i)throw new Error(`glTF file error: Could not find ${e}[${t}]`);return i}getTypedArrayForBufferView(e){const t=(e=this.getBufferView(e)).buffer,i=this.gltf.buffers[t];DG(i);const n=(e.byteOffset||0)+i.byteOffset;return new Uint8Array(i.arrayBuffer,n,e.byteLength)}getTypedArrayForAccessor(e){const t=this.getAccessor(e);return function(e,t,i){const n="number"==typeof i?e.accessors?.[i]:i;if(!n)throw new Error(`No gltf accessor ${JSON.stringify(i)}`);const r=e.bufferViews?.[n.bufferView||0];if(!r)throw new Error(`No gltf buffer view for accessor ${r}`);const{arrayBuffer:o,byteOffset:s}=t[r.buffer],a=(s||0)+(n.byteOffset||0)+(r.byteOffset||0),{ArrayType:l,length:c,componentByteSize:u,numberOfComponentsInElement:h}=ZG(n,r),d=u*h,p=r.byteStride||d;if(void 0===r.byteStride||r.byteStride===d)return new l(o,a,c);const f=new l(c);for(let e=0;et===e)||this.json.extensionsUsed.push(e)}registerRequiredExtension(e){this.registerUsedExtension(e),this.json.extensionsRequired=this.json.extensionsRequired||[],this.json.extensionsRequired.find(t=>t===e)||this.json.extensionsRequired.push(e)}removeExtension(e){if(this.json.extensions?.[e]){this.json.extensionsRemoved=this.json.extensionsRemoved||[];const t=this.json.extensionsRemoved;t.includes(e)||t.push(e)}this.json.extensions&&delete this.json.extensions[e],this.json.extensionsRequired&&this._removeStringFromArray(this.json.extensionsRequired,e),this.json.extensionsUsed&&this._removeStringFromArray(this.json.extensionsUsed,e)}setDefaultScene(e){this.json.scene=e}addScene(e){const{nodeIndices:t}=e;return this.json.scenes=this.json.scenes||[],this.json.scenes.push({nodes:t}),this.json.scenes.length-1}addNode(e){const{meshIndex:t,matrix:i}=e;this.json.nodes=this.json.nodes||[];const n={mesh:t};return i&&(n.matrix=i),this.json.nodes.push(n),this.json.nodes.length-1}addMesh(e){const{attributes:t,indices:i,material:n,mode:r=4}=e,o={primitives:[{attributes:this._addAttributes(t),mode:r}]};if(i){const e=this._addIndices(i);o.primitives[0].indices=e}return Number.isFinite(n)&&(o.primitives[0].material=n),this.json.meshes=this.json.meshes||[],this.json.meshes.push(o),this.json.meshes.length-1}addPointCloud(e){const t={primitives:[{attributes:this._addAttributes(e),mode:0}]};return this.json.meshes=this.json.meshes||[],this.json.meshes.push(t),this.json.meshes.length-1}addImage(e,t){const i=PG(e),n=t||i?.mimeType,r={bufferView:this.addBufferView(e),mimeType:n};return this.json.images=this.json.images||[],this.json.images.push(r),this.json.images.length-1}addBufferView(e,t=0,i=this.byteLength){const n=e.byteLength;DG(Number.isFinite(n)),this.sourceBuffers=this.sourceBuffers||[],this.sourceBuffers.push(e);const r={buffer:t,byteOffset:i,byteLength:n};return this.byteLength+=ij(n,4),this.json.bufferViews=this.json.bufferViews||[],this.json.bufferViews.push(r),this.json.bufferViews.length-1}addAccessor(e,t){const i={bufferView:e,type:QG(t.size),componentType:t.componentType,count:t.count,max:t.max,min:t.min};return this.json.accessors=this.json.accessors||[],this.json.accessors.push(i),this.json.accessors.length-1}addBinaryBuffer(e,t={size:3}){const i=this.addBufferView(e);let n={min:t.min,max:t.max};n.min&&n.max||(n=this._getAccessorMinMax(e,t.size));const r={size:t.size,componentType:$G(e),count:Math.round(e.length/t.size),min:n.min,max:n.max};return this.addAccessor(i,Object.assign(r,t))}addTexture(e){const{imageIndex:t}=e,i={source:t};return this.json.textures=this.json.textures||[],this.json.textures.push(i),this.json.textures.length-1}addMaterial(e){return this.json.materials=this.json.materials||[],this.json.materials.push(e),this.json.materials.length-1}createBinaryChunk(){this.gltf.buffers=[];const e=this.byteLength,t=new ArrayBuffer(e),i=new Uint8Array(t);let n=0;for(const e of this.sourceBuffers||[])n=nj(e,i,n);this.json?.buffers?.[0]?this.json.buffers[0].byteLength=e:this.json.buffers=[{byteLength:e}],this.gltf.binary=t,this.sourceBuffers=[t]}_removeStringFromArray(e,t){let i=!0;for(;i;){const n=e.indexOf(t);n>-1?e.splice(n,1):i=!1}}_addAttributes(e={}){const t={};for(const i in e){const n=e[i],r=this._getGltfAttributeName(i),o=this.addBinaryBuffer(n.value,n);t[r]=o}return t}_addIndices(e){return this.addBinaryBuffer(e,{size:1})}_getGltfAttributeName(e){switch(e.toLowerCase()){case"position":case"positions":case"vertices":return"POSITION";case"normal":case"normals":return"NORMAL";case"color":case"colors":return"COLOR_0";case"texcoord":case"texcoords":return"TEXCOORD_0";default:return e}}_getAccessorMinMax(e,t){const i={min:null,max:null};if(e.lengtht===e);-1===t&&(t=n.push(e)-1),o.push(t)}const s=new Uint32Array(o),a=e.gltf.buffers.push({arrayBuffer:s.buffer,byteOffset:s.byteOffset,byteLength:s.byteLength})-1,l=e.addBufferView(s,a,0),c=e.addAccessor(l,{size:1,componentType:$G(s),count:s.length});r.attributes[t]=c}function oH(e,t,i,n,r=[0]){const o={r:{offset:0,shift:0},g:{offset:1,shift:8},b:{offset:2,shift:16},a:{offset:3,shift:24}},s=i[n],a=i[n+1];let l=1;!t||-1===t.indexOf("image/jpeg")&&-1===t.indexOf("image/png")||(l=4);const c=function(e,t,i,n=1){const r=i.width,o=KG(e)*(r-1),s=Math.round(o),a=i.height,l=KG(t)*(a-1),c=Math.round(l),u=i.components?i.components:n,h=(c*r+s)*u;return h}(s,a,e,l);let u=0;for(const t of r){const i="number"==typeof t?Object.values(o)[t]:o[t],n=c+i.offset,r=yG(e);if(r.data.length<=n)throw new Error(`${r.data.length} <= ${n}`);u|=r.data[n]<n)break;const l=t/r,c=a/r;o.push(e.slice(l,l+c))}return o}function aH(e,t,i){const n=[];for(let r=0;rr)break;const c=vH(t,i/o,l/o,s);a.push(c)}return a}({valuesData:u,numberOfElements:i,arrayOffsets:r,valuesDataBytesLength:n.length,elementSize:l,enumEntry:s});const e=t.count;return e?function(e,t,i,n){const r=[];for(let o=0;o{e(i).then(e=>{const{BasisFile:i,initializeBasis:n}=e;n(),t({BasisFile:i})})})}(t,i)}(e),await OH)}async function NH(e){const t=e.modules||{};return t.basisEncoder?t.basisEncoder:(zH=zH||async function(e){let t=null,i=null;return[t,i]=await Promise.all([await uB(kH,"textures",e),await uB(DH,"textures",e)]),t=t||globalThis.BASIS,await function(e,t){const i={};t&&(i.wasmBinary=t);return new Promise(t=>{e(i).then(e=>{const{BasisFile:i,KTX2File:n,initializeBasis:r,BasisEncoder:o}=e;r(),t({BasisFile:i,KTX2File:n,BasisEncoder:o})})})}(t,i)}(e),await zH)}const VH=33776,jH=33779,GH=35840,HH=35842,QH=36196,$H=37808,ZH=["","WEBKIT_","MOZ_"],WH={WEBGL_compressed_texture_s3tc:"dxt",WEBGL_compressed_texture_s3tc_srgb:"dxt-srgb",WEBGL_compressed_texture_etc1:"etc1",WEBGL_compressed_texture_etc:"etc2",WEBGL_compressed_texture_pvrtc:"pvrtc",WEBGL_compressed_texture_atc:"atc",WEBGL_compressed_texture_astc:"astc",EXT_texture_compression_rgtc:"rgtc"};let qH=null;function KH(e){if(!qH){e=e||function(){try{return document.createElement("canvas").getContext("webgl")}catch(e){return null}}()||void 0,qH=new Set;for(const t of ZH)for(const i in WH)if(e&&e.getExtension(`${t}${i}`)){const e=WH[i];qH.add(e)}}return qH}var XH,JH,YH,eQ,tQ,iQ,nQ,rQ;!function(e){e[e.NONE=0]="NONE",e[e.BASISLZ=1]="BASISLZ",e[e.ZSTD=2]="ZSTD",e[e.ZLIB=3]="ZLIB"}(XH||(XH={})),function(e){e[e.BASICFORMAT=0]="BASICFORMAT"}(JH||(JH={})),function(e){e[e.UNSPECIFIED=0]="UNSPECIFIED",e[e.ETC1S=163]="ETC1S",e[e.UASTC=166]="UASTC"}(YH||(YH={})),function(e){e[e.UNSPECIFIED=0]="UNSPECIFIED",e[e.SRGB=1]="SRGB"}(eQ||(eQ={})),function(e){e[e.UNSPECIFIED=0]="UNSPECIFIED",e[e.LINEAR=1]="LINEAR",e[e.SRGB=2]="SRGB",e[e.ITU=3]="ITU",e[e.NTSC=4]="NTSC",e[e.SLOG=5]="SLOG",e[e.SLOG2=6]="SLOG2"}(tQ||(tQ={})),function(e){e[e.ALPHA_STRAIGHT=0]="ALPHA_STRAIGHT",e[e.ALPHA_PREMULTIPLIED=1]="ALPHA_PREMULTIPLIED"}(iQ||(iQ={})),function(e){e[e.RGB=0]="RGB",e[e.RRR=3]="RRR",e[e.GGG=4]="GGG",e[e.AAA=15]="AAA"}(nQ||(nQ={})),function(e){e[e.RGB=0]="RGB",e[e.RGBA=3]="RGBA",e[e.RRR=4]="RRR",e[e.RRRG=5]="RRRG"}(rQ||(rQ={}));const oQ=[171,75,84,88,32,50,48,187,13,10,26,10];const sQ={etc1:{basisFormat:0,compressed:!0,format:QH},etc2:{basisFormat:1,compressed:!0},bc1:{basisFormat:2,compressed:!0,format:VH},bc3:{basisFormat:3,compressed:!0,format:jH},bc4:{basisFormat:4,compressed:!0},bc5:{basisFormat:5,compressed:!0},"bc7-m6-opaque-only":{basisFormat:6,compressed:!0},"bc7-m5":{basisFormat:7,compressed:!0},"pvrtc1-4-rgb":{basisFormat:8,compressed:!0,format:GH},"pvrtc1-4-rgba":{basisFormat:9,compressed:!0,format:HH},"astc-4x4":{basisFormat:10,compressed:!0,format:$H},"atc-rgb":{basisFormat:11,compressed:!0},"atc-rgba-interpolated-alpha":{basisFormat:12,compressed:!0},rgba32:{basisFormat:13,compressed:!1},rgb565:{basisFormat:14,compressed:!1},bgr565:{basisFormat:15,compressed:!1},rgba4444:{basisFormat:16,compressed:!1}};function aQ(e,t,i){const n=new e(new Uint8Array(t));try{if(!n.startTranscoding())throw new Error("Failed to start basis transcoding");const e=n.getNumImages(),t=[];for(let r=0;r20);const n=t.getUint32(i+0,fQ),r=t.getUint32(i+4,fQ);return i+=8,KV(0===r),yQ(e,t,i,n),i+=n,i+=vQ(e,t,i,e.header.byteLength),i}(e,r,i);case 2:return function(e,t,i,n){return KV(e.header.byteLength>20),function(e,t,i,n){for(;i+8<=e.header.byteLength;){const r=t.getUint32(i+0,fQ),o=t.getUint32(i+4,fQ);switch(i+=8,o){case gQ:yQ(e,t,i,r);break;case _Q:vQ(e,t,i,r);break;case 0:n.strict||yQ(e,t,i,r);break;case 1:n.strict||vQ(e,t,i,r)}i+=ij(r,4)}}(e,t,i,n),i+e.header.byteLength}(e,r,i,{});default:throw new Error(`Invalid GLB version ${e.version}. Only supports version 1 and 2.`)}}function yQ(e,t,i,n){const r=new Uint8Array(t.buffer,i,n),o=new TextDecoder("utf8").decode(r);return e.json=JSON.parse(o),ij(n,4)}function vQ(e,t,i,n){return e.header.hasBinChunk=!0,e.binChunks.push({byteOffset:i,byteLength:n,arrayBuffer:t.buffer}),ij(n,4)}function xQ(e,t){if(e.startsWith("data:")||e.startsWith("http:")||e.startsWith("https:"))return e;const i=t.baseUri||t.uri;if(!i)throw new Error(`'baseUri' must be provided to resolve relative url ${e}`);return i.substr(0,i.lastIndexOf("/")+1)+e}const bQ="B9h9z9tFBBBF8fL9gBB9gLaaaaaFa9gEaaaB9gFaFa9gEaaaFaEMcBFFFGGGEIIILF9wFFFLEFBFKNFaFCx/IFMO/LFVK9tv9t9vq95GBt9f9f939h9z9t9f9j9h9s9s9f9jW9vq9zBBp9tv9z9o9v9wW9f9kv9j9v9kv9WvqWv94h919m9mvqBF8Z9tv9z9o9v9wW9f9kv9j9v9kv9J9u9kv94h919m9mvqBGy9tv9z9o9v9wW9f9kv9j9v9kv9J9u9kv949TvZ91v9u9jvBEn9tv9z9o9v9wW9f9kv9j9v9kv69p9sWvq9P9jWBIi9tv9z9o9v9wW9f9kv9j9v9kv69p9sWvq9R919hWBLn9tv9z9o9v9wW9f9kv9j9v9kv69p9sWvq9F949wBKI9z9iqlBOc+x8ycGBM/qQFTa8jUUUUBCU/EBlHL8kUUUUBC9+RKGXAGCFJAI9LQBCaRKAE2BBC+gF9HQBALAEAIJHOAGlAGTkUUUBRNCUoBAG9uC/wgBZHKCUGAKCUG9JyRVAECFJRICBRcGXEXAcAF9PQFAVAFAclAcAVJAF9JyRMGXGXAG9FQBAMCbJHKC9wZRSAKCIrCEJCGrRQANCUGJRfCBRbAIRTEXGXAOATlAQ9PQBCBRISEMATAQJRIGXAS9FQBCBRtCBREEXGXAOAIlCi9PQBCBRISLMANCU/CBJAEJRKGXGXGXGXGXATAECKrJ2BBAtCKZrCEZfIBFGEBMAKhB83EBAKCNJhB83EBSEMAKAI2BIAI2BBHmCKrHYAYCE6HYy86BBAKCFJAICIJAYJHY2BBAmCIrCEZHPAPCE6HPy86BBAKCGJAYAPJHY2BBAmCGrCEZHPAPCE6HPy86BBAKCEJAYAPJHY2BBAmCEZHmAmCE6Hmy86BBAKCIJAYAmJHY2BBAI2BFHmCKrHPAPCE6HPy86BBAKCLJAYAPJHY2BBAmCIrCEZHPAPCE6HPy86BBAKCKJAYAPJHY2BBAmCGrCEZHPAPCE6HPy86BBAKCOJAYAPJHY2BBAmCEZHmAmCE6Hmy86BBAKCNJAYAmJHY2BBAI2BGHmCKrHPAPCE6HPy86BBAKCVJAYAPJHY2BBAmCIrCEZHPAPCE6HPy86BBAKCcJAYAPJHY2BBAmCGrCEZHPAPCE6HPy86BBAKCMJAYAPJHY2BBAmCEZHmAmCE6Hmy86BBAKCSJAYAmJHm2BBAI2BEHICKrHYAYCE6HYy86BBAKCQJAmAYJHm2BBAICIrCEZHYAYCE6HYy86BBAKCfJAmAYJHm2BBAICGrCEZHYAYCE6HYy86BBAKCbJAmAYJHK2BBAICEZHIAICE6HIy86BBAKAIJRISGMAKAI2BNAI2BBHmCIrHYAYCb6HYy86BBAKCFJAICNJAYJHY2BBAmCbZHmAmCb6Hmy86BBAKCGJAYAmJHm2BBAI2BFHYCIrHPAPCb6HPy86BBAKCEJAmAPJHm2BBAYCbZHYAYCb6HYy86BBAKCIJAmAYJHm2BBAI2BGHYCIrHPAPCb6HPy86BBAKCLJAmAPJHm2BBAYCbZHYAYCb6HYy86BBAKCKJAmAYJHm2BBAI2BEHYCIrHPAPCb6HPy86BBAKCOJAmAPJHm2BBAYCbZHYAYCb6HYy86BBAKCNJAmAYJHm2BBAI2BIHYCIrHPAPCb6HPy86BBAKCVJAmAPJHm2BBAYCbZHYAYCb6HYy86BBAKCcJAmAYJHm2BBAI2BLHYCIrHPAPCb6HPy86BBAKCMJAmAPJHm2BBAYCbZHYAYCb6HYy86BBAKCSJAmAYJHm2BBAI2BKHYCIrHPAPCb6HPy86BBAKCQJAmAPJHm2BBAYCbZHYAYCb6HYy86BBAKCfJAmAYJHm2BBAI2BOHICIrHYAYCb6HYy86BBAKCbJAmAYJHK2BBAICbZHIAICb6HIy86BBAKAIJRISFMAKAI8pBB83BBAKCNJAICNJ8pBB83BBAICTJRIMAtCGJRtAECTJHEAS9JQBMMGXAIQBCBRISEMGXAM9FQBANAbJ2BBRtCBRKAfREEXAEANCU/CBJAKJ2BBHTCFrCBATCFZl9zAtJHt86BBAEAGJREAKCFJHKAM9HQBMMAfCFJRfAIRTAbCFJHbAG9HQBMMABAcAG9sJANCUGJAMAG9sTkUUUBpANANCUGJAMCaJAG9sJAGTkUUUBpMAMCBAIyAcJRcAIQBMC9+RKSFMCBC99AOAIlAGCAAGCA9Ly6yRKMALCU/EBJ8kUUUUBAKM+OmFTa8jUUUUBCoFlHL8kUUUUBC9+RKGXAFCE9uHOCtJAI9LQBCaRKAE2BBHNC/wFZC/gF9HQBANCbZHVCF9LQBALCoBJCgFCUFT+JUUUBpALC84Jha83EBALC8wJha83EBALC8oJha83EBALCAJha83EBALCiJha83EBALCTJha83EBALha83ENALha83EBAEAIJC9wJRcAECFJHNAOJRMGXAF9FQBCQCbAVCF6yRSABRECBRVCBRQCBRfCBRICBRKEXGXAMAcuQBC9+RKSEMGXGXAN2BBHOC/vF9LQBALCoBJAOCIrCa9zAKJCbZCEWJHb8oGIRTAb8oGBRtGXAOCbZHbAS9PQBALAOCa9zAIJCbZCGWJ8oGBAVAbyROAb9FRbGXGXAGCG9HQBABAt87FBABCIJAO87FBABCGJAT87FBSFMAEAtjGBAECNJAOjGBAECIJATjGBMAVAbJRVALCoBJAKCEWJHmAOjGBAmATjGIALAICGWJAOjGBALCoBJAKCFJCbZHKCEWJHTAtjGBATAOjGIAIAbJRIAKCFJRKSGMGXGXAbCb6QBAQAbJAbC989zJCFJRQSFMAM1BBHbCgFZROGXGXAbCa9MQBAMCFJRMSFMAM1BFHbCgBZCOWAOCgBZqROGXAbCa9MQBAMCGJRMSFMAM1BGHbCgBZCfWAOqROGXAbCa9MQBAMCEJRMSFMAM1BEHbCgBZCdWAOqROGXAbCa9MQBAMCIJRMSFMAM2BIC8cWAOqROAMCLJRMMAOCFrCBAOCFZl9zAQJRQMGXGXAGCG9HQBABAt87FBABCIJAQ87FBABCGJAT87FBSFMAEAtjGBAECNJAQjGBAECIJATjGBMALCoBJAKCEWJHOAQjGBAOATjGIALAICGWJAQjGBALCoBJAKCFJCbZHKCEWJHOAtjGBAOAQjGIAICFJRIAKCFJRKSFMGXAOCDF9LQBALAIAcAOCbZJ2BBHbCIrHTlCbZCGWJ8oGBAVCFJHtATyROALAIAblCbZCGWJ8oGBAtAT9FHmJHtAbCbZHTyRbAT9FRTGXGXAGCG9HQBABAV87FBABCIJAb87FBABCGJAO87FBSFMAEAVjGBAECNJAbjGBAECIJAOjGBMALAICGWJAVjGBALCoBJAKCEWJHYAOjGBAYAVjGIALAICFJHICbZCGWJAOjGBALCoBJAKCFJCbZCEWJHYAbjGBAYAOjGIALAIAmJCbZHICGWJAbjGBALCoBJAKCGJCbZHKCEWJHOAVjGBAOAbjGIAKCFJRKAIATJRIAtATJRVSFMAVCBAM2BBHYyHTAOC/+F6HPJROAYCbZRtGXGXAYCIrHmQBAOCFJRbSFMAORbALAIAmlCbZCGWJ8oGBROMGXGXAtQBAbCFJRVSFMAbRVALAIAYlCbZCGWJ8oGBRbMGXGXAP9FQBAMCFJRYSFMAM1BFHYCgFZRTGXGXAYCa9MQBAMCGJRYSFMAM1BGHYCgBZCOWATCgBZqRTGXAYCa9MQBAMCEJRYSFMAM1BEHYCgBZCfWATqRTGXAYCa9MQBAMCIJRYSFMAM1BIHYCgBZCdWATqRTGXAYCa9MQBAMCLJRYSFMAMCKJRYAM2BLC8cWATqRTMATCFrCBATCFZl9zAQJHQRTMGXGXAmCb6QBAYRPSFMAY1BBHMCgFZROGXGXAMCa9MQBAYCFJRPSFMAY1BFHMCgBZCOWAOCgBZqROGXAMCa9MQBAYCGJRPSFMAY1BGHMCgBZCfWAOqROGXAMCa9MQBAYCEJRPSFMAY1BEHMCgBZCdWAOqROGXAMCa9MQBAYCIJRPSFMAYCLJRPAY2BIC8cWAOqROMAOCFrCBAOCFZl9zAQJHQROMGXGXAtCb6QBAPRMSFMAP1BBHMCgFZRbGXGXAMCa9MQBAPCFJRMSFMAP1BFHMCgBZCOWAbCgBZqRbGXAMCa9MQBAPCGJRMSFMAP1BGHMCgBZCfWAbqRbGXAMCa9MQBAPCEJRMSFMAP1BEHMCgBZCdWAbqRbGXAMCa9MQBAPCIJRMSFMAPCLJRMAP2BIC8cWAbqRbMAbCFrCBAbCFZl9zAQJHQRbMGXGXAGCG9HQBABAT87FBABCIJAb87FBABCGJAO87FBSFMAEATjGBAECNJAbjGBAECIJAOjGBMALCoBJAKCEWJHYAOjGBAYATjGIALAICGWJATjGBALCoBJAKCFJCbZCEWJHYAbjGBAYAOjGIALAICFJHICbZCGWJAOjGBALCoBJAKCGJCbZCEWJHOATjGBAOAbjGIALAIAm9FAmCb6qJHICbZCGWJAbjGBAIAt9FAtCb6qJRIAKCEJRKMANCFJRNABCKJRBAECSJREAKCbZRKAICbZRIAfCEJHfAF9JQBMMCBC99AMAc6yRKMALCoFJ8kUUUUBAKM/tIFGa8jUUUUBCTlRLC9+RKGXAFCLJAI9LQBCaRKAE2BBC/+FZC/QF9HQBALhB83ENAECFJRKAEAIJC98JREGXAF9FQBGXAGCG6QBEXGXAKAE9JQBC9+bMAK1BBHGCgFZRIGXGXAGCa9MQBAKCFJRKSFMAK1BFHGCgBZCOWAICgBZqRIGXAGCa9MQBAKCGJRKSFMAK1BGHGCgBZCfWAIqRIGXAGCa9MQBAKCEJRKSFMAK1BEHGCgBZCdWAIqRIGXAGCa9MQBAKCIJRKSFMAK2BIC8cWAIqRIAKCLJRKMALCNJAICFZCGWqHGAICGrCBAICFrCFZl9zAG8oGBJHIjGBABAIjGBABCIJRBAFCaJHFQBSGMMEXGXAKAE9JQBC9+bMAK1BBHGCgFZRIGXGXAGCa9MQBAKCFJRKSFMAK1BFHGCgBZCOWAICgBZqRIGXAGCa9MQBAKCGJRKSFMAK1BGHGCgBZCfWAIqRIGXAGCa9MQBAKCEJRKSFMAK1BEHGCgBZCdWAIqRIGXAGCa9MQBAKCIJRKSFMAK2BIC8cWAIqRIAKCLJRKMABAICGrCBAICFrCFZl9zALCNJAICFZCGWqHI8oGBJHG87FBAIAGjGBABCGJRBAFCaJHFQBMMCBC99AKAE6yRKMAKM+lLKFaF99GaG99FaG99GXGXAGCI9HQBAF9FQFEXGXGX9DBBB8/9DBBB+/ABCGJHG1BB+yAB1BBHE+yHI+L+TABCFJHL1BBHK+yHO+L+THN9DBBBB9gHVyAN9DBB/+hANAN+U9DBBBBANAVyHcAc+MHMAECa3yAI+SHIAI+UAcAMAKCa3yAO+SHcAc+U+S+S+R+VHO+U+SHN+L9DBBB9P9d9FQBAN+oRESFMCUUUU94REMAGAE86BBGXGX9DBBB8/9DBBB+/Ac9DBBBB9gyAcAO+U+SHN+L9DBBB9P9d9FQBAN+oRGSFMCUUUU94RGMALAG86BBGXGX9DBBB8/9DBBB+/AI9DBBBB9gyAIAO+U+SHN+L9DBBB9P9d9FQBAN+oRGSFMCUUUU94RGMABAG86BBABCIJRBAFCaJHFQBSGMMAF9FQBEXGXGX9DBBB8/9DBBB+/ABCIJHG8uFB+yAB8uFBHE+yHI+L+TABCGJHL8uFBHK+yHO+L+THN9DBBBB9gHVyAN9DB/+g6ANAN+U9DBBBBANAVyHcAc+MHMAECa3yAI+SHIAI+UAcAMAKCa3yAO+SHcAc+U+S+S+R+VHO+U+SHN+L9DBBB9P9d9FQBAN+oRESFMCUUUU94REMAGAE87FBGXGX9DBBB8/9DBBB+/Ac9DBBBB9gyAcAO+U+SHN+L9DBBB9P9d9FQBAN+oRGSFMCUUUU94RGMALAG87FBGXGX9DBBB8/9DBBB+/AI9DBBBB9gyAIAO+U+SHN+L9DBBB9P9d9FQBAN+oRGSFMCUUUU94RGMABAG87FBABCNJRBAFCaJHFQBMMM/SEIEaE99EaF99GXAF9FQBCBREABRIEXGXGX9D/zI818/AICKJ8uFBHLCEq+y+VHKAI8uFB+y+UHO9DB/+g6+U9DBBB8/9DBBB+/AO9DBBBB9gy+SHN+L9DBBB9P9d9FQBAN+oRVSFMCUUUU94RVMAICIJ8uFBRcAICGJ8uFBRMABALCFJCEZAEqCFWJAV87FBGXGXAKAM+y+UHN9DB/+g6+U9DBBB8/9DBBB+/AN9DBBBB9gy+SHS+L9DBBB9P9d9FQBAS+oRMSFMCUUUU94RMMABALCGJCEZAEqCFWJAM87FBGXGXAKAc+y+UHK9DB/+g6+U9DBBB8/9DBBB+/AK9DBBBB9gy+SHS+L9DBBB9P9d9FQBAS+oRcSFMCUUUU94RcMABALCaJCEZAEqCFWJAc87FBGXGX9DBBU8/AOAO+U+TANAN+U+TAKAK+U+THO9DBBBBAO9DBBBB9gy+R9DB/+g6+U9DBBB8/+SHO+L9DBBB9P9d9FQBAO+oRcSFMCUUUU94RcMABALCEZAEqCFWJAc87FBAICNJRIAECIJREAFCaJHFQBMMM9JBGXAGCGrAF9sHF9FQBEXABAB8oGBHGCNWCN91+yAGCi91CnWCUUU/8EJ+++U84GBABCIJRBAFCaJHFQBMMM9TFEaCBCB8oGUkUUBHFABCEJC98ZJHBjGUkUUBGXGXAB8/BCTWHGuQBCaREABAGlCggEJCTrXBCa6QFMAFREMAEM/lFFFaGXGXAFABqCEZ9FQBABRESFMGXGXAGCT9PQBABRESFMABREEXAEAF8oGBjGBAECIJAFCIJ8oGBjGBAECNJAFCNJ8oGBjGBAECSJAFCSJ8oGBjGBAECTJREAFCTJRFAGC9wJHGCb9LQBMMAGCI9JQBEXAEAF8oGBjGBAFCIJRFAECIJREAGC98JHGCE9LQBMMGXAG9FQBEXAEAF2BB86BBAECFJREAFCFJRFAGCaJHGQBMMABMoFFGaGXGXABCEZ9FQBABRESFMAFCgFZC+BwsN9sRIGXGXAGCT9PQBABRESFMABREEXAEAIjGBAECSJAIjGBAECNJAIjGBAECIJAIjGBAECTJREAGC9wJHGCb9LQBMMAGCI9JQBEXAEAIjGBAECIJREAGC98JHGCE9LQBMMGXAG9FQBEXAEAF86BBAECFJREAGCaJHGQBMMABMMMFBCUNMIT9kBB",wQ="B9h9z9tFBBBF8dL9gBB9gLaaaaaFa9gEaaaB9gGaaB9gFaFaEQSBBFBFFGEGEGIILF9wFFFLEFBFKNFaFCx/aFMO/LFVK9tv9t9vq95GBt9f9f939h9z9t9f9j9h9s9s9f9jW9vq9zBBp9tv9z9o9v9wW9f9kv9j9v9kv9WvqWv94h919m9mvqBG8Z9tv9z9o9v9wW9f9kv9j9v9kv9J9u9kv94h919m9mvqBIy9tv9z9o9v9wW9f9kv9j9v9kv9J9u9kv949TvZ91v9u9jvBLn9tv9z9o9v9wW9f9kv9j9v9kv69p9sWvq9P9jWBKi9tv9z9o9v9wW9f9kv9j9v9kv69p9sWvq9R919hWBNn9tv9z9o9v9wW9f9kv9j9v9kv69p9sWvq9F949wBcI9z9iqlBMc/j9JSIBTEM9+FLa8jUUUUBCTlRBCBRFEXCBRGCBREEXABCNJAGJAECUaAFAGrCFZHIy86BBAEAIJREAGCFJHGCN9HQBMAFCx+YUUBJAE86BBAFCEWCxkUUBJAB8pEN83EBAFCFJHFCUG9HQBMMkRIbaG97FaK978jUUUUBCU/KBlHL8kUUUUBC9+RKGXAGCFJAI9LQBCaRKAE2BBC+gF9HQBALAEAIJHOAGlAG/8cBBCUoBAG9uC/wgBZHKCUGAKCUG9JyRNAECFJRKCBRVGXEXAVAF9PQFANAFAVlAVANJAF9JyRcGXGXAG9FQBAcCbJHIC9wZHMCE9sRSAMCFWRQAICIrCEJCGrRfCBRbEXAKRTCBRtGXEXGXAOATlAf9PQBCBRKSLMALCU/CBJAtAM9sJRmATAfJRKCBREGXAMCoB9JQBAOAKlC/gB9JQBCBRIEXAmAIJREGXGXGXGXGXATAICKrJ2BBHYCEZfIBFGEBMAECBDtDMIBSEMAEAKDBBIAKDBBBHPCID+MFAPDQBTFtGmEYIPLdKeOnHPCGD+MFAPDQBTFtGmEYIPLdKeOnC0+G+MiDtD9OHdCEDbD8jHPD8dBhUg/8/4/w/goB9+h84k7HeCEWCxkUUBJDBEBAeCx+YUUBJDBBBHnAnDQBBBBBBBBBBBBBBBBAPD8dFhUg/8/4/w/goB9+h84k7HeCEWCxkUUBJDBEBD9uDQBFGEILKOTtmYPdenDfAdAPD9SDMIBAKCIJAnDeBJAeCx+YUUBJ2BBJRKSGMAEAKDBBNAKDBBBHPCID+MFAPDQBTFtGmEYIPLdKeOnC+P+e+8/4BDtD9OHdCbDbD8jHPD8dBhUg/8/4/w/goB9+h84k7HeCEWCxkUUBJDBEBAeCx+YUUBJDBBBHnAnDQBBBBBBBBBBBBBBBBAPD8dFhUg/8/4/w/goB9+h84k7HeCEWCxkUUBJDBEBD9uDQBFGEILKOTtmYPdenDfAdAPD9SDMIBAKCNJAnDeBJAeCx+YUUBJ2BBJRKSFMAEAKDBBBDMIBAKCTJRKMGXGXGXGXGXAYCGrCEZfIBFGEBMAECBDtDMITSEMAEAKDBBIAKDBBBHPCID+MFAPDQBTFtGmEYIPLdKeOnHPCGD+MFAPDQBTFtGmEYIPLdKeOnC0+G+MiDtD9OHdCEDbD8jHPD8dBhUg/8/4/w/goB9+h84k7HeCEWCxkUUBJDBEBAeCx+YUUBJDBBBHnAnDQBBBBBBBBBBBBBBBBAPD8dFhUg/8/4/w/goB9+h84k7HeCEWCxkUUBJDBEBD9uDQBFGEILKOTtmYPdenDfAdAPD9SDMITAKCIJAnDeBJAeCx+YUUBJ2BBJRKSGMAEAKDBBNAKDBBBHPCID+MFAPDQBTFtGmEYIPLdKeOnC+P+e+8/4BDtD9OHdCbDbD8jHPD8dBhUg/8/4/w/goB9+h84k7HeCEWCxkUUBJDBEBAeCx+YUUBJDBBBHnAnDQBBBBBBBBBBBBBBBBAPD8dFhUg/8/4/w/goB9+h84k7HeCEWCxkUUBJDBEBD9uDQBFGEILKOTtmYPdenDfAdAPD9SDMITAKCNJAnDeBJAeCx+YUUBJ2BBJRKSFMAEAKDBBBDMITAKCTJRKMGXGXGXGXGXAYCIrCEZfIBFGEBMAECBDtDMIASEMAEAKDBBIAKDBBBHPCID+MFAPDQBTFtGmEYIPLdKeOnHPCGD+MFAPDQBTFtGmEYIPLdKeOnC0+G+MiDtD9OHdCEDbD8jHPD8dBhUg/8/4/w/goB9+h84k7HeCEWCxkUUBJDBEBAeCx+YUUBJDBBBHnAnDQBBBBBBBBBBBBBBBBAPD8dFhUg/8/4/w/goB9+h84k7HeCEWCxkUUBJDBEBD9uDQBFGEILKOTtmYPdenDfAdAPD9SDMIAAKCIJAnDeBJAeCx+YUUBJ2BBJRKSGMAEAKDBBNAKDBBBHPCID+MFAPDQBTFtGmEYIPLdKeOnC+P+e+8/4BDtD9OHdCbDbD8jHPD8dBhUg/8/4/w/goB9+h84k7HeCEWCxkUUBJDBEBAeCx+YUUBJDBBBHnAnDQBBBBBBBBBBBBBBBBAPD8dFhUg/8/4/w/goB9+h84k7HeCEWCxkUUBJDBEBD9uDQBFGEILKOTtmYPdenDfAdAPD9SDMIAAKCNJAnDeBJAeCx+YUUBJ2BBJRKSFMAEAKDBBBDMIAAKCTJRKMGXGXGXGXGXAYCKrfIBFGEBMAECBDtDMI8wSEMAEAKDBBIAKDBBBHPCID+MFAPDQBTFtGmEYIPLdKeOnHPCGD+MFAPDQBTFtGmEYIPLdKeOnC0+G+MiDtD9OHdCEDbD8jHPD8dBhUg/8/4/w/goB9+h84k7HYCEWCxkUUBJDBEBAYCx+YUUBJDBBBHnAnDQBBBBBBBBBBBBBBBBAPD8dFhUg/8/4/w/goB9+h84k7HYCEWCxkUUBJDBEBD9uDQBFGEILKOTtmYPdenDfAdAPD9SDMI8wAKCIJAnDeBJAYCx+YUUBJ2BBJRKSGMAEAKDBBNAKDBBBHPCID+MFAPDQBTFtGmEYIPLdKeOnC+P+e+8/4BDtD9OHdCbDbD8jHPD8dBhUg/8/4/w/goB9+h84k7HYCEWCxkUUBJDBEBAYCx+YUUBJDBBBHnAnDQBBBBBBBBBBBBBBBBAPD8dFhUg/8/4/w/goB9+h84k7HYCEWCxkUUBJDBEBD9uDQBFGEILKOTtmYPdenDfAdAPD9SDMI8wAKCNJAnDeBJAYCx+YUUBJ2BBJRKSFMAEAKDBBBDMI8wAKCTJRKMAICoBJREAICUFJAM9LQFAERIAOAKlC/fB9LQBMMGXAEAM9PQBAECErRIEXGXAOAKlCi9PQBCBRKSOMAmAEJRYGXGXGXGXGXATAECKrJ2BBAICKZrCEZfIBFGEBMAYCBDtDMIBSEMAYAKDBBIAKDBBBHPCID+MFAPDQBTFtGmEYIPLdKeOnHPCGD+MFAPDQBTFtGmEYIPLdKeOnC0+G+MiDtD9OHdCEDbD8jHPD8dBhUg/8/4/w/goB9+h84k7HeCEWCxkUUBJDBEBAeCx+YUUBJDBBBHnAnDQBBBBBBBBBBBBBBBBAPD8dFhUg/8/4/w/goB9+h84k7HeCEWCxkUUBJDBEBD9uDQBFGEILKOTtmYPdenDfAdAPD9SDMIBAKCIJAnDeBJAeCx+YUUBJ2BBJRKSGMAYAKDBBNAKDBBBHPCID+MFAPDQBTFtGmEYIPLdKeOnC+P+e+8/4BDtD9OHdCbDbD8jHPD8dBhUg/8/4/w/goB9+h84k7HeCEWCxkUUBJDBEBAeCx+YUUBJDBBBHnAnDQBBBBBBBBBBBBBBBBAPD8dFhUg/8/4/w/goB9+h84k7HeCEWCxkUUBJDBEBD9uDQBFGEILKOTtmYPdenDfAdAPD9SDMIBAKCNJAnDeBJAeCx+YUUBJ2BBJRKSFMAYAKDBBBDMIBAKCTJRKMAICGJRIAECTJHEAM9JQBMMGXAK9FQBAKRTAtCFJHtCI6QGSFMMCBRKSEMGXAM9FQBALCUGJAbJREALAbJDBGBRnCBRYEXAEALCU/CBJAYJHIDBIBHdCFD9tAdCFDbHPD9OD9hD9RHdAIAMJDBIBHiCFD9tAiAPD9OD9hD9RHiDQBTFtGmEYIPLdKeOnH8ZAIAQJDBIBHpCFD9tApAPD9OD9hD9RHpAIASJDBIBHyCFD9tAyAPD9OD9hD9RHyDQBTFtGmEYIPLdKeOnH8cDQBFTtGEmYILPdKOenHPAPDQBFGEBFGEBFGEBFGEAnD9uHnDyBjGBAEAGJHIAnAPAPDQILKOILKOILKOILKOD9uHnDyBjGBAIAGJHIAnAPAPDQNVcMNVcMNVcMNVcMD9uHnDyBjGBAIAGJHIAnAPAPDQSQfbSQfbSQfbSQfbD9uHnDyBjGBAIAGJHIAnA8ZA8cDQNVi8ZcMpySQ8c8dfb8e8fHPAPDQBFGEBFGEBFGEBFGED9uHnDyBjGBAIAGJHIAnAPAPDQILKOILKOILKOILKOD9uHnDyBjGBAIAGJHIAnAPAPDQNVcMNVcMNVcMNVcMD9uHnDyBjGBAIAGJHIAnAPAPDQSQfbSQfbSQfbSQfbD9uHnDyBjGBAIAGJHIAnAdAiDQNiV8ZcpMyS8cQ8df8eb8fHdApAyDQNiV8ZcpMyS8cQ8df8eb8fHiDQBFTtGEmYILPdKOenHPAPDQBFGEBFGEBFGEBFGED9uHnDyBjGBAIAGJHIAnAPAPDQILKOILKOILKOILKOD9uHnDyBjGBAIAGJHIAnAPAPDQNVcMNVcMNVcMNVcMD9uHnDyBjGBAIAGJHIAnAPAPDQSQfbSQfbSQfbSQfbD9uHnDyBjGBAIAGJHIAnAdAiDQNVi8ZcMpySQ8c8dfb8e8fHPAPDQBFGEBFGEBFGEBFGED9uHnDyBjGBAIAGJHIAnAPAPDQILKOILKOILKOILKOD9uHnDyBjGBAIAGJHIAnAPAPDQNVcMNVcMNVcMNVcMD9uHnDyBjGBAIAGJHIAnAPAPDQSQfbSQfbSQfbSQfbD9uHnDyBjGBAIAGJREAYCTJHYAM9JQBMMAbCIJHbAG9JQBMMABAVAG9sJALCUGJAcAG9s/8cBBALALCUGJAcCaJAG9sJAG/8cBBMAcCBAKyAVJRVAKQBMC9+RKSFMCBC99AOAKlAGCAAGCA9Ly6yRKMALCU/KBJ8kUUUUBAKMNBT+BUUUBM+KmFTa8jUUUUBCoFlHL8kUUUUBC9+RKGXAFCE9uHOCtJAI9LQBCaRKAE2BBHNC/wFZC/gF9HQBANCbZHVCF9LQBALCoBJCgFCUF/8MBALC84Jha83EBALC8wJha83EBALC8oJha83EBALCAJha83EBALCiJha83EBALCTJha83EBALha83ENALha83EBAEAIJC9wJRcAECFJHNAOJRMGXAF9FQBCQCbAVCF6yRSABRECBRVCBRQCBRfCBRICBRKEXGXAMAcuQBC9+RKSEMGXGXAN2BBHOC/vF9LQBALCoBJAOCIrCa9zAKJCbZCEWJHb8oGIRTAb8oGBRtGXAOCbZHbAS9PQBALAOCa9zAIJCbZCGWJ8oGBAVAbyROAb9FRbGXGXAGCG9HQBABAt87FBABCIJAO87FBABCGJAT87FBSFMAEAtjGBAECNJAOjGBAECIJATjGBMAVAbJRVALCoBJAKCEWJHmAOjGBAmATjGIALAICGWJAOjGBALCoBJAKCFJCbZHKCEWJHTAtjGBATAOjGIAIAbJRIAKCFJRKSGMGXGXAbCb6QBAQAbJAbC989zJCFJRQSFMAM1BBHbCgFZROGXGXAbCa9MQBAMCFJRMSFMAM1BFHbCgBZCOWAOCgBZqROGXAbCa9MQBAMCGJRMSFMAM1BGHbCgBZCfWAOqROGXAbCa9MQBAMCEJRMSFMAM1BEHbCgBZCdWAOqROGXAbCa9MQBAMCIJRMSFMAM2BIC8cWAOqROAMCLJRMMAOCFrCBAOCFZl9zAQJRQMGXGXAGCG9HQBABAt87FBABCIJAQ87FBABCGJAT87FBSFMAEAtjGBAECNJAQjGBAECIJATjGBMALCoBJAKCEWJHOAQjGBAOATjGIALAICGWJAQjGBALCoBJAKCFJCbZHKCEWJHOAtjGBAOAQjGIAICFJRIAKCFJRKSFMGXAOCDF9LQBALAIAcAOCbZJ2BBHbCIrHTlCbZCGWJ8oGBAVCFJHtATyROALAIAblCbZCGWJ8oGBAtAT9FHmJHtAbCbZHTyRbAT9FRTGXGXAGCG9HQBABAV87FBABCIJAb87FBABCGJAO87FBSFMAEAVjGBAECNJAbjGBAECIJAOjGBMALAICGWJAVjGBALCoBJAKCEWJHYAOjGBAYAVjGIALAICFJHICbZCGWJAOjGBALCoBJAKCFJCbZCEWJHYAbjGBAYAOjGIALAIAmJCbZHICGWJAbjGBALCoBJAKCGJCbZHKCEWJHOAVjGBAOAbjGIAKCFJRKAIATJRIAtATJRVSFMAVCBAM2BBHYyHTAOC/+F6HPJROAYCbZRtGXGXAYCIrHmQBAOCFJRbSFMAORbALAIAmlCbZCGWJ8oGBROMGXGXAtQBAbCFJRVSFMAbRVALAIAYlCbZCGWJ8oGBRbMGXGXAP9FQBAMCFJRYSFMAM1BFHYCgFZRTGXGXAYCa9MQBAMCGJRYSFMAM1BGHYCgBZCOWATCgBZqRTGXAYCa9MQBAMCEJRYSFMAM1BEHYCgBZCfWATqRTGXAYCa9MQBAMCIJRYSFMAM1BIHYCgBZCdWATqRTGXAYCa9MQBAMCLJRYSFMAMCKJRYAM2BLC8cWATqRTMATCFrCBATCFZl9zAQJHQRTMGXGXAmCb6QBAYRPSFMAY1BBHMCgFZROGXGXAMCa9MQBAYCFJRPSFMAY1BFHMCgBZCOWAOCgBZqROGXAMCa9MQBAYCGJRPSFMAY1BGHMCgBZCfWAOqROGXAMCa9MQBAYCEJRPSFMAY1BEHMCgBZCdWAOqROGXAMCa9MQBAYCIJRPSFMAYCLJRPAY2BIC8cWAOqROMAOCFrCBAOCFZl9zAQJHQROMGXGXAtCb6QBAPRMSFMAP1BBHMCgFZRbGXGXAMCa9MQBAPCFJRMSFMAP1BFHMCgBZCOWAbCgBZqRbGXAMCa9MQBAPCGJRMSFMAP1BGHMCgBZCfWAbqRbGXAMCa9MQBAPCEJRMSFMAP1BEHMCgBZCdWAbqRbGXAMCa9MQBAPCIJRMSFMAPCLJRMAP2BIC8cWAbqRbMAbCFrCBAbCFZl9zAQJHQRbMGXGXAGCG9HQBABAT87FBABCIJAb87FBABCGJAO87FBSFMAEATjGBAECNJAbjGBAECIJAOjGBMALCoBJAKCEWJHYAOjGBAYATjGIALAICGWJATjGBALCoBJAKCFJCbZCEWJHYAbjGBAYAOjGIALAICFJHICbZCGWJAOjGBALCoBJAKCGJCbZCEWJHOATjGBAOAbjGIALAIAm9FAmCb6qJHICbZCGWJAbjGBAIAt9FAtCb6qJRIAKCEJRKMANCFJRNABCKJRBAECSJREAKCbZRKAICbZRIAfCEJHfAF9JQBMMCBC99AMAc6yRKMALCoFJ8kUUUUBAKM/tIFGa8jUUUUBCTlRLC9+RKGXAFCLJAI9LQBCaRKAE2BBC/+FZC/QF9HQBALhB83ENAECFJRKAEAIJC98JREGXAF9FQBGXAGCG6QBEXGXAKAE9JQBC9+bMAK1BBHGCgFZRIGXGXAGCa9MQBAKCFJRKSFMAK1BFHGCgBZCOWAICgBZqRIGXAGCa9MQBAKCGJRKSFMAK1BGHGCgBZCfWAIqRIGXAGCa9MQBAKCEJRKSFMAK1BEHGCgBZCdWAIqRIGXAGCa9MQBAKCIJRKSFMAK2BIC8cWAIqRIAKCLJRKMALCNJAICFZCGWqHGAICGrCBAICFrCFZl9zAG8oGBJHIjGBABAIjGBABCIJRBAFCaJHFQBSGMMEXGXAKAE9JQBC9+bMAK1BBHGCgFZRIGXGXAGCa9MQBAKCFJRKSFMAK1BFHGCgBZCOWAICgBZqRIGXAGCa9MQBAKCGJRKSFMAK1BGHGCgBZCfWAIqRIGXAGCa9MQBAKCEJRKSFMAK1BEHGCgBZCdWAIqRIGXAGCa9MQBAKCIJRKSFMAK2BIC8cWAIqRIAKCLJRKMABAICGrCBAICFrCFZl9zALCNJAICFZCGWqHI8oGBJHG87FBAIAGjGBABCGJRBAFCaJHFQBMMCBC99AKAE6yRKMAKM/xLGEaK978jUUUUBCAlHE8kUUUUBGXGXAGCI9HQBGXAFC98ZHI9FQBABRGCBRLEXAGAGDBBBHKCiD+rFCiD+sFD/6FHOAKCND+rFCiD+sFD/6FAOD/gFAKCTD+rFCiD+sFD/6FHND/gFD/kFD/lFHVCBDtD+2FHcAOCUUUU94DtHMD9OD9RD/kFHO9DBB/+hDYAOAOD/mFAVAVD/mFANAcANAMD9OD9RD/kFHOAOD/mFD/kFD/kFD/jFD/nFHND/mF9DBBX9LDYHcD/kFCgFDtD9OAKCUUU94DtD9OD9QAOAND/mFAcD/kFCND+rFCU/+EDtD9OD9QAVAND/mFAcD/kFCTD+rFCUU/8ODtD9OD9QDMBBAGCTJRGALCIJHLAI9JQBMMAIAF9PQFAEAFCEZHLCGWHGqCBCTAGl/8MBAEABAICGWJHIAG/8cBBGXAL9FQBAEAEDBIBHKCiD+rFCiD+sFD/6FHOAKCND+rFCiD+sFD/6FAOD/gFAKCTD+rFCiD+sFD/6FHND/gFD/kFD/lFHVCBDtD+2FHcAOCUUUU94DtHMD9OD9RD/kFHO9DBB/+hDYAOAOD/mFAVAVD/mFANAcANAMD9OD9RD/kFHOAOD/mFD/kFD/kFD/jFD/nFHND/mF9DBBX9LDYHcD/kFCgFDtD9OAKCUUU94DtD9OD9QAOAND/mFAcD/kFCND+rFCU/+EDtD9OD9QAVAND/mFAcD/kFCTD+rFCUU/8ODtD9OD9QDMIBMAIAEAG/8cBBSFMABAFC98ZHGT+HUUUBAGAF9PQBAEAFCEZHICEWHLJCBCAALl/8MBAEABAGCEWJHGAL/8cBBAEAIT+HUUUBAGAEAL/8cBBMAECAJ8kUUUUBM+yEGGaO97GXAF9FQBCBRGEXABCTJHEAEDBBBHICBDtHLCUU98D8cFCUU98D8cEHKD9OABDBBBHOAIDQILKOSQfbPden8c8d8e8fCggFDtD9OD/6FAOAIDQBFGENVcMTtmYi8ZpyHICTD+sFD/6FHND/gFAICTD+rFCTD+sFD/6FHVD/gFD/kFD/lFHI9DB/+g6DYAVAIALD+2FHLAVCUUUU94DtHcD9OD9RD/kFHVAVD/mFAIAID/mFANALANAcD9OD9RD/kFHIAID/mFD/kFD/kFD/jFD/nFHND/mF9DBBX9LDYHLD/kFCTD+rFAVAND/mFALD/kFCggEDtD9OD9QHVAIAND/mFALD/kFCaDbCBDnGCBDnECBDnKCBDnOCBDncCBDnMCBDnfCBDnbD9OHIDQNVi8ZcMpySQ8c8dfb8e8fD9QDMBBABAOAKD9OAVAIDQBFTtGEmYILPdKOenD9QDMBBABCAJRBAGCIJHGAF9JQBMMM94FEa8jUUUUBCAlHE8kUUUUBABAFC98ZHIT+JUUUBGXAIAF9PQBAEAFCEZHLCEWHFJCBCAAFl/8MBAEABAICEWJHBAF/8cBBAEALT+JUUUBABAEAF/8cBBMAECAJ8kUUUUBM/hEIGaF97FaL978jUUUUBCTlRGGXAF9FQBCBREEXAGABDBBBHIABCTJHLDBBBHKDQILKOSQfbPden8c8d8e8fHOCTD+sFHNCID+rFDMIBAB9DBBU8/DY9D/zI818/DYANCEDtD9QD/6FD/nFHNAIAKDQBFGENVcMTtmYi8ZpyHICTD+rFCTD+sFD/6FD/mFHKAKD/mFANAICTD+sFD/6FD/mFHVAVD/mFANAOCTD+rFCTD+sFD/6FD/mFHOAOD/mFD/kFD/kFD/lFCBDtD+4FD/jF9DB/+g6DYHND/mF9DBBX9LDYHID/kFCggEDtHcD9OAVAND/mFAID/kFCTD+rFD9QHVAOAND/mFAID/kFCTD+rFAKAND/mFAID/kFAcD9OD9QHNDQBFTtGEmYILPdKOenHID8dBAGDBIBDyB+t+J83EBABCNJAID8dFAGDBIBDyF+t+J83EBALAVANDQNVi8ZcMpySQ8c8dfb8e8fHND8dBAGDBIBDyG+t+J83EBABCiJAND8dFAGDBIBDyE+t+J83EBABCAJRBAECIJHEAF9JQBMMM/3FGEaF978jUUUUBCoBlREGXAGCGrAF9sHIC98ZHL9FQBCBRGABRFEXAFAFDBBBHKCND+rFCND+sFD/6FAKCiD+sFCnD+rFCUUU/8EDtD+uFD/mFDMBBAFCTJRFAGCIJHGAL9JQBMMGXALAI9PQBAEAICEZHGCGWHFqCBCoBAFl/8MBAEABALCGWJHLAF/8cBBGXAG9FQBAEAEDBIBHKCND+rFCND+sFD/6FAKCiD+sFCnD+rFCUUU/8EDtD+uFD/mFDMIBMALAEAF/8cBBMM9TFEaCBCB8oGUkUUBHFABCEJC98ZJHBjGUkUUBGXGXAB8/BCTWHGuQBCaREABAGlCggEJCTrXBCa6QFMAFREMAEMMMFBCUNMIT9tBB",TQ=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]),EQ=new Uint8Array([32,0,65,253,3,1,2,34,4,106,6,5,11,8,7,20,13,33,12,16,128,9,116,64,19,113,127,15,10,21,22,14,255,66,24,54,136,107,18,23,192,26,114,118,132,17,77,101,130,144,27,87,131,44,45,74,156,154,70,167]),CQ={0:"",1:"meshopt_decodeFilterOct",2:"meshopt_decodeFilterQuat",3:"meshopt_decodeFilterExp",NONE:"",OCTAHEDRAL:"meshopt_decodeFilterOct",QUATERNION:"meshopt_decodeFilterQuat",EXPONENTIAL:"meshopt_decodeFilterExp"},SQ={0:"meshopt_decodeVertexBuffer",1:"meshopt_decodeIndexBuffer",2:"meshopt_decodeIndexSequence",ATTRIBUTES:"meshopt_decodeVertexBuffer",TRIANGLES:"meshopt_decodeIndexBuffer",INDICES:"meshopt_decodeIndexSequence"};async function BQ(e,t,i,n,r,o="NONE"){const s=await async function(){IQ||(IQ=async function(){let e=bQ;WebAssembly.validate(TQ)&&(e=wQ,console.log("Warning: meshopt_decoder is using experimental SIMD support"));const t=await WebAssembly.instantiate(function(e){const t=new Uint8Array(e.length);for(let i=0;i96?n-71:n>64?n-65:n>47?n+4:n>46?63:62}let i=0;for(let n=0;n0)throw new Error("glTF: Empty primitive detected: Draco decompression failure?")}(t)}function HQ(e,t,i=4,n,r){if(!n.DracoWriter)throw new Error("options.gltf.DracoWriter not provided");const o=n.DracoWriter.encodeSync({attributes:e}),s=r?.parseSync?.({attributes:e}),a=n._addFauxAttributes(s.attributes),l=n.addBufferView(o);return{primitives:[{attributes:a,mode:i,extensions:{[VQ]:{bufferView:l,attributes:a}}}]}}function*QQ(e){for(const t of e.json.meshes||[])for(const e of t.primitives)yield e}var $Q=Object.freeze({__proto__:null,name:jQ,preprocess:function(e,t,i){const n=new qG(e);for(const e of QQ(n))n.getObjectExtension(e,VQ)},decode:async function(e,t,i){if(!t?.gltf?.decompressMeshes)return;const n=new qG(e),r=[];for(const e of QQ(n))n.getObjectExtension(e,VQ)&&r.push(GQ(n,e,t,i));await Promise.all(r),n.removeExtension(VQ)},encode:function(e,t={}){const i=new qG(e);for(const e of i.json.meshes||[])HQ(e),i.addRequiredExtension(VQ)}});const ZQ="KHR_texture_transform",WQ=ZQ,qQ=new AA,KQ=new EA,XQ=new EA;function JQ(e,t){const i=t.json.materials?.[e],n=[i?.pbrMetallicRoughness?.baseColorTexture,i?.emissiveTexture,i?.normalTexture,i?.occlusionTexture,i?.pbrMetallicRoughness?.metallicRoughnessTexture],r=[];for(const i of n)i&&i?.extensions?.[ZQ]&&YQ(t,e,i,r)}function YQ(e,t,i,n){const r=function(e,t){const i=e.extensions?.[ZQ],{texCoord:n=0}=e,{texCoord:r=n}=i,o=-1!==t.findIndex(([e,t])=>e===n&&t===r);if(!o){const o=function(e){const{offset:t=[0,0],rotation:i=0,scale:n=[1,1]}=e,r=(new EA).set(1,0,0,0,1,0,t[0],t[1],1),o=KQ.set(Math.cos(i),Math.sin(i),0,-Math.sin(i),Math.cos(i),0,0,0,1),s=XQ.set(n[0],0,0,0,n[1],0,0,0,1);return r.multiplyRight(o).multiplyRight(s)}(i);return n!==r&&(e.texCoord=r),t.push([n,r]),{originalTexCoord:n,texCoord:r,matrix:o}}return null}(i,n);if(!r)return;const o=e.json.meshes||[];for(const i of o)for(const n of i.primitives){const i=n.material;Number.isFinite(i)&&t===i&&e$(e,n,r)}}function e$(e,t,i){const{originalTexCoord:n,texCoord:r,matrix:o}=i,s=t.attributes[`TEXCOORD_${n}`];if(Number.isFinite(s)){const i=e.json.accessors?.[s];if(i&&i.bufferView){const s=e.json.bufferViews?.[i.bufferView];if(s){const{arrayBuffer:a,byteOffset:l}=e.buffers[s.buffer],c=(l||0)+(i.byteOffset||0)+(s.byteOffset||0),{ArrayType:u,length:h}=ZG(i,s),d=zG[i.componentType],p=OG[i.type],f=s.byteStride||d*p,m=new Float32Array(h);for(let e=0;e{e.uniforms[t].value&&!(t in i)&&(i[t]=e.uniforms[t].value)}),Object.keys(i).forEach(e=>{"object"==typeof i[e]&&void 0!==i[e].index&&(i[e].texture=t.getTexture(i[e].index))}),i}const u$=[bH,dH,LQ,DQ,UQ,$Q,r$,Object.freeze({__proto__:null,name:s$,decode:async function(e){const t=new qG(e),{json:i}=t;for(const e of i.materials||[]){e.extensions&&e.extensions.KHR_materials_unlit&&(e.unlit=!0),t.removeObjectExtension(e,o$)}t.removeExtension(o$)},encode:function(e){const t=new qG(e),{json:i}=t;if(t.materials)for(const e of i.materials||[])e.unlit&&(delete e.unlit,t.addObjectExtension(e,o$,{}),t.addExtension(o$))}}),Object.freeze({__proto__:null,name:l$,decode:async function(e){const t=new qG(e),{json:i}=t,n=t.getExtension(a$);if(n){const e=function(e,t){const{programs:i=[],shaders:n=[],techniques:r=[]}=e,o=new TextDecoder;return n.forEach(e=>{if(!Number.isFinite(e.bufferView))throw new Error("KHR_techniques_webgl: no shader code");e.code=o.decode(t.getTypedArrayForBufferView(e.bufferView))}),i.forEach(e=>{e.fragmentShader=n[e.fragmentShader],e.vertexShader=n[e.vertexShader]}),r.forEach(e=>{e.program=i[e.program]}),r}(n,t);for(const n of i.materials||[]){const i=t.getObjectExtension(n,a$);i&&(n.technique=Object.assign({},i,e[i.technique]),n.technique.values=c$(n.technique,t)),t.removeObjectExtension(n,a$)}t.removeExtension(a$)}},encode:async function(e,t){}}),t$,RH];function h$(e,t){const i=t?.gltf?.excludeExtensions||{};return!(e in i&&!i[e])}const d$="KHR_binary_glTF";const p$={accessors:"accessor",animations:"animation",buffers:"buffer",bufferViews:"bufferView",images:"image",materials:"material",meshes:"mesh",nodes:"node",samplers:"sampler",scenes:"scene",skins:"skin",textures:"texture"},f$={accessor:"accessors",animations:"animation",buffer:"buffers",bufferView:"bufferViews",image:"images",material:"materials",mesh:"meshes",node:"nodes",sampler:"samplers",scene:"scenes",skin:"skins",texture:"textures"};class m${idToIndexMap={animations:{},accessors:{},buffers:{},bufferViews:{},images:{},materials:{},meshes:{},nodes:{},samplers:{},scenes:{},skins:{},textures:{}};json;normalize(e,t){this.json=e.json;const i=e.json;switch(i.asset&&i.asset.version){case"2.0":return;case void 0:case"1.0":break;default:return void console.warn(`glTF: Unknown version ${i.asset.version}`)}if(!t.normalize)throw new Error("glTF v1 is not supported.");console.warn("Converting glTF v1 to glTF v2 format. This is experimental and may fail."),this._addAsset(i),this._convertTopLevelObjectsToArrays(i),function(e){const t=new qG(e),{json:i}=t;for(const e of i.images||[]){const i=t.getObjectExtension(e,d$);i&&Object.assign(e,i),t.removeObjectExtension(e,d$)}i.buffers&&i.buffers[0]&&delete i.buffers[0].uri,t.removeExtension(d$)}(e),this._convertObjectIdsToArrayIndices(i),this._updateObjects(i),this._updateMaterial(i)}_addAsset(e){e.asset=e.asset||{},e.asset.version="2.0",e.asset.generator=e.asset.generator||"Normalized to glTF 2.0 by loaders.gl"}_convertTopLevelObjectsToArrays(e){for(const t in p$)this._convertTopLevelObjectToArray(e,t)}_convertTopLevelObjectToArray(e,t){const i=e[t];if(i&&!Array.isArray(i)){e[t]=[];for(const n in i){const r=i[n];r.id=r.id||n;const o=e[t].length;e[t].push(r),this.idToIndexMap[t][n]=o}}}_convertObjectIdsToArrayIndices(e){for(const t in p$)this._convertIdsToIndices(e,t);"scene"in e&&(e.scene=this._convertIdToIndex(e.scene,"scene"));for(const t of e.textures)this._convertTextureIds(t);for(const t of e.meshes)this._convertMeshIds(t);for(const t of e.nodes)this._convertNodeIds(t);for(const t of e.scenes)this._convertSceneIds(t)}_convertTextureIds(e){e.source&&(e.source=this._convertIdToIndex(e.source,"image"))}_convertMeshIds(e){for(const t of e.primitives){const{attributes:e,indices:i,material:n}=t;for(const t in e)e[t]=this._convertIdToIndex(e[t],"accessor");i&&(t.indices=this._convertIdToIndex(i,"accessor")),n&&(t.material=this._convertIdToIndex(n,"material"))}}_convertNodeIds(e){e.children&&(e.children=e.children.map(e=>this._convertIdToIndex(e,"node"))),e.meshes&&(e.meshes=e.meshes.map(e=>this._convertIdToIndex(e,"mesh")))}_convertSceneIds(e){e.nodes&&(e.nodes=e.nodes.map(e=>this._convertIdToIndex(e,"node")))}_convertIdsToIndices(e,t){e[t]||(console.warn(`gltf v1: json doesn't contain attribute ${t}`),e[t]=[]);for(const i of e[t])for(const e in i){const t=i[e],n=this._convertIdToIndex(t,e);i[e]=n}}_convertIdToIndex(e,t){const i=f$[t];if(i in this.idToIndexMap){const n=this.idToIndexMap[i][e];if(!Number.isFinite(n))throw new Error(`gltf v1: failed to resolve ${t} with id ${e}`);return n}return e}_updateObjects(e){for(const e of this.json.buffers)delete e.type}_updateMaterial(e){for(const t of e.materials){t.pbrMetallicRoughness={baseColorFactor:[1,1,1,1],metallicFactor:1,roughnessFactor:1};const i=t.values?.tex||t.values?.texture2d_0||t.values?.diffuseTex,n=e.textures.findIndex(e=>e.id===i);-1!==n&&(t.pbrMetallicRoughness.baseColorTexture={index:n})}}}async function g$(e,t,i=0,n,r){return function(e,t,i,n){n.uri&&(e.baseUri=n.uri);if(t instanceof ArrayBuffer&&!function(e,t=0,i={}){const n=new DataView(e),{magic:r=mQ}=i,o=n.getUint32(t,!1);return o===r||o===mQ}(t,i,n)){t=(new TextDecoder).decode(t)}if("string"==typeof t)e.json=ej(t);else if(t instanceof ArrayBuffer){const r={};i=AQ(r,t,i,n.glb),DG("glTF"===r.type,`Invalid GLB magic string ${r.type}`),e._glb=r,e.json=r.json}else DG(!1,"GLTF: must be ArrayBuffer or string");const r=e.json.buffers||[];if(e.buffers=new Array(r.length).fill(null),e._glb&&e._glb.header.hasBinChunk){const{binChunks:t}=e._glb;e.buffers[0]={arrayBuffer:t[0].arrayBuffer,byteOffset:t[0].byteOffset,byteLength:t[0].byteLength}}const o=e.json.images||[];e.images=new Array(o.length).fill({})}(e,t,i,n),function(e,t={}){(new m$).normalize(e,t)}(e,{normalize:n?.gltf?.normalize}),function(e,t={},i){const n=u$.filter(e=>h$(e.name,t));for(const r of n)r.preprocess?.(e,t,i)}(e,n,r),n?.gltf?.loadBuffers&&e.json.buffers&&await async function(e,t,i){const n=e.json.buffers||[];for(let r=0;rh$(e.name,t));for(const r of n)await(r.decode?.(e,t,i))}(e,n,r),e}async function _$(e,t,i,n,r){let o;if(t.uri&&!t.hasOwnProperty("bufferView")){const e=xQ(t.uri,n),{fetch:i}=r,s=await i(e);o=await s.arrayBuffer(),t.bufferView={data:o}}if(Number.isFinite(t.bufferView)){const i=function(e,t,i){const n=e.bufferViews[i];DG(n);const r=t[n.buffer];DG(r);const o=(n.byteOffset||0)+r.byteOffset;return new Uint8Array(r.arrayBuffer,o,n.byteLength)}(e.json,e.buffers,t.bufferView);o=tj(i.buffer,i.byteOffset,i.byteLength)}DG(o,"glTF image has no data");let s=await qV(o,[LG,pQ],{...n,mimeType:t.mimeType,basis:n.basis||{format:dQ()}},r);s&&s[0]&&(s={compressed:!0,mipmaps:!1,width:s[0].width,height:s[0].height,data:s[0]}),e.images=e.images||[],e.images[i]=s}const A$={dataType:null,batchType:null,name:"glTF",id:"gltf",module:"gltf",version:"4.2.4",extensions:["gltf","glb"],mimeTypes:["model/gltf+json","model/gltf-binary"],text:!0,binary:!0,tests:["glTF"],parse:async function(e,t={},i){(t={...A$.options,...t}).gltf={...A$.options.gltf,...t.gltf};const{byteOffset:n=0}=t;return await g$({},e,n,t,i)},options:{gltf:{normalize:!0,loadBuffers:!0,loadImages:!0,decompressMeshes:!0},log:console}};const y$={SCALAR:1,VEC2:2,VEC3:3,VEC4:4,MAT2:4,MAT3:9,MAT4:16},v$={5120:1,5121:1,5122:2,5123:2,5125:4,5126:4},x$=10240,b$=10241,w$=10242,T$=10243,E$=10497,C$=9729,S$=9986,B$={magFilter:x$,minFilter:b$,wrapS:w$,wrapT:T$},I$={[x$]:C$,[b$]:S$,[w$]:E$,[T$]:E$};class M${baseUri="";jsonUnprocessed;json;buffers=[];images=[];postProcess(e,t={}){const{json:i,buffers:n=[],images:r=[]}=e,{baseUri:o=""}=e;return DG(i),this.baseUri=o,this.buffers=n,this.images=r,this.jsonUnprocessed=i,this.json=this._resolveTree(e.json,t),this.json}_resolveTree(e,t={}){const i={...e};return this.json=i,e.bufferViews&&(i.bufferViews=e.bufferViews.map((e,t)=>this._resolveBufferView(e,t))),e.images&&(i.images=e.images.map((e,t)=>this._resolveImage(e,t))),e.samplers&&(i.samplers=e.samplers.map((e,t)=>this._resolveSampler(e,t))),e.textures&&(i.textures=e.textures.map((e,t)=>this._resolveTexture(e,t))),e.accessors&&(i.accessors=e.accessors.map((e,t)=>this._resolveAccessor(e,t))),e.materials&&(i.materials=e.materials.map((e,t)=>this._resolveMaterial(e,t))),e.meshes&&(i.meshes=e.meshes.map((e,t)=>this._resolveMesh(e,t))),e.nodes&&(i.nodes=e.nodes.map((e,t)=>this._resolveNode(e,t)),i.nodes=i.nodes.map((e,t)=>this._resolveNodeChildren(e))),e.skins&&(i.skins=e.skins.map((e,t)=>this._resolveSkin(e,t))),e.scenes&&(i.scenes=e.scenes.map((e,t)=>this._resolveScene(e,t))),"number"==typeof this.json.scene&&i.scenes&&(i.scene=i.scenes[this.json.scene]),i}getScene(e){return this._get(this.json.scenes,e)}getNode(e){return this._get(this.json.nodes,e)}getSkin(e){return this._get(this.json.skins,e)}getMesh(e){return this._get(this.json.meshes,e)}getMaterial(e){return this._get(this.json.materials,e)}getAccessor(e){return this._get(this.json.accessors,e)}getCamera(e){return this._get(this.json.cameras,e)}getTexture(e){return this._get(this.json.textures,e)}getSampler(e){return this._get(this.json.samplers,e)}getImage(e){return this._get(this.json.images,e)}getBufferView(e){return this._get(this.json.bufferViews,e)}getBuffer(e){return this._get(this.json.buffers,e)}_get(e,t){if("object"==typeof t)return t;const i=e&&e[t];return i||console.warn(`glTF file error: Could not find ${e}[${t}]`),i}_resolveScene(e,t){return{...e,id:e.id||`scene-${t}`,nodes:(e.nodes||[]).map(e=>this.getNode(e))}}_resolveNode(e,t){const i={...e,id:e?.id||`node-${t}`};return void 0!==e.mesh&&(i.mesh=this.getMesh(e.mesh)),void 0!==e.camera&&(i.camera=this.getCamera(e.camera)),void 0!==e.skin&&(i.skin=this.getSkin(e.skin)),void 0!==e.meshes&&e.meshes.length&&(i.mesh=e.meshes.reduce((e,t)=>{const i=this.getMesh(t);return e.id=i.id,e.primitives=e.primitives.concat(i.primitives),e},{primitives:[]})),i}_resolveNodeChildren(e){return e.children&&(e.children=e.children.map(e=>this.getNode(e))),e}_resolveSkin(e,t){const i="number"==typeof e.inverseBindMatrices?this.getAccessor(e.inverseBindMatrices):void 0;return{...e,id:e.id||`skin-${t}`,inverseBindMatrices:i}}_resolveMesh(e,t){const i={...e,id:e.id||`mesh-${t}`,primitives:[]};return e.primitives&&(i.primitives=e.primitives.map(e=>{const t={...e,attributes:{},indices:void 0,material:void 0},i=e.attributes;for(const e in i)t.attributes[e]=this.getAccessor(i[e]);return void 0!==e.indices&&(t.indices=this.getAccessor(e.indices)),void 0!==e.material&&(t.material=this.getMaterial(e.material)),t})),i}_resolveMaterial(e,t){const i={...e,id:e.id||`material-${t}`};if(i.normalTexture&&(i.normalTexture={...i.normalTexture},i.normalTexture.texture=this.getTexture(i.normalTexture.index)),i.occlusionTexture&&(i.occlusionTexture={...i.occlusionTexture},i.occlusionTexture.texture=this.getTexture(i.occlusionTexture.index)),i.emissiveTexture&&(i.emissiveTexture={...i.emissiveTexture},i.emissiveTexture.texture=this.getTexture(i.emissiveTexture.index)),i.emissiveFactor||(i.emissiveFactor=i.emissiveTexture?[1,1,1]:[0,0,0]),i.pbrMetallicRoughness){i.pbrMetallicRoughness={...i.pbrMetallicRoughness};const e=i.pbrMetallicRoughness;e.baseColorTexture&&(e.baseColorTexture={...e.baseColorTexture},e.baseColorTexture.texture=this.getTexture(e.baseColorTexture.index)),e.metallicRoughnessTexture&&(e.metallicRoughnessTexture={...e.metallicRoughnessTexture},e.metallicRoughnessTexture.texture=this.getTexture(e.metallicRoughnessTexture.index))}return i}_resolveAccessor(e,t){const i=(n=e.componentType,v$[n]);var n;const r=function(e){return y$[e]}(e.type),o=i*r,s={...e,id:e.id||`accessor-${t}`,bytesPerComponent:i,components:r,bytesPerElement:o,value:void 0,bufferView:void 0,sparse:void 0};if(void 0!==e.bufferView&&(s.bufferView=this.getBufferView(e.bufferView)),s.bufferView){const e=s.bufferView.buffer,{ArrayType:t,byteLength:i}=ZG(s,s.bufferView),n=(s.bufferView.byteOffset||0)+(s.byteOffset||0)+e.byteOffset;let r=e.arrayBuffer.slice(n,n+i);s.bufferView.byteStride&&(r=this._getValueFromInterleavedBuffer(e,n,s.bufferView.byteStride,s.bytesPerElement,s.count)),s.value=new t(r)}return s}_getValueFromInterleavedBuffer(e,t,i,n,r){const o=new Uint8Array(r*n);for(let s=0;s12;){const s={shape:"tile3d"};e.tiles.push(s),i=await o(t,i,n,r,s)}return i}(r,e,t,i,n,z$);case mj:return await D$(r,e,t,i,n);case _j:return await async function(e,t,i,n){if(e.rotateYtoZ=!0,e.gltfUpAxis=i?.["3d-tiles"]?.assetGltfUpAxis?i["3d-tiles"].assetGltfUpAxis:"Y",i?.["3d-tiles"]?.loadGLTF){if(!n)return t.byteLength;const r=await qV(t,A$,i,n);e.gltf=P$(r),e.gpuMemoryUsageInBytes=WG(e.gltf)}else e.gltfArrayBuffer=t;return t.byteLength}(r,e,i,n);case gj:return await O$(r,e,t,i,n);case fj:return await dG(r,e,t,i,n);default:throw new Error(`3DTileLoader: unknown type ${r.type}`)}}async function U$(e,t,i,n){const r=Number.isFinite(t.bitstream)?t.bitstream:t.bufferView;if("number"!=typeof r)return;const o=e.bufferViews[r],s=e.buffers[o.buffer];if(!n?.baseUrl)throw new Error("Url is not provided");if(!n.fetch)throw new Error("fetch is not provided");if(s.uri){const e=`${n?.baseUrl||""}/${s.uri}`,i=await n.fetch(e),r=await i.arrayBuffer();return void(t.explicitBitstream=new Uint8Array(r,o.byteOffset,o.byteLength))}const a=e.buffers.slice(0,o.buffer).reduce((e,t)=>e+t.byteLength,0);t.explicitBitstream=new Uint8Array(i.slice(a,a+s.byteLength),o.byteOffset,o.byteLength)}function N$(e){const t=new DataView(e);return t.getUint32(0,!0)+2**32*t.getUint32(4,!0)}const V$={dataType:null,batchType:null,id:"3d-tiles-subtree",name:"3D Tiles Subtree",module:"3d-tiles",version:dj,extensions:["subtree"],mimeTypes:["application/octet-stream"],tests:["subtree"],parse:async function(e,t,i){if(1952609651!==new Uint32Array(e.slice(0,4))[0])throw new Error("Wrong subtree file magic number");if(1!==new Uint32Array(e.slice(4,8))[0])throw new Error("Wrong subtree file verson, must be 1");const n=N$(e.slice(8,16)),r=new Uint8Array(e,24,n),o=new TextDecoder("utf8").decode(r),s=JSON.parse(o),a=N$(e.slice(16,24));let l=new ArrayBuffer(0);if(a&&(l=e.slice(24+n)),await U$(s,s.tileAvailability,l,i),Array.isArray(s.contentAvailability))for(const e of s.contentAvailability)await U$(s,e,l,i);else await U$(s,s.contentAvailability,l,i);return await U$(s,s.childSubtreeAvailability,l,i),s},options:{}}; /** * @license * Copyright 2009 The Closure Library Authors @@ -49,21 +49,21 @@ function e(e,t){return t.forEach(function(t){t&&"string"!=typeof t&&!Array.isArr * limitations under the License. * * SPDX-License-Identifier: Apache-2.0 - */var Rj=null;try{Rj=new WebAssembly.Instance(new WebAssembly.Module(new Uint8Array([0,97,115,109,1,0,0,0,1,13,2,96,0,1,127,96,4,127,127,127,127,1,127,3,7,6,0,1,1,1,1,1,6,6,1,127,1,65,0,11,7,50,6,3,109,117,108,0,1,5,100,105,118,95,115,0,2,5,100,105,118,95,117,0,3,5,114,101,109,95,115,0,4,5,114,101,109,95,117,0,5,8,103,101,116,95,104,105,103,104,0,0,10,191,1,6,4,0,35,0,11,36,1,1,126,32,0,173,32,1,173,66,32,134,132,32,2,173,32,3,173,66,32,134,132,126,34,4,66,32,135,167,36,0,32,4,167,11,36,1,1,126,32,0,173,32,1,173,66,32,134,132,32,2,173,32,3,173,66,32,134,132,127,34,4,66,32,135,167,36,0,32,4,167,11,36,1,1,126,32,0,173,32,1,173,66,32,134,132,32,2,173,32,3,173,66,32,134,132,128,34,4,66,32,135,167,36,0,32,4,167,11,36,1,1,126,32,0,173,32,1,173,66,32,134,132,32,2,173,32,3,173,66,32,134,132,129,34,4,66,32,135,167,36,0,32,4,167,11,36,1,1,126,32,0,173,32,1,173,66,32,134,132,32,2,173,32,3,173,66,32,134,132,130,34,4,66,32,135,167,36,0,32,4,167,11])),{}).exports}catch{}function Lj(e,t,i){this.low=0|e,this.high=0|t,this.unsigned=!!i}function Fj(e){return!0===(e&&e.__isLong__)}function kj(e){var t=Math.clz32(e&-e);return e?31-t:t}Lj.prototype.__isLong__,Object.defineProperty(Lj.prototype,"__isLong__",{value:!0}),Lj.isLong=Fj;var Dj={},Oj={};function zj(e,t){var i,r,n;return t?(n=0<=(e>>>=0)&&e<256)&&(r=Oj[e])?r:(i=Nj(e,0,!0),n&&(Oj[e]=i),i):(n=-128<=(e|=0)&&e<128)&&(r=Dj[e])?r:(i=Nj(e,e<0?-1:0,!1),n&&(Dj[e]=i),i)}function Uj(e,t){if(isNaN(e))return t?qj:Wj;if(t){if(e<0)return qj;if(e>=Qj)return eG}else{if(e<=-$j)return tG;if(e+1>=$j)return Yj}return e<0?Uj(-e,t).neg():Nj(e%Hj|0,e/Hj|0,t)}function Nj(e,t,i){return new Lj(e,t,i)}Lj.fromInt=zj,Lj.fromNumber=Uj,Lj.fromBits=Nj;var Vj=Math.pow;function jj(e,t,i){if(0===e.length)throw Error("empty string");if("number"==typeof t?(i=t,t=!1):t=!!t,"NaN"===e||"Infinity"===e||"+Infinity"===e||"-Infinity"===e)return t?qj:Wj;if((i=i||10)<2||360)throw Error("interior hyphen");if(0===r)return jj(e.substring(1),t,i).neg();for(var n=Uj(Vj(i,8)),o=Wj,s=0;s>>0:this.low},iG.toNumber=function(){return this.unsigned?(this.high>>>0)*Hj+(this.low>>>0):this.high*Hj+(this.low>>>0)},iG.toString=function(e){if((e=e||10)<2||36>>0).toString(e);if((o=a).isZero())return l+s;for(;l.length<6;)l="0"+l;s=""+l+s}},iG.getHighBits=function(){return this.high},iG.getHighBitsUnsigned=function(){return this.high>>>0},iG.getLowBits=function(){return this.low},iG.getLowBitsUnsigned=function(){return this.low>>>0},iG.getNumBitsAbs=function(){if(this.isNegative())return this.eq(tG)?64:this.neg().getNumBitsAbs();for(var e=0!=this.high?this.high:this.low,t=31;t>0&&!(e&1<>21;return!e||!this.unsigned&&(-1===e&&!(0===this.low&&-2097152===this.high))},iG.isZero=function(){return 0===this.high&&0===this.low},iG.eqz=iG.isZero,iG.isNegative=function(){return!this.unsigned&&this.high<0},iG.isPositive=function(){return this.unsigned||this.high>=0},iG.isOdd=function(){return!(1&~this.low)},iG.isEven=function(){return!(1&this.low)},iG.equals=function(e){return Fj(e)||(e=Gj(e)),(this.unsigned===e.unsigned||this.high>>>31!=1||e.high>>>31!=1)&&(this.high===e.high&&this.low===e.low)},iG.eq=iG.equals,iG.notEquals=function(e){return!this.eq(e)},iG.neq=iG.notEquals,iG.ne=iG.notEquals,iG.lessThan=function(e){return this.comp(e)<0},iG.lt=iG.lessThan,iG.lessThanOrEqual=function(e){return this.comp(e)<=0},iG.lte=iG.lessThanOrEqual,iG.le=iG.lessThanOrEqual,iG.greaterThan=function(e){return this.comp(e)>0},iG.gt=iG.greaterThan,iG.greaterThanOrEqual=function(e){return this.comp(e)>=0},iG.gte=iG.greaterThanOrEqual,iG.ge=iG.greaterThanOrEqual,iG.compare=function(e){if(Fj(e)||(e=Gj(e)),this.eq(e))return 0;var t=this.isNegative(),i=e.isNegative();return t&&!i?-1:!t&&i?1:this.unsigned?e.high>>>0>this.high>>>0||e.high===this.high&&e.low>>>0>this.low>>>0?-1:1:this.sub(e).isNegative()?-1:1},iG.comp=iG.compare,iG.negate=function(){return!this.unsigned&&this.eq(tG)?tG:this.not().add(Kj)},iG.neg=iG.negate,iG.add=function(e){Fj(e)||(e=Gj(e));var t=this.high>>>16,i=65535&this.high,r=this.low>>>16,n=65535&this.low,o=e.high>>>16,s=65535&e.high,a=e.low>>>16,l=0,c=0,u=0,h=0;return u+=(h+=n+(65535&e.low))>>>16,c+=(u+=r+a)>>>16,l+=(c+=i+s)>>>16,l+=t+o,Nj((u&=65535)<<16|(h&=65535),(l&=65535)<<16|(c&=65535),this.unsigned)},iG.subtract=function(e){return Fj(e)||(e=Gj(e)),this.add(e.neg())},iG.sub=iG.subtract,iG.multiply=function(e){if(this.isZero())return this;if(Fj(e)||(e=Gj(e)),Rj)return Nj(Rj.mul(this.low,this.high,e.low,e.high),Rj.get_high(),this.unsigned);if(e.isZero())return this.unsigned?qj:Wj;if(this.eq(tG))return e.isOdd()?tG:Wj;if(e.eq(tG))return this.isOdd()?tG:Wj;if(this.isNegative())return e.isNegative()?this.neg().mul(e.neg()):this.neg().mul(e).neg();if(e.isNegative())return this.mul(e.neg()).neg();if(this.lt(Zj)&&e.lt(Zj))return Uj(this.toNumber()*e.toNumber(),this.unsigned);var t=this.high>>>16,i=65535&this.high,r=this.low>>>16,n=65535&this.low,o=e.high>>>16,s=65535&e.high,a=e.low>>>16,l=65535&e.low,c=0,u=0,h=0,d=0;return h+=(d+=n*l)>>>16,u+=(h+=r*l)>>>16,h&=65535,u+=(h+=n*a)>>>16,c+=(u+=i*l)>>>16,u&=65535,c+=(u+=r*a)>>>16,u&=65535,c+=(u+=n*s)>>>16,c+=t*l+i*a+r*s+n*o,Nj((h&=65535)<<16|(d&=65535),(c&=65535)<<16|(u&=65535),this.unsigned)},iG.mul=iG.multiply,iG.divide=function(e){if(Fj(e)||(e=Gj(e)),e.isZero())throw Error("division by zero");var t,i,r;if(Rj)return this.unsigned||-2147483648!==this.high||-1!==e.low||-1!==e.high?Nj((this.unsigned?Rj.div_u:Rj.div_s)(this.low,this.high,e.low,e.high),Rj.get_high(),this.unsigned):this;if(this.isZero())return this.unsigned?qj:Wj;if(this.unsigned){if(e.unsigned||(e=e.toUnsigned()),e.gt(this))return qj;if(e.gt(this.shru(1)))return Xj;r=qj}else{if(this.eq(tG))return e.eq(Kj)||e.eq(Jj)?tG:e.eq(tG)?Kj:(t=this.shr(1).div(e).shl(1)).eq(Wj)?e.isNegative()?Kj:Jj:(i=this.sub(e.mul(t)),r=t.add(i.div(e)));if(e.eq(tG))return this.unsigned?qj:Wj;if(this.isNegative())return e.isNegative()?this.neg().div(e.neg()):this.neg().div(e).neg();if(e.isNegative())return this.div(e.neg()).neg();r=Wj}for(i=this;i.gte(e);){t=Math.max(1,Math.floor(i.toNumber()/e.toNumber()));for(var n=Math.ceil(Math.log(t)/Math.LN2),o=n<=48?1:Vj(2,n-48),s=Uj(t),a=s.mul(e);a.isNegative()||a.gt(i);)a=(s=Uj(t-=o,this.unsigned)).mul(e);s.isZero()&&(s=Kj),r=r.add(s),i=i.sub(a)}return r},iG.div=iG.divide,iG.modulo=function(e){return Fj(e)||(e=Gj(e)),Rj?Nj((this.unsigned?Rj.rem_u:Rj.rem_s)(this.low,this.high,e.low,e.high),Rj.get_high(),this.unsigned):this.sub(this.div(e).mul(e))},iG.mod=iG.modulo,iG.rem=iG.modulo,iG.not=function(){return Nj(~this.low,~this.high,this.unsigned)},iG.countLeadingZeros=function(){return this.high?Math.clz32(this.high):Math.clz32(this.low)+32},iG.clz=iG.countLeadingZeros,iG.countTrailingZeros=function(){return this.low?kj(this.low):kj(this.high)+32},iG.ctz=iG.countTrailingZeros,iG.and=function(e){return Fj(e)||(e=Gj(e)),Nj(this.low&e.low,this.high&e.high,this.unsigned)},iG.or=function(e){return Fj(e)||(e=Gj(e)),Nj(this.low|e.low,this.high|e.high,this.unsigned)},iG.xor=function(e){return Fj(e)||(e=Gj(e)),Nj(this.low^e.low,this.high^e.high,this.unsigned)},iG.shiftLeft=function(e){return Fj(e)&&(e=e.toInt()),0==(e&=63)?this:e<32?Nj(this.low<>>32-e,this.unsigned):Nj(0,this.low<>>e|this.high<<32-e,this.high>>e,this.unsigned):Nj(this.high>>e-32,this.high>=0?0:-1,this.unsigned)},iG.shr=iG.shiftRight,iG.shiftRightUnsigned=function(e){return Fj(e)&&(e=e.toInt()),0==(e&=63)?this:e<32?Nj(this.low>>>e|this.high<<32-e,this.high>>>e,this.unsigned):Nj(32===e?this.high:this.high>>>e-32,0,this.unsigned)},iG.shru=iG.shiftRightUnsigned,iG.shr_u=iG.shiftRightUnsigned,iG.rotateLeft=function(e){var t;return Fj(e)&&(e=e.toInt()),0==(e&=63)?this:32===e?Nj(this.high,this.low,this.unsigned):e<32?(t=32-e,Nj(this.low<>>t,this.high<>>t,this.unsigned)):(t=32-(e-=32),Nj(this.high<>>t,this.low<>>t,this.unsigned))},iG.rotl=iG.rotateLeft,iG.rotateRight=function(e){var t;return Fj(e)&&(e=e.toInt()),0==(e&=63)?this:32===e?Nj(this.high,this.low,this.unsigned):e<32?(t=32-e,Nj(this.high<>>e,this.low<>>e,this.unsigned)):(t=32-(e-=32),Nj(this.low<>>e,this.high<>>e,this.unsigned))},iG.rotr=iG.rotateRight,iG.toSigned=function(){return this.unsigned?Nj(this.low,this.high,!1):this},iG.toUnsigned=function(){return this.unsigned?this:Nj(this.low,this.high,!0)},iG.toBytes=function(e){return e?this.toBytesLE():this.toBytesBE()},iG.toBytesLE=function(){var e=this.high,t=this.low;return[255&t,t>>>8&255,t>>>16&255,t>>>24,255&e,e>>>8&255,e>>>16&255,e>>>24]},iG.toBytesBE=function(){var e=this.high,t=this.low;return[e>>>24,e>>>16&255,e>>>8&255,255&e,t>>>24,t>>>16&255,t>>>8&255,255&t]},Lj.fromBytes=function(e,t,i){return i?Lj.fromBytesLE(e,t):Lj.fromBytesBE(e,t)},Lj.fromBytesLE=function(e,t){return new Lj(e[0]|e[1]<<8|e[2]<<16|e[3]<<24,e[4]|e[5]<<8|e[6]<<16|e[7]<<24,t)},Lj.fromBytesBE=function(e,t){return new Lj(e[4]<<24|e[5]<<16|e[6]<<8|e[7],e[0]<<24|e[1]<<16|e[2]<<8|e[3],t)},"function"==typeof BigInt&&(Lj.fromBigInt=function(e,t){return Nj(Number(BigInt.asIntN(32,e)),Number(BigInt.asIntN(32,e>>BigInt(32))),t)},Lj.fromValue=function(e,t){return"bigint"==typeof e?Lj.fromBigInt(e,t):Gj(e,t)},iG.toBigInt=function(){var e=BigInt(this.low>>>0);return BigInt(this.unsigned?this.high>>>0:this.high)<=.5?1/3*(4*e*e-1):1/3*(1-4*(1-e)*(1-e))}function aG(e){return[sG(e[0]),sG(e[1])]}function lG(e,[t,i]){switch(e){case 0:return[1,t,i];case 1:return[-t,1,i];case 2:return[-t,-i,1];case 3:return[-1,-i,-t];case 4:return[i,-1,-t];case 5:return[i,t,-1];default:throw new Error("Invalid face")}}function cG([e,t,i]){const r=Math.atan2(i,Math.sqrt(e*e+t*t));return[Math.atan2(t,e)*nG,r*nG]}function uG(e,t,i,r){if(0===r){1===i&&(t[0]=e-1-t[0],t[1]=e-1-t[1]);const r=t[0];t[0]=t[1],t[1]=r}}function hG(e){const{face:t,ij:i,level:r}=e,n=[[0,0],[0,1],[1,1],[1,0],[0,0]],o=Math.max(1,Math.ceil(100*Math.pow(2,-r))),s=new Float64Array(4*o*2+2);let a=0,l=0;for(let e=0;e<4;e++){const c=n[e].slice(0),u=n[e+1],h=(u[0]-c[0])/o,d=(u[1]-c[1])/o;for(let e=0;e89.999&&(e[0]=l);const n=e[0]-l;e[0]+=n>180?-360:n<-180?360:0,s[a++]=e[0],s[a++]=e[1],l=e[0]}}return s[a++]=s[0],s[a++]=s[1],s}function dG(e){const t=function(e){if(e.indexOf("/")>0)return e;const t=rG(e);return function(e){if(e.isZero())return"";let t=e.toString(2);for(;t.length<64;)t="0"+t;const i=t.lastIndexOf("1"),r=t.substring(0,3),n=t.substring(3,i),o=n.length/2,s=Lj.fromString(r,!0,2).toString(10);let a="";if(0!==o)for(a=Lj.fromString(n,!0,2).toString(4);a.length=0;e--){o=n-e;const t=r[e];let i=0,a=0;"1"===t?a=1:"2"===t?(i=1,a=1):"3"===t&&(i=1);const l=Math.pow(2,o-1);uG(l,s,i,a),s[0]+=l*i,s[1]+=l*a}if(i%2==1){const e=s[0];s[0]=s[1],s[1]=e}return{face:i,ij:s,level:o}}(t);return i}function pG(e){return function(e){const t=aG(oG(e.ij,e.level,[.5,.5]));return cG(lG(e.face,t))}(dG(e))}function fG(e){if(e.length%2!=0)throw new Error("Invalid corners");const t=[],i=[];for(let r=0;re-t),i.sort((e,t)=>e-t),{west:t[0],east:t[t.length-1],north:i[i.length-1],south:i[0]}}function mG(e,t){const i=t?.minimumHeight||0,r=t?.maximumHeight||0,n=function(e){let t;if(2===e.face||5===e.face){let i=null,r=0;for(let t=0;t<4;t++){const n=hG(dG(`${e.face}/${t}`));null==i&&(i=new Float64Array(4*n.length)),i.set(n,r),r+=n.length}t=fG(i)}else t=fG(hG(e));return t}(dG(e)),o=n.west,s=n.south,a=n.east,l=n.north,c=[];return c.push(new mA(o,l,i)),c.push(new mA(a,l,i)),c.push(new mA(a,s,i)),c.push(new mA(o,s,i)),c.push(new mA(o,l,r)),c.push(new mA(a,l,r)),c.push(new mA(a,s,r)),c.push(new mA(o,s,r)),c}function gG(e){const t=e.token,i={minimumHeight:e.minimumHeight,maximumHeight:e.maximumHeight},r=mG(t,i),n=pG(t),o=n[0],s=n[1],a=iF.WGS84.cartographicToCartesian([o,s,i.maximumHeight]),l=new mA(a[0],a[1],a[2]);r.push(l);const c=NI(r);return[...c.center,...c.halfAxes]}const _G={QUADTREE:4,OCTREE:8};function AG(e,t,i){if(e?.box){const r=function(e,t){const i=function(e){return e.and(e.not().add(1))}(e).shiftRightUnsigned(2);return e.add(Lj.fromNumber(2*t+1-4).multiply(i))}(rG(e.s2VolumeInfo.token),t),n=function(e){if(e.isZero())return"X";let t=e.countTrailingZeros();t=(t-t%4)/4;const i=t;t*=4;const r=e.shiftRightUnsigned(t).toString(16).replace(/0+$/,"");return Array(17-i-r.length).join("0")+r}(r),o={...e.s2VolumeInfo};if(o.token=n,"OCTREE"===i){const t=e.s2VolumeInfo,i=t.maximumHeight-t.minimumHeight,r=i/2,n=t.minimumHeight+i/2;t.minimumHeight=n-r,t.maximumHeight=n+r}return{box:gG(o),s2VolumeInfo:o}}}async function yG(e){const{implicitOptions:t,parentData:i={mortonIndex:0,x:0,y:0,z:0},childIndex:r=0,s2VolumeBox:n,loaderOptions:o}=e;let{subtree:s,level:a=0,globalData:l={level:0,mortonIndex:0,x:0,y:0,z:0}}=e;const{subdivisionScheme:c,subtreeLevels:u,maximumLevel:h,contentUrlTemplate:d,subtreesUriTemplate:p,basePath:f}=t,m={children:[],lodMetricValue:0,contentUrl:""};if(!h)return Zu.once(`Missing 'maximumLevel' or 'availableLevels' property. The subtree ${d} won't be loaded...`),m;const g=a+l.level;if(g>h)return m;const _=_G[c],A=Math.log2(_),y=1&r,v=r>>1&1,x=r>>2&1,b=(_**a-1)/(_-1);let w=bG(i.mortonIndex,r,A),T=b+w,E=bG(i.x,y,1),C=bG(i.y,v,1),B=bG(i.z,x,1),S=!1;a>=u&&(S=vG(s.childSubtreeAvailability,w));const I=bG(l.x,E,a),M=bG(l.y,C,a),P=bG(l.z,B,a);if(S){const e=wG(`${f}/${p}`,g,I,M,P);s=await VS(e,Pj,o),l={mortonIndex:w,x:E,y:C,z:B,level:a},w=0,T=0,E=0,C=0,B=0,a=0}if(!vG(s.tileAvailability,T))return m;vG(s.contentAvailability,T)&&(m.contentUrl=wG(d,g,I,M,P));const R=a+1,L={mortonIndex:w,x:E,y:C,z:B};for(let e=0;e<_;e++){const i=AG(n,e,c),r=await yG({subtree:s,implicitOptions:t,loaderOptions:o,parentData:L,childIndex:e,level:R,globalData:{...l},s2VolumeBox:i});if(r.contentUrl||r.children.length){const e=xG(r,g+1,{childTileX:E,childTileY:C,childTileZ:B},t,n);m.children.push(e)}}return m}function vG(e,t){let i;return Array.isArray(e)?(i=e[0],e.length>1&&Zu.once('Not supported extension "3DTILES_multiple_contents" has been detected')):i=e,"constant"in i?Boolean(i.constant):!!i.explicitBitstream&&function(e,t){const i=Math.floor(e/8),r=e%8;return 1==(t[i]>>r&1)}(t,i.explicitBitstream)}function xG(e,t,i,r,n){const{basePath:o,refine:s,getRefine:a,lodMetricType:l,getTileType:c,rootLodMetricValue:u,rootBoundingVolume:h}=r,d=e.contentUrl&&e.contentUrl.replace(`${o}/`,""),p=u/2**t,f=function(e,t,i){if(t.region){const{childTileX:r,childTileY:n,childTileZ:o}=i,[s,a,l,c,u,h]=t.region,d=2**e,p=(l-s)/d,f=(c-a)/d,m=(h-u)/d,[g,_]=[s+p*r,s+p*(r+1)],[A,y]=[a+f*n,a+f*(n+1)],[v,x]=[u+m*o,u+m*(o+1)];return{region:[g,A,_,y,v,x]}}if(t.box)return t;throw new Error(`Unsupported bounding volume type ${JSON.stringify(t)}`)}(t,n?.box?{box:n.box}:h,i);return{children:e.children,contentUrl:e.contentUrl,content:{uri:d},id:e.contentUrl,refine:a(s),type:c(e),lodMetricType:l,lodMetricValue:p,geometricError:p,transform:e.transform,boundingVolume:f}}function bG(e,t,i){return(e<o[e])}function TG(e,t=""){if(!t)return YO.EMPTY;const i=t.split("?")[0].split(".").pop();switch(i){case"pnts":return YO.POINTCLOUD;case"i3dm":case"b3dm":case"glb":case"gltf":return YO.SCENEGRAPH;default:return i||YO.EMPTY}}function EG(e){switch(e){case"REPLACE":case"replace":return JO.REPLACE;case"ADD":case"add":return JO.ADD;default:return e}}function CG(e,t){if(/^[a-z][0-9a-z+.-]*:/i.test(t)){const i=new URL(e,`${t}/`);return decodeURI(i.toString())}return e.startsWith("/")?e:qO(t,e)}function BG(e,t){if(!e)return null;let i;if(e.content){const r=e.content.uri||e.content?.url;void 0!==r&&(i=CG(r,t))}return{...e,id:i,contentUrl:i,lodMetricType:tz.GEOMETRIC_ERROR,lodMetricValue:e.geometricError,transformMatrix:e.transform,type:TG(0,i),refine:EG(e.refine)}}async function SG(e,t,i,r,n){const{subdivisionScheme:o,maximumLevel:s,availableLevels:a,subtreeLevels:l,subtrees:{uri:c}}=r,u=CG(wG(c,0,0,0,0),i),h=await VS(u,Pj,n),d=e.content?.uri,p=d?CG(d,i):"",f=t?.root?.refine,m=e.geometricError,g=e.boundingVolume.extensions?.["3DTILES_bounding_volume_S2"];if(g){const t={box:gG(g),s2VolumeInfo:g};e.boundingVolume=t}const _=e.boundingVolume,A={contentUrlTemplate:p,subtreesUriTemplate:c,subdivisionScheme:o,subtreeLevels:l,maximumLevel:Number.isFinite(a)?a-1:s,refine:f,basePath:i,lodMetricType:tz.GEOMETRIC_ERROR,rootLodMetricValue:m,rootBoundingVolume:_,getTileType:TG,getRefine:EG};return await async function(e,t,i,r,n){if(!e)return null;const{children:o,contentUrl:s}=await yG({subtree:i,implicitOptions:r,loaderOptions:n});let a,l=null;s&&(a=s,l={uri:s.replace(`${t}/`,"")});const c={...e,id:a,contentUrl:a,lodMetricType:tz.GEOMETRIC_ERROR,lodMetricValue:e.geometricError,transformMatrix:e.transform,type:TG(0,a),refine:EG(e.refine),content:l||e.content,children:o};return c}(e,i,h,A,n)}function IG(e){return e?.extensions?.["3DTILES_implicit_tiling"]||e?.implicitTiling}const MG={dataType:null,batchType:null,id:"3d-tiles",name:"3D Tiles",module:"3d-tiles",version:iz,extensions:["cmpt","pnts","b3dm","i3dm"],mimeTypes:["application/octet-stream"],tests:["cmpt","pnts","b3dm","i3dm"],parse:async function(e,t={},i){const r=t["3d-tiles"]||{};let n;n="auto"===r.isTileset?i?.url&&-1!==i.url.indexOf(".json"):r.isTileset;return n?async function(e,t,i){const r=JSON.parse((new TextDecoder).decode(e)),n=i?.url||"",o=function(e){return function(e){const t=e?e.lastIndexOf("/"):-1;return t>=0?e.substr(0,t):""}(e)}(n),s=await async function(e,t,i){let r=null;const n=IG(e.root);r=n&&e.root?await SG(e.root,e,t,n,i):BG(e.root,t);const o=[];for(o.push(r);o.length>0;){const r=o.pop()||{},n=r.children||[],s=[];for(const r of n){const n=IG(r);let a;a=n?await SG(r,e,t,n,i):BG(r,t),a&&(s.push(a),o.push(a))}r.children=s}return r}(r,o,t||{}),a={...r,shape:"tileset3d",loader:MG,url:n,queryString:i?.queryString||"",basePath:o,root:s||r.root,type:ez.TILES3D,lodMetricType:tz.GEOMETRIC_ERROR,lodMetricValue:r.root?.geometricError||0};return a}(e,t,i):async function(e,t,i){const r={content:{shape:"tile3d",featureIds:null}},n=0;return await Sj(e,n,t,i,r.content),r.content}(e,t,i)},options:{"3d-tiles":{loadGLTF:!0,decodeQuantizedPositions:!1,isTileset:"auto",assetGltfUpAxis:null}}};const PG={aliceblue:[240,248,255],antiquewhite:[250,235,215],aqua:[0,255,255],aquamarine:[127,255,212],azure:[240,255,255],beige:[245,245,220],bisque:[255,228,196],black:[0,0,0],blanchedalmond:[255,235,205],blue:[0,0,255],blueviolet:[138,43,226],brown:[165,42,42],burlywood:[222,184,135],cadetblue:[95,158,160],chartreuse:[127,255,0],chocolate:[210,105,30],coral:[255,127,80],cornflowerblue:[100,149,237],cornsilk:[255,248,220],crimson:[220,20,60],cyan:[0,255,255],darkblue:[0,0,139],darkcyan:[0,139,139],darkgoldenrod:[184,134,11],darkgray:[169,169,169],darkgreen:[0,100,0],darkgrey:[169,169,169],darkkhaki:[189,183,107],darkmagenta:[139,0,139],darkolivegreen:[85,107,47],darkorange:[255,140,0],darkorchid:[153,50,204],darkred:[139,0,0],darksalmon:[233,150,122],darkseagreen:[143,188,143],darkslateblue:[72,61,139],darkslategray:[47,79,79],darkslategrey:[47,79,79],darkturquoise:[0,206,209],darkviolet:[148,0,211],deeppink:[255,20,147],deepskyblue:[0,191,255],dimgray:[105,105,105],dimgrey:[105,105,105],dodgerblue:[30,144,255],firebrick:[178,34,34],floralwhite:[255,250,240],forestgreen:[34,139,34],fuchsia:[255,0,255],gainsboro:[220,220,220],ghostwhite:[248,248,255],gold:[255,215,0],goldenrod:[218,165,32],gray:[128,128,128],green:[0,128,0],greenyellow:[173,255,47],grey:[128,128,128],honeydew:[240,255,240],hotpink:[255,105,180],indianred:[205,92,92],indigo:[75,0,130],ivory:[255,255,240],khaki:[240,230,140],lavender:[230,230,250],lavenderblush:[255,240,245],lawngreen:[124,252,0],lemonchiffon:[255,250,205],lightblue:[173,216,230],lightcoral:[240,128,128],lightcyan:[224,255,255],lightgoldenrodyellow:[250,250,210],lightgray:[211,211,211],lightgreen:[144,238,144],lightgrey:[211,211,211],lightpink:[255,182,193],lightsalmon:[255,160,122],lightseagreen:[32,178,170],lightskyblue:[135,206,250],lightslategray:[119,136,153],lightslategrey:[119,136,153],lightsteelblue:[176,196,222],lightyellow:[255,255,224],lime:[0,255,0],limegreen:[50,205,50],linen:[250,240,230],magenta:[255,0,255],maroon:[128,0,0],mediumaquamarine:[102,205,170],mediumblue:[0,0,205],mediumorchid:[186,85,211],mediumpurple:[147,112,219],mediumseagreen:[60,179,113],mediumslateblue:[123,104,238],mediumspringgreen:[0,250,154],mediumturquoise:[72,209,204],mediumvioletred:[199,21,133],midnightblue:[25,25,112],mintcream:[245,255,250],mistyrose:[255,228,225],moccasin:[255,228,181],navajowhite:[255,222,173],navy:[0,0,128],oldlace:[253,245,230],olive:[128,128,0],olivedrab:[107,142,35],orange:[255,165,0],orangered:[255,69,0],orchid:[218,112,214],palegoldenrod:[238,232,170],palegreen:[152,251,152],paleturquoise:[175,238,238],palevioletred:[219,112,147],papayawhip:[255,239,213],peachpuff:[255,218,185],peru:[205,133,63],pink:[255,192,203],plum:[221,160,221],powderblue:[176,224,230],purple:[128,0,128],rebeccapurple:[102,51,153],red:[255,0,0],rosybrown:[188,143,143],royalblue:[65,105,225],saddlebrown:[139,69,19],salmon:[250,128,114],sandybrown:[244,164,96],seagreen:[46,139,87],seashell:[255,245,238],sienna:[160,82,45],silver:[192,192,192],skyblue:[135,206,235],slateblue:[106,90,205],slategray:[112,128,144],slategrey:[112,128,144],snow:[255,250,250],springgreen:[0,255,127],steelblue:[70,130,180],tan:[210,180,140],teal:[0,128,128],thistle:[216,191,216],tomato:[255,99,71],turquoise:[64,224,208],violet:[238,130,238],wheat:[245,222,179],white:[255,255,255],whitesmoke:[245,245,245],yellow:[255,255,0],yellowgreen:[154,205,50]};for(const e in PG)Object.freeze(PG[e]);var RG=Object.freeze(PG);const LG=Object.create(null);for(const e in RG)Object.hasOwn(RG,e)&&(LG[RG[e]]=e);const FG={to:{},get:{}};function kG(e,t,i){return Math.min(Math.max(t,e),i)}function DG(e){const t=Math.round(e).toString(16).toUpperCase();return t.length<2?"0"+t:t}FG.get=function(e){let t,i;switch(e.slice(0,3).toLowerCase()){case"hsl":t=FG.get.hsl(e),i="hsl";break;case"hwb":t=FG.get.hwb(e),i="hwb";break;default:t=FG.get.rgb(e),i="rgb"}return t?{model:i,value:t}:null},FG.get.rgb=function(e){if(!e)return null;let t,i,r,n=[0,0,0,1];if(t=e.match(/^#([a-f\d]{6})([a-f\d]{2})?$/i)){for(r=t[2],t=t[1],i=0;i<3;i++){const e=2*i;n[i]=Number.parseInt(t.slice(e,e+2),16)}r&&(n[3]=Number.parseInt(r,16)/255)}else if(t=e.match(/^#([a-f\d]{3,4})$/i)){for(t=t[1],r=t[3],i=0;i<3;i++)n[i]=Number.parseInt(t[i]+t[i],16);r&&(n[3]=Number.parseInt(r+r,16)/255)}else if(t=e.match(/^rgba?\(\s*([+-]?(?:\d*\.)?\d+(?:e\d+)?)(?=[\s,])\s*(?:,\s*)?([+-]?(?:\d*\.)?\d+(?:e\d+)?)(?=[\s,])\s*(?:,\s*)?([+-]?(?:\d*\.)?\d+(?:e\d+)?)\s*(?:[\s,|/]\s*([+-]?(?:\d*\.)?\d+(?:e\d+)?)(%?)\s*)?\)$/i)){for(i=0;i<3;i++)n[i]=Number.parseFloat(t[i+1]);t[4]&&(n[3]=t[5]?.01*Number.parseFloat(t[4]):Number.parseFloat(t[4]))}else{if(!(t=e.match(/^rgba?\(\s*([+-]?[\d.]+)%\s*,?\s*([+-]?[\d.]+)%\s*,?\s*([+-]?[\d.]+)%\s*(?:[\s,|/]\s*([+-]?[\d.]+)(%?)\s*)?\)$/i)))return(t=e.toLowerCase().match(/^(\w+)$/))?"transparent"===t[1]?[0,0,0,0]:Object.hasOwn(RG,t[1])?(n=RG[t[1]].slice(),n[3]=1,n):null:null;for(i=0;i<3;i++)n[i]=Math.round(2.55*Number.parseFloat(t[i+1]));t[4]&&(n[3]=t[5]?.01*Number.parseFloat(t[4]):Number.parseFloat(t[4]))}for(i=0;i<3;i++)n[i]=kG(n[i],0,255);return n[3]=kG(n[3],0,1),n},FG.get.hsl=function(e){if(!e)return null;const t=e.match(/^hsla?\(\s*([+-]?(?:\d{0,3}\.)?\d+)(?:deg)?\s*,?\s*([+-]?[\d.]+)%\s*,?\s*([+-]?[\d.]+)%\s*(?:[,|/]\s*([+-]?(?=\.\d|\d)(?:0|[1-9]\d*)?(?:\.\d*)?(?:e[+-]?\d+)?)\s*)?\)$/i);if(t){const e=Number.parseFloat(t[4]);return[(Number.parseFloat(t[1])%360+360)%360,kG(Number.parseFloat(t[2]),0,100),kG(Number.parseFloat(t[3]),0,100),kG(Number.isNaN(e)?1:e,0,1)]}return null},FG.get.hwb=function(e){if(!e)return null;const t=e.match(/^hwb\(\s*([+-]?\d{0,3}(?:\.\d+)?)(?:deg)?\s*[\s,]\s*([+-]?[\d.]+)%\s*[\s,]\s*([+-]?[\d.]+)%\s*(?:[\s,]\s*([+-]?(?=\.\d|\d)(?:0|[1-9]\d*)?(?:\.\d*)?(?:e[+-]?\d+)?)\s*)?\)$/i);if(t){const e=Number.parseFloat(t[4]);return[(Number.parseFloat(t[1])%360+360)%360,kG(Number.parseFloat(t[2]),0,100),kG(Number.parseFloat(t[3]),0,100),kG(Number.isNaN(e)?1:e,0,1)]}return null},FG.to.hex=function(...e){return"#"+DG(e[0])+DG(e[1])+DG(e[2])+(e[3]<1?DG(Math.round(255*e[3])):"")},FG.to.rgb=function(...e){return e.length<4||1===e[3]?"rgb("+Math.round(e[0])+", "+Math.round(e[1])+", "+Math.round(e[2])+")":"rgba("+Math.round(e[0])+", "+Math.round(e[1])+", "+Math.round(e[2])+", "+e[3]+")"},FG.to.rgb.percent=function(...e){const t=Math.round(e[0]/255*100),i=Math.round(e[1]/255*100),r=Math.round(e[2]/255*100);return e.length<4||1===e[3]?"rgb("+t+"%, "+i+"%, "+r+"%)":"rgba("+t+"%, "+i+"%, "+r+"%, "+e[3]+")"},FG.to.hsl=function(...e){return e.length<4||1===e[3]?"hsl("+e[0]+", "+e[1]+"%, "+e[2]+"%)":"hsla("+e[0]+", "+e[1]+"%, "+e[2]+"%, "+e[3]+")"},FG.to.hwb=function(...e){let t="";return e.length>=4&&1!==e[3]&&(t=", "+e[3]),"hwb("+e[0]+", "+e[1]+"%, "+e[2]+"%"+t+")"},FG.to.keyword=function(...e){return LG[e.slice(0,3)]};const OG={};for(const e of Object.keys(RG))OG[RG[e]]=e;const zG={rgb:{channels:3,labels:"rgb"},hsl:{channels:3,labels:"hsl"},hsv:{channels:3,labels:"hsv"},hwb:{channels:3,labels:"hwb"},cmyk:{channels:4,labels:"cmyk"},xyz:{channels:3,labels:"xyz"},lab:{channels:3,labels:"lab"},oklab:{channels:3,labels:["okl","oka","okb"]},lch:{channels:3,labels:"lch"},oklch:{channels:3,labels:["okl","okc","okh"]},hex:{channels:1,labels:["hex"]},keyword:{channels:1,labels:["keyword"]},ansi16:{channels:1,labels:["ansi16"]},ansi256:{channels:1,labels:["ansi256"]},hcg:{channels:3,labels:["h","c","g"]},apple:{channels:3,labels:["r16","g16","b16"]},gray:{channels:1,labels:["gray"]}},UG=(6/29)**3;function NG(e){const t=e>.0031308?1.055*e**(1/2.4)-.055:12.92*e;return Math.min(Math.max(0,t),1)}function VG(e){return e>.04045?((e+.055)/1.055)**2.4:e/12.92}for(const e of Object.keys(zG)){if(!("channels"in zG[e]))throw new Error("missing channels property: "+e);if(!("labels"in zG[e]))throw new Error("missing channel labels property: "+e);if(zG[e].labels.length!==zG[e].channels)throw new Error("channel and label counts mismatch: "+e);const{channels:t,labels:i}=zG[e];delete zG[e].channels,delete zG[e].labels,Object.defineProperty(zG[e],"channels",{value:t}),Object.defineProperty(zG[e],"labels",{value:i})}function jG(e,t){return(e[0]-t[0])**2+(e[1]-t[1])**2+(e[2]-t[2])**2}function GG(e){const t=function(){const e={},t=Object.keys(zG);for(let{length:i}=t,r=0;r0;){const e=i.pop(),r=Object.keys(zG[e]);for(let{length:n}=r,o=0;o1&&(n-=1)}return[360*n,100*o,100*c]},zG.rgb.hwb=function(e){const t=e[0],i=e[1];let r=e[2];const n=zG.rgb.hsl(e)[0],o=1/255*Math.min(t,Math.min(i,r));return r=1-1/255*Math.max(t,Math.max(i,r)),[n,100*o,100*r]},zG.rgb.oklab=function(e){const t=VG(e[0]/255),i=VG(e[1]/255),r=VG(e[2]/255),n=Math.cbrt(.4122214708*t+.5363325363*i+.0514459929*r),o=Math.cbrt(.2119034982*t+.6806995451*i+.1073969566*r),s=Math.cbrt(.0883024619*t+.2817188376*i+.6299787005*r);return[100*(.2104542553*n+.793617785*o-.0040720468*s),100*(1.9779984951*n-2.428592205*o+.4505937099*s),100*(.0259040371*n+.7827717662*o-.808675766*s)]},zG.rgb.cmyk=function(e){const t=e[0]/255,i=e[1]/255,r=e[2]/255,n=Math.min(1-t,1-i,1-r);return[100*((1-t-n)/(1-n)||0),100*((1-i-n)/(1-n)||0),100*((1-r-n)/(1-n)||0),100*n]},zG.rgb.keyword=function(e){const t=OG[e];if(t)return t;let i,r=Number.POSITIVE_INFINITY;for(const t of Object.keys(RG)){const n=jG(e,RG[t]);nUG?i**(1/3):7.787*i+16/116,r=r>UG?r**(1/3):7.787*r+16/116,n=n>UG?n**(1/3):7.787*n+16/116;return[116*r-16,500*(i-r),200*(r-n)]},zG.hsl.rgb=function(e){const t=e[0]/360,i=e[1]/100,r=e[2]/100;let n,o;if(0===i)return o=255*r,[o,o,o];const s=r<.5?r*(1+i):r+i-r*i,a=2*r-s,l=[0,0,0];for(let e=0;e<3;e++)n=t+1/3*-(e-1),n<0&&n++,n>1&&n--,o=6*n<1?a+6*(s-a)*n:2*n<1?s:3*n<2?a+(s-a)*(2/3-n)*6:a,l[e]=255*o;return l},zG.hsl.hsv=function(e){const t=e[0];let i=e[1]/100,r=e[2]/100,n=i;const o=Math.max(r,.01);r*=2,i*=r<=1?r:2-r,n*=o<=1?o:2-o;return[t,100*(0===r?2*n/(o+n):2*i/(r+i)),100*((r+i)/2)]},zG.hsv.rgb=function(e){const t=e[0]/60,i=e[1]/100;let r=e[2]/100;const n=Math.floor(t)%6,o=t-Math.floor(t),s=255*r*(1-i),a=255*r*(1-i*o),l=255*r*(1-i*(1-o));switch(r*=255,n){case 0:return[r,l,s];case 1:return[a,r,s];case 2:return[s,r,l];case 3:return[s,a,r];case 4:return[l,s,r];case 5:return[r,s,a]}},zG.hsv.hsl=function(e){const t=e[0],i=e[1]/100,r=e[2]/100,n=Math.max(r,.01);let o,s;s=(2-i)*r;const a=(2-i)*n;return o=i*n,o/=a<=1?a:2-a,o=o||0,s/=2,[t,100*o,100*s]},zG.hwb.rgb=function(e){const t=e[0]/360;let i=e[1]/100,r=e[2]/100;const n=i+r;let o;n>1&&(i/=n,r/=n);const s=Math.floor(6*t),a=1-r;o=6*t-s,1&s&&(o=1-o);const l=i+o*(a-i);let c,u,h;switch(s){default:case 6:case 0:c=a,u=l,h=i;break;case 1:c=l,u=a,h=i;break;case 2:c=i,u=a,h=l;break;case 3:c=i,u=l,h=a;break;case 4:c=l,u=i,h=a;break;case 5:c=a,u=i,h=l}return[255*c,255*u,255*h]},zG.cmyk.rgb=function(e){const t=e[0]/100,i=e[1]/100,r=e[2]/100,n=e[3]/100;return[255*(1-Math.min(1,t*(1-n)+n)),255*(1-Math.min(1,i*(1-n)+n)),255*(1-Math.min(1,r*(1-n)+n))]},zG.xyz.rgb=function(e){const t=e[0]/100,i=e[1]/100,r=e[2]/100;let n,o,s;return n=3.2404542*t+-1.5371385*i+-.4985314*r,o=-.969266*t+1.8760108*i+.041556*r,s=.0556434*t+-.2040259*i+1.0572252*r,n=NG(n),o=NG(o),s=NG(s),[255*n,255*o,255*s]},zG.xyz.lab=function(e){let t=e[0],i=e[1],r=e[2];t/=95.047,i/=100,r/=108.883,t=t>UG?t**(1/3):7.787*t+16/116,i=i>UG?i**(1/3):7.787*i+16/116,r=r>UG?r**(1/3):7.787*r+16/116;return[116*i-16,500*(t-i),200*(i-r)]},zG.xyz.oklab=function(e){const t=e[0]/100,i=e[1]/100,r=e[2]/100,n=Math.cbrt(.8189330101*t+.3618667424*i-.1288597137*r),o=Math.cbrt(.0329845436*t+.9293118715*i+.0361456387*r),s=Math.cbrt(.0482003018*t+.2643662691*i+.633851707*r);return[100*(.2104542553*n+.793617785*o-.0040720468*s),100*(1.9779984951*n-2.428592205*o+.4505937099*s),100*(.0259040371*n+.7827717662*o-.808675766*s)]},zG.oklab.oklch=function(e){return zG.lab.lch(e)},zG.oklab.xyz=function(e){const t=e[0]/100,i=e[1]/100,r=e[2]/100,n=(.999999998*t+.396337792*i+.215803758*r)**3,o=(1.000000008*t-.105561342*i-.063854175*r)**3,s=(1.000000055*t-.089484182*i-1.291485538*r)**3;return[100*(1.227013851*n-.55779998*o+.281256149*s),100*(-.040580178*n+1.11225687*o-.071676679*s),100*(-.076381285*n-.421481978*o+1.58616322*s)]},zG.oklab.rgb=function(e){const t=e[0]/100,i=e[1]/100,r=e[2]/100,n=(t+.3963377774*i+.2158037573*r)**3,o=(t-.1055613458*i-.0638541728*r)**3,s=(t-.0894841775*i-1.291485548*r)**3;return[255*NG(4.0767416621*n-3.3077115913*o+.2309699292*s),255*NG(-1.2684380046*n+2.6097574011*o-.3413193965*s),255*NG(-.0041960863*n-.7034186147*o+1.707614701*s)]},zG.oklch.oklab=function(e){return zG.lch.lab(e)},zG.lab.xyz=function(e){let t,i,r;i=(e[0]+16)/116,t=e[1]/500+i,r=i-e[2]/200;const n=i**3,o=t**3,s=r**3;return i=n>UG?n:(i-16/116)/7.787,t=o>UG?o:(t-16/116)/7.787,r=s>UG?s:(r-16/116)/7.787,t*=95.047,i*=100,r*=108.883,[t,i,r]},zG.lab.lch=function(e){const t=e[0],i=e[1],r=e[2];let n;n=360*Math.atan2(r,i)/2/Math.PI,n<0&&(n+=360);return[t,Math.sqrt(i*i+r*r),n]},zG.lch.lab=function(e){const t=e[0],i=e[1],r=e[2]/360*2*Math.PI;return[t,i*Math.cos(r),i*Math.sin(r)]},zG.rgb.ansi16=function(e,t=null){const[i,r,n]=e;let o=null===t?zG.rgb.hsv(e)[2]:t;if(o=Math.round(o/50),0===o)return 30;let s=30+(Math.round(n/255)<<2|Math.round(r/255)<<1|Math.round(i/255));return 2===o&&(s+=60),s},zG.hsv.ansi16=function(e){return zG.rgb.ansi16(zG.hsv.rgb(e),e[2])},zG.rgb.ansi256=function(e){const t=e[0],i=e[1],r=e[2];if(t>>4==i>>4&&i>>4==r>>4)return t<8?16:t>248?231:Math.round((t-8)/247*24)+232;return 16+36*Math.round(t/255*5)+6*Math.round(i/255*5)+Math.round(r/255*5)},zG.ansi16.rgb=function(e){let t=(e=e[0])%10;if(0===t||7===t)return e>50&&(t+=3.5),t=t/10.5*255,[t,t,t];const i=.5*(Math.trunc(e>50)+1);return[(1&t)*i*255,(t>>1&1)*i*255,(t>>2&1)*i*255]},zG.ansi256.rgb=function(e){if((e=e[0])>=232){const t=10*(e-232)+8;return[t,t,t]}let t;e-=16;return[Math.floor(e/36)/5*255,Math.floor((t=e%36)/6)/5*255,t%6/5*255]},zG.rgb.hex=function(e){const t=(((255&Math.round(e[0]))<<16)+((255&Math.round(e[1]))<<8)+(255&Math.round(e[2]))).toString(16).toUpperCase();return"000000".slice(t.length)+t},zG.hex.rgb=function(e){const t=e.toString(16).match(/[a-f\d]{6}|[a-f\d]{3}/i);if(!t)return[0,0,0];let i=t[0];3===t[0].length&&(i=[...i].map(e=>e+e).join(""));const r=Number.parseInt(i,16);return[r>>16&255,r>>8&255,255&r]},zG.rgb.hcg=function(e){const t=e[0]/255,i=e[1]/255,r=e[2]/255,n=Math.max(Math.max(t,i),r),o=Math.min(Math.min(t,i),r),s=n-o;let a;return a=s<=0?0:n===t?(i-r)/s%6:n===i?2+(r-t)/s:4+(t-i)/s,a/=6,a%=1,[360*a,100*s,100*(s<1?o/(1-s):0)]},zG.hsl.hcg=function(e){const t=e[1]/100,i=e[2]/100,r=i<.5?2*t*i:2*t*(1-i);let n=0;return r<1&&(n=(i-.5*r)/(1-r)),[e[0],100*r,100*n]},zG.hsv.hcg=function(e){const t=e[1]/100,i=e[2]/100,r=t*i;let n=0;return r<1&&(n=(i-r)/(1-r)),[e[0],100*r,100*n]},zG.hcg.rgb=function(e){const t=e[0]/360,i=e[1]/100,r=e[2]/100;if(0===i)return[255*r,255*r,255*r];const n=[0,0,0],o=t%1*6,s=o%1,a=1-s;let l=0;switch(Math.floor(o)){case 0:n[0]=1,n[1]=s,n[2]=0;break;case 1:n[0]=a,n[1]=1,n[2]=0;break;case 2:n[0]=0,n[1]=1,n[2]=s;break;case 3:n[0]=0,n[1]=a,n[2]=1;break;case 4:n[0]=s,n[1]=0,n[2]=1;break;default:n[0]=1,n[1]=0,n[2]=a}return l=(1-i)*r,[255*(i*n[0]+l),255*(i*n[1]+l),255*(i*n[2]+l)]},zG.hcg.hsv=function(e){const t=e[1]/100,i=t+e[2]/100*(1-t);let r=0;return i>0&&(r=t/i),[e[0],100*r,100*i]},zG.hcg.hsl=function(e){const t=e[1]/100,i=e[2]/100*(1-t)+.5*t;let r=0;return i>0&&i<.5?r=t/(2*i):i>=.5&&i<1&&(r=t/(2*(1-i))),[e[0],100*r,100*i]},zG.hcg.hwb=function(e){const t=e[1]/100,i=t+e[2]/100*(1-t);return[e[0],100*(i-t),100*(1-i)]},zG.hwb.hcg=function(e){const t=e[1]/100,i=1-e[2]/100,r=i-t;let n=0;return r<1&&(n=(i-r)/(1-r)),[e[0],100*r,100*n]},zG.apple.rgb=function(e){return[e[0]/65535*255,e[1]/65535*255,e[2]/65535*255]},zG.rgb.apple=function(e){return[e[0]/255*65535,e[1]/255*65535,e[2]/255*65535]},zG.gray.rgb=function(e){return[e[0]/100*255,e[0]/100*255,e[0]/100*255]},zG.gray.hsl=function(e){return[0,0,e[0]]},zG.gray.hsv=zG.gray.hsl,zG.gray.hwb=function(e){return[0,100,e[0]]},zG.gray.cmyk=function(e){return[0,0,0,e[0]]},zG.gray.lab=function(e){return[e[0],0,0]},zG.gray.hex=function(e){const t=255&Math.round(e[0]/100*255),i=((t<<16)+(t<<8)+t).toString(16).toUpperCase();return"000000".slice(i.length)+i},zG.rgb.gray=function(e){return[(e[0]+e[1]+e[2])/3/255*100]};const ZG={},WG=Object.keys(zG);function qG(e){const t=function(...t){const i=t[0];return null==i?i:(i.length>1&&(t=i),e(t))};return"conversion"in e&&(t.conversion=e.conversion),t}function KG(e){const t=function(...t){const i=t[0];if(null==i)return i;i.length>1&&(t=i);const r=e(t);if("object"==typeof r)for(let{length:e}=r,t=0;t0){this.model=t||"rgb",r=ZG[this.model].channels;const i=Array.prototype.slice.call(e,0,r);this.color=nH(i,r),this.valpha="number"==typeof e[r]?e[r]:1}else if("number"==typeof e)this.model="rgb",this.color=[e>>16&255,e>>8&255,255&e],this.valpha=1;else{this.valpha=1;const t=Object.keys(e);"alpha"in e&&(t.splice(t.indexOf("alpha"),1),this.valpha="number"==typeof e.alpha?e.alpha:0);const r=t.sort().join("");if(!(r in JG))throw new Error("Unable to parse color from object: "+JSON.stringify(e));this.model=JG[r];const{labels:n}=ZG[this.model],o=[];for(i=0;i(e%360+360)%360),saturationl:iH("hsl",1,rH(100)),lightness:iH("hsl",2,rH(100)),saturationv:iH("hsv",1,rH(100)),value:iH("hsv",2,rH(100)),chroma:iH("hcg",1,rH(100)),gray:iH("hcg",2,rH(100)),white:iH("hwb",1,rH(100)),wblack:iH("hwb",2,rH(100)),cyan:iH("cmyk",0,rH(100)),magenta:iH("cmyk",1,rH(100)),yellow:iH("cmyk",2,rH(100)),black:iH("cmyk",3,rH(100)),x:iH("xyz",0,rH(95.047)),y:iH("xyz",1,rH(100)),z:iH("xyz",2,rH(108.833)),l:iH("lab",0,rH(100)),a:iH("lab",1),b:iH("lab",2),keyword(e){return void 0!==e?new eH(e):ZG[this.model].keyword(this.color)},hex(e){return void 0!==e?new eH(e):FG.to.hex(...this.rgb().round().color)},hexa(e){if(void 0!==e)return new eH(e);const t=this.rgb().round().color;let i=Math.round(255*this.valpha).toString(16).toUpperCase();return 1===i.length&&(i="0"+i),FG.to.hex(...t)+i},rgbNumber(){const e=this.rgb().color;return(255&e[0])<<16|(255&e[1])<<8|255&e[2]},luminosity(){const e=this.rgb().color,t=[];for(const[i,r]of e.entries()){const e=r/255;t[i]=e<=.04045?e/12.92:((e+.055)/1.055)**2.4}return.2126*t[0]+.7152*t[1]+.0722*t[2]},contrast(e){const t=this.luminosity(),i=e.luminosity();return t>i?(t+.05)/(i+.05):(i+.05)/(t+.05)},level(e){const t=this.contrast(e);return t>=7?"AAA":t>=4.5?"AA":""},isDark(){const e=this.rgb().color;return(2126*e[0]+7152*e[1]+722*e[2])/1e4<128},isLight(){return!this.isDark()},negate(){const e=this.rgb();for(let t=0;t<3;t++)e.color[t]=255-e.color[t];return e},lighten(e){const t=this.hsl();return t.color[2]+=t.color[2]*e,t},darken(e){const t=this.hsl();return t.color[2]-=t.color[2]*e,t},saturate(e){const t=this.hsl();return t.color[1]+=t.color[1]*e,t},desaturate(e){const t=this.hsl();return t.color[1]-=t.color[1]*e,t},whiten(e){const t=this.hwb();return t.color[1]+=t.color[1]*e,t},blacken(e){const t=this.hwb();return t.color[2]+=t.color[2]*e,t},grayscale(){const e=this.rgb().color,t=.3*e[0]+.59*e[1]+.11*e[2];return eH.rgb(t,t,t)},fade(e){return this.alpha(this.valpha-this.valpha*e)},opaquer(e){return this.alpha(this.valpha+this.valpha*e)},rotate(e){const t=this.hsl();let i=t.color[0];return i=(i+e)%360,i=i<0?360+i:i,t.color[0]=i,t},mix(e,t){if(!e||!e.rgb)throw new Error('Argument to "mix" was not a Color instance, but rather an instance of '+typeof e);const i=e.rgb(),r=this.rgb(),n=void 0===t?.5:t,o=2*n-1,s=i.alpha()-r.alpha(),a=((o*s===-1?o:(o+s)/(1+o*s))+1)/2,l=1-a;return eH.rgb(a*i.red()+l*r.red(),a*i.green()+l*r.green(),a*i.blue()+l*r.blue(),i.alpha()*n+r.alpha()*(1-n))}};for(const e of Object.keys(ZG)){if(XG.includes(e))continue;const{channels:t}=ZG[e];eH.prototype[e]=function(...t){return this.model===e?new eH(this):t.length>0?new eH(t,e):new eH([...(i=ZG[this.model][e].raw(this.color),Array.isArray(i)?i:[i]),this.valpha],e);var i},eH[e]=function(...i){let r=i[0];return"number"==typeof r&&(r=nH(i,t)),new eH(r,e)}}function tH(e){return function(t){return function(e,t){return Number(e.toFixed(t))}(t,e)}}function iH(e,t,i){e=Array.isArray(e)?e:[e];for(const r of e)(YG[r]||=[])[t]=i;return e=e[0],function(r){let n;return void 0!==r?(i&&(r=i(r)),n=this[e](),n.color[t]=r,n):(n=this[e]().color[t],i&&(n=i(n)),n)}}function rH(e){return function(t){return Math.max(0,Math.min(e,t))}}function nH(e,t){for(let i=0;ii(24,c=e));let u,{id:h}=t,{bearing:d}=t,{center:p}=t,{pitch:f}=t,{showCollisions:m}=t,{showBoundaries:g}=t,{zoom:_}=t,{mapStyle:A}=t,{numberOfMaps:y}=t,{onMapMount:v}=t,{mapRenderer:x}=t;const b=H();let w,T,E,C={},B=null,S=!1,I={};const M=()=>({bearing:T.getBearing(),center:T.getCenter(),pitch:T.getPitch(),zoom:T.getZoom()}),P=(e,t)=>{e&&!nu(M(),I)&&e.jumpTo(t)},R=()=>{o&&T.setProjection({type:o})},L=()=>{const e=T.getStyle(),t=e?.light,{data:i,beforeId:r}=s;let n,o,a;if(t){let{anchor:e,color:i,intensity:r,position:s}=t;i||(i="rgb(255, 255, 255)"),i=eH(i).rgb().array(),n=new yv({color:i,intensity:5*r}),s?(o=new Tv({color:i,intensity:10*r,direction:(l=s,[l[2],(l[1]-90)%180*-1,l[0]])}),a=new Rv({ambientLight:n,directionalLight:o})):a=new Rv({ambientLight:n})}var l;const c=new OO({id:"tile-3d-layer",data:i,loader:MG,onTilesetError:e=>console.log(e),...r&&{beforeId:r}});E||(E=new fB({interleaved:!0,layers:[c],...a&&{effects:[a]}}),T.addControl(E))};return j(async()=>{await(async()=>{"maplibre-gl"===x?(await Promise.resolve().then(function(){return jZ}),u=await Promise.resolve().then(function(){return Xe})):"maptiler-sdk"===x?(await Promise.resolve().then(function(){return GZ}),u=await Promise.resolve().then(function(){return Y4}),u.config.apiKey=c.maptilerApiKey):(await Promise.resolve().then(function(){return e5}),u=await Promise.resolve().then(function(){return We}),u.accessToken=c.mapboxGlAccessToken,c.mapboxBaseApiUrl&&(u.baseApiUrl=c.mapboxBaseApiUrl))})();const e=u;let t,l="string"==typeof w;if(r){const e=n??r?.options?.default;if(!e)return;if(l&&(t=await vu(w)),!t)return;r&&r?.script&&(t=await r.script(t,e))}i(13,T=new e.Map({container:h,style:w,canvasContextAttributes:{preserveDrawingBuffer:!0},preserveDrawingBuffer:!0,...I})),s&&a&&T.once("load",L),o&&"maplibre-gl"===x&&T.on("style.load",()=>{setTimeout(R,150)}),v(T);const d=Ct(()=>{document.getElementById(h).querySelector('canvas[tabindex="0"]').focus()},250);document.getElementById(h).addEventListener("wheel",d,{passive:!0});T.on("move",e=>{e?.resize||(({origin:e})=>{document.getElementById(h)?.contains(document.activeElement)&&b("mapMove",{options:M()})})(e)}),T.on("click",t=>{let i=T.queryRenderedFeatures(t.point);i.length&&(S?(B.remove(),B=null):(B=(new e.Popup).setLngLat(t.lngLat).setHTML((e=>{const t=e.reduce((e,t)=>{const{source:i,sourceLayer:r,properties:n}=t,o=e.some(e=>{const t=e.source===i&&e.sourceLayer===r,o=Object.keys(n).every(t=>n[t]===e.properties[t]);return t&&o});return o||e.push(t),e},[]);let i='",i})(i)).setMaxWidth(360).addTo(T),S=!0,B.on("close",()=>{S=!1})))})}),G(()=>{T&&T.remove()}),e.$$set=e=>{"id"in e&&i(0,h=e.id),"bearing"in e&&i(1,d=e.bearing),"center"in e&&i(2,p=e.center),"pitch"in e&&i(3,f=e.pitch),"showCollisions"in e&&i(4,m=e.showCollisions),"showBoundaries"in e&&i(5,g=e.showBoundaries),"zoom"in e&&i(6,_=e.zoom),"mapStyle"in e&&i(7,A=e.mapStyle),"numberOfMaps"in e&&i(8,y=e.numberOfMaps),"onMapMount"in e&&i(9,v=e.onMapMount),"mapRenderer"in e&&i(10,x=e.mapRenderer)},e.$$.update=()=>{128&e.$$.dirty[0]&&i(11,({style:C,url:w,precompile:r,selectedPrecompileOption:n,projection:o,deckGlLayer:s,landmarks3D:a}=A),C,(i(12,w),i(7,A)),(i(18,n),i(7,A)),(i(17,o),i(7,A)),(i(16,s),i(7,A)),(i(15,a),i(7,A))),78&e.$$.dirty[0]&&i(14,I={bearing:d,center:p,pitch:f,zoom:_}),8208&e.$$.dirty[0]&&T&&i(13,T.showCollisionBoxes=m,T),8224&e.$$.dirty[0]&&T&&i(13,T.showTileBoundaries=g,T),24576&e.$$.dirty[0]&&P(T,I),505856&e.$$.dirty[0]&&(async(e,t,i,n,o,s,a)=>{if(!e)return;e.off("style.load",R),E&&(e.removeControl(E),E=null);let l=t;!l&&A?.pattern&&(l=xu(A?.pattern,A?.branch,A?.branchStyle));let c=i;if(r){if(!n)return;if(!i&&"string"==typeof l&&(c=await vu(l)),!c)return;c=await r.script(c,n),e.setStyle(c)}else e.setStyle(l||i);s&&a&&setTimeout(L,150),o&&"maplibre-gl"===x&&setTimeout(R,150)})(T,w,C,n,o,s,a),9473&e.$$.dirty[0]&&T&&y&&"maplibre-gl"!==x&&"maptiler-sdk"!==x&&T.once("render",()=>{const e=document.getElementById(h);if(e){new ResizeObserver(()=>{T.resize({resize:!0})}).observe(e)}})},[h,d,p,f,m,g,_,A,y,v,x,C,w,T,I,a,s,o,n]}class aH extends ge{constructor(e){super(),me(this,e,sH,oH,a,{id:0,bearing:1,center:2,pitch:3,showCollisions:4,showBoundaries:5,zoom:6,mapStyle:7,numberOfMaps:8,onMapMount:9,mapRenderer:10},null,[-1,-1])}}var lH={exports:{}}; + */var j$=null;try{j$=new WebAssembly.Instance(new WebAssembly.Module(new Uint8Array([0,97,115,109,1,0,0,0,1,13,2,96,0,1,127,96,4,127,127,127,127,1,127,3,7,6,0,1,1,1,1,1,6,6,1,127,1,65,0,11,7,50,6,3,109,117,108,0,1,5,100,105,118,95,115,0,2,5,100,105,118,95,117,0,3,5,114,101,109,95,115,0,4,5,114,101,109,95,117,0,5,8,103,101,116,95,104,105,103,104,0,0,10,191,1,6,4,0,35,0,11,36,1,1,126,32,0,173,32,1,173,66,32,134,132,32,2,173,32,3,173,66,32,134,132,126,34,4,66,32,135,167,36,0,32,4,167,11,36,1,1,126,32,0,173,32,1,173,66,32,134,132,32,2,173,32,3,173,66,32,134,132,127,34,4,66,32,135,167,36,0,32,4,167,11,36,1,1,126,32,0,173,32,1,173,66,32,134,132,32,2,173,32,3,173,66,32,134,132,128,34,4,66,32,135,167,36,0,32,4,167,11,36,1,1,126,32,0,173,32,1,173,66,32,134,132,32,2,173,32,3,173,66,32,134,132,129,34,4,66,32,135,167,36,0,32,4,167,11,36,1,1,126,32,0,173,32,1,173,66,32,134,132,32,2,173,32,3,173,66,32,134,132,130,34,4,66,32,135,167,36,0,32,4,167,11])),{}).exports}catch{}function G$(e,t,i){this.low=0|e,this.high=0|t,this.unsigned=!!i}function H$(e){return!0===(e&&e.__isLong__)}function Q$(e){var t=Math.clz32(e&-e);return e?31-t:t}G$.prototype.__isLong__,Object.defineProperty(G$.prototype,"__isLong__",{value:!0}),G$.isLong=H$;var $$={},Z$={};function W$(e,t){var i,n,r;return t?(r=0<=(e>>>=0)&&e<256)&&(n=Z$[e])?n:(i=K$(e,0,!0),r&&(Z$[e]=i),i):(r=-128<=(e|=0)&&e<128)&&(n=$$[e])?n:(i=K$(e,e<0?-1:0,!1),r&&($$[e]=i),i)}function q$(e,t){if(isNaN(e))return t?oZ:rZ;if(t){if(e<0)return oZ;if(e>=tZ)return uZ}else{if(e<=-iZ)return hZ;if(e+1>=iZ)return cZ}return e<0?q$(-e,t).neg():K$(e%eZ|0,e/eZ|0,t)}function K$(e,t,i){return new G$(e,t,i)}G$.fromInt=W$,G$.fromNumber=q$,G$.fromBits=K$;var X$=Math.pow;function J$(e,t,i){if(0===e.length)throw Error("empty string");if("number"==typeof t?(i=t,t=!1):t=!!t,"NaN"===e||"Infinity"===e||"+Infinity"===e||"-Infinity"===e)return t?oZ:rZ;if((i=i||10)<2||360)throw Error("interior hyphen");if(0===n)return J$(e.substring(1),t,i).neg();for(var r=q$(X$(i,8)),o=rZ,s=0;s>>0:this.low},dZ.toNumber=function(){return this.unsigned?(this.high>>>0)*eZ+(this.low>>>0):this.high*eZ+(this.low>>>0)},dZ.toString=function(e){if((e=e||10)<2||36>>0).toString(e);if((o=a).isZero())return l+s;for(;l.length<6;)l="0"+l;s=""+l+s}},dZ.getHighBits=function(){return this.high},dZ.getHighBitsUnsigned=function(){return this.high>>>0},dZ.getLowBits=function(){return this.low},dZ.getLowBitsUnsigned=function(){return this.low>>>0},dZ.getNumBitsAbs=function(){if(this.isNegative())return this.eq(hZ)?64:this.neg().getNumBitsAbs();for(var e=0!=this.high?this.high:this.low,t=31;t>0&&!(e&1<>21;return!e||!this.unsigned&&(-1===e&&!(0===this.low&&-2097152===this.high))},dZ.isZero=function(){return 0===this.high&&0===this.low},dZ.eqz=dZ.isZero,dZ.isNegative=function(){return!this.unsigned&&this.high<0},dZ.isPositive=function(){return this.unsigned||this.high>=0},dZ.isOdd=function(){return!(1&~this.low)},dZ.isEven=function(){return!(1&this.low)},dZ.equals=function(e){return H$(e)||(e=Y$(e)),(this.unsigned===e.unsigned||this.high>>>31!=1||e.high>>>31!=1)&&(this.high===e.high&&this.low===e.low)},dZ.eq=dZ.equals,dZ.notEquals=function(e){return!this.eq(e)},dZ.neq=dZ.notEquals,dZ.ne=dZ.notEquals,dZ.lessThan=function(e){return this.comp(e)<0},dZ.lt=dZ.lessThan,dZ.lessThanOrEqual=function(e){return this.comp(e)<=0},dZ.lte=dZ.lessThanOrEqual,dZ.le=dZ.lessThanOrEqual,dZ.greaterThan=function(e){return this.comp(e)>0},dZ.gt=dZ.greaterThan,dZ.greaterThanOrEqual=function(e){return this.comp(e)>=0},dZ.gte=dZ.greaterThanOrEqual,dZ.ge=dZ.greaterThanOrEqual,dZ.compare=function(e){if(H$(e)||(e=Y$(e)),this.eq(e))return 0;var t=this.isNegative(),i=e.isNegative();return t&&!i?-1:!t&&i?1:this.unsigned?e.high>>>0>this.high>>>0||e.high===this.high&&e.low>>>0>this.low>>>0?-1:1:this.sub(e).isNegative()?-1:1},dZ.comp=dZ.compare,dZ.negate=function(){return!this.unsigned&&this.eq(hZ)?hZ:this.not().add(sZ)},dZ.neg=dZ.negate,dZ.add=function(e){H$(e)||(e=Y$(e));var t=this.high>>>16,i=65535&this.high,n=this.low>>>16,r=65535&this.low,o=e.high>>>16,s=65535&e.high,a=e.low>>>16,l=0,c=0,u=0,h=0;return u+=(h+=r+(65535&e.low))>>>16,c+=(u+=n+a)>>>16,l+=(c+=i+s)>>>16,l+=t+o,K$((u&=65535)<<16|(h&=65535),(l&=65535)<<16|(c&=65535),this.unsigned)},dZ.subtract=function(e){return H$(e)||(e=Y$(e)),this.add(e.neg())},dZ.sub=dZ.subtract,dZ.multiply=function(e){if(this.isZero())return this;if(H$(e)||(e=Y$(e)),j$)return K$(j$.mul(this.low,this.high,e.low,e.high),j$.get_high(),this.unsigned);if(e.isZero())return this.unsigned?oZ:rZ;if(this.eq(hZ))return e.isOdd()?hZ:rZ;if(e.eq(hZ))return this.isOdd()?hZ:rZ;if(this.isNegative())return e.isNegative()?this.neg().mul(e.neg()):this.neg().mul(e).neg();if(e.isNegative())return this.mul(e.neg()).neg();if(this.lt(nZ)&&e.lt(nZ))return q$(this.toNumber()*e.toNumber(),this.unsigned);var t=this.high>>>16,i=65535&this.high,n=this.low>>>16,r=65535&this.low,o=e.high>>>16,s=65535&e.high,a=e.low>>>16,l=65535&e.low,c=0,u=0,h=0,d=0;return h+=(d+=r*l)>>>16,u+=(h+=n*l)>>>16,h&=65535,u+=(h+=r*a)>>>16,c+=(u+=i*l)>>>16,u&=65535,c+=(u+=n*a)>>>16,u&=65535,c+=(u+=r*s)>>>16,c+=t*l+i*a+n*s+r*o,K$((h&=65535)<<16|(d&=65535),(c&=65535)<<16|(u&=65535),this.unsigned)},dZ.mul=dZ.multiply,dZ.divide=function(e){if(H$(e)||(e=Y$(e)),e.isZero())throw Error("division by zero");var t,i,n;if(j$)return this.unsigned||-2147483648!==this.high||-1!==e.low||-1!==e.high?K$((this.unsigned?j$.div_u:j$.div_s)(this.low,this.high,e.low,e.high),j$.get_high(),this.unsigned):this;if(this.isZero())return this.unsigned?oZ:rZ;if(this.unsigned){if(e.unsigned||(e=e.toUnsigned()),e.gt(this))return oZ;if(e.gt(this.shru(1)))return aZ;n=oZ}else{if(this.eq(hZ))return e.eq(sZ)||e.eq(lZ)?hZ:e.eq(hZ)?sZ:(t=this.shr(1).div(e).shl(1)).eq(rZ)?e.isNegative()?sZ:lZ:(i=this.sub(e.mul(t)),n=t.add(i.div(e)));if(e.eq(hZ))return this.unsigned?oZ:rZ;if(this.isNegative())return e.isNegative()?this.neg().div(e.neg()):this.neg().div(e).neg();if(e.isNegative())return this.div(e.neg()).neg();n=rZ}for(i=this;i.gte(e);){t=Math.max(1,Math.floor(i.toNumber()/e.toNumber()));for(var r=Math.ceil(Math.log(t)/Math.LN2),o=r<=48?1:X$(2,r-48),s=q$(t),a=s.mul(e);a.isNegative()||a.gt(i);)a=(s=q$(t-=o,this.unsigned)).mul(e);s.isZero()&&(s=sZ),n=n.add(s),i=i.sub(a)}return n},dZ.div=dZ.divide,dZ.modulo=function(e){return H$(e)||(e=Y$(e)),j$?K$((this.unsigned?j$.rem_u:j$.rem_s)(this.low,this.high,e.low,e.high),j$.get_high(),this.unsigned):this.sub(this.div(e).mul(e))},dZ.mod=dZ.modulo,dZ.rem=dZ.modulo,dZ.not=function(){return K$(~this.low,~this.high,this.unsigned)},dZ.countLeadingZeros=function(){return this.high?Math.clz32(this.high):Math.clz32(this.low)+32},dZ.clz=dZ.countLeadingZeros,dZ.countTrailingZeros=function(){return this.low?Q$(this.low):Q$(this.high)+32},dZ.ctz=dZ.countTrailingZeros,dZ.and=function(e){return H$(e)||(e=Y$(e)),K$(this.low&e.low,this.high&e.high,this.unsigned)},dZ.or=function(e){return H$(e)||(e=Y$(e)),K$(this.low|e.low,this.high|e.high,this.unsigned)},dZ.xor=function(e){return H$(e)||(e=Y$(e)),K$(this.low^e.low,this.high^e.high,this.unsigned)},dZ.shiftLeft=function(e){return H$(e)&&(e=e.toInt()),0==(e&=63)?this:e<32?K$(this.low<>>32-e,this.unsigned):K$(0,this.low<>>e|this.high<<32-e,this.high>>e,this.unsigned):K$(this.high>>e-32,this.high>=0?0:-1,this.unsigned)},dZ.shr=dZ.shiftRight,dZ.shiftRightUnsigned=function(e){return H$(e)&&(e=e.toInt()),0==(e&=63)?this:e<32?K$(this.low>>>e|this.high<<32-e,this.high>>>e,this.unsigned):K$(32===e?this.high:this.high>>>e-32,0,this.unsigned)},dZ.shru=dZ.shiftRightUnsigned,dZ.shr_u=dZ.shiftRightUnsigned,dZ.rotateLeft=function(e){var t;return H$(e)&&(e=e.toInt()),0==(e&=63)?this:32===e?K$(this.high,this.low,this.unsigned):e<32?(t=32-e,K$(this.low<>>t,this.high<>>t,this.unsigned)):(t=32-(e-=32),K$(this.high<>>t,this.low<>>t,this.unsigned))},dZ.rotl=dZ.rotateLeft,dZ.rotateRight=function(e){var t;return H$(e)&&(e=e.toInt()),0==(e&=63)?this:32===e?K$(this.high,this.low,this.unsigned):e<32?(t=32-e,K$(this.high<>>e,this.low<>>e,this.unsigned)):(t=32-(e-=32),K$(this.low<>>e,this.high<>>e,this.unsigned))},dZ.rotr=dZ.rotateRight,dZ.toSigned=function(){return this.unsigned?K$(this.low,this.high,!1):this},dZ.toUnsigned=function(){return this.unsigned?this:K$(this.low,this.high,!0)},dZ.toBytes=function(e){return e?this.toBytesLE():this.toBytesBE()},dZ.toBytesLE=function(){var e=this.high,t=this.low;return[255&t,t>>>8&255,t>>>16&255,t>>>24,255&e,e>>>8&255,e>>>16&255,e>>>24]},dZ.toBytesBE=function(){var e=this.high,t=this.low;return[e>>>24,e>>>16&255,e>>>8&255,255&e,t>>>24,t>>>16&255,t>>>8&255,255&t]},G$.fromBytes=function(e,t,i){return i?G$.fromBytesLE(e,t):G$.fromBytesBE(e,t)},G$.fromBytesLE=function(e,t){return new G$(e[0]|e[1]<<8|e[2]<<16|e[3]<<24,e[4]|e[5]<<8|e[6]<<16|e[7]<<24,t)},G$.fromBytesBE=function(e,t){return new G$(e[4]<<24|e[5]<<16|e[6]<<8|e[7],e[0]<<24|e[1]<<16|e[2]<<8|e[3],t)},"function"==typeof BigInt&&(G$.fromBigInt=function(e,t){return K$(Number(BigInt.asIntN(32,e)),Number(BigInt.asIntN(32,e>>BigInt(32))),t)},G$.fromValue=function(e,t){return"bigint"==typeof e?G$.fromBigInt(e,t):Y$(e,t)},dZ.toBigInt=function(){var e=BigInt(this.low>>>0);return BigInt(this.unsigned?this.high>>>0:this.high)<=.5?1/3*(4*e*e-1):1/3*(1-4*(1-e)*(1-e))}function _Z(e){return[gZ(e[0]),gZ(e[1])]}function AZ(e,[t,i]){switch(e){case 0:return[1,t,i];case 1:return[-t,1,i];case 2:return[-t,-i,1];case 3:return[-1,-i,-t];case 4:return[i,-1,-t];case 5:return[i,t,-1];default:throw new Error("Invalid face")}}function yZ([e,t,i]){const n=Math.atan2(i,Math.sqrt(e*e+t*t));return[Math.atan2(t,e)*fZ,n*fZ]}function vZ(e,t,i,n){if(0===n){1===i&&(t[0]=e-1-t[0],t[1]=e-1-t[1]);const n=t[0];t[0]=t[1],t[1]=n}}function xZ(e){const{face:t,ij:i,level:n}=e,r=[[0,0],[0,1],[1,1],[1,0],[0,0]],o=Math.max(1,Math.ceil(100*Math.pow(2,-n))),s=new Float64Array(4*o*2+2);let a=0,l=0;for(let e=0;e<4;e++){const c=r[e].slice(0),u=r[e+1],h=(u[0]-c[0])/o,d=(u[1]-c[1])/o;for(let e=0;e89.999&&(e[0]=l);const r=e[0]-l;e[0]+=r>180?-360:r<-180?360:0,s[a++]=e[0],s[a++]=e[1],l=e[0]}}return s[a++]=s[0],s[a++]=s[1],s}function bZ(e){const t=function(e){if(e.indexOf("/")>0)return e;const t=pZ(e);return function(e){if(e.isZero())return"";let t=e.toString(2);for(;t.length<64;)t="0"+t;const i=t.lastIndexOf("1"),n=t.substring(0,3),r=t.substring(3,i),o=r.length/2,s=G$.fromString(n,!0,2).toString(10);let a="";if(0!==o)for(a=G$.fromString(r,!0,2).toString(4);a.length=0;e--){o=r-e;const t=n[e];let i=0,a=0;"1"===t?a=1:"2"===t?(i=1,a=1):"3"===t&&(i=1);const l=Math.pow(2,o-1);vZ(l,s,i,a),s[0]+=l*i,s[1]+=l*a}if(i%2==1){const e=s[0];s[0]=s[1],s[1]=e}return{face:i,ij:s,level:o}}(t);return i}function wZ(e){return function(e){const t=_Z(mZ(e.ij,e.level,[.5,.5]));return yZ(AZ(e.face,t))}(bZ(e))}function TZ(e){if(e.length%2!=0)throw new Error("Invalid corners");const t=[],i=[];for(let n=0;ne-t),i.sort((e,t)=>e-t),{west:t[0],east:t[t.length-1],north:i[i.length-1],south:i[0]}}function EZ(e,t){const i=t?.minimumHeight||0,n=t?.maximumHeight||0,r=function(e){let t;if(2===e.face||5===e.face){let i=null,n=0;for(let t=0;t<4;t++){const r=xZ(bZ(`${e.face}/${t}`));null==i&&(i=new Float64Array(4*r.length)),i.set(r,n),n+=r.length}t=TZ(i)}else t=TZ(xZ(e));return t}(bZ(e)),o=r.west,s=r.south,a=r.east,l=r.north,c=[];return c.push(new AA(o,l,i)),c.push(new AA(a,l,i)),c.push(new AA(a,s,i)),c.push(new AA(o,s,i)),c.push(new AA(o,l,n)),c.push(new AA(a,l,n)),c.push(new AA(a,s,n)),c.push(new AA(o,s,n)),c}function CZ(e){const t=e.token,i={minimumHeight:e.minimumHeight,maximumHeight:e.maximumHeight},n=EZ(t,i),r=wZ(t),o=r[0],s=r[1],a=PO.WGS84.cartographicToCartesian([o,s,i.maximumHeight]),l=new AA(a[0],a[1],a[2]);n.push(l);const c=NR(n);return[...c.center,...c.halfAxes]}const SZ={QUADTREE:4,OCTREE:8};function BZ(e,t,i){if(e?.box){const n=function(e,t){const i=function(e){return e.and(e.not().add(1))}(e).shiftRightUnsigned(2);return e.add(G$.fromNumber(2*t+1-4).multiply(i))}(pZ(e.s2VolumeInfo.token),t),r=function(e){if(e.isZero())return"X";let t=e.countTrailingZeros();t=(t-t%4)/4;const i=t;t*=4;const n=e.shiftRightUnsigned(t).toString(16).replace(/0+$/,"");return Array(17-i-n.length).join("0")+n}(n),o={...e.s2VolumeInfo};if(o.token=r,"OCTREE"===i){const t=e.s2VolumeInfo,i=t.maximumHeight-t.minimumHeight,n=i/2,r=t.minimumHeight+i/2;t.minimumHeight=r-n,t.maximumHeight=r+n}return{box:CZ(o),s2VolumeInfo:o}}}async function IZ(e){const{implicitOptions:t,parentData:i={mortonIndex:0,x:0,y:0,z:0},childIndex:n=0,s2VolumeBox:r,loaderOptions:o}=e;let{subtree:s,level:a=0,globalData:l={level:0,mortonIndex:0,x:0,y:0,z:0}}=e;const{subdivisionScheme:c,subtreeLevels:u,maximumLevel:h,contentUrlTemplate:d,subtreesUriTemplate:p,basePath:f}=t,m={children:[],lodMetricValue:0,contentUrl:""};if(!h)return Zu.once(`Missing 'maximumLevel' or 'availableLevels' property. The subtree ${d} won't be loaded...`),m;const g=a+l.level;if(g>h)return m;const _=SZ[c],A=Math.log2(_),y=1&n,v=n>>1&1,x=n>>2&1,b=(_**a-1)/(_-1);let w=RZ(i.mortonIndex,n,A),T=b+w,E=RZ(i.x,y,1),C=RZ(i.y,v,1),S=RZ(i.z,x,1),B=!1;a>=u&&(B=MZ(s.childSubtreeAvailability,w));const I=RZ(l.x,E,a),M=RZ(l.y,C,a),P=RZ(l.z,S,a);if(B){const e=LZ(`${f}/${p}`,g,I,M,P);s=await dI(e,V$,o),l={mortonIndex:w,x:E,y:C,z:S,level:a},w=0,T=0,E=0,C=0,S=0,a=0}if(!MZ(s.tileAvailability,T))return m;MZ(s.contentAvailability,T)&&(m.contentUrl=LZ(d,g,I,M,P));const R=a+1,L={mortonIndex:w,x:E,y:C,z:S};for(let e=0;e<_;e++){const i=BZ(r,e,c),n=await IZ({subtree:s,implicitOptions:t,loaderOptions:o,parentData:L,childIndex:e,level:R,globalData:{...l},s2VolumeBox:i});if(n.contentUrl||n.children.length){const e=PZ(n,g+1,{childTileX:E,childTileY:C,childTileZ:S},t,r);m.children.push(e)}}return m}function MZ(e,t){let i;return Array.isArray(e)?(i=e[0],e.length>1&&Zu.once('Not supported extension "3DTILES_multiple_contents" has been detected')):i=e,"constant"in i?Boolean(i.constant):!!i.explicitBitstream&&function(e,t){const i=Math.floor(e/8),n=e%8;return 1==(t[i]>>n&1)}(t,i.explicitBitstream)}function PZ(e,t,i,n,r){const{basePath:o,refine:s,getRefine:a,lodMetricType:l,getTileType:c,rootLodMetricValue:u,rootBoundingVolume:h}=n,d=e.contentUrl&&e.contentUrl.replace(`${o}/`,""),p=u/2**t,f=function(e,t,i){if(t.region){const{childTileX:n,childTileY:r,childTileZ:o}=i,[s,a,l,c,u,h]=t.region,d=2**e,p=(l-s)/d,f=(c-a)/d,m=(h-u)/d,[g,_]=[s+p*n,s+p*(n+1)],[A,y]=[a+f*r,a+f*(r+1)],[v,x]=[u+m*o,u+m*(o+1)];return{region:[g,A,_,y,v,x]}}if(t.box)return t;throw new Error(`Unsupported bounding volume type ${JSON.stringify(t)}`)}(t,r?.box?{box:r.box}:h,i);return{children:e.children,contentUrl:e.contentUrl,content:{uri:d},id:e.contentUrl,refine:a(s),type:c(e),lodMetricType:l,lodMetricValue:p,geometricError:p,transform:e.transform,boundingVolume:f}}function RZ(e,t,i){return(e<o[e])}function FZ(e,t=""){if(!t)return cj.EMPTY;const i=t.split("?")[0].split(".").pop();switch(i){case"pnts":return cj.POINTCLOUD;case"i3dm":case"b3dm":case"glb":case"gltf":return cj.SCENEGRAPH;default:return i||cj.EMPTY}}function kZ(e){switch(e){case"REPLACE":case"replace":return lj.REPLACE;case"ADD":case"add":return lj.ADD;default:return e}}function DZ(e,t){if(/^[a-z][0-9a-z+.-]*:/i.test(t)){const i=new URL(e,`${t}/`);return decodeURI(i.toString())}return e.startsWith("/")?e:oj(t,e)}function OZ(e,t){if(!e)return null;let i;if(e.content){const n=e.content.uri||e.content?.url;void 0!==n&&(i=DZ(n,t))}return{...e,id:i,contentUrl:i,lodMetricType:hj.GEOMETRIC_ERROR,lodMetricValue:e.geometricError,transformMatrix:e.transform,type:FZ(0,i),refine:kZ(e.refine)}}async function zZ(e,t,i,n,r){const{subdivisionScheme:o,maximumLevel:s,availableLevels:a,subtreeLevels:l,subtrees:{uri:c}}=n,u=DZ(LZ(c,0,0,0,0),i),h=await dI(u,V$,r),d=e.content?.uri,p=d?DZ(d,i):"",f=t?.root?.refine,m=e.geometricError,g=e.boundingVolume.extensions?.["3DTILES_bounding_volume_S2"];if(g){const t={box:CZ(g),s2VolumeInfo:g};e.boundingVolume=t}const _=e.boundingVolume,A={contentUrlTemplate:p,subtreesUriTemplate:c,subdivisionScheme:o,subtreeLevels:l,maximumLevel:Number.isFinite(a)?a-1:s,refine:f,basePath:i,lodMetricType:hj.GEOMETRIC_ERROR,rootLodMetricValue:m,rootBoundingVolume:_,getTileType:FZ,getRefine:kZ};return await async function(e,t,i,n,r){if(!e)return null;const{children:o,contentUrl:s}=await IZ({subtree:i,implicitOptions:n,loaderOptions:r});let a,l=null;s&&(a=s,l={uri:s.replace(`${t}/`,"")});const c={...e,id:a,contentUrl:a,lodMetricType:hj.GEOMETRIC_ERROR,lodMetricValue:e.geometricError,transformMatrix:e.transform,type:FZ(0,a),refine:kZ(e.refine),content:l||e.content,children:o};return c}(e,i,h,A,r)}function UZ(e){return e?.extensions?.["3DTILES_implicit_tiling"]||e?.implicitTiling}const NZ={dataType:null,batchType:null,id:"3d-tiles",name:"3D Tiles",module:"3d-tiles",version:dj,extensions:["cmpt","pnts","b3dm","i3dm"],mimeTypes:["application/octet-stream"],tests:["cmpt","pnts","b3dm","i3dm"],parse:async function(e,t={},i){const n=t["3d-tiles"]||{};let r;r="auto"===n.isTileset?i?.url&&-1!==i.url.indexOf(".json"):n.isTileset;return r?async function(e,t,i){const n=JSON.parse((new TextDecoder).decode(e)),r=i?.url||"",o=function(e){return function(e){const t=e?e.lastIndexOf("/"):-1;return t>=0?e.substr(0,t):""}(e)}(r),s=await async function(e,t,i){let n=null;const r=UZ(e.root);n=r&&e.root?await zZ(e.root,e,t,r,i):OZ(e.root,t);const o=[];for(o.push(n);o.length>0;){const n=o.pop()||{},r=n.children||[],s=[];for(const n of r){const r=UZ(n);let a;a=r?await zZ(n,e,t,r,i):OZ(n,t),a&&(s.push(a),o.push(a))}n.children=s}return n}(n,o,t||{}),a={...n,shape:"tileset3d",loader:NZ,url:r,queryString:i?.queryString||"",basePath:o,root:s||n.root,type:uj.TILES3D,lodMetricType:hj.GEOMETRIC_ERROR,lodMetricValue:n.root?.geometricError||0};return a}(e,t,i):async function(e,t,i){const n={content:{shape:"tile3d",featureIds:null}},r=0;return await z$(e,r,t,i,n.content),n.content}(e,t,i)},options:{"3d-tiles":{loadGLTF:!0,decodeQuantizedPositions:!1,isTileset:"auto",assetGltfUpAxis:null}}};const VZ={aliceblue:[240,248,255],antiquewhite:[250,235,215],aqua:[0,255,255],aquamarine:[127,255,212],azure:[240,255,255],beige:[245,245,220],bisque:[255,228,196],black:[0,0,0],blanchedalmond:[255,235,205],blue:[0,0,255],blueviolet:[138,43,226],brown:[165,42,42],burlywood:[222,184,135],cadetblue:[95,158,160],chartreuse:[127,255,0],chocolate:[210,105,30],coral:[255,127,80],cornflowerblue:[100,149,237],cornsilk:[255,248,220],crimson:[220,20,60],cyan:[0,255,255],darkblue:[0,0,139],darkcyan:[0,139,139],darkgoldenrod:[184,134,11],darkgray:[169,169,169],darkgreen:[0,100,0],darkgrey:[169,169,169],darkkhaki:[189,183,107],darkmagenta:[139,0,139],darkolivegreen:[85,107,47],darkorange:[255,140,0],darkorchid:[153,50,204],darkred:[139,0,0],darksalmon:[233,150,122],darkseagreen:[143,188,143],darkslateblue:[72,61,139],darkslategray:[47,79,79],darkslategrey:[47,79,79],darkturquoise:[0,206,209],darkviolet:[148,0,211],deeppink:[255,20,147],deepskyblue:[0,191,255],dimgray:[105,105,105],dimgrey:[105,105,105],dodgerblue:[30,144,255],firebrick:[178,34,34],floralwhite:[255,250,240],forestgreen:[34,139,34],fuchsia:[255,0,255],gainsboro:[220,220,220],ghostwhite:[248,248,255],gold:[255,215,0],goldenrod:[218,165,32],gray:[128,128,128],green:[0,128,0],greenyellow:[173,255,47],grey:[128,128,128],honeydew:[240,255,240],hotpink:[255,105,180],indianred:[205,92,92],indigo:[75,0,130],ivory:[255,255,240],khaki:[240,230,140],lavender:[230,230,250],lavenderblush:[255,240,245],lawngreen:[124,252,0],lemonchiffon:[255,250,205],lightblue:[173,216,230],lightcoral:[240,128,128],lightcyan:[224,255,255],lightgoldenrodyellow:[250,250,210],lightgray:[211,211,211],lightgreen:[144,238,144],lightgrey:[211,211,211],lightpink:[255,182,193],lightsalmon:[255,160,122],lightseagreen:[32,178,170],lightskyblue:[135,206,250],lightslategray:[119,136,153],lightslategrey:[119,136,153],lightsteelblue:[176,196,222],lightyellow:[255,255,224],lime:[0,255,0],limegreen:[50,205,50],linen:[250,240,230],magenta:[255,0,255],maroon:[128,0,0],mediumaquamarine:[102,205,170],mediumblue:[0,0,205],mediumorchid:[186,85,211],mediumpurple:[147,112,219],mediumseagreen:[60,179,113],mediumslateblue:[123,104,238],mediumspringgreen:[0,250,154],mediumturquoise:[72,209,204],mediumvioletred:[199,21,133],midnightblue:[25,25,112],mintcream:[245,255,250],mistyrose:[255,228,225],moccasin:[255,228,181],navajowhite:[255,222,173],navy:[0,0,128],oldlace:[253,245,230],olive:[128,128,0],olivedrab:[107,142,35],orange:[255,165,0],orangered:[255,69,0],orchid:[218,112,214],palegoldenrod:[238,232,170],palegreen:[152,251,152],paleturquoise:[175,238,238],palevioletred:[219,112,147],papayawhip:[255,239,213],peachpuff:[255,218,185],peru:[205,133,63],pink:[255,192,203],plum:[221,160,221],powderblue:[176,224,230],purple:[128,0,128],rebeccapurple:[102,51,153],red:[255,0,0],rosybrown:[188,143,143],royalblue:[65,105,225],saddlebrown:[139,69,19],salmon:[250,128,114],sandybrown:[244,164,96],seagreen:[46,139,87],seashell:[255,245,238],sienna:[160,82,45],silver:[192,192,192],skyblue:[135,206,235],slateblue:[106,90,205],slategray:[112,128,144],slategrey:[112,128,144],snow:[255,250,250],springgreen:[0,255,127],steelblue:[70,130,180],tan:[210,180,140],teal:[0,128,128],thistle:[216,191,216],tomato:[255,99,71],turquoise:[64,224,208],violet:[238,130,238],wheat:[245,222,179],white:[255,255,255],whitesmoke:[245,245,245],yellow:[255,255,0],yellowgreen:[154,205,50]};for(const e in VZ)Object.freeze(VZ[e]);var jZ=Object.freeze(VZ);const GZ=Object.create(null);for(const e in jZ)Object.hasOwn(jZ,e)&&(GZ[jZ[e]]=e);const HZ={to:{},get:{}};function QZ(e,t,i){return Math.min(Math.max(t,e),i)}function $Z(e){const t=Math.round(e).toString(16).toUpperCase();return t.length<2?"0"+t:t}HZ.get=function(e){let t,i;switch(e.slice(0,3).toLowerCase()){case"hsl":t=HZ.get.hsl(e),i="hsl";break;case"hwb":t=HZ.get.hwb(e),i="hwb";break;default:t=HZ.get.rgb(e),i="rgb"}return t?{model:i,value:t}:null},HZ.get.rgb=function(e){if(!e)return null;let t,i,n,r=[0,0,0,1];if(t=e.match(/^#([a-f\d]{6})([a-f\d]{2})?$/i)){for(n=t[2],t=t[1],i=0;i<3;i++){const e=2*i;r[i]=Number.parseInt(t.slice(e,e+2),16)}n&&(r[3]=Number.parseInt(n,16)/255)}else if(t=e.match(/^#([a-f\d]{3,4})$/i)){for(t=t[1],n=t[3],i=0;i<3;i++)r[i]=Number.parseInt(t[i]+t[i],16);n&&(r[3]=Number.parseInt(n+n,16)/255)}else if(t=e.match(/^rgba?\(\s*([+-]?(?:\d*\.)?\d+(?:e\d+)?)(?=[\s,])\s*(?:,\s*)?([+-]?(?:\d*\.)?\d+(?:e\d+)?)(?=[\s,])\s*(?:,\s*)?([+-]?(?:\d*\.)?\d+(?:e\d+)?)\s*(?:[\s,|/]\s*([+-]?(?:\d*\.)?\d+(?:e\d+)?)(%?)\s*)?\)$/i)){for(i=0;i<3;i++)r[i]=Number.parseFloat(t[i+1]);t[4]&&(r[3]=t[5]?.01*Number.parseFloat(t[4]):Number.parseFloat(t[4]))}else{if(!(t=e.match(/^rgba?\(\s*([+-]?[\d.]+)%\s*,?\s*([+-]?[\d.]+)%\s*,?\s*([+-]?[\d.]+)%\s*(?:[\s,|/]\s*([+-]?[\d.]+)(%?)\s*)?\)$/i)))return(t=e.toLowerCase().match(/^(\w+)$/))?"transparent"===t[1]?[0,0,0,0]:Object.hasOwn(jZ,t[1])?(r=jZ[t[1]].slice(),r[3]=1,r):null:null;for(i=0;i<3;i++)r[i]=Math.round(2.55*Number.parseFloat(t[i+1]));t[4]&&(r[3]=t[5]?.01*Number.parseFloat(t[4]):Number.parseFloat(t[4]))}for(i=0;i<3;i++)r[i]=QZ(r[i],0,255);return r[3]=QZ(r[3],0,1),r},HZ.get.hsl=function(e){if(!e)return null;const t=e.match(/^hsla?\(\s*([+-]?(?:\d{0,3}\.)?\d+)(?:deg)?\s*,?\s*([+-]?[\d.]+)%\s*,?\s*([+-]?[\d.]+)%\s*(?:[,|/]\s*([+-]?(?=\.\d|\d)(?:0|[1-9]\d*)?(?:\.\d*)?(?:e[+-]?\d+)?)\s*)?\)$/i);if(t){const e=Number.parseFloat(t[4]);return[(Number.parseFloat(t[1])%360+360)%360,QZ(Number.parseFloat(t[2]),0,100),QZ(Number.parseFloat(t[3]),0,100),QZ(Number.isNaN(e)?1:e,0,1)]}return null},HZ.get.hwb=function(e){if(!e)return null;const t=e.match(/^hwb\(\s*([+-]?\d{0,3}(?:\.\d+)?)(?:deg)?\s*[\s,]\s*([+-]?[\d.]+)%\s*[\s,]\s*([+-]?[\d.]+)%\s*(?:[\s,]\s*([+-]?(?=\.\d|\d)(?:0|[1-9]\d*)?(?:\.\d*)?(?:e[+-]?\d+)?)\s*)?\)$/i);if(t){const e=Number.parseFloat(t[4]);return[(Number.parseFloat(t[1])%360+360)%360,QZ(Number.parseFloat(t[2]),0,100),QZ(Number.parseFloat(t[3]),0,100),QZ(Number.isNaN(e)?1:e,0,1)]}return null},HZ.to.hex=function(...e){return"#"+$Z(e[0])+$Z(e[1])+$Z(e[2])+(e[3]<1?$Z(Math.round(255*e[3])):"")},HZ.to.rgb=function(...e){return e.length<4||1===e[3]?"rgb("+Math.round(e[0])+", "+Math.round(e[1])+", "+Math.round(e[2])+")":"rgba("+Math.round(e[0])+", "+Math.round(e[1])+", "+Math.round(e[2])+", "+e[3]+")"},HZ.to.rgb.percent=function(...e){const t=Math.round(e[0]/255*100),i=Math.round(e[1]/255*100),n=Math.round(e[2]/255*100);return e.length<4||1===e[3]?"rgb("+t+"%, "+i+"%, "+n+"%)":"rgba("+t+"%, "+i+"%, "+n+"%, "+e[3]+")"},HZ.to.hsl=function(...e){return e.length<4||1===e[3]?"hsl("+e[0]+", "+e[1]+"%, "+e[2]+"%)":"hsla("+e[0]+", "+e[1]+"%, "+e[2]+"%, "+e[3]+")"},HZ.to.hwb=function(...e){let t="";return e.length>=4&&1!==e[3]&&(t=", "+e[3]),"hwb("+e[0]+", "+e[1]+"%, "+e[2]+"%"+t+")"},HZ.to.keyword=function(...e){return GZ[e.slice(0,3)]};const ZZ={};for(const e of Object.keys(jZ))ZZ[jZ[e]]=e;const WZ={rgb:{channels:3,labels:"rgb"},hsl:{channels:3,labels:"hsl"},hsv:{channels:3,labels:"hsv"},hwb:{channels:3,labels:"hwb"},cmyk:{channels:4,labels:"cmyk"},xyz:{channels:3,labels:"xyz"},lab:{channels:3,labels:"lab"},oklab:{channels:3,labels:["okl","oka","okb"]},lch:{channels:3,labels:"lch"},oklch:{channels:3,labels:["okl","okc","okh"]},hex:{channels:1,labels:["hex"]},keyword:{channels:1,labels:["keyword"]},ansi16:{channels:1,labels:["ansi16"]},ansi256:{channels:1,labels:["ansi256"]},hcg:{channels:3,labels:["h","c","g"]},apple:{channels:3,labels:["r16","g16","b16"]},gray:{channels:1,labels:["gray"]}},qZ=(6/29)**3;function KZ(e){const t=e>.0031308?1.055*e**(1/2.4)-.055:12.92*e;return Math.min(Math.max(0,t),1)}function XZ(e){return e>.04045?((e+.055)/1.055)**2.4:e/12.92}for(const e of Object.keys(WZ)){if(!("channels"in WZ[e]))throw new Error("missing channels property: "+e);if(!("labels"in WZ[e]))throw new Error("missing channel labels property: "+e);if(WZ[e].labels.length!==WZ[e].channels)throw new Error("channel and label counts mismatch: "+e);const{channels:t,labels:i}=WZ[e];delete WZ[e].channels,delete WZ[e].labels,Object.defineProperty(WZ[e],"channels",{value:t}),Object.defineProperty(WZ[e],"labels",{value:i})}function JZ(e,t){return(e[0]-t[0])**2+(e[1]-t[1])**2+(e[2]-t[2])**2}function YZ(e){const t=function(){const e={},t=Object.keys(WZ);for(let{length:i}=t,n=0;n0;){const e=i.pop(),n=Object.keys(WZ[e]);for(let{length:r}=n,o=0;o1&&(r-=1)}return[360*r,100*o,100*c]},WZ.rgb.hwb=function(e){const t=e[0],i=e[1];let n=e[2];const r=WZ.rgb.hsl(e)[0],o=1/255*Math.min(t,Math.min(i,n));return n=1-1/255*Math.max(t,Math.max(i,n)),[r,100*o,100*n]},WZ.rgb.oklab=function(e){const t=XZ(e[0]/255),i=XZ(e[1]/255),n=XZ(e[2]/255),r=Math.cbrt(.4122214708*t+.5363325363*i+.0514459929*n),o=Math.cbrt(.2119034982*t+.6806995451*i+.1073969566*n),s=Math.cbrt(.0883024619*t+.2817188376*i+.6299787005*n);return[100*(.2104542553*r+.793617785*o-.0040720468*s),100*(1.9779984951*r-2.428592205*o+.4505937099*s),100*(.0259040371*r+.7827717662*o-.808675766*s)]},WZ.rgb.cmyk=function(e){const t=e[0]/255,i=e[1]/255,n=e[2]/255,r=Math.min(1-t,1-i,1-n);return[100*((1-t-r)/(1-r)||0),100*((1-i-r)/(1-r)||0),100*((1-n-r)/(1-r)||0),100*r]},WZ.rgb.keyword=function(e){const t=ZZ[e];if(t)return t;let i,n=Number.POSITIVE_INFINITY;for(const t of Object.keys(jZ)){const r=JZ(e,jZ[t]);rqZ?i**(1/3):7.787*i+16/116,n=n>qZ?n**(1/3):7.787*n+16/116,r=r>qZ?r**(1/3):7.787*r+16/116;return[116*n-16,500*(i-n),200*(n-r)]},WZ.hsl.rgb=function(e){const t=e[0]/360,i=e[1]/100,n=e[2]/100;let r,o;if(0===i)return o=255*n,[o,o,o];const s=n<.5?n*(1+i):n+i-n*i,a=2*n-s,l=[0,0,0];for(let e=0;e<3;e++)r=t+1/3*-(e-1),r<0&&r++,r>1&&r--,o=6*r<1?a+6*(s-a)*r:2*r<1?s:3*r<2?a+(s-a)*(2/3-r)*6:a,l[e]=255*o;return l},WZ.hsl.hsv=function(e){const t=e[0];let i=e[1]/100,n=e[2]/100,r=i;const o=Math.max(n,.01);n*=2,i*=n<=1?n:2-n,r*=o<=1?o:2-o;return[t,100*(0===n?2*r/(o+r):2*i/(n+i)),100*((n+i)/2)]},WZ.hsv.rgb=function(e){const t=e[0]/60,i=e[1]/100;let n=e[2]/100;const r=Math.floor(t)%6,o=t-Math.floor(t),s=255*n*(1-i),a=255*n*(1-i*o),l=255*n*(1-i*(1-o));switch(n*=255,r){case 0:return[n,l,s];case 1:return[a,n,s];case 2:return[s,n,l];case 3:return[s,a,n];case 4:return[l,s,n];case 5:return[n,s,a]}},WZ.hsv.hsl=function(e){const t=e[0],i=e[1]/100,n=e[2]/100,r=Math.max(n,.01);let o,s;s=(2-i)*n;const a=(2-i)*r;return o=i*r,o/=a<=1?a:2-a,o=o||0,s/=2,[t,100*o,100*s]},WZ.hwb.rgb=function(e){const t=e[0]/360;let i=e[1]/100,n=e[2]/100;const r=i+n;let o;r>1&&(i/=r,n/=r);const s=Math.floor(6*t),a=1-n;o=6*t-s,1&s&&(o=1-o);const l=i+o*(a-i);let c,u,h;switch(s){default:case 6:case 0:c=a,u=l,h=i;break;case 1:c=l,u=a,h=i;break;case 2:c=i,u=a,h=l;break;case 3:c=i,u=l,h=a;break;case 4:c=l,u=i,h=a;break;case 5:c=a,u=i,h=l}return[255*c,255*u,255*h]},WZ.cmyk.rgb=function(e){const t=e[0]/100,i=e[1]/100,n=e[2]/100,r=e[3]/100;return[255*(1-Math.min(1,t*(1-r)+r)),255*(1-Math.min(1,i*(1-r)+r)),255*(1-Math.min(1,n*(1-r)+r))]},WZ.xyz.rgb=function(e){const t=e[0]/100,i=e[1]/100,n=e[2]/100;let r,o,s;return r=3.2404542*t+-1.5371385*i+-.4985314*n,o=-.969266*t+1.8760108*i+.041556*n,s=.0556434*t+-.2040259*i+1.0572252*n,r=KZ(r),o=KZ(o),s=KZ(s),[255*r,255*o,255*s]},WZ.xyz.lab=function(e){let t=e[0],i=e[1],n=e[2];t/=95.047,i/=100,n/=108.883,t=t>qZ?t**(1/3):7.787*t+16/116,i=i>qZ?i**(1/3):7.787*i+16/116,n=n>qZ?n**(1/3):7.787*n+16/116;return[116*i-16,500*(t-i),200*(i-n)]},WZ.xyz.oklab=function(e){const t=e[0]/100,i=e[1]/100,n=e[2]/100,r=Math.cbrt(.8189330101*t+.3618667424*i-.1288597137*n),o=Math.cbrt(.0329845436*t+.9293118715*i+.0361456387*n),s=Math.cbrt(.0482003018*t+.2643662691*i+.633851707*n);return[100*(.2104542553*r+.793617785*o-.0040720468*s),100*(1.9779984951*r-2.428592205*o+.4505937099*s),100*(.0259040371*r+.7827717662*o-.808675766*s)]},WZ.oklab.oklch=function(e){return WZ.lab.lch(e)},WZ.oklab.xyz=function(e){const t=e[0]/100,i=e[1]/100,n=e[2]/100,r=(.999999998*t+.396337792*i+.215803758*n)**3,o=(1.000000008*t-.105561342*i-.063854175*n)**3,s=(1.000000055*t-.089484182*i-1.291485538*n)**3;return[100*(1.227013851*r-.55779998*o+.281256149*s),100*(-.040580178*r+1.11225687*o-.071676679*s),100*(-.076381285*r-.421481978*o+1.58616322*s)]},WZ.oklab.rgb=function(e){const t=e[0]/100,i=e[1]/100,n=e[2]/100,r=(t+.3963377774*i+.2158037573*n)**3,o=(t-.1055613458*i-.0638541728*n)**3,s=(t-.0894841775*i-1.291485548*n)**3;return[255*KZ(4.0767416621*r-3.3077115913*o+.2309699292*s),255*KZ(-1.2684380046*r+2.6097574011*o-.3413193965*s),255*KZ(-.0041960863*r-.7034186147*o+1.707614701*s)]},WZ.oklch.oklab=function(e){return WZ.lch.lab(e)},WZ.lab.xyz=function(e){let t,i,n;i=(e[0]+16)/116,t=e[1]/500+i,n=i-e[2]/200;const r=i**3,o=t**3,s=n**3;return i=r>qZ?r:(i-16/116)/7.787,t=o>qZ?o:(t-16/116)/7.787,n=s>qZ?s:(n-16/116)/7.787,t*=95.047,i*=100,n*=108.883,[t,i,n]},WZ.lab.lch=function(e){const t=e[0],i=e[1],n=e[2];let r;r=360*Math.atan2(n,i)/2/Math.PI,r<0&&(r+=360);return[t,Math.sqrt(i*i+n*n),r]},WZ.lch.lab=function(e){const t=e[0],i=e[1],n=e[2]/360*2*Math.PI;return[t,i*Math.cos(n),i*Math.sin(n)]},WZ.rgb.ansi16=function(e,t=null){const[i,n,r]=e;let o=null===t?WZ.rgb.hsv(e)[2]:t;if(o=Math.round(o/50),0===o)return 30;let s=30+(Math.round(r/255)<<2|Math.round(n/255)<<1|Math.round(i/255));return 2===o&&(s+=60),s},WZ.hsv.ansi16=function(e){return WZ.rgb.ansi16(WZ.hsv.rgb(e),e[2])},WZ.rgb.ansi256=function(e){const t=e[0],i=e[1],n=e[2];if(t>>4==i>>4&&i>>4==n>>4)return t<8?16:t>248?231:Math.round((t-8)/247*24)+232;return 16+36*Math.round(t/255*5)+6*Math.round(i/255*5)+Math.round(n/255*5)},WZ.ansi16.rgb=function(e){let t=(e=e[0])%10;if(0===t||7===t)return e>50&&(t+=3.5),t=t/10.5*255,[t,t,t];const i=.5*(Math.trunc(e>50)+1);return[(1&t)*i*255,(t>>1&1)*i*255,(t>>2&1)*i*255]},WZ.ansi256.rgb=function(e){if((e=e[0])>=232){const t=10*(e-232)+8;return[t,t,t]}let t;e-=16;return[Math.floor(e/36)/5*255,Math.floor((t=e%36)/6)/5*255,t%6/5*255]},WZ.rgb.hex=function(e){const t=(((255&Math.round(e[0]))<<16)+((255&Math.round(e[1]))<<8)+(255&Math.round(e[2]))).toString(16).toUpperCase();return"000000".slice(t.length)+t},WZ.hex.rgb=function(e){const t=e.toString(16).match(/[a-f\d]{6}|[a-f\d]{3}/i);if(!t)return[0,0,0];let i=t[0];3===t[0].length&&(i=[...i].map(e=>e+e).join(""));const n=Number.parseInt(i,16);return[n>>16&255,n>>8&255,255&n]},WZ.rgb.hcg=function(e){const t=e[0]/255,i=e[1]/255,n=e[2]/255,r=Math.max(Math.max(t,i),n),o=Math.min(Math.min(t,i),n),s=r-o;let a;return a=s<=0?0:r===t?(i-n)/s%6:r===i?2+(n-t)/s:4+(t-i)/s,a/=6,a%=1,[360*a,100*s,100*(s<1?o/(1-s):0)]},WZ.hsl.hcg=function(e){const t=e[1]/100,i=e[2]/100,n=i<.5?2*t*i:2*t*(1-i);let r=0;return n<1&&(r=(i-.5*n)/(1-n)),[e[0],100*n,100*r]},WZ.hsv.hcg=function(e){const t=e[1]/100,i=e[2]/100,n=t*i;let r=0;return n<1&&(r=(i-n)/(1-n)),[e[0],100*n,100*r]},WZ.hcg.rgb=function(e){const t=e[0]/360,i=e[1]/100,n=e[2]/100;if(0===i)return[255*n,255*n,255*n];const r=[0,0,0],o=t%1*6,s=o%1,a=1-s;let l=0;switch(Math.floor(o)){case 0:r[0]=1,r[1]=s,r[2]=0;break;case 1:r[0]=a,r[1]=1,r[2]=0;break;case 2:r[0]=0,r[1]=1,r[2]=s;break;case 3:r[0]=0,r[1]=a,r[2]=1;break;case 4:r[0]=s,r[1]=0,r[2]=1;break;default:r[0]=1,r[1]=0,r[2]=a}return l=(1-i)*n,[255*(i*r[0]+l),255*(i*r[1]+l),255*(i*r[2]+l)]},WZ.hcg.hsv=function(e){const t=e[1]/100,i=t+e[2]/100*(1-t);let n=0;return i>0&&(n=t/i),[e[0],100*n,100*i]},WZ.hcg.hsl=function(e){const t=e[1]/100,i=e[2]/100*(1-t)+.5*t;let n=0;return i>0&&i<.5?n=t/(2*i):i>=.5&&i<1&&(n=t/(2*(1-i))),[e[0],100*n,100*i]},WZ.hcg.hwb=function(e){const t=e[1]/100,i=t+e[2]/100*(1-t);return[e[0],100*(i-t),100*(1-i)]},WZ.hwb.hcg=function(e){const t=e[1]/100,i=1-e[2]/100,n=i-t;let r=0;return n<1&&(r=(i-n)/(1-n)),[e[0],100*n,100*r]},WZ.apple.rgb=function(e){return[e[0]/65535*255,e[1]/65535*255,e[2]/65535*255]},WZ.rgb.apple=function(e){return[e[0]/255*65535,e[1]/255*65535,e[2]/255*65535]},WZ.gray.rgb=function(e){return[e[0]/100*255,e[0]/100*255,e[0]/100*255]},WZ.gray.hsl=function(e){return[0,0,e[0]]},WZ.gray.hsv=WZ.gray.hsl,WZ.gray.hwb=function(e){return[0,100,e[0]]},WZ.gray.cmyk=function(e){return[0,0,0,e[0]]},WZ.gray.lab=function(e){return[e[0],0,0]},WZ.gray.hex=function(e){const t=255&Math.round(e[0]/100*255),i=((t<<16)+(t<<8)+t).toString(16).toUpperCase();return"000000".slice(i.length)+i},WZ.rgb.gray=function(e){return[(e[0]+e[1]+e[2])/3/255*100]};const nW={},rW=Object.keys(WZ);function oW(e){const t=function(...t){const i=t[0];return null==i?i:(i.length>1&&(t=i),e(t))};return"conversion"in e&&(t.conversion=e.conversion),t}function sW(e){const t=function(...t){const i=t[0];if(null==i)return i;i.length>1&&(t=i);const n=e(t);if("object"==typeof n)for(let{length:e}=n,t=0;t0){this.model=t||"rgb",n=nW[this.model].channels;const i=Array.prototype.slice.call(e,0,n);this.color=fW(i,n),this.valpha="number"==typeof e[n]?e[n]:1}else if("number"==typeof e)this.model="rgb",this.color=[e>>16&255,e>>8&255,255&e],this.valpha=1;else{this.valpha=1;const t=Object.keys(e);"alpha"in e&&(t.splice(t.indexOf("alpha"),1),this.valpha="number"==typeof e.alpha?e.alpha:0);const n=t.sort().join("");if(!(n in lW))throw new Error("Unable to parse color from object: "+JSON.stringify(e));this.model=lW[n];const{labels:r}=nW[this.model],o=[];for(i=0;i(e%360+360)%360),saturationl:dW("hsl",1,pW(100)),lightness:dW("hsl",2,pW(100)),saturationv:dW("hsv",1,pW(100)),value:dW("hsv",2,pW(100)),chroma:dW("hcg",1,pW(100)),gray:dW("hcg",2,pW(100)),white:dW("hwb",1,pW(100)),wblack:dW("hwb",2,pW(100)),cyan:dW("cmyk",0,pW(100)),magenta:dW("cmyk",1,pW(100)),yellow:dW("cmyk",2,pW(100)),black:dW("cmyk",3,pW(100)),x:dW("xyz",0,pW(95.047)),y:dW("xyz",1,pW(100)),z:dW("xyz",2,pW(108.833)),l:dW("lab",0,pW(100)),a:dW("lab",1),b:dW("lab",2),keyword(e){return void 0!==e?new uW(e):nW[this.model].keyword(this.color)},hex(e){return void 0!==e?new uW(e):HZ.to.hex(...this.rgb().round().color)},hexa(e){if(void 0!==e)return new uW(e);const t=this.rgb().round().color;let i=Math.round(255*this.valpha).toString(16).toUpperCase();return 1===i.length&&(i="0"+i),HZ.to.hex(...t)+i},rgbNumber(){const e=this.rgb().color;return(255&e[0])<<16|(255&e[1])<<8|255&e[2]},luminosity(){const e=this.rgb().color,t=[];for(const[i,n]of e.entries()){const e=n/255;t[i]=e<=.04045?e/12.92:((e+.055)/1.055)**2.4}return.2126*t[0]+.7152*t[1]+.0722*t[2]},contrast(e){const t=this.luminosity(),i=e.luminosity();return t>i?(t+.05)/(i+.05):(i+.05)/(t+.05)},level(e){const t=this.contrast(e);return t>=7?"AAA":t>=4.5?"AA":""},isDark(){const e=this.rgb().color;return(2126*e[0]+7152*e[1]+722*e[2])/1e4<128},isLight(){return!this.isDark()},negate(){const e=this.rgb();for(let t=0;t<3;t++)e.color[t]=255-e.color[t];return e},lighten(e){const t=this.hsl();return t.color[2]+=t.color[2]*e,t},darken(e){const t=this.hsl();return t.color[2]-=t.color[2]*e,t},saturate(e){const t=this.hsl();return t.color[1]+=t.color[1]*e,t},desaturate(e){const t=this.hsl();return t.color[1]-=t.color[1]*e,t},whiten(e){const t=this.hwb();return t.color[1]+=t.color[1]*e,t},blacken(e){const t=this.hwb();return t.color[2]+=t.color[2]*e,t},grayscale(){const e=this.rgb().color,t=.3*e[0]+.59*e[1]+.11*e[2];return uW.rgb(t,t,t)},fade(e){return this.alpha(this.valpha-this.valpha*e)},opaquer(e){return this.alpha(this.valpha+this.valpha*e)},rotate(e){const t=this.hsl();let i=t.color[0];return i=(i+e)%360,i=i<0?360+i:i,t.color[0]=i,t},mix(e,t){if(!e||!e.rgb)throw new Error('Argument to "mix" was not a Color instance, but rather an instance of '+typeof e);const i=e.rgb(),n=this.rgb(),r=void 0===t?.5:t,o=2*r-1,s=i.alpha()-n.alpha(),a=((o*s===-1?o:(o+s)/(1+o*s))+1)/2,l=1-a;return uW.rgb(a*i.red()+l*n.red(),a*i.green()+l*n.green(),a*i.blue()+l*n.blue(),i.alpha()*r+n.alpha()*(1-r))}};for(const e of Object.keys(nW)){if(aW.includes(e))continue;const{channels:t}=nW[e];uW.prototype[e]=function(...t){return this.model===e?new uW(this):t.length>0?new uW(t,e):new uW([...(i=nW[this.model][e].raw(this.color),Array.isArray(i)?i:[i]),this.valpha],e);var i},uW[e]=function(...i){let n=i[0];return"number"==typeof n&&(n=fW(i,t)),new uW(n,e)}}function hW(e){return function(t){return function(e,t){return Number(e.toFixed(t))}(t,e)}}function dW(e,t,i){e=Array.isArray(e)?e:[e];for(const n of e)(cW[n]||=[])[t]=i;return e=e[0],function(n){let r;return void 0!==n?(i&&(n=i(n)),r=this[e](),r.color[t]=n,r):(r=this[e]().color[t],i&&(r=i(r)),r)}}function pW(e){return function(t){return Math.max(0,Math.min(e,t))}}function fW(e,t){for(let i=0;ii(24,c=e));let u,{id:h}=t,{bearing:d}=t,{center:p}=t,{pitch:f}=t,{showCollisions:m}=t,{showBoundaries:g}=t,{zoom:_}=t,{mapStyle:A}=t,{numberOfMaps:y}=t,{onMapMount:v}=t,{mapRenderer:x}=t;const b=H();let w,T,E,C={},S=null,B=!1,I={};const M=()=>({bearing:T.getBearing(),center:T.getCenter(),pitch:T.getPitch(),zoom:T.getZoom()}),P=(e,t)=>{e&&!ru(M(),I)&&e.jumpTo(t)},R=()=>{o&&T.setProjection({type:o})},L=()=>{const e=T.getStyle(),t=e?.light,i=e?.terrain,{data:n,beforeId:r,light:o,opacity:a}=s;let l,c,u,h,d;if(o){const{ambient:e,directional:t,point:i,camera:n}=o;e&&(e.color||(e.color="rgb(255, 255, 255)"),e.color=uW(e.color).rgb().array(),l=new wv(e)),t&&(t.color||(t.color="rgb(255, 255, 255)"),t.color=uW(t.color).rgb().array(),c=new Bv(t)),i&&(i.color||(i.color="rgb(255, 255, 255)"),i.color=uW(i.color).rgb().array(),u=new ax(i)),n&&(n.color||(n.color="rgb(255, 255, 255)"),n.color=uW(n.color).rgb().array(),h=new lx(n)),d=new Dv({...l&&{ambientLight:l},...c&&{directionalLight:c},...u&&{pointLight:u},...h&&{cameraLight:h}})}else if(t){let{anchor:e,color:i,intensity:n,position:r}=t;i||(i="rgb(255, 255, 255)"),i=uW(i).rgb().array(),l=new wv({color:i,intensity:5*n}),r?(c=new Bv({color:i,intensity:10*n,direction:(p=r,[p[2],(p[1]-90)%180*-1,p[0]])}),d=new Dv({ambientLight:l,directionalLight:c})):d=new Dv({ambientLight:l})}var p;let f,m;if(i){const{source:t,exaggeration:n}=i,r=e?.sources?.[t];f=new PV({id:"terrain",minZoom:0,maxZoom:23,strategy:"no-overlap",elevationDecoder:{rScaler:6553.6*n,gScaler:25.6*n,bScaler:.1*n,offset:-1e4*n},elevationData:r?.url??r?.tiles?.[0],color:[255,255,255,0],operation:"terrain+draw"}),m=new WV}const g=new dV({id:"tile-3d-layer",data:n,loader:NZ,opacity:a??1,onTilesetError:e=>console.log(e),...r&&{beforeId:r},...m&&{extensions:[m]}});E||(E=new US({interleaved:!0,layers:[f,g].filter(Boolean),...d&&{effects:[d]}}),T.addControl(E))};return j(async()=>{await(async()=>{"maplibre-gl"===x?(await Promise.resolve().then(function(){return JX}),u=await Promise.resolve().then(function(){return Xe})):"maptiler-sdk"===x?(await Promise.resolve().then(function(){return YX}),u=await Promise.resolve().then(function(){return c7}),u.config.apiKey=c.maptilerApiKey):(await Promise.resolve().then(function(){return u7}),u=await Promise.resolve().then(function(){return We}),u.accessToken=c.mapboxGlAccessToken,c.mapboxBaseApiUrl&&(u.baseApiUrl=c.mapboxBaseApiUrl))})();const e=u;let t,l="string"==typeof w;if(n){const e=r??n?.options?.default;if(!e)return;if(l&&(t=await vu(w)),!t)return;n&&n?.script&&(t=await n.script(t,e))}i(13,T=new e.Map({container:h,style:t??w,canvasContextAttributes:{preserveDrawingBuffer:!0},preserveDrawingBuffer:!0,maxPitch:85,...I})),s&&a&&T.once("load",L),o&&"maplibre-gl"===x&&T.on("style.load",()=>{setTimeout(R,150)}),v(T);const d=Ct(()=>{document.getElementById(h).querySelector('canvas[tabindex="0"]').focus()},250);document.getElementById(h).addEventListener("wheel",d,{passive:!0});T.on("move",e=>{e?.resize||(({origin:e})=>{document.getElementById(h)?.contains(document.activeElement)&&b("mapMove",{options:M()})})(e)}),T.on("click",t=>{let i=T.queryRenderedFeatures(t.point);i.length&&(B?(S.remove(),S=null):(S=(new e.Popup).setLngLat(t.lngLat).setHTML((e=>{const t=e.reduce((e,t)=>{const{source:i,sourceLayer:n,properties:r}=t,o=e.some(e=>{const t=e.source===i&&e.sourceLayer===n,o=Object.keys(r).every(t=>r[t]===e.properties[t]);return t&&o});return o||e.push(t),e},[]);let i='",i})(i)).setMaxWidth(360).addTo(T),B=!0,S.on("close",()=>{B=!1})))})}),G(()=>{T&&T.remove()}),e.$$set=e=>{"id"in e&&i(0,h=e.id),"bearing"in e&&i(1,d=e.bearing),"center"in e&&i(2,p=e.center),"pitch"in e&&i(3,f=e.pitch),"showCollisions"in e&&i(4,m=e.showCollisions),"showBoundaries"in e&&i(5,g=e.showBoundaries),"zoom"in e&&i(6,_=e.zoom),"mapStyle"in e&&i(7,A=e.mapStyle),"numberOfMaps"in e&&i(8,y=e.numberOfMaps),"onMapMount"in e&&i(9,v=e.onMapMount),"mapRenderer"in e&&i(10,x=e.mapRenderer)},e.$$.update=()=>{128&e.$$.dirty[0]&&i(11,({style:C,url:w,precompile:n,selectedPrecompileOption:r,projection:o,deckGlLayer:s,landmarks3D:a}=A),C,(i(12,w),i(7,A)),(i(18,r),i(7,A)),(i(17,o),i(7,A)),(i(16,s),i(7,A)),(i(15,a),i(7,A))),78&e.$$.dirty[0]&&i(14,I={bearing:d,center:p,pitch:f,zoom:_}),8208&e.$$.dirty[0]&&T&&i(13,T.showCollisionBoxes=m,T),8224&e.$$.dirty[0]&&T&&i(13,T.showTileBoundaries=g,T),24576&e.$$.dirty[0]&&P(T,I),505856&e.$$.dirty[0]&&(async(e,t,i,r,o,s,a)=>{if(!e)return;e.off("style.load",R),E&&(e.removeControl(E),E=null);let l=t;!l&&A?.pattern&&(l=xu(A?.pattern,A?.branch,A?.branchStyle));let c=i;if(n){if(!r)return;if(!i&&"string"==typeof l&&(c=await vu(l)),!c)return;c=await n.script(c,r),e.setStyle(c)}else e.setStyle(l||i);s&&a&&setTimeout(L,150),o&&"maplibre-gl"===x&&setTimeout(R,150)})(T,w,C,r,o,s,a),9473&e.$$.dirty[0]&&T&&y&&"maplibre-gl"!==x&&"maptiler-sdk"!==x&&T.once("render",()=>{const e=document.getElementById(h);if(e){new ResizeObserver(()=>{T.resize({resize:!0})}).observe(e)}})},[h,d,p,f,m,g,_,A,y,v,x,C,w,T,I,a,s,o,r]}class _W extends ge{constructor(e){super(),me(this,e,gW,mW,a,{id:0,bearing:1,center:2,pitch:3,showCollisions:4,showBoundaries:5,zoom:6,mapStyle:7,numberOfMaps:8,onMapMount:9,mapRenderer:10},null,[-1,-1])}}var AW={exports:{}}; /* @preserve * Leaflet 1.9.4, a JS library for interactive maps. https://leafletjs.com * (c) 2010-2023 Vladimir Agafonkin, (c) 2010-2011 CloudMade - */function cH(e){let i;return{c(){i=b("div"),S(i,"id",e[0]),S(i,"class","map svelte-84o01x")},m(e,t){y(e,i,t)},p(e,[t]){1&t&&S(i,"id",e[0])},i:t,o:t,d(e){e&&v(i)}}}function uH(e,t,i){let{id:r}=t,{center:n}=t,{zoom:o}=t,{mapStyle:s}=t,{numberOfMaps:a}=t,{overrideLayer:l}=t,{onMapMount:c}=t;const u=H();let h,d,p,f={};const m=()=>({center:d.getCenter(),zoom:d.getZoom()-1}),g=(e,t)=>{e&&!nu(m(),f)&&e.setView(t.center,t.zoom+1,{animate:!1})};return j(async()=>{i(8,d=lH.exports.map(r,{zoomControl:!1,zoomDelta:.25,zoomSnap:0}).setView(f.center,f.zoom+1)),d.attributionControl.setPrefix(""),c(d);const e=Ct(()=>{document.getElementById(r).focus()},250);document.getElementById(r).addEventListener("wheel",e,{passive:!0});d.on("move",e=>{e?.resize||(({origin:e})=>{document.getElementById(r)===document.activeElement&&u("mapMove",{options:m()})})(e)})}),G(()=>{d&&d.remove()}),e.$$set=e=>{"id"in e&&i(0,r=e.id),"center"in e&&i(1,n=e.center),"zoom"in e&&i(2,o=e.zoom),"mapStyle"in e&&i(3,s=e.mapStyle),"numberOfMaps"in e&&i(4,a=e.numberOfMaps),"overrideLayer"in e&&i(5,l=e.overrideLayer),"onMapMount"in e&&i(6,c=e.onMapMount)},e.$$.update=()=>{8&e.$$.dirty&&i(7,({url:h}=s),h),6&e.$$.dirty&&i(9,f={center:n,zoom:o}),768&e.$$.dirty&&g(d,f),416&e.$$.dirty&&((e,t,i)=>{e&&(p&&p.remove(),p=i||lH.exports.tileLayer(t,{detectRetina:!0}),p.addTo(e))})(d,h,l),273&e.$$.dirty&&d&&a&&d.once("render",()=>{const e=document.getElementById(r);if(e){new ResizeObserver(()=>{d.resize({resize:!0})}).observe(e)}})},[r,n,o,s,a,l,c,h,d,f]}!function(e){var t="1.9.4";function i(e){var t,i,r,n;for(i=1,r=arguments.length;i0?Math.floor(e):Math.ceil(e)};function k(e,t,i){return e instanceof R?e:_(e)?new R(e[0],e[1]):null==e?e:"object"==typeof e&&"x"in e&&"y"in e?new R(e.x,e.y):new R(e,t,i)}function D(e,t){if(e)for(var i=t?[e,t]:e,r=0,n=i.length;r=this.min.x&&i.x<=this.max.x&&t.y>=this.min.y&&i.y<=this.max.y},intersects:function(e){e=O(e);var t=this.min,i=this.max,r=e.min,n=e.max,o=n.x>=t.x&&r.x<=i.x,s=n.y>=t.y&&r.y<=i.y;return o&&s},overlaps:function(e){e=O(e);var t=this.min,i=this.max,r=e.min,n=e.max,o=n.x>t.x&&r.xt.y&&r.y=r.lat&&i.lat<=n.lat&&t.lng>=r.lng&&i.lng<=n.lng},intersects:function(e){e=U(e);var t=this._southWest,i=this._northEast,r=e.getSouthWest(),n=e.getNorthEast(),o=n.lat>=t.lat&&r.lat<=i.lat,s=n.lng>=t.lng&&r.lng<=i.lng;return o&&s},overlaps:function(e){e=U(e);var t=this._southWest,i=this._northEast,r=e.getSouthWest(),n=e.getNorthEast(),o=n.lat>t.lat&&r.latt.lng&&r.lng1,Ie=function(){var e=!1;try{var t=Object.defineProperty({},"passive",{get:function(){e=!0}});window.addEventListener("testPassiveEventSupport",c,t),window.removeEventListener("testPassiveEventSupport",c,t)}catch(e){}return e}(),Me=!!document.createElement("canvas").getContext,Pe=!(!document.createElementNS||!K("svg").createSVGRect),Re=!!Pe&&((J=document.createElement("div")).innerHTML="","http://www.w3.org/2000/svg"===(J.firstChild&&J.firstChild.namespaceURI)),Le=!Pe&&function(){try{var e=document.createElement("div");e.innerHTML='';var t=e.firstChild;return t.style.behavior="url(#default#VML)",t&&"object"==typeof t.adj}catch(e){return!1}}(),Fe=0===navigator.platform.indexOf("Mac"),ke=0===navigator.platform.indexOf("Linux");function De(e){return navigator.userAgent.toLowerCase().indexOf(e)>=0}var Oe={ie:ee,ielt9:te,edge:ie,webkit:re,android:ne,android23:oe,androidStock:ae,opera:le,chrome:ce,gecko:ue,safari:he,phantom:de,opera12:pe,win:fe,ie3d:me,webkit3d:ge,gecko3d:_e,any3d:Ae,mobile:ye,mobileWebkit:ve,mobileWebkit3d:xe,msPointer:be,pointer:we,touch:Ee,touchNative:Te,mobileOpera:Ce,mobileGecko:Be,retina:Se,passiveEvents:Ie,canvas:Me,svg:Pe,vml:Le,inlineSvg:Re,mac:Fe,linux:ke},ze=Oe.msPointer?"MSPointerDown":"pointerdown",Ue=Oe.msPointer?"MSPointerMove":"pointermove",Ne=Oe.msPointer?"MSPointerUp":"pointerup",Ve=Oe.msPointer?"MSPointerCancel":"pointercancel",je={touchstart:ze,touchmove:Ue,touchend:Ne,touchcancel:Ve},Ge={touchstart:Ye,touchmove:Je,touchend:Je,touchcancel:Je},He={},Qe=!1;function $e(e,t,i){return"touchstart"===t&&Xe(),Ge[t]?(i=Ge[t].bind(this,i),e.addEventListener(je[t],i,!1),i):(console.warn("wrong event specified:",t),c)}function Ze(e,t,i){je[t]?e.removeEventListener(je[t],i,!1):console.warn("wrong event specified:",t)}function We(e){He[e.pointerId]=e}function qe(e){He[e.pointerId]&&(He[e.pointerId]=e)}function Ke(e){delete He[e.pointerId]}function Xe(){Qe||(document.addEventListener(ze,We,!0),document.addEventListener(Ue,qe,!0),document.addEventListener(Ne,Ke,!0),document.addEventListener(Ve,Ke,!0),Qe=!0)}function Je(e,t){if(t.pointerType!==(t.MSPOINTER_TYPE_MOUSE||"mouse")){for(var i in t.touches=[],He)t.touches.push(He[i]);t.changedTouches=[t],e(t)}}function Ye(e,t){t.MSPOINTER_TYPE_TOUCH&&t.pointerType===t.MSPOINTER_TYPE_TOUCH&&Wt(t),Je(e,t)}function et(e){var t,i,r={};for(i in e)t=e[i],r[i]=t&&t.bind?t.bind(e):t;return e=r,r.type="dblclick",r.detail=2,r.isTrusted=!1,r._simulated=!0,r}var tt=200;function it(e,t){e.addEventListener("dblclick",t);var i,r=0;function n(e){if(1===e.detail){if("mouse"!==e.pointerType&&(!e.sourceCapabilities||e.sourceCapabilities.firesTouchEvents)){var n=Kt(e);if(!n.some(function(e){return e instanceof HTMLLabelElement&&e.attributes.for})||n.some(function(e){return e instanceof HTMLInputElement||e instanceof HTMLSelectElement})){var o=Date.now();o-r<=tt?2===++i&&t(et(e)):i=1,r=o}}}else i=e.detail}return e.addEventListener("click",n),{dblclick:t,simDblclick:n}}function rt(e,t){e.removeEventListener("dblclick",t.dblclick),e.removeEventListener("click",t.simDblclick)}var nt,ot,st,at,lt,ct=Ct(["transform","webkitTransform","OTransform","MozTransform","msTransform"]),ut=Ct(["webkitTransition","transition","OTransition","MozTransition","msTransition"]),ht="webkitTransition"===ut||"OTransition"===ut?ut+"End":"transitionend";function dt(e){return"string"==typeof e?document.getElementById(e):e}function pt(e,t){var i=e.style[t]||e.currentStyle&&e.currentStyle[t];if((!i||"auto"===i)&&document.defaultView){var r=document.defaultView.getComputedStyle(e,null);i=r?r[t]:null}return"auto"===i?null:i}function ft(e,t,i){var r=document.createElement(e);return r.className=t||"",i&&i.appendChild(r),r}function mt(e){var t=e.parentNode;t&&t.removeChild(e)}function gt(e){for(;e.firstChild;)e.removeChild(e.firstChild)}function _t(e){var t=e.parentNode;t&&t.lastChild!==e&&t.appendChild(e)}function At(e){var t=e.parentNode;t&&t.firstChild!==e&&t.insertBefore(e,t.firstChild)}function yt(e,t){if(void 0!==e.classList)return e.classList.contains(t);var i=wt(e);return i.length>0&&new RegExp("(^|\\s)"+t+"(\\s|$)").test(i)}function vt(e,t){if(void 0!==e.classList)for(var i=d(t),r=0,n=i.length;r0?2*window.devicePixelRatio:1;function Yt(e){return Oe.edge?e.wheelDeltaY/2:e.deltaY&&0===e.deltaMode?-e.deltaY/Jt:e.deltaY&&1===e.deltaMode?20*-e.deltaY:e.deltaY&&2===e.deltaMode?60*-e.deltaY:e.deltaX||e.deltaZ?0:e.wheelDelta?(e.wheelDeltaY||e.wheelDelta)/2:e.detail&&Math.abs(e.detail)<32765?20*-e.detail:e.detail?e.detail/-32765*60:0}function ei(e,t){var i=t.relatedTarget;if(!i)return!0;try{for(;i&&i!==e;)i=i.parentNode}catch(e){return!1}return i!==e}var ti={__proto__:null,on:zt,off:Nt,stopPropagation:Qt,disableScrollPropagation:$t,disableClickPropagation:Zt,preventDefault:Wt,stop:qt,getPropagationPath:Kt,getMousePosition:Xt,getWheelDelta:Yt,isExternalTarget:ei,addListener:zt,removeListener:Nt},ii=P.extend({run:function(e,t,i,r){this.stop(),this._el=e,this._inProgress=!0,this._duration=i||.25,this._easeOutPower=1/Math.max(r||.5,.2),this._startPos=It(e),this._offset=t.subtract(this._startPos),this._startTime=+new Date,this.fire("start"),this._animate()},stop:function(){this._inProgress&&(this._step(!0),this._complete())},_animate:function(){this._animId=E(this._animate,this),this._step()},_step:function(e){var t=+new Date-this._startTime,i=1e3*this._duration;tthis.options.maxZoom)?this.setZoom(e):this},panInsideBounds:function(e,t){this._enforcingBounds=!0;var i=this.getCenter(),r=this._limitCenter(i,this._zoom,U(e));return i.equals(r)||this.panTo(r,t),this._enforcingBounds=!1,this},panInside:function(e,t){var i=k((t=t||{}).paddingTopLeft||t.padding||[0,0]),r=k(t.paddingBottomRight||t.padding||[0,0]),n=this.project(this.getCenter()),o=this.project(e),s=this.getPixelBounds(),a=O([s.min.add(i),s.max.subtract(r)]),l=a.getSize();if(!a.contains(o)){this._enforcingBounds=!0;var c=o.subtract(a.getCenter()),u=a.extend(o).getSize().subtract(l);n.x+=c.x<0?-u.x:u.x,n.y+=c.y<0?-u.y:u.y,this.panTo(this.unproject(n),t),this._enforcingBounds=!1}return this},invalidateSize:function(e){if(!this._loaded)return this;e=i({animate:!1,pan:!0},!0===e?{animate:!0}:e);var t=this.getSize();this._sizeChanged=!0,this._lastCenter=null;var r=this.getSize(),o=t.divideBy(2).round(),s=r.divideBy(2).round(),a=o.subtract(s);return a.x||a.y?(e.animate&&e.pan?this.panBy(a):(e.pan&&this._rawPanBy(a),this.fire("move"),e.debounceMoveend?(clearTimeout(this._sizeTimer),this._sizeTimer=setTimeout(n(this.fire,this,"moveend"),200)):this.fire("moveend")),this.fire("resize",{oldSize:t,newSize:r})):this},stop:function(){return this.setZoom(this._limitZoom(this._zoom)),this.options.zoomSnap||this.fire("viewreset"),this._stop()},locate:function(e){if(e=this._locateOptions=i({timeout:1e4,watch:!1},e),!("geolocation"in navigator))return this._handleGeolocationError({code:0,message:"Geolocation not supported."}),this;var t=n(this._handleGeolocationResponse,this),r=n(this._handleGeolocationError,this);return e.watch?this._locationWatchId=navigator.geolocation.watchPosition(t,r,e):navigator.geolocation.getCurrentPosition(t,r,e),this},stopLocate:function(){return navigator.geolocation&&navigator.geolocation.clearWatch&&navigator.geolocation.clearWatch(this._locationWatchId),this._locateOptions&&(this._locateOptions.setView=!1),this},_handleGeolocationError:function(e){if(this._container._leaflet_id){var t=e.code,i=e.message||(1===t?"permission denied":2===t?"position unavailable":"timeout");this._locateOptions.setView&&!this._loaded&&this.fitWorld(),this.fire("locationerror",{code:t,message:"Geolocation error: "+i+"."})}},_handleGeolocationResponse:function(e){if(this._container._leaflet_id){var t=new N(e.coords.latitude,e.coords.longitude),i=t.toBounds(2*e.coords.accuracy),r=this._locateOptions;if(r.setView){var n=this.getBoundsZoom(i);this.setView(t,r.maxZoom?Math.min(n,r.maxZoom):n)}var o={latlng:t,bounds:i,timestamp:e.timestamp};for(var s in e.coords)"number"==typeof e.coords[s]&&(o[s]=e.coords[s]);this.fire("locationfound",o)}},addHandler:function(e,t){if(!t)return this;var i=this[e]=new t(this);return this._handlers.push(i),this.options[e]&&i.enable(),this},remove:function(){if(this._initEvents(!0),this.options.maxBounds&&this.off("moveend",this._panInsideMaxBounds),this._containerId!==this._container._leaflet_id)throw new Error("Map container is being reused by another instance");try{delete this._container._leaflet_id,delete this._containerId}catch(e){this._container._leaflet_id=void 0,this._containerId=void 0}var e;for(e in void 0!==this._locationWatchId&&this.stopLocate(),this._stop(),mt(this._mapPane),this._clearControlPos&&this._clearControlPos(),this._resizeRequest&&(C(this._resizeRequest),this._resizeRequest=null),this._clearHandlers(),this._loaded&&this.fire("unload"),this._layers)this._layers[e].remove();for(e in this._panes)mt(this._panes[e]);return this._layers=[],this._panes=[],delete this._mapPane,delete this._renderer,this},createPane:function(e,t){var i=ft("div","leaflet-pane"+(e?" leaflet-"+e.replace("Pane","")+"-pane":""),t||this._mapPane);return e&&(this._panes[e]=i),i},getCenter:function(){return this._checkIfLoaded(),this._lastCenter&&!this._moved()?this._lastCenter.clone():this.layerPointToLatLng(this._getCenterLayerPoint())},getZoom:function(){return this._zoom},getBounds:function(){var e=this.getPixelBounds();return new z(this.unproject(e.getBottomLeft()),this.unproject(e.getTopRight()))},getMinZoom:function(){return void 0===this.options.minZoom?this._layersMinZoom||0:this.options.minZoom},getMaxZoom:function(){return void 0===this.options.maxZoom?void 0===this._layersMaxZoom?1/0:this._layersMaxZoom:this.options.maxZoom},getBoundsZoom:function(e,t,i){e=U(e),i=k(i||[0,0]);var r=this.getZoom()||0,n=this.getMinZoom(),o=this.getMaxZoom(),s=e.getNorthWest(),a=e.getSouthEast(),l=this.getSize().subtract(i),c=O(this.project(a,r),this.project(s,r)).getSize(),u=Oe.any3d?this.options.zoomSnap:1,h=l.x/c.x,d=l.y/c.y,p=t?Math.max(h,d):Math.min(h,d);return r=this.getScaleZoom(p,r),u&&(r=Math.round(r/(u/100))*(u/100),r=t?Math.ceil(r/u)*u:Math.floor(r/u)*u),Math.max(n,Math.min(o,r))},getSize:function(){return this._size&&!this._sizeChanged||(this._size=new R(this._container.clientWidth||0,this._container.clientHeight||0),this._sizeChanged=!1),this._size.clone()},getPixelBounds:function(e,t){var i=this._getTopLeftPoint(e,t);return new D(i,i.add(this.getSize()))},getPixelOrigin:function(){return this._checkIfLoaded(),this._pixelOrigin},getPixelWorldBounds:function(e){return this.options.crs.getProjectedBounds(void 0===e?this.getZoom():e)},getPane:function(e){return"string"==typeof e?this._panes[e]:e},getPanes:function(){return this._panes},getContainer:function(){return this._container},getZoomScale:function(e,t){var i=this.options.crs;return t=void 0===t?this._zoom:t,i.scale(e)/i.scale(t)},getScaleZoom:function(e,t){var i=this.options.crs;t=void 0===t?this._zoom:t;var r=i.zoom(e*i.scale(t));return isNaN(r)?1/0:r},project:function(e,t){return t=void 0===t?this._zoom:t,this.options.crs.latLngToPoint(V(e),t)},unproject:function(e,t){return t=void 0===t?this._zoom:t,this.options.crs.pointToLatLng(k(e),t)},layerPointToLatLng:function(e){var t=k(e).add(this.getPixelOrigin());return this.unproject(t)},latLngToLayerPoint:function(e){return this.project(V(e))._round()._subtract(this.getPixelOrigin())},wrapLatLng:function(e){return this.options.crs.wrapLatLng(V(e))},wrapLatLngBounds:function(e){return this.options.crs.wrapLatLngBounds(U(e))},distance:function(e,t){return this.options.crs.distance(V(e),V(t))},containerPointToLayerPoint:function(e){return k(e).subtract(this._getMapPanePos())},layerPointToContainerPoint:function(e){return k(e).add(this._getMapPanePos())},containerPointToLatLng:function(e){var t=this.containerPointToLayerPoint(k(e));return this.layerPointToLatLng(t)},latLngToContainerPoint:function(e){return this.layerPointToContainerPoint(this.latLngToLayerPoint(V(e)))},mouseEventToContainerPoint:function(e){return Xt(e,this._container)},mouseEventToLayerPoint:function(e){return this.containerPointToLayerPoint(this.mouseEventToContainerPoint(e))},mouseEventToLatLng:function(e){return this.layerPointToLatLng(this.mouseEventToLayerPoint(e))},_initContainer:function(e){var t=this._container=dt(e);if(!t)throw new Error("Map container not found.");if(t._leaflet_id)throw new Error("Map container is already initialized.");zt(t,"scroll",this._onScroll,this),this._containerId=s(t)},_initLayout:function(){var e=this._container;this._fadeAnimated=this.options.fadeAnimation&&Oe.any3d,vt(e,"leaflet-container"+(Oe.touch?" leaflet-touch":"")+(Oe.retina?" leaflet-retina":"")+(Oe.ielt9?" leaflet-oldie":"")+(Oe.safari?" leaflet-safari":"")+(this._fadeAnimated?" leaflet-fade-anim":""));var t=pt(e,"position");"absolute"!==t&&"relative"!==t&&"fixed"!==t&&"sticky"!==t&&(e.style.position="relative"),this._initPanes(),this._initControlPos&&this._initControlPos()},_initPanes:function(){var e=this._panes={};this._paneRenderers={},this._mapPane=this.createPane("mapPane",this._container),St(this._mapPane,new R(0,0)),this.createPane("tilePane"),this.createPane("overlayPane"),this.createPane("shadowPane"),this.createPane("markerPane"),this.createPane("tooltipPane"),this.createPane("popupPane"),this.options.markerZoomAnimation||(vt(e.markerPane,"leaflet-zoom-hide"),vt(e.shadowPane,"leaflet-zoom-hide"))},_resetView:function(e,t,i){St(this._mapPane,new R(0,0));var r=!this._loaded;this._loaded=!0,t=this._limitZoom(t),this.fire("viewprereset");var n=this._zoom!==t;this._moveStart(n,i)._move(e,t)._moveEnd(n),this.fire("viewreset"),r&&this.fire("load")},_moveStart:function(e,t){return e&&this.fire("zoomstart"),t||this.fire("movestart"),this},_move:function(e,t,i,r){void 0===t&&(t=this._zoom);var n=this._zoom!==t;return this._zoom=t,this._lastCenter=e,this._pixelOrigin=this._getNewPixelOrigin(e),r?i&&i.pinch&&this.fire("zoom",i):((n||i&&i.pinch)&&this.fire("zoom",i),this.fire("move",i)),this},_moveEnd:function(e){return e&&this.fire("zoomend"),this.fire("moveend")},_stop:function(){return C(this._flyToFrame),this._panAnim&&this._panAnim.stop(),this},_rawPanBy:function(e){St(this._mapPane,this._getMapPanePos().subtract(e))},_getZoomSpan:function(){return this.getMaxZoom()-this.getMinZoom()},_panInsideMaxBounds:function(){this._enforcingBounds||this.panInsideBounds(this.options.maxBounds)},_checkIfLoaded:function(){if(!this._loaded)throw new Error("Set map center and zoom first.")},_initEvents:function(e){this._targets={},this._targets[s(this._container)]=this;var t=e?Nt:zt;t(this._container,"click dblclick mousedown mouseup mouseover mouseout mousemove contextmenu keypress keydown keyup",this._handleDOMEvent,this),this.options.trackResize&&t(window,"resize",this._onResize,this),Oe.any3d&&this.options.transform3DLimit&&(e?this.off:this.on).call(this,"moveend",this._onMoveEnd)},_onResize:function(){C(this._resizeRequest),this._resizeRequest=E(function(){this.invalidateSize({debounceMoveend:!0})},this)},_onScroll:function(){this._container.scrollTop=0,this._container.scrollLeft=0},_onMoveEnd:function(){var e=this._getMapPanePos();Math.max(Math.abs(e.x),Math.abs(e.y))>=this.options.transform3DLimit&&this._resetView(this.getCenter(),this.getZoom())},_findEventTargets:function(e,t){for(var i,r=[],n="mouseout"===t||"mouseover"===t,o=e.target||e.srcElement,a=!1;o;){if((i=this._targets[s(o)])&&("click"===t||"preclick"===t)&&this._draggableMoved(i)){a=!0;break}if(i&&i.listens(t,!0)){if(n&&!ei(o,e))break;if(r.push(i),n)break}if(o===this._container)break;o=o.parentNode}return r.length||a||n||!this.listens(t,!0)||(r=[this]),r},_isClickDisabled:function(e){for(;e&&e!==this._container;){if(e._leaflet_disable_click)return!0;e=e.parentNode}},_handleDOMEvent:function(e){var t=e.target||e.srcElement;if(!(!this._loaded||t._leaflet_disable_events||"click"===e.type&&this._isClickDisabled(t))){var i=e.type;"mousedown"===i&&Lt(t),this._fireDOMEvent(e,i)}},_mouseEvents:["click","dblclick","mouseover","mouseout","contextmenu"],_fireDOMEvent:function(e,t,r){if("click"===e.type){var n=i({},e);n.type="preclick",this._fireDOMEvent(n,n.type,r)}var o=this._findEventTargets(e,t);if(r){for(var s=[],a=0;a0?Math.round(e-t)/2:Math.max(0,Math.ceil(e))-Math.max(0,Math.floor(t))},_limitZoom:function(e){var t=this.getMinZoom(),i=this.getMaxZoom(),r=Oe.any3d?this.options.zoomSnap:1;return r&&(e=Math.round(e/r)*r),Math.max(t,Math.min(i,e))},_onPanTransitionStep:function(){this.fire("move")},_onPanTransitionEnd:function(){xt(this._mapPane,"leaflet-pan-anim"),this.fire("moveend")},_tryAnimatedPan:function(e,t){var i=this._getCenterOffset(e)._trunc();return!(!0!==(t&&t.animate)&&!this.getSize().contains(i)||(this.panBy(i,t),0))},_createAnimProxy:function(){var e=this._proxy=ft("div","leaflet-proxy leaflet-zoom-animated");this._panes.mapPane.appendChild(e),this.on("zoomanim",function(e){var t=ct,i=this._proxy.style[t];Bt(this._proxy,this.project(e.center,e.zoom),this.getZoomScale(e.zoom,1)),i===this._proxy.style[t]&&this._animatingZoom&&this._onZoomTransitionEnd()},this),this.on("load moveend",this._animMoveEnd,this),this._on("unload",this._destroyAnimProxy,this)},_destroyAnimProxy:function(){mt(this._proxy),this.off("load moveend",this._animMoveEnd,this),delete this._proxy},_animMoveEnd:function(){var e=this.getCenter(),t=this.getZoom();Bt(this._proxy,this.project(e,t),this.getZoomScale(t,1))},_catchTransitionEnd:function(e){this._animatingZoom&&e.propertyName.indexOf("transform")>=0&&this._onZoomTransitionEnd()},_nothingToAnimate:function(){return!this._container.getElementsByClassName("leaflet-zoom-animated").length},_tryAnimatedZoom:function(e,t,i){if(this._animatingZoom)return!0;if(i=i||{},!this._zoomAnimated||!1===i.animate||this._nothingToAnimate()||Math.abs(t-this._zoom)>this.options.zoomAnimationThreshold)return!1;var r=this.getZoomScale(t),n=this._getCenterOffset(e)._divideBy(1-1/r);return!(!0!==i.animate&&!this.getSize().contains(n)||(E(function(){this._moveStart(!0,i.noMoveStart||!1)._animateZoom(e,t,!0)},this),0))},_animateZoom:function(e,t,i,r){this._mapPane&&(i&&(this._animatingZoom=!0,this._animateToCenter=e,this._animateToZoom=t,vt(this._mapPane,"leaflet-zoom-anim")),this.fire("zoomanim",{center:e,zoom:t,noUpdate:r}),this._tempFireZoomEvent||(this._tempFireZoomEvent=this._zoom!==this._animateToZoom),this._move(this._animateToCenter,this._animateToZoom,void 0,!0),setTimeout(n(this._onZoomTransitionEnd,this),250))},_onZoomTransitionEnd:function(){this._animatingZoom&&(this._mapPane&&xt(this._mapPane,"leaflet-zoom-anim"),this._animatingZoom=!1,this._move(this._animateToCenter,this._animateToZoom,void 0,!0),this._tempFireZoomEvent&&this.fire("zoom"),delete this._tempFireZoomEvent,this.fire("move"),this._moveEnd(!0))}});function ni(e,t){return new ri(e,t)}var oi=S.extend({options:{position:"topright"},initialize:function(e){p(this,e)},getPosition:function(){return this.options.position},setPosition:function(e){var t=this._map;return t&&t.removeControl(this),this.options.position=e,t&&t.addControl(this),this},getContainer:function(){return this._container},addTo:function(e){this.remove(),this._map=e;var t=this._container=this.onAdd(e),i=this.getPosition(),r=e._controlCorners[i];return vt(t,"leaflet-control"),-1!==i.indexOf("bottom")?r.insertBefore(t,r.firstChild):r.appendChild(t),this._map.on("unload",this.remove,this),this},remove:function(){return this._map?(mt(this._container),this.onRemove&&this.onRemove(this._map),this._map.off("unload",this.remove,this),this._map=null,this):this},_refocusOnMap:function(e){this._map&&e&&e.screenX>0&&e.screenY>0&&this._map.getContainer().focus()}}),si=function(e){return new oi(e)};ri.include({addControl:function(e){return e.addTo(this),this},removeControl:function(e){return e.remove(),this},_initControlPos:function(){var e=this._controlCorners={},t="leaflet-",i=this._controlContainer=ft("div",t+"control-container",this._container);function r(r,n){var o=t+r+" "+t+n;e[r+n]=ft("div",o,i)}r("top","left"),r("top","right"),r("bottom","left"),r("bottom","right")},_clearControlPos:function(){for(var e in this._controlCorners)mt(this._controlCorners[e]);mt(this._controlContainer),delete this._controlCorners,delete this._controlContainer}});var ai=oi.extend({options:{collapsed:!0,position:"topright",autoZIndex:!0,hideSingleBase:!1,sortLayers:!1,sortFunction:function(e,t,i,r){return i1,this._baseLayersList.style.display=e?"":"none"),this._separator.style.display=t&&e?"":"none",this},_onLayerChange:function(e){this._handlingClick||this._update();var t=this._getLayer(s(e.target)),i=t.overlay?"add"===e.type?"overlayadd":"overlayremove":"add"===e.type?"baselayerchange":null;i&&this._map.fire(i,t)},_createRadioElement:function(e,t){var i='",r=document.createElement("div");return r.innerHTML=i,r.firstChild},_addItem:function(e){var t,i=document.createElement("label"),r=this._map.hasLayer(e.layer);e.overlay?((t=document.createElement("input")).type="checkbox",t.className="leaflet-control-layers-selector",t.defaultChecked=r):t=this._createRadioElement("leaflet-base-layers_"+s(this),r),this._layerControlInputs.push(t),t.layerId=s(e.layer),zt(t,"click",this._onInputClick,this);var n=document.createElement("span");n.innerHTML=" "+e.name;var o=document.createElement("span");return i.appendChild(o),o.appendChild(t),o.appendChild(n),(e.overlay?this._overlaysList:this._baseLayersList).appendChild(i),this._checkDisabledLayers(),i},_onInputClick:function(){if(!this._preventClick){var e,t,i=this._layerControlInputs,r=[],n=[];this._handlingClick=!0;for(var o=i.length-1;o>=0;o--)e=i[o],t=this._getLayer(e.layerId).layer,e.checked?r.push(t):e.checked||n.push(t);for(o=0;o=0;n--)e=i[n],t=this._getLayer(e.layerId).layer,e.disabled=void 0!==t.options.minZoom&&rt.options.maxZoom},_expandIfNotCollapsed:function(){return this._map&&!this.options.collapsed&&this.expand(),this},_expandSafely:function(){var e=this._section;this._preventClick=!0,zt(e,"click",Wt),this.expand();var t=this;setTimeout(function(){Nt(e,"click",Wt),t._preventClick=!1})}}),li=function(e,t,i){return new ai(e,t,i)},ci=oi.extend({options:{position:"topleft",zoomInText:'',zoomInTitle:"Zoom in",zoomOutText:'',zoomOutTitle:"Zoom out"},onAdd:function(e){var t="leaflet-control-zoom",i=ft("div",t+" leaflet-bar"),r=this.options;return this._zoomInButton=this._createButton(r.zoomInText,r.zoomInTitle,t+"-in",i,this._zoomIn),this._zoomOutButton=this._createButton(r.zoomOutText,r.zoomOutTitle,t+"-out",i,this._zoomOut),this._updateDisabled(),e.on("zoomend zoomlevelschange",this._updateDisabled,this),i},onRemove:function(e){e.off("zoomend zoomlevelschange",this._updateDisabled,this)},disable:function(){return this._disabled=!0,this._updateDisabled(),this},enable:function(){return this._disabled=!1,this._updateDisabled(),this},_zoomIn:function(e){!this._disabled&&this._map._zoomthis._map.getMinZoom()&&this._map.zoomOut(this._map.options.zoomDelta*(e.shiftKey?3:1))},_createButton:function(e,t,i,r,n){var o=ft("a",i,r);return o.innerHTML=e,o.href="#",o.title=t,o.setAttribute("role","button"),o.setAttribute("aria-label",t),Zt(o),zt(o,"click",qt),zt(o,"click",n,this),zt(o,"click",this._refocusOnMap,this),o},_updateDisabled:function(){var e=this._map,t="leaflet-disabled";xt(this._zoomInButton,t),xt(this._zoomOutButton,t),this._zoomInButton.setAttribute("aria-disabled","false"),this._zoomOutButton.setAttribute("aria-disabled","false"),(this._disabled||e._zoom===e.getMinZoom())&&(vt(this._zoomOutButton,t),this._zoomOutButton.setAttribute("aria-disabled","true")),(this._disabled||e._zoom===e.getMaxZoom())&&(vt(this._zoomInButton,t),this._zoomInButton.setAttribute("aria-disabled","true"))}});ri.mergeOptions({zoomControl:!0}),ri.addInitHook(function(){this.options.zoomControl&&(this.zoomControl=new ci,this.addControl(this.zoomControl))});var ui=function(e){return new ci(e)},hi=oi.extend({options:{position:"bottomleft",maxWidth:100,metric:!0,imperial:!0},onAdd:function(e){var t="leaflet-control-scale",i=ft("div",t),r=this.options;return this._addScales(r,t+"-line",i),e.on(r.updateWhenIdle?"moveend":"move",this._update,this),e.whenReady(this._update,this),i},onRemove:function(e){e.off(this.options.updateWhenIdle?"moveend":"move",this._update,this)},_addScales:function(e,t,i){e.metric&&(this._mScale=ft("div",t,i)),e.imperial&&(this._iScale=ft("div",t,i))},_update:function(){var e=this._map,t=e.getSize().y/2,i=e.distance(e.containerPointToLatLng([0,t]),e.containerPointToLatLng([this.options.maxWidth,t]));this._updateScales(i)},_updateScales:function(e){this.options.metric&&e&&this._updateMetric(e),this.options.imperial&&e&&this._updateImperial(e)},_updateMetric:function(e){var t=this._getRoundNum(e),i=t<1e3?t+" m":t/1e3+" km";this._updateScale(this._mScale,i,t/e)},_updateImperial:function(e){var t,i,r,n=3.2808399*e;n>5280?(t=n/5280,i=this._getRoundNum(t),this._updateScale(this._iScale,i+" mi",i/t)):(r=this._getRoundNum(n),this._updateScale(this._iScale,r+" ft",r/n))},_updateScale:function(e,t,i){e.style.width=Math.round(this.options.maxWidth*i)+"px",e.innerHTML=t},_getRoundNum:function(e){var t=Math.pow(10,(Math.floor(e)+"").length-1),i=e/t;return t*(i=i>=10?10:i>=5?5:i>=3?3:i>=2?2:1)}}),di=function(e){return new hi(e)},pi='',fi=oi.extend({options:{position:"bottomright",prefix:''+(Oe.inlineSvg?pi+" ":"")+"Leaflet"},initialize:function(e){p(this,e),this._attributions={}},onAdd:function(e){for(var t in e.attributionControl=this,this._container=ft("div","leaflet-control-attribution"),Zt(this._container),e._layers)e._layers[t].getAttribution&&this.addAttribution(e._layers[t].getAttribution());return this._update(),e.on("layeradd",this._addAttribution,this),this._container},onRemove:function(e){e.off("layeradd",this._addAttribution,this)},_addAttribution:function(e){e.layer.getAttribution&&(this.addAttribution(e.layer.getAttribution()),e.layer.once("remove",function(){this.removeAttribution(e.layer.getAttribution())},this))},setPrefix:function(e){return this.options.prefix=e,this._update(),this},addAttribution:function(e){return e?(this._attributions[e]||(this._attributions[e]=0),this._attributions[e]++,this._update(),this):this},removeAttribution:function(e){return e?(this._attributions[e]&&(this._attributions[e]--,this._update()),this):this},_update:function(){if(this._map){var e=[];for(var t in this._attributions)this._attributions[t]&&e.push(t);var i=[];this.options.prefix&&i.push(this.options.prefix),e.length&&i.push(e.join(", ")),this._container.innerHTML=i.join(' ')}}});ri.mergeOptions({attributionControl:!0}),ri.addInitHook(function(){this.options.attributionControl&&(new fi).addTo(this)});var mi=function(e){return new fi(e)};oi.Layers=ai,oi.Zoom=ci,oi.Scale=hi,oi.Attribution=fi,si.layers=li,si.zoom=ui,si.scale=di,si.attribution=mi;var gi=S.extend({initialize:function(e){this._map=e},enable:function(){return this._enabled||(this._enabled=!0,this.addHooks()),this},disable:function(){return this._enabled?(this._enabled=!1,this.removeHooks(),this):this},enabled:function(){return!!this._enabled}});gi.addTo=function(e,t){return e.addHandler(t,this),this};var _i={Events:M},Ai=Oe.touch?"touchstart mousedown":"mousedown",yi=P.extend({options:{clickTolerance:3},initialize:function(e,t,i,r){p(this,r),this._element=e,this._dragStartTarget=t||e,this._preventOutline=i},enable:function(){this._enabled||(zt(this._dragStartTarget,Ai,this._onDown,this),this._enabled=!0)},disable:function(){this._enabled&&(yi._dragging===this&&this.finishDrag(!0),Nt(this._dragStartTarget,Ai,this._onDown,this),this._enabled=!1,this._moved=!1)},_onDown:function(e){if(this._enabled&&(this._moved=!1,!yt(this._element,"leaflet-zoom-anim")))if(e.touches&&1!==e.touches.length)yi._dragging===this&&this.finishDrag();else if(!(yi._dragging||e.shiftKey||1!==e.which&&1!==e.button&&!e.touches||(yi._dragging=this,this._preventOutline&&Lt(this._element),Pt(),nt(),this._moving))){this.fire("down");var t=e.touches?e.touches[0]:e,i=kt(this._element);this._startPoint=new R(t.clientX,t.clientY),this._startPos=It(this._element),this._parentScale=Dt(i);var r="mousedown"===e.type;zt(document,r?"mousemove":"touchmove",this._onMove,this),zt(document,r?"mouseup":"touchend touchcancel",this._onUp,this)}},_onMove:function(e){if(this._enabled)if(e.touches&&e.touches.length>1)this._moved=!0;else{var t=e.touches&&1===e.touches.length?e.touches[0]:e,i=new R(t.clientX,t.clientY)._subtract(this._startPoint);(i.x||i.y)&&(Math.abs(i.x)+Math.abs(i.y)l&&(o=s,l=a);l>i&&(t[o]=1,Ii(e,t,i,r,o),Ii(e,t,i,o,n))}function Mi(e,t){for(var i=[e[0]],r=1,n=0,o=e.length;rt&&(i.push(e[r]),n=r);return nt.max.x&&(i|=2),e.yt.max.y&&(i|=8),i}function Fi(e,t){var i=t.x-e.x,r=t.y-e.y;return i*i+r*r}function ki(e,t,i,r){var n,o=t.x,s=t.y,a=i.x-o,l=i.y-s,c=a*a+l*l;return c>0&&((n=((e.x-o)*a+(e.y-s)*l)/c)>1?(o=i.x,s=i.y):n>0&&(o+=a*n,s+=l*n)),a=e.x-o,l=e.y-s,r?a*a+l*l:new R(o,s)}function Di(e){return!_(e[0])||"object"!=typeof e[0][0]&&void 0!==e[0][0]}function Oi(e){return console.warn("Deprecated use of _flat, please use L.LineUtil.isFlat instead."),Di(e)}function zi(e,t){var i,r,n,o,s,a,l,c;if(!e||0===e.length)throw new Error("latlngs not passed");Di(e)||(console.warn("latlngs are not flat! Only the first ring will be used"),e=e[0]);var u=V([0,0]),h=U(e);h.getNorthWest().distanceTo(h.getSouthWest())*h.getNorthEast().distanceTo(h.getNorthWest())<1700&&(u=bi(e));var d=e.length,p=[];for(i=0;ir){l=(o-r)/n,c=[a.x-l*(a.x-s.x),a.y-l*(a.y-s.y)];break}var m=t.unproject(k(c));return V([m.lat+u.lat,m.lng+u.lng])}var Ui={__proto__:null,simplify:Ei,pointToSegmentDistance:Ci,closestPointOnSegment:Bi,clipSegment:Pi,_getEdgeIntersection:Ri,_getBitCode:Li,_sqClosestPointOnSegment:ki,isFlat:Di,_flat:Oi,polylineCenter:zi},Ni={project:function(e){return new R(e.lng,e.lat)},unproject:function(e){return new N(e.y,e.x)},bounds:new D([-180,-90],[180,90])},Vi={R:6378137,R_MINOR:6356752.314245179,bounds:new D([-20037508.34279,-15496570.73972],[20037508.34279,18764656.23138]),project:function(e){var t=Math.PI/180,i=this.R,r=e.lat*t,n=this.R_MINOR/i,o=Math.sqrt(1-n*n),s=o*Math.sin(r),a=Math.tan(Math.PI/4-r/2)/Math.pow((1-s)/(1+s),o/2);return r=-i*Math.log(Math.max(a,1e-10)),new R(e.lng*t*i,r)},unproject:function(e){for(var t,i=180/Math.PI,r=this.R,n=this.R_MINOR/r,o=Math.sqrt(1-n*n),s=Math.exp(-e.y/r),a=Math.PI/2-2*Math.atan(s),l=0,c=.1;l<15&&Math.abs(c)>1e-7;l++)t=o*Math.sin(a),t=Math.pow((1-t)/(1+t),o/2),a+=c=Math.PI/2-2*Math.atan(s*t)-a;return new N(a*i,e.x*i/r)}},ji={__proto__:null,LonLat:Ni,Mercator:Vi,SphericalMercator:Q},Gi=i({},G,{code:"EPSG:3395",projection:Vi,transformation:function(){var e=.5/(Math.PI*Vi.R);return Z(e,.5,-e,.5)}()}),Hi=i({},G,{code:"EPSG:4326",projection:Ni,transformation:Z(1/180,1,-1/180,.5)}),Qi=i({},j,{projection:Ni,transformation:Z(1,0,-1,0),scale:function(e){return Math.pow(2,e)},zoom:function(e){return Math.log(e)/Math.LN2},distance:function(e,t){var i=t.lng-e.lng,r=t.lat-e.lat;return Math.sqrt(i*i+r*r)},infinite:!0});j.Earth=G,j.EPSG3395=Gi,j.EPSG3857=W,j.EPSG900913=q,j.EPSG4326=Hi,j.Simple=Qi;var $i=P.extend({options:{pane:"overlayPane",attribution:null,bubblingMouseEvents:!0},addTo:function(e){return e.addLayer(this),this},remove:function(){return this.removeFrom(this._map||this._mapToAdd)},removeFrom:function(e){return e&&e.removeLayer(this),this},getPane:function(e){return this._map.getPane(e?this.options[e]||e:this.options.pane)},addInteractiveTarget:function(e){return this._map._targets[s(e)]=this,this},removeInteractiveTarget:function(e){return delete this._map._targets[s(e)],this},getAttribution:function(){return this.options.attribution},_layerAdd:function(e){var t=e.target;if(t.hasLayer(this)){if(this._map=t,this._zoomAnimated=t._zoomAnimated,this.getEvents){var i=this.getEvents();t.on(i,this),this.once("remove",function(){t.off(i,this)},this)}this.onAdd(t),this.fire("add"),t.fire("layeradd",{layer:this})}}});ri.include({addLayer:function(e){if(!e._layerAdd)throw new Error("The provided object is not a Layer.");var t=s(e);return this._layers[t]||(this._layers[t]=e,e._mapToAdd=this,e.beforeAdd&&e.beforeAdd(this),this.whenReady(e._layerAdd,e)),this},removeLayer:function(e){var t=s(e);return this._layers[t]?(this._loaded&&e.onRemove(this),delete this._layers[t],this._loaded&&(this.fire("layerremove",{layer:e}),e.fire("remove")),e._map=e._mapToAdd=null,this):this},hasLayer:function(e){return s(e)in this._layers},eachLayer:function(e,t){for(var i in this._layers)e.call(t,this._layers[i]);return this},_addLayers:function(e){for(var t=0,i=(e=e?_(e)?e:[e]:[]).length;tthis._layersMaxZoom&&this.setZoom(this._layersMaxZoom),void 0===this.options.minZoom&&this._layersMinZoom&&this.getZoom()=2&&t[0]instanceof N&&t[0].equals(t[i-1])&&t.pop(),t},_setLatLngs:function(e){lr.prototype._setLatLngs.call(this,e),Di(this._latlngs)&&(this._latlngs=[this._latlngs])},_defaultShape:function(){return Di(this._latlngs[0])?this._latlngs[0]:this._latlngs[0][0]},_clipPoints:function(){var e=this._renderer._bounds,t=this.options.weight,i=new R(t,t);if(e=new D(e.min.subtract(i),e.max.add(i)),this._parts=[],this._pxBounds&&this._pxBounds.intersects(e))if(this.options.noClip)this._parts=this._rings;else for(var r,n=0,o=this._rings.length;ne.y!=r.y>e.y&&e.x<(r.x-i.x)*(e.y-i.y)/(r.y-i.y)+i.x&&(c=!c);return c||lr.prototype._containsPoint.call(this,e,!0)}});function hr(e,t){return new ur(e,t)}var dr=qi.extend({initialize:function(e,t){p(this,t),this._layers={},e&&this.addData(e)},addData:function(e){var t,i,r,n=_(e)?e:e.features;if(n){for(t=0,i=n.length;t0&&n.push(n[0].slice()),n}function yr(e,t){return e.feature?i({},e.feature,{geometry:t}):vr(t)}function vr(e){return"Feature"===e.type||"FeatureCollection"===e.type?e:{type:"Feature",properties:{},geometry:e}}var xr={toGeoJSON:function(e){return yr(this,{type:"Point",coordinates:_r(this.getLatLng(),e)})}};function br(e,t){return new dr(e,t)}tr.include(xr),sr.include(xr),nr.include(xr),lr.include({toGeoJSON:function(e){var t=!Di(this._latlngs);return yr(this,{type:(t?"Multi":"")+"LineString",coordinates:Ar(this._latlngs,t?1:0,!1,e)})}}),ur.include({toGeoJSON:function(e){var t=!Di(this._latlngs),i=t&&!Di(this._latlngs[0]),r=Ar(this._latlngs,i?2:t?1:0,!0,e);return t||(r=[r]),yr(this,{type:(i?"Multi":"")+"Polygon",coordinates:r})}}),Zi.include({toMultiPoint:function(e){var t=[];return this.eachLayer(function(i){t.push(i.toGeoJSON(e).geometry.coordinates)}),yr(this,{type:"MultiPoint",coordinates:t})},toGeoJSON:function(e){var t=this.feature&&this.feature.geometry&&this.feature.geometry.type;if("MultiPoint"===t)return this.toMultiPoint(e);var i="GeometryCollection"===t,r=[];return this.eachLayer(function(t){if(t.toGeoJSON){var n=t.toGeoJSON(e);if(i)r.push(n.geometry);else{var o=vr(n);"FeatureCollection"===o.type?r.push.apply(r,o.features):r.push(o)}}}),i?yr(this,{geometries:r,type:"GeometryCollection"}):{type:"FeatureCollection",features:r}}});var wr=br,Tr=$i.extend({options:{opacity:1,alt:"",interactive:!1,crossOrigin:!1,errorOverlayUrl:"",zIndex:1,className:""},initialize:function(e,t,i){this._url=e,this._bounds=U(t),p(this,i)},onAdd:function(){this._image||(this._initImage(),this.options.opacity<1&&this._updateOpacity()),this.options.interactive&&(vt(this._image,"leaflet-interactive"),this.addInteractiveTarget(this._image)),this.getPane().appendChild(this._image),this._reset()},onRemove:function(){mt(this._image),this.options.interactive&&this.removeInteractiveTarget(this._image)},setOpacity:function(e){return this.options.opacity=e,this._image&&this._updateOpacity(),this},setStyle:function(e){return e.opacity&&this.setOpacity(e.opacity),this},bringToFront:function(){return this._map&&_t(this._image),this},bringToBack:function(){return this._map&&At(this._image),this},setUrl:function(e){return this._url=e,this._image&&(this._image.src=e),this},setBounds:function(e){return this._bounds=U(e),this._map&&this._reset(),this},getEvents:function(){var e={zoom:this._reset,viewreset:this._reset};return this._zoomAnimated&&(e.zoomanim=this._animateZoom),e},setZIndex:function(e){return this.options.zIndex=e,this._updateZIndex(),this},getBounds:function(){return this._bounds},getElement:function(){return this._image},_initImage:function(){var e="IMG"===this._url.tagName,t=this._image=e?this._url:ft("img");vt(t,"leaflet-image-layer"),this._zoomAnimated&&vt(t,"leaflet-zoom-animated"),this.options.className&&vt(t,this.options.className),t.onselectstart=c,t.onmousemove=c,t.onload=n(this.fire,this,"load"),t.onerror=n(this._overlayOnError,this,"error"),(this.options.crossOrigin||""===this.options.crossOrigin)&&(t.crossOrigin=!0===this.options.crossOrigin?"":this.options.crossOrigin),this.options.zIndex&&this._updateZIndex(),e?this._url=t.src:(t.src=this._url,t.alt=this.options.alt)},_animateZoom:function(e){var t=this._map.getZoomScale(e.zoom),i=this._map._latLngBoundsToNewLayerBounds(this._bounds,e.zoom,e.center).min;Bt(this._image,i,t)},_reset:function(){var e=this._image,t=new D(this._map.latLngToLayerPoint(this._bounds.getNorthWest()),this._map.latLngToLayerPoint(this._bounds.getSouthEast())),i=t.getSize();St(e,t.min),e.style.width=i.x+"px",e.style.height=i.y+"px"},_updateOpacity:function(){Tt(this._image,this.options.opacity)},_updateZIndex:function(){this._image&&void 0!==this.options.zIndex&&null!==this.options.zIndex&&(this._image.style.zIndex=this.options.zIndex)},_overlayOnError:function(){this.fire("error");var e=this.options.errorOverlayUrl;e&&this._url!==e&&(this._url=e,this._image.src=e)},getCenter:function(){return this._bounds.getCenter()}}),Er=function(e,t,i){return new Tr(e,t,i)},Cr=Tr.extend({options:{autoplay:!0,loop:!0,keepAspectRatio:!0,muted:!1,playsInline:!0},_initImage:function(){var e="VIDEO"===this._url.tagName,t=this._image=e?this._url:ft("video");if(vt(t,"leaflet-image-layer"),this._zoomAnimated&&vt(t,"leaflet-zoom-animated"),this.options.className&&vt(t,this.options.className),t.onselectstart=c,t.onmousemove=c,t.onloadeddata=n(this.fire,this,"load"),e){for(var i=t.getElementsByTagName("source"),r=[],o=0;o0?r:[t.src]}else{_(this._url)||(this._url=[this._url]),!this.options.keepAspectRatio&&Object.prototype.hasOwnProperty.call(t.style,"objectFit")&&(t.style.objectFit="fill"),t.autoplay=!!this.options.autoplay,t.loop=!!this.options.loop,t.muted=!!this.options.muted,t.playsInline=!!this.options.playsInline;for(var s=0;sn?(t.height=n+"px",vt(e,o)):xt(e,o),this._containerWidth=this._container.offsetWidth},_animateZoom:function(e){var t=this._map._latLngToNewLayerPoint(this._latlng,e.zoom,e.center),i=this._getAnchor();St(this._container,t.add(i))},_adjustPan:function(){if(this.options.autoPan)if(this._map._panAnim&&this._map._panAnim.stop(),this._autopanning)this._autopanning=!1;else{var e=this._map,t=parseInt(pt(this._container,"marginBottom"),10)||0,i=this._container.offsetHeight+t,r=this._containerWidth,n=new R(this._containerLeft,-i-this._containerBottom);n._add(It(this._container));var o=e.layerPointToContainerPoint(n),s=k(this.options.autoPanPadding),a=k(this.options.autoPanPaddingTopLeft||s),l=k(this.options.autoPanPaddingBottomRight||s),c=e.getSize(),u=0,h=0;o.x+r+l.x>c.x&&(u=o.x+r-c.x+l.x),o.x-u-a.x<0&&(u=o.x-a.x),o.y+i+l.y>c.y&&(h=o.y+i-c.y+l.y),o.y-h-a.y<0&&(h=o.y-a.y),(u||h)&&(this.options.keepInView&&(this._autopanning=!0),e.fire("autopanstart").panBy([u,h]))}},_getAnchor:function(){return k(this._source&&this._source._getPopupAnchor?this._source._getPopupAnchor():[0,0])}}),Rr=function(e,t){return new Pr(e,t)};ri.mergeOptions({closePopupOnClick:!0}),ri.include({openPopup:function(e,t,i){return this._initOverlay(Pr,e,t,i).openOn(this),this},closePopup:function(e){return(e=arguments.length?e:this._popup)&&e.close(),this}}),$i.include({bindPopup:function(e,t){return this._popup=this._initOverlay(Pr,this._popup,e,t),this._popupHandlersAdded||(this.on({click:this._openPopup,keypress:this._onKeyPress,remove:this.closePopup,move:this._movePopup}),this._popupHandlersAdded=!0),this},unbindPopup:function(){return this._popup&&(this.off({click:this._openPopup,keypress:this._onKeyPress,remove:this.closePopup,move:this._movePopup}),this._popupHandlersAdded=!1,this._popup=null),this},openPopup:function(e){return this._popup&&(this instanceof qi||(this._popup._source=this),this._popup._prepareOpen(e||this._latlng)&&this._popup.openOn(this._map)),this},closePopup:function(){return this._popup&&this._popup.close(),this},togglePopup:function(){return this._popup&&this._popup.toggle(this),this},isPopupOpen:function(){return!!this._popup&&this._popup.isOpen()},setPopupContent:function(e){return this._popup&&this._popup.setContent(e),this},getPopup:function(){return this._popup},_openPopup:function(e){if(this._popup&&this._map){qt(e);var t=e.layer||e.target;this._popup._source!==t||t instanceof rr?(this._popup._source=t,this.openPopup(e.latlng)):this._map.hasLayer(this._popup)?this.closePopup():this.openPopup(e.latlng)}},_movePopup:function(e){this._popup.setLatLng(e.latlng)},_onKeyPress:function(e){13===e.originalEvent.keyCode&&this._openPopup(e)}});var Lr=Mr.extend({options:{pane:"tooltipPane",offset:[0,0],direction:"auto",permanent:!1,sticky:!1,opacity:.9},onAdd:function(e){Mr.prototype.onAdd.call(this,e),this.setOpacity(this.options.opacity),e.fire("tooltipopen",{tooltip:this}),this._source&&(this.addEventParent(this._source),this._source.fire("tooltipopen",{tooltip:this},!0))},onRemove:function(e){Mr.prototype.onRemove.call(this,e),e.fire("tooltipclose",{tooltip:this}),this._source&&(this.removeEventParent(this._source),this._source.fire("tooltipclose",{tooltip:this},!0))},getEvents:function(){var e=Mr.prototype.getEvents.call(this);return this.options.permanent||(e.preclick=this.close),e},_initLayout:function(){var e="leaflet-tooltip "+(this.options.className||"")+" leaflet-zoom-"+(this._zoomAnimated?"animated":"hide");this._contentNode=this._container=ft("div",e),this._container.setAttribute("role","tooltip"),this._container.setAttribute("id","leaflet-tooltip-"+s(this))},_updateLayout:function(){},_adjustPan:function(){},_setPosition:function(e){var t,i,r=this._map,n=this._container,o=r.latLngToContainerPoint(r.getCenter()),s=r.layerPointToContainerPoint(e),a=this.options.direction,l=n.offsetWidth,c=n.offsetHeight,u=k(this.options.offset),h=this._getAnchor();"top"===a?(t=l/2,i=c):"bottom"===a?(t=l/2,i=0):"center"===a?(t=l/2,i=c/2):"right"===a?(t=0,i=c/2):"left"===a?(t=l,i=c/2):s.xthis.options.maxZoom||ir&&this._retainParent(n,o,s,r))},_retainChildren:function(e,t,i,r){for(var n=2*e;n<2*e+2;n++)for(var o=2*t;o<2*t+2;o++){var s=new R(n,o);s.z=i+1;var a=this._tileCoordsToKey(s),l=this._tiles[a];l&&l.active?l.retain=!0:(l&&l.loaded&&(l.retain=!0),i+1this.options.maxZoom||void 0!==this.options.minZoom&&n1)this._setView(e,i);else{for(var h=n.min.y;h<=n.max.y;h++)for(var d=n.min.x;d<=n.max.x;d++){var p=new R(d,h);if(p.z=this._tileZoom,this._isValidTile(p)){var f=this._tiles[this._tileCoordsToKey(p)];f?f.current=!0:s.push(p)}}if(s.sort(function(e,t){return e.distanceTo(o)-t.distanceTo(o)}),0!==s.length){this._loading||(this._loading=!0,this.fire("loading"));var m=document.createDocumentFragment();for(d=0;di.max.x)||!t.wrapLat&&(e.yi.max.y))return!1}if(!this.options.bounds)return!0;var r=this._tileCoordsToBounds(e);return U(this.options.bounds).overlaps(r)},_keyToBounds:function(e){return this._tileCoordsToBounds(this._keyToTileCoords(e))},_tileCoordsToNwSe:function(e){var t=this._map,i=this.getTileSize(),r=e.scaleBy(i),n=r.add(i);return[t.unproject(r,e.z),t.unproject(n,e.z)]},_tileCoordsToBounds:function(e){var t=this._tileCoordsToNwSe(e),i=new z(t[0],t[1]);return this.options.noWrap||(i=this._map.wrapLatLngBounds(i)),i},_tileCoordsToKey:function(e){return e.x+":"+e.y+":"+e.z},_keyToTileCoords:function(e){var t=e.split(":"),i=new R(+t[0],+t[1]);return i.z=+t[2],i},_removeTile:function(e){var t=this._tiles[e];t&&(mt(t.el),delete this._tiles[e],this.fire("tileunload",{tile:t.el,coords:this._keyToTileCoords(e)}))},_initTile:function(e){vt(e,"leaflet-tile");var t=this.getTileSize();e.style.width=t.x+"px",e.style.height=t.y+"px",e.onselectstart=c,e.onmousemove=c,Oe.ielt9&&this.options.opacity<1&&Tt(e,this.options.opacity)},_addTile:function(e,t){var i=this._getTilePos(e),r=this._tileCoordsToKey(e),o=this.createTile(this._wrapCoords(e),n(this._tileReady,this,e));this._initTile(o),this.createTile.length<2&&E(n(this._tileReady,this,e,null,o)),St(o,i),this._tiles[r]={el:o,coords:e,current:!0},t.appendChild(o),this.fire("tileloadstart",{tile:o,coords:e})},_tileReady:function(e,t,i){t&&this.fire("tileerror",{error:t,tile:i,coords:e});var r=this._tileCoordsToKey(e);(i=this._tiles[r])&&(i.loaded=+new Date,this._map._fadeAnimated?(Tt(i.el,0),C(this._fadeFrame),this._fadeFrame=E(this._updateOpacity,this)):(i.active=!0,this._pruneTiles()),t||(vt(i.el,"leaflet-tile-loaded"),this.fire("tileload",{tile:i.el,coords:e})),this._noTilesToLoad()&&(this._loading=!1,this.fire("load"),Oe.ielt9||!this._map._fadeAnimated?E(this._pruneTiles,this):setTimeout(n(this._pruneTiles,this),250)))},_getTilePos:function(e){return e.scaleBy(this.getTileSize()).subtract(this._level.origin)},_wrapCoords:function(e){var t=new R(this._wrapX?l(e.x,this._wrapX):e.x,this._wrapY?l(e.y,this._wrapY):e.y);return t.z=e.z,t},_pxBoundsToTileRange:function(e){var t=this.getTileSize();return new D(e.min.unscaleBy(t).floor(),e.max.unscaleBy(t).ceil().subtract([1,1]))},_noTilesToLoad:function(){for(var e in this._tiles)if(!this._tiles[e].loaded)return!1;return!0}});function zr(e){return new Or(e)}var Ur=Or.extend({options:{minZoom:0,maxZoom:18,subdomains:"abc",errorTileUrl:"",zoomOffset:0,tms:!1,zoomReverse:!1,detectRetina:!1,crossOrigin:!1,referrerPolicy:!1},initialize:function(e,t){this._url=e,(t=p(this,t)).detectRetina&&Oe.retina&&t.maxZoom>0?(t.tileSize=Math.floor(t.tileSize/2),t.zoomReverse?(t.zoomOffset--,t.minZoom=Math.min(t.maxZoom,t.minZoom+1)):(t.zoomOffset++,t.maxZoom=Math.max(t.minZoom,t.maxZoom-1)),t.minZoom=Math.max(0,t.minZoom)):t.zoomReverse?t.minZoom=Math.min(t.maxZoom,t.minZoom):t.maxZoom=Math.max(t.minZoom,t.maxZoom),"string"==typeof t.subdomains&&(t.subdomains=t.subdomains.split("")),this.on("tileunload",this._onTileRemove)},setUrl:function(e,t){return this._url===e&&void 0===t&&(t=!0),this._url=e,t||this.redraw(),this},createTile:function(e,t){var i=document.createElement("img");return zt(i,"load",n(this._tileOnLoad,this,t,i)),zt(i,"error",n(this._tileOnError,this,t,i)),(this.options.crossOrigin||""===this.options.crossOrigin)&&(i.crossOrigin=!0===this.options.crossOrigin?"":this.options.crossOrigin),"string"==typeof this.options.referrerPolicy&&(i.referrerPolicy=this.options.referrerPolicy),i.alt="",i.src=this.getTileUrl(e),i},getTileUrl:function(e){var t={r:Oe.retina?"@2x":"",s:this._getSubdomain(e),x:e.x,y:e.y,z:this._getZoomForUrl()};if(this._map&&!this._map.options.crs.infinite){var r=this._globalTileRange.max.y-e.y;this.options.tms&&(t.y=r),t["-y"]=r}return g(this._url,i(t,this.options))},_tileOnLoad:function(e,t){Oe.ielt9?setTimeout(n(e,this,null,t),0):e(null,t)},_tileOnError:function(e,t,i){var r=this.options.errorTileUrl;r&&t.getAttribute("src")!==r&&(t.src=r),e(i,t)},_onTileRemove:function(e){e.tile.onload=null},_getZoomForUrl:function(){var e=this._tileZoom,t=this.options.maxZoom;return this.options.zoomReverse&&(e=t-e),e+this.options.zoomOffset},_getSubdomain:function(e){var t=Math.abs(e.x+e.y)%this.options.subdomains.length;return this.options.subdomains[t]},_abortLoading:function(){var e,t;for(e in this._tiles)if(this._tiles[e].coords.z!==this._tileZoom&&((t=this._tiles[e].el).onload=c,t.onerror=c,!t.complete)){t.src=y;var i=this._tiles[e].coords;mt(t),delete this._tiles[e],this.fire("tileabort",{tile:t,coords:i})}},_removeTile:function(e){var t=this._tiles[e];if(t)return t.el.setAttribute("src",y),Or.prototype._removeTile.call(this,e)},_tileReady:function(e,t,i){if(this._map&&(!i||i.getAttribute("src")!==y))return Or.prototype._tileReady.call(this,e,t,i)}});function Nr(e,t){return new Ur(e,t)}var Vr=Ur.extend({defaultWmsParams:{service:"WMS",request:"GetMap",layers:"",styles:"",format:"image/jpeg",transparent:!1,version:"1.1.1"},options:{crs:null,uppercase:!1},initialize:function(e,t){this._url=e;var r=i({},this.defaultWmsParams);for(var n in t)n in this.options||(r[n]=t[n]);var o=(t=p(this,t)).detectRetina&&Oe.retina?2:1,s=this.getTileSize();r.width=s.x*o,r.height=s.y*o,this.wmsParams=r},onAdd:function(e){this._crs=this.options.crs||e.options.crs,this._wmsVersion=parseFloat(this.wmsParams.version);var t=this._wmsVersion>=1.3?"crs":"srs";this.wmsParams[t]=this._crs.code,Ur.prototype.onAdd.call(this,e)},getTileUrl:function(e){var t=this._tileCoordsToNwSe(e),i=this._crs,r=O(i.project(t[0]),i.project(t[1])),n=r.min,o=r.max,s=(this._wmsVersion>=1.3&&this._crs===Hi?[n.y,n.x,o.y,o.x]:[n.x,n.y,o.x,o.y]).join(","),a=Ur.prototype.getTileUrl.call(this,e);return a+f(this.wmsParams,a,this.options.uppercase)+(this.options.uppercase?"&BBOX=":"&bbox=")+s},setParams:function(e,t){return i(this.wmsParams,e),t||this.redraw(),this}});function jr(e,t){return new Vr(e,t)}Ur.WMS=Vr,Nr.wms=jr;var Gr=$i.extend({options:{padding:.1},initialize:function(e){p(this,e),s(this),this._layers=this._layers||{}},onAdd:function(){this._container||(this._initContainer(),vt(this._container,"leaflet-zoom-animated")),this.getPane().appendChild(this._container),this._update(),this.on("update",this._updatePaths,this)},onRemove:function(){this.off("update",this._updatePaths,this),this._destroyContainer()},getEvents:function(){var e={viewreset:this._reset,zoom:this._onZoom,moveend:this._update,zoomend:this._onZoomEnd};return this._zoomAnimated&&(e.zoomanim=this._onAnimZoom),e},_onAnimZoom:function(e){this._updateTransform(e.center,e.zoom)},_onZoom:function(){this._updateTransform(this._map.getCenter(),this._map.getZoom())},_updateTransform:function(e,t){var i=this._map.getZoomScale(t,this._zoom),r=this._map.getSize().multiplyBy(.5+this.options.padding),n=this._map.project(this._center,t),o=r.multiplyBy(-i).add(n).subtract(this._map._getNewPixelOrigin(e,t));Oe.any3d?Bt(this._container,o,i):St(this._container,o)},_reset:function(){for(var e in this._update(),this._updateTransform(this._center,this._zoom),this._layers)this._layers[e]._reset()},_onZoomEnd:function(){for(var e in this._layers)this._layers[e]._project()},_updatePaths:function(){for(var e in this._layers)this._layers[e]._update()},_update:function(){var e=this.options.padding,t=this._map.getSize(),i=this._map.containerPointToLayerPoint(t.multiplyBy(-e)).round();this._bounds=new D(i,i.add(t.multiplyBy(1+2*e)).round()),this._center=this._map.getCenter(),this._zoom=this._map.getZoom()}}),Hr=Gr.extend({options:{tolerance:0},getEvents:function(){var e=Gr.prototype.getEvents.call(this);return e.viewprereset=this._onViewPreReset,e},_onViewPreReset:function(){this._postponeUpdatePaths=!0},onAdd:function(){Gr.prototype.onAdd.call(this),this._draw()},_initContainer:function(){var e=this._container=document.createElement("canvas");zt(e,"mousemove",this._onMouseMove,this),zt(e,"click dblclick mousedown mouseup contextmenu",this._onClick,this),zt(e,"mouseout",this._handleMouseOut,this),e._leaflet_disable_events=!0,this._ctx=e.getContext("2d")},_destroyContainer:function(){C(this._redrawRequest),delete this._ctx,mt(this._container),Nt(this._container),delete this._container},_updatePaths:function(){if(!this._postponeUpdatePaths){for(var e in this._redrawBounds=null,this._layers)this._layers[e]._update();this._redraw()}},_update:function(){if(!this._map._animatingZoom||!this._bounds){Gr.prototype._update.call(this);var e=this._bounds,t=this._container,i=e.getSize(),r=Oe.retina?2:1;St(t,e.min),t.width=r*i.x,t.height=r*i.y,t.style.width=i.x+"px",t.style.height=i.y+"px",Oe.retina&&this._ctx.scale(2,2),this._ctx.translate(-e.min.x,-e.min.y),this.fire("update")}},_reset:function(){Gr.prototype._reset.call(this),this._postponeUpdatePaths&&(this._postponeUpdatePaths=!1,this._updatePaths())},_initPath:function(e){this._updateDashArray(e),this._layers[s(e)]=e;var t=e._order={layer:e,prev:this._drawLast,next:null};this._drawLast&&(this._drawLast.next=t),this._drawLast=t,this._drawFirst=this._drawFirst||this._drawLast},_addPath:function(e){this._requestRedraw(e)},_removePath:function(e){var t=e._order,i=t.next,r=t.prev;i?i.prev=r:this._drawLast=r,r?r.next=i:this._drawFirst=i,delete e._order,delete this._layers[s(e)],this._requestRedraw(e)},_updatePath:function(e){this._extendRedrawBounds(e),e._project(),e._update(),this._requestRedraw(e)},_updateStyle:function(e){this._updateDashArray(e),this._requestRedraw(e)},_updateDashArray:function(e){if("string"==typeof e.options.dashArray){var t,i,r=e.options.dashArray.split(/[, ]+/),n=[];for(i=0;i')}}catch(e){}return function(e){return document.createElement("<"+e+' xmlns="urn:schemas-microsoft.com:vml" class="lvml">')}}(),Zr={_initContainer:function(){this._container=ft("div","leaflet-vml-container")},_update:function(){this._map._animatingZoom||(Gr.prototype._update.call(this),this.fire("update"))},_initPath:function(e){var t=e._container=$r("shape");vt(t,"leaflet-vml-shape "+(this.options.className||"")),t.coordsize="1 1",e._path=$r("path"),t.appendChild(e._path),this._updateStyle(e),this._layers[s(e)]=e},_addPath:function(e){var t=e._container;this._container.appendChild(t),e.options.interactive&&e.addInteractiveTarget(t)},_removePath:function(e){var t=e._container;mt(t),e.removeInteractiveTarget(t),delete this._layers[s(e)]},_updateStyle:function(e){var t=e._stroke,i=e._fill,r=e.options,n=e._container;n.stroked=!!r.stroke,n.filled=!!r.fill,r.stroke?(t||(t=e._stroke=$r("stroke")),n.appendChild(t),t.weight=r.weight+"px",t.color=r.color,t.opacity=r.opacity,r.dashArray?t.dashStyle=_(r.dashArray)?r.dashArray.join(" "):r.dashArray.replace(/( *, *)/g," "):t.dashStyle="",t.endcap=r.lineCap.replace("butt","flat"),t.joinstyle=r.lineJoin):t&&(n.removeChild(t),e._stroke=null),r.fill?(i||(i=e._fill=$r("fill")),n.appendChild(i),i.color=r.fillColor||r.color,i.opacity=r.fillOpacity):i&&(n.removeChild(i),e._fill=null)},_updateCircle:function(e){var t=e._point.round(),i=Math.round(e._radius),r=Math.round(e._radiusY||i);this._setPath(e,e._empty()?"M0 0":"AL "+t.x+","+t.y+" "+i+","+r+" 0,23592600")},_setPath:function(e,t){e._path.v=t},_bringToFront:function(e){_t(e._container)},_bringToBack:function(e){At(e._container)}},Wr=Oe.vml?$r:K,qr=Gr.extend({_initContainer:function(){this._container=Wr("svg"),this._container.setAttribute("pointer-events","none"),this._rootGroup=Wr("g"),this._container.appendChild(this._rootGroup)},_destroyContainer:function(){mt(this._container),Nt(this._container),delete this._container,delete this._rootGroup,delete this._svgSize},_update:function(){if(!this._map._animatingZoom||!this._bounds){Gr.prototype._update.call(this);var e=this._bounds,t=e.getSize(),i=this._container;this._svgSize&&this._svgSize.equals(t)||(this._svgSize=t,i.setAttribute("width",t.x),i.setAttribute("height",t.y)),St(i,e.min),i.setAttribute("viewBox",[e.min.x,e.min.y,t.x,t.y].join(" ")),this.fire("update")}},_initPath:function(e){var t=e._path=Wr("path");e.options.className&&vt(t,e.options.className),e.options.interactive&&vt(t,"leaflet-interactive"),this._updateStyle(e),this._layers[s(e)]=e},_addPath:function(e){this._rootGroup||this._initContainer(),this._rootGroup.appendChild(e._path),e.addInteractiveTarget(e._path)},_removePath:function(e){mt(e._path),e.removeInteractiveTarget(e._path),delete this._layers[s(e)]},_updatePath:function(e){e._project(),e._update()},_updateStyle:function(e){var t=e._path,i=e.options;t&&(i.stroke?(t.setAttribute("stroke",i.color),t.setAttribute("stroke-opacity",i.opacity),t.setAttribute("stroke-width",i.weight),t.setAttribute("stroke-linecap",i.lineCap),t.setAttribute("stroke-linejoin",i.lineJoin),i.dashArray?t.setAttribute("stroke-dasharray",i.dashArray):t.removeAttribute("stroke-dasharray"),i.dashOffset?t.setAttribute("stroke-dashoffset",i.dashOffset):t.removeAttribute("stroke-dashoffset")):t.setAttribute("stroke","none"),i.fill?(t.setAttribute("fill",i.fillColor||i.color),t.setAttribute("fill-opacity",i.fillOpacity),t.setAttribute("fill-rule",i.fillRule||"evenodd")):t.setAttribute("fill","none"))},_updatePoly:function(e,t){this._setPath(e,X(e._parts,t))},_updateCircle:function(e){var t=e._point,i=Math.max(Math.round(e._radius),1),r="a"+i+","+(Math.max(Math.round(e._radiusY),1)||i)+" 0 1,0 ",n=e._empty()?"M0 0":"M"+(t.x-i)+","+t.y+r+2*i+",0 "+r+2*-i+",0 ";this._setPath(e,n)},_setPath:function(e,t){e._path.setAttribute("d",t)},_bringToFront:function(e){_t(e._path)},_bringToBack:function(e){At(e._path)}});function Kr(e){return Oe.svg||Oe.vml?new qr(e):null}Oe.vml&&qr.include(Zr),ri.include({getRenderer:function(e){var t=e.options.renderer||this._getPaneRenderer(e.options.pane)||this.options.renderer||this._renderer;return t||(t=this._renderer=this._createRenderer()),this.hasLayer(t)||this.addLayer(t),t},_getPaneRenderer:function(e){if("overlayPane"===e||void 0===e)return!1;var t=this._paneRenderers[e];return void 0===t&&(t=this._createRenderer({pane:e}),this._paneRenderers[e]=t),t},_createRenderer:function(e){return this.options.preferCanvas&&Qr(e)||Kr(e)}});var Xr=ur.extend({initialize:function(e,t){ur.prototype.initialize.call(this,this._boundsToLatLngs(e),t)},setBounds:function(e){return this.setLatLngs(this._boundsToLatLngs(e))},_boundsToLatLngs:function(e){return[(e=U(e)).getSouthWest(),e.getNorthWest(),e.getNorthEast(),e.getSouthEast()]}});function Jr(e,t){return new Xr(e,t)}qr.create=Wr,qr.pointsToPath=X,dr.geometryToLayer=pr,dr.coordsToLatLng=mr,dr.coordsToLatLngs=gr,dr.latLngToCoords=_r,dr.latLngsToCoords=Ar,dr.getFeature=yr,dr.asFeature=vr,ri.mergeOptions({boxZoom:!0});var Yr=gi.extend({initialize:function(e){this._map=e,this._container=e._container,this._pane=e._panes.overlayPane,this._resetStateTimeout=0,e.on("unload",this._destroy,this)},addHooks:function(){zt(this._container,"mousedown",this._onMouseDown,this)},removeHooks:function(){Nt(this._container,"mousedown",this._onMouseDown,this)},moved:function(){return this._moved},_destroy:function(){mt(this._pane),delete this._pane},_resetState:function(){this._resetStateTimeout=0,this._moved=!1},_clearDeferredResetState:function(){0!==this._resetStateTimeout&&(clearTimeout(this._resetStateTimeout),this._resetStateTimeout=0)},_onMouseDown:function(e){if(!e.shiftKey||1!==e.which&&1!==e.button)return!1;this._clearDeferredResetState(),this._resetState(),nt(),Pt(),this._startPoint=this._map.mouseEventToContainerPoint(e),zt(document,{contextmenu:qt,mousemove:this._onMouseMove,mouseup:this._onMouseUp,keydown:this._onKeyDown},this)},_onMouseMove:function(e){this._moved||(this._moved=!0,this._box=ft("div","leaflet-zoom-box",this._container),vt(this._container,"leaflet-crosshair"),this._map.fire("boxzoomstart")),this._point=this._map.mouseEventToContainerPoint(e);var t=new D(this._point,this._startPoint),i=t.getSize();St(this._box,t.min),this._box.style.width=i.x+"px",this._box.style.height=i.y+"px"},_finish:function(){this._moved&&(mt(this._box),xt(this._container,"leaflet-crosshair")),ot(),Rt(),Nt(document,{contextmenu:qt,mousemove:this._onMouseMove,mouseup:this._onMouseUp,keydown:this._onKeyDown},this)},_onMouseUp:function(e){if((1===e.which||1===e.button)&&(this._finish(),this._moved)){this._clearDeferredResetState(),this._resetStateTimeout=setTimeout(n(this._resetState,this),0);var t=new z(this._map.containerPointToLatLng(this._startPoint),this._map.containerPointToLatLng(this._point));this._map.fitBounds(t).fire("boxzoomend",{boxZoomBounds:t})}},_onKeyDown:function(e){27===e.keyCode&&(this._finish(),this._clearDeferredResetState(),this._resetState())}});ri.addInitHook("addHandler","boxZoom",Yr),ri.mergeOptions({doubleClickZoom:!0});var en=gi.extend({addHooks:function(){this._map.on("dblclick",this._onDoubleClick,this)},removeHooks:function(){this._map.off("dblclick",this._onDoubleClick,this)},_onDoubleClick:function(e){var t=this._map,i=t.getZoom(),r=t.options.zoomDelta,n=e.originalEvent.shiftKey?i-r:i+r;"center"===t.options.doubleClickZoom?t.setZoom(n):t.setZoomAround(e.containerPoint,n)}});ri.addInitHook("addHandler","doubleClickZoom",en),ri.mergeOptions({dragging:!0,inertia:!0,inertiaDeceleration:3400,inertiaMaxSpeed:1/0,easeLinearity:.2,worldCopyJump:!1,maxBoundsViscosity:0});var tn=gi.extend({addHooks:function(){if(!this._draggable){var e=this._map;this._draggable=new yi(e._mapPane,e._container),this._draggable.on({dragstart:this._onDragStart,drag:this._onDrag,dragend:this._onDragEnd},this),this._draggable.on("predrag",this._onPreDragLimit,this),e.options.worldCopyJump&&(this._draggable.on("predrag",this._onPreDragWrap,this),e.on("zoomend",this._onZoomEnd,this),e.whenReady(this._onZoomEnd,this))}vt(this._map._container,"leaflet-grab leaflet-touch-drag"),this._draggable.enable(),this._positions=[],this._times=[]},removeHooks:function(){xt(this._map._container,"leaflet-grab"),xt(this._map._container,"leaflet-touch-drag"),this._draggable.disable()},moved:function(){return this._draggable&&this._draggable._moved},moving:function(){return this._draggable&&this._draggable._moving},_onDragStart:function(){var e=this._map;if(e._stop(),this._map.options.maxBounds&&this._map.options.maxBoundsViscosity){var t=U(this._map.options.maxBounds);this._offsetLimit=O(this._map.latLngToContainerPoint(t.getNorthWest()).multiplyBy(-1),this._map.latLngToContainerPoint(t.getSouthEast()).multiplyBy(-1).add(this._map.getSize())),this._viscosity=Math.min(1,Math.max(0,this._map.options.maxBoundsViscosity))}else this._offsetLimit=null;e.fire("movestart").fire("dragstart"),e.options.inertia&&(this._positions=[],this._times=[])},_onDrag:function(e){if(this._map.options.inertia){var t=this._lastTime=+new Date,i=this._lastPos=this._draggable._absPos||this._draggable._newPos;this._positions.push(i),this._times.push(t),this._prunePositions(t)}this._map.fire("move",e).fire("drag",e)},_prunePositions:function(e){for(;this._positions.length>1&&e-this._times[0]>50;)this._positions.shift(),this._times.shift()},_onZoomEnd:function(){var e=this._map.getSize().divideBy(2),t=this._map.latLngToLayerPoint([0,0]);this._initialWorldOffset=t.subtract(e).x,this._worldWidth=this._map.getPixelWorldBounds().getSize().x},_viscousLimit:function(e,t){return e-(e-t)*this._viscosity},_onPreDragLimit:function(){if(this._viscosity&&this._offsetLimit){var e=this._draggable._newPos.subtract(this._draggable._startPos),t=this._offsetLimit;e.xt.max.x&&(e.x=this._viscousLimit(e.x,t.max.x)),e.y>t.max.y&&(e.y=this._viscousLimit(e.y,t.max.y)),this._draggable._newPos=this._draggable._startPos.add(e)}},_onPreDragWrap:function(){var e=this._worldWidth,t=Math.round(e/2),i=this._initialWorldOffset,r=this._draggable._newPos.x,n=(r-t+i)%e+t-i,o=(r+t+i)%e-t-i,s=Math.abs(n+i)0?o:-o))-t;this._delta=0,this._startTime=null,s&&("center"===e.options.scrollWheelZoom?e.setZoom(t+s):e.setZoomAround(this._lastMousePos,t+s))}});ri.addInitHook("addHandler","scrollWheelZoom",nn);var on=600;ri.mergeOptions({tapHold:Oe.touchNative&&Oe.safari&&Oe.mobile,tapTolerance:15});var sn=gi.extend({addHooks:function(){zt(this._map._container,"touchstart",this._onDown,this)},removeHooks:function(){Nt(this._map._container,"touchstart",this._onDown,this)},_onDown:function(e){if(clearTimeout(this._holdTimeout),1===e.touches.length){var t=e.touches[0];this._startPos=this._newPos=new R(t.clientX,t.clientY),this._holdTimeout=setTimeout(n(function(){this._cancel(),this._isTapValid()&&(zt(document,"touchend",Wt),zt(document,"touchend touchcancel",this._cancelClickPrevent),this._simulateEvent("contextmenu",t))},this),on),zt(document,"touchend touchcancel contextmenu",this._cancel,this),zt(document,"touchmove",this._onMove,this)}},_cancelClickPrevent:function e(){Nt(document,"touchend",Wt),Nt(document,"touchend touchcancel",e)},_cancel:function(){clearTimeout(this._holdTimeout),Nt(document,"touchend touchcancel contextmenu",this._cancel,this),Nt(document,"touchmove",this._onMove,this)},_onMove:function(e){var t=e.touches[0];this._newPos=new R(t.clientX,t.clientY)},_isTapValid:function(){return this._newPos.distanceTo(this._startPos)<=this._map.options.tapTolerance},_simulateEvent:function(e,t){var i=new MouseEvent(e,{bubbles:!0,cancelable:!0,view:window,screenX:t.screenX,screenY:t.screenY,clientX:t.clientX,clientY:t.clientY});i._simulated=!0,t.target.dispatchEvent(i)}});ri.addInitHook("addHandler","tapHold",sn),ri.mergeOptions({touchZoom:Oe.touch,bounceAtZoomLimits:!0});var an=gi.extend({addHooks:function(){vt(this._map._container,"leaflet-touch-zoom"),zt(this._map._container,"touchstart",this._onTouchStart,this)},removeHooks:function(){xt(this._map._container,"leaflet-touch-zoom"),Nt(this._map._container,"touchstart",this._onTouchStart,this)},_onTouchStart:function(e){var t=this._map;if(e.touches&&2===e.touches.length&&!t._animatingZoom&&!this._zooming){var i=t.mouseEventToContainerPoint(e.touches[0]),r=t.mouseEventToContainerPoint(e.touches[1]);this._centerPoint=t.getSize()._divideBy(2),this._startLatLng=t.containerPointToLatLng(this._centerPoint),"center"!==t.options.touchZoom&&(this._pinchStartLatLng=t.containerPointToLatLng(i.add(r)._divideBy(2))),this._startDist=i.distanceTo(r),this._startZoom=t.getZoom(),this._moved=!1,this._zooming=!0,t._stop(),zt(document,"touchmove",this._onTouchMove,this),zt(document,"touchend touchcancel",this._onTouchEnd,this),Wt(e)}},_onTouchMove:function(e){if(e.touches&&2===e.touches.length&&this._zooming){var t=this._map,i=t.mouseEventToContainerPoint(e.touches[0]),r=t.mouseEventToContainerPoint(e.touches[1]),o=i.distanceTo(r)/this._startDist;if(this._zoom=t.getScaleZoom(o,this._startZoom),!t.options.bounceAtZoomLimits&&(this._zoomt.getMaxZoom()&&o>1)&&(this._zoom=t._limitZoom(this._zoom)),"center"===t.options.touchZoom){if(this._center=this._startLatLng,1===o)return}else{var s=i._add(r)._divideBy(2)._subtract(this._centerPoint);if(1===o&&0===s.x&&0===s.y)return;this._center=t.unproject(t.project(this._pinchStartLatLng,this._zoom).subtract(s),this._zoom)}this._moved||(t._moveStart(!0,!1),this._moved=!0),C(this._animRequest);var a=n(t._move,t,this._center,this._zoom,{pinch:!0,round:!1},void 0);this._animRequest=E(a,this,!0),Wt(e)}},_onTouchEnd:function(){this._moved&&this._zooming?(this._zooming=!1,C(this._animRequest),Nt(document,"touchmove",this._onTouchMove,this),Nt(document,"touchend touchcancel",this._onTouchEnd,this),this._map.options.zoomAnimation?this._map._animateZoom(this._center,this._map._limitZoom(this._zoom),!0,this._map.options.zoomSnap):this._map._resetView(this._center,this._map._limitZoom(this._zoom))):this._zooming=!1}});ri.addInitHook("addHandler","touchZoom",an),ri.BoxZoom=Yr,ri.DoubleClickZoom=en,ri.Drag=tn,ri.Keyboard=rn,ri.ScrollWheelZoom=nn,ri.TapHold=sn,ri.TouchZoom=an,e.Bounds=D,e.Browser=Oe,e.CRS=j,e.Canvas=Hr,e.Circle=sr,e.CircleMarker=nr,e.Class=S,e.Control=oi,e.DivIcon=kr,e.DivOverlay=Mr,e.DomEvent=ti,e.DomUtil=Ot,e.Draggable=yi,e.Evented=P,e.FeatureGroup=qi,e.GeoJSON=dr,e.GridLayer=Or,e.Handler=gi,e.Icon=Xi,e.ImageOverlay=Tr,e.LatLng=N,e.LatLngBounds=z,e.Layer=$i,e.LayerGroup=Zi,e.LineUtil=Ui,e.Map=ri,e.Marker=tr,e.Mixin=_i,e.Path=rr,e.Point=R,e.PolyUtil=Ti,e.Polygon=ur,e.Polyline=lr,e.Popup=Pr,e.PosAnimation=ii,e.Projection=ji,e.Rectangle=Xr,e.Renderer=Gr,e.SVG=qr,e.SVGOverlay=Sr,e.TileLayer=Ur,e.Tooltip=Lr,e.Transformation=$,e.Util=B,e.VideoOverlay=Cr,e.bind=n,e.bounds=O,e.canvas=Qr,e.circle=ar,e.circleMarker=or,e.control=si,e.divIcon=Dr,e.extend=i,e.featureGroup=Ki,e.geoJSON=br,e.geoJson=wr,e.gridLayer=zr,e.icon=Ji,e.imageOverlay=Er,e.latLng=V,e.latLngBounds=U,e.layerGroup=Wi,e.map=ni,e.marker=ir,e.point=k,e.polygon=hr,e.polyline=cr,e.popup=Rr,e.rectangle=Jr,e.setOptions=p,e.stamp=s,e.svg=Kr,e.svgOverlay=Ir,e.tileLayer=Nr,e.tooltip=Fr,e.transformation=Z,e.version=t,e.videoOverlay=Br;var ln=window.L;e.noConflict=function(){return window.L=ln,this},window.L=e}(lH.exports);class hH extends ge{constructor(e){super(),me(this,e,uH,cH,a,{id:0,center:1,zoom:2,mapStyle:3,numberOfMaps:4,overrideLayer:5,onMapMount:6})}}var dH={exports:{}};function pH(e){let t,r;const n=[{mapStyle:e[0]},{overrideLayer:e[1]},e[2]];let o={};for(let e=0;e{t=i(i({},t),f(e)),r(2,a=m(t,n)),"mapStyle"in e&&r(0,l=e.mapStyle)},e.$$.update=()=>{1&e.$$.dirty&&r(3,({url:s}=l),s),8&e.$$.dirty&&r(1,o=(e=>null!=o&&o.options.scene===e?o:dH.exports.leafletLayer({scene:e,webGLContextOptions:{preserveDrawingBuffer:!0}}))(s))},[l,o,a,s,function(t){Q.call(this,e,t)}]}dH.exports=function(){var e,t,i={};function r(r,n){if(e)if(t){var o="var shared_chunk = {}; ("+e+")(shared_chunk); ("+t+")(shared_chunk);",s={};e(s),(i=n(s)).workerURL=window.URL.createObjectURL(new Blob([o],{type:"text/javascript"}))}else t=n;else e=n}r(["exports"],function(e){function t(e,t){return e(t={exports:{}},t.exports),t.exports}var i=t(function(e){var t=e.exports={version:"2.6.3"};"number"==typeof __e&&(__e=t)}),r=(i.version,t(function(e){var t=e.exports="undefined"!=typeof window&&window.Math==Math?window:"undefined"!=typeof self&&self.Math==Math?self:Function("return this")();"number"==typeof __g&&(__g=t)})),n=t(function(e){var t=r["__core-js_shared__"]||(r["__core-js_shared__"]={});(e.exports=function(e,i){return t[e]||(t[e]=void 0!==i?i:{})})("versions",[]).push({version:i.version,mode:"global",copyright:"© 2019 Denis Pushkarev (zloirock.ru)"})}),o=0,s=Math.random(),a=function(e){return"Symbol(".concat(void 0===e?"":e,")_",(++o+s).toString(36))},l=t(function(e){var t=n("wks"),i=r.Symbol,o="function"==typeof i;(e.exports=function(e){return t[e]||(t[e]=o&&i[e]||(o?i:a)("Symbol."+e))}).store=t}),c=function(e){return"object"==typeof e?null!==e:"function"==typeof e},u=function(e){if(!c(e))throw TypeError(e+" is not an object!");return e},h=function(e){try{return!!e()}catch(e){return!0}},d=!h(function(){return 7!=Object.defineProperty({},"a",{get:function(){return 7}}).a}),p=r.document,f=c(p)&&c(p.createElement),m=function(e){return f?p.createElement(e):{}},g=!d&&!h(function(){return 7!=Object.defineProperty(m("div"),"a",{get:function(){return 7}}).a}),_=function(e,t){if(!c(e))return e;var i,r;if(t&&"function"==typeof(i=e.toString)&&!c(r=i.call(e)))return r;if("function"==typeof(i=e.valueOf)&&!c(r=i.call(e)))return r;if(!t&&"function"==typeof(i=e.toString)&&!c(r=i.call(e)))return r;throw TypeError("Can't convert object to primitive value")},A=Object.defineProperty,y={f:d?Object.defineProperty:function(e,t,i){if(u(e),t=_(t,!0),u(i),g)try{return A(e,t,i)}catch(e){}if("get"in i||"set"in i)throw TypeError("Accessors not supported!");return"value"in i&&(e[t]=i.value),e}},v=function(e,t){return{enumerable:!(1&e),configurable:!(2&e),writable:!(4&e),value:t}},x=d?function(e,t,i){return y.f(e,t,v(1,i))}:function(e,t,i){return e[t]=i,e},b=l("unscopables"),w=Array.prototype;null==w[b]&&x(w,b,{});var T=function(e){w[b][e]=!0},E=function(e,t){return{value:t,done:!!e}},C={},B={}.toString,S=function(e){return B.call(e).slice(8,-1)},I=Object("z").propertyIsEnumerable(0)?Object:function(e){return"String"==S(e)?e.split(""):Object(e)},M=function(e){if(null==e)throw TypeError("Can't call method on "+e);return e},P=function(e){return I(M(e))},R={}.hasOwnProperty,L=function(e,t){return R.call(e,t)},F=t(function(e){var t=a("src"),n=Function.toString,o=(""+n).split("toString");i.inspectSource=function(e){return n.call(e)},(e.exports=function(e,i,n,s){var a="function"==typeof n;a&&(L(n,"name")||x(n,"name",i)),e[i]!==n&&(a&&(L(n,t)||x(n,t,e[i]?""+e[i]:o.join(String(i)))),e===r?e[i]=n:s?e[i]?e[i]=n:x(e,i,n):(delete e[i],x(e,i,n)))})(Function.prototype,"toString",function(){return"function"==typeof this&&this[t]||n.call(this)})}),k=function(e){if("function"!=typeof e)throw TypeError(e+" is not a function!");return e},D=function(e,t,i){if(k(e),void 0===t)return e;switch(i){case 1:return function(i){return e.call(t,i)};case 2:return function(i,r){return e.call(t,i,r)};case 3:return function(i,r,n){return e.call(t,i,r,n)}}return function(){return e.apply(t,arguments)}},O=function(e,t,n){var o,s,a,l,c=e&O.F,u=e&O.G,h=e&O.S,d=e&O.P,p=e&O.B,f=u?r:h?r[t]||(r[t]={}):(r[t]||{}).prototype,m=u?i:i[t]||(i[t]={}),g=m.prototype||(m.prototype={});for(o in u&&(n=t),n)a=((s=!c&&f&&void 0!==f[o])?f:n)[o],l=p&&s?D(a,r):d&&"function"==typeof a?D(Function.call,a):a,f&&F(f,o,a,e&O.U),m[o]!=a&&x(m,o,l),d&&g[o]!=a&&(g[o]=a)};r.core=i,O.F=1,O.G=2,O.S=4,O.P=8,O.B=16,O.W=32,O.U=64,O.R=128;var z=O,U=Math.ceil,N=Math.floor,V=function(e){return isNaN(e=+e)?0:(e>0?N:U)(e)},j=Math.min,G=function(e){return e>0?j(V(e),9007199254740991):0},H=Math.max,Q=Math.min,$=function(e,t){return(e=V(e))<0?H(e+t,0):Q(e,t)},Z=function(e){return function(t,i,r){var n,o=P(t),s=G(o.length),a=$(r,s);if(e&&i!=i){for(;s>a;)if((n=o[a++])!=n)return!0}else for(;s>a;a++)if((e||a in o)&&o[a]===i)return e||a||0;return!e&&-1}},W=n("keys"),q=function(e){return W[e]||(W[e]=a(e))},K=Z(!1),X=q("IE_PROTO"),J=function(e,t){var i,r=P(e),n=0,o=[];for(i in r)i!=X&&L(r,i)&&o.push(i);for(;t.length>n;)L(r,i=t[n++])&&(~K(o,i)||o.push(i));return o},Y="constructor,hasOwnProperty,isPrototypeOf,propertyIsEnumerable,toLocaleString,toString,valueOf".split(","),ee=Object.keys||function(e){return J(e,Y)},te=d?Object.defineProperties:function(e,t){u(e);for(var i,r=ee(t),n=r.length,o=0;n>o;)y.f(e,i=r[o++],t[i]);return e},ie=r.document,re=ie&&ie.documentElement,ne=q("IE_PROTO"),oe=function(){},se=function(){var e,t=m("iframe"),i=Y.length;for(t.style.display="none",re.appendChild(t),t.src="javascript:",(e=t.contentWindow.document).open(),e.write("\";\n unsubscribe = listen(window, 'message', (event) => {\n if (event.source === iframe.contentWindow)\n fn();\n });\n }\n else {\n iframe.src = 'about:blank';\n iframe.onload = () => {\n unsubscribe = listen(iframe.contentWindow, 'resize', fn);\n // make sure an initial resize event is fired _after_ the iframe is loaded (which is asynchronous)\n // see https://github.com/sveltejs/svelte/issues/4233\n fn();\n };\n }\n append(node, iframe);\n return () => {\n if (crossorigin) {\n unsubscribe();\n }\n else if (unsubscribe && iframe.contentWindow) {\n unsubscribe();\n }\n detach(iframe);\n };\n}\nconst resize_observer_content_box = /* @__PURE__ */ new ResizeObserverSingleton({ box: 'content-box' });\nconst resize_observer_border_box = /* @__PURE__ */ new ResizeObserverSingleton({ box: 'border-box' });\nconst resize_observer_device_pixel_content_box = /* @__PURE__ */ new ResizeObserverSingleton({ box: 'device-pixel-content-box' });\nfunction toggle_class(element, name, toggle) {\n element.classList[toggle ? 'add' : 'remove'](name);\n}\nfunction custom_event(type, detail, { bubbles = false, cancelable = false } = {}) {\n const e = document.createEvent('CustomEvent');\n e.initCustomEvent(type, bubbles, cancelable, detail);\n return e;\n}\nfunction query_selector_all(selector, parent = document.body) {\n return Array.from(parent.querySelectorAll(selector));\n}\nfunction head_selector(nodeId, head) {\n const result = [];\n let started = 0;\n for (const node of head.childNodes) {\n if (node.nodeType === 8 /* comment node */) {\n const comment = node.textContent.trim();\n if (comment === `HEAD_${nodeId}_END`) {\n started -= 1;\n result.push(node);\n }\n else if (comment === `HEAD_${nodeId}_START`) {\n started += 1;\n result.push(node);\n }\n }\n else if (started > 0) {\n result.push(node);\n }\n }\n return result;\n}\nclass HtmlTag {\n constructor(is_svg = false) {\n this.is_svg = false;\n this.is_svg = is_svg;\n this.e = this.n = null;\n }\n c(html) {\n this.h(html);\n }\n m(html, target, anchor = null) {\n if (!this.e) {\n if (this.is_svg)\n this.e = svg_element(target.nodeName);\n /** #7364 target for